@maximem/synap-js-sdk 0.5.11 → 0.5.12

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/dist/index.cjs CHANGED
@@ -639,6 +639,7 @@ function buildFetchRequest(scope, options) {
639
639
  const perQuery = opt(options, "max_results_per_query", "maxResultsPerQuery");
640
640
  const responseShape = responseShapeOf(options);
641
641
  const { mode, precisionLevel } = retrievalOptionsOf(options);
642
+ const { contextMode, lastN } = scopeOptionsOf(scope, options);
642
643
  if (searchQuery !== void 0 && !Array.isArray(searchQuery)) {
643
644
  throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("search_query must be an array when provided");
644
645
  }
@@ -666,21 +667,7 @@ function buildFetchRequest(scope, options) {
666
667
  switch (scope) {
667
668
  case "user":
668
669
  {
669
- if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
670
670
  body["user_id"] = userId;
671
- const contextMode = _nullishCoalesce(opt(options, "context_mode", "contextMode"), () => ( "in-conversation"));
672
- if (!VALID_CONTEXT_MODES.includes(contextMode)) {
673
- throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
674
- `Invalid context_mode '${contextMode}'. Must be one of: ${VALID_CONTEXT_MODES.join(", ")}`
675
- );
676
- }
677
- const lastN = _nullishCoalesce(opt(options, "last_n_conversations", "lastNConversations"), () => ( 1));
678
- if (!Number.isInteger(lastN)) {
679
- throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("last_n_conversations must be an integer");
680
- }
681
- if (lastN < 0 || lastN > 20) {
682
- throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("last_n_conversations must be between 0 and 20");
683
- }
684
671
  if (contextMode === "conversation-summary") {
685
672
  body["context_mode"] = contextMode;
686
673
  body["include_profile"] = _nullishCoalesce(opt(options, "include_profile", "includeProfile"), () => ( true));
@@ -691,11 +678,9 @@ function buildFetchRequest(scope, options) {
691
678
  }
692
679
  break;
693
680
  case "customer":
694
- if (!customerId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("customer_id is required");
695
681
  body["customer_id"] = customerId;
696
682
  break;
697
683
  case "conversation":
698
- if (!conversationId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("conversation_id is required");
699
684
  if (userId !== void 0) body["user_id"] = userId;
700
685
  if (customerId !== void 0) body["customer_id"] = customerId;
701
686
  break;
@@ -714,6 +699,33 @@ function responseShapeOf(options) {
714
699
  }
715
700
  return shape;
716
701
  }
702
+ var REQUIRED_ID = {
703
+ user: ["user_id", "userId"],
704
+ customer: ["customer_id", "customerId"],
705
+ conversation: ["conversation_id", "conversationId"],
706
+ client: null
707
+ };
708
+ function scopeOptionsOf(scope, options) {
709
+ const required = REQUIRED_ID[scope];
710
+ if (required !== null && !opt(options, required[0], required[1])) {
711
+ throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(`${required[0]} is required`);
712
+ }
713
+ const contextMode = _nullishCoalesce(opt(options, "context_mode", "contextMode"), () => ( "in-conversation"));
714
+ const lastN = _nullishCoalesce(opt(options, "last_n_conversations", "lastNConversations"), () => ( 1));
715
+ if (scope !== "user") return { contextMode, lastN };
716
+ if (!VALID_CONTEXT_MODES.includes(contextMode)) {
717
+ throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
718
+ `Invalid context_mode '${contextMode}'. Must be one of: ${VALID_CONTEXT_MODES.join(", ")}`
719
+ );
720
+ }
721
+ if (!Number.isInteger(lastN)) {
722
+ throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("last_n_conversations must be an integer");
723
+ }
724
+ if (lastN < 0 || lastN > 20) {
725
+ throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("last_n_conversations must be between 0 and 20");
726
+ }
727
+ return { contextMode, lastN };
728
+ }
717
729
  var VALID_MODES = ["fast", "accurate"];
718
730
  var VALID_PRECISION = ["high", "medium"];
719
731
  function retrievalOptionsOf(options) {
@@ -740,12 +752,18 @@ async function fetchContext(transport, scope, options = {}, hooks = {}) {
740
752
  );
741
753
  const responseShape = responseShapeOf(options);
742
754
  retrievalOptionsOf(options);
755
+ const { contextMode } = scopeOptionsOf(scope, options);
756
+ const summaryMode = scope === "user" && contextMode === "conversation-summary";
757
+ const finish = (response2) => {
758
+ _optionalChain([hooks, 'access', _27 => _27.onResponse, 'optionalCall', _28 => _28(scope, options, response2)]);
759
+ return response2;
760
+ };
743
761
  const network = async () => {
744
762
  const { endpoint, body } = buildFetchRequest(scope, options);
745
763
  const result = await transport.request(endpoint, { body });
746
- return applyResponseShape(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _27 => _27["context"]]), () => ( {})), responseShape);
764
+ return applyResponseShape(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _29 => _29["context"]]), () => ( {})), responseShape);
747
765
  };
748
- const anticipated = await _asyncNullishCoalesce(await _optionalChain([hooks, 'access', _28 => _28.beforeFetch, 'optionalCall', _29 => _29(scope, options)]), async () => ( null));
766
+ const anticipated = summaryMode ? null : await _asyncNullishCoalesce(await _optionalChain([hooks, 'access', _30 => _30.beforeFetch, 'optionalCall', _31 => _31(scope, options)]), async () => ( null));
749
767
  if (anticipated !== null && anticipated.borderline) {
750
768
  const pending = network();
751
769
  pending.catch(() => void 0);
@@ -756,18 +774,18 @@ async function fetchContext(transport, scope, options = {}, hooks = {}) {
756
774
  const won = await Promise.race([pending.then((r) => r, () => null), late]);
757
775
  if (timer !== void 0) clearTimeout(timer);
758
776
  if (won !== null) {
759
- _optionalChain([hooks, 'access', _30 => _30.onAssembled, 'optionalCall', _31 => _31(scope, options, won, startedAt)]);
760
- return won;
777
+ _optionalChain([hooks, 'access', _32 => _32.onAssembled, 'optionalCall', _33 => _33(scope, options, won, startedAt)]);
778
+ return finish(won);
761
779
  }
762
780
  }
763
781
  if (anticipated !== null) {
764
- _optionalChain([hooks, 'access', _32 => _32.onServedFromCache, 'optionalCall', _33 => _33(scope, options, anticipated)]);
765
- _optionalChain([hooks, 'access', _34 => _34.onAssembled, 'optionalCall', _35 => _35(scope, options, anticipated.response, startedAt)]);
766
- return applyResponseShape(anticipated.response, responseShape);
782
+ _optionalChain([hooks, 'access', _34 => _34.onServedFromCache, 'optionalCall', _35 => _35(scope, options, anticipated)]);
783
+ _optionalChain([hooks, 'access', _36 => _36.onAssembled, 'optionalCall', _37 => _37(scope, options, anticipated.response, startedAt)]);
784
+ return finish(applyResponseShape(anticipated.response, responseShape));
767
785
  }
768
786
  const response = await network();
769
- _optionalChain([hooks, 'access', _36 => _36.onAssembled, 'optionalCall', _37 => _37(scope, options, response, startedAt)]);
770
- return response;
787
+ _optionalChain([hooks, 'access', _38 => _38.onAssembled, 'optionalCall', _39 => _39(scope, options, response, startedAt)]);
788
+ return finish(response);
771
789
  }
772
790
 
773
791
  // src/context/normalize.ts
@@ -1169,7 +1187,7 @@ function createMemoriesInterface(transport, onForgotten) {
1169
1187
  await transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.forget");
1170
1188
  const body = buildForgetBody(options);
1171
1189
  const result = await transport.request("memories_forget", { body });
1172
- const removed = !!_optionalChain([result, 'optionalAccess', _38 => _38.deleted_ids, 'optionalAccess', _39 => _39.length]) || _optionalChain([result, 'optionalAccess', _40 => _40.status]) === "deleted" || _optionalChain([result, 'optionalAccess', _41 => _41.status]) === "partial";
1190
+ const removed = !!_optionalChain([result, 'optionalAccess', _40 => _40.deleted_ids, 'optionalAccess', _41 => _41.length]) || _optionalChain([result, 'optionalAccess', _42 => _42.status]) === "deleted" || _optionalChain([result, 'optionalAccess', _43 => _43.status]) === "partial";
1173
1191
  if (removed && onForgotten) {
1174
1192
  try {
1175
1193
  onForgotten({
@@ -1209,14 +1227,14 @@ function sleep2(ms, signal) {
1209
1227
  if (ms <= 0) return Promise.resolve();
1210
1228
  return new Promise((resolve, reject) => {
1211
1229
  const timer = setTimeout(() => {
1212
- _optionalChain([signal, 'optionalAccess', _42 => _42.removeEventListener, 'call', _43 => _43("abort", onAbort)]);
1230
+ _optionalChain([signal, 'optionalAccess', _44 => _44.removeEventListener, 'call', _45 => _45("abort", onAbort)]);
1213
1231
  resolve();
1214
1232
  }, ms);
1215
1233
  function onAbort() {
1216
1234
  clearTimeout(timer);
1217
- reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _44 => _44.reason]), () => ( new Error("Aborted"))));
1235
+ reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _46 => _46.reason]), () => ( new Error("Aborted"))));
1218
1236
  }
1219
- _optionalChain([signal, 'optionalAccess', _45 => _45.addEventListener, 'call', _46 => _46("abort", onAbort, { once: true })]);
1237
+ _optionalChain([signal, 'optionalAccess', _47 => _47.addEventListener, 'call', _48 => _48("abort", onAbort, { once: true })]);
1220
1238
  });
1221
1239
  }
1222
1240
 
@@ -1389,7 +1407,7 @@ function storedBatchRows(bodies, result) {
1389
1407
  const r = _nullishCoalesce(result, () => ( {}));
1390
1408
  const results = Array.isArray(r["results"]) ? r["results"] : [];
1391
1409
  const errors = Array.isArray(r["errors"]) ? r["errors"] : [];
1392
- const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess', _47 => _47["index"]])));
1410
+ const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess', _49 => _49["index"]])));
1393
1411
  const stored = bodies.filter((_, index) => !failed.has(index));
1394
1412
  if (stored.length !== results.length) return [];
1395
1413
  const pairs = [];
@@ -1535,8 +1553,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
1535
1553
  pathParams: { conversation_id: id },
1536
1554
  query: { style: _nullishCoalesce(options.style, () => ( "structured")) }
1537
1555
  });
1538
- const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _48 => _48["context_for_prompt"]]), () => ( result)), () => ( {}));
1539
- _optionalChain([localShortTerm, 'access', _49 => _49.reseed, 'optionalCall', _50 => _50(id, response)]);
1556
+ const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _50 => _50["context_for_prompt"]]), () => ( result)), () => ( {}));
1557
+ _optionalChain([localShortTerm, 'access', _51 => _51.reseed, 'optionalCall', _52 => _52(id, response)]);
1540
1558
  return withHistory(response);
1541
1559
  },
1542
1560
  async compact(options) {
@@ -1729,8 +1747,8 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1729
1747
  let onConversationState = null;
1730
1748
  const internals = {
1731
1749
  onCompactionUpdate(conversationId, bundle) {
1732
- _optionalChain([applyCompaction, 'optionalCall', _51 => _51(bundle)]);
1733
- _optionalChain([dispatchCompaction, 'optionalCall', _52 => _52(conversationId, bundle)]);
1750
+ _optionalChain([applyCompaction, 'optionalCall', _53 => _53(bundle)]);
1751
+ _optionalChain([dispatchCompaction, 'optionalCall', _54 => _54(conversationId, bundle)]);
1734
1752
  },
1735
1753
  setCompactionApplier(apply) {
1736
1754
  applyCompaction = apply;
@@ -1742,10 +1760,10 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1742
1760
  onConversationState = handle;
1743
1761
  },
1744
1762
  sendContextUsed(event) {
1745
- _optionalChain([client, 'optionalAccess', _53 => _53.sendContextUsed, 'call', _54 => _54(event)]);
1763
+ _optionalChain([client, 'optionalAccess', _55 => _55.sendContextUsed, 'call', _56 => _56(event)]);
1746
1764
  },
1747
1765
  sendContextAssembled(event) {
1748
- _optionalChain([client, 'optionalAccess', _55 => _55.sendContextAssembled, 'call', _56 => _56(event)]);
1766
+ _optionalChain([client, 'optionalAccess', _57 => _57.sendContextAssembled, 'call', _58 => _58(event)]);
1749
1767
  },
1750
1768
  setCompactionDispatcher(dispatch) {
1751
1769
  dispatchCompaction = dispatch;
@@ -1776,7 +1794,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1776
1794
  throw new (0, _chunkUXNVTP4Dcjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
1777
1795
  }
1778
1796
  try {
1779
- _optionalChain([onListen, 'optionalCall', _57 => _57()]);
1797
+ _optionalChain([onListen, 'optionalCall', _59 => _59()]);
1780
1798
  } catch (e10) {
1781
1799
  }
1782
1800
  const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-5GYUWETN.cjs")));
@@ -1794,17 +1812,17 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1794
1812
  internals.onCompactionUpdate(conversationId, bundle);
1795
1813
  },
1796
1814
  onConversationState: (conversationId, messageCount) => {
1797
- _optionalChain([onConversationState, 'optionalCall', _58 => _58(conversationId, messageCount)]);
1815
+ _optionalChain([onConversationState, 'optionalCall', _60 => _60(conversationId, messageCount)]);
1798
1816
  },
1799
1817
  onStateChange: (state) => {
1800
1818
  if (state !== "connected") openSessions.clear();
1801
1819
  if (state === "reconnecting") {
1802
1820
  reconnectAttempts += 1;
1803
- _optionalChain([onReconnect, 'optionalCall', _59 => _59(reconnectAttempts)]);
1821
+ _optionalChain([onReconnect, 'optionalCall', _61 => _61(reconnectAttempts)]);
1804
1822
  } else if (state === "disconnected") {
1805
- const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _60 => _60.lastError]), () => ( null));
1823
+ const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _62 => _62.lastError]), () => ( null));
1806
1824
  const reason = stopped === null ? "stream disconnected" : `credit_stop:${_nullishCoalesce(stopped.reason, () => ( "unknown"))}`;
1807
- _optionalChain([onDisconnect, 'optionalCall', _61 => _61(reason)]);
1825
+ _optionalChain([onDisconnect, 'optionalCall', _63 => _63(reason)]);
1808
1826
  }
1809
1827
  }
1810
1828
  });
@@ -1814,7 +1832,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1814
1832
  } catch (error) {
1815
1833
  if (error instanceof _chunkUXNVTP4Dcjs.SynapError) throw error;
1816
1834
  throw new (0, _chunkUXNVTP4Dcjs.SynapError)(
1817
- `Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _62 => _62.message]), () => ( String(error)))}`,
1835
+ `Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _64 => _64.message]), () => ( String(error)))}`,
1818
1836
  { cause: error }
1819
1837
  );
1820
1838
  }
@@ -1860,7 +1878,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1860
1878
  _nullishCoalesce(_nullishCoalesce(options.customer_id, () => ( options.customerId)), () => ( ""))
1861
1879
  );
1862
1880
  if (eventType === "user_message" || eventType === "assistant_message") {
1863
- _optionalChain([onTurn, 'optionalCall', _63 => _63({
1881
+ _optionalChain([onTurn, 'optionalCall', _65 => _65({
1864
1882
  conversationId,
1865
1883
  role: _nullishCoalesce(options.role, () => ( "user")),
1866
1884
  content: options.content
@@ -1906,7 +1924,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1906
1924
  async record_tool_result(options) {
1907
1925
  const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
1908
1926
  if (conversationId) {
1909
- _optionalChain([onToolResult, 'optionalCall', _64 => _64({ conversationId, result: options.result, toolName: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")) })]);
1927
+ _optionalChain([onToolResult, 'optionalCall', _66 => _66({ conversationId, result: options.result, toolName: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")) })]);
1910
1928
  }
1911
1929
  await namespace.send_message({
1912
1930
  content: "",
@@ -1958,7 +1976,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1958
1976
  }
1959
1977
 
1960
1978
  // src/version.ts
1961
- var SDK_VERSION = "0.5.11";
1979
+ var SDK_VERSION = "0.5.12";
1962
1980
 
1963
1981
  // src/registry.ts
1964
1982
  var instances = /* @__PURE__ */ new Map();
@@ -2426,7 +2444,7 @@ var TurnStore = (_class3 = class {
2426
2444
  }
2427
2445
  /** Turns the server also holds: archived tool results are local only. Python: `count`. */
2428
2446
  count(conversationId) {
2429
- return (_nullishCoalesce(_optionalChain([this, 'access', _65 => _65.#conversations, 'access', _66 => _66.get, 'call', _67 => _67(conversationId), 'optionalAccess', _68 => _68.turns]), () => ( []))).filter((t) => t.role !== "tool").length;
2447
+ return (_nullishCoalesce(_optionalChain([this, 'access', _67 => _67.#conversations, 'access', _68 => _68.get, 'call', _69 => _69(conversationId), 'optionalAccess', _70 => _70.turns]), () => ( []))).filter((t) => t.role !== "tool").length;
2430
2448
  }
2431
2449
  sizeBytes() {
2432
2450
  let n2 = 0;
@@ -2605,7 +2623,7 @@ function askedKinds(query) {
2605
2623
  }
2606
2624
  function asksHowItStarted(query) {
2607
2625
  const spec = _chunkICUFS3B5cjs.HISTORY_SEARCH.early_query;
2608
- if (!_optionalChain([spec, 'optionalAccess', _69 => _69.pattern])) return false;
2626
+ if (!_optionalChain([spec, 'optionalAccess', _71 => _71.pattern])) return false;
2609
2627
  return new RegExp(spec.pattern, (_nullishCoalesce(spec.flags, () => ( ""))).includes("i") ? "i" : "").test(_nullishCoalesce(query, () => ( "")));
2610
2628
  }
2611
2629
  async function searchTurns(turns, query, options = {}) {
@@ -3776,6 +3794,21 @@ var SynapClient = (_class4 = class _SynapClient {
3776
3794
  },
3777
3795
  onServedFromCache: (_scope, options2, served) => {
3778
3796
  this.#emitContextUsed(options2, _scope, served);
3797
+ },
3798
+ // The periodic user-summary splice, as Python runs it at the end of the
3799
+ // user, customer and client fetches (the conversation fetch does its own
3800
+ // through `onFetched`). Until 0.5.12 only the conversation fetch had it,
3801
+ // so the same usage gave the model different context in JS.
3802
+ onResponse: (scope, options2, response) => {
3803
+ if (scope === "conversation") return;
3804
+ const o2 = options2;
3805
+ const owner = scope === "user" ? _nullishCoalesce(o2["user_id"], () => ( o2["userId"])) : scope === "customer" ? _nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])) : "_client";
3806
+ this.#injectUserSummary(
3807
+ response,
3808
+ _nullishCoalesce(o2["conversation_id"], () => ( o2["conversationId"])),
3809
+ owner,
3810
+ _chunkICUFS3B5cjs.rungKey.call(void 0, _nullishCoalesce(o2["scope_path"], () => ( o2["scopePath"])))
3811
+ );
3779
3812
  }
3780
3813
  };
3781
3814
  this.user = createUserNamespace(this.#transport, this.#fetchHooks);
@@ -3795,7 +3828,7 @@ var SynapClient = (_class4 = class _SynapClient {
3795
3828
  this.#localEncoder = _nullishCoalesce(_nullishCoalesce(options.history_search_encoder, () => ( options.historySearchEncoder)), () => ( null));
3796
3829
  const modelOption = options.history_search_model !== void 0 ? options.history_search_model : options.historySearchModel;
3797
3830
  this.#localModelName = modelOption === void 0 ? "auto" : modelOption;
3798
- if (_optionalChain([this, 'access', _70 => _70.#localEncoder, 'optionalAccess', _71 => _71.model]) === _chunkICUFS3B5cjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(this.#localEncoder);
3831
+ if (_optionalChain([this, 'access', _72 => _72.#localEncoder, 'optionalAccess', _73 => _73.model]) === _chunkICUFS3B5cjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(this.#localEncoder);
3799
3832
  this.#turns = new TurnCounter();
3800
3833
  this.conversation = createConversationNamespace(
3801
3834
  this.#transport,
@@ -4286,14 +4319,14 @@ var SynapClient = (_class4 = class _SynapClient {
4286
4319
  }))
4287
4320
  );
4288
4321
  const entry = this.#shortTerm.get(conversationId);
4289
- const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess', _72 => _72.serverMessageCount]), () => ( 0))) || 0);
4322
+ const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess', _74 => _74.serverMessageCount]), () => ( 0))) || 0);
4290
4323
  this.#maybeBackfillTurns(conversationId, total);
4291
4324
  if (!r["context_block"]) return response;
4292
4325
  const turns = store.turns(conversationId);
4293
4326
  let q = query;
4294
4327
  if (!q) {
4295
4328
  const latest = [...recent].reverse().find((m) => m["role"] === "user");
4296
- q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access', _73 => _73.reverse, 'call', _74 => _74(), 'access', _75 => _75.find, 'call', _76 => _76((t) => t.role === "user"), 'optionalAccess', _77 => _77.content]), () => ( ""));
4329
+ q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access', _75 => _75.reverse, 'call', _76 => _76(), 'access', _77 => _77.find, 'call', _78 => _78((t) => t.role === "user"), 'optionalAccess', _79 => _79.content]), () => ( ""));
4297
4330
  }
4298
4331
  if (!q) return response;
4299
4332
  const exclude = /* @__PURE__ */ new Set();
@@ -4437,7 +4470,7 @@ function pick3(o2, snake, camel) {
4437
4470
  function resolveBaseUrl(options) {
4438
4471
  const explicit = _nullishCoalesce(options.baseUrl, () => ( options.api_base_url));
4439
4472
  if (explicit !== void 0) return explicit;
4440
- const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()]);
4473
+ const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]);
4441
4474
  return fromEnv !== void 0 && fromEnv !== "" ? fromEnv : void 0;
4442
4475
  }
4443
4476
  function resolveCredentials(options) {