@bastani/atomic-ai 0.9.90 → 0.10.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/api/anthropic-messages.d.ts.map +1 -1
  3. package/dist/api/anthropic-messages.js +12 -9
  4. package/dist/api/anthropic-messages.js.map +1 -1
  5. package/dist/api/azure-openai-responses.d.ts.map +1 -1
  6. package/dist/api/azure-openai-responses.js +6 -4
  7. package/dist/api/azure-openai-responses.js.map +1 -1
  8. package/dist/api/classifier-shared.d.ts.map +1 -1
  9. package/dist/api/classifier-shared.js +4 -3
  10. package/dist/api/classifier-shared.js.map +1 -1
  11. package/dist/api/google-generative-ai.d.ts.map +1 -1
  12. package/dist/api/google-generative-ai.js +6 -3
  13. package/dist/api/google-generative-ai.js.map +1 -1
  14. package/dist/api/google-shared.d.ts +2 -1
  15. package/dist/api/google-shared.d.ts.map +1 -1
  16. package/dist/api/google-shared.js +3 -2
  17. package/dist/api/google-shared.js.map +1 -1
  18. package/dist/api/google-vertex.d.ts.map +1 -1
  19. package/dist/api/google-vertex.js +8 -4
  20. package/dist/api/google-vertex.js.map +1 -1
  21. package/dist/api/llama-cpp-classify.d.ts.map +1 -1
  22. package/dist/api/llama-cpp-classify.js +6 -4
  23. package/dist/api/llama-cpp-classify.js.map +1 -1
  24. package/dist/api/openai-codex-responses.d.ts.map +1 -1
  25. package/dist/api/openai-codex-responses.js +9 -16
  26. package/dist/api/openai-codex-responses.js.map +1 -1
  27. package/dist/api/openai-completions.d.ts.map +1 -1
  28. package/dist/api/openai-completions.js +34 -6
  29. package/dist/api/openai-completions.js.map +1 -1
  30. package/dist/api/openai-decisions.d.ts.map +1 -1
  31. package/dist/api/openai-decisions.js +2 -1
  32. package/dist/api/openai-decisions.js.map +1 -1
  33. package/dist/api/openai-images.d.ts.map +1 -1
  34. package/dist/api/openai-images.js +6 -4
  35. package/dist/api/openai-images.js.map +1 -1
  36. package/dist/api/openai-responses.d.ts.map +1 -1
  37. package/dist/api/openai-responses.js +6 -4
  38. package/dist/api/openai-responses.js.map +1 -1
  39. package/dist/api/openrouter-images.d.ts.map +1 -1
  40. package/dist/api/openrouter-images.js +6 -4
  41. package/dist/api/openrouter-images.js.map +1 -1
  42. package/dist/api/simple-options.d.ts.map +1 -1
  43. package/dist/api/simple-options.js +1 -0
  44. package/dist/api/simple-options.js.map +1 -1
  45. package/dist/api/system-one-shared.d.ts.map +1 -1
  46. package/dist/api/system-one-shared.js +2 -1
  47. package/dist/api/system-one-shared.js.map +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1 -0
  51. package/dist/index.js.map +1 -1
  52. package/dist/providers/data/.manifest.json +1 -1
  53. package/dist/providers/data/amazon-bedrock.json +1 -1
  54. package/dist/providers/data/fireworks.json +1 -1
  55. package/dist/providers/data/opencode.json +1 -1
  56. package/dist/providers/data/openrouter.json +1 -1
  57. package/dist/providers/data/vercel-ai-gateway.json +1 -1
  58. package/dist/providers/github-copilot-stop-reason.d.ts +14 -0
  59. package/dist/providers/github-copilot-stop-reason.d.ts.map +1 -0
  60. package/dist/providers/github-copilot-stop-reason.js +27 -0
  61. package/dist/providers/github-copilot-stop-reason.js.map +1 -0
  62. package/dist/types.d.ts +11 -0
  63. package/dist/types.d.ts.map +1 -1
  64. package/dist/types.js.map +1 -1
  65. package/dist/utils/provider-retry.d.ts +20 -1
  66. package/dist/utils/provider-retry.d.ts.map +1 -1
  67. package/dist/utils/provider-retry.js +46 -19
  68. package/dist/utils/provider-retry.js.map +1 -1
  69. package/dist/utils/retry-sleep.d.ts +10 -0
  70. package/dist/utils/retry-sleep.d.ts.map +1 -0
  71. package/dist/utils/retry-sleep.js +38 -0
  72. package/dist/utils/retry-sleep.js.map +1 -0
  73. package/dist/utils/retry.d.ts +6 -2
  74. package/dist/utils/retry.d.ts.map +1 -1
  75. package/dist/utils/retry.js +9 -1
  76. package/dist/utils/retry.js.map +1 -1
  77. package/dist/utils/sse.d.ts +11 -0
  78. package/dist/utils/sse.d.ts.map +1 -1
  79. package/dist/utils/sse.js +131 -0
  80. package/dist/utils/sse.js.map +1 -1
  81. package/dist/utils/version.d.ts +1 -1
  82. package/dist/utils/version.js +1 -1
  83. package/dist/utils/version.js.map +1 -1
  84. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ This package is Atomic's fork of `@earendil-works/pi-ai`, published as `@bastani
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.10.0] - 2026-11-20
8
+
9
+ ### Added
10
+
11
+ - Provider requests and `retryAssistantCall()` accept `retryDeadline`, an absolute `performance.now()` timestamp. An Atomic-managed backoff retry that reaches the deadline is not sent, even if the caller's abort timer has not fired. Omitting it keeps the original retry timing ([#5627](https://github.com/bastani-inc/atomic/issues/5627)).
12
+
13
+ ### Fixed
14
+
15
+ - Fixed GitHub Copilot turns on Chat Completions, seen with Gemini models, failing with `stream-ended-early` when the response stream ended normally but reported no finish reason. GitHub Copilot sometimes ends a response stream normally without reporting a finish reason. For every GitHub Copilot model on Chat Completions, Atomic now tells such a response from a cut-off stream by the stream's final `[DONE]` event: a response whose tool calls are all complete ends with `toolUse`, a response with text and no tool call ends with `stop`, and a response with neither is the retryable `empty-response` error. A tool call that may be incomplete, or a stream that ends without `[DONE]`, is still a retryable `stream-ended-early`. An inferred stop reason is noted in the message's diagnostics as `github_copilot_inferred_stop_reason` (`GITHUB_COPILOT_INFERRED_STOP_REASON_DIAGNOSTIC`), so `/debug` output and session exports show it. Streams that report a finish reason, and other providers, are unchanged ([#6028](https://github.com/bastani-inc/atomic/pull/6028)).
16
+
17
+ ## [0.10.0-alpha.1] - 2026-11-20
18
+
19
+ ### Added
20
+
21
+ - Provider requests and `retryAssistantCall()` accept `retryDeadline`, an absolute `performance.now()` timestamp. An Atomic-managed backoff retry that reaches the deadline is not sent, even if the caller's abort timer has not fired. Omitting it keeps the original retry timing ([#5627](https://github.com/bastani-inc/atomic/issues/5627)).
22
+
23
+ ### Fixed
24
+
25
+ - Fixed GitHub Copilot turns on Chat Completions, seen with Gemini models, failing with `stream-ended-early` when the response stream ended normally but reported no finish reason. GitHub Copilot sometimes ends a response stream normally without reporting a finish reason. For every GitHub Copilot model on Chat Completions, Atomic now tells such a response from a cut-off stream by the stream's final `[DONE]` event: a response whose tool calls are all complete ends with `toolUse`, a response with text and no tool call ends with `stop`, and a response with neither is the retryable `empty-response` error. A tool call that may be incomplete, or a stream that ends without `[DONE]`, is still a retryable `stream-ended-early`. An inferred stop reason is noted in the message's diagnostics as `github_copilot_inferred_stop_reason` (`GITHUB_COPILOT_INFERRED_STOP_REASON_DIAGNOSTIC`), so `/debug` output and session exports show it. Streams that report a finish reason, and other providers, are unchanged ([#6028](https://github.com/bastani-inc/atomic/pull/6028)).
26
+
7
27
  ## [0.9.89] - 2026-11-18
8
28
 
9
29
  ### Added
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAkD,MAAM,mBAAmB,CAAC;AAqBnF,OAAO,KAAK,EASX,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAMb,MAAM,aAAa,CAAC;AA6LrB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAgfhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,C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E,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAkOD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAgczE,CAAC;AA+CF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAgDlF,CAAC"}
@@ -16,7 +16,8 @@ import { inlineImageMimeType, unsupportedImagePlaceholder } from "../utils/inlin
16
16
  import { parseJsonWithRepair } from "../utils/json-parse.js";
17
17
  import { applyOpenRouterReportedCost, isOpenRouterModel, } from "../utils/openrouter-cost.js";
18
18
  import { getAtomicEnvValue, getProviderEnvValue } from "../utils/provider-env.js";
19
- import { retryProviderRequest } from "../utils/provider-retry.js";
19
+ import { ProviderRetryTransport, retryProviderRequest } from "../utils/provider-retry.js";
20
+ import { RetryDeadlineError } from "../utils/retry-sleep.js";
20
21
  import { getFetchAdmission } from "../utils/request-admission.js";
21
22
  import { getProviderRetryAfterMs } from "../utils/retry-hints.js";
22
23
  import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
@@ -755,6 +756,7 @@ export const stream = (model, context, options) => {
755
756
  if (thinkingOffFallback) {
756
757
  appendThinkingOffFallbackDiagnostic(output, thinkingOffFallback.level, thinkingOffFallback.effort);
757
758
  }
759
+ const retryTransport = options?.client ? undefined : ProviderRetryTransport.for(options);
758
760
  let client;
759
761
  let isOAuth;
760
762
  let usageModel = model;
@@ -787,7 +789,7 @@ export const stream = (model, context, options) => {
787
789
  }
788
790
  const created = createClient(model, apiKey, model.reasoning && options?.thinkingEnabled === true && (options.interleavedThinking ?? true), shouldUseFineGrainedToolStreamingBeta(model, context), shouldUseServerSideFallbackBeta(model), options?.headers, options?.fetch, copilotDynamicHeaders, cacheSessionId, compat.supportsMidConvoToolChanges &&
789
791
  compat.supportsMidConvoSystemMessages &&
790
- (getInitialSystemMessage(normalizedContext.messages)?.toolsAdded?.length ?? 0) > 0, federation, options?.identity, threadSessionId !== undefined);
792
+ (getInitialSystemMessage(normalizedContext.messages)?.toolsAdded?.length ?? 0) > 0, federation, options?.identity, threadSessionId !== undefined, retryTransport);
791
793
  client = created.client;
792
794
  isOAuth = created.isOAuthToken;
793
795
  }
@@ -805,8 +807,9 @@ export const stream = (model, context, options) => {
805
807
  }, {
806
808
  maxRetries: options?.maxRetries,
807
809
  maxRetryDelayMs: options?.maxRetryDelayMs,
810
+ retryDeadline: options?.retryDeadline,
808
811
  signal: streamDeadline.signal,
809
- });
812
+ }, retryTransport);
810
813
  let disablePreferredStrictTools = hasExceededStrictToolLimits(options?.sessionId);
811
814
  let response;
812
815
  let params;
@@ -1116,7 +1119,7 @@ export const stream = (model, context, options) => {
1116
1119
  !output.diagnostics?.some((diagnostic) => diagnostic.type === "anthropic_input_transformations")) {
1117
1120
  recordInputTransformations(output, inputTransformations);
1118
1121
  }
1119
- output.stopReason = options?.signal?.aborted ? "aborted" : "error";
1122
+ output.stopReason = options?.signal?.aborted || error instanceof RetryDeadlineError ? "aborted" : "error";
1120
1123
  output.errorMessage = error instanceof Error ? withCauseDetail(error) : JSON.stringify(error);
1121
1124
  appendProviderResponseFailureDiagnostic(output, error);
1122
1125
  output.retryAfterMs = error instanceof Error ? getProviderRetryAfterMs(error) : undefined;
@@ -1203,7 +1206,7 @@ export const streamSimple = (model, context, options) => {
1203
1206
  function isOAuthToken(apiKey) {
1204
1207
  return apiKey.includes("sk-ant-oat");
1205
1208
  }
1206
- function createClient(model, apiKey, interleavedThinking, useFineGrainedToolStreamingBeta, useServerSideFallbackBeta, optionsHeaders, fetch, dynamicHeaders, sessionId, useNativeToolChanges = false, federation, identity, useMessageThreads = false) {
1209
+ function createClient(model, apiKey, interleavedThinking, useFineGrainedToolStreamingBeta, useServerSideFallbackBeta, optionsHeaders, fetch, dynamicHeaders, sessionId, useNativeToolChanges = false, federation, identity, useMessageThreads = false, retryTransport) {
1207
1210
  // Adaptive thinking models have interleaved thinking built in, so skip the beta header.
1208
1211
  const needsInterleavedBeta = interleavedThinking && model.compat?.forceAdaptiveThinking !== true;
1209
1212
  const betaFeatures = [];
@@ -1236,7 +1239,7 @@ function createClient(model, apiKey, interleavedThinking, useFineGrainedToolStre
1236
1239
  authToken: apiKey ?? null,
1237
1240
  baseURL: model.baseUrl,
1238
1241
  dangerouslyAllowBrowser: true,
1239
- fetch,
1242
+ fetch: retryTransport?.fetch ?? fetch,
1240
1243
  defaultHeaders: mergeHeaders(getIdentityHeaders(model, identity), {
1241
1244
  accept: "application/json",
1242
1245
  "anthropic-dangerous-direct-browser-access": "true",
@@ -1252,7 +1255,7 @@ function createClient(model, apiKey, interleavedThinking, useFineGrainedToolStre
1252
1255
  authToken: apiKey,
1253
1256
  baseURL: model.baseUrl,
1254
1257
  dangerouslyAllowBrowser: true,
1255
- fetch,
1258
+ fetch: retryTransport?.fetch ?? fetch,
1256
1259
  defaultHeaders: mergeHeaders({
1257
1260
  accept: "application/json",
1258
1261
  "anthropic-dangerous-direct-browser-access": "true",
@@ -1288,14 +1291,14 @@ function createClient(model, apiKey, interleavedThinking, useFineGrainedToolStre
1288
1291
  });
1289
1292
  federationClient = { key, fetch, client };
1290
1293
  }
1291
- return { client: federationClient.client.withOptions({ defaultHeaders, fetch }), isOAuthToken: false };
1294
+ return { client: federationClient.client.withOptions({ defaultHeaders, fetch: retryTransport?.fetch ?? fetch }), isOAuthToken: false };
1292
1295
  }
1293
1296
  const client = new AtomicAnthropic({
1294
1297
  apiKey: apiKey ?? null,
1295
1298
  authToken: null,
1296
1299
  baseURL: model.baseUrl,
1297
1300
  dangerouslyAllowBrowser: true,
1298
- fetch,
1301
+ fetch: retryTransport?.fetch ?? fetch,
1299
1302
  defaultHeaders,
1300
1303
  });
1301
1304
  return { client, isOAuthToken: false };