@gajae-code/ai 0.13.2 → 0.14.0
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 +61 -2
- package/dist/types/auth-broker/client.d.ts +9 -1
- package/dist/types/auth-broker/redact.d.ts +7 -0
- package/dist/types/auth-broker/remote-store.d.ts +50 -9
- package/dist/types/auth-broker/types.d.ts +14 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +25 -0
- package/dist/types/auth-storage.d.ts +200 -6
- package/dist/types/core.d.ts +1 -0
- package/dist/types/model-cache.d.ts +4 -1
- package/dist/types/model-manager.d.ts +11 -0
- package/dist/types/provider-models/openai-compat.d.ts +5 -0
- package/dist/types/provider-models/special.d.ts +3 -0
- package/dist/types/providers/anthropic.d.ts +31 -0
- package/dist/types/providers/cursor.d.ts +9 -1
- package/dist/types/providers/kiro-codewhisperer.d.ts +8 -0
- package/dist/types/providers/mock.d.ts +8 -0
- package/dist/types/providers/register-builtins.d.ts +1 -0
- package/dist/types/providers/transform-messages.d.ts +18 -0
- package/dist/types/types.d.ts +34 -8
- package/dist/types/usage/grok-cli.d.ts +5 -0
- package/dist/types/usage.d.ts +6 -0
- package/dist/types/utils/discovery/openai-compatible.d.ts +5 -0
- package/dist/types/utils/event-stream.d.ts +4 -2
- package/dist/types/utils/fallback-transport.d.ts +10 -0
- package/dist/types/utils/http-inspector.d.ts +1 -0
- package/dist/types/utils/idle-iterator.d.ts +13 -1
- package/dist/types/utils/json-parse.d.ts +19 -0
- package/dist/types/utils/oauth/callback-server.d.ts +13 -0
- package/dist/types/utils/oauth/kiro.d.ts +71 -0
- package/dist/types/utils/oauth/types.d.ts +1 -1
- package/dist/types/utils/parse-bind.d.ts +8 -5
- package/dist/types/utils/tool-call-healing.d.ts +7 -0
- package/dist/types/utils/tool-choice-capability.d.ts +11 -0
- package/package.json +3 -2
- package/src/auth-broker/client.ts +30 -0
- package/src/auth-broker/redact.ts +15 -0
- package/src/auth-broker/refresher.ts +4 -2
- package/src/auth-broker/remote-store.ts +693 -70
- package/src/auth-broker/server.ts +57 -12
- package/src/auth-broker/types.ts +16 -0
- package/src/auth-broker/wire-schemas.ts +21 -0
- package/src/auth-gateway/server.ts +84 -19
- package/src/auth-storage.ts +985 -41
- package/src/core.ts +1 -0
- package/src/model-cache.ts +23 -4
- package/src/model-manager.ts +70 -11
- package/src/model-thinking.ts +45 -1
- package/src/models.json +9604 -1932
- package/src/openai-completions-compat.ts +2 -1
- package/src/provider-models/descriptors.ts +7 -1
- package/src/provider-models/openai-compat.ts +52 -28
- package/src/provider-models/special.ts +12 -0
- package/src/providers/amazon-bedrock.ts +2 -1
- package/src/providers/anthropic.ts +831 -27
- package/src/providers/cursor.ts +83 -3
- package/src/providers/kiro-codewhisperer.ts +572 -0
- package/src/providers/mock.ts +15 -2
- package/src/providers/ollama.ts +9 -2
- package/src/providers/openai-codex-responses.ts +16 -9
- package/src/providers/openai-completions.ts +6 -1
- package/src/providers/openai-responses-shared.ts +180 -18
- package/src/providers/register-builtins.ts +24 -2
- package/src/providers/transform-messages.ts +64 -1
- package/src/stream.ts +25 -2
- package/src/types.ts +36 -7
- package/src/usage/grok-cli.ts +86 -1
- package/src/usage.ts +7 -0
- package/src/utils/discovery/openai-compatible.ts +89 -4
- package/src/utils/event-stream.ts +11 -2
- package/src/utils/fallback-transport.ts +44 -2
- package/src/utils/http-inspector.ts +1 -0
- package/src/utils/idle-iterator.ts +29 -6
- package/src/utils/json-parse.ts +80 -0
- package/src/utils/oauth/callback-server.ts +31 -1
- package/src/utils/oauth/index.ts +14 -1
- package/src/utils/oauth/kiro.ts +448 -0
- package/src/utils/oauth/synthetic.ts +2 -3
- package/src/utils/oauth/types.ts +1 -0
- package/src/utils/parse-bind.ts +27 -0
- package/src/utils/tool-call-healing.ts +13 -2
- package/src/utils/tool-choice-capability.ts +386 -6
|
@@ -125,6 +125,7 @@ export function detectOpenAICompat(model: Model<"openai-completions">, resolvedB
|
|
|
125
125
|
baseUrl.includes("fireworks.ai") ||
|
|
126
126
|
isDirectDeepseekApi;
|
|
127
127
|
const isGrok = provider === "xai" || baseUrl.includes("api.x.ai");
|
|
128
|
+
const isDirectXaiReasoningEffortModel = provider === "xai" && (model.id === "grok-4.5" || model.id === "grok-4.6");
|
|
128
129
|
const isMistral = provider === "mistral" || baseUrl.includes("mistral.ai");
|
|
129
130
|
|
|
130
131
|
// Hosts whose chat-completions endpoints are known to accept multiple
|
|
@@ -215,7 +216,7 @@ export function detectOpenAICompat(model: Model<"openai-completions">, resolvedB
|
|
|
215
216
|
sendSessionHeaders: false,
|
|
216
217
|
supportsResponsesSessionAffinity: false,
|
|
217
218
|
supportsMultipleSystemMessages: supportsMultipleSystemMessagesDefault,
|
|
218
|
-
supportsReasoningEffort: !isGrok && !isZai,
|
|
219
|
+
supportsReasoningEffort: (!isGrok && !isZai) || isDirectXaiReasoningEffortModel,
|
|
219
220
|
reasoningEffortMap,
|
|
220
221
|
supportsUsageInStreaming: !isCerebras,
|
|
221
222
|
disableReasoningOnForcedToolChoice: isKimiModel || isAnthropicModel || isOpenCodeGoReasoning,
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
nanoGptModelManagerOptions,
|
|
33
33
|
nvidiaModelManagerOptions,
|
|
34
34
|
ollamaModelManagerOptions,
|
|
35
|
+
omlxModelManagerOptions,
|
|
35
36
|
openaiModelManagerOptions,
|
|
36
37
|
opencodeGoModelManagerOptions,
|
|
37
38
|
opencodeZenModelManagerOptions,
|
|
@@ -52,6 +53,7 @@ import {
|
|
|
52
53
|
cursorModelManagerOptions,
|
|
53
54
|
glmZcodeModelManagerOptions,
|
|
54
55
|
jetbrainsJunieModelManagerOptions,
|
|
56
|
+
kiroModelManagerOptions,
|
|
55
57
|
openCodexModelManagerOptions,
|
|
56
58
|
zaiModelManagerOptions,
|
|
57
59
|
} from "./special";
|
|
@@ -268,6 +270,9 @@ export const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[] = [
|
|
|
268
270
|
catalog("LiteLLM", ["LITELLM_API_KEY"], { allowUnauthenticated: true }),
|
|
269
271
|
),
|
|
270
272
|
descriptor("lm-studio", "llama-3-8b", config => lmStudioModelManagerOptions(config), { allowUnauthenticated: true }),
|
|
273
|
+
descriptor("omlx", "Qwen3.5-122B-A10B-Q4", config => omlxModelManagerOptions(config), {
|
|
274
|
+
allowUnauthenticated: true,
|
|
275
|
+
}),
|
|
271
276
|
catalogDescriptor(
|
|
272
277
|
"vllm",
|
|
273
278
|
"gpt-oss-20b",
|
|
@@ -340,7 +345,7 @@ export const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[] = [
|
|
|
340
345
|
config => maraModelManagerOptions(config),
|
|
341
346
|
catalog("Mara Cloud", ["MARA_API_KEY"]),
|
|
342
347
|
),
|
|
343
|
-
catalogDescriptor("zai", "glm-5.
|
|
348
|
+
catalogDescriptor("zai", "glm-5.3", config => zaiModelManagerOptions(config), catalog("zAI", ["ZAI_API_KEY"])),
|
|
344
349
|
catalogDescriptor(
|
|
345
350
|
"glm-zcode",
|
|
346
351
|
"glm-5.2",
|
|
@@ -356,6 +361,7 @@ export const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[] = [
|
|
|
356
361
|
config => cursorModelManagerOptions(config),
|
|
357
362
|
catalog("Cursor", ["CURSOR_API_KEY"], { oauthProvider: "cursor" }),
|
|
358
363
|
),
|
|
364
|
+
descriptor("kiro", "CLAUDE_3_7_SONNET_20250219_V1_0", config => kiroModelManagerOptions(config)),
|
|
359
365
|
] as const;
|
|
360
366
|
|
|
361
367
|
/** Default model IDs for all known providers, built from descriptors + special providers. */
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
fetchOpenAICompatibleModels,
|
|
9
9
|
type OpenAICompatibleModelMapperContext,
|
|
10
10
|
type OpenAICompatibleModelRecord,
|
|
11
|
+
resolveLoopbackOpenAIBaseUrl,
|
|
11
12
|
} from "../utils/discovery/openai-compatible";
|
|
12
13
|
import { toFireworksPublicModelId } from "../utils/fireworks-model-id";
|
|
13
14
|
import { getGitHubCopilotBaseUrl, OPENCODE_HEADERS, parseGitHubCopilotApiKey } from "../utils/oauth/github-copilot";
|
|
@@ -226,7 +227,6 @@ function mapLmStudioModel(
|
|
|
226
227
|
),
|
|
227
228
|
};
|
|
228
229
|
}
|
|
229
|
-
|
|
230
230
|
function normalizeAnthropicBaseUrl(baseUrl: string | undefined, fallback: string): string {
|
|
231
231
|
const value = baseUrl?.trim();
|
|
232
232
|
if (!value) {
|
|
@@ -1398,6 +1398,30 @@ export function lmStudioModelManagerOptions(
|
|
|
1398
1398
|
};
|
|
1399
1399
|
}
|
|
1400
1400
|
|
|
1401
|
+
// ---------------------------------------------------------------------------
|
|
1402
|
+
// 12.6. oMLX (Apple Silicon MLX Local Server)
|
|
1403
|
+
// ---------------------------------------------------------------------------
|
|
1404
|
+
|
|
1405
|
+
export interface OmlxModelManagerConfig {
|
|
1406
|
+
apiKey?: string;
|
|
1407
|
+
baseUrl?: string;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
export function omlxModelManagerOptions(config?: OmlxModelManagerConfig): ModelManagerOptions<"openai-completions"> {
|
|
1411
|
+
const apiKey = config?.apiKey;
|
|
1412
|
+
const baseUrl = resolveLoopbackOpenAIBaseUrl(config?.baseUrl ?? Bun.env.OMLX_BASE_URL, "http://127.0.0.1:8080/v1");
|
|
1413
|
+
return {
|
|
1414
|
+
providerId: "omlx",
|
|
1415
|
+
fetchDynamicModels: () =>
|
|
1416
|
+
fetchOpenAICompatibleModels({
|
|
1417
|
+
api: "openai-completions",
|
|
1418
|
+
provider: "omlx",
|
|
1419
|
+
baseUrl,
|
|
1420
|
+
apiKey,
|
|
1421
|
+
}),
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1401
1425
|
// ---------------------------------------------------------------------------
|
|
1402
1426
|
// 13. Synthetic
|
|
1403
1427
|
// ---------------------------------------------------------------------------
|
|
@@ -1977,36 +2001,36 @@ export function anthropicModelManagerOptions(
|
|
|
1977
2001
|
.then(payload => mapAnthropicModelsDev(payload, baseUrl))
|
|
1978
2002
|
.catch(() => []);
|
|
1979
2003
|
const references = buildAnthropicReferenceMap(modelsDevModels);
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
if (!reference) {
|
|
1994
|
-
return {
|
|
1995
|
-
...defaults,
|
|
1996
|
-
name: discoveredName,
|
|
1997
|
-
};
|
|
1998
|
-
}
|
|
2004
|
+
const models = await fetchOpenAICompatibleModels({
|
|
2005
|
+
api: "anthropic-messages",
|
|
2006
|
+
provider: "anthropic",
|
|
2007
|
+
baseUrl,
|
|
2008
|
+
headers: buildAnthropicDiscoveryHeaders(apiKey),
|
|
2009
|
+
mapModel: (
|
|
2010
|
+
entry: OpenAICompatibleModelRecord,
|
|
2011
|
+
defaults: Model<"anthropic-messages">,
|
|
2012
|
+
_context: OpenAICompatibleModelMapperContext<"anthropic-messages">,
|
|
2013
|
+
): Model<"anthropic-messages"> => {
|
|
2014
|
+
const discoveredName = typeof entry.display_name === "string" ? entry.display_name : defaults.name;
|
|
2015
|
+
const reference = references.get(defaults.id);
|
|
2016
|
+
if (!reference) {
|
|
1999
2017
|
return {
|
|
2000
|
-
...
|
|
2001
|
-
id: defaults.id,
|
|
2018
|
+
...defaults,
|
|
2002
2019
|
name: discoveredName,
|
|
2003
|
-
api: "anthropic-messages",
|
|
2004
|
-
provider: "anthropic",
|
|
2005
|
-
baseUrl,
|
|
2006
2020
|
};
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2021
|
+
}
|
|
2022
|
+
return {
|
|
2023
|
+
...reference,
|
|
2024
|
+
id: defaults.id,
|
|
2025
|
+
name: discoveredName,
|
|
2026
|
+
api: "anthropic-messages",
|
|
2027
|
+
provider: "anthropic",
|
|
2028
|
+
baseUrl,
|
|
2029
|
+
};
|
|
2030
|
+
},
|
|
2031
|
+
});
|
|
2032
|
+
if (models === null) return null;
|
|
2033
|
+
return models;
|
|
2010
2034
|
},
|
|
2011
2035
|
}),
|
|
2012
2036
|
};
|
|
@@ -96,3 +96,15 @@ export function jetbrainsJunieModelManagerOptions(
|
|
|
96
96
|
): ModelManagerOptions<"anthropic-messages"> {
|
|
97
97
|
return { providerId: "jetbrains-junie" };
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// Kiro (Amazon Q Developer / CodeWhisperer)
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
|
|
104
|
+
export interface KiroModelManagerConfig {}
|
|
105
|
+
|
|
106
|
+
export function kiroModelManagerOptions(
|
|
107
|
+
_config: KiroModelManagerConfig = {},
|
|
108
|
+
): ModelManagerOptions<"kiro-codewhisperer-stream"> {
|
|
109
|
+
return { providerId: "kiro" };
|
|
110
|
+
}
|
|
@@ -36,7 +36,7 @@ import { normalizeToolCallId, resolveCacheRetention, sanitizeJsonStrings } from
|
|
|
36
36
|
import { AssistantMessageEventStream } from "../utils/event-stream";
|
|
37
37
|
import { transportFailureFacts } from "../utils/fallback-transport";
|
|
38
38
|
import { appendRawHttpRequestDumpFor400, type RawHttpRequestDump, withHttpStatus } from "../utils/http-inspector";
|
|
39
|
-
import { parseStreamingJson } from "../utils/json-parse";
|
|
39
|
+
import { findUnnecessaryUnicodeEscape, parseStreamingJson } from "../utils/json-parse";
|
|
40
40
|
import { resolveRetryBudget } from "../utils/retry-budget";
|
|
41
41
|
import { flattenToolRootCombinators, toolWireSchema } from "../utils/schema";
|
|
42
42
|
import {
|
|
@@ -597,6 +597,7 @@ function handleContentBlockStop(
|
|
|
597
597
|
break;
|
|
598
598
|
case "toolCall":
|
|
599
599
|
block.arguments = parseStreamingJson(block.partialJson);
|
|
600
|
+
if (findUnnecessaryUnicodeEscape(block.partialJson ?? "")) block.escapedNonAsciiArguments = true;
|
|
600
601
|
delete (block as Block).partialJson;
|
|
601
602
|
stream.push({ type: "toolcall_end", contentIndex: index, toolCall: block, partial: output });
|
|
602
603
|
break;
|