@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/types/auth-broker/client.d.ts +6 -2
  3. package/dist/types/auth-broker/remote-store.d.ts +14 -2
  4. package/dist/types/auth-broker/types.d.ts +6 -0
  5. package/dist/types/auth-broker/wire-schemas.d.ts +19 -0
  6. package/dist/types/auth-gateway/server.d.ts +39 -5
  7. package/dist/types/auth-gateway/types.d.ts +16 -2
  8. package/dist/types/auth-storage.d.ts +92 -24
  9. package/dist/types/provider-models/openai-compat.d.ts +1 -0
  10. package/dist/types/providers/register-builtins.d.ts +12 -12
  11. package/dist/types/stream.d.ts +2 -1
  12. package/dist/types/types.d.ts +22 -2
  13. package/dist/types/utils/oauth/api-key-login.d.ts +4 -1
  14. package/dist/types/utils/oauth/api-key-validation.d.ts +12 -6
  15. package/dist/types/utils/oauth/commandcode.d.ts +1 -0
  16. package/dist/types/utils/oauth/types.d.ts +1 -1
  17. package/dist/types/utils/retry.d.ts +2 -0
  18. package/package.json +3 -3
  19. package/src/auth-broker/client.ts +41 -13
  20. package/src/auth-broker/redact.ts +25 -1
  21. package/src/auth-broker/remote-store.ts +374 -115
  22. package/src/auth-broker/server.ts +131 -91
  23. package/src/auth-broker/types.ts +6 -0
  24. package/src/auth-broker/wire-schemas.ts +6 -0
  25. package/src/auth-gateway/server.ts +447 -79
  26. package/src/auth-gateway/types.ts +28 -2
  27. package/src/auth-storage.ts +658 -154
  28. package/src/cli.ts +1 -0
  29. package/src/models.json +1023 -0
  30. package/src/provider-models/descriptors.ts +3 -1
  31. package/src/provider-models/openai-compat.ts +41 -1
  32. package/src/providers/anthropic.ts +7 -1
  33. package/src/providers/azure-openai-responses.ts +4 -1
  34. package/src/providers/cursor.ts +256 -101
  35. package/src/providers/gitlab-duo.ts +18 -1
  36. package/src/providers/google-gemini-cli.ts +3 -0
  37. package/src/providers/google-shared.ts +3 -0
  38. package/src/providers/kiro-codewhisperer.ts +24 -8
  39. package/src/providers/ollama.ts +3 -0
  40. package/src/providers/openai-codex-responses.ts +20 -6
  41. package/src/providers/openai-completions.ts +11 -1
  42. package/src/providers/openai-responses.ts +10 -1
  43. package/src/providers/pi-native-client.ts +1 -0
  44. package/src/providers/pi-native-server.ts +24 -0
  45. package/src/providers/register-builtins.d.ts +12 -12
  46. package/src/providers/register-builtins.ts +16 -3
  47. package/src/stream.d.ts +2 -1
  48. package/src/stream.ts +175 -67
  49. package/src/types.d.ts +22 -2
  50. package/src/types.ts +27 -1
  51. package/src/utils/oauth/api-key-login.ts +13 -2
  52. package/src/utils/oauth/api-key-validation.ts +242 -41
  53. package/src/utils/oauth/commandcode.ts +17 -0
  54. package/src/utils/oauth/index.ts +20 -5
  55. package/src/utils/oauth/types.d.ts +1 -1
  56. package/src/utils/oauth/types.ts +1 -0
  57. package/src/utils/retry.d.ts +2 -0
  58. 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", "CLAUDE_3_7_SONNET_20250219_V1_0", config => kiroModelManagerOptions(config)),
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;