@gajae-code/ai 0.15.5 → 0.15.6
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 +15 -0
- package/dist/types/auth-broker/client.d.ts +6 -2
- package/dist/types/auth-broker/remote-store.d.ts +14 -2
- package/dist/types/auth-broker/types.d.ts +6 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +19 -0
- package/dist/types/auth-gateway/server.d.ts +39 -5
- package/dist/types/auth-gateway/types.d.ts +16 -2
- package/dist/types/auth-storage.d.ts +92 -24
- package/dist/types/provider-models/openai-compat.d.ts +1 -0
- package/dist/types/providers/register-builtins.d.ts +12 -12
- package/dist/types/stream.d.ts +2 -1
- package/dist/types/types.d.ts +22 -2
- package/dist/types/utils/oauth/api-key-login.d.ts +4 -1
- package/dist/types/utils/oauth/api-key-validation.d.ts +12 -6
- package/dist/types/utils/oauth/commandcode.d.ts +1 -0
- package/dist/types/utils/oauth/types.d.ts +1 -1
- package/dist/types/utils/retry.d.ts +2 -0
- package/package.json +3 -3
- package/src/auth-broker/client.ts +41 -13
- package/src/auth-broker/redact.ts +25 -1
- package/src/auth-broker/remote-store.ts +374 -115
- package/src/auth-broker/server.ts +131 -91
- package/src/auth-broker/types.ts +6 -0
- package/src/auth-broker/wire-schemas.ts +6 -0
- package/src/auth-gateway/server.ts +447 -79
- package/src/auth-gateway/types.ts +28 -2
- package/src/auth-storage.ts +658 -154
- package/src/cli.ts +1 -0
- package/src/models.json +1023 -0
- package/src/provider-models/descriptors.ts +3 -1
- package/src/provider-models/openai-compat.ts +41 -1
- package/src/providers/anthropic.ts +7 -1
- package/src/providers/azure-openai-responses.ts +4 -1
- package/src/providers/cursor.ts +256 -101
- package/src/providers/gitlab-duo.ts +18 -1
- package/src/providers/google-gemini-cli.ts +3 -0
- package/src/providers/google-shared.ts +3 -0
- package/src/providers/kiro-codewhisperer.ts +24 -8
- package/src/providers/ollama.ts +3 -0
- package/src/providers/openai-codex-responses.ts +20 -6
- package/src/providers/openai-completions.ts +11 -1
- package/src/providers/openai-responses.ts +10 -1
- package/src/providers/pi-native-client.ts +1 -0
- package/src/providers/pi-native-server.ts +24 -0
- package/src/providers/register-builtins.d.ts +12 -12
- package/src/providers/register-builtins.ts +16 -3
- package/src/stream.d.ts +2 -1
- package/src/stream.ts +175 -67
- package/src/types.d.ts +22 -2
- package/src/types.ts +27 -1
- package/src/utils/oauth/api-key-login.ts +13 -2
- package/src/utils/oauth/api-key-validation.ts +242 -41
- package/src/utils/oauth/commandcode.ts +17 -0
- package/src/utils/oauth/index.ts +20 -5
- package/src/utils/oauth/types.d.ts +1 -1
- package/src/utils/oauth/types.ts +1 -0
- package/src/utils/retry.d.ts +2 -0
- package/src/utils/retry.ts +15 -2
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
bizrouterModelManagerOptions,
|
|
15
15
|
cerebrasModelManagerOptions,
|
|
16
16
|
cloudflareAiGatewayModelManagerOptions,
|
|
17
|
+
commandCodeModelManagerOptions,
|
|
17
18
|
deepinfraModelManagerOptions,
|
|
18
19
|
deepseekModelManagerOptions,
|
|
19
20
|
firepassModelManagerOptions,
|
|
@@ -203,6 +204,7 @@ export const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[] = [
|
|
|
203
204
|
),
|
|
204
205
|
descriptor("opencode-zen", "claude-sonnet-4-6", config => opencodeZenModelManagerOptions(config)),
|
|
205
206
|
descriptor("opencode-go", "kimi-k2.5", config => opencodeGoModelManagerOptions(config)),
|
|
207
|
+
descriptor("commandcode-goat", "zai-org/GLM-5.3", config => commandCodeModelManagerOptions(config)),
|
|
206
208
|
catalogDescriptor(
|
|
207
209
|
"openrouter",
|
|
208
210
|
"openai/gpt-5.4",
|
|
@@ -370,7 +372,7 @@ export const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[] = [
|
|
|
370
372
|
config => cursorModelManagerOptions(config),
|
|
371
373
|
catalog("Cursor", ["CURSOR_API_KEY"], { oauthProvider: "cursor" }),
|
|
372
374
|
),
|
|
373
|
-
descriptor("kiro", "
|
|
375
|
+
descriptor("kiro", "auto", config => kiroModelManagerOptions(config)),
|
|
374
376
|
] as const;
|
|
375
377
|
|
|
376
378
|
/** Default model IDs for all known providers, built from descriptors + special providers. */
|
|
@@ -832,7 +832,7 @@ export interface OpenCodeModelManagerConfig {
|
|
|
832
832
|
}
|
|
833
833
|
|
|
834
834
|
function openCodeModelManagerOptions(
|
|
835
|
-
providerId: "opencode-go" | "opencode-zen",
|
|
835
|
+
providerId: "opencode-go" | "opencode-zen" | "commandcode-goat",
|
|
836
836
|
defaultBaseUrl: string,
|
|
837
837
|
config?: OpenCodeModelManagerConfig,
|
|
838
838
|
): ModelManagerOptions<"openai-completions"> {
|
|
@@ -873,6 +873,46 @@ export function opencodeGoModelManagerOptions(
|
|
|
873
873
|
return openCodeModelManagerOptions("opencode-go", "https://opencode.ai/zen/go/v1", config);
|
|
874
874
|
}
|
|
875
875
|
|
|
876
|
+
export function commandCodeModelManagerOptions(config?: OpenCodeModelManagerConfig): ModelManagerOptions<Api> {
|
|
877
|
+
const apiKey = config?.apiKey;
|
|
878
|
+
const openAiBaseUrl = config?.baseUrl ?? "https://api.commandcode.ai/provider/v1";
|
|
879
|
+
const anthropicBaseUrl = openAiBaseUrl.replace(/\/v1\/?$/u, "");
|
|
880
|
+
return {
|
|
881
|
+
providerId: "commandcode-goat",
|
|
882
|
+
...(apiKey && {
|
|
883
|
+
fetchDynamicModels: () =>
|
|
884
|
+
fetchOpenAICompatibleModels<Api>({
|
|
885
|
+
api: "openai-completions",
|
|
886
|
+
provider: "commandcode-goat",
|
|
887
|
+
baseUrl: openAiBaseUrl,
|
|
888
|
+
apiKey,
|
|
889
|
+
mapModel: (_entry, defaults) => {
|
|
890
|
+
const isClaude = /(?:^|\/)claude(?:[\w.-]|$)/iu.test(defaults.id);
|
|
891
|
+
if (isClaude) {
|
|
892
|
+
return {
|
|
893
|
+
...defaults,
|
|
894
|
+
api: "anthropic-messages",
|
|
895
|
+
baseUrl: anthropicBaseUrl,
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
...defaults,
|
|
900
|
+
api: "openai-completions",
|
|
901
|
+
compat: {
|
|
902
|
+
...defaults.compat,
|
|
903
|
+
supportsStore: false,
|
|
904
|
+
supportsDeveloperRole: false,
|
|
905
|
+
supportsReasoningEffort: false,
|
|
906
|
+
maxTokensField: "max_tokens",
|
|
907
|
+
reasoningContentField: "reasoning_content",
|
|
908
|
+
},
|
|
909
|
+
};
|
|
910
|
+
},
|
|
911
|
+
}),
|
|
912
|
+
}),
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
|
|
876
916
|
// ---------------------------------------------------------------------------
|
|
877
917
|
// 9. Ollama
|
|
878
918
|
// ---------------------------------------------------------------------------
|
|
@@ -2143,6 +2143,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
|
|
|
2143
2143
|
const idleTimeoutAbortError = new Error("Anthropic stream stalled while waiting for the next event");
|
|
2144
2144
|
const { requestSignal } = activeAbortTracker;
|
|
2145
2145
|
setRawRequestDump(params);
|
|
2146
|
+
options?.onStreamCreated?.();
|
|
2146
2147
|
const anthropicRequest = client.messages.create(
|
|
2147
2148
|
{ ...params, stream: true },
|
|
2148
2149
|
{
|
|
@@ -2616,6 +2617,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
|
|
|
2616
2617
|
}
|
|
2617
2618
|
if (
|
|
2618
2619
|
!options?.fallbackManaged &&
|
|
2620
|
+
!options?.disableProviderRetries &&
|
|
2619
2621
|
!disableStrictTools &&
|
|
2620
2622
|
firstTokenTime === undefined &&
|
|
2621
2623
|
hasStrictAnthropicTools(params) &&
|
|
@@ -2636,6 +2638,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
|
|
|
2636
2638
|
!droppedForcedToolChoice &&
|
|
2637
2639
|
firstTokenTime === undefined &&
|
|
2638
2640
|
!options?.fallbackManaged &&
|
|
2641
|
+
!options?.disableProviderRetries &&
|
|
2639
2642
|
isSentForcedAnthropicToolChoice(params.tool_choice) &&
|
|
2640
2643
|
isForcedToolChoiceUnsupportedError(streamFailure, true)
|
|
2641
2644
|
) {
|
|
@@ -2667,6 +2670,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
|
|
|
2667
2670
|
const maskedProxyRejection = isAnthropicMaskedProxyRejection(streamFailure);
|
|
2668
2671
|
if (
|
|
2669
2672
|
!options?.fallbackManaged &&
|
|
2673
|
+
!options?.disableProviderRetries &&
|
|
2670
2674
|
thinkingReplayRepairScope === "none" &&
|
|
2671
2675
|
thinkingReplayRepairAttempts < ANTHROPIC_MAX_THINKING_REPAIRS &&
|
|
2672
2676
|
firstTokenTime === undefined &&
|
|
@@ -2804,6 +2808,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
|
|
|
2804
2808
|
}
|
|
2805
2809
|
if (
|
|
2806
2810
|
!options?.fallbackManaged &&
|
|
2811
|
+
!options?.disableProviderRetries &&
|
|
2807
2812
|
!dropFastMode &&
|
|
2808
2813
|
resolveServiceTier(options?.serviceTier, model.provider) === "priority" &&
|
|
2809
2814
|
firstTokenTime === undefined &&
|
|
@@ -2825,6 +2830,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
|
|
|
2825
2830
|
}
|
|
2826
2831
|
if (
|
|
2827
2832
|
!options?.fallbackManaged &&
|
|
2833
|
+
!options?.disableProviderRetries &&
|
|
2828
2834
|
generatedCacheBudget > 0 &&
|
|
2829
2835
|
firstTokenTime === undefined &&
|
|
2830
2836
|
isAnthropicCacheBreakpointOverflowError(streamFailure)
|
|
@@ -2862,7 +2868,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
|
|
|
2862
2868
|
// Anthropic and non-CPA proxies are untouched.
|
|
2863
2869
|
const cpaAliasFailure = parseCpaToolAliasRestoreFailure(streamFailure);
|
|
2864
2870
|
if (cpaAliasFailure && firstTokenTime === undefined) {
|
|
2865
|
-
if (options?.fallbackManaged) {
|
|
2871
|
+
if (options?.fallbackManaged || options?.disableProviderRetries) {
|
|
2866
2872
|
// The managed fallback controller owns retries: never retry
|
|
2867
2873
|
// inside the attempt it handed us. Record the corrective
|
|
2868
2874
|
// steering against this exact turn and surface the raw error;
|
|
@@ -142,11 +142,13 @@ export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses"
|
|
|
142
142
|
};
|
|
143
143
|
let openaiStream: Awaited<ReturnType<typeof client.responses.create>>;
|
|
144
144
|
try {
|
|
145
|
+
options?.onStreamCreated?.();
|
|
145
146
|
openaiStream = await client.responses.create(params, { signal: requestSignal });
|
|
146
147
|
} catch (error) {
|
|
147
148
|
if (
|
|
148
149
|
!isForcedToolChoiceUnsupportedError(error, isForcedAzureResponsesToolChoice(params.tool_choice)) ||
|
|
149
|
-
options?.fallbackManaged
|
|
150
|
+
options?.fallbackManaged ||
|
|
151
|
+
options?.disableProviderRetries
|
|
150
152
|
) {
|
|
151
153
|
throw error;
|
|
152
154
|
}
|
|
@@ -165,6 +167,7 @@ export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses"
|
|
|
165
167
|
});
|
|
166
168
|
delete params.tool_choice;
|
|
167
169
|
rawRequestDump = { ...rawRequestDump, body: params };
|
|
170
|
+
options?.onStreamCreated?.();
|
|
168
171
|
openaiStream = await client.responses.create(params, { signal: requestSignal });
|
|
169
172
|
}
|
|
170
173
|
streamConnected = true;
|