@maximem/synap-js-sdk 0.4.2 → 0.4.4

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
@@ -22,7 +22,7 @@
22
22
 
23
23
 
24
24
 
25
- var _chunkHR5Y3KXScjs = require('./chunk-HR5Y3KXS.cjs');
25
+ var _chunk2TVL5IPQcjs = require('./chunk-2TVL5IPQ.cjs');
26
26
 
27
27
 
28
28
 
@@ -113,7 +113,7 @@ function shouldRetry(input) {
113
113
  if (attempt >= policy.maxAttempts) {
114
114
  return { retry: false, delaySeconds: 0, reason: "max_attempts_exhausted" };
115
115
  }
116
- if (!_chunkHR5Y3KXScjs.isSynapError.call(void 0, error) || !error.transient) {
116
+ if (!_chunk2TVL5IPQcjs.isSynapError.call(void 0, error) || !error.transient) {
117
117
  return { retry: false, delaySeconds: 0, reason: "not_transient" };
118
118
  }
119
119
  const idempotent = _nullishCoalesce(input.idempotent, () => ( IDEMPOTENT_METHODS.has(method.toUpperCase())));
@@ -131,7 +131,7 @@ function shouldRetry(input) {
131
131
  };
132
132
  }
133
133
  function backoffDelay(error, attempt, policy) {
134
- if (error instanceof _chunkHR5Y3KXScjs.RateLimitError && error.retryAfterSeconds != null) {
134
+ if (error instanceof _chunk2TVL5IPQcjs.RateLimitError && error.retryAfterSeconds != null) {
135
135
  return Math.min(error.retryAfterSeconds, policy.backoffMax);
136
136
  }
137
137
  const exponential = policy.backoffBase * 2 ** (attempt - 1);
@@ -200,6 +200,16 @@ var Heartbeat = (_class = class {
200
200
  }
201
201
  }, _class);
202
202
 
203
+ // src/scoping.ts
204
+ var B2C_ISOLATION = "equals_customer";
205
+ function checkCustomerId(isolation, customerId, where, instanceId) {
206
+ if (customerId === void 0 || customerId === null || customerId === "") return;
207
+ if (isolation !== B2C_ISOLATION) return;
208
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
209
+ `${where}: customer_id is not accepted on this instance${instanceId ? ` (${instanceId})` : ""}, which is B2C (user_context_isolation='${B2C_ISOLATION}'). Send user_id only; it is the whole identity, and the server files and reads your data under it. Received customer_id=${JSON.stringify(customerId)}.`
210
+ );
211
+ }
212
+
203
213
  // src/transport/http.ts
204
214
  var DEFAULT_BASE_URL = "https://synap-cloud-prod.maximem.ai";
205
215
  var DEFAULT_TIMEOUTS = { connect: 5, read: 30, write: 10 };
@@ -215,11 +225,11 @@ var HttpTransport = (_class2 = class {
215
225
 
216
226
 
217
227
  __init2() {this.closed = false}
218
- constructor(options) {;_class2.prototype.__init2.call(this);
228
+ constructor(options) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);
219
229
  this.#credentials = options.credentials;
220
230
  this.baseUrl = (_nullishCoalesce(options.baseUrl, () => ( DEFAULT_BASE_URL))).replace(/\/+$/, "");
221
231
  this.timeouts = { ...DEFAULT_TIMEOUTS, ...options.timeouts };
222
- this.retryPolicy = { ...DEFAULT_RETRY_POLICY, ...options.retryPolicy };
232
+ this.retryPolicy = options.retryPolicy === null ? { ...DEFAULT_RETRY_POLICY, maxAttempts: 1 } : { ...DEFAULT_RETRY_POLICY, ...options.retryPolicy };
223
233
  this.userAgent = _nullishCoalesce(options.userAgent, () => ( "@maximem/synap-js-sdk"));
224
234
  this.fetchImpl = _nullishCoalesce(options.fetchImpl, () => ( globalThis.fetch.bind(globalThis)));
225
235
  this.keepAliveOptions = _nullishCoalesce(options.keepAlive, () => ( {}));
@@ -253,12 +263,38 @@ var HttpTransport = (_class2 = class {
253
263
  updateCredentials(patch) {
254
264
  this.#credentials = { ...this.#credentials, ...patch };
255
265
  }
266
+ /**
267
+ * The instance's scoping mode, from whoami. Lives here rather than on the
268
+ * client because every interface factory already receives the transport,
269
+ * and it is per-client, so a module-level global would be wrong the moment a
270
+ * process holds two clients.
271
+ *
272
+ * undefined means the server did not report it, which is true of any
273
+ * deployment older than the field, and must mean "enforce nothing".
274
+ */
275
+ __init3() {this.userContextIsolation = void 0}
276
+ /** Refuse a customer_id on a B2C instance, at the call site. */
277
+ checkCustomerId(customerId, where) {
278
+ checkCustomerId(
279
+ this.userContextIsolation,
280
+ customerId,
281
+ where,
282
+ this.#credentials.instanceId
283
+ );
284
+ }
256
285
  setTimeouts(timeouts) {
257
286
  this.timeouts = { ...this.timeouts, ...timeouts };
258
287
  }
259
- /** `null` restores the default policy, matching Python's `retry_policy=None`. */
288
+ /**
289
+ * `null` DISABLES retries, matching Python.
290
+ *
291
+ * Python's `SDKConfig(retry_policy=None)` leaves `self.retry_policy` unset and
292
+ * `max_attempts` falls to 1 (http_client.py:180). We restored the default
293
+ * policy instead, so a caller following the "Disabling Retries" documentation
294
+ * got three attempts and no way to turn them off.
295
+ */
260
296
  setRetryPolicy(policy) {
261
- this.retryPolicy = policy === null ? { ...DEFAULT_RETRY_POLICY } : { ...this.retryPolicy, ...policy };
297
+ this.retryPolicy = policy === null ? { ...DEFAULT_RETRY_POLICY, maxAttempts: 1 } : { ...this.retryPolicy, ...policy };
262
298
  }
263
299
  close() {
264
300
  this.closed = true;
@@ -288,7 +324,7 @@ var HttpTransport = (_class2 = class {
288
324
  await sleep(decision.delaySeconds * 1e3, options.signal);
289
325
  }
290
326
  }
291
- throw _nullishCoalesce(_optionalChain([last, 'optionalAccess', _10 => _10.error]), () => ( new (0, _chunkHR5Y3KXScjs.SynapError)("Request failed with no recorded error")));
327
+ throw _nullishCoalesce(_optionalChain([last, 'optionalAccess', _10 => _10.error]), () => ( new (0, _chunk2TVL5IPQcjs.SynapError)("Request failed with no recorded error")));
292
328
  }
293
329
  async attempt(name, options, correlationId) {
294
330
  const spec = ENDPOINTS[name];
@@ -321,7 +357,7 @@ var HttpTransport = (_class2 = class {
321
357
  try {
322
358
  return JSON.parse(text);
323
359
  } catch (e3) {
324
- throw new (0, _chunkHR5Y3KXScjs.SynapError)(`Malformed JSON in response from ${url}`, { correlationId });
360
+ throw new (0, _chunk2TVL5IPQcjs.SynapError)(`Malformed JSON in response from ${url}`, { correlationId });
325
361
  }
326
362
  }
327
363
  buildUrl(path, query) {
@@ -355,14 +391,14 @@ var HttpTransport = (_class2 = class {
355
391
  }
356
392
  }, _class2);
357
393
  function isOutcomeUnknown(error) {
358
- if (error instanceof _chunkHR5Y3KXScjs.RateLimitError) return false;
359
- if (error instanceof _chunkHR5Y3KXScjs.ServiceUnavailableError) return false;
360
- if (error instanceof _chunkHR5Y3KXScjs.AuthenticationError) return false;
361
- if (error instanceof _chunkHR5Y3KXScjs.InvalidInputError) return false;
362
- if (error instanceof _chunkHR5Y3KXScjs.ConflictError) return false;
363
- if (error instanceof _chunkHR5Y3KXScjs.InsufficientCreditsError) return false;
364
- if (error instanceof _chunkHR5Y3KXScjs.ContextNotFoundError) return false;
365
- if (error instanceof _chunkHR5Y3KXScjs.NetworkTimeoutError) return true;
394
+ if (error instanceof _chunk2TVL5IPQcjs.RateLimitError) return false;
395
+ if (error instanceof _chunk2TVL5IPQcjs.ServiceUnavailableError) return false;
396
+ if (error instanceof _chunk2TVL5IPQcjs.AuthenticationError) return false;
397
+ if (error instanceof _chunk2TVL5IPQcjs.InvalidInputError) return false;
398
+ if (error instanceof _chunk2TVL5IPQcjs.ConflictError) return false;
399
+ if (error instanceof _chunk2TVL5IPQcjs.InsufficientCreditsError) return false;
400
+ if (error instanceof _chunk2TVL5IPQcjs.ContextNotFoundError) return false;
401
+ if (error instanceof _chunk2TVL5IPQcjs.NetworkTimeoutError) return true;
366
402
  if (isConnectionRefusal(error)) return false;
367
403
  return true;
368
404
  }
@@ -371,12 +407,12 @@ function isConnectionRefusal(error) {
371
407
  return code === "ECONNREFUSED" || code === "ENOTFOUND" || code === "EAI_AGAIN" || code === "ECONNRESET" || code === "EHOSTUNREACH";
372
408
  }
373
409
  function toTransportError(error, correlationId) {
374
- if (error instanceof _chunkHR5Y3KXScjs.SynapError) return error;
410
+ if (error instanceof _chunk2TVL5IPQcjs.SynapError) return error;
375
411
  const name = _optionalChain([error, 'optionalAccess', _14 => _14.name]);
376
412
  if (name === "AbortError" || name === "TimeoutError") {
377
- return new (0, _chunkHR5Y3KXScjs.NetworkTimeoutError)("Request timed out", { correlationId, cause: error });
413
+ return new (0, _chunk2TVL5IPQcjs.NetworkTimeoutError)("Request timed out", { correlationId, cause: error });
378
414
  }
379
- return new (0, _chunkHR5Y3KXScjs.ServiceUnavailableError)(
415
+ return new (0, _chunk2TVL5IPQcjs.ServiceUnavailableError)(
380
416
  `Network request failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _15 => _15.message]), () => ( String(error)))}`,
381
417
  { correlationId, cause: error }
382
418
  );
@@ -396,48 +432,53 @@ async function toHttpError(response, correlationId) {
396
432
  switch (response.status) {
397
433
  case 400:
398
434
  case 422:
399
- return new (0, _chunkHR5Y3KXScjs.InvalidInputError)(message, opts);
435
+ return new (0, _chunk2TVL5IPQcjs.InvalidInputError)(message, opts);
400
436
  case 401:
401
437
  case 403:
402
- return new (0, _chunkHR5Y3KXScjs.AuthenticationError)(message, opts);
438
+ return new (0, _chunk2TVL5IPQcjs.AuthenticationError)(message, opts);
403
439
  case 404:
404
- return new (0, _chunkHR5Y3KXScjs.ContextNotFoundError)(message, opts);
440
+ return new (0, _chunk2TVL5IPQcjs.ContextNotFoundError)(message, opts);
405
441
  case 402:
406
- return new (0, _chunkHR5Y3KXScjs.InsufficientCreditsError)(message, {
442
+ return new (0, _chunk2TVL5IPQcjs.InsufficientCreditsError)(message, {
407
443
  ...opts,
408
444
  balanceCredits: numberOrNull(parsed["balance_credits"]),
409
- requiredCredits: numberOrNull(parsed["required_credits"])
445
+ requiredCredits: _nullishCoalesce(numberOrNull(parsed["minimum_required_credits"]), () => ( numberOrNull(parsed["required_credits"]))),
446
+ recoveryUrl: stringOrNull(parsed["recovery_url"]),
447
+ redeemUrl: stringOrNull(parsed["redeem_url"])
410
448
  });
411
449
  case 409:
412
450
  if (detailObject !== null && detailObject["code"] === "transcript_conflict") {
413
- return new (0, _chunkHR5Y3KXScjs.TranscriptConflictError)(message, opts);
451
+ return new (0, _chunk2TVL5IPQcjs.TranscriptConflictError)(message, opts);
414
452
  }
415
- return new (0, _chunkHR5Y3KXScjs.ConflictError)(message, opts);
453
+ return new (0, _chunk2TVL5IPQcjs.ConflictError)(message, opts);
416
454
  case 429: {
417
455
  const header = response.headers.get("retry-after");
418
456
  const retryAfter = header !== null && header.trim() !== "" ? Number(header) : null;
419
- return new (0, _chunkHR5Y3KXScjs.RateLimitError)(message, {
457
+ return new (0, _chunk2TVL5IPQcjs.RateLimitError)(message, {
420
458
  ...opts,
421
459
  retryAfterSeconds: retryAfter !== null && Number.isFinite(retryAfter) ? retryAfter : null
422
460
  });
423
461
  }
424
462
  case 503:
425
- return new (0, _chunkHR5Y3KXScjs.ServiceUnavailableError)(message, opts);
463
+ return new (0, _chunk2TVL5IPQcjs.ServiceUnavailableError)(message, opts);
426
464
  case 504:
427
- return new (0, _chunkHR5Y3KXScjs.AgentUnavailableError)(message, opts);
465
+ return new (0, _chunk2TVL5IPQcjs.AgentUnavailableError)(message, opts);
428
466
  default:
429
- if (response.status >= 500) return new (0, _chunkHR5Y3KXScjs.ServiceUnavailableError)(message, opts);
430
- return new (0, _chunkHR5Y3KXScjs.SynapError)(message, opts);
467
+ if (response.status >= 500) return new (0, _chunk2TVL5IPQcjs.ServiceUnavailableError)(message, opts);
468
+ return new (0, _chunk2TVL5IPQcjs.SynapError)(message, opts);
431
469
  }
432
470
  }
433
471
  function numberOrNull(v) {
434
472
  return typeof v === "number" && Number.isFinite(v) ? v : null;
435
473
  }
474
+ function stringOrNull(v) {
475
+ return typeof v === "string" && v !== "" ? v : null;
476
+ }
436
477
  function withTimeout(ms, external) {
437
478
  const controller = new AbortController();
438
479
  const onExternalAbort = () => controller.abort(_optionalChain([external, 'optionalAccess', _16 => _16.reason]));
439
480
  const timer = setTimeout(() => {
440
- controller.abort(new (0, _chunkHR5Y3KXScjs.NetworkTimeoutError)(`Timed out after ${ms}ms`));
481
+ controller.abort(new (0, _chunk2TVL5IPQcjs.NetworkTimeoutError)(`Timed out after ${ms}ms`));
441
482
  }, ms);
442
483
  _optionalChain([timer, 'access', _17 => _17.unref, 'optionalCall', _18 => _18()]);
443
484
  if (external) {
@@ -489,10 +530,10 @@ function buildFetchRequest(scope, options) {
489
530
  const precisionLevel = _nullishCoalesce(opt(options, "precision_level", "precisionLevel"), () => ( "high"));
490
531
  const mode = _nullishCoalesce(options.mode, () => ( "fast"));
491
532
  if (searchQuery !== void 0 && !Array.isArray(searchQuery)) {
492
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("search_query must be an array when provided");
533
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("search_query must be an array when provided");
493
534
  }
494
535
  if (options.types !== void 0 && !Array.isArray(options.types)) {
495
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("types must be an array when provided");
536
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("types must be an array when provided");
496
537
  }
497
538
  const body = {
498
539
  conversation_id: _nullishCoalesce(conversationId, () => ( null)),
@@ -507,16 +548,39 @@ function buildFetchRequest(scope, options) {
507
548
  }
508
549
  switch (scope) {
509
550
  case "user":
510
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
511
- body["user_id"] = userId;
512
- if (customerId !== void 0) body["customer_id"] = customerId;
551
+ {
552
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
553
+ body["user_id"] = userId;
554
+ const scopePath = opt(options, "scope_path", "scopePath");
555
+ if (scopePath !== void 0) body["scope"] = scopePath;
556
+ const contextMode = _nullishCoalesce(opt(options, "context_mode", "contextMode"), () => ( "in-conversation"));
557
+ if (!VALID_CONTEXT_MODES.includes(contextMode)) {
558
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
559
+ `Invalid context_mode '${contextMode}'. Must be one of: ${VALID_CONTEXT_MODES.join(", ")}`
560
+ );
561
+ }
562
+ const lastN = _nullishCoalesce(opt(options, "last_n_conversations", "lastNConversations"), () => ( 1));
563
+ if (!Number.isInteger(lastN)) {
564
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("last_n_conversations must be an integer");
565
+ }
566
+ if (lastN < 0 || lastN > 20) {
567
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("last_n_conversations must be between 0 and 20");
568
+ }
569
+ if (contextMode === "conversation-summary") {
570
+ body["context_mode"] = contextMode;
571
+ body["include_profile"] = _nullishCoalesce(opt(options, "include_profile", "includeProfile"), () => ( true));
572
+ body["last_n_conversations"] = lastN;
573
+ }
574
+ if (customerId !== void 0) body["customer_id"] = customerId;
575
+ break;
576
+ }
513
577
  break;
514
578
  case "customer":
515
- if (!customerId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("customer_id is required");
579
+ if (!customerId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("customer_id is required");
516
580
  body["customer_id"] = customerId;
517
581
  break;
518
582
  case "conversation":
519
- if (!conversationId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("conversation_id is required");
583
+ if (!conversationId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("conversation_id is required");
520
584
  if (userId !== void 0) body["user_id"] = userId;
521
585
  if (customerId !== void 0) body["customer_id"] = customerId;
522
586
  break;
@@ -525,8 +589,13 @@ function buildFetchRequest(scope, options) {
525
589
  }
526
590
  return { endpoint: ENDPOINT_BY_SCOPE[scope], body };
527
591
  }
592
+ var VALID_CONTEXT_MODES = ["in-conversation", "conversation-summary"];
528
593
  async function fetchContext(transport, scope, options = {}, hooks = {}) {
529
594
  const startedAt = Date.now();
595
+ transport.checkCustomerId(
596
+ opt(options, "customer_id", "customerId"),
597
+ `${scope}.context.fetch`
598
+ );
530
599
  const anticipated = _nullishCoalesce(_optionalChain([hooks, 'access', _26 => _26.beforeFetch, 'optionalCall', _27 => _27(scope, options)]), () => ( null));
531
600
  if (anticipated !== null) {
532
601
  _optionalChain([hooks, 'access', _28 => _28.onServedFromCache, 'optionalCall', _29 => _29(scope, options, anticipated)]);
@@ -756,17 +825,17 @@ function isoOrNull(v) {
756
825
  return v instanceof Date ? v.toISOString() : v;
757
826
  }
758
827
  function buildCreateBody(options) {
759
- if (!options.document) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("document is required");
828
+ if (!options.document) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("document is required");
760
829
  const o2 = options;
761
830
  const documentType = _nullishCoalesce(either(o2, "document_type", "documentType"), () => ( DEFAULT_DOCUMENT_TYPE));
762
831
  const mode = _nullishCoalesce(options.mode, () => ( DEFAULT_INGEST_MODE));
763
832
  if (!DOCUMENT_TYPES.includes(documentType)) {
764
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)(
833
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
765
834
  `Invalid document_type '${documentType}'. Expected one of: ${DOCUMENT_TYPES.join(", ")}`
766
835
  );
767
836
  }
768
837
  if (!INGEST_MODES.includes(mode)) {
769
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)(
838
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
770
839
  `Invalid mode '${mode}'. Expected one of: ${INGEST_MODES.join(", ")}`
771
840
  );
772
841
  }
@@ -787,12 +856,14 @@ var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "error",
787
856
  function createMemoriesInterface(transport) {
788
857
  return {
789
858
  async create(options) {
859
+ const o2 = options;
860
+ transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.create");
790
861
  return transport.request("memories_create", { body: buildCreateBody(options) });
791
862
  },
792
863
  async batch_create(options) {
793
864
  const docs = options.documents;
794
865
  if (!Array.isArray(docs) || docs.length === 0) {
795
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("documents must be a non-empty array");
866
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("documents must be a non-empty array");
796
867
  }
797
868
  const failFast = _nullishCoalesce(_nullishCoalesce(options.fail_fast, () => ( options.failFast)), () => ( false));
798
869
  return transport.request("memories_batch", {
@@ -802,15 +873,15 @@ function createMemoriesInterface(transport) {
802
873
  async create_from_file(options) {
803
874
  const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
804
875
  const customerId = _nullishCoalesce(options.customer_id, () => ( options.customerId));
805
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
806
- if (!customerId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("customer_id is required");
876
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
877
+ transport.checkCustomerId(customerId, "memories.create_from_file");
807
878
  const filePath = _nullishCoalesce(options.file_path, () => ( options.filePath));
808
879
  const sources = [filePath, options.file, options.text].filter((v) => v !== void 0);
809
880
  if (sources.length === 0) {
810
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("One of file_path, file, or text must be provided.");
881
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("One of file_path, file, or text must be provided.");
811
882
  }
812
883
  if (sources.length > 1) {
813
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)(
884
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
814
885
  "Provide exactly one of file_path, file, or text, not several."
815
886
  );
816
887
  }
@@ -841,13 +912,13 @@ function createMemoriesInterface(transport) {
841
912
  });
842
913
  },
843
914
  async get(memoryId) {
844
- if (!memoryId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("memory_id is required");
915
+ if (!memoryId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("memory_id is required");
845
916
  return transport.request("memories_get", { pathParams: { memory_id: memoryId } });
846
917
  },
847
918
  async update(options) {
848
919
  const memoryId = _nullishCoalesce(options.memory_id, () => ( options.memoryId));
849
- if (!memoryId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("memory_id is required");
850
- if (!options.document) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("document is required");
920
+ if (!memoryId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("memory_id is required");
921
+ if (!options.document) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("document is required");
851
922
  const body = {
852
923
  document: options.document,
853
924
  merge_strategy: _nullishCoalesce(_nullishCoalesce(options.merge_strategy, () => ( options.mergeStrategy)), () => ( "smart-merge"))
@@ -862,20 +933,20 @@ function createMemoriesInterface(transport) {
862
933
  },
863
934
  async delete(memoryId) {
864
935
  if (!memoryId) {
865
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)(
936
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
866
937
  "memory_id is required. Deleting by user is no longer supported: the previous implementation tracked ids in process memory, so it silently deleted nothing in any serverless or multi-process deployment while reporting success."
867
938
  );
868
939
  }
869
940
  return transport.request("memories_delete", { pathParams: { memory_id: memoryId } });
870
941
  },
871
942
  async status(ingestionId) {
872
- if (!ingestionId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("ingestion_id is required");
943
+ if (!ingestionId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("ingestion_id is required");
873
944
  return transport.request("memories_status", {
874
945
  pathParams: { ingestion_id: ingestionId }
875
946
  });
876
947
  },
877
948
  async wait_for_completion(ingestionId, options = {}) {
878
- if (!ingestionId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("ingestion_id is required");
949
+ if (!ingestionId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("ingestion_id is required");
879
950
  const timeoutMs = (_nullishCoalesce(_nullishCoalesce(options.timeout_seconds, () => ( options.timeoutSeconds)), () => ( 300))) * 1e3;
880
951
  const pollMs = (_nullishCoalesce(_nullishCoalesce(options.poll_interval_seconds, () => ( options.pollIntervalSeconds)), () => ( 2))) * 1e3;
881
952
  const deadline = Date.now() + timeoutMs;
@@ -913,17 +984,26 @@ var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9
913
984
  function validateConversationId(conversationId) {
914
985
  if (conversationId === void 0 || conversationId === null || conversationId === "") return;
915
986
  if (typeof conversationId !== "string" || !UUID_RE.test(conversationId)) {
916
- throw new (0, _chunkHR5Y3KXScjs.InvalidConversationIdError)(`Invalid conversation ID: ${String(conversationId)}`);
987
+ throw new (0, _chunk2TVL5IPQcjs.InvalidConversationIdError)(`Invalid conversation ID: ${String(conversationId)}`);
917
988
  }
918
989
  }
919
990
  function validateInstanceId(instanceId) {
920
991
  if (instanceId === void 0 || instanceId === null || instanceId === "") return;
921
992
  if (typeof instanceId !== "string" || !INSTANCE_ID_RE.test(instanceId)) {
922
- throw new (0, _chunkHR5Y3KXScjs.InvalidInstanceIdError)(`Invalid instance ID: ${String(instanceId)}`);
993
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInstanceIdError)(`Invalid instance ID: ${String(instanceId)}`);
923
994
  }
924
995
  }
925
996
 
926
997
  // src/conversation/interface.ts
998
+ var COMPACTION_LEVELS = [
999
+ "low",
1000
+ "medium",
1001
+ "high",
1002
+ "adaptive",
1003
+ "aggressive",
1004
+ "balanced",
1005
+ "conservative"
1006
+ ];
927
1007
  function either2(o2, snake, camel) {
928
1008
  const a = o2[snake];
929
1009
  if (a !== void 0) return a;
@@ -939,14 +1019,13 @@ function buildRecordMessageBody(options) {
939
1019
  const conversationId = either2(o2, "conversation_id", "conversationId");
940
1020
  const userId = either2(o2, "user_id", "userId");
941
1021
  const customerId = either2(o2, "customer_id", "customerId");
942
- if (!conversationId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("conversation_id is required");
1022
+ if (!conversationId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("conversation_id is required");
943
1023
  validateConversationId(conversationId);
944
- if (!options.role) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("role is required");
1024
+ if (!options.role) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("role is required");
945
1025
  if (options.content === void 0 || options.content === null) {
946
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("content is required");
1026
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("content is required");
947
1027
  }
948
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
949
- if (!customerId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("customer_id is required");
1028
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
950
1029
  const body = {
951
1030
  conversation_id: conversationId,
952
1031
  role: options.role,
@@ -964,10 +1043,10 @@ function buildIngestTranscriptBody(options) {
964
1043
  const o2 = options;
965
1044
  const conversationId = either2(o2, "conversation_id", "conversationId");
966
1045
  const userId = either2(o2, "user_id", "userId");
967
- if (!conversationId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("conversation_id is required");
968
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
1046
+ if (!conversationId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("conversation_id is required");
1047
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
969
1048
  if (options.transcript === void 0 || options.transcript === null) {
970
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("transcript is required");
1049
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("transcript is required");
971
1050
  }
972
1051
  const body = {
973
1052
  conversation_id: conversationId,
@@ -989,7 +1068,7 @@ function buildIngestTranscriptBody(options) {
989
1068
  function buildCompactBody(options) {
990
1069
  const o2 = options;
991
1070
  const conversationId = either2(o2, "conversation_id", "conversationId");
992
- if (!conversationId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("conversation_id is required");
1071
+ if (!conversationId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("conversation_id is required");
993
1072
  validateConversationId(conversationId);
994
1073
  const body = { conversation_id: conversationId, force: _nullishCoalesce(options.force, () => ( false)) };
995
1074
  const strategy = _nullishCoalesce(options.strategy, () => ( either2(o2, "compaction_level", "compactionLevel")));
@@ -1045,12 +1124,16 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
1045
1124
  }) {
1046
1125
  const convId = (v) => {
1047
1126
  const id = typeof v === "string" ? v : _nullishCoalesce(v.conversation_id, () => ( v.conversationId));
1048
- if (!id) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("conversation_id is required");
1127
+ if (!id) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("conversation_id is required");
1049
1128
  validateConversationId(id);
1050
1129
  return id;
1051
1130
  };
1052
1131
  return {
1053
1132
  async record_message(options) {
1133
+ transport.checkCustomerId(
1134
+ _nullishCoalesce(options["customer_id"], () => ( options["customerId"])),
1135
+ "conversation.record_message"
1136
+ );
1054
1137
  const body = buildRecordMessageBody(options);
1055
1138
  const result = await transport.request("conversations_messages", { body });
1056
1139
  onTurn({
@@ -1067,7 +1150,14 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
1067
1150
  },
1068
1151
  async record_messages_batch(messages) {
1069
1152
  if (!Array.isArray(messages) || messages.length === 0) {
1070
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("messages must be a non-empty array");
1153
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("messages must be a non-empty array");
1154
+ }
1155
+ for (const m of messages) {
1156
+ const mo = m;
1157
+ transport.checkCustomerId(
1158
+ _nullishCoalesce(mo["customer_id"], () => ( mo["customerId"])),
1159
+ "conversation.record_messages_batch"
1160
+ );
1071
1161
  }
1072
1162
  const bodies = messages.map(buildRecordMessageBody);
1073
1163
  const result = await transport.request("conversations_messages_batch", {
@@ -1151,8 +1241,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
1151
1241
  * Returns an idempotent unsubscribe thunk, matching Python.
1152
1242
  */
1153
1243
  subscribe_to_compaction_updates(conversationId, callback) {
1154
- if (!conversationId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("conversation_id is required");
1155
- if (typeof callback !== "function") throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("callback is required");
1244
+ if (!conversationId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("conversation_id is required");
1245
+ if (typeof callback !== "function") throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("callback is required");
1156
1246
  return subscribers.add(conversationId, callback);
1157
1247
  },
1158
1248
  /** Remove subscribers for one conversation, or all of them. Returns the count removed. */
@@ -1168,7 +1258,7 @@ function createUserNamespace(transport, hooks = {}) {
1168
1258
  return {
1169
1259
  async get_profile(options) {
1170
1260
  const userId = typeof options === "string" ? options : _nullishCoalesce(options.user_id, () => ( options.userId));
1171
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
1261
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
1172
1262
  const customerId = typeof options === "string" ? void 0 : _nullishCoalesce(options.customer_id, () => ( options.customerId));
1173
1263
  return transport.request("user_profile", {
1174
1264
  pathParams: { user_id: userId },
@@ -1184,15 +1274,26 @@ function createUserNamespace(transport, hooks = {}) {
1184
1274
  }
1185
1275
 
1186
1276
  // src/credits/interface.ts
1277
+ function iso2(v) {
1278
+ return v instanceof Date ? v.toISOString() : v;
1279
+ }
1187
1280
  function createCreditsNamespace(transport) {
1188
1281
  return {
1189
1282
  async get_balance() {
1190
1283
  return transport.request("credits_balance");
1191
1284
  },
1192
1285
  async get_ledger(options = {}) {
1193
- return transport.request("credits_ledger", {
1194
- query: { limit: _nullishCoalesce(options.limit, () => ( 50)), offset: _nullishCoalesce(options.offset, () => ( 0)) }
1195
- });
1286
+ const query = {
1287
+ limit: _nullishCoalesce(options.limit, () => ( 100)),
1288
+ offset: _nullishCoalesce(options.offset, () => ( 0))
1289
+ };
1290
+ const entryType = _nullishCoalesce(options.entry_type, () => ( options.entryType));
1291
+ if (entryType !== void 0) query["entry_type"] = entryType;
1292
+ const from = _nullishCoalesce(options.from_time, () => ( options.fromTime));
1293
+ if (from !== void 0) query["from"] = iso2(from);
1294
+ const to = _nullishCoalesce(options.to_time, () => ( options.toTime));
1295
+ if (to !== void 0) query["to"] = iso2(to);
1296
+ return transport.request("credits_ledger", { query });
1196
1297
  },
1197
1298
  async estimate(options) {
1198
1299
  return transport.request("credits_estimate", {
@@ -1206,7 +1307,7 @@ function createCreditsNamespace(transport) {
1206
1307
  });
1207
1308
  },
1208
1309
  async redeem(code) {
1209
- if (!code) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("code is required");
1310
+ if (!code) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("code is required");
1210
1311
  return transport.request("credits_redeem", { body: { code } });
1211
1312
  }
1212
1313
  };
@@ -1217,11 +1318,11 @@ function createCacheNamespace(cache) {
1217
1318
  return {
1218
1319
  clear: () => cache.clear(),
1219
1320
  clear_user: (userId) => {
1220
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
1321
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
1221
1322
  cache.dropEntity(userId);
1222
1323
  },
1223
1324
  clear_customer: (customerId) => {
1224
- if (!customerId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("customer_id is required");
1325
+ if (!customerId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("customer_id is required");
1225
1326
  cache.dropEntity(customerId);
1226
1327
  },
1227
1328
  stats: () => ({ bundles: cache.size, items: cache.itemCount })
@@ -1270,9 +1371,9 @@ function createInstanceNamespace(credentials, cache, onTurn) {
1270
1371
  const namespace = {
1271
1372
  async listen(options = {}) {
1272
1373
  if (client !== null) {
1273
- throw new (0, _chunkHR5Y3KXScjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
1374
+ throw new (0, _chunk2TVL5IPQcjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
1274
1375
  }
1275
- const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-ZN6ADZBR.cjs")));
1376
+ const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-PRTOH62B.cjs")));
1276
1377
  const onContext = _nullishCoalesce(options.on_context, () => ( options.onContext));
1277
1378
  const onDisconnect = _nullishCoalesce(options.on_disconnect, () => ( options.onDisconnect));
1278
1379
  const onReconnect = _nullishCoalesce(options.on_reconnect, () => ( options.onReconnect));
@@ -1297,8 +1398,8 @@ function createInstanceNamespace(credentials, cache, onTurn) {
1297
1398
  try {
1298
1399
  await created.connect();
1299
1400
  } catch (error) {
1300
- if (error instanceof _chunkHR5Y3KXScjs.SynapError) throw error;
1301
- throw new (0, _chunkHR5Y3KXScjs.SynapError)(
1401
+ if (error instanceof _chunk2TVL5IPQcjs.SynapError) throw error;
1402
+ throw new (0, _chunk2TVL5IPQcjs.SynapError)(
1302
1403
  `Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _49 => _49.message]), () => ( String(error)))}`,
1303
1404
  { cause: error }
1304
1405
  );
@@ -1312,9 +1413,9 @@ function createInstanceNamespace(credentials, cache, onTurn) {
1312
1413
  await active.disconnect();
1313
1414
  },
1314
1415
  async send_message(options) {
1315
- if (client === null) throw new (0, _chunkHR5Y3KXScjs.ListeningNotActiveError)("Listening is not active");
1416
+ if (client === null) throw new (0, _chunk2TVL5IPQcjs.ListeningNotActiveError)("Listening is not active");
1316
1417
  if (options.content === void 0) {
1317
- throw new (0, _chunkHR5Y3KXScjs.ListeningNotActiveError)("content is required");
1418
+ throw new (0, _chunk2TVL5IPQcjs.ListeningNotActiveError)("content is required");
1318
1419
  }
1319
1420
  const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
1320
1421
  _optionalChain([onTurn, 'optionalCall', _50 => _50({
@@ -1332,12 +1433,18 @@ function createInstanceNamespace(credentials, cache, onTurn) {
1332
1433
  session_id: _nullishCoalesce(_nullishCoalesce(options.session_id, () => ( options.sessionId)), () => ( "")),
1333
1434
  metadata: _nullishCoalesce(options.metadata, () => ( {})),
1334
1435
  timestamp_ms: Date.now(),
1436
+ tool_name: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")),
1437
+ // Python serialises tool_args with json.dumps into tool_args_json.
1438
+ tool_args_json: (() => {
1439
+ const a = _nullishCoalesce(options.tool_args, () => ( options.toolArgs));
1440
+ return a === void 0 ? "" : JSON.stringify(a);
1441
+ })(),
1335
1442
  search_queries: _nullishCoalesce(_nullishCoalesce(options.search_queries, () => ( options.searchQueries)), () => ( [])),
1336
1443
  context_types: _nullishCoalesce(_nullishCoalesce(options.context_types, () => ( options.contextTypes)), () => ( []))
1337
1444
  });
1338
1445
  },
1339
1446
  async record_thinking(options) {
1340
- if (client === null) throw new (0, _chunkHR5Y3KXScjs.ListeningNotActiveError)("Listening is not active");
1447
+ if (client === null) throw new (0, _chunk2TVL5IPQcjs.ListeningNotActiveError)("Listening is not active");
1341
1448
  client.sendConversationEvent({
1342
1449
  // Python emits reasoning as an `agent_thinking` conversation event.
1343
1450
  event_type: "agent_thinking",
@@ -2101,7 +2208,7 @@ function buildTool(target, options = {}, onWarning = () => {
2101
2208
  const scope = String(_nullishCoalesce(options.scope, () => ( "user"))).toLowerCase();
2102
2209
  if (!VALID_SCOPES.includes(scope)) {
2103
2210
  const sorted = [...VALID_SCOPES].sort();
2104
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)(
2211
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
2105
2212
  `scope must be one of ['${sorted.join("', '")}'], got '${String(options.scope)}'`
2106
2213
  );
2107
2214
  }
@@ -2109,10 +2216,10 @@ function buildTool(target, options = {}, onWarning = () => {
2109
2216
  const customerId = _nullishCoalesce(options.customer_id, () => ( options.customerId));
2110
2217
  const conversationId = _nullishCoalesce(options.conversation_id, () => ( options.conversationId));
2111
2218
  if (scope === "user" && (userId === void 0 || userId === "")) {
2112
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("scope='user' requires user_id");
2219
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("scope='user' requires user_id");
2113
2220
  }
2114
2221
  if (scope === "customer" && (customerId === void 0 || customerId === "")) {
2115
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("scope='customer' requires customer_id");
2222
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("scope='customer' requires customer_id");
2116
2223
  }
2117
2224
  if (scope === "conversation" && (userId === void 0 || userId === "")) {
2118
2225
  onWarning(
@@ -2121,7 +2228,7 @@ function buildTool(target, options = {}, onWarning = () => {
2121
2228
  }
2122
2229
  const style = String(_nullishCoalesce(options.style, () => ( "openai")));
2123
2230
  if (style !== "openai" && style !== "anthropic") {
2124
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)(`style must be 'openai' or 'anthropic', got '${style}'`);
2231
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(`style must be 'openai' or 'anthropic', got '${style}'`);
2125
2232
  }
2126
2233
  const toolName = _nullishCoalesce(options.name, () => ( `synap_fetch_${scope}_context`));
2127
2234
  const toolDesc = _nullishCoalesce(options.description, () => ( defaultToolDescription(scope)));
@@ -2306,9 +2413,9 @@ var SynapClient = class {
2306
2413
  */
2307
2414
  async searchMemory(options) {
2308
2415
  const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
2309
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
2416
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
2310
2417
  if (options.query === void 0 || options.query === null) {
2311
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("query is required");
2418
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("query is required");
2312
2419
  }
2313
2420
  const context = await fetchContext(this.#transport, "user", {
2314
2421
  user_id: userId,
@@ -2329,7 +2436,7 @@ var SynapClient = class {
2329
2436
  */
2330
2437
  async getMemories(options) {
2331
2438
  const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
2332
- if (!userId) throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("user_id is required");
2439
+ if (!userId) throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("user_id is required");
2333
2440
  const context = await fetchContext(this.#transport, "user", {
2334
2441
  user_id: userId,
2335
2442
  ...pick3(options, "customer_id", "customerId") !== void 0 ? { customer_id: pick3(options, "customer_id", "customerId") } : {},
@@ -2377,6 +2484,8 @@ var SynapClient = class {
2377
2484
  const whoami = await this.#transport.request("whoami", {});
2378
2485
  const resolvedClientId = String(_nullishCoalesce(whoami["client_id"], () => ( "")));
2379
2486
  const resolvedInstanceId = String(_nullishCoalesce(whoami["instance_id"], () => ( "")));
2487
+ const iso3 = whoami["user_context_isolation"];
2488
+ this.#transport.userContextIsolation = typeof iso3 === "string" ? iso3 : void 0;
2380
2489
  this.#transport.updateCredentials({
2381
2490
  ...resolvedClientId !== "" && credentials.clientId === "" ? { clientId: resolvedClientId } : {},
2382
2491
  ...resolvedInstanceId !== "" && credentials.instanceId === "" ? { instanceId: resolvedInstanceId } : {}
@@ -2420,7 +2529,7 @@ var SynapClient = class {
2420
2529
  */
2421
2530
  configure(options = {}) {
2422
2531
  if (this.#initialized) {
2423
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)("Cannot reconfigure after initialization");
2532
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)("Cannot reconfigure after initialization");
2424
2533
  }
2425
2534
  if (options.timeouts !== void 0) this.#transport.setTimeouts(options.timeouts);
2426
2535
  if (options.retryPolicy !== void 0 || options.retry_policy !== void 0) {
@@ -2518,7 +2627,7 @@ var SynapClient = class {
2518
2627
  successful.push([label, result.value]);
2519
2628
  continue;
2520
2629
  }
2521
- if (result.reason instanceof _chunkHR5Y3KXScjs.InvalidInputError) throw result.reason;
2630
+ if (result.reason instanceof _chunk2TVL5IPQcjs.InvalidInputError) throw result.reason;
2522
2631
  this.#warn(`Scope '${label}' fetch failed in unified fetch (non-fatal): ${String(result.reason)}`);
2523
2632
  }
2524
2633
  const merged = mergeScopeResults(successful);
@@ -2649,7 +2758,7 @@ function resolveBaseUrl(options) {
2649
2758
  function resolveCredentials(options) {
2650
2759
  const apiKey = _nullishCoalesce(options.apiKey, () => ( _chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_API_KEY")));
2651
2760
  if (!apiKey) {
2652
- throw new (0, _chunkHR5Y3KXScjs.InvalidInputError)(
2761
+ throw new (0, _chunk2TVL5IPQcjs.InvalidInputError)(
2653
2762
  "No Synap API key found. Set SYNAP_API_KEY in your environment, or pass apiKey to the SynapClient constructor."
2654
2763
  );
2655
2764
  }
@@ -2709,5 +2818,6 @@ function resolveCredentials(options) {
2709
2818
 
2710
2819
 
2711
2820
 
2712
- exports.ANY_SCOPE = _chunkRB57I2IQcjs.ANY_SCOPE; exports.AgentUnavailableError = _chunkHR5Y3KXScjs.AgentUnavailableError; exports.AnticipationCache = _chunkRB57I2IQcjs.AnticipationCache; exports.AuthenticationError = _chunkHR5Y3KXScjs.AuthenticationError; exports.BM25 = _chunkRB57I2IQcjs.BM25; exports.CONTRACT = _chunkRB57I2IQcjs.CONTRACT; exports.ConflictError = _chunkHR5Y3KXScjs.ConflictError; exports.ConnectionError = _chunkHR5Y3KXScjs.ConnectionError; exports.ContextNotFoundError = _chunkHR5Y3KXScjs.ContextNotFoundError; exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; exports.DEFAULT_DOCUMENT_TYPE = DEFAULT_DOCUMENT_TYPE; exports.DEFAULT_INGEST_MODE = DEFAULT_INGEST_MODE; exports.DEFAULT_RETRY_POLICY = DEFAULT_RETRY_POLICY; exports.DEFAULT_TIMEOUTS = DEFAULT_TIMEOUTS; exports.DOCUMENT_TYPES = DOCUMENT_TYPES; exports.ENDPOINTS = ENDPOINTS; exports.HttpTransport = HttpTransport; exports.INGEST_MODES = INGEST_MODES; exports.ITEM_COLLECTIONS = ITEM_COLLECTIONS; exports.InsufficientCreditsError = _chunkHR5Y3KXScjs.InsufficientCreditsError; exports.InvalidConversationIdError = _chunkHR5Y3KXScjs.InvalidConversationIdError; exports.InvalidInputError = _chunkHR5Y3KXScjs.InvalidInputError; exports.InvalidInstanceIdError = _chunkHR5Y3KXScjs.InvalidInstanceIdError; exports.ListeningAlreadyActiveError = _chunkHR5Y3KXScjs.ListeningAlreadyActiveError; exports.ListeningNotActiveError = _chunkHR5Y3KXScjs.ListeningNotActiveError; exports.NetworkTimeoutError = _chunkHR5Y3KXScjs.NetworkTimeoutError; exports.PermanentError = _chunkHR5Y3KXScjs.PermanentError; exports.RateLimitError = _chunkHR5Y3KXScjs.RateLimitError; exports.SDKError = _chunkHR5Y3KXScjs.SDKError; exports.SDK_VERSION = SDK_VERSION; exports.ServiceUnavailableError = _chunkHR5Y3KXScjs.ServiceUnavailableError; exports.SessionExpiredError = _chunkHR5Y3KXScjs.SessionExpiredError; exports.SynapClient = SynapClient; exports.SynapError = _chunkHR5Y3KXScjs.SynapError; exports.SynapPermanentError = _chunkHR5Y3KXScjs.SynapPermanentError; exports.SynapTransientError = _chunkHR5Y3KXScjs.SynapTransientError; exports.THRESHOLDS = _chunkRB57I2IQcjs.THRESHOLDS; exports.TranscriptConflictError = _chunkHR5Y3KXScjs.TranscriptConflictError; exports.TransientError = _chunkHR5Y3KXScjs.TransientError; exports.flattenContextItems = flattenContextItems; exports.formatForPrompt = formatForPrompt; exports.isOutcomeUnknown = isOutcomeUnknown; exports.isRecallQuery = _chunkRB57I2IQcjs.isRecallQuery; exports.isSynapError = _chunkHR5Y3KXScjs.isSynapError; exports.mergeScopeResults = mergeScopeResults; exports.resolvePath = resolvePath; exports.shouldRetry = shouldRetry; exports.stem = _chunkRB57I2IQcjs.stem; exports.tokenize = _chunkRB57I2IQcjs.tokenize;
2821
+
2822
+ exports.ANY_SCOPE = _chunkRB57I2IQcjs.ANY_SCOPE; exports.AgentUnavailableError = _chunk2TVL5IPQcjs.AgentUnavailableError; exports.AnticipationCache = _chunkRB57I2IQcjs.AnticipationCache; exports.AuthenticationError = _chunk2TVL5IPQcjs.AuthenticationError; exports.BM25 = _chunkRB57I2IQcjs.BM25; exports.COMPACTION_LEVELS = COMPACTION_LEVELS; exports.CONTRACT = _chunkRB57I2IQcjs.CONTRACT; exports.ConflictError = _chunk2TVL5IPQcjs.ConflictError; exports.ConnectionError = _chunk2TVL5IPQcjs.ConnectionError; exports.ContextNotFoundError = _chunk2TVL5IPQcjs.ContextNotFoundError; exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; exports.DEFAULT_DOCUMENT_TYPE = DEFAULT_DOCUMENT_TYPE; exports.DEFAULT_INGEST_MODE = DEFAULT_INGEST_MODE; exports.DEFAULT_RETRY_POLICY = DEFAULT_RETRY_POLICY; exports.DEFAULT_TIMEOUTS = DEFAULT_TIMEOUTS; exports.DOCUMENT_TYPES = DOCUMENT_TYPES; exports.ENDPOINTS = ENDPOINTS; exports.HttpTransport = HttpTransport; exports.INGEST_MODES = INGEST_MODES; exports.ITEM_COLLECTIONS = ITEM_COLLECTIONS; exports.InsufficientCreditsError = _chunk2TVL5IPQcjs.InsufficientCreditsError; exports.InvalidConversationIdError = _chunk2TVL5IPQcjs.InvalidConversationIdError; exports.InvalidInputError = _chunk2TVL5IPQcjs.InvalidInputError; exports.InvalidInstanceIdError = _chunk2TVL5IPQcjs.InvalidInstanceIdError; exports.ListeningAlreadyActiveError = _chunk2TVL5IPQcjs.ListeningAlreadyActiveError; exports.ListeningNotActiveError = _chunk2TVL5IPQcjs.ListeningNotActiveError; exports.NetworkTimeoutError = _chunk2TVL5IPQcjs.NetworkTimeoutError; exports.PermanentError = _chunk2TVL5IPQcjs.PermanentError; exports.RateLimitError = _chunk2TVL5IPQcjs.RateLimitError; exports.SDKError = _chunk2TVL5IPQcjs.SDKError; exports.SDK_VERSION = SDK_VERSION; exports.ServiceUnavailableError = _chunk2TVL5IPQcjs.ServiceUnavailableError; exports.SessionExpiredError = _chunk2TVL5IPQcjs.SessionExpiredError; exports.SynapClient = SynapClient; exports.SynapError = _chunk2TVL5IPQcjs.SynapError; exports.SynapPermanentError = _chunk2TVL5IPQcjs.SynapPermanentError; exports.SynapTransientError = _chunk2TVL5IPQcjs.SynapTransientError; exports.THRESHOLDS = _chunkRB57I2IQcjs.THRESHOLDS; exports.TranscriptConflictError = _chunk2TVL5IPQcjs.TranscriptConflictError; exports.TransientError = _chunk2TVL5IPQcjs.TransientError; exports.flattenContextItems = flattenContextItems; exports.formatForPrompt = formatForPrompt; exports.isOutcomeUnknown = isOutcomeUnknown; exports.isRecallQuery = _chunkRB57I2IQcjs.isRecallQuery; exports.isSynapError = _chunk2TVL5IPQcjs.isSynapError; exports.mergeScopeResults = mergeScopeResults; exports.resolvePath = resolvePath; exports.shouldRetry = shouldRetry; exports.stem = _chunkRB57I2IQcjs.stem; exports.tokenize = _chunkRB57I2IQcjs.tokenize;
2713
2823
  //# sourceMappingURL=index.cjs.map