@maximem/synap-js-sdk 0.6.8 → 0.7.1

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 (36) hide show
  1. package/dist/anticipation-cache-Q7IYC3ID.cjs.map +1 -1
  2. package/dist/{chunk-DEFC7NHQ.js → chunk-BMA3HZEX.js} +6 -1
  3. package/dist/chunk-BMA3HZEX.js.map +1 -0
  4. package/dist/chunk-BYUGILQI.cjs.map +1 -1
  5. package/dist/{chunk-7IZHVYO2.cjs → chunk-JPDEKN5M.cjs} +28 -23
  6. package/dist/chunk-JPDEKN5M.cjs.map +1 -0
  7. package/dist/{chunk-YUCHB2YK.js → chunk-RKKTOLXP.js} +2 -2
  8. package/dist/{chunk-EI4AGILN.cjs → chunk-SAKMZI7G.cjs} +6 -6
  9. package/dist/chunk-SAKMZI7G.cjs.map +1 -0
  10. package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
  11. package/dist/env-55ULHNJZ.cjs.map +1 -1
  12. package/dist/{errors-x5bpgxmC.d.ts → errors-DEJFTN6v.d.cts} +9 -2
  13. package/dist/{errors-x5bpgxmC.d.cts → errors-DEJFTN6v.d.ts} +9 -2
  14. package/dist/grpc/index.cjs +7 -7
  15. package/dist/grpc/index.cjs.map +1 -1
  16. package/dist/grpc/index.d.cts +1 -1
  17. package/dist/grpc/index.d.ts +1 -1
  18. package/dist/grpc/index.js +3 -3
  19. package/dist/index.cjs +710 -235
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +200 -4
  22. package/dist/index.d.ts +200 -4
  23. package/dist/index.js +486 -11
  24. package/dist/index.js.map +1 -1
  25. package/dist/onnx-encoder-4RSL6ID4.cjs.map +1 -1
  26. package/dist/{stream-client-Q2RR5SCS.js → stream-client-7A2DQ3H3.js} +3 -3
  27. package/dist/stream-client-H2ES74FF.cjs +22 -0
  28. package/dist/stream-client-H2ES74FF.cjs.map +1 -0
  29. package/package.json +1 -1
  30. package/dist/chunk-7IZHVYO2.cjs.map +0 -1
  31. package/dist/chunk-DEFC7NHQ.js.map +0 -1
  32. package/dist/chunk-EI4AGILN.cjs.map +0 -1
  33. package/dist/stream-client-TDHTS7F4.cjs +0 -22
  34. package/dist/stream-client-TDHTS7F4.cjs.map +0 -1
  35. /package/dist/{chunk-YUCHB2YK.js.map → chunk-RKKTOLXP.js.map} +0 -0
  36. /package/dist/{stream-client-Q2RR5SCS.js.map → stream-client-7A2DQ3H3.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -41,7 +41,8 @@ var _chunkZKOJDUN4cjs = require('./chunk-ZKOJDUN4.cjs');
41
41
 
42
42
 
43
43
 
44
- var _chunk7IZHVYO2cjs = require('./chunk-7IZHVYO2.cjs');
44
+
45
+ var _chunkJPDEKN5Mcjs = require('./chunk-JPDEKN5M.cjs');
45
46
 
46
47
  // src/local-mode.ts
47
48
  function isLocalMode(apiKey, baseUrl) {
@@ -83,7 +84,9 @@ var ENDPOINTS = {
83
84
  credits_ledger: { method: "GET", path: "/v1/credits/ledger", idempotent: true },
84
85
  credits_estimate: { method: "POST", path: "/v1/credits/estimate", idempotent: true },
85
86
  credits_redeem: { method: "POST", path: "/v1/credits/redeem", idempotent: false },
86
- telemetry_batch: { method: "POST", path: "/v1/telemetry/batch", idempotent: false }
87
+ telemetry_batch: { method: "POST", path: "/v1/telemetry/batch", idempotent: false },
88
+ maca_generate: { method: "POST", path: "/v1/maca/generate", idempotent: false },
89
+ maca_job: { method: "GET", path: "/v1/maca/jobs/{job_id}", idempotent: true }
87
90
  };
88
91
  function resolvePath(name, params = {}) {
89
92
  return ENDPOINTS[name].path.replace(/\{(\w+)\}/g, (_m, key) => {
@@ -116,10 +119,10 @@ function shouldRetry(input) {
116
119
  if (attempt >= policy.maxAttempts) {
117
120
  return { retry: false, delaySeconds: 0, reason: "max_attempts_exhausted" };
118
121
  }
119
- if (!_chunk7IZHVYO2cjs.isSynapError.call(void 0, error) || !error.transient) {
122
+ if (!_chunkJPDEKN5Mcjs.isSynapError.call(void 0, error) || !error.transient) {
120
123
  return { retry: false, delaySeconds: 0, reason: "not_transient" };
121
124
  }
122
- if (error instanceof _chunk7IZHVYO2cjs.RateLimitError && error.reason) {
125
+ if (error instanceof _chunkJPDEKN5Mcjs.RateLimitError && error.reason) {
123
126
  return { retry: false, delaySeconds: 0, reason: "credit_stop" };
124
127
  }
125
128
  const idempotent = _nullishCoalesce(input.idempotent, () => ( IDEMPOTENT_METHODS.has(method.toUpperCase())));
@@ -137,7 +140,7 @@ function shouldRetry(input) {
137
140
  };
138
141
  }
139
142
  function backoffDelay(error, attempt, policy) {
140
- if (error instanceof _chunk7IZHVYO2cjs.RateLimitError && error.retryAfterSeconds != null) {
143
+ if (error instanceof _chunkJPDEKN5Mcjs.RateLimitError && error.retryAfterSeconds != null) {
141
144
  return Math.min(error.retryAfterSeconds, policy.backoffMax);
142
145
  }
143
146
  const exponential = policy.backoffBase * 2 ** (attempt - 1);
@@ -211,7 +214,222 @@ var B2C_ISOLATION = "equals_customer";
211
214
  function checkCustomerId(isolation, customerId, where, instanceId) {
212
215
  if (customerId === void 0 || customerId === null || customerId === "") return;
213
216
  if (isolation !== B2C_ISOLATION) return;
214
- throw new (0, _chunk7IZHVYO2cjs.CustomerIdNotAcceptedError)(where, String(customerId), instanceId);
217
+ throw new (0, _chunkJPDEKN5Mcjs.CustomerIdNotAcceptedError)(where, String(customerId), instanceId);
218
+ }
219
+
220
+ // src/scope-ladder.ts
221
+ var ROLE_TENANT = "tenant_of_record";
222
+ var ROLE_IDENTITY = "identity";
223
+ var LADDER_TTL_MS = 3e5;
224
+ var LADDER_RETRY_BACKOFF_MS = 6e4;
225
+ var LADDER_INVALIDATION_MIN_INTERVAL_MS = 5e3;
226
+ var ScopeAddress = class {
227
+
228
+
229
+
230
+ constructor(init = {}) {
231
+ this.user_id = _nullishCoalesce(init.user_id, () => ( null));
232
+ this.customer_id = _nullishCoalesce(init.customer_id, () => ( null));
233
+ this.scope_path = _nullishCoalesce(init.scope_path, () => ( null));
234
+ }
235
+ /**
236
+ * Options for reads: `fetch`, `send_message`, `record_message`,
237
+ * `user.context.fetch`, `conversation.context.fetch` and
238
+ * `client.context.fetch`. The path is `scope_path`.
239
+ *
240
+ * Not for `customer.context.fetch`: that route refuses a path that names the
241
+ * identity rung (HTTP 400, it reads shared material only) and takes no
242
+ * `user_id`. Call `client.fetch(addr.read_kwargs())`, which sends the
243
+ * customer route the path cut above the identity rung.
244
+ */
245
+ read_kwargs() {
246
+ const out = {};
247
+ if (this.user_id) out.user_id = this.user_id;
248
+ if (this.customer_id) out.customer_id = this.customer_id;
249
+ if (this.scope_path && Object.keys(this.scope_path).length > 0) {
250
+ out.scope_path = { ...this.scope_path };
251
+ }
252
+ return out;
253
+ }
254
+ /** Options for `memories.create` / `create_from_file` / `forget`: the path is `scope`. */
255
+ write_kwargs() {
256
+ const out = {};
257
+ if (this.user_id) out.user_id = this.user_id;
258
+ if (this.customer_id) out.customer_id = this.customer_id;
259
+ if (this.scope_path && Object.keys(this.scope_path).length > 0) {
260
+ out.scope = { ...this.scope_path };
261
+ }
262
+ return out;
263
+ }
264
+ };
265
+ var RESERVED_IDENTITY_KEY = "user";
266
+ function pathAboveIdentity(scopePath, ladder) {
267
+ if (!scopePath || Object.keys(scopePath).length === 0) return void 0;
268
+ const identity = _optionalChain([ladder, 'optionalAccess', _9 => _9.levels, 'access', _10 => _10.find, 'call', _11 => _11((lv) => lv.role === ROLE_IDENTITY)]);
269
+ const out = {};
270
+ if (!ladder || !identity) {
271
+ for (const [k, v] of Object.entries(scopePath)) if (k !== RESERVED_IDENTITY_KEY) out[k] = v;
272
+ } else {
273
+ const position = new Map(ladder.levels.map((lv) => [lv.key, lv.position]));
274
+ for (const [k, v] of Object.entries(scopePath)) {
275
+ if ((_nullishCoalesce(position.get(k), () => ( -1))) < identity.position) out[k] = v;
276
+ }
277
+ }
278
+ return Object.keys(out).length > 0 ? out : void 0;
279
+ }
280
+ var REFRESH_HINT = "The account's ladder may not be accepted yet, or nested scoping may be off for this instance. If that changed recently, `await sdk.get_scope_ladder({ refresh: true })` re-reads it.";
281
+ var ScopeLadder = class {
282
+
283
+
284
+
285
+
286
+ /** "server" | "inferred" */
287
+
288
+ /** True when the instance is B2C: the tenant and identity level are one node. */
289
+
290
+ constructor(init) {
291
+ this.levels = Object.freeze([...init.levels]);
292
+ this.is_default = init.is_default;
293
+ this.ladder_ratified = init.ladder_ratified;
294
+ this.nested_scoping_enabled = init.nested_scoping_enabled;
295
+ this.source = init.source;
296
+ this.b2c = _nullishCoalesce(init.b2c, () => ( false));
297
+ }
298
+ get keys() {
299
+ return this.levels.map((l) => l.key);
300
+ }
301
+ /**
302
+ * Map `values` (outermost level first) to ids and, on a deeper ladder, the
303
+ * full prefix path. A shorter list addresses a higher level. Throws
304
+ * `ScopeLadderError` before any call when the values cannot be addressed.
305
+ */
306
+ address(values) {
307
+ if (!Array.isArray(values)) {
308
+ throw new (0, _chunkJPDEKN5Mcjs.ScopeLadderError)(
309
+ `address() takes a list of values, outermost level first, got ${typeof values}.`
310
+ );
311
+ }
312
+ const vals = [...values];
313
+ if (vals.length === 0) {
314
+ throw new (0, _chunkJPDEKN5Mcjs.ScopeLadderError)(
315
+ `address() needs at least one value. The client level is addressed explicitly elsewhere (scope='client'), not through the ladder. Levels, outermost first: ${JSON.stringify(this.keys)}.`
316
+ );
317
+ }
318
+ for (const v of vals) {
319
+ if (typeof v !== "string" || v === "") {
320
+ throw new (0, _chunkJPDEKN5Mcjs.ScopeLadderError)(`address() values must be non-empty strings, got ${JSON.stringify(v)}.`);
321
+ }
322
+ }
323
+ const levels = this.levels;
324
+ const expected = this.b2c ? levels.filter((l) => l.role !== ROLE_TENANT) : levels;
325
+ if (vals.length > expected.length) {
326
+ throw new (0, _chunkJPDEKN5Mcjs.ScopeLadderError)(
327
+ `${vals.length} values for ${expected.length} levels (${JSON.stringify(expected.map((l) => l.key))}, outermost first).`
328
+ );
329
+ }
330
+ if (!this.is_default && (!this.nested_scoping_enabled || !this.ladder_ratified)) {
331
+ throw new (0, _chunkJPDEKN5Mcjs.ScopeLadderError)(
332
+ `This account has a deeper scope ladder (${JSON.stringify(this.keys)}), but the server would refuse a scope path (nested_scoping_enabled=${this.nested_scoping_enabled}, ladder_ratified=${this.ladder_ratified}). ` + REFRESH_HINT
333
+ );
334
+ }
335
+ let userId = null;
336
+ let customerId = null;
337
+ const path = {};
338
+ if (this.b2c) {
339
+ const identity = levels.find((l) => l.role === ROLE_IDENTITY);
340
+ if (identity === void 0) {
341
+ throw new (0, _chunkJPDEKN5Mcjs.ScopeLadderError)("This ladder has no identity level, so a B2C address cannot be built.");
342
+ }
343
+ if (vals.length < expected.length) {
344
+ throw new (0, _chunkJPDEKN5Mcjs.ScopeLadderError)(
345
+ `On a B2C instance the tenant level takes the identity's value, so give one value for every level after it (${JSON.stringify(expected.map((l) => l.key))}); got ${vals.length}.`
346
+ );
347
+ }
348
+ const byKey = /* @__PURE__ */ new Map();
349
+ expected.forEach((l, i) => byKey.set(l.key, vals[i]));
350
+ const identityValue = byKey.get(identity.key);
351
+ userId = identityValue;
352
+ if (!this.is_default) {
353
+ for (const l of levels) {
354
+ path[l.key] = l.role === ROLE_TENANT ? identityValue : byKey.get(l.key);
355
+ }
356
+ }
357
+ } else {
358
+ levels.slice(0, vals.length).forEach((l, i) => {
359
+ const v = vals[i];
360
+ if (l.role === ROLE_TENANT) customerId = v;
361
+ else if (l.role === ROLE_IDENTITY) userId = v;
362
+ if (!this.is_default) path[l.key] = v;
363
+ });
364
+ }
365
+ return new ScopeAddress({
366
+ user_id: userId,
367
+ customer_id: customerId,
368
+ scope_path: Object.keys(path).length > 0 ? path : null
369
+ });
370
+ }
371
+ };
372
+ var STRICT_LEVELS = [
373
+ { key: "customer", label: "Customer", position: 1, role: ROLE_TENANT, required: true },
374
+ { key: "user", label: "User", position: 2, role: ROLE_IDENTITY, required: true }
375
+ ];
376
+ var B2C_LEVELS = [
377
+ { key: "user", label: "User", position: 1, role: ROLE_IDENTITY, required: true }
378
+ ];
379
+ function parseLevels(raw) {
380
+ if (!Array.isArray(raw) || raw.length === 0) return null;
381
+ const out = [];
382
+ for (const item of raw) {
383
+ if (typeof item !== "object" || item === null || Array.isArray(item)) return null;
384
+ const o2 = item;
385
+ const key = o2["key"];
386
+ if (typeof key !== "string" || key === "") return null;
387
+ const position = Number(o2["position"]);
388
+ if (!Number.isFinite(position) || o2["position"] === null || o2["position"] === "") return null;
389
+ const label = o2["label"];
390
+ const role = o2["role"];
391
+ out.push({
392
+ key,
393
+ label: typeof label === "string" && label !== "" ? label : key,
394
+ position: Math.trunc(position),
395
+ role: typeof role === "string" && role !== "" ? role : null,
396
+ required: o2["required"] === void 0 ? true : Boolean(o2["required"])
397
+ });
398
+ }
399
+ out.sort((a, b) => a.position - b.position);
400
+ return out;
401
+ }
402
+ function ladderFromWhoami(whoami, fallbackIsolation, warn = () => {
403
+ }) {
404
+ const rawIso = whoami["user_context_isolation"];
405
+ const isolation = _nullishCoalesce((typeof rawIso === "string" && rawIso !== "" ? rawIso : void 0), () => ( fallbackIsolation));
406
+ const b2c = isolation === "equals_customer";
407
+ const block = whoami["scope_ladder"];
408
+ if (block !== void 0 && block !== null) {
409
+ const levels = typeof block === "object" && !Array.isArray(block) ? parseLevels(block["levels"]) : null;
410
+ if (levels === null) {
411
+ warn("whoami returned a malformed scope_ladder block; ignoring it and inferring the default ladder.");
412
+ } else {
413
+ const b = block;
414
+ return new ScopeLadder({
415
+ levels,
416
+ is_default: Boolean(b["is_default"]),
417
+ ladder_ratified: Boolean(b["ladder_ratified"]),
418
+ nested_scoping_enabled: Boolean(b["nested_scoping_enabled"]),
419
+ source: "server",
420
+ b2c
421
+ });
422
+ }
423
+ }
424
+ if (isolation === void 0) return null;
425
+ return new ScopeLadder({
426
+ levels: b2c ? B2C_LEVELS : STRICT_LEVELS,
427
+ is_default: true,
428
+ ladder_ratified: false,
429
+ nested_scoping_enabled: false,
430
+ source: "inferred",
431
+ b2c
432
+ });
215
433
  }
216
434
 
217
435
  // src/transport/http.ts
@@ -268,7 +486,7 @@ var HttpTransport = (_class2 = class {
268
486
  // instance id -> when the refusal's wait ends (monotonic ms), and what was said.
269
487
  // One JS thread runs every request, so a plain Map needs no lock.
270
488
  __init3() {this.notReadyCooldown = /* @__PURE__ */ new Map()}
271
- constructor(options) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
489
+ constructor(options) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);
272
490
  this.clock = _nullishCoalesce(options.clock, () => ( (() => performance.now())));
273
491
  this.#credentials = options.credentials;
274
492
  this.baseUrl = (_nullishCoalesce(options.baseUrl, () => ( DEFAULT_BASE_URL))).replace(/\/+$/, "");
@@ -279,7 +497,7 @@ var HttpTransport = (_class2 = class {
279
497
  this.keepAliveOptions = _nullishCoalesce(options.keepAlive, () => ( {}));
280
498
  this.heartbeat = new Heartbeat(
281
499
  () => this.pingHealth(),
282
- _nullishCoalesce(_optionalChain([options, 'access', _9 => _9.keepAlive, 'optionalAccess', _10 => _10.heartbeatIntervalMs]), () => ( HEARTBEAT_INTERVAL_MS))
500
+ _nullishCoalesce(_optionalChain([options, 'access', _12 => _12.keepAlive, 'optionalAccess', _13 => _13.heartbeatIntervalMs]), () => ( HEARTBEAT_INTERVAL_MS))
283
501
  );
284
502
  }
285
503
  /**
@@ -327,13 +545,115 @@ var HttpTransport = (_class2 = class {
327
545
  * deployment older than the field, and must mean "enforce nothing".
328
546
  */
329
547
  __init4() {this.userContextIsolation = void 0}
548
+ // ── Scope ladder (Python: MaximemSynapSDK.get_scope_ladder) ───────────────
549
+ // Held here, like `userContextIsolation`, so the interface factories that
550
+ // receive the transport can reach it and the client's public surface carries
551
+ // only the method Python has.
552
+ #ladder = null;
553
+ // Loaded is separate from the value: "the server does not say" (null) is an
554
+ // answer too, and is cached for the same 300 s.
555
+ #ladderLoaded = false;
556
+ #ladderExpiresAt = 0;
557
+ #ladderRetryAt = 0;
558
+ // Bumped by every invalidation. A read that started under an older number is
559
+ // not stored when it finishes.
560
+ #ladderGeneration = 0;
561
+ #ladderInvalidated = false;
562
+ #ladderInvalidationReadAt = Number.NEGATIVE_INFINITY;
563
+ // The read in flight, shared by concurrent callers.
564
+ #ladderInflight = void 0;
565
+ /**
566
+ * Called as observer(error, carriedScopePath) for every 400 answer.
567
+ * `carriedScopePath` says whether the refused request named a scope path,
568
+ * which is how the client learns its cached ladder may be stale. Never
569
+ * allowed to throw.
570
+ */
571
+ __init5() {this.onInvalidInput = void 0}
572
+ /**
573
+ * A 400 answered a call that carried a scope path: the ladder we hold may be
574
+ * stale. The next read is at most one per LADDER_INVALIDATION_MIN_INTERVAL_MS,
575
+ * the last known ladder stays as the answer if it fails, and a read already
576
+ * in flight will not be stored.
577
+ *
578
+ * The server's refusal wording is deliberately not inspected. The gRPC
579
+ * stream does not surface HTTP 400, so a ladder error on the stream is not
580
+ * observed here.
581
+ */
582
+ invalidateScopeLadder() {
583
+ this.#ladderGeneration += 1;
584
+ this.#ladderInvalidated = true;
585
+ this.#ladderRetryAt = 0;
586
+ }
587
+ /** The ladder already held, or null when none has been read. Makes no request. */
588
+ cachedScopeLadder() {
589
+ return this.#ladderLoaded ? this.#ladder : null;
590
+ }
591
+ /**
592
+ * The account's ladder, from whoami, cached for 300 s (`null` included).
593
+ * Concurrent callers share one read. A failed re-read after expiry keeps the
594
+ * last known ladder (with a warning) and waits 60 s before trying again. A
595
+ * failure on the first read, or with `refresh`, is thrown.
596
+ */
597
+ async getScopeLadder(refresh, warn) {
598
+ const now = this.clock();
599
+ const cached2 = this.#ladder;
600
+ const loaded = this.#ladderLoaded;
601
+ if (!refresh && loaded) {
602
+ if (now < this.#ladderRetryAt) return cached2;
603
+ if (this.#ladderInvalidated) {
604
+ if (now < this.#ladderInvalidationReadAt + LADDER_INVALIDATION_MIN_INTERVAL_MS) return cached2;
605
+ } else if (now < this.#ladderExpiresAt) {
606
+ return cached2;
607
+ }
608
+ }
609
+ const keepOnFailure = loaded && !refresh;
610
+ const inflight = this.#ladderInflight;
611
+ if (inflight !== void 0 && inflight.generation === this.#ladderGeneration && inflight.keepOnFailure === keepOnFailure) {
612
+ return inflight.promise;
613
+ }
614
+ const generation = this.#ladderGeneration;
615
+ if (this.#ladderInvalidated && !refresh) this.#ladderInvalidationReadAt = now;
616
+ const promise = this.#readScopeLadder(now, generation, cached2, keepOnFailure, warn);
617
+ const entry = { promise, generation, keepOnFailure };
618
+ this.#ladderInflight = entry;
619
+ const clear = () => {
620
+ if (this.#ladderInflight === entry) this.#ladderInflight = void 0;
621
+ };
622
+ promise.then(clear, clear);
623
+ return promise;
624
+ }
625
+ async #readScopeLadder(now, generation, cached2, keepOnFailure, warn) {
626
+ let whoami;
627
+ try {
628
+ const raw = await this.request("whoami", {});
629
+ whoami = typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : {};
630
+ } catch (error) {
631
+ if (keepOnFailure) {
632
+ warn(
633
+ `Could not re-read the scope ladder (${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _14 => _14.message]), () => ( String(error)))}); keeping the last known one and retrying in ${LADDER_RETRY_BACKOFF_MS / 1e3}s.`
634
+ );
635
+ this.#ladderRetryAt = now + LADDER_RETRY_BACKOFF_MS;
636
+ return cached2;
637
+ }
638
+ throw error;
639
+ }
640
+ const ladder = ladderFromWhoami(whoami, this.userContextIsolation, warn);
641
+ if (generation === this.#ladderGeneration) {
642
+ this.#ladder = ladder;
643
+ this.#ladderLoaded = true;
644
+ this.#ladderExpiresAt = now + LADDER_TTL_MS;
645
+ this.#ladderRetryAt = 0;
646
+ this.#ladderInvalidated = false;
647
+ }
648
+ return ladder;
649
+ }
330
650
  /**
331
651
  * Set by the client to its identity resolution (`initialize()`'s whoami).
332
652
  * Python refuses every call before `initialize()`; here the first request
333
653
  * runs it instead, so a caller who skips it gets the same identity-dependent
334
654
  * behaviour (client-scope cache hits, the B2C check) rather than an error.
335
655
  */
336
- __init5() {this.identityResolver = void 0}
656
+ __init6() {this.identityResolver = void 0}
337
657
  /** Resolve identity once, before the first request. Never throws. */
338
658
  async ready() {
339
659
  if (this.identityResolver !== void 0) await this.identityResolver();
@@ -379,7 +699,7 @@ var HttpTransport = (_class2 = class {
379
699
  this.notReadyCooldown.delete(instanceId);
380
700
  return;
381
701
  }
382
- throw new (0, _chunk7IZHVYO2cjs.InstanceNotReadyError)(entry.message, {
702
+ throw new (0, _chunkJPDEKN5Mcjs.InstanceNotReadyError)(entry.message, {
383
703
  correlationId,
384
704
  retryAfterSeconds: Math.max(1, Math.ceil(remainingMs / 1e3)),
385
705
  instanceId,
@@ -400,7 +720,7 @@ var HttpTransport = (_class2 = class {
400
720
  }
401
721
  async request(name, options = {}) {
402
722
  const spec = ENDPOINTS[name];
403
- const correlationId = _nullishCoalesce(options.correlationId, () => ( _chunk7IZHVYO2cjs.newCorrelationId.call(void 0, )));
723
+ const correlationId = _nullishCoalesce(options.correlationId, () => ( _chunkJPDEKN5Mcjs.newCorrelationId.call(void 0, )));
404
724
  const idempotent = _nullishCoalesce(options.idempotent, () => ( spec.idempotent));
405
725
  if (name !== "whoami") await this.ready();
406
726
  const gated = isGatedPath(spec.method, resolvePath(name, options.pathParams));
@@ -415,7 +735,7 @@ var HttpTransport = (_class2 = class {
415
735
  if (gated) this.notReadyCooldown.delete(cooldownKey);
416
736
  return result;
417
737
  } catch (error) {
418
- if (gated && error instanceof _chunk7IZHVYO2cjs.InstanceNotReadyError && !error.fromCooldown) {
738
+ if (gated && error instanceof _chunkJPDEKN5Mcjs.InstanceNotReadyError && !error.fromCooldown) {
419
739
  this.cooldownStart(cooldownKey, error);
420
740
  }
421
741
  last = { error, outcomeUnknown: isOutcomeUnknown(error) };
@@ -431,7 +751,7 @@ var HttpTransport = (_class2 = class {
431
751
  await sleep(decision.delaySeconds * 1e3, options.signal);
432
752
  }
433
753
  }
434
- throw _nullishCoalesce(_optionalChain([last, 'optionalAccess', _11 => _11.error]), () => ( new (0, _chunk7IZHVYO2cjs.SynapError)("Request failed with no recorded error")));
754
+ throw _nullishCoalesce(_optionalChain([last, 'optionalAccess', _15 => _15.error]), () => ( new (0, _chunkJPDEKN5Mcjs.SynapError)("Request failed with no recorded error")));
435
755
  }
436
756
  async attempt(name, options, correlationId) {
437
757
  const spec = ENDPOINTS[name];
@@ -457,15 +777,21 @@ var HttpTransport = (_class2 = class {
457
777
  }
458
778
  if (!response.ok) {
459
779
  const error = await toHttpError(response, correlationId);
460
- throw _nullishCoalesce(_optionalChain([options, 'access', _12 => _12.mapError, 'optionalCall', _13 => _13(response.status, error)]), () => ( error));
780
+ if (response.status === 400 && error instanceof _chunkJPDEKN5Mcjs.InvalidInputError) {
781
+ try {
782
+ _optionalChain([this, 'access', _16 => _16.onInvalidInput, 'optionalCall', _17 => _17(error, carriesScopePath(options.body))]);
783
+ } catch (e3) {
784
+ }
785
+ }
786
+ throw _nullishCoalesce(_optionalChain([options, 'access', _18 => _18.mapError, 'optionalCall', _19 => _19(response.status, error)]), () => ( error));
461
787
  }
462
788
  if (response.status === 204) return void 0;
463
789
  const text = await response.text();
464
790
  if (!text) return void 0;
465
791
  try {
466
792
  return JSON.parse(text);
467
- } catch (e3) {
468
- throw new (0, _chunk7IZHVYO2cjs.SynapError)(`Malformed JSON in response from ${url}`, { correlationId });
793
+ } catch (e4) {
794
+ throw new (0, _chunkJPDEKN5Mcjs.SynapError)(`Malformed JSON in response from ${url}`, { correlationId });
469
795
  }
470
796
  }
471
797
  buildUrl(path, query) {
@@ -500,15 +826,15 @@ var HttpTransport = (_class2 = class {
500
826
  }
501
827
  }, _class2);
502
828
  function isOutcomeUnknown(error) {
503
- if (error instanceof _chunk7IZHVYO2cjs.RateLimitError) return false;
504
- if (error instanceof _chunk7IZHVYO2cjs.ServiceUnavailableError) return false;
505
- if (error instanceof _chunk7IZHVYO2cjs.AuthenticationError) return false;
506
- if (error instanceof _chunk7IZHVYO2cjs.InvalidInputError) return false;
507
- if (error instanceof _chunk7IZHVYO2cjs.ConflictError) return false;
508
- if (error instanceof _chunk7IZHVYO2cjs.InsufficientCreditsError) return false;
509
- if (error instanceof _chunk7IZHVYO2cjs.ContextNotFoundError) return false;
829
+ if (error instanceof _chunkJPDEKN5Mcjs.RateLimitError) return false;
830
+ if (error instanceof _chunkJPDEKN5Mcjs.ServiceUnavailableError) return false;
831
+ if (error instanceof _chunkJPDEKN5Mcjs.AuthenticationError) return false;
832
+ if (error instanceof _chunkJPDEKN5Mcjs.InvalidInputError) return false;
833
+ if (error instanceof _chunkJPDEKN5Mcjs.ConflictError) return false;
834
+ if (error instanceof _chunkJPDEKN5Mcjs.InsufficientCreditsError) return false;
835
+ if (error instanceof _chunkJPDEKN5Mcjs.ContextNotFoundError) return false;
510
836
  if (isConnectionRefusal(error)) return false;
511
- if (error instanceof _chunk7IZHVYO2cjs.NetworkTimeoutError) return true;
837
+ if (error instanceof _chunkJPDEKN5Mcjs.NetworkTimeoutError) return true;
512
838
  return true;
513
839
  }
514
840
  var CONNECTION_REFUSAL_CODES = /* @__PURE__ */ new Set([
@@ -528,19 +854,19 @@ function isConnectionRefusal(error) {
528
854
  return false;
529
855
  }
530
856
  function toTransportError(error, correlationId) {
531
- if (error instanceof _chunk7IZHVYO2cjs.SynapError) return error;
532
- const name = _optionalChain([error, 'optionalAccess', _14 => _14.name]);
857
+ if (error instanceof _chunkJPDEKN5Mcjs.SynapError) return error;
858
+ const name = _optionalChain([error, 'optionalAccess', _20 => _20.name]);
533
859
  if (name === "AbortError" || name === "TimeoutError") {
534
- return new (0, _chunk7IZHVYO2cjs.NetworkTimeoutError)("Request timed out", { correlationId, cause: error });
860
+ return new (0, _chunkJPDEKN5Mcjs.NetworkTimeoutError)("Request timed out", { correlationId, cause: error });
535
861
  }
536
862
  if (isConnectionRefusal(error)) {
537
- return new (0, _chunk7IZHVYO2cjs.NetworkTimeoutError)(
538
- `Connection failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _15 => _15.message]), () => ( String(error)))}`,
863
+ return new (0, _chunkJPDEKN5Mcjs.NetworkTimeoutError)(
864
+ `Connection failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _21 => _21.message]), () => ( String(error)))}`,
539
865
  { correlationId, cause: error }
540
866
  );
541
867
  }
542
- return new (0, _chunk7IZHVYO2cjs.ServiceUnavailableError)(
543
- `Network request failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _16 => _16.message]), () => ( String(error)))}`,
868
+ return new (0, _chunkJPDEKN5Mcjs.ServiceUnavailableError)(
869
+ `Network request failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _22 => _22.message]), () => ( String(error)))}`,
544
870
  { correlationId, cause: error }
545
871
  );
546
872
  }
@@ -554,12 +880,44 @@ function creditReason(payload) {
554
880
  const error = stringOrNull(payload["error"]);
555
881
  return error !== null && CREDIT_ERRORS.has(error) ? error : null;
556
882
  }
883
+ function isScopePath(value) {
884
+ let v = value;
885
+ if (typeof v === "string" && v.trimStart().startsWith("{")) {
886
+ try {
887
+ v = JSON.parse(v);
888
+ } catch (e5) {
889
+ return false;
890
+ }
891
+ }
892
+ return typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length > 0;
893
+ }
894
+ function carriesScopePath(body) {
895
+ if (typeof FormData !== "undefined" && body instanceof FormData) {
896
+ if (isScopePath(body.get("scope"))) return true;
897
+ const manifest = body.get("manifest");
898
+ if (typeof manifest === "string") {
899
+ try {
900
+ const parsed = JSON.parse(manifest);
901
+ return typeof parsed === "object" && parsed !== null && isScopePath(parsed["scope"]);
902
+ } catch (e6) {
903
+ return false;
904
+ }
905
+ }
906
+ return false;
907
+ }
908
+ if (typeof body !== "object" || body === null || Array.isArray(body)) return false;
909
+ const o2 = body;
910
+ if (isScopePath(o2["scope"])) return true;
911
+ return Object.values(o2).some(
912
+ (v) => Array.isArray(v) && v.some((i) => typeof i === "object" && i !== null && isScopePath(i["scope"]))
913
+ );
914
+ }
557
915
  async function toHttpError(response, correlationId) {
558
916
  const body = await response.text().catch(() => "");
559
917
  let parsed = {};
560
918
  try {
561
919
  parsed = JSON.parse(body);
562
- } catch (e4) {
920
+ } catch (e7) {
563
921
  }
564
922
  const rawDetail = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(parsed["detail"], () => ( parsed["message"])), () => ( body)), () => ( ""));
565
923
  const detailObject = typeof rawDetail === "object" && rawDetail !== null ? rawDetail : null;
@@ -574,15 +932,15 @@ async function toHttpError(response, correlationId) {
574
932
  case 405:
575
933
  case 413:
576
934
  case 415:
577
- return new (0, _chunk7IZHVYO2cjs.InvalidInputError)(message, opts);
935
+ return new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(message, opts);
578
936
  case 401:
579
937
  case 403:
580
- return new (0, _chunk7IZHVYO2cjs.AuthenticationError)(message, opts);
938
+ return new (0, _chunkJPDEKN5Mcjs.AuthenticationError)(message, opts);
581
939
  case 404:
582
- return new (0, _chunk7IZHVYO2cjs.ContextNotFoundError)(message, opts);
940
+ return new (0, _chunkJPDEKN5Mcjs.ContextNotFoundError)(message, opts);
583
941
  case 402: {
584
942
  const credit = creditPayload(parsed, detailObject);
585
- return new (0, _chunk7IZHVYO2cjs.InsufficientCreditsError)(message, {
943
+ return new (0, _chunkJPDEKN5Mcjs.InsufficientCreditsError)(message, {
586
944
  ...opts,
587
945
  balanceCredits: numberOrNull(credit["balance_credits"]),
588
946
  requiredCredits: _nullishCoalesce(numberOrNull(credit["minimum_required_credits"]), () => ( numberOrNull(credit["required_credits"]))),
@@ -593,11 +951,11 @@ async function toHttpError(response, correlationId) {
593
951
  });
594
952
  }
595
953
  case 409:
596
- if (parsed["error"] === "instance_build_failed" || _optionalChain([detailObject, 'optionalAccess', _17 => _17["code"]]) === "instance_build_failed" || _optionalChain([detailObject, 'optionalAccess', _18 => _18["error"]]) === "instance_build_failed") {
597
- const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess', _19 => _19[key]])));
954
+ if (parsed["error"] === "instance_build_failed" || _optionalChain([detailObject, 'optionalAccess', _23 => _23["code"]]) === "instance_build_failed" || _optionalChain([detailObject, 'optionalAccess', _24 => _24["error"]]) === "instance_build_failed") {
955
+ const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess', _25 => _25[key]])));
598
956
  const msg = pick4("message");
599
957
  const attempts = Number(pick4("attempts"));
600
- return new (0, _chunk7IZHVYO2cjs.InstanceBuildFailedError)(
958
+ return new (0, _chunkJPDEKN5Mcjs.InstanceBuildFailedError)(
601
959
  typeof msg === "string" && msg !== "" ? msg : "This instance's memory architecture build failed.",
602
960
  {
603
961
  ...opts,
@@ -607,12 +965,12 @@ async function toHttpError(response, correlationId) {
607
965
  }
608
966
  );
609
967
  }
610
- if (parsed["error"] === "instance_not_ready" || _optionalChain([detailObject, 'optionalAccess', _20 => _20["code"]]) === "instance_not_ready" || _optionalChain([detailObject, 'optionalAccess', _21 => _21["error"]]) === "instance_not_ready") {
611
- const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess', _22 => _22[key]])));
968
+ if (parsed["error"] === "instance_not_ready" || _optionalChain([detailObject, 'optionalAccess', _26 => _26["code"]]) === "instance_not_ready" || _optionalChain([detailObject, 'optionalAccess', _27 => _27["error"]]) === "instance_not_ready") {
969
+ const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess', _28 => _28[key]])));
612
970
  const rawWait = _nullishCoalesce(pick4("retry_after_seconds"), () => ( response.headers.get("retry-after")));
613
971
  const wait = rawWait !== null && rawWait !== void 0 && String(rawWait).trim() !== "" ? Number(rawWait) : NaN;
614
972
  const msg = pick4("message");
615
- return new (0, _chunk7IZHVYO2cjs.InstanceNotReadyError)(
973
+ return new (0, _chunkJPDEKN5Mcjs.InstanceNotReadyError)(
616
974
  typeof msg === "string" && msg !== "" ? msg : "This instance's memory architecture is still being built.",
617
975
  {
618
976
  ...opts,
@@ -623,14 +981,14 @@ async function toHttpError(response, correlationId) {
623
981
  );
624
982
  }
625
983
  if (detailObject !== null && detailObject["code"] === "transcript_conflict") {
626
- return new (0, _chunk7IZHVYO2cjs.TranscriptConflictError)(message, opts);
984
+ return new (0, _chunkJPDEKN5Mcjs.TranscriptConflictError)(message, opts);
627
985
  }
628
- return new (0, _chunk7IZHVYO2cjs.ConflictError)(message, opts);
986
+ return new (0, _chunkJPDEKN5Mcjs.ConflictError)(message, opts);
629
987
  case 429: {
630
988
  const header = response.headers.get("retry-after");
631
989
  const retryAfter = header !== null && header.trim() !== "" ? Number(header) : null;
632
990
  const credit = creditPayload(parsed, detailObject);
633
- return new (0, _chunk7IZHVYO2cjs.RateLimitError)(message, {
991
+ return new (0, _chunkJPDEKN5Mcjs.RateLimitError)(message, {
634
992
  ...opts,
635
993
  retryAfterSeconds: retryAfter !== null && Number.isFinite(retryAfter) ? retryAfter : null,
636
994
  reason: creditReason(credit),
@@ -639,13 +997,13 @@ async function toHttpError(response, correlationId) {
639
997
  });
640
998
  }
641
999
  case 503:
642
- return new (0, _chunk7IZHVYO2cjs.ServiceUnavailableError)(message, opts);
1000
+ return new (0, _chunkJPDEKN5Mcjs.ServiceUnavailableError)(message, opts);
643
1001
  case 504:
644
- return new (0, _chunk7IZHVYO2cjs.AgentUnavailableError)(message, opts);
1002
+ return new (0, _chunkJPDEKN5Mcjs.AgentUnavailableError)(message, opts);
645
1003
  default:
646
- if (response.status >= 500) return new (0, _chunk7IZHVYO2cjs.ServiceUnavailableError)(message, opts);
647
- if (response.status >= 400) return new (0, _chunk7IZHVYO2cjs.SynapPermanentError)(message, opts);
648
- return new (0, _chunk7IZHVYO2cjs.SynapError)(message, opts);
1004
+ if (response.status >= 500) return new (0, _chunkJPDEKN5Mcjs.ServiceUnavailableError)(message, opts);
1005
+ if (response.status >= 400) return new (0, _chunkJPDEKN5Mcjs.SynapPermanentError)(message, opts);
1006
+ return new (0, _chunkJPDEKN5Mcjs.SynapError)(message, opts);
649
1007
  }
650
1008
  }
651
1009
  function numberOrNull(v) {
@@ -656,11 +1014,11 @@ function stringOrNull(v) {
656
1014
  }
657
1015
  function withTimeout(ms, external) {
658
1016
  const controller = new AbortController();
659
- const onExternalAbort = () => controller.abort(_optionalChain([external, 'optionalAccess', _23 => _23.reason]));
1017
+ const onExternalAbort = () => controller.abort(_optionalChain([external, 'optionalAccess', _29 => _29.reason]));
660
1018
  const timer = setTimeout(() => {
661
- controller.abort(new (0, _chunk7IZHVYO2cjs.NetworkTimeoutError)(`Timed out after ${ms}ms`));
1019
+ controller.abort(new (0, _chunkJPDEKN5Mcjs.NetworkTimeoutError)(`Timed out after ${ms}ms`));
662
1020
  }, ms);
663
- _optionalChain([timer, 'access', _24 => _24.unref, 'optionalCall', _25 => _25()]);
1021
+ _optionalChain([timer, 'access', _30 => _30.unref, 'optionalCall', _31 => _31()]);
664
1022
  if (external) {
665
1023
  if (external.aborted) onExternalAbort();
666
1024
  else external.addEventListener("abort", onExternalAbort, { once: true });
@@ -669,7 +1027,7 @@ function withTimeout(ms, external) {
669
1027
  signal: controller.signal,
670
1028
  dispose() {
671
1029
  clearTimeout(timer);
672
- _optionalChain([external, 'optionalAccess', _26 => _26.removeEventListener, 'call', _27 => _27("abort", onExternalAbort)]);
1030
+ _optionalChain([external, 'optionalAccess', _32 => _32.removeEventListener, 'call', _33 => _33("abort", onExternalAbort)]);
673
1031
  }
674
1032
  };
675
1033
  }
@@ -677,14 +1035,14 @@ function sleep(ms, signal) {
677
1035
  if (ms <= 0) return Promise.resolve();
678
1036
  return new Promise((resolve, reject) => {
679
1037
  const timer = setTimeout(() => {
680
- _optionalChain([signal, 'optionalAccess', _28 => _28.removeEventListener, 'call', _29 => _29("abort", onAbort)]);
1038
+ _optionalChain([signal, 'optionalAccess', _34 => _34.removeEventListener, 'call', _35 => _35("abort", onAbort)]);
681
1039
  resolve();
682
1040
  }, ms);
683
1041
  function onAbort() {
684
1042
  clearTimeout(timer);
685
- reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _30 => _30.reason]), () => ( new Error("Aborted"))));
1043
+ reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _36 => _36.reason]), () => ( new Error("Aborted"))));
686
1044
  }
687
- _optionalChain([signal, 'optionalAccess', _31 => _31.addEventListener, 'call', _32 => _32("abort", onAbort, { once: true })]);
1045
+ _optionalChain([signal, 'optionalAccess', _37 => _37.addEventListener, 'call', _38 => _38("abort", onAbort, { once: true })]);
688
1046
  });
689
1047
  }
690
1048
 
@@ -828,10 +1186,10 @@ function buildFetchRequest(scope, options) {
828
1186
  const { mode, precisionLevel } = retrievalOptionsOf(options);
829
1187
  const { contextMode, lastN } = scopeOptionsOf(scope, options);
830
1188
  if (searchQuery !== void 0 && !Array.isArray(searchQuery)) {
831
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("search_query must be an array when provided");
1189
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("search_query must be an array when provided");
832
1190
  }
833
1191
  if (options.types !== void 0 && !Array.isArray(options.types)) {
834
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("types must be an array when provided");
1192
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("types must be an array when provided");
835
1193
  }
836
1194
  const body = {
837
1195
  conversation_id: _nullishCoalesce(conversationId, () => ( null)),
@@ -880,7 +1238,7 @@ var VALID_CONTEXT_MODES = ["in-conversation", "conversation-summary"];
880
1238
  function responseShapeOf(options) {
881
1239
  const shape = _nullishCoalesce(opt(options, "response_shape", "responseShape"), () => ( "by_type"));
882
1240
  if (!RESPONSE_SHAPES.includes(shape)) {
883
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1241
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
884
1242
  `Invalid response_shape '${shape}'. Must be one of: ${RESPONSE_SHAPES.join(", ")}`
885
1243
  );
886
1244
  }
@@ -895,21 +1253,21 @@ var REQUIRED_ID = {
895
1253
  function scopeOptionsOf(scope, options) {
896
1254
  const required = REQUIRED_ID[scope];
897
1255
  if (required !== null && !opt(options, required[0], required[1])) {
898
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`${required[0]} is required`);
1256
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`${required[0]} is required`);
899
1257
  }
900
1258
  const contextMode = _nullishCoalesce(opt(options, "context_mode", "contextMode"), () => ( "in-conversation"));
901
1259
  const lastN = _nullishCoalesce(opt(options, "last_n_conversations", "lastNConversations"), () => ( 1));
902
1260
  if (scope !== "user") return { contextMode, lastN };
903
1261
  if (!VALID_CONTEXT_MODES.includes(contextMode)) {
904
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1262
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
905
1263
  `Invalid context_mode '${contextMode}'. Must be one of: ${VALID_CONTEXT_MODES.join(", ")}`
906
1264
  );
907
1265
  }
908
1266
  if (!Number.isInteger(lastN)) {
909
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("last_n_conversations must be an integer");
1267
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("last_n_conversations must be an integer");
910
1268
  }
911
1269
  if (lastN < 0 || lastN > 20) {
912
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("last_n_conversations must be between 0 and 20");
1270
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("last_n_conversations must be between 0 and 20");
913
1271
  }
914
1272
  return { contextMode, lastN };
915
1273
  }
@@ -918,13 +1276,13 @@ var VALID_PRECISION = ["high", "medium"];
918
1276
  function retrievalOptionsOf(options) {
919
1277
  const mode = _nullishCoalesce(options.mode, () => ( "fast"));
920
1278
  if (!VALID_MODES.includes(mode)) {
921
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1279
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
922
1280
  `Invalid mode '${mode}'. Must be one of: ${VALID_MODES.join(", ")}`
923
1281
  );
924
1282
  }
925
1283
  const precisionLevel = _nullishCoalesce(opt(options, "precision_level", "precisionLevel"), () => ( "high"));
926
1284
  if (!VALID_PRECISION.includes(precisionLevel)) {
927
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1285
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
928
1286
  `Invalid precision_level '${precisionLevel}'. Must be one of: ${VALID_PRECISION.join(", ")}`
929
1287
  );
930
1288
  }
@@ -933,12 +1291,12 @@ function retrievalOptionsOf(options) {
933
1291
  function validateSearchQuery(searchQuery) {
934
1292
  if (searchQuery === void 0 || searchQuery === null) return;
935
1293
  if (!Array.isArray(searchQuery) || searchQuery.some((query) => typeof query !== "string")) {
936
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("search_query must be an array of strings when provided");
1294
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("search_query must be an array of strings when provided");
937
1295
  }
938
1296
  }
939
1297
  async function fetchContext(transport, scope, options = {}, hooks = {}) {
940
1298
  const startedAt = Date.now();
941
- await _optionalChain([transport, 'access', _33 => _33.ready, 'optionalCall', _34 => _34()]);
1299
+ await _optionalChain([transport, 'access', _39 => _39.ready, 'optionalCall', _40 => _40()]);
942
1300
  await transport.checkCustomerId(
943
1301
  opt(options, "customer_id", "customerId"),
944
1302
  `${scope}.context.fetch`
@@ -954,20 +1312,20 @@ async function fetchContext(transport, scope, options = {}, hooks = {}) {
954
1312
  if (answer !== null) return applyResponseShape(answer, responseShape);
955
1313
  }
956
1314
  const finish = (response2) => {
957
- _optionalChain([hooks, 'access', _35 => _35.onResponse, 'optionalCall', _36 => _36(scope, options, response2)]);
1315
+ _optionalChain([hooks, 'access', _41 => _41.onResponse, 'optionalCall', _42 => _42(scope, options, response2)]);
958
1316
  return response2;
959
1317
  };
960
1318
  const conversationId = opt(options, "conversation_id", "conversationId");
961
- const skipServerSt = conversationId ? _optionalChain([hooks, 'access', _37 => _37.skipServerShortTerm, 'optionalCall', _38 => _38(conversationId)]) === true : false;
1319
+ const skipServerSt = conversationId ? _optionalChain([hooks, 'access', _43 => _43.skipServerShortTerm, 'optionalCall', _44 => _44(conversationId)]) === true : false;
962
1320
  const network = async () => {
963
1321
  const { endpoint, body } = buildFetchRequest(
964
1322
  scope,
965
1323
  skipServerSt ? { ...options, include_conversation_context: false } : options
966
1324
  );
967
1325
  const result = await transport.request(endpoint, { body });
968
- return applyResponseShape(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _39 => _39["context"]]), () => ( {})), responseShape);
1326
+ return applyResponseShape(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _45 => _45["context"]]), () => ( {})), responseShape);
969
1327
  };
970
- const anticipated = summaryMode ? null : await _asyncNullishCoalesce(await _optionalChain([hooks, 'access', _40 => _40.beforeFetch, 'optionalCall', _41 => _41(scope, options)]), async () => ( null));
1328
+ const anticipated = summaryMode ? null : await _asyncNullishCoalesce(await _optionalChain([hooks, 'access', _46 => _46.beforeFetch, 'optionalCall', _47 => _47(scope, options)]), async () => ( null));
971
1329
  if (anticipated !== null && anticipated.borderline) {
972
1330
  const pending = network();
973
1331
  pending.catch(() => void 0);
@@ -978,17 +1336,17 @@ async function fetchContext(transport, scope, options = {}, hooks = {}) {
978
1336
  const won = await Promise.race([pending.then((r) => r, () => null), late]);
979
1337
  if (timer !== void 0) clearTimeout(timer);
980
1338
  if (won !== null) {
981
- _optionalChain([hooks, 'access', _42 => _42.onAssembled, 'optionalCall', _43 => _43(scope, options, won, startedAt)]);
1339
+ _optionalChain([hooks, 'access', _48 => _48.onAssembled, 'optionalCall', _49 => _49(scope, options, won, startedAt)]);
982
1340
  return finish(won);
983
1341
  }
984
1342
  }
985
1343
  if (anticipated !== null) {
986
- _optionalChain([hooks, 'access', _44 => _44.onServedFromCache, 'optionalCall', _45 => _45(scope, options, anticipated)]);
987
- _optionalChain([hooks, 'access', _46 => _46.onAssembled, 'optionalCall', _47 => _47(scope, options, anticipated.response, startedAt)]);
1344
+ _optionalChain([hooks, 'access', _50 => _50.onServedFromCache, 'optionalCall', _51 => _51(scope, options, anticipated)]);
1345
+ _optionalChain([hooks, 'access', _52 => _52.onAssembled, 'optionalCall', _53 => _53(scope, options, anticipated.response, startedAt)]);
988
1346
  return finish(applyResponseShape(anticipated.response, responseShape));
989
1347
  }
990
1348
  const response = await network();
991
- _optionalChain([hooks, 'access', _48 => _48.onAssembled, 'optionalCall', _49 => _49(scope, options, response, startedAt)]);
1349
+ _optionalChain([hooks, 'access', _54 => _54.onAssembled, 'optionalCall', _55 => _55(scope, options, response, startedAt)]);
992
1350
  return finish(response);
993
1351
  }
994
1352
 
@@ -1239,7 +1597,7 @@ function isBranded(value) {
1239
1597
  return typeof value === "object" && value !== null && PART_BRAND in value;
1240
1598
  }
1241
1599
  function textPart(text) {
1242
- if (typeof text !== "string") throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("TextPart text must be a string");
1600
+ if (typeof text !== "string") throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("TextPart text must be a string");
1243
1601
  return brand({ type: "text", text });
1244
1602
  }
1245
1603
  function filePart(init) {
@@ -1268,7 +1626,7 @@ function checkOneSource(p) {
1268
1626
  (k) => p[k] !== void 0 && p[k] !== null
1269
1627
  );
1270
1628
  if (given.length !== 1) {
1271
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1629
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1272
1630
  "FilePart takes exactly one of data, path or url" + (given.length > 0 ? ` (got ${given.join(", ")})` : "")
1273
1631
  );
1274
1632
  }
@@ -1285,12 +1643,12 @@ function defaultFilename(p, source) {
1285
1643
  let pathname = "";
1286
1644
  try {
1287
1645
  pathname = new URL(String(p.url)).pathname;
1288
- } catch (e5) {
1646
+ } catch (e8) {
1289
1647
  pathname = _nullishCoalesce(String(p.url).split(/[?#]/)[0], () => ( ""));
1290
1648
  }
1291
1649
  return lastSegment(pathname) || "file";
1292
1650
  }
1293
- const named = _optionalChain([p, 'access', _50 => _50.data, 'optionalAccess', _51 => _51.name]);
1651
+ const named = _optionalChain([p, 'access', _56 => _56.data, 'optionalAccess', _57 => _57.name]);
1294
1652
  return typeof named === "string" && named ? named : "file";
1295
1653
  }
1296
1654
  var MEDIA_TYPES = {
@@ -1327,7 +1685,7 @@ function guessMediaType(filename) {
1327
1685
  function defaultMediaType(filename, data) {
1328
1686
  const guessed = guessMediaType(filename);
1329
1687
  if (guessed !== null) return guessed;
1330
- const blobType = _optionalChain([data, 'optionalAccess', _52 => _52.type]);
1688
+ const blobType = _optionalChain([data, 'optionalAccess', _58 => _58.type]);
1331
1689
  return typeof blobType === "string" && blobType ? blobType : DEFAULT_MEDIA_TYPE;
1332
1690
  }
1333
1691
  function normaliseContent(value, field) {
@@ -1335,12 +1693,12 @@ function normaliseContent(value, field) {
1335
1693
  if (isBranded(value) && isFilePart(value)) return { kind: "parts", parts: [value] };
1336
1694
  if (!Array.isArray(value)) return null;
1337
1695
  if (value.length === 0) {
1338
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`${field} is an empty list; pass at least one part`);
1696
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`${field} is an empty list; pass at least one part`);
1339
1697
  }
1340
1698
  const parts = value.map((item, i) => {
1341
1699
  if (typeof item === "string") return { type: "text", text: item };
1342
1700
  if (isTextPart(item) || isFilePart(item)) return item;
1343
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1701
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1344
1702
  `${field}[${i}] is a ${typeName(item)}; expected a string, TextPart or FilePart`
1345
1703
  );
1346
1704
  });
@@ -1353,7 +1711,7 @@ function typeName(value) {
1353
1711
  if (value === null) return "null";
1354
1712
  if (Array.isArray(value)) return "array";
1355
1713
  if (typeof value === "object") {
1356
- return _nullishCoalesce(_optionalChain([value, 'access', _53 => _53.constructor, 'optionalAccess', _54 => _54.name]), () => ( "object"));
1714
+ return _nullishCoalesce(_optionalChain([value, 'access', _59 => _59.constructor, 'optionalAccess', _60 => _60.name]), () => ( "object"));
1357
1715
  }
1358
1716
  return typeof value;
1359
1717
  }
@@ -1369,8 +1727,8 @@ async function resolveFile(part, fetchImpl) {
1369
1727
  try {
1370
1728
  bytes = new Uint8Array(await readFile(part.path));
1371
1729
  } catch (error) {
1372
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1373
- `Could not read FilePart path '${part.path}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _55 => _55.message]), () => ( String(error)))}`,
1730
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1731
+ `Could not read FilePart path '${part.path}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _61 => _61.message]), () => ( String(error)))}`,
1374
1732
  { cause: error }
1375
1733
  );
1376
1734
  }
@@ -1380,7 +1738,7 @@ async function resolveFile(part, fetchImpl) {
1380
1738
  if (mediaType === DEFAULT_MEDIA_TYPE && fetched.contentType) mediaType = fetched.contentType;
1381
1739
  }
1382
1740
  if (bytes.byteLength > MAX_FILE_BYTES) {
1383
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1741
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1384
1742
  `${filename} is ${bytes.byteLength} bytes; the limit is ${MAX_FILE_BYTES} bytes per file`
1385
1743
  );
1386
1744
  }
@@ -1400,17 +1758,17 @@ async function toBytes(data) {
1400
1758
  if (typeof Blob !== "undefined" && data instanceof Blob) {
1401
1759
  return new Uint8Array(await data.arrayBuffer());
1402
1760
  }
1403
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("FilePart data must be a Uint8Array, ArrayBuffer or Blob");
1761
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("FilePart data must be a Uint8Array, ArrayBuffer or Blob");
1404
1762
  }
1405
1763
  async function fetchUrl(url, fetchImpl) {
1406
1764
  let scheme = "";
1407
1765
  try {
1408
1766
  scheme = new URL(url).protocol;
1409
- } catch (e6) {
1410
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`Could not fetch FilePart url '${url}': not a valid URL`);
1767
+ } catch (e9) {
1768
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`Could not fetch FilePart url '${url}': not a valid URL`);
1411
1769
  }
1412
1770
  if (scheme !== "http:" && scheme !== "https:") {
1413
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1771
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1414
1772
  `Could not fetch FilePart url '${url}': only http and https are supported`
1415
1773
  );
1416
1774
  }
@@ -1419,28 +1777,28 @@ async function fetchUrl(url, fetchImpl) {
1419
1777
  try {
1420
1778
  const response = await fetchImpl(url, { method: "GET", signal: controller.signal });
1421
1779
  if (response.status < 200 || response.status >= 300) {
1422
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1780
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1423
1781
  `Fetching FilePart url '${url}' returned HTTP ${response.status}`
1424
1782
  );
1425
1783
  }
1426
1784
  const declared = Number(_nullishCoalesce(response.headers.get("content-length"), () => ( "")));
1427
1785
  if (Number.isFinite(declared) && declared > MAX_FILE_BYTES) {
1428
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(urlTooLarge(url));
1786
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(urlTooLarge(url));
1429
1787
  }
1430
1788
  const bytes = await readCapped(response, url);
1431
1789
  const rawType = response.headers.get("content-type");
1432
1790
  const contentType = rawType ? rawType.split(";", 1)[0].trim().toLowerCase() || null : null;
1433
1791
  return { bytes, contentType };
1434
1792
  } catch (error) {
1435
- if (error instanceof _chunk7IZHVYO2cjs.InvalidInputError) throw error;
1793
+ if (error instanceof _chunkJPDEKN5Mcjs.InvalidInputError) throw error;
1436
1794
  if (controller.signal.aborted) {
1437
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1795
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1438
1796
  `Could not fetch FilePart url '${url}': timed out after ${URL_FETCH_TIMEOUT_MS / 1e3} s`,
1439
1797
  { cause: error }
1440
1798
  );
1441
1799
  }
1442
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1443
- `Could not fetch FilePart url '${url}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _56 => _56.message]), () => ( String(error)))}`,
1800
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1801
+ `Could not fetch FilePart url '${url}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _62 => _62.message]), () => ( String(error)))}`,
1444
1802
  { cause: error }
1445
1803
  );
1446
1804
  } finally {
@@ -1462,7 +1820,7 @@ async function readCapped(response, url) {
1462
1820
  if (total > MAX_FILE_BYTES) {
1463
1821
  await reader.cancel().catch(() => {
1464
1822
  });
1465
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(urlTooLarge(url));
1823
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(urlTooLarge(url));
1466
1824
  }
1467
1825
  chunks.push(value);
1468
1826
  }
@@ -1534,12 +1892,12 @@ function createFields(options, defaultType) {
1534
1892
  const documentType = _nullishCoalesce(either(o2, "document_type", "documentType"), () => ( defaultType));
1535
1893
  const mode = _nullishCoalesce(options.mode, () => ( DEFAULT_INGEST_MODE));
1536
1894
  if (documentType !== null && !DOCUMENT_TYPES.includes(documentType)) {
1537
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1895
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1538
1896
  `Invalid document_type '${documentType}'. Expected one of: ${DOCUMENT_TYPES.join(", ")}`
1539
1897
  );
1540
1898
  }
1541
1899
  if (!INGEST_MODES.includes(mode)) {
1542
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1900
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1543
1901
  `Invalid mode '${mode}'. Expected one of: ${INGEST_MODES.join(", ")}`
1544
1902
  );
1545
1903
  }
@@ -1569,13 +1927,13 @@ function normaliseCreateScope(scope, userId, customerId) {
1569
1927
  if (scope === void 0 || scope === null) return null;
1570
1928
  const entries = Object.entries(scope);
1571
1929
  if (entries.length > 1 && entries.some(([, v]) => v === "self")) {
1572
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1930
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1573
1931
  `"self" can only be used alone, as scope={"client": "self"}; got ${JSON.stringify(scope)}`
1574
1932
  );
1575
1933
  }
1576
1934
  if (entries.length === 1 && entries[0][0] === "client" && entries[0][1] === "self") {
1577
1935
  if (userId !== null || customerId !== null) {
1578
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1936
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1579
1937
  'scope={"client": "self"} names the client level, so it cannot be combined with user_id or customer_id'
1580
1938
  );
1581
1939
  }
@@ -1587,7 +1945,7 @@ function jsonDocument(document, where) {
1587
1945
  const n2 = normaliseContent(document, "document");
1588
1946
  if (n2 === null) return document;
1589
1947
  if (n2.kind === "parts") {
1590
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1948
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1591
1949
  `${where} cannot carry a FilePart. memories.create sends files as multipart; call it once per document that has files.`
1592
1950
  );
1593
1951
  }
@@ -1595,7 +1953,7 @@ function jsonDocument(document, where) {
1595
1953
  }
1596
1954
  function buildCreateBody(options) {
1597
1955
  const document = jsonDocument(options.document, "This request");
1598
- if (!document) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("document is required");
1956
+ if (!document) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("document is required");
1599
1957
  return { document, ...createFields(options, DEFAULT_DOCUMENT_TYPE) };
1600
1958
  }
1601
1959
  function buildCreateManifest(options, parts, files) {
@@ -1616,13 +1974,13 @@ function buildForgetBody(options) {
1616
1974
  if (typeof description !== "string" || // Code points, as Python's len() and the server count; `.length` counts
1617
1975
  // UTF-16 units, so 251 emoji (502 units) were refused here only.
1618
1976
  [...description].length < FORGET_DESCRIPTION_MIN || [...description].length > FORGET_DESCRIPTION_MAX) {
1619
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1977
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1620
1978
  `description must be between ${FORGET_DESCRIPTION_MIN} and ${FORGET_DESCRIPTION_MAX} characters`
1621
1979
  );
1622
1980
  }
1623
1981
  const mode = _nullishCoalesce(options.mode, () => ( "preview"));
1624
1982
  if (!FORGET_MODES.includes(mode)) {
1625
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
1983
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1626
1984
  `Invalid mode '${mode}'. Expected one of: ${FORGET_MODES.join(", ")}`
1627
1985
  );
1628
1986
  }
@@ -1637,7 +1995,7 @@ function buildForgetBody(options) {
1637
1995
  const conversationId = either(o2, "conversation_id", "conversationId");
1638
1996
  if (conversationId !== void 0 && conversationId !== null) {
1639
1997
  if (typeof conversationId !== "string" || [...conversationId].length < 1 || [...conversationId].length > 200) {
1640
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("conversation_id must be a string of 1 to 200 characters");
1998
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("conversation_id must be a string of 1 to 200 characters");
1641
1999
  }
1642
2000
  body["conversation_id"] = conversationId;
1643
2001
  }
@@ -1679,7 +2037,7 @@ function createMemoriesInterface(transport, onForgotten) {
1679
2037
  // /api/v1/memories/{memory_id} exists with other methods. Either would
1680
2038
  // otherwise read as "context not found" or a bare HTTP error.
1681
2039
  // InvalidInputError, with Python's message.
1682
- mapError: (status, error) => status === 404 || status === 405 ? new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2040
+ mapError: (status, error) => status === 404 || status === 405 ? new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1683
2041
  "This Synap server does not support file parts in memories.create. Upgrade the Synap server, or send text only.",
1684
2042
  { correlationId: error.correlationId, cause: error }
1685
2043
  ) : void 0
@@ -1688,7 +2046,7 @@ function createMemoriesInterface(transport, onForgotten) {
1688
2046
  async batch_create(options) {
1689
2047
  const docs = options.documents;
1690
2048
  if (!Array.isArray(docs) || docs.length === 0) {
1691
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("documents must be a non-empty array");
2049
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("documents must be a non-empty array");
1692
2050
  }
1693
2051
  const failFast = _nullishCoalesce(_nullishCoalesce(options.fail_fast, () => ( options.failFast)), () => ( false));
1694
2052
  return transport.request("memories_batch", {
@@ -1706,17 +2064,17 @@ function createMemoriesInterface(transport, onForgotten) {
1706
2064
  const customerId = _nullishCoalesce(options.customer_id, () => ( options.customerId));
1707
2065
  const scope = options.scope;
1708
2066
  if (scope !== void 0 && scope !== null && (typeof scope !== "object" || Array.isArray(scope) || !Object.values(scope).every((v) => typeof v === "string"))) {
1709
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("scope must be a flat dict of level key to id, both strings.");
2067
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("scope must be a flat dict of level key to id, both strings.");
1710
2068
  }
1711
- if (!userId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("user_id is required");
2069
+ if (!userId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_id is required");
1712
2070
  await transport.checkCustomerId(customerId, "memories.create_from_file");
1713
2071
  const filePath = _nullishCoalesce(options.file_path, () => ( options.filePath));
1714
2072
  const sources = [filePath, options.file, options.text].filter((v) => v !== void 0);
1715
2073
  if (sources.length === 0) {
1716
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("One of file_path, file, or text must be provided.");
2074
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("One of file_path, file, or text must be provided.");
1717
2075
  }
1718
2076
  if (sources.length > 1) {
1719
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2077
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1720
2078
  "Provide exactly one of file_path, file, or text, not several."
1721
2079
  );
1722
2080
  }
@@ -1752,13 +2110,13 @@ function createMemoriesInterface(transport, onForgotten) {
1752
2110
  });
1753
2111
  },
1754
2112
  async get(memoryId) {
1755
- if (!memoryId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("memory_id is required");
2113
+ if (!memoryId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("memory_id is required");
1756
2114
  return transport.request("memories_get", { pathParams: { memory_id: memoryId } });
1757
2115
  },
1758
2116
  async update(options) {
1759
2117
  const memoryId = _nullishCoalesce(options.memory_id, () => ( options.memoryId));
1760
- if (!memoryId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("memory_id is required");
1761
- if (!options.document) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("document is required");
2118
+ if (!memoryId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("memory_id is required");
2119
+ if (!options.document) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("document is required");
1762
2120
  const body = {
1763
2121
  document: options.document,
1764
2122
  merge_strategy: _nullishCoalesce(_nullishCoalesce(options.merge_strategy, () => ( options.mergeStrategy)), () => ( "smart-merge"))
@@ -1773,7 +2131,7 @@ function createMemoriesInterface(transport, onForgotten) {
1773
2131
  },
1774
2132
  async delete(memoryId) {
1775
2133
  if (!memoryId) {
1776
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2134
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1777
2135
  "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."
1778
2136
  );
1779
2137
  }
@@ -1784,26 +2142,26 @@ function createMemoriesInterface(transport, onForgotten) {
1784
2142
  await transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.forget");
1785
2143
  const body = buildForgetBody(options);
1786
2144
  const result = await transport.request("memories_forget", { body });
1787
- const removed = !!_optionalChain([result, 'optionalAccess', _57 => _57.deleted_ids, 'optionalAccess', _58 => _58.length]) || _optionalChain([result, 'optionalAccess', _59 => _59.status]) === "deleted" || _optionalChain([result, 'optionalAccess', _60 => _60.status]) === "partial";
2145
+ const removed = !!_optionalChain([result, 'optionalAccess', _63 => _63.deleted_ids, 'optionalAccess', _64 => _64.length]) || _optionalChain([result, 'optionalAccess', _65 => _65.status]) === "deleted" || _optionalChain([result, 'optionalAccess', _66 => _66.status]) === "partial";
1788
2146
  if (removed && onForgotten) {
1789
2147
  try {
1790
2148
  onForgotten({
1791
2149
  userId: _nullishCoalesce(body["user_id"], () => ( null)),
1792
2150
  customerId: _nullishCoalesce(body["customer_id"], () => ( null))
1793
2151
  });
1794
- } catch (e7) {
2152
+ } catch (e10) {
1795
2153
  }
1796
2154
  }
1797
2155
  return result;
1798
2156
  },
1799
2157
  async status(ingestionId) {
1800
- if (!ingestionId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("ingestion_id is required");
2158
+ if (!ingestionId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("ingestion_id is required");
1801
2159
  return transport.request("memories_status", {
1802
2160
  pathParams: { ingestion_id: ingestionId }
1803
2161
  });
1804
2162
  },
1805
2163
  async wait_for_completion(ingestionId, options = {}) {
1806
- if (!ingestionId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("ingestion_id is required");
2164
+ if (!ingestionId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("ingestion_id is required");
1807
2165
  const timeoutMs = (_nullishCoalesce(_nullishCoalesce(options.timeout_seconds, () => ( options.timeoutSeconds)), () => ( 300))) * 1e3;
1808
2166
  const pollMs = (_nullishCoalesce(_nullishCoalesce(options.poll_interval_seconds, () => ( options.pollIntervalSeconds)), () => ( 2))) * 1e3;
1809
2167
  const deadline = Date.now() + timeoutMs;
@@ -1824,14 +2182,14 @@ function sleep2(ms, signal) {
1824
2182
  if (ms <= 0) return Promise.resolve();
1825
2183
  return new Promise((resolve, reject) => {
1826
2184
  const timer = setTimeout(() => {
1827
- _optionalChain([signal, 'optionalAccess', _61 => _61.removeEventListener, 'call', _62 => _62("abort", onAbort)]);
2185
+ _optionalChain([signal, 'optionalAccess', _67 => _67.removeEventListener, 'call', _68 => _68("abort", onAbort)]);
1828
2186
  resolve();
1829
2187
  }, ms);
1830
2188
  function onAbort() {
1831
2189
  clearTimeout(timer);
1832
- reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _63 => _63.reason]), () => ( new Error("Aborted"))));
2190
+ reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _69 => _69.reason]), () => ( new Error("Aborted"))));
1833
2191
  }
1834
- _optionalChain([signal, 'optionalAccess', _64 => _64.addEventListener, 'call', _65 => _65("abort", onAbort, { once: true })]);
2192
+ _optionalChain([signal, 'optionalAccess', _70 => _70.addEventListener, 'call', _71 => _71("abort", onAbort, { once: true })]);
1835
2193
  });
1836
2194
  }
1837
2195
 
@@ -1841,13 +2199,13 @@ 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
1841
2199
  function validateConversationId(conversationId) {
1842
2200
  if (conversationId === void 0 || conversationId === null || conversationId === "") return;
1843
2201
  if (typeof conversationId !== "string" || !UUID_RE.test(conversationId)) {
1844
- throw new (0, _chunk7IZHVYO2cjs.InvalidConversationIdError)(`Invalid conversation ID: ${String(conversationId)}`);
2202
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidConversationIdError)(`Invalid conversation ID: ${String(conversationId)}`);
1845
2203
  }
1846
2204
  }
1847
2205
  function validateInstanceId(instanceId) {
1848
2206
  if (instanceId === void 0 || instanceId === null || instanceId === "") return;
1849
2207
  if (typeof instanceId !== "string" || !INSTANCE_ID_RE.test(instanceId)) {
1850
- throw new (0, _chunk7IZHVYO2cjs.InvalidInstanceIdError)(`Invalid instance ID: ${String(instanceId)}`);
2208
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInstanceIdError)(`Invalid instance ID: ${String(instanceId)}`);
1851
2209
  }
1852
2210
  }
1853
2211
 
@@ -1897,23 +2255,23 @@ function buildRecordMessageBody(options, resolvedContent, field = "content") {
1897
2255
  const conversationId = either2(o2, "conversation_id", "conversationId");
1898
2256
  const userId = either2(o2, "user_id", "userId");
1899
2257
  const customerId = either2(o2, "customer_id", "customerId");
1900
- if (!conversationId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("conversation_id is required");
2258
+ if (!conversationId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("conversation_id is required");
1901
2259
  validateConversationId(conversationId);
1902
- if (!options.role) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("role is required");
2260
+ if (!options.role) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("role is required");
1903
2261
  if (!MESSAGE_ROLES.includes(options.role)) {
1904
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`Invalid role '${options.role}'. Must be 'user' or 'assistant'.`);
2262
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`Invalid role '${options.role}'. Must be 'user' or 'assistant'.`);
1905
2263
  }
1906
2264
  if (options.content === void 0 || options.content === null) {
1907
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("content is required");
2265
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("content is required");
1908
2266
  }
1909
- if (!userId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("user_id is required");
2267
+ if (!userId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_id is required");
1910
2268
  let content = options.content;
1911
2269
  if (resolvedContent !== void 0) {
1912
2270
  content = resolvedContent;
1913
2271
  } else {
1914
2272
  const n2 = normaliseContent(options.content, field);
1915
- if (_optionalChain([n2, 'optionalAccess', _66 => _66.kind]) === "parts") {
1916
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2273
+ if (_optionalChain([n2, 'optionalAccess', _72 => _72.kind]) === "parts") {
2274
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
1917
2275
  "content holds a FilePart, whose bytes have to be read first. Send it with conversation.record_message."
1918
2276
  );
1919
2277
  }
@@ -1940,10 +2298,10 @@ function buildIngestTranscriptBody(options) {
1940
2298
  const o2 = options;
1941
2299
  const conversationId = either2(o2, "conversation_id", "conversationId");
1942
2300
  const userId = either2(o2, "user_id", "userId");
1943
- if (!conversationId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("conversation_id is required");
1944
- if (!userId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("user_id is required");
2301
+ if (!conversationId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("conversation_id is required");
2302
+ if (!userId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_id is required");
1945
2303
  if (options.transcript === void 0 || options.transcript === null) {
1946
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("transcript is required");
2304
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("transcript is required");
1947
2305
  }
1948
2306
  const body = {
1949
2307
  conversation_id: conversationId,
@@ -1969,7 +2327,7 @@ function buildIngestTranscriptBody(options) {
1969
2327
  function buildCompactBody(options) {
1970
2328
  const o2 = options;
1971
2329
  const conversationId = either2(o2, "conversation_id", "conversationId");
1972
- if (!conversationId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("conversation_id is required");
2330
+ if (!conversationId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("conversation_id is required");
1973
2331
  validateConversationId(conversationId);
1974
2332
  const body = { conversation_id: conversationId, force: _nullishCoalesce(options.force, () => ( false)) };
1975
2333
  const strategy = _nullishCoalesce(options.strategy, () => ( either2(o2, "compaction_level", "compactionLevel")));
@@ -2023,7 +2381,7 @@ function storedBatchRows(bodies, result) {
2023
2381
  const r = _nullishCoalesce(result, () => ( {}));
2024
2382
  const results = Array.isArray(r["results"]) ? r["results"] : [];
2025
2383
  const errors = Array.isArray(r["errors"]) ? r["errors"] : [];
2026
- const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess', _67 => _67["index"]])));
2384
+ const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess', _73 => _73["index"]])));
2027
2385
  const stored = bodies.filter((_, index) => !failed.has(index));
2028
2386
  if (stored.length !== results.length) return [];
2029
2387
  const pairs = [];
@@ -2067,7 +2425,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2067
2425
  };
2068
2426
  const fetchImpl = ((url, init) => transport.fetchExternal(url, init));
2069
2427
  const validateMessage = (options, field = "content") => {
2070
- if (_optionalChain([normaliseContent, 'call', _68 => _68(options.content, field), 'optionalAccess', _69 => _69.kind]) === "parts") {
2428
+ if (_optionalChain([normaliseContent, 'call', _74 => _74(options.content, field), 'optionalAccess', _75 => _75.kind]) === "parts") {
2071
2429
  buildRecordMessageBody(options, "", field);
2072
2430
  } else {
2073
2431
  buildRecordMessageBody(options, void 0, field);
@@ -2075,7 +2433,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2075
2433
  };
2076
2434
  const prepareMessage = async (options, field = "content") => {
2077
2435
  const n2 = normaliseContent(options.content, field);
2078
- if (_optionalChain([n2, 'optionalAccess', _70 => _70.kind]) !== "parts") {
2436
+ if (_optionalChain([n2, 'optionalAccess', _76 => _76.kind]) !== "parts") {
2079
2437
  const body = buildRecordMessageBody(options, void 0, field);
2080
2438
  return { body, mirror: String(_nullishCoalesce(body["content"], () => ( ""))) };
2081
2439
  }
@@ -2085,7 +2443,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2085
2443
  };
2086
2444
  const convId = (v) => {
2087
2445
  const id = typeof v === "string" ? v : _nullishCoalesce(v.conversation_id, () => ( v.conversationId));
2088
- if (!id) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("conversation_id is required");
2446
+ if (!id) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("conversation_id is required");
2089
2447
  validateConversationId(id);
2090
2448
  return id;
2091
2449
  };
@@ -2121,7 +2479,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2121
2479
  },
2122
2480
  async record_messages_batch(messages) {
2123
2481
  if (!Array.isArray(messages) || messages.length === 0) {
2124
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("messages must be a non-empty array");
2482
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("messages must be a non-empty array");
2125
2483
  }
2126
2484
  for (const m of messages) {
2127
2485
  const mo = m;
@@ -2166,7 +2524,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2166
2524
  const raw = await transport.request("conversations_ingest", { body });
2167
2525
  const result = {
2168
2526
  ...raw,
2169
- warnings: Array.isArray(_optionalChain([raw, 'optionalAccess', _71 => _71.warnings])) ? raw.warnings.map(String) : []
2527
+ warnings: Array.isArray(_optionalChain([raw, 'optionalAccess', _77 => _77.warnings])) ? raw.warnings.map(String) : []
2170
2528
  };
2171
2529
  onWrite({
2172
2530
  userId: body["user_id"],
@@ -2191,7 +2549,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2191
2549
  const id = convId(options);
2192
2550
  const style = _nullishCoalesce(options.style, () => ( "structured"));
2193
2551
  if (!PROMPT_STYLES.includes(style)) {
2194
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2552
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
2195
2553
  `Invalid style '${style}'. Must be one of: ${PROMPT_STYLES.join(", ")}`
2196
2554
  );
2197
2555
  }
@@ -2200,7 +2558,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2200
2558
  if (!search) return response2;
2201
2559
  try {
2202
2560
  return await localShortTerm.historyExcerpts(id, response2, options.query);
2203
- } catch (e8) {
2561
+ } catch (e11) {
2204
2562
  return response2;
2205
2563
  }
2206
2564
  };
@@ -2210,8 +2568,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2210
2568
  pathParams: { conversation_id: id },
2211
2569
  query: { style }
2212
2570
  });
2213
- const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _72 => _72["context_for_prompt"]]), () => ( result)), () => ( {}));
2214
- _optionalChain([localShortTerm, 'access', _73 => _73.reseed, 'optionalCall', _74 => _74(id, response)]);
2571
+ const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _78 => _78["context_for_prompt"]]), () => ( result)), () => ( {}));
2572
+ _optionalChain([localShortTerm, 'access', _79 => _79.reseed, 'optionalCall', _80 => _80(id, response)]);
2215
2573
  return withHistory(response);
2216
2574
  },
2217
2575
  async compact(options) {
@@ -2251,8 +2609,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
2251
2609
  * Returns an idempotent unsubscribe thunk, matching Python.
2252
2610
  */
2253
2611
  subscribe_to_compaction_updates(conversationId, callback) {
2254
- if (!conversationId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("conversation_id is required");
2255
- if (typeof callback !== "function") throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("callback is required");
2612
+ if (!conversationId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("conversation_id is required");
2613
+ if (typeof callback !== "function") throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("callback is required");
2256
2614
  return subscribers.add(conversationId, callback);
2257
2615
  },
2258
2616
  /** Remove subscribers for one conversation, or all of them. Returns the count removed. */
@@ -2281,17 +2639,17 @@ function buildDeleteBody(options, instanceId) {
2281
2639
  const o2 = options;
2282
2640
  const scope = options.scope;
2283
2641
  if (scope !== null && typeof scope === "object") {
2284
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2642
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
2285
2643
  "scope must be one of: user, conversation, customer. A dict is not accepted here (the rung-path dict used by memories.create and fetch is a different parameter)."
2286
2644
  );
2287
2645
  }
2288
2646
  if (typeof scope !== "string" || !DATA_SCOPES.includes(scope)) {
2289
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2647
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
2290
2648
  `Invalid scope '${String(scope)}'. Expected one of: ${DATA_SCOPES.join(", ")}`
2291
2649
  );
2292
2650
  }
2293
2651
  const dryRun = _nullishCoalesce(either3(o2, "dry_run", "dryRun"), () => ( false));
2294
- if (typeof dryRun !== "boolean") throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("dry_run must be a boolean");
2652
+ if (typeof dryRun !== "boolean") throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("dry_run must be a boolean");
2295
2653
  const ids = {
2296
2654
  user_id: either3(o2, "user_id", "userId"),
2297
2655
  customer_id: either3(o2, "customer_id", "customerId"),
@@ -2299,23 +2657,23 @@ function buildDeleteBody(options, instanceId) {
2299
2657
  };
2300
2658
  for (const [name, value] of Object.entries(ids)) {
2301
2659
  if (value !== void 0 && value !== null && (typeof value !== "string" || value.trim() === "")) {
2302
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`${name} must not be empty`);
2660
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`${name} must not be empty`);
2303
2661
  }
2304
2662
  }
2305
2663
  const field = ID_FIELD[scope];
2306
2664
  const target = ids[field];
2307
2665
  if (target === void 0 || target === null) {
2308
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`${field} is required for scope='${scope}'`);
2666
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`${field} is required for scope='${scope}'`);
2309
2667
  }
2310
2668
  const confirm = _nullishCoalesce(options.confirm, () => ( null));
2311
2669
  if (!dryRun) {
2312
2670
  if (confirm === null || confirm === "") {
2313
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
2671
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
2314
2672
  `confirm is required unless dry_run=True: pass the ${field} being deleted as confirm`
2315
2673
  );
2316
2674
  }
2317
2675
  if (confirm !== target) {
2318
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`confirm must equal the ${field} being deleted`);
2676
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`confirm must equal the ${field} being deleted`);
2319
2677
  }
2320
2678
  }
2321
2679
  return {
@@ -2376,14 +2734,14 @@ function createDataInterface(transport, onDeleted) {
2376
2734
  customerId: _nullishCoalesce(body["customer_id"], () => ( null)),
2377
2735
  conversationId: _nullishCoalesce(body["conversation_id"], () => ( null))
2378
2736
  });
2379
- } catch (e9) {
2737
+ } catch (e12) {
2380
2738
  }
2381
2739
  }
2382
2740
  return final;
2383
2741
  },
2384
2742
  async status(deletionId) {
2385
2743
  if (typeof deletionId !== "string" || deletionId.trim() === "") {
2386
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("deletion_id is required");
2744
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("deletion_id is required");
2387
2745
  }
2388
2746
  return normalise(
2389
2747
  await transport.request("data_delete_status", {
@@ -2400,7 +2758,7 @@ function createUserNamespace(transport, hooks = {}) {
2400
2758
  return {
2401
2759
  async get_profile(options) {
2402
2760
  const userId = typeof options === "string" ? options : _nullishCoalesce(options.user_id, () => ( options.userId));
2403
- if (!userId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("user_id is required");
2761
+ if (!userId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_id is required");
2404
2762
  const customerId = typeof options === "string" ? void 0 : _nullishCoalesce(options.customer_id, () => ( options.customerId));
2405
2763
  return transport.request("user_profile", {
2406
2764
  pathParams: { user_id: userId },
@@ -2449,22 +2807,84 @@ function createCreditsNamespace(transport) {
2449
2807
  });
2450
2808
  },
2451
2809
  async redeem(code) {
2452
- if (!code) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("code is required");
2810
+ if (!code) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("code is required");
2453
2811
  return transport.request("credits_redeem", { body: { code } });
2454
2812
  }
2455
2813
  };
2456
2814
  }
2457
2815
 
2816
+ // src/maca/interface.ts
2817
+ var MACA_FINAL_STATUSES = ["succeeded", "invalid", "failed"];
2818
+ var MACA_MAX_FILE_BYTES = 256 * 1024;
2819
+ function toJob(raw) {
2820
+ return {
2821
+ job_id: String(raw["job_id"]),
2822
+ status: String(raw["status"]),
2823
+ message: typeof raw["message"] === "string" ? raw["message"] : "",
2824
+ created_at: typeof raw["created_at"] === "string" ? raw["created_at"] : null,
2825
+ updated_at: typeof raw["updated_at"] === "string" ? raw["updated_at"] : null,
2826
+ removed_fields: Array.isArray(raw["removed_fields"]) ? raw["removed_fields"] : [],
2827
+ problems: Array.isArray(raw["problems"]) ? raw["problems"] : [],
2828
+ config_file: typeof raw["config_file"] === "string" ? raw["config_file"] : null,
2829
+ yaml: typeof raw["yaml"] === "string" ? raw["yaml"] : null
2830
+ };
2831
+ }
2832
+ function createMacaNamespace(transport) {
2833
+ const namespace = {
2834
+ async generate(options) {
2835
+ const filePath = _nullishCoalesce(options.file_path, () => ( options.filePath));
2836
+ const relationship = _nullishCoalesce(options.user_relationship, () => ( options.userRelationship));
2837
+ if (relationship !== "b2c" && relationship !== "b2b") {
2838
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_relationship must be 'b2c' or 'b2b'");
2839
+ }
2840
+ if (typeof filePath !== "string" || !filePath) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("file_path is required");
2841
+ const { readFile, stat } = await Promise.resolve().then(() => _interopRequireWildcard(require("fs/promises")));
2842
+ const { basename } = await Promise.resolve().then(() => _interopRequireWildcard(require("path")));
2843
+ let size;
2844
+ try {
2845
+ size = (await stat(filePath)).size;
2846
+ } catch (e13) {
2847
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`file_path does not point to a readable file: ${filePath}`);
2848
+ }
2849
+ if (size === 0) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("The use-case file is empty");
2850
+ if (size > MACA_MAX_FILE_BYTES) {
2851
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`The use-case file is larger than ${MACA_MAX_FILE_BYTES / 1024} KB`);
2852
+ }
2853
+ const bytes = await readFile(filePath);
2854
+ const form = new FormData();
2855
+ form.set("user_relationship", relationship);
2856
+ form.set("file", new Blob([bytes]), basename(filePath));
2857
+ return toJob(await transport.request("maca_generate", { body: form, rawBody: true }));
2858
+ },
2859
+ async get_job(jobId) {
2860
+ if (!jobId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("job_id is required");
2861
+ return toJob(await transport.request("maca_job", { pathParams: { job_id: jobId } }));
2862
+ },
2863
+ async wait_for_completion(jobId, options = {}) {
2864
+ const timeout = (_nullishCoalesce(_nullishCoalesce(options.timeout_seconds, () => ( options.timeoutSeconds)), () => ( 3e3))) * 1e3;
2865
+ const interval = (_nullishCoalesce(_nullishCoalesce(options.poll_interval_seconds, () => ( options.pollIntervalSeconds)), () => ( 15))) * 1e3;
2866
+ const start = Date.now();
2867
+ while (Date.now() - start < timeout) {
2868
+ const job = await namespace.get_job(jobId);
2869
+ if (MACA_FINAL_STATUSES.includes(job.status)) return job;
2870
+ await new Promise((resolve) => setTimeout(resolve, interval));
2871
+ }
2872
+ throw new Error(`MACA job ${jobId} did not finish within ${timeout / 1e3}s`);
2873
+ }
2874
+ };
2875
+ return namespace;
2876
+ }
2877
+
2458
2878
  // src/cache/interface.ts
2459
2879
  function createCacheNamespace(cache) {
2460
2880
  return {
2461
2881
  clear: () => cache.clear(),
2462
2882
  clear_user: (userId) => {
2463
- if (!userId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("user_id is required");
2883
+ if (!userId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_id is required");
2464
2884
  cache.dropEntity(userId);
2465
2885
  },
2466
2886
  clear_customer: (customerId) => {
2467
- if (!customerId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("customer_id is required");
2887
+ if (!customerId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("customer_id is required");
2468
2888
  cache.dropEntity(customerId);
2469
2889
  },
2470
2890
  stats: () => ({ bundles: cache.size, items: cache.itemCount })
@@ -2520,10 +2940,10 @@ function jsonOrText(value) {
2520
2940
  (_k, v) => typeof v === "bigint" ? String(v) : v
2521
2941
  );
2522
2942
  return out === void 0 ? String(value) : out;
2523
- } catch (e10) {
2943
+ } catch (e14) {
2524
2944
  try {
2525
2945
  return String(value);
2526
- } catch (e11) {
2946
+ } catch (e15) {
2527
2947
  return "";
2528
2948
  }
2529
2949
  }
@@ -2546,8 +2966,8 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2546
2966
  let onConversationState = null;
2547
2967
  const internals = {
2548
2968
  onCompactionUpdate(conversationId, bundle) {
2549
- _optionalChain([applyCompaction, 'optionalCall', _75 => _75(bundle)]);
2550
- _optionalChain([dispatchCompaction, 'optionalCall', _76 => _76(conversationId, bundle)]);
2969
+ _optionalChain([applyCompaction, 'optionalCall', _81 => _81(bundle)]);
2970
+ _optionalChain([dispatchCompaction, 'optionalCall', _82 => _82(conversationId, bundle)]);
2551
2971
  },
2552
2972
  setCompactionApplier(apply) {
2553
2973
  applyCompaction = apply;
@@ -2562,10 +2982,10 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2562
2982
  onConversationState = handle;
2563
2983
  },
2564
2984
  sendContextUsed(event) {
2565
- _optionalChain([client, 'optionalAccess', _77 => _77.sendContextUsed, 'call', _78 => _78(event)]);
2985
+ _optionalChain([client, 'optionalAccess', _83 => _83.sendContextUsed, 'call', _84 => _84(event)]);
2566
2986
  },
2567
2987
  sendContextAssembled(event) {
2568
- _optionalChain([client, 'optionalAccess', _79 => _79.sendContextAssembled, 'call', _80 => _80(event)]);
2988
+ _optionalChain([client, 'optionalAccess', _85 => _85.sendContextAssembled, 'call', _86 => _86(event)]);
2569
2989
  },
2570
2990
  setCompactionDispatcher(dispatch) {
2571
2991
  dispatchCompaction = dispatch;
@@ -2577,7 +2997,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2577
2997
  function ensureSession(conversationId, userId, customerId) {
2578
2998
  if (!conversationId || !userId || client === null) return;
2579
2999
  if (openSessions.has(conversationId)) return;
2580
- const sessionId = _chunk7IZHVYO2cjs.newCorrelationId.call(void 0, );
3000
+ const sessionId = _chunkJPDEKN5Mcjs.newCorrelationId.call(void 0, );
2581
3001
  try {
2582
3002
  client.sendSessionControl({
2583
3003
  action: "start",
@@ -2587,7 +3007,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2587
3007
  ...customerId ? { customer_id: customerId } : {}
2588
3008
  });
2589
3009
  openSessions.set(conversationId, sessionId);
2590
- } catch (e12) {
3010
+ } catch (e16) {
2591
3011
  }
2592
3012
  }
2593
3013
  let tail = Promise.resolve();
@@ -2597,7 +3017,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2597
3017
  send(sync);
2598
3018
  return Promise.resolve();
2599
3019
  }
2600
- _optionalChain([prepared, 'optionalAccess', _81 => _81.catch, 'call', _82 => _82(() => {
3020
+ _optionalChain([prepared, 'optionalAccess', _87 => _87.catch, 'call', _88 => _88(() => {
2601
3021
  })]);
2602
3022
  queued += 1;
2603
3023
  const run = tail.then(async () => {
@@ -2611,15 +3031,15 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2611
3031
  }
2612
3032
  const namespace = {
2613
3033
  async listen(options = {}) {
2614
- if (listenBlockedBy !== null) throw new (0, _chunk7IZHVYO2cjs.SynapPermanentError)(listenBlockedBy);
3034
+ if (listenBlockedBy !== null) throw new (0, _chunkJPDEKN5Mcjs.SynapPermanentError)(listenBlockedBy);
2615
3035
  if (client !== null) {
2616
- throw new (0, _chunk7IZHVYO2cjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
3036
+ throw new (0, _chunkJPDEKN5Mcjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
2617
3037
  }
2618
3038
  try {
2619
- _optionalChain([onListen, 'optionalCall', _83 => _83()]);
2620
- } catch (e13) {
3039
+ _optionalChain([onListen, 'optionalCall', _89 => _89()]);
3040
+ } catch (e17) {
2621
3041
  }
2622
- const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-TDHTS7F4.cjs")));
3042
+ const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-H2ES74FF.cjs")));
2623
3043
  const onContext = _nullishCoalesce(options.on_context, () => ( options.onContext));
2624
3044
  const onDisconnect = _nullishCoalesce(options.on_disconnect, () => ( options.onDisconnect));
2625
3045
  const onReconnect = _nullishCoalesce(options.on_reconnect, () => ( options.onReconnect));
@@ -2634,17 +3054,17 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2634
3054
  internals.onCompactionUpdate(conversationId, bundle);
2635
3055
  },
2636
3056
  onConversationState: (conversationId, messageCount) => {
2637
- _optionalChain([onConversationState, 'optionalCall', _84 => _84(conversationId, messageCount)]);
3057
+ _optionalChain([onConversationState, 'optionalCall', _90 => _90(conversationId, messageCount)]);
2638
3058
  },
2639
3059
  onStateChange: (state) => {
2640
3060
  if (state !== "connected") openSessions.clear();
2641
3061
  if (state === "reconnecting") {
2642
3062
  reconnectAttempts += 1;
2643
- _optionalChain([onReconnect, 'optionalCall', _85 => _85(reconnectAttempts)]);
3063
+ _optionalChain([onReconnect, 'optionalCall', _91 => _91(reconnectAttempts)]);
2644
3064
  } else if (state === "disconnected") {
2645
- const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _86 => _86.lastError]), () => ( null));
3065
+ const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _92 => _92.lastError]), () => ( null));
2646
3066
  const reason = stopped === null ? "stream disconnected" : `credit_stop:${_nullishCoalesce(stopped.reason, () => ( "unknown"))}`;
2647
- _optionalChain([onDisconnect, 'optionalCall', _87 => _87(reason)]);
3067
+ _optionalChain([onDisconnect, 'optionalCall', _93 => _93(reason)]);
2648
3068
  }
2649
3069
  }
2650
3070
  });
@@ -2652,9 +3072,9 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2652
3072
  try {
2653
3073
  await created.connect();
2654
3074
  } catch (error) {
2655
- if (error instanceof _chunk7IZHVYO2cjs.SynapError) throw error;
2656
- throw new (0, _chunk7IZHVYO2cjs.SynapError)(
2657
- `Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _88 => _88.message]), () => ( String(error)))}`,
3075
+ if (error instanceof _chunkJPDEKN5Mcjs.SynapError) throw error;
3076
+ throw new (0, _chunkJPDEKN5Mcjs.SynapError)(
3077
+ `Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _94 => _94.message]), () => ( String(error)))}`,
2658
3078
  { cause: error }
2659
3079
  );
2660
3080
  }
@@ -2679,7 +3099,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2679
3099
  session_id: sessionId,
2680
3100
  conversation_id: conversationId
2681
3101
  });
2682
- } catch (e14) {
3102
+ } catch (e18) {
2683
3103
  }
2684
3104
  },
2685
3105
  async send_message(options) {
@@ -2689,19 +3109,19 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2689
3109
  "instance.send_message"
2690
3110
  );
2691
3111
  }
2692
- if (client === null) throw new (0, _chunk7IZHVYO2cjs.ListeningNotActiveError)("Listening is not active");
3112
+ if (client === null) throw new (0, _chunkJPDEKN5Mcjs.ListeningNotActiveError)("Listening is not active");
2693
3113
  const eventType = _nullishCoalesce(_nullishCoalesce(options.event_type, () => ( options.eventType)), () => ( "user_message"));
2694
3114
  if (!KNOWN_EVENT_TYPES.has(eventType)) {
2695
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
3115
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
2696
3116
  `unknown event_type '${eventType}'. Expected one of: ` + [...KNOWN_EVENT_TYPES].sort().join(", ")
2697
3117
  );
2698
3118
  }
2699
3119
  if (options.content === void 0 || options.content === null) {
2700
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("content is required");
3120
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("content is required");
2701
3121
  }
2702
3122
  const parts = normaliseContent(options.content, "content");
2703
3123
  const emit = ({ content, metadata }) => {
2704
- if (client === null) throw new (0, _chunk7IZHVYO2cjs.ListeningNotActiveError)("Listening is not active");
3124
+ if (client === null) throw new (0, _chunkJPDEKN5Mcjs.ListeningNotActiveError)("Listening is not active");
2705
3125
  const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
2706
3126
  ensureSession(
2707
3127
  conversationId,
@@ -2709,7 +3129,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2709
3129
  _nullishCoalesce(_nullishCoalesce(options.customer_id, () => ( options.customerId)), () => ( ""))
2710
3130
  );
2711
3131
  if (eventType === "user_message" || eventType === "assistant_message") {
2712
- _optionalChain([onTurn, 'optionalCall', _89 => _89({
3132
+ _optionalChain([onTurn, 'optionalCall', _95 => _95({
2713
3133
  conversationId,
2714
3134
  role: _nullishCoalesce(options.role, () => ( "user")),
2715
3135
  content
@@ -2741,14 +3161,14 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2741
3161
  })()
2742
3162
  });
2743
3163
  };
2744
- if (_optionalChain([parts, 'optionalAccess', _90 => _90.kind]) !== "parts") {
2745
- const content = _optionalChain([parts, 'optionalAccess', _91 => _91.kind]) === "text" ? parts.text : options.content;
3164
+ if (_optionalChain([parts, 'optionalAccess', _96 => _96.kind]) !== "parts") {
3165
+ const content = _optionalChain([parts, 'optionalAccess', _97 => _97.kind]) === "text" ? parts.text : options.content;
2746
3166
  return inOrder(null, emit, { content, metadata: _nullishCoalesce(options.metadata, () => ( {})) });
2747
3167
  }
2748
3168
  const prepared = (async () => {
2749
3169
  const inline = await toInlineParts(parts.parts, fetchUrl2);
2750
3170
  if (inline.rawBytes > MAX_STREAM_IMAGE_BYTES) {
2751
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
3171
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
2752
3172
  `The images in this event come to more than ${MAX_STREAM_IMAGE_BYTES} bytes, which is over what one streamed event can carry. Send them with memories.create or conversation.record_message instead.`
2753
3173
  );
2754
3174
  }
@@ -2780,7 +3200,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2780
3200
  async record_tool_result(options) {
2781
3201
  const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
2782
3202
  if (conversationId) {
2783
- _optionalChain([onToolResult, 'optionalCall', _92 => _92({ conversationId, result: options.result, toolName: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")) })]);
3203
+ _optionalChain([onToolResult, 'optionalCall', _98 => _98({ conversationId, result: options.result, toolName: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")) })]);
2784
3204
  }
2785
3205
  await namespace.send_message({
2786
3206
  content: "",
@@ -2797,7 +3217,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2797
3217
  });
2798
3218
  },
2799
3219
  async record_thinking(options) {
2800
- if (client === null) throw new (0, _chunk7IZHVYO2cjs.ListeningNotActiveError)("Listening is not active");
3220
+ if (client === null) throw new (0, _chunkJPDEKN5Mcjs.ListeningNotActiveError)("Listening is not active");
2801
3221
  const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
2802
3222
  ensureSession(
2803
3223
  conversationId,
@@ -2805,7 +3225,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2805
3225
  _nullishCoalesce(_nullishCoalesce(options.customer_id, () => ( options.customerId)), () => ( ""))
2806
3226
  );
2807
3227
  return inOrder(null, () => {
2808
- if (client === null) throw new (0, _chunk7IZHVYO2cjs.ListeningNotActiveError)("Listening is not active");
3228
+ if (client === null) throw new (0, _chunkJPDEKN5Mcjs.ListeningNotActiveError)("Listening is not active");
2809
3229
  client.sendConversationEvent({
2810
3230
  // Python emits reasoning as an `agent_thinking` conversation event.
2811
3231
  event_type: "agent_thinking",
@@ -2835,7 +3255,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
2835
3255
  }
2836
3256
 
2837
3257
  // src/version.ts
2838
- var SDK_VERSION = "0.6.8";
3258
+ var SDK_VERSION = "0.7.1";
2839
3259
 
2840
3260
  // src/registry.ts
2841
3261
  var instances = /* @__PURE__ */ new Map();
@@ -2975,7 +3395,7 @@ var ShortTermStore = class {
2975
3395
  if (this.#archive !== null) {
2976
3396
  try {
2977
3397
  this.#archive.add(conversationId, role, content, stamp, { messageId: _nullishCoalesce(confirmation.messageId, () => ( null)) });
2978
- } catch (e15) {
3398
+ } catch (e19) {
2979
3399
  }
2980
3400
  }
2981
3401
  const entry = _nullishCoalesce(this.#entries.get(conversationId), () => ( this.#blank(conversationId)));
@@ -3182,13 +3602,13 @@ function bytesOf(text) {
3182
3602
  }
3183
3603
  var TurnStore = (_class3 = class {
3184
3604
 
3185
- __init6() {this.onDisk = false}
3605
+ __init7() {this.onDisk = false}
3186
3606
  #now;
3187
3607
  #seq = 0;
3188
3608
  #writes = 0;
3189
3609
  #conversations = /* @__PURE__ */ new Map();
3190
3610
  #vectors = /* @__PURE__ */ new Map();
3191
- constructor(options = {}) {;_class3.prototype.__init6.call(this);
3611
+ constructor(options = {}) {;_class3.prototype.__init7.call(this);
3192
3612
  this.limits = _nullishCoalesce(options.limits, () => ( { ..._chunkBYUGILQIcjs.HISTORY_SEARCH.store_limits }));
3193
3613
  this.#now = _nullishCoalesce(options.now, () => ( (() => Date.now() / 1e3)));
3194
3614
  }
@@ -3303,7 +3723,7 @@ var TurnStore = (_class3 = class {
3303
3723
  }
3304
3724
  /** Turns the server also holds: archived tool results are local only. Python: `count`. */
3305
3725
  count(conversationId) {
3306
- return (_nullishCoalesce(_optionalChain([this, 'access', _93 => _93.#conversations, 'access', _94 => _94.get, 'call', _95 => _95(conversationId), 'optionalAccess', _96 => _96.turns]), () => ( []))).filter((t) => t.role !== "tool").length;
3726
+ return (_nullishCoalesce(_optionalChain([this, 'access', _99 => _99.#conversations, 'access', _100 => _100.get, 'call', _101 => _101(conversationId), 'optionalAccess', _102 => _102.turns]), () => ( []))).filter((t) => t.role !== "tool").length;
3307
3727
  }
3308
3728
  sizeBytes() {
3309
3729
  let n2 = 0;
@@ -3482,7 +3902,7 @@ function askedKinds(query) {
3482
3902
  }
3483
3903
  function asksHowItStarted(query) {
3484
3904
  const spec = _chunkBYUGILQIcjs.HISTORY_SEARCH.early_query;
3485
- if (!_optionalChain([spec, 'optionalAccess', _97 => _97.pattern])) return false;
3905
+ if (!_optionalChain([spec, 'optionalAccess', _103 => _103.pattern])) return false;
3486
3906
  return new RegExp(spec.pattern, (_nullishCoalesce(spec.flags, () => ( ""))).includes("i") ? "i" : "").test(_nullishCoalesce(query, () => ( "")));
3487
3907
  }
3488
3908
  async function searchTurns(turns, query, options = {}) {
@@ -3750,7 +4170,7 @@ function overlayLocalRecentTurns(response, store, conversationId, configured) {
3750
4170
  compacted_at: orLocal("compacted_at", entry.compactedAt),
3751
4171
  conversation_id: conversationId
3752
4172
  };
3753
- } catch (e16) {
4173
+ } catch (e20) {
3754
4174
  }
3755
4175
  }
3756
4176
 
@@ -3763,7 +4183,7 @@ function stringify(value) {
3763
4183
  if (t === "string" || t === "number" || t === "boolean") return String(value);
3764
4184
  try {
3765
4185
  return _nullishCoalesce(JSON.stringify(value), () => ( ""));
3766
- } catch (e17) {
4186
+ } catch (e21) {
3767
4187
  return String(value);
3768
4188
  }
3769
4189
  }
@@ -4067,7 +4487,7 @@ async function tryServeFromCache(cache, scope, params, maxItems) {
4067
4487
  });
4068
4488
  if (hit === null) return { response: null, hit: null };
4069
4489
  return { response: buildAnticipationResponse(hit), hit };
4070
- } catch (e18) {
4490
+ } catch (e22) {
4071
4491
  return { response: null, hit: null };
4072
4492
  }
4073
4493
  }
@@ -4437,7 +4857,8 @@ function toolInputSchema(scope, options) {
4437
4857
  }
4438
4858
  var RESULT_COLLECTIONS = ["facts", "preferences", "episodes", "emotions", "temporal_events"];
4439
4859
  async function invokeScopeFetch(params) {
4440
- const { target, scope, userId, customerId, conversationId, callArgs } = params;
4860
+ const { target, scope, userId, customerId, conversationId, callArgs, scopePath } = params;
4861
+ const pathOpt = scopePath !== void 0 && scopePath !== null && Object.keys(scopePath).length > 0 ? { scope_path: scopePath } : {};
4441
4862
  const searchQuery = callArgs["search_query"];
4442
4863
  const rawMax = callArgs["max_results"];
4443
4864
  const maxResults = typeof rawMax === "number" && rawMax !== 0 ? Math.trunc(rawMax) : 10;
@@ -4450,7 +4871,8 @@ async function invokeScopeFetch(params) {
4450
4871
  max_results: maxResults,
4451
4872
  types,
4452
4873
  mode,
4453
- precision_level: precisionLevel
4874
+ precision_level: precisionLevel,
4875
+ ...pathOpt
4454
4876
  };
4455
4877
  if (scope === "unified") {
4456
4878
  const response2 = await target.fetch({
@@ -4505,7 +4927,7 @@ function buildTool(target, options = {}, onWarning = () => {
4505
4927
  const scope = String(_nullishCoalesce(options.scope, () => ( "user"))).toLowerCase();
4506
4928
  if (!VALID_SCOPES.includes(scope)) {
4507
4929
  const sorted = [...VALID_SCOPES].sort();
4508
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(
4930
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
4509
4931
  `scope must be one of ['${sorted.join("', '")}'], got '${String(options.scope)}'`
4510
4932
  );
4511
4933
  }
@@ -4513,10 +4935,10 @@ function buildTool(target, options = {}, onWarning = () => {
4513
4935
  const customerId = _nullishCoalesce(options.customer_id, () => ( options.customerId));
4514
4936
  const conversationId = _nullishCoalesce(options.conversation_id, () => ( options.conversationId));
4515
4937
  if (scope === "user" && (userId === void 0 || userId === "")) {
4516
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("scope='user' requires user_id");
4938
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("scope='user' requires user_id");
4517
4939
  }
4518
4940
  if (scope === "customer" && (customerId === void 0 || customerId === "")) {
4519
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("scope='customer' requires customer_id");
4941
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("scope='customer' requires customer_id");
4520
4942
  }
4521
4943
  if (scope === "conversation" && (userId === void 0 || userId === "")) {
4522
4944
  onWarning(
@@ -4525,12 +4947,20 @@ function buildTool(target, options = {}, onWarning = () => {
4525
4947
  }
4526
4948
  const style = String(_nullishCoalesce(options.style, () => ( "openai")));
4527
4949
  if (style !== "openai" && style !== "anthropic") {
4528
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)(`style must be 'openai' or 'anthropic', got '${style}'`);
4950
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`style must be 'openai' or 'anthropic', got '${style}'`);
4529
4951
  }
4530
4952
  const toolName = _nullishCoalesce(options.name, () => ( `synap_fetch_${scope}_context`));
4531
4953
  const toolDesc = _nullishCoalesce(options.description, () => ( defaultToolDescription(scope)));
4532
4954
  const schema = toolInputSchema(scope, { hasConversationId: conversationId !== void 0 });
4533
- const handler = (callArgs = {}) => invokeScopeFetch({ target, scope, userId, customerId, conversationId, callArgs });
4955
+ const handler = (callArgs = {}) => invokeScopeFetch({
4956
+ target,
4957
+ scope,
4958
+ userId,
4959
+ customerId,
4960
+ conversationId,
4961
+ callArgs,
4962
+ scopePath: options.scope_path
4963
+ });
4534
4964
  if (style === "openai") {
4535
4965
  return {
4536
4966
  type: "function",
@@ -4567,6 +4997,7 @@ var SynapClient = (_class4 = class _SynapClient {
4567
4997
 
4568
4998
 
4569
4999
 
5000
+
4570
5001
  #closed = false;
4571
5002
  #initialized = false;
4572
5003
  #identity;
@@ -4620,10 +5051,14 @@ var SynapClient = (_class4 = class _SynapClient {
4620
5051
  ...options.retryPolicy !== void 0 ? { retryPolicy: options.retryPolicy } : {},
4621
5052
  ...options.keepAlive !== void 0 ? { keepAlive: options.keepAlive } : {},
4622
5053
  ...options.fetchImpl !== void 0 ? { fetchImpl: options.fetchImpl } : {},
5054
+ ...options._clock !== void 0 ? { clock: options._clock } : {},
4623
5055
  userAgent: `@maximem/synap-js-sdk/${SDK_VERSION}`
4624
5056
  });
4625
5057
  if (options.heartbeat) this.#transport.startHeartbeat();
4626
5058
  this.#transport.identityResolver = () => this.#resolveIdentity();
5059
+ this.#transport.onInvalidInput = (_error, carriedScopePath) => {
5060
+ if (carriedScopePath) this.#transport.invalidateScopeLadder();
5061
+ };
4627
5062
  this.#anticipationCache = new (0, _chunkBYUGILQIcjs.AnticipationCache)();
4628
5063
  this.#fetchHooks = {
4629
5064
  beforeFetch: async (scope, options2) => {
@@ -4690,7 +5125,7 @@ var SynapClient = (_class4 = class _SynapClient {
4690
5125
  ...customerId !== void 0 ? { customer_id: customerId } : {}
4691
5126
  });
4692
5127
  return profileContext(profile);
4693
- } catch (e19) {
5128
+ } catch (e23) {
4694
5129
  return null;
4695
5130
  }
4696
5131
  }
@@ -4730,7 +5165,7 @@ var SynapClient = (_class4 = class _SynapClient {
4730
5165
  this.#localEncoder = _nullishCoalesce(_nullishCoalesce(options.history_search_encoder, () => ( options.historySearchEncoder)), () => ( null));
4731
5166
  const modelOption = options.history_search_model !== void 0 ? options.history_search_model : options.historySearchModel;
4732
5167
  this.#localModelName = modelOption === void 0 ? "auto" : modelOption;
4733
- if (_optionalChain([this, 'access', _98 => _98.#localEncoder, 'optionalAccess', _99 => _99.model]) === _chunkBYUGILQIcjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(this.#localEncoder);
5168
+ if (_optionalChain([this, 'access', _104 => _104.#localEncoder, 'optionalAccess', _105 => _105.model]) === _chunkBYUGILQIcjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(this.#localEncoder);
4734
5169
  this.#turns = new TurnCounter();
4735
5170
  this.conversation = createConversationNamespace(
4736
5171
  this.#transport,
@@ -4793,6 +5228,7 @@ var SynapClient = (_class4 = class _SynapClient {
4793
5228
  return cleared;
4794
5229
  });
4795
5230
  this.credits = createCreditsNamespace(this.#transport);
5231
+ this.maca = createMacaNamespace(this.#transport);
4796
5232
  this.cache = createCacheNamespace(this.#anticipationCache);
4797
5233
  this.instance = createInstanceNamespace(
4798
5234
  () => this.#transport.currentCredentials(),
@@ -4853,9 +5289,9 @@ var SynapClient = (_class4 = class _SynapClient {
4853
5289
  */
4854
5290
  async searchMemory(options) {
4855
5291
  const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
4856
- if (!userId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("user_id is required");
5292
+ if (!userId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_id is required");
4857
5293
  if (options.query === void 0 || options.query === null) {
4858
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("query is required");
5294
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("query is required");
4859
5295
  }
4860
5296
  const context = await fetchContext(this.#transport, "user", {
4861
5297
  user_id: userId,
@@ -4876,7 +5312,7 @@ var SynapClient = (_class4 = class _SynapClient {
4876
5312
  */
4877
5313
  async getMemories(options) {
4878
5314
  const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
4879
- if (!userId) throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("user_id is required");
5315
+ if (!userId) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("user_id is required");
4880
5316
  const context = await fetchContext(this.#transport, "user", {
4881
5317
  user_id: userId,
4882
5318
  ...pick3(options, "customer_id", "customerId") !== void 0 ? { customer_id: pick3(options, "customer_id", "customerId") } : {},
@@ -4923,6 +5359,25 @@ var SynapClient = (_class4 = class _SynapClient {
4923
5359
  this.#initialized = true;
4924
5360
  await this.#resolveIdentity();
4925
5361
  }
5362
+ /**
5363
+ * The account's scope ladder, or `null` when it cannot be known.
5364
+ *
5365
+ * Mirrors Python's `get_scope_ladder()`. Read lazily from
5366
+ * `GET /api/v1/auth/whoami` (even when the client and instance ids are
5367
+ * already known), cached for 300 s (`null` included), re-read on `refresh: true`. Concurrent
5368
+ * callers share one read. If a re-read
5369
+ * after expiry fails, the last known ladder is returned with a warning and
5370
+ * the next try waits 60 s. A failure on the very first read, or with
5371
+ * `refresh`, is thrown. With no `scope_ladder` block the default ladder is
5372
+ * inferred from `user_context_isolation` (`source: "inferred"`).
5373
+ *
5374
+ * const ladder = await client.get_scope_ladder();
5375
+ * const addr = ladder!.address(['acme', 'payments', 'dana']);
5376
+ * await client.fetch({ search_query: ['...'], ...addr.read_kwargs() });
5377
+ */
5378
+ async get_scope_ladder(options = {}) {
5379
+ return this.#transport.getScopeLadder(options.refresh === true, (m) => this.#warn(m));
5380
+ }
4926
5381
  /** Runs whoami at most once, however many calls arrive together. */
4927
5382
  #resolveIdentity() {
4928
5383
  this.#identity ??= this.#whoami().catch((error) => {
@@ -4951,8 +5406,8 @@ var SynapClient = (_class4 = class _SynapClient {
4951
5406
  }
4952
5407
  } catch (error) {
4953
5408
  if (this.#localMode) {
4954
- throw new (0, _chunk7IZHVYO2cjs.AuthenticationError)(
4955
- `Could not reach the Synap server at ${this.#transport.baseUrl}, or it did not identify itself: GET /api/v1/auth/whoami failed (${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _100 => _100.message]), () => ( String(error)))}).`,
5409
+ throw new (0, _chunkJPDEKN5Mcjs.AuthenticationError)(
5410
+ `Could not reach the Synap server at ${this.#transport.baseUrl}, or it did not identify itself: GET /api/v1/auth/whoami failed (${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _106 => _106.message]), () => ( String(error)))}).`,
4956
5411
  { cause: error }
4957
5412
  );
4958
5413
  }
@@ -4960,7 +5415,7 @@ var SynapClient = (_class4 = class _SynapClient {
4960
5415
  if (this.#localMode) {
4961
5416
  const known = this.#transport.currentCredentials();
4962
5417
  if (known.clientId === "" || known.instanceId === "") {
4963
- throw new (0, _chunk7IZHVYO2cjs.AuthenticationError)(
5418
+ throw new (0, _chunkJPDEKN5Mcjs.AuthenticationError)(
4964
5419
  `The Synap server at ${this.#transport.baseUrl} did not identify itself: GET /api/v1/auth/whoami returned no client_id or instance_id.`
4965
5420
  );
4966
5421
  }
@@ -4998,7 +5453,7 @@ var SynapClient = (_class4 = class _SynapClient {
4998
5453
  */
4999
5454
  configure(options = {}) {
5000
5455
  if (this.#initialized) {
5001
- throw new (0, _chunk7IZHVYO2cjs.InvalidInputError)("Cannot reconfigure after initialization");
5456
+ throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("Cannot reconfigure after initialization");
5002
5457
  }
5003
5458
  if (options.timeouts !== void 0) this.#transport.setTimeouts(options.timeouts);
5004
5459
  if (options.retryPolicy !== void 0 || options.retry_policy !== void 0) {
@@ -5049,7 +5504,8 @@ var SynapClient = (_class4 = class _SynapClient {
5049
5504
  context_mode: contextMode = "in-conversation",
5050
5505
  include_profile: includeProfile = true,
5051
5506
  last_n_conversations: lastNConversations = 1,
5052
- response_shape: responseShape = "by_type"
5507
+ response_shape: responseShape = "by_type",
5508
+ scope_path: scopePath
5053
5509
  } = options;
5054
5510
  await this.#transport.checkCustomerId(customerId, "sdk.fetch");
5055
5511
  validateConversationId(conversationId);
@@ -5066,8 +5522,24 @@ var SynapClient = (_class4 = class _SynapClient {
5066
5522
  // sits one indent deeper; spreading removes that whole class of miss.
5067
5523
  query_date: queryDate,
5068
5524
  max_results_per_query: maxResultsPerQuery,
5069
- response_shape: responseShape
5525
+ response_shape: responseShape,
5526
+ // Forwarded only when set (Python: `if scope_path`), so a call without
5527
+ // one hands every scope fetch exactly the options it always got.
5528
+ ...scopePath !== void 0 && scopePath !== null && Object.keys(scopePath).length > 0 ? { scope_path: scopePath } : {}
5070
5529
  };
5530
+ const { scope_path: _fullPath, ...sharedNoPath } = shared;
5531
+ void _fullPath;
5532
+ let customerPath;
5533
+ if (scopePath && Object.keys(scopePath).length > 0 && customerId !== void 0 && customerId !== null && customerId !== "" && wants("customer")) {
5534
+ let ladder = null;
5535
+ try {
5536
+ ladder = await this.get_scope_ladder();
5537
+ } catch (e) {
5538
+ this.#warn(`Could not read the scope ladder (${e instanceof Error ? e.message : String(e)}); cutting the customer scope's path at the reserved key 'user'.`);
5539
+ }
5540
+ customerPath = pathAboveIdentity(scopePath, ladder);
5541
+ }
5542
+ const customerShared = customerPath ? { ...sharedNoPath, scope_path: customerPath } : sharedNoPath;
5071
5543
  const labels = [];
5072
5544
  const tasks = [];
5073
5545
  const present = (v) => v !== void 0 && v !== null && v !== "";
@@ -5099,14 +5571,14 @@ var SynapClient = (_class4 = class _SynapClient {
5099
5571
  tasks.push(this.customer.context.fetch({
5100
5572
  customer_id: customerId,
5101
5573
  conversation_id: conversationId,
5102
- ...shared
5574
+ ...customerShared
5103
5575
  }));
5104
5576
  }
5105
5577
  if (scopes !== void 0 && scopes.includes("client")) {
5106
5578
  labels.push("client");
5107
5579
  tasks.push(this.client.context.fetch({
5108
5580
  conversation_id: conversationId,
5109
- ...shared
5581
+ ...sharedNoPath
5110
5582
  }));
5111
5583
  }
5112
5584
  if (tasks.length === 0 && !(conversationState && includeConversationContext)) {
@@ -5121,7 +5593,7 @@ var SynapClient = (_class4 = class _SynapClient {
5121
5593
  successful.push([label, result.value]);
5122
5594
  continue;
5123
5595
  }
5124
- if (result.reason instanceof _chunk7IZHVYO2cjs.InvalidInputError) throw result.reason;
5596
+ if (result.reason instanceof _chunkJPDEKN5Mcjs.InvalidInputError) throw result.reason;
5125
5597
  this.#warn(`Scope '${label}' fetch failed in unified fetch (non-fatal): ${String(result.reason)}`);
5126
5598
  }
5127
5599
  const merged = mergeScopeResults(successful);
@@ -5136,7 +5608,7 @@ var SynapClient = (_class4 = class _SynapClient {
5136
5608
  if (conversationState && !merged.scopes_queried.includes("conversation")) {
5137
5609
  merged.scopes_queried.unshift("conversation");
5138
5610
  }
5139
- } catch (e20) {
5611
+ } catch (e24) {
5140
5612
  }
5141
5613
  }
5142
5614
  merged.formatted_context = formatForPrompt(merged, {
@@ -5188,7 +5660,7 @@ var SynapClient = (_class4 = class _SynapClient {
5188
5660
  // not carry the caller's words.
5189
5661
  query_count: distinctQueryCount(_nullishCoalesce(options["search_query"], () => ( options["searchQuery"])))
5190
5662
  });
5191
- } catch (e21) {
5663
+ } catch (e25) {
5192
5664
  }
5193
5665
  }
5194
5666
  /**
@@ -5203,7 +5675,7 @@ var SynapClient = (_class4 = class _SynapClient {
5203
5675
  if (!this.instance.is_listening) return;
5204
5676
  this.instance._internal.sendContextAssembled({
5205
5677
  ...buildAssembledEvent({
5206
- correlationId: _chunk7IZHVYO2cjs.newCorrelationId.call(void 0, ),
5678
+ correlationId: _chunkJPDEKN5Mcjs.newCorrelationId.call(void 0, ),
5207
5679
  response,
5208
5680
  conversationId: _nullishCoalesce(options["conversation_id"], () => ( options["conversationId"])),
5209
5681
  userId: _nullishCoalesce(options["user_id"], () => ( options["userId"])),
@@ -5213,7 +5685,7 @@ var SynapClient = (_class4 = class _SynapClient {
5213
5685
  }),
5214
5686
  scope
5215
5687
  });
5216
- } catch (e22) {
5688
+ } catch (e26) {
5217
5689
  }
5218
5690
  }
5219
5691
  /**
@@ -5274,14 +5746,14 @@ var SynapClient = (_class4 = class _SynapClient {
5274
5746
  }))
5275
5747
  );
5276
5748
  const entry = this.#shortTerm.get(conversationId);
5277
- const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess', _101 => _101.serverMessageCount]), () => ( 0))) || 0);
5749
+ const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess', _107 => _107.serverMessageCount]), () => ( 0))) || 0);
5278
5750
  this.#maybeBackfillTurns(conversationId, total);
5279
5751
  if (!r["context_block"]) return response;
5280
5752
  const turns = store.turns(conversationId);
5281
5753
  let q = query;
5282
5754
  if (!q) {
5283
5755
  const latest = [...recent].reverse().find((m) => m["role"] === "user");
5284
- q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access', _102 => _102.reverse, 'call', _103 => _103(), 'access', _104 => _104.find, 'call', _105 => _105((t) => t.role === "user"), 'optionalAccess', _106 => _106.content]), () => ( ""));
5756
+ q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access', _108 => _108.reverse, 'call', _109 => _109(), 'access', _110 => _110.find, 'call', _111 => _111((t) => t.role === "user"), 'optionalAccess', _112 => _112.content]), () => ( ""));
5285
5757
  }
5286
5758
  if (!q) return response;
5287
5759
  const exclude = /* @__PURE__ */ new Set();
@@ -5315,7 +5787,7 @@ var SynapClient = (_class4 = class _SynapClient {
5315
5787
  toolResultText(result, _nullishCoalesce(options.tool_name, () => ( options.toolName))),
5316
5788
  _nullishCoalesce(options.timestamp, () => ( (/* @__PURE__ */ new Date()).toISOString()))
5317
5789
  );
5318
- } catch (e23) {
5790
+ } catch (e27) {
5319
5791
  }
5320
5792
  }
5321
5793
  static __initStatic() {this.BACKFILL_COOLDOWN_MS = 6e4}
@@ -5425,13 +5897,13 @@ function pick3(o2, snake, camel) {
5425
5897
  function resolveBaseUrl(options) {
5426
5898
  const explicit = _nullishCoalesce(options.baseUrl, () => ( options.api_base_url));
5427
5899
  if (explicit !== void 0) return explicit;
5428
- const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()]);
5900
+ const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()]);
5429
5901
  return fromEnv !== void 0 && fromEnv !== "" ? fromEnv : void 0;
5430
5902
  }
5431
5903
  function resolveCredentials(options, localMode) {
5432
5904
  const apiKey = options.apiKey || _chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_API_KEY");
5433
5905
  if (!apiKey && !localMode) {
5434
- throw new (0, _chunk7IZHVYO2cjs.AuthenticationError)(
5906
+ throw new (0, _chunkJPDEKN5Mcjs.AuthenticationError)(
5435
5907
  "No Synap API key found. Set SYNAP_API_KEY in your environment, or pass apiKey to the SynapClient constructor."
5436
5908
  );
5437
5909
  }
@@ -5506,5 +5978,8 @@ function resolveCredentials(options, localMode) {
5506
5978
 
5507
5979
 
5508
5980
 
5509
- exports.ANY_SCOPE = _chunkBYUGILQIcjs.ANY_SCOPE; exports.AgentUnavailableError = _chunk7IZHVYO2cjs.AgentUnavailableError; exports.AnticipationCache = _chunkBYUGILQIcjs.AnticipationCache; exports.AuthenticationError = _chunk7IZHVYO2cjs.AuthenticationError; exports.BM25 = _chunkBYUGILQIcjs.BM25; exports.COMPACTION_LEVELS = COMPACTION_LEVELS; exports.CONTRACT = _chunkBYUGILQIcjs.CONTRACT; exports.ConflictError = _chunk7IZHVYO2cjs.ConflictError; exports.ConnectionError = _chunk7IZHVYO2cjs.ConnectionError; exports.ContextNotFoundError = _chunk7IZHVYO2cjs.ContextNotFoundError; exports.CustomerIdNotAcceptedError = _chunk7IZHVYO2cjs.CustomerIdNotAcceptedError; exports.DATA_SCOPES = DATA_SCOPES; 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.EXCERPT_CATEGORY = EXCERPT_CATEGORY; exports.FORGET_MODES = FORGET_MODES; exports.HttpTransport = HttpTransport; exports.INGEST_MODES = INGEST_MODES; exports.ITEM_COLLECTIONS = ITEM_COLLECTIONS; exports.InstanceBuildFailedError = _chunk7IZHVYO2cjs.InstanceBuildFailedError; exports.InstanceNotReadyError = _chunk7IZHVYO2cjs.InstanceNotReadyError; exports.InsufficientCreditsError = _chunk7IZHVYO2cjs.InsufficientCreditsError; exports.InvalidConversationIdError = _chunk7IZHVYO2cjs.InvalidConversationIdError; exports.InvalidInputError = _chunk7IZHVYO2cjs.InvalidInputError; exports.InvalidInstanceIdError = _chunk7IZHVYO2cjs.InvalidInstanceIdError; exports.ListeningAlreadyActiveError = _chunk7IZHVYO2cjs.ListeningAlreadyActiveError; exports.ListeningNotActiveError = _chunk7IZHVYO2cjs.ListeningNotActiveError; exports.MEMORY_TYPES = MEMORY_TYPES; exports.NetworkTimeoutError = _chunk7IZHVYO2cjs.NetworkTimeoutError; exports.OBJECTIVES = OBJECTIVES; exports.PermanentError = _chunk7IZHVYO2cjs.PermanentError; exports.RESPONSE_SHAPES = RESPONSE_SHAPES; exports.RateLimitError = _chunk7IZHVYO2cjs.RateLimitError; exports.SDKError = _chunk7IZHVYO2cjs.SDKError; exports.SDK_VERSION = SDK_VERSION; exports.ServiceUnavailableError = _chunk7IZHVYO2cjs.ServiceUnavailableError; exports.SessionExpiredError = _chunk7IZHVYO2cjs.SessionExpiredError; exports.SynapClient = SynapClient; exports.SynapError = _chunk7IZHVYO2cjs.SynapError; exports.SynapPermanentError = _chunk7IZHVYO2cjs.SynapPermanentError; exports.SynapTransientError = _chunk7IZHVYO2cjs.SynapTransientError; exports.THRESHOLDS = _chunkBYUGILQIcjs.THRESHOLDS; exports.TranscriptConflictError = _chunk7IZHVYO2cjs.TranscriptConflictError; exports.TransientError = _chunk7IZHVYO2cjs.TransientError; exports.applyResponseShape = applyResponseShape; exports.filePart = filePart; exports.flattenContextItems = flattenContextItems; exports.formatForPrompt = formatForPrompt; exports.isOutcomeUnknown = isOutcomeUnknown; exports.isSynapError = _chunk7IZHVYO2cjs.isSynapError; exports.mergeScopeResults = mergeScopeResults; exports.rankItems = rankItems; exports.resolvePath = resolvePath; exports.shouldRetry = shouldRetry; exports.stem = _chunkBYUGILQIcjs.stem; exports.textPart = textPart; exports.tokenize = _chunkBYUGILQIcjs.tokenize; exports.wireRankScore = wireRankScore;
5981
+
5982
+
5983
+
5984
+ exports.ANY_SCOPE = _chunkBYUGILQIcjs.ANY_SCOPE; exports.AgentUnavailableError = _chunkJPDEKN5Mcjs.AgentUnavailableError; exports.AnticipationCache = _chunkBYUGILQIcjs.AnticipationCache; exports.AuthenticationError = _chunkJPDEKN5Mcjs.AuthenticationError; exports.BM25 = _chunkBYUGILQIcjs.BM25; exports.COMPACTION_LEVELS = COMPACTION_LEVELS; exports.CONTRACT = _chunkBYUGILQIcjs.CONTRACT; exports.ConflictError = _chunkJPDEKN5Mcjs.ConflictError; exports.ConnectionError = _chunkJPDEKN5Mcjs.ConnectionError; exports.ContextNotFoundError = _chunkJPDEKN5Mcjs.ContextNotFoundError; exports.CustomerIdNotAcceptedError = _chunkJPDEKN5Mcjs.CustomerIdNotAcceptedError; exports.DATA_SCOPES = DATA_SCOPES; 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.EXCERPT_CATEGORY = EXCERPT_CATEGORY; exports.FORGET_MODES = FORGET_MODES; exports.HttpTransport = HttpTransport; exports.INGEST_MODES = INGEST_MODES; exports.ITEM_COLLECTIONS = ITEM_COLLECTIONS; exports.InstanceBuildFailedError = _chunkJPDEKN5Mcjs.InstanceBuildFailedError; exports.InstanceNotReadyError = _chunkJPDEKN5Mcjs.InstanceNotReadyError; exports.InsufficientCreditsError = _chunkJPDEKN5Mcjs.InsufficientCreditsError; exports.InvalidConversationIdError = _chunkJPDEKN5Mcjs.InvalidConversationIdError; exports.InvalidInputError = _chunkJPDEKN5Mcjs.InvalidInputError; exports.InvalidInstanceIdError = _chunkJPDEKN5Mcjs.InvalidInstanceIdError; exports.ListeningAlreadyActiveError = _chunkJPDEKN5Mcjs.ListeningAlreadyActiveError; exports.ListeningNotActiveError = _chunkJPDEKN5Mcjs.ListeningNotActiveError; exports.MEMORY_TYPES = MEMORY_TYPES; exports.NetworkTimeoutError = _chunkJPDEKN5Mcjs.NetworkTimeoutError; exports.OBJECTIVES = OBJECTIVES; exports.PermanentError = _chunkJPDEKN5Mcjs.PermanentError; exports.RESPONSE_SHAPES = RESPONSE_SHAPES; exports.RateLimitError = _chunkJPDEKN5Mcjs.RateLimitError; exports.SDKError = _chunkJPDEKN5Mcjs.SDKError; exports.SDK_VERSION = SDK_VERSION; exports.ScopeAddress = ScopeAddress; exports.ScopeLadder = ScopeLadder; exports.ScopeLadderError = _chunkJPDEKN5Mcjs.ScopeLadderError; exports.ServiceUnavailableError = _chunkJPDEKN5Mcjs.ServiceUnavailableError; exports.SessionExpiredError = _chunkJPDEKN5Mcjs.SessionExpiredError; exports.SynapClient = SynapClient; exports.SynapError = _chunkJPDEKN5Mcjs.SynapError; exports.SynapPermanentError = _chunkJPDEKN5Mcjs.SynapPermanentError; exports.SynapTransientError = _chunkJPDEKN5Mcjs.SynapTransientError; exports.THRESHOLDS = _chunkBYUGILQIcjs.THRESHOLDS; exports.TranscriptConflictError = _chunkJPDEKN5Mcjs.TranscriptConflictError; exports.TransientError = _chunkJPDEKN5Mcjs.TransientError; exports.applyResponseShape = applyResponseShape; exports.filePart = filePart; exports.flattenContextItems = flattenContextItems; exports.formatForPrompt = formatForPrompt; exports.isOutcomeUnknown = isOutcomeUnknown; exports.isSynapError = _chunkJPDEKN5Mcjs.isSynapError; exports.mergeScopeResults = mergeScopeResults; exports.rankItems = rankItems; exports.resolvePath = resolvePath; exports.shouldRetry = shouldRetry; exports.stem = _chunkBYUGILQIcjs.stem; exports.textPart = textPart; exports.tokenize = _chunkBYUGILQIcjs.tokenize; exports.wireRankScore = wireRankScore;
5510
5985
  //# sourceMappingURL=index.cjs.map