@bastani/pi-ai 0.9.70 → 0.9.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/README.md +5 -2
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +249 -17
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/github-copilot-headers.d.ts +11 -0
- package/dist/api/github-copilot-headers.d.ts.map +1 -1
- package/dist/api/github-copilot-headers.js +18 -1
- package/dist/api/github-copilot-headers.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +7 -3
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/simple-options.d.ts +1 -0
- package/dist/api/simple-options.d.ts.map +1 -1
- package/dist/api/simple-options.js +16 -2
- package/dist/api/simple-options.js.map +1 -1
- package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
- package/dist/auth/oauth/github-copilot.js +4 -58
- package/dist/auth/oauth/github-copilot.js.map +1 -1
- package/dist/models.d.ts +8 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +12 -0
- package/dist/models.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +3 -0
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +3 -0
- package/dist/providers/compat-schema.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/github-copilot-account.d.ts +18 -0
- package/dist/providers/github-copilot-account.d.ts.map +1 -0
- package/dist/providers/github-copilot-account.js +57 -0
- package/dist/providers/github-copilot-account.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +32 -2
- package/dist/providers/github-copilot.d.ts.map +1 -1
- package/dist/providers/github-copilot.js +263 -7
- package/dist/providers/github-copilot.js.map +1 -1
- package/dist/types.d.ts +18 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/transcript.d.ts +1 -1
- package/dist/utils/transcript.js +1 -1
- package/dist/utils/transcript.js.map +1 -1
- package/dist/utils/validation.d.ts +9 -4
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +67 -19
- package/dist/utils/validation.js.map +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The Copilot host for individual accounts, and the default when nothing names another. */
|
|
2
|
+
export declare const GITHUB_COPILOT_INDIVIDUAL_BASE_URL = "https://api.individual.githubcopilot.com";
|
|
3
|
+
/** The model IDs a login saves from the account's `GET /models` list. */
|
|
4
|
+
export interface GitHubCopilotAccountModelLists {
|
|
5
|
+
/** Models the account offers in its model picker. */
|
|
6
|
+
availableModelIds: string[];
|
|
7
|
+
/** Fast IDs the account lists; they are not picker entries. */
|
|
8
|
+
fastModelIds: string[];
|
|
9
|
+
/** Built-in models whose policy the account has not configured yet, which a login enables. */
|
|
10
|
+
policyModelIds: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Read the model lists a login saves, and its availability filter checks, from a `GET /models`
|
|
14
|
+
* response of the host at `baseUrl`. A login and a catalog refresh both use these rules, so either
|
|
15
|
+
* read of the account's list leaves the same lists.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseGitHubCopilotAccountModelLists(raw: unknown, baseUrl: string): GitHubCopilotAccountModelLists;
|
|
18
|
+
//# sourceMappingURL=github-copilot-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-copilot-account.d.ts","sourceRoot":"","sources":["../../src/providers/github-copilot-account.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,eAAO,MAAM,kCAAkC,6CAA6C,CAAC;AAE7F,yEAAyE;AACzE,MAAM,WAAW,8BAA8B;IAC9C,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,+DAA+D;IAC/D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,8FAA8F;IAC9F,cAAc,EAAE,MAAM,EAAE,CAAC;CACzB;AAMD;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,8BAA8B,CAiDjH"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { GITHUB_COPILOT_MODELS } from "./github-copilot.models.js";
|
|
2
|
+
/** The Copilot host for individual accounts, and the default when nothing names another. */
|
|
3
|
+
export const GITHUB_COPILOT_INDIVIDUAL_BASE_URL = "https://api.individual.githubcopilot.com";
|
|
4
|
+
function asRecord(value) {
|
|
5
|
+
return value && typeof value === "object" ? value : undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Read the model lists a login saves, and its availability filter checks, from a `GET /models`
|
|
9
|
+
* response of the host at `baseUrl`. A login and a catalog refresh both use these rules, so either
|
|
10
|
+
* read of the account's list leaves the same lists.
|
|
11
|
+
*/
|
|
12
|
+
export function parseGitHubCopilotAccountModelLists(raw, baseUrl) {
|
|
13
|
+
const data = asRecord(raw)?.data;
|
|
14
|
+
if (!Array.isArray(data)) {
|
|
15
|
+
throw new Error("Invalid Copilot models response");
|
|
16
|
+
}
|
|
17
|
+
// Some Individual accounts return false for every picker flag despite explicit enabled policies.
|
|
18
|
+
// Limit the fallback to that endpoint so other account types keep strict picker semantics.
|
|
19
|
+
const allowPolicyFallback = baseUrl === GITHUB_COPILOT_INDIVIDUAL_BASE_URL;
|
|
20
|
+
const accountModels = data.flatMap((rawItem) => {
|
|
21
|
+
const item = asRecord(rawItem);
|
|
22
|
+
const id = item?.id;
|
|
23
|
+
if (!item || typeof id !== "string")
|
|
24
|
+
return [];
|
|
25
|
+
const capabilities = asRecord(item.capabilities);
|
|
26
|
+
const supports = asRecord(capabilities?.supports);
|
|
27
|
+
if (supports?.tool_calls === false)
|
|
28
|
+
return [];
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
id,
|
|
32
|
+
pickerEnabled: item.model_picker_enabled === true,
|
|
33
|
+
policyState: asRecord(item.policy)?.state,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
});
|
|
37
|
+
const pickerModelIds = accountModels
|
|
38
|
+
.filter((model) => model.pickerEnabled && model.policyState !== "disabled")
|
|
39
|
+
.map((model) => model.id);
|
|
40
|
+
const usePolicyFallback = allowPolicyFallback && pickerModelIds.length === 0;
|
|
41
|
+
const availableModelIds = pickerModelIds.length > 0 || !allowPolicyFallback
|
|
42
|
+
? pickerModelIds
|
|
43
|
+
: accountModels
|
|
44
|
+
.filter((model) => !model.id.endsWith("-fast") && model.policyState === "enabled")
|
|
45
|
+
.map((model) => model.id);
|
|
46
|
+
// Fast siblings are not picker entries: a fast ID the account lists is entitled unless its policy is disabled.
|
|
47
|
+
const fastModelIds = accountModels
|
|
48
|
+
.filter((model) => model.id.endsWith("-fast") && model.policyState !== "disabled")
|
|
49
|
+
.map((model) => model.id);
|
|
50
|
+
const policyModelIds = accountModels
|
|
51
|
+
.filter((model) => model.policyState === "unconfigured" &&
|
|
52
|
+
Object.hasOwn(GITHUB_COPILOT_MODELS, model.id) &&
|
|
53
|
+
(model.pickerEnabled || usePolicyFallback))
|
|
54
|
+
.map((model) => model.id);
|
|
55
|
+
return { availableModelIds, fastModelIds, policyModelIds };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=github-copilot-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-copilot-account.js","sourceRoot":"","sources":["../../src/providers/github-copilot-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,4FAA4F;AAC5F,MAAM,CAAC,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AC;AAC5D,CAAC","sourcesContent":["import { GITHUB_COPILOT_MODELS } from \"./github-copilot.models.ts\";\n\n/** The Copilot host for individual accounts, and the default when nothing names another. */\nexport const GITHUB_COPILOT_INDIVIDUAL_BASE_URL = \"https://api.individual.githubcopilot.com\";\n\n/** The model IDs a login saves from the account's `GET /models` list. */\nexport interface GitHubCopilotAccountModelLists {\n\t/** Models the account offers in its model picker. */\n\tavailableModelIds: string[];\n\t/** Fast IDs the account lists; they are not picker entries. */\n\tfastModelIds: string[];\n\t/** Built-in models whose policy the account has not configured yet, which a login enables. */\n\tpolicyModelIds: string[];\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\n/**\n * Read the model lists a login saves, and its availability filter checks, from a `GET /models`\n * response of the host at `baseUrl`. A login and a catalog refresh both use these rules, so either\n * read of the account's list leaves the same lists.\n */\nexport function parseGitHubCopilotAccountModelLists(raw: unknown, baseUrl: string): GitHubCopilotAccountModelLists {\n\tconst data = asRecord(raw)?.data;\n\tif (!Array.isArray(data)) {\n\t\tthrow new Error(\"Invalid Copilot models response\");\n\t}\n\n\t// Some Individual accounts return false for every picker flag despite explicit enabled policies.\n\t// Limit the fallback to that endpoint so other account types keep strict picker semantics.\n\tconst allowPolicyFallback = baseUrl === GITHUB_COPILOT_INDIVIDUAL_BASE_URL;\n\tconst accountModels = data.flatMap((rawItem) => {\n\t\tconst item = asRecord(rawItem);\n\t\tconst id = item?.id;\n\t\tif (!item || typeof id !== \"string\") return [];\n\n\t\tconst capabilities = asRecord(item.capabilities);\n\t\tconst supports = asRecord(capabilities?.supports);\n\t\tif (supports?.tool_calls === false) return [];\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tpickerEnabled: item.model_picker_enabled === true,\n\t\t\t\tpolicyState: asRecord(item.policy)?.state,\n\t\t\t},\n\t\t];\n\t});\n\tconst pickerModelIds = accountModels\n\t\t.filter((model) => model.pickerEnabled && model.policyState !== \"disabled\")\n\t\t.map((model) => model.id);\n\tconst usePolicyFallback = allowPolicyFallback && pickerModelIds.length === 0;\n\tconst availableModelIds =\n\t\tpickerModelIds.length > 0 || !allowPolicyFallback\n\t\t\t? pickerModelIds\n\t\t\t: accountModels\n\t\t\t\t\t.filter((model) => !model.id.endsWith(\"-fast\") && model.policyState === \"enabled\")\n\t\t\t\t\t.map((model) => model.id);\n\t// Fast siblings are not picker entries: a fast ID the account lists is entitled unless its policy is disabled.\n\tconst fastModelIds = accountModels\n\t\t.filter((model) => model.id.endsWith(\"-fast\") && model.policyState !== \"disabled\")\n\t\t.map((model) => model.id);\n\tconst policyModelIds = accountModels\n\t\t.filter(\n\t\t\t(model) =>\n\t\t\t\tmodel.policyState === \"unconfigured\" &&\n\t\t\t\tObject.hasOwn(GITHUB_COPILOT_MODELS, model.id) &&\n\t\t\t\t(model.pickerEnabled || usePolicyFallback),\n\t\t)\n\t\t.map((model) => model.id);\n\treturn { availableModelIds, fastModelIds, policyModelIds };\n}\n"]}
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
-
import { type Provider } from "../models.ts";
|
|
2
|
-
|
|
1
|
+
import { type Provider, type RefreshModelsContext } from "../models.ts";
|
|
2
|
+
import type { AnyModel, Api, Model } from "../types.ts";
|
|
3
|
+
type GitHubCopilotApi = "anthropic-messages" | "openai-completions" | "openai-responses";
|
|
4
|
+
/**
|
|
5
|
+
* Turn a GitHub Copilot `GET /models` response into the chat models the catalog lacks, in the
|
|
6
|
+
* order the account lists them.
|
|
7
|
+
*
|
|
8
|
+
* Every model keeps the exact ID the account advertises, which is sent upstream unchanged, and takes
|
|
9
|
+
* the entry's display name as its name, or its ID when the entry has none. An entry is skipped when it
|
|
10
|
+
* is not a chat model, does not support tool calls, has a disabled policy, or is already in the
|
|
11
|
+
* catalog, whose curated entry always wins. An ordinary entry is also skipped when the account hides
|
|
12
|
+
* it from the model picker. A fast entry is offered
|
|
13
|
+
* whenever the account lists it, as Copilot's fast entitlement does, and like every other entry is
|
|
14
|
+
* described by its own row. It carries fast route metadata only when its `capabilities.family`
|
|
15
|
+
* names another model in the catalog, which then becomes its base. Otherwise it is an ordinary model.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseGitHubCopilotDiscoveredModels(raw: unknown, catalog: readonly AnyModel[]): Model<Api>[];
|
|
18
|
+
/**
|
|
19
|
+
* Read the account's model list with the effective OAuth or API-key credential and return the chat
|
|
20
|
+
* models `catalog` lacks (see {@link parseGitHubCopilotDiscoveredModels}). An OAuth login reads the
|
|
21
|
+
* host its token names; an API key reads the provider's configured host, the one its requests use.
|
|
22
|
+
*
|
|
23
|
+
* Returns undefined when the list cannot be read: without a usable credential, or when the host
|
|
24
|
+
* refuses the token (400, 401, 403 or 404). That is not an empty list, so a caller keeps the models it
|
|
25
|
+
* found before. Other failures throw.
|
|
26
|
+
*
|
|
27
|
+
* An OAuth login's saved model lists, which decide what the login is offered, are renewed from the
|
|
28
|
+
* same response through `context.updateCredential`, so what a refresh discovers is offered at once.
|
|
29
|
+
*/
|
|
30
|
+
export declare function discoverGitHubCopilotModels(catalog: readonly AnyModel[], context: RefreshModelsContext): Promise<Model<Api>[] | undefined>;
|
|
31
|
+
export declare function githubCopilotProvider(): Provider<GitHubCopilotApi>;
|
|
32
|
+
export {};
|
|
3
33
|
//# sourceMappingURL=github-copilot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-copilot.d.ts","sourceRoot":"","sources":["../../src/providers/github-copilot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github-copilot.d.ts","sourceRoot":"","sources":["../../src/providers/github-copilot.ts"],"names":[],"mappings":"AAaA,OAAO,EAAkB,KAAK,QAAQ,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAsB,MAAM,aAAa,CAAC;AAe5E,KAAK,gBAAgB,GAAG,oBAAoB,GAAG,oBAAoB,GAAG,kBAAkB,CAAC;AAyIzF;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,QAAQ,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAsB3G;AAqCD;;;;;;;;;;;GAWG;AACH,wBAAsB,2BAA2B,CAChD,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,OAAO,EAAE,oBAAoB,GAC3B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,CAkBnC;AAwBD,wBAAgB,qBAAqB,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CA4ClE"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { anthropicMessagesApi } from "../api/anthropic-messages.lazy.js";
|
|
2
|
+
import { COPILOT_API_VERSION, COPILOT_HEADERS, copilotClientHeaders, preserveCopilotIntegrationHeader, } from "../api/github-copilot-headers.js";
|
|
2
3
|
import { openAICompletionsApi } from "../api/openai-completions.lazy.js";
|
|
3
4
|
import { openAIResponsesApi } from "../api/openai-responses.lazy.js";
|
|
5
|
+
import { typesafeSystemOneApi } from "../api/typesafe-system-one.lazy.js";
|
|
4
6
|
import { envApiKeyAuth, lazyOAuth } from "../auth/helpers.js";
|
|
5
7
|
import { loadGitHubCopilotOAuth } from "../auth/oauth/load.js";
|
|
6
8
|
import { createProvider } from "../models.js";
|
|
7
|
-
import {
|
|
9
|
+
import { providerHeadersToRecord } from "../utils/headers.js";
|
|
10
|
+
import { isModelType } from "../utils/model-operations.js";
|
|
11
|
+
import { GITHUB_COPILOT_CLASSIFIER_MODELS, GITHUB_COPILOT_MODELS } from "./github-copilot.models.js";
|
|
12
|
+
import { GITHUB_COPILOT_INDIVIDUAL_BASE_URL as GITHUB_COPILOT_BASE_URL, parseGitHubCopilotAccountModelLists, } from "./github-copilot-account.js";
|
|
13
|
+
import { THINKING_LEVELS } from "./model-schema.js";
|
|
14
|
+
const GITHUB_COPILOT_MODELS_TIMEOUT_MS = 15_000;
|
|
15
|
+
const GITHUB_COPILOT_FAST_ID_SUFFIX = "-fast";
|
|
16
|
+
const DEFAULT_CONTEXT_WINDOW = 128_000;
|
|
17
|
+
const DEFAULT_MAX_TOKENS = 8_192;
|
|
8
18
|
/** Copilot advertises entitlements as string ID arrays on the OAuth credential; ignore any other shape. */
|
|
9
19
|
function advertisedModelIds(value) {
|
|
10
20
|
if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string"))
|
|
@@ -15,11 +25,247 @@ function advertisedModelIds(value) {
|
|
|
15
25
|
function lacksAccountModelList(credential) {
|
|
16
26
|
return advertisedModelIds(credential.availableModelIds) === undefined;
|
|
17
27
|
}
|
|
28
|
+
function asRecord(value) {
|
|
29
|
+
return value && typeof value === "object" ? value : undefined;
|
|
30
|
+
}
|
|
31
|
+
function positiveInteger(value) {
|
|
32
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : undefined;
|
|
33
|
+
}
|
|
34
|
+
/** Copilot prefers the Messages API, then Responses, then Chat Completions; an entry without a list uses Chat Completions. */
|
|
35
|
+
function apiForEndpoints(endpoints) {
|
|
36
|
+
if (endpoints === undefined)
|
|
37
|
+
return "openai-completions";
|
|
38
|
+
if (!Array.isArray(endpoints))
|
|
39
|
+
return undefined;
|
|
40
|
+
if (endpoints.includes("/v1/messages"))
|
|
41
|
+
return "anthropic-messages";
|
|
42
|
+
if (endpoints.includes("/responses"))
|
|
43
|
+
return "openai-responses";
|
|
44
|
+
if (endpoints.includes("/chat/completions"))
|
|
45
|
+
return "openai-completions";
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
function thinkingLevelMap(efforts) {
|
|
49
|
+
return Object.fromEntries([
|
|
50
|
+
["off", efforts.includes("none") ? "none" : null],
|
|
51
|
+
...THINKING_LEVELS.map((level) => [level, efforts.includes(level) ? level : null]),
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
function accountModelEntries(raw) {
|
|
55
|
+
const data = asRecord(raw)?.data;
|
|
56
|
+
if (!Array.isArray(data))
|
|
57
|
+
throw new Error("Invalid GitHub Copilot models response");
|
|
58
|
+
const seen = new Set();
|
|
59
|
+
return data.flatMap((rawItem) => {
|
|
60
|
+
const item = asRecord(rawItem);
|
|
61
|
+
const id = item?.id;
|
|
62
|
+
if (!item || typeof id !== "string" || !id || seen.has(id))
|
|
63
|
+
return [];
|
|
64
|
+
seen.add(id);
|
|
65
|
+
const capabilities = asRecord(item.capabilities);
|
|
66
|
+
const supports = asRecord(capabilities?.supports);
|
|
67
|
+
const type = capabilities?.type;
|
|
68
|
+
if (type !== undefined && type !== "chat")
|
|
69
|
+
return [];
|
|
70
|
+
if (supports?.tool_calls !== true)
|
|
71
|
+
return [];
|
|
72
|
+
if (asRecord(item.policy)?.state === "disabled")
|
|
73
|
+
return [];
|
|
74
|
+
const family = capabilities?.family;
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
id,
|
|
78
|
+
family: typeof family === "string" ? family : undefined,
|
|
79
|
+
pickerDisabled: item.model_picker_enabled === false,
|
|
80
|
+
item,
|
|
81
|
+
capabilities,
|
|
82
|
+
supports,
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The account's list does not say which models accept a 24-hour prompt cache, and some models reject
|
|
89
|
+
* the request, so a discovered OpenAI-style model never asks for one. A Messages model the list marks
|
|
90
|
+
* as adaptive receives the selected effort instead of a thinking budget.
|
|
91
|
+
*/
|
|
92
|
+
function discoveredCompat(api, reasoning, supports) {
|
|
93
|
+
if (api === "openai-completions") {
|
|
94
|
+
return {
|
|
95
|
+
supportsStore: false,
|
|
96
|
+
supportsDeveloperRole: false,
|
|
97
|
+
supportsReasoningEffort: reasoning,
|
|
98
|
+
supportsLongCacheRetention: false,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (api === "anthropic-messages") {
|
|
102
|
+
return supports?.adaptive_thinking === true ? { forceAdaptiveThinking: true } : undefined;
|
|
103
|
+
}
|
|
104
|
+
return { supportsLongCacheRetention: false };
|
|
105
|
+
}
|
|
106
|
+
/** The display name the account's entry advertises, or its ID when the entry has no usable one. */
|
|
107
|
+
function discoveredName(entry) {
|
|
108
|
+
const name = entry.item.name;
|
|
109
|
+
return typeof name === "string" && name.trim() ? name.trim() : entry.id;
|
|
110
|
+
}
|
|
111
|
+
function discoveredModel(entry) {
|
|
112
|
+
const api = apiForEndpoints(entry.item.supported_endpoints);
|
|
113
|
+
if (!api)
|
|
114
|
+
return undefined;
|
|
115
|
+
const limits = asRecord(entry.capabilities?.limits);
|
|
116
|
+
const rawEfforts = entry.supports?.reasoning_effort;
|
|
117
|
+
const efforts = Array.isArray(rawEfforts)
|
|
118
|
+
? rawEfforts.filter((effort) => typeof effort === "string")
|
|
119
|
+
: [];
|
|
120
|
+
const reasoning = efforts.length > 0;
|
|
121
|
+
const compat = discoveredCompat(api, reasoning, entry.supports);
|
|
122
|
+
return {
|
|
123
|
+
id: entry.id,
|
|
124
|
+
name: discoveredName(entry),
|
|
125
|
+
api,
|
|
126
|
+
provider: "github-copilot",
|
|
127
|
+
baseUrl: GITHUB_COPILOT_BASE_URL,
|
|
128
|
+
reasoning,
|
|
129
|
+
...(reasoning ? { thinkingLevelMap: thinkingLevelMap(efforts) } : {}),
|
|
130
|
+
input: entry.supports?.vision === true ? ["text", "image"] : ["text"],
|
|
131
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
132
|
+
contextWindow: positiveInteger(limits?.max_context_window_tokens) ??
|
|
133
|
+
positiveInteger(limits?.max_prompt_tokens) ??
|
|
134
|
+
DEFAULT_CONTEXT_WINDOW,
|
|
135
|
+
maxTokens: positiveInteger(limits?.max_output_tokens) ?? DEFAULT_MAX_TOKENS,
|
|
136
|
+
headers: { ...COPILOT_HEADERS },
|
|
137
|
+
...(compat ? { compat } : {}),
|
|
138
|
+
discovered: true,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Turn a GitHub Copilot `GET /models` response into the chat models the catalog lacks, in the
|
|
143
|
+
* order the account lists them.
|
|
144
|
+
*
|
|
145
|
+
* Every model keeps the exact ID the account advertises, which is sent upstream unchanged, and takes
|
|
146
|
+
* the entry's display name as its name, or its ID when the entry has none. An entry is skipped when it
|
|
147
|
+
* is not a chat model, does not support tool calls, has a disabled policy, or is already in the
|
|
148
|
+
* catalog, whose curated entry always wins. An ordinary entry is also skipped when the account hides
|
|
149
|
+
* it from the model picker. A fast entry is offered
|
|
150
|
+
* whenever the account lists it, as Copilot's fast entitlement does, and like every other entry is
|
|
151
|
+
* described by its own row. It carries fast route metadata only when its `capabilities.family`
|
|
152
|
+
* names another model in the catalog, which then becomes its base. Otherwise it is an ordinary model.
|
|
153
|
+
*/
|
|
154
|
+
export function parseGitHubCopilotDiscoveredModels(raw, catalog) {
|
|
155
|
+
const known = new Set();
|
|
156
|
+
for (const model of catalog)
|
|
157
|
+
known.add(model.id);
|
|
158
|
+
const entries = accountModelEntries(raw).filter((entry) => !known.has(entry.id));
|
|
159
|
+
const ordinary = new Set();
|
|
160
|
+
const models = new Map();
|
|
161
|
+
for (const entry of entries) {
|
|
162
|
+
const isFast = entry.id.endsWith(GITHUB_COPILOT_FAST_ID_SUFFIX);
|
|
163
|
+
if (!isFast && entry.pickerDisabled)
|
|
164
|
+
continue;
|
|
165
|
+
const model = discoveredModel(entry);
|
|
166
|
+
if (!model)
|
|
167
|
+
continue;
|
|
168
|
+
models.set(entry.id, model);
|
|
169
|
+
if (!isFast)
|
|
170
|
+
ordinary.add(entry.id);
|
|
171
|
+
}
|
|
172
|
+
return entries.flatMap((entry) => {
|
|
173
|
+
const model = models.get(entry.id);
|
|
174
|
+
if (!model)
|
|
175
|
+
return [];
|
|
176
|
+
if (ordinary.has(entry.id))
|
|
177
|
+
return [model];
|
|
178
|
+
const baseId = entry.family !== entry.id ? entry.family : undefined;
|
|
179
|
+
if (baseId === undefined || !(known.has(baseId) || ordinary.has(baseId)))
|
|
180
|
+
return [model];
|
|
181
|
+
return [{ ...model, fastRoute: { baseModelId: baseId, upstreamModelId: entry.id } }];
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async function accountModelListRequest(context) {
|
|
185
|
+
const credential = context.credential;
|
|
186
|
+
if (credential?.type === "oauth") {
|
|
187
|
+
const auth = await (await loadGitHubCopilotOAuth()).toAuth(credential);
|
|
188
|
+
return auth.apiKey ? { token: auth.apiKey, baseUrl: auth.baseUrl ?? GITHUB_COPILOT_BASE_URL } : undefined;
|
|
189
|
+
}
|
|
190
|
+
if (credential?.type === "api_key" && credential.key) {
|
|
191
|
+
return { token: credential.key, baseUrl: context.baseUrl ?? GITHUB_COPILOT_BASE_URL };
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
/** Whether a login's saved list names exactly these IDs. */
|
|
196
|
+
function savesSameIds(saved, ids) {
|
|
197
|
+
const savedIds = advertisedModelIds(saved);
|
|
198
|
+
return savedIds !== undefined && savedIds.size === new Set(ids).size && ids.every((id) => savedIds.has(id));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Save to an OAuth login the model lists it keeps, read from the account's list this refresh just
|
|
202
|
+
* read with it. The login otherwise renews them only with its token, so a refresh with a still-valid
|
|
203
|
+
* token could discover a model the login's older lists hide.
|
|
204
|
+
*/
|
|
205
|
+
async function saveLoginModelLists(context, raw, baseUrl) {
|
|
206
|
+
if (context.credential?.type !== "oauth" || !context.updateCredential)
|
|
207
|
+
return;
|
|
208
|
+
const { availableModelIds, fastModelIds } = parseGitHubCopilotAccountModelLists(raw, baseUrl);
|
|
209
|
+
await context.updateCredential((current) => savesSameIds(current.availableModelIds, availableModelIds) && savesSameIds(current.fastModelIds, fastModelIds)
|
|
210
|
+
? undefined
|
|
211
|
+
: { ...current, availableModelIds, fastModelIds });
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Read the account's model list with the effective OAuth or API-key credential and return the chat
|
|
215
|
+
* models `catalog` lacks (see {@link parseGitHubCopilotDiscoveredModels}). An OAuth login reads the
|
|
216
|
+
* host its token names; an API key reads the provider's configured host, the one its requests use.
|
|
217
|
+
*
|
|
218
|
+
* Returns undefined when the list cannot be read: without a usable credential, or when the host
|
|
219
|
+
* refuses the token (400, 401, 403 or 404). That is not an empty list, so a caller keeps the models it
|
|
220
|
+
* found before. Other failures throw.
|
|
221
|
+
*
|
|
222
|
+
* An OAuth login's saved model lists, which decide what the login is offered, are renewed from the
|
|
223
|
+
* same response through `context.updateCredential`, so what a refresh discovers is offered at once.
|
|
224
|
+
*/
|
|
225
|
+
export async function discoverGitHubCopilotModels(catalog, context) {
|
|
226
|
+
const request = await accountModelListRequest(context);
|
|
227
|
+
if (!request)
|
|
228
|
+
return undefined;
|
|
229
|
+
const response = await fetch(`${request.baseUrl.replace(/\/+$/, "")}/models`, {
|
|
230
|
+
headers: {
|
|
231
|
+
Accept: "application/json",
|
|
232
|
+
Authorization: `Bearer ${request.token}`,
|
|
233
|
+
...copilotClientHeaders(request.token),
|
|
234
|
+
"X-GitHub-Api-Version": COPILOT_API_VERSION,
|
|
235
|
+
},
|
|
236
|
+
signal: AbortSignal.any([context.signal, AbortSignal.timeout(GITHUB_COPILOT_MODELS_TIMEOUT_MS)]),
|
|
237
|
+
});
|
|
238
|
+
if ([400, 401, 403, 404].includes(response.status))
|
|
239
|
+
return undefined;
|
|
240
|
+
if (!response.ok)
|
|
241
|
+
throw new Error(`GitHub Copilot model list request failed: ${response.status}`);
|
|
242
|
+
const raw = await response.json();
|
|
243
|
+
const models = parseGitHubCopilotDiscoveredModels(raw, catalog);
|
|
244
|
+
await saveLoginModelLists(context, raw, request.baseUrl);
|
|
245
|
+
return models;
|
|
246
|
+
}
|
|
247
|
+
/** Copilot's account endpoint has no version prefix, but System One requires it. */
|
|
248
|
+
function copilotSystemOne(classifier) {
|
|
249
|
+
return {
|
|
250
|
+
classify: (model, context, options) => {
|
|
251
|
+
const defaults = copilotClientHeaders(options?.apiKey ?? "");
|
|
252
|
+
const integration = { "Copilot-Integration-Id": defaults["Copilot-Integration-Id"] };
|
|
253
|
+
const headers = providerHeadersToRecord(defaults, model.headers, options?.headers);
|
|
254
|
+
return classifier.classify({
|
|
255
|
+
...model,
|
|
256
|
+
baseUrl: `${model.baseUrl.replace(/\/+$/u, "")}/v1`,
|
|
257
|
+
}, context, {
|
|
258
|
+
...options,
|
|
259
|
+
headers: providerHeadersToRecord(headers, preserveCopilotIntegrationHeader(headers, integration)),
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
}
|
|
18
264
|
export function githubCopilotProvider() {
|
|
19
265
|
return createProvider({
|
|
20
266
|
id: "github-copilot",
|
|
21
267
|
name: "GitHub Copilot",
|
|
22
|
-
baseUrl:
|
|
268
|
+
baseUrl: GITHUB_COPILOT_BASE_URL,
|
|
23
269
|
auth: {
|
|
24
270
|
apiKey: envApiKeyAuth("GitHub Copilot token", ["COPILOT_GITHUB_TOKEN"]),
|
|
25
271
|
oauth: lazyOAuth({
|
|
@@ -29,17 +275,26 @@ export function githubCopilotProvider() {
|
|
|
29
275
|
load: loadGitHubCopilotOAuth,
|
|
30
276
|
}),
|
|
31
277
|
},
|
|
32
|
-
models: Object.values(GITHUB_COPILOT_MODELS),
|
|
278
|
+
models: [...Object.values(GITHUB_COPILOT_MODELS), ...Object.values(GITHUB_COPILOT_CLASSIFIER_MODELS)],
|
|
33
279
|
filterModels: (models, credential) => {
|
|
34
280
|
const oauth = credential?.type === "oauth" ? credential : undefined;
|
|
35
281
|
const entitledFastModelIds = advertisedModelIds(oauth?.fastModelIds);
|
|
36
282
|
const availableModelIds = advertisedModelIds(oauth?.availableModelIds);
|
|
37
283
|
return models.filter((model) => {
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
284
|
+
// Picker entitlements list chat models, not classifiers.
|
|
285
|
+
if (isModelType(model, "classifier"))
|
|
286
|
+
return true;
|
|
287
|
+
// The login's saved lists decide for every model, discovered ones included: discovered models are
|
|
288
|
+
// cached per provider, not per login. A refresh that reads the account's list renews the lists of
|
|
289
|
+
// the same login (see `discoverGitHubCopilotModels`), so they never predate what it found.
|
|
290
|
+
// A fast ID the login lists is entitled whether or not it is a picker entry.
|
|
291
|
+
if (entitledFastModelIds?.has(model.id) === true)
|
|
292
|
+
return true;
|
|
293
|
+
// Fast-ness comes from the explicit route metadata, never from the `-fast` suffix. A login that
|
|
294
|
+
// lists its fast IDs offers only those; without such a list (an API key), the account's own
|
|
295
|
+
// model list already decided which fast models exist.
|
|
41
296
|
if (model.fastRoute !== undefined)
|
|
42
|
-
return entitledFastModelIds
|
|
297
|
+
return entitledFastModelIds === undefined;
|
|
43
298
|
// A login without a stored model list (an older login) keeps the catalog so it is never left
|
|
44
299
|
// with no models; `Models.refresh()` with network access re-reads the list once (see
|
|
45
300
|
// `needsRefresh`), and the account list applies from then on.
|
|
@@ -51,6 +306,7 @@ export function githubCopilotProvider() {
|
|
|
51
306
|
"openai-completions": openAICompletionsApi(),
|
|
52
307
|
"openai-responses": openAIResponsesApi(),
|
|
53
308
|
},
|
|
309
|
+
classifiers: { "typesafe-system-one": copilotSystemOne(typesafeSystemOneApi()) },
|
|
54
310
|
});
|
|
55
311
|
}
|
|
56
312
|
//# sourceMappingURL=github-copilot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-copilot.js","sourceRoot":"","sources":["../../src/providers/github-copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;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AAC;YACrE,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;YACvE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC9B,yFAAyF;gBACzF,6FAA6F;gBAC7F,iFAAiF;gBACjF,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;oBAAE,OAAO,oBAAoB,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;gBACvF,6FAA6F;gBAC7F,qFAAqF;gBACrF,8DAA8D;gBAC9D,OAAO,iBAAiB,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;YACjD,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,GAAG,EAAE;YACJ,oBAAoB,EAAE,oBAAoB,EAAE;YAC5C,oBAAoB,EAAE,oBAAoB,EAAE;YAC5C,kBAAkB,EAAE,kBAAkB,EAAE;SACxC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { anthropicMessagesApi } from \"../api/anthropic-messages.lazy.ts\";\nimport { openAICompletionsApi } from \"../api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"../api/openai-responses.lazy.ts\";\nimport { envApiKeyAuth, lazyOAuth } from \"../auth/helpers.ts\";\nimport type { OAuthCredential } from \"../auth/types.ts\";\nimport { loadGitHubCopilotOAuth } from \"../auth/oauth/load.ts\";\nimport { createProvider, type Provider } from \"../models.ts\";\nimport { GITHUB_COPILOT_MODELS } from \"./github-copilot.models.ts\";\n\n/** Copilot advertises entitlements as string ID arrays on the OAuth credential; ignore any other shape. */\nfunction advertisedModelIds(value: unknown): ReadonlySet<string> | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn new Set(value);\n}\n\n/** A login saved before Copilot model lists were stored, or whose list is malformed, must re-read it. */\nfunction lacksAccountModelList(credential: OAuthCredential): boolean {\n\treturn advertisedModelIds(credential.availableModelIds) === undefined;\n}\n\nexport function githubCopilotProvider(): Provider<\"anthropic-messages\" | \"openai-completions\" | \"openai-responses\"> {\n\treturn createProvider({\n\t\tid: \"github-copilot\",\n\t\tname: \"GitHub Copilot\",\n\t\tbaseUrl: \"https://api.individual.githubcopilot.com\",\n\t\tauth: {\n\t\t\tapiKey: envApiKeyAuth(\"GitHub Copilot token\", [\"COPILOT_GITHUB_TOKEN\"]),\n\t\t\toauth: lazyOAuth({\n\t\t\t\tname: \"GitHub Copilot\",\n\t\t\t\tisSubscription: true,\n\t\t\t\tneedsRefresh: lacksAccountModelList,\n\t\t\t\tload: loadGitHubCopilotOAuth,\n\t\t\t}),\n\t\t},\n\t\tmodels: Object.values(GITHUB_COPILOT_MODELS),\n\t\tfilterModels: (models, credential) => {\n\t\t\tconst oauth = credential?.type === \"oauth\" ? credential : undefined;\n\t\t\tconst entitledFastModelIds = advertisedModelIds(oauth?.fastModelIds);\n\t\t\tconst availableModelIds = advertisedModelIds(oauth?.availableModelIds);\n\t\t\treturn models.filter((model) => {\n\t\t\t\t// Fast siblings are advertised per account, so expose only the exact IDs this credential\n\t\t\t\t// entitles. Fast-ness comes from the explicit route metadata, never from the `-fast` suffix:\n\t\t\t\t// a Copilot-owned model that merely ends in `-fast` is an ordinary picker model.\n\t\t\t\tif (model.fastRoute !== undefined) return entitledFastModelIds?.has(model.id) === true;\n\t\t\t\t// A login without a stored model list (an older login) keeps the catalog so it is never left\n\t\t\t\t// with no models; `Models.refresh()` with network access re-reads the list once (see\n\t\t\t\t// `needsRefresh`), and the account list applies from then on.\n\t\t\t\treturn availableModelIds?.has(model.id) ?? true;\n\t\t\t});\n\t\t},\n\t\tapi: {\n\t\t\t\"anthropic-messages\": anthropicMessagesApi(),\n\t\t\t\"openai-completions\": openAICompletionsApi(),\n\t\t\t\"openai-responses\": openAIResponsesApi(),\n\t\t},\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"github-copilot.js","sourceRoot":"","sources":["../../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AK,EAAE,YAAY,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAClD,kGAAkG;gBAClG,kGAAkG;gBAClG,2FAA2F;gBAC3F,6EAA6E;gBAC7E,IAAI,oBAAoB,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI;oBAAE,OAAO,IAAI,CAAC;gBAC9D,gGAAgG;gBAChG,4FAA4F;gBAC5F,sDAAsD;gBACtD,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;oBAAE,OAAO,oBAAoB,KAAK,SAAS,CAAC;gBAC7E,6FAA6F;gBAC7F,qFAAqF;gBACrF,8DAA8D;gBAC9D,OAAO,iBAAiB,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;YACjD,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,GAAG,EAAE;YACJ,oBAAoB,EAAE,oBAAoB,EAAE;YAC5C,oBAAoB,EAAE,oBAAoB,EAAE;YAC5C,kBAAkB,EAAE,kBAAkB,EAAE;SACxC;QACD,WAAW,EAAE,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,EAAE;KAChF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { anthropicMessagesApi } from \"../api/anthropic-messages.lazy.ts\";\nimport {\n\tCOPILOT_API_VERSION,\n\tCOPILOT_HEADERS,\n\tcopilotClientHeaders,\n\tpreserveCopilotIntegrationHeader,\n} from \"../api/github-copilot-headers.js\";\nimport { openAICompletionsApi } from \"../api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"../api/openai-responses.lazy.ts\";\nimport { typesafeSystemOneApi } from \"../api/typesafe-system-one.lazy.js\";\nimport { envApiKeyAuth, lazyOAuth } from \"../auth/helpers.ts\";\nimport { loadGitHubCopilotOAuth } from \"../auth/oauth/load.ts\";\nimport type { OAuthCredential } from \"../auth/types.ts\";\nimport { createProvider, type Provider, type RefreshModelsContext } from \"../models.ts\";\nimport type { AnyModel, Api, Model, ProviderClassifier } from \"../types.ts\";\nimport { providerHeadersToRecord } from \"../utils/headers.js\";\nimport { isModelType } from \"../utils/model-operations.ts\";\nimport { GITHUB_COPILOT_CLASSIFIER_MODELS, GITHUB_COPILOT_MODELS } from \"./github-copilot.models.js\";\nimport {\n\tGITHUB_COPILOT_INDIVIDUAL_BASE_URL as GITHUB_COPILOT_BASE_URL,\n\tparseGitHubCopilotAccountModelLists,\n} from \"./github-copilot-account.ts\";\nimport { THINKING_LEVELS, type ThinkingLevelMap } from \"./model-schema.ts\";\n\nconst GITHUB_COPILOT_MODELS_TIMEOUT_MS = 15_000;\nconst GITHUB_COPILOT_FAST_ID_SUFFIX = \"-fast\";\nconst DEFAULT_CONTEXT_WINDOW = 128_000;\nconst DEFAULT_MAX_TOKENS = 8_192;\n\ntype GitHubCopilotApi = \"anthropic-messages\" | \"openai-completions\" | \"openai-responses\";\n\n/** Copilot advertises entitlements as string ID arrays on the OAuth credential; ignore any other shape. */\nfunction advertisedModelIds(value: unknown): ReadonlySet<string> | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn new Set(value);\n}\n\n/** A login saved before Copilot model lists were stored, or whose list is malformed, must re-read it. */\nfunction lacksAccountModelList(credential: OAuthCredential): boolean {\n\treturn advertisedModelIds(credential.availableModelIds) === undefined;\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction positiveInteger(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\n/** Copilot prefers the Messages API, then Responses, then Chat Completions; an entry without a list uses Chat Completions. */\nfunction apiForEndpoints(endpoints: unknown): GitHubCopilotApi | undefined {\n\tif (endpoints === undefined) return \"openai-completions\";\n\tif (!Array.isArray(endpoints)) return undefined;\n\tif (endpoints.includes(\"/v1/messages\")) return \"anthropic-messages\";\n\tif (endpoints.includes(\"/responses\")) return \"openai-responses\";\n\tif (endpoints.includes(\"/chat/completions\")) return \"openai-completions\";\n\treturn undefined;\n}\n\nfunction thinkingLevelMap(efforts: readonly string[]): ThinkingLevelMap {\n\treturn Object.fromEntries([\n\t\t[\"off\", efforts.includes(\"none\") ? \"none\" : null],\n\t\t...THINKING_LEVELS.map((level) => [level, efforts.includes(level) ? level : null]),\n\t]);\n}\n\ninterface AccountModelEntry {\n\tid: string;\n\tfamily: string | undefined;\n\tpickerDisabled: boolean;\n\titem: Record<string, unknown>;\n\tcapabilities: Record<string, unknown> | undefined;\n\tsupports: Record<string, unknown> | undefined;\n}\n\nfunction accountModelEntries(raw: unknown): AccountModelEntry[] {\n\tconst data = asRecord(raw)?.data;\n\tif (!Array.isArray(data)) throw new Error(\"Invalid GitHub Copilot models response\");\n\tconst seen = new Set<string>();\n\treturn data.flatMap((rawItem): AccountModelEntry[] => {\n\t\tconst item = asRecord(rawItem);\n\t\tconst id = item?.id;\n\t\tif (!item || typeof id !== \"string\" || !id || seen.has(id)) return [];\n\t\tseen.add(id);\n\t\tconst capabilities = asRecord(item.capabilities);\n\t\tconst supports = asRecord(capabilities?.supports);\n\t\tconst type = capabilities?.type;\n\t\tif (type !== undefined && type !== \"chat\") return [];\n\t\tif (supports?.tool_calls !== true) return [];\n\t\tif (asRecord(item.policy)?.state === \"disabled\") return [];\n\t\tconst family = capabilities?.family;\n\t\treturn [\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tfamily: typeof family === \"string\" ? family : undefined,\n\t\t\t\tpickerDisabled: item.model_picker_enabled === false,\n\t\t\t\titem,\n\t\t\t\tcapabilities,\n\t\t\t\tsupports,\n\t\t\t},\n\t\t];\n\t});\n}\n\n/**\n * The account's list does not say which models accept a 24-hour prompt cache, and some models reject\n * the request, so a discovered OpenAI-style model never asks for one. A Messages model the list marks\n * as adaptive receives the selected effort instead of a thinking budget.\n */\nfunction discoveredCompat(\n\tapi: GitHubCopilotApi,\n\treasoning: boolean,\n\tsupports: Record<string, unknown> | undefined,\n): Model<Api>[\"compat\"] {\n\tif (api === \"openai-completions\") {\n\t\treturn {\n\t\t\tsupportsStore: false,\n\t\t\tsupportsDeveloperRole: false,\n\t\t\tsupportsReasoningEffort: reasoning,\n\t\t\tsupportsLongCacheRetention: false,\n\t\t};\n\t}\n\tif (api === \"anthropic-messages\") {\n\t\treturn supports?.adaptive_thinking === true ? { forceAdaptiveThinking: true } : undefined;\n\t}\n\treturn { supportsLongCacheRetention: false };\n}\n\n/** The display name the account's entry advertises, or its ID when the entry has no usable one. */\nfunction discoveredName(entry: AccountModelEntry): string {\n\tconst name = entry.item.name;\n\treturn typeof name === \"string\" && name.trim() ? name.trim() : entry.id;\n}\n\nfunction discoveredModel(entry: AccountModelEntry): Model<Api> | undefined {\n\tconst api = apiForEndpoints(entry.item.supported_endpoints);\n\tif (!api) return undefined;\n\tconst limits = asRecord(entry.capabilities?.limits);\n\tconst rawEfforts = entry.supports?.reasoning_effort;\n\tconst efforts = Array.isArray(rawEfforts)\n\t\t? rawEfforts.filter((effort): effort is string => typeof effort === \"string\")\n\t\t: [];\n\tconst reasoning = efforts.length > 0;\n\tconst compat = discoveredCompat(api, reasoning, entry.supports);\n\treturn {\n\t\tid: entry.id,\n\t\tname: discoveredName(entry),\n\t\tapi,\n\t\tprovider: \"github-copilot\",\n\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\treasoning,\n\t\t...(reasoning ? { thinkingLevelMap: thinkingLevelMap(efforts) } : {}),\n\t\tinput: entry.supports?.vision === true ? [\"text\", \"image\"] : [\"text\"],\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow:\n\t\t\tpositiveInteger(limits?.max_context_window_tokens) ??\n\t\t\tpositiveInteger(limits?.max_prompt_tokens) ??\n\t\t\tDEFAULT_CONTEXT_WINDOW,\n\t\tmaxTokens: positiveInteger(limits?.max_output_tokens) ?? DEFAULT_MAX_TOKENS,\n\t\theaders: { ...COPILOT_HEADERS },\n\t\t...(compat ? { compat } : {}),\n\t\tdiscovered: true,\n\t};\n}\n\n/**\n * Turn a GitHub Copilot `GET /models` response into the chat models the catalog lacks, in the\n * order the account lists them.\n *\n * Every model keeps the exact ID the account advertises, which is sent upstream unchanged, and takes\n * the entry's display name as its name, or its ID when the entry has none. An entry is skipped when it\n * is not a chat model, does not support tool calls, has a disabled policy, or is already in the\n * catalog, whose curated entry always wins. An ordinary entry is also skipped when the account hides\n * it from the model picker. A fast entry is offered\n * whenever the account lists it, as Copilot's fast entitlement does, and like every other entry is\n * described by its own row. It carries fast route metadata only when its `capabilities.family`\n * names another model in the catalog, which then becomes its base. Otherwise it is an ordinary model.\n */\nexport function parseGitHubCopilotDiscoveredModels(raw: unknown, catalog: readonly AnyModel[]): Model<Api>[] {\n\tconst known = new Set<string>();\n\tfor (const model of catalog) known.add(model.id);\n\tconst entries = accountModelEntries(raw).filter((entry) => !known.has(entry.id));\n\tconst ordinary = new Set<string>();\n\tconst models = new Map<string, Model<Api>>();\n\tfor (const entry of entries) {\n\t\tconst isFast = entry.id.endsWith(GITHUB_COPILOT_FAST_ID_SUFFIX);\n\t\tif (!isFast && entry.pickerDisabled) continue;\n\t\tconst model = discoveredModel(entry);\n\t\tif (!model) continue;\n\t\tmodels.set(entry.id, model);\n\t\tif (!isFast) ordinary.add(entry.id);\n\t}\n\treturn entries.flatMap((entry): Model<Api>[] => {\n\t\tconst model = models.get(entry.id);\n\t\tif (!model) return [];\n\t\tif (ordinary.has(entry.id)) return [model];\n\t\tconst baseId = entry.family !== entry.id ? entry.family : undefined;\n\t\tif (baseId === undefined || !(known.has(baseId) || ordinary.has(baseId))) return [model];\n\t\treturn [{ ...model, fastRoute: { baseModelId: baseId, upstreamModelId: entry.id } }];\n\t});\n}\n\nasync function accountModelListRequest(\n\tcontext: RefreshModelsContext,\n): Promise<{ token: string; baseUrl: string } | undefined> {\n\tconst credential = context.credential;\n\tif (credential?.type === \"oauth\") {\n\t\tconst auth = await (await loadGitHubCopilotOAuth()).toAuth(credential);\n\t\treturn auth.apiKey ? { token: auth.apiKey, baseUrl: auth.baseUrl ?? GITHUB_COPILOT_BASE_URL } : undefined;\n\t}\n\tif (credential?.type === \"api_key\" && credential.key) {\n\t\treturn { token: credential.key, baseUrl: context.baseUrl ?? GITHUB_COPILOT_BASE_URL };\n\t}\n\treturn undefined;\n}\n\n/** Whether a login's saved list names exactly these IDs. */\nfunction savesSameIds(saved: unknown, ids: readonly string[]): boolean {\n\tconst savedIds = advertisedModelIds(saved);\n\treturn savedIds !== undefined && savedIds.size === new Set(ids).size && ids.every((id) => savedIds.has(id));\n}\n\n/**\n * Save to an OAuth login the model lists it keeps, read from the account's list this refresh just\n * read with it. The login otherwise renews them only with its token, so a refresh with a still-valid\n * token could discover a model the login's older lists hide.\n */\nasync function saveLoginModelLists(context: RefreshModelsContext, raw: unknown, baseUrl: string): Promise<void> {\n\tif (context.credential?.type !== \"oauth\" || !context.updateCredential) return;\n\tconst { availableModelIds, fastModelIds } = parseGitHubCopilotAccountModelLists(raw, baseUrl);\n\tawait context.updateCredential((current) =>\n\t\tsavesSameIds(current.availableModelIds, availableModelIds) && savesSameIds(current.fastModelIds, fastModelIds)\n\t\t\t? undefined\n\t\t\t: { ...current, availableModelIds, fastModelIds },\n\t);\n}\n\n/**\n * Read the account's model list with the effective OAuth or API-key credential and return the chat\n * models `catalog` lacks (see {@link parseGitHubCopilotDiscoveredModels}). An OAuth login reads the\n * host its token names; an API key reads the provider's configured host, the one its requests use.\n *\n * Returns undefined when the list cannot be read: without a usable credential, or when the host\n * refuses the token (400, 401, 403 or 404). That is not an empty list, so a caller keeps the models it\n * found before. Other failures throw.\n *\n * An OAuth login's saved model lists, which decide what the login is offered, are renewed from the\n * same response through `context.updateCredential`, so what a refresh discovers is offered at once.\n */\nexport async function discoverGitHubCopilotModels(\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n): Promise<Model<Api>[] | undefined> {\n\tconst request = await accountModelListRequest(context);\n\tif (!request) return undefined;\n\tconst response = await fetch(`${request.baseUrl.replace(/\\/+$/, \"\")}/models`, {\n\t\theaders: {\n\t\t\tAccept: \"application/json\",\n\t\t\tAuthorization: `Bearer ${request.token}`,\n\t\t\t...copilotClientHeaders(request.token),\n\t\t\t\"X-GitHub-Api-Version\": COPILOT_API_VERSION,\n\t\t},\n\t\tsignal: AbortSignal.any([context.signal, AbortSignal.timeout(GITHUB_COPILOT_MODELS_TIMEOUT_MS)]),\n\t});\n\tif ([400, 401, 403, 404].includes(response.status)) return undefined;\n\tif (!response.ok) throw new Error(`GitHub Copilot model list request failed: ${response.status}`);\n\tconst raw: unknown = await response.json();\n\tconst models = parseGitHubCopilotDiscoveredModels(raw, catalog);\n\tawait saveLoginModelLists(context, raw, request.baseUrl);\n\treturn models;\n}\n\n/** Copilot's account endpoint has no version prefix, but System One requires it. */\nfunction copilotSystemOne(classifier: ProviderClassifier): ProviderClassifier {\n\treturn {\n\t\tclassify: (model, context, options) => {\n\t\t\tconst defaults = copilotClientHeaders(options?.apiKey ?? \"\");\n\t\t\tconst integration = { \"Copilot-Integration-Id\": defaults[\"Copilot-Integration-Id\"]! };\n\t\t\tconst headers = providerHeadersToRecord(defaults, model.headers, options?.headers);\n\t\t\treturn classifier.classify(\n\t\t\t\t{\n\t\t\t\t\t...model,\n\t\t\t\t\tbaseUrl: `${model.baseUrl.replace(/\\/+$/u, \"\")}/v1`,\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\t...options,\n\t\t\t\t\theaders: providerHeadersToRecord(headers, preserveCopilotIntegrationHeader(headers, integration)),\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t};\n}\n\nexport function githubCopilotProvider(): Provider<GitHubCopilotApi> {\n\treturn createProvider<GitHubCopilotApi>({\n\t\tid: \"github-copilot\",\n\t\tname: \"GitHub Copilot\",\n\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\tauth: {\n\t\t\tapiKey: envApiKeyAuth(\"GitHub Copilot token\", [\"COPILOT_GITHUB_TOKEN\"]),\n\t\t\toauth: lazyOAuth({\n\t\t\t\tname: \"GitHub Copilot\",\n\t\t\t\tisSubscription: true,\n\t\t\t\tneedsRefresh: lacksAccountModelList,\n\t\t\t\tload: loadGitHubCopilotOAuth,\n\t\t\t}),\n\t\t},\n\t\tmodels: [...Object.values(GITHUB_COPILOT_MODELS), ...Object.values(GITHUB_COPILOT_CLASSIFIER_MODELS)],\n\t\tfilterModels: (models, credential) => {\n\t\t\tconst oauth = credential?.type === \"oauth\" ? credential : undefined;\n\t\t\tconst entitledFastModelIds = advertisedModelIds(oauth?.fastModelIds);\n\t\t\tconst availableModelIds = advertisedModelIds(oauth?.availableModelIds);\n\t\t\treturn models.filter((model) => {\n\t\t\t\t// Picker entitlements list chat models, not classifiers.\n\t\t\t\tif (isModelType(model, \"classifier\")) return true;\n\t\t\t\t// The login's saved lists decide for every model, discovered ones included: discovered models are\n\t\t\t\t// cached per provider, not per login. A refresh that reads the account's list renews the lists of\n\t\t\t\t// the same login (see `discoverGitHubCopilotModels`), so they never predate what it found.\n\t\t\t\t// A fast ID the login lists is entitled whether or not it is a picker entry.\n\t\t\t\tif (entitledFastModelIds?.has(model.id) === true) return true;\n\t\t\t\t// Fast-ness comes from the explicit route metadata, never from the `-fast` suffix. A login that\n\t\t\t\t// lists its fast IDs offers only those; without such a list (an API key), the account's own\n\t\t\t\t// model list already decided which fast models exist.\n\t\t\t\tif (model.fastRoute !== undefined) return entitledFastModelIds === undefined;\n\t\t\t\t// A login without a stored model list (an older login) keeps the catalog so it is never left\n\t\t\t\t// with no models; `Models.refresh()` with network access re-reads the list once (see\n\t\t\t\t// `needsRefresh`), and the account list applies from then on.\n\t\t\t\treturn availableModelIds?.has(model.id) ?? true;\n\t\t\t});\n\t\t},\n\t\tapi: {\n\t\t\t\"anthropic-messages\": anthropicMessagesApi(),\n\t\t\t\"openai-completions\": openAICompletionsApi(),\n\t\t\t\"openai-responses\": openAIResponsesApi(),\n\t\t},\n\t\tclassifiers: { \"typesafe-system-one\": copilotSystemOne(typesafeSystemOneApi()) },\n\t});\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -144,6 +144,13 @@ export interface StreamOptions extends ProviderRequestOptions<Model<Api>> {
|
|
|
144
144
|
* session-aware features. Ignored by providers that don't support it.
|
|
145
145
|
*/
|
|
146
146
|
sessionId?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Do not use or record server-side continuation state for this request (for example
|
|
149
|
+
* Anthropic message threads). Set this for replays such as cache warming, which must not
|
|
150
|
+
* replace the state of the real conversation. Providers that do not keep continuation
|
|
151
|
+
* state ignore it.
|
|
152
|
+
*/
|
|
153
|
+
disableContinuation?: boolean;
|
|
147
154
|
/**
|
|
148
155
|
* WebSocket connect timeout in milliseconds for providers that support
|
|
149
156
|
* WebSocket transports. This covers the connection/open handshake only;
|
|
@@ -594,7 +601,12 @@ export type ConstrainedSamplingConfig = {
|
|
|
594
601
|
type: "grammar";
|
|
595
602
|
variants: GrammarVariants;
|
|
596
603
|
};
|
|
597
|
-
|
|
604
|
+
/**
|
|
605
|
+
* A tool the model may call. `parameters` is the JSON Schema of its arguments: a TypeBox schema (the default type, which
|
|
606
|
+
* also types the arguments through TypeBox's `Static`), a schema from `@earendil-works/pi-schema`'s builders, or any
|
|
607
|
+
* plain JSON Schema object such as an MCP server's.
|
|
608
|
+
*/
|
|
609
|
+
export interface Tool<TParameters extends object = TSchema> {
|
|
598
610
|
name: string;
|
|
599
611
|
description: string;
|
|
600
612
|
parameters: TParameters;
|
|
@@ -761,6 +773,11 @@ export interface Model<TApi extends Api> extends BaseModel<TApi> {
|
|
|
761
773
|
* upstream routing it needs. Absent on every normal model.
|
|
762
774
|
*/
|
|
763
775
|
fastRoute?: ModelFastRoute;
|
|
776
|
+
/**
|
|
777
|
+
* Set on a model the provider found in the account's own model list rather than in its built-in
|
|
778
|
+
* catalog. Its metadata comes from that list, so `modelOverrides` can correct it.
|
|
779
|
+
*/
|
|
780
|
+
discovered?: boolean;
|
|
764
781
|
/**
|
|
765
782
|
* Service tiers this model advertises. When set, the Codex adapter sends only advertised tiers.
|
|
766
783
|
* When unset, the model carries no tier metadata and only Ultrafast is withheld.
|