@adaptic/lumic-utils 1.0.17 → 1.0.18

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.
@@ -7921,7 +7921,30 @@ function translateContextToAnthropic(context) {
7921
7921
  continue;
7922
7922
  }
7923
7923
  }
7924
- return { messages, systemText: systemParts.join('\n\n') };
7924
+ // Anthropic requires alternating user/assistant roles — merge consecutive
7925
+ // same-role messages into a single message with combined content blocks.
7926
+ const merged = [];
7927
+ for (const msg of messages) {
7928
+ const prev = merged[merged.length - 1];
7929
+ if (prev && prev.role === msg.role) {
7930
+ // Merge into the previous message by combining content blocks
7931
+ const prevBlocks = toContentBlocks(prev.content);
7932
+ const curBlocks = toContentBlocks(msg.content);
7933
+ prev.content = [...prevBlocks, ...curBlocks];
7934
+ }
7935
+ else {
7936
+ // Ensure content is in block form for consistency (string → TextBlock)
7937
+ merged.push({ role: msg.role, content: toContentBlocks(msg.content) });
7938
+ }
7939
+ }
7940
+ return { messages: merged, systemText: systemParts.join('\n\n') };
7941
+ }
7942
+ /** Convert string or content block array to a uniform content block array. */
7943
+ function toContentBlocks(content) {
7944
+ if (typeof content === 'string') {
7945
+ return [{ type: 'text', text: content }];
7946
+ }
7947
+ return content;
7925
7948
  }
7926
7949
  /**
7927
7950
  * Makes a call to the Anthropic Messages API.
@@ -22710,11 +22733,11 @@ let poolConfig = DEFAULT_POOL_CONFIG;
22710
22733
  async function loadApolloModules() {
22711
22734
  if (typeof window === "undefined" || process.env.AWS_EXECUTION_ENV) {
22712
22735
  // Server-side (or Lambda): load the CommonJS‑based implementation.
22713
- return (await Promise.resolve().then(function () { return require('./apollo-client.server-CS3TcmzK.js'); }));
22736
+ return (await Promise.resolve().then(function () { return require('./apollo-client.server-BAuFJqgR.js'); }));
22714
22737
  }
22715
22738
  else {
22716
22739
  // Client-side: load the ESM‑based implementation.
22717
- return (await Promise.resolve().then(function () { return require('./apollo-client.client-NpMY129A.js'); }));
22740
+ return (await Promise.resolve().then(function () { return require('./apollo-client.client-Cz-ZMwuK.js'); }));
22718
22741
  }
22719
22742
  }
22720
22743
  /**
@@ -81425,4 +81448,4 @@ exports.withCorrelationId = withCorrelationId;
81425
81448
  exports.withMetrics = withMetrics;
81426
81449
  exports.withRateLimit = withRateLimit;
81427
81450
  exports.withRetry = withRetry;
81428
- //# sourceMappingURL=index-Y9dzs7p_.js.map
81451
+ //# sourceMappingURL=index-C3ihLNel.js.map