1
>
/*---------------------------------------------------------------------------------------------
agentModelByokMeta.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import type { SessionModelInfo } from './state/protocol/state.js';
7
>
import type { IAgentModelInfo } from './agentService.js';
8
>
9
>
/**
10
>
* Well-known key for the renderer LM-service identifier of the BYOK model an
11
>
* agent-host model is a copy of, carried under a model's open `_meta` bag (see
12
>
* {@link IAgentModelInfo._meta} / {@link SessionModelInfo._meta}).
13
>
*
14
>
* A renderer BYOK model is registered under `<vendor>/<group>/<id>` (or `<vendor>/<id>`
15
>
* without a configured group) — exactly the id the "Manage Models" view keys visibility
16
>
* by. That identifier is not otherwise recoverable once the model round-trips the
17
>
* agent-host bridge, so the renderer attaches it here so the chat model picker can honour
18
>
* the model's visibility toggle.
19
>
*/
20
>
export const BYOK_MODEL_IDENTIFIER_META_KEY = 'byokModelIdentifier';
21
>
22
>
/**
23
>
* Builds a `_meta` payload carrying the BYOK model identifier, or `undefined` when there
24
>
* is none so callers can avoid attaching an empty `_meta` object.
25
>
*/
26
>
export function createAgentModelByokMeta(modelIdentifier: string | undefined): Record<string, unknown> | undefined {
27
return modelIdentifier !== undefined ? { [BYOK_MODEL_IDENTIFIER_META_KEY]: modelIdentifier } : undefined;
28
}
30
>
/**
31
>
* Reads the BYOK model identifier from a model's open `_meta` bag, ignoring unrelated
32
>
* keys and values of the wrong type.
33
>
*/
34
>
export function readAgentModelByokIdentifier(model: IAgentModelInfo | SessionModelInfo): string | undefined {
35
const meta = model._meta;
36
if (!meta) {