@adaptic/lumic-utils 1.0.15 → 1.0.17

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.
@@ -7815,12 +7815,19 @@ function sanitizeObject(obj, sensitiveFields = ['apiKey', 'token', 'secret', 'pa
7815
7815
  // llm-anthropic.ts
7816
7816
  /**
7817
7817
  * Determines if an Anthropic API error should be retried.
7818
- * Retries on rate limits (429) and overloaded (529) errors.
7818
+ * Retries on:
7819
+ * - 429 rate limit
7820
+ * - 500 internal server error (transient)
7821
+ * - 503 service unavailable (transient)
7822
+ * - 529 overloaded
7823
+ * - Messages containing "rate limit" or "overloaded"
7819
7824
  */
7820
7825
  const isRetryableAnthropicError = (error) => {
7821
7826
  if (error instanceof Error) {
7822
7827
  const message = error.message;
7823
7828
  if (message.includes('429') ||
7829
+ message.includes('500') ||
7830
+ message.includes('503') ||
7824
7831
  message.includes('529') ||
7825
7832
  message.includes('rate limit') ||
7826
7833
  message.includes('overloaded')) {
@@ -7866,10 +7873,38 @@ function translateContextToAnthropic(context) {
7866
7873
  continue;
7867
7874
  }
7868
7875
  if (msg.role === 'assistant') {
7869
- const content = typeof msg.content === 'string'
7870
- ? msg.content
7871
- : JSON.stringify(msg.content);
7872
- messages.push({ role: 'assistant', content });
7876
+ const assistantMsg = msg;
7877
+ // If the assistant message has tool_calls, translate to Anthropic tool_use blocks
7878
+ if (assistantMsg.tool_calls && assistantMsg.tool_calls.length > 0) {
7879
+ const contentBlocks = [];
7880
+ // Include text content if present
7881
+ if (typeof assistantMsg.content === 'string' && assistantMsg.content.trim()) {
7882
+ contentBlocks.push({ type: 'text', text: assistantMsg.content });
7883
+ }
7884
+ // Translate each tool_call to a tool_use block
7885
+ for (const tc of assistantMsg.tool_calls) {
7886
+ let input = {};
7887
+ try {
7888
+ input = JSON.parse(tc.function.arguments);
7889
+ }
7890
+ catch {
7891
+ input = { raw: tc.function.arguments };
7892
+ }
7893
+ contentBlocks.push({
7894
+ type: 'tool_use',
7895
+ id: tc.id,
7896
+ name: tc.function.name,
7897
+ input,
7898
+ });
7899
+ }
7900
+ messages.push({ role: 'assistant', content: contentBlocks });
7901
+ }
7902
+ else {
7903
+ const content = typeof assistantMsg.content === 'string'
7904
+ ? assistantMsg.content
7905
+ : JSON.stringify(assistantMsg.content);
7906
+ messages.push({ role: 'assistant', content });
7907
+ }
7873
7908
  continue;
7874
7909
  }
7875
7910
  if (msg.role === 'tool') {
@@ -22675,11 +22710,11 @@ let poolConfig = DEFAULT_POOL_CONFIG;
22675
22710
  async function loadApolloModules() {
22676
22711
  if (typeof window === "undefined" || process.env.AWS_EXECUTION_ENV) {
22677
22712
  // Server-side (or Lambda): load the CommonJS‑based implementation.
22678
- return (await Promise.resolve().then(function () { return require('./apollo-client.server-DqSN1Fiy.js'); }));
22713
+ return (await Promise.resolve().then(function () { return require('./apollo-client.server-CS3TcmzK.js'); }));
22679
22714
  }
22680
22715
  else {
22681
22716
  // Client-side: load the ESM‑based implementation.
22682
- return (await Promise.resolve().then(function () { return require('./apollo-client.client-DcvDB-WD.js'); }));
22717
+ return (await Promise.resolve().then(function () { return require('./apollo-client.client-NpMY129A.js'); }));
22683
22718
  }
22684
22719
  }
22685
22720
  /**
@@ -81390,4 +81425,4 @@ exports.withCorrelationId = withCorrelationId;
81390
81425
  exports.withMetrics = withMetrics;
81391
81426
  exports.withRateLimit = withRateLimit;
81392
81427
  exports.withRetry = withRetry;
81393
- //# sourceMappingURL=index-BD1cU0P8.js.map
81428
+ //# sourceMappingURL=index-Y9dzs7p_.js.map