wontopos 2.2.40 → 2.2.42

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.
@@ -26,10 +26,11 @@
26
26
  * and searching call no LLM.
27
27
  *
28
28
  * Reliability: every call retries transient failures with exponential backoff +
29
- * jitter, honoring `Retry-After` — 429 always; 408/502/503/504 and connection errors
30
- * only when a retry can never double-process a write (idempotent calls, or a failure
31
- * at connect time). Tune with `maxRetries` (0 disables) and `timeoutMs`, or per
32
- * call site via the `withTimeout()` / `withRetries()` clones.
29
+ * jitter, honoring `Retry-After` up to 30s — 429 and a 409 that says another write
30
+ * to the store was in flight, always; 408/502/503/504 and connection errors only when
31
+ * a retry can never double-process a write (idempotent calls, or a failure at connect
32
+ * time). Tune with `maxRetries` (0 disables) and `timeoutMs`, or per call site via
33
+ * the `withTimeout()` / `withRetries()` clones.
33
34
  *
34
35
  * Debugging: set `WONTOPOS_LOG=debug` to log method/path/status/timing/retries
35
36
  * to stderr — never memory content, request bodies, or the API key.
@@ -40,7 +41,7 @@
40
41
  * runtime's (never disabled by this SDK; Node 18+ floors TLS at 1.2). Prefer
41
42
  * `Client.fromEnv()` over keys in source code.
42
43
  */
43
- /** Test hook — the warn-once set is process-global by design. */
44
+ /** @deprecated Test hook. The warn-once set is process-global by design. */
44
45
  export declare function _resetStoreIdWarnings(): void;
45
46
  export declare const SEARCH_LIMIT_MIN = 5;
46
47
  export declare const SEARCH_LIMIT_MAX = 20;
@@ -53,16 +54,36 @@ export interface RateLimit {
53
54
  remaining: number | null;
54
55
  reset: number | null;
55
56
  }
57
+ /** What a `WosError` carries beyond its status, message and request id. */
58
+ export interface WosErrorInit {
59
+ /** `error.type` from the service's answer. */
60
+ type?: string;
61
+ /** The rest of the service's error object. */
62
+ details?: Record<string, unknown>;
63
+ /** `Retry-After`, in seconds (read by `RateLimitError`). */
64
+ retryAfter?: number;
65
+ /** The underlying error, kept as the standard `cause`. */
66
+ cause?: unknown;
67
+ }
56
68
  export declare class WosError extends Error {
57
69
  readonly status: number;
58
70
  /** The server's id for the request when it sent one — include it when contacting support. */
59
71
  readonly requestId?: string;
60
- constructor(status: number, message: string, requestId?: string);
72
+ /** `error.type` from the service's answer (e.g. `"conflict_error"`), when it sent one.
73
+ * Control characters are removed and it is capped, like the message. */
74
+ readonly type?: string;
75
+ /** Every other field of the service's error object — all but `message`, `type` and
76
+ * `request_id` — when there is any. Control characters are removed from its keys
77
+ * and strings, each string is capped, and when its JSON is over 8192 characters the
78
+ * biggest fields are left out. A 501 carries `model` and `endpoint` here. */
79
+ readonly details?: Record<string, unknown>;
80
+ constructor(status: number, message: string, requestId?: string, init?: WosErrorInit);
61
81
  }
62
82
  /** The request never got a response (DNS/TLS/timeout/connection). `status` is 0. */
63
83
  export declare class APIConnectionError extends WosError {
64
84
  }
65
- /** 400 — the request was malformed (bad arguments). */
85
+ /** 400 — the request was malformed (bad arguments). 413 (body too large) and 422
86
+ * (an idempotency key reused with a different body) arrive as this class too. */
66
87
  export declare class BadRequestError extends WosError {
67
88
  }
68
89
  /** 401 — the API key is missing, wrong, or revoked. */
@@ -77,12 +98,20 @@ export declare class PermissionDeniedError extends WosError {
77
98
  /** 404 — the store or resource doesn't exist. */
78
99
  export declare class NotFoundError extends WosError {
79
100
  }
80
- /** 409 — another write to this store was in flight (nothing was stored; retry), or the
81
- * store id collides with an existing store's (permanent). */
101
+ /** 409: another write to this store was in flight (retried automatically; nothing was
102
+ * stored), or the store id collides with an existing one (not retried). */
82
103
  export declare class ConflictError extends WosError {
104
+ /** The existing store id this one collides with. Set only on a collision, which
105
+ * retrying cannot fix. */
106
+ readonly conflictsWith?: string;
107
+ constructor(status: number, message: string, requestId?: string, init?: WosErrorInit);
83
108
  }
84
- /** 429 — too many requests. Back off and retry (the client already retries these). */
109
+ /** 429 — too many requests. Back off and retry (the client already retries these,
110
+ * unless `Retry-After` asks for more than 30 seconds). */
85
111
  export declare class RateLimitError extends WosError {
112
+ /** Seconds the service asked to wait (`Retry-After`), when it said. */
113
+ readonly retryAfter?: number;
114
+ constructor(status: number, message: string, requestId?: string, init?: WosErrorInit);
86
115
  }
87
116
  /**
88
117
  * 5xx — the service failed.
@@ -90,11 +119,9 @@ export declare class RateLimitError extends WosError {
90
119
  * `502` / `503` / `504` are transient: the client already retries them for calls
91
120
  * where a retry cannot double-process a write, and retrying yourself is reasonable.
92
121
  *
93
- * `501` is NOT transient. It means the engine behind the model you selected does
94
- * not implement that endpoint at all (the error carries `model` and `endpoint`).
95
- * Retrying can never succeed — pick a model that supports it (`listModels`) or
96
- * drop the call. Treating the whole 5xx range as retryable sends a caller into a
97
- * loop that cannot end.
122
+ * `501` is NOT transient. It means the model you selected does not implement that
123
+ * endpoint at all (`details` carries `model` and `endpoint`). Retrying can never
124
+ * succeed — pick a model that supports it (`listModels`) or drop the call.
98
125
  */
99
126
  export declare class ServerError extends WosError {
100
127
  }
@@ -140,8 +167,7 @@ export interface StoreResult {
140
167
  * A genuinely new fact that only varies a detail of one already stored ("no meetings
141
168
  * before 10am" next to "no meetings on Fridays") can land here too, so a duplicate is
142
169
  * not always a harmless no-op: read this id, and either store one sentence that states
143
- * both or `update()` the existing memory with the combined statement. Without it a
144
- * dropped write gave the caller nothing to act on.
170
+ * both or `update()` the existing memory with the combined statement.
145
171
  */
146
172
  duplicate_of?: string;
147
173
  /** Present when the store was a duplicate and something (e.g. a speaker tag) was dropped. */
@@ -160,7 +186,8 @@ export interface StatusResult {
160
186
  /**
161
187
  * An image attached to a memory, passed to `add`/`store` via `opts.image`.
162
188
  *
163
- * Both edges must be 700px or more; a smaller image is refused (400).
189
+ * Both edges must be 700px or more; a smaller image is refused (400). A request
190
+ * body is capped at 10MB.
164
191
  *
165
192
  * What the service keeps is NOT your original. An image whose long edge is over
166
193
  * 1568px is downscaled to 1568 before anything else happens, and that smaller
@@ -176,18 +203,23 @@ export interface StatusResult {
176
203
  * already fits within 1568px, and a re-encode that would make the file BIGGER is
177
204
  * thrown away and your bytes kept as they were.
178
205
  *
179
- * Keep your own copy if you need the full-resolution file. Either archive it
180
- * yourself, or put its URL in `reference` — we store that string and never open it.
206
+ * Keep your own copy if you need the full-resolution file.
181
207
  *
182
208
  * You are billed for the picture we keep, so downscaling never costs you more.
183
209
  */
184
210
  export interface ImageInput {
185
211
  /** base64 of the image. A `data:image/...;base64,` prefix is accepted and stripped. */
186
212
  data: string;
187
- /** Where YOUR copy of the original lives. Stored as-is; the service never fetches it. */
213
+ /**
214
+ * Where YOUR copy of the image lives. Stored as-is; the service never fetches it.
215
+ *
216
+ * When you send one, the service keeps no image bytes: `getImage` answers 404 for
217
+ * this memory, and you fetch the picture from your own reference.
218
+ */
188
219
  reference?: string;
189
220
  /**
190
- * When the image was TAKEN (RFC3339), if you know it — usually from EXIF.
221
+ * When the image was TAKEN, if you know it — usually from EXIF. RFC3339 or a plain
222
+ * date (`YYYY-MM-DD`); anything else is refused (400) naming the field.
191
223
  *
192
224
  * Worth passing: an image knows a moment that its caption does not. This fills
193
225
  * `metadata.event_date` when that is empty, so "the day we moved" sorts by when it
@@ -214,12 +246,8 @@ export interface ImageDeleteResult {
214
246
  status?: string;
215
247
  memory_id?: string;
216
248
  /**
217
- * Whether the MEMORY survives losing its image.
218
- *
219
- * A captioned image keeps its text and only loses the image. An image stored with no
220
- * caption IS the memory, so deleting the image deletes the memory — and the service
221
- * says so here rather than silently taking more than you asked for. Call with
222
- * `preview: true` first if that distinction matters to you.
249
+ * Whether the MEMORY survives losing its image. `false` means the delete removed
250
+ * the whole memory; call with `preview: true` first to find out before it happens.
223
251
  */
224
252
  memory_kept?: boolean;
225
253
  /** Plain-language note about the above, when there is something to say. */
@@ -245,7 +273,7 @@ export interface RevisionsResult {
245
273
  revised?: number;
246
274
  /** Memories nothing has touched since they were written. Always `total - revised`. */
247
275
  unrevised?: number;
248
- /** Every memory in the store. Internal records nobody stored directly are not counted. */
276
+ /** The memories you stored. */
249
277
  total?: number;
250
278
  /** What `revised` counts, spelled out by the service. */
251
279
  counts?: string;
@@ -398,7 +426,9 @@ export interface StatsResult {
398
426
  export interface MemoryPage {
399
427
  memories: Memory[];
400
428
  count: number;
401
- /** Pass back as `cursor` for the next page; `null` on the last page. */
429
+ /** Pass back as `cursor` for the next page; `null` means there is none. It can be
430
+ * non-null on the last page, and the next call then returns an empty page. Pass
431
+ * back only a cursor the service returned. */
402
432
  next_cursor: string | null;
403
433
  [key: string]: unknown;
404
434
  }
@@ -409,12 +439,31 @@ export interface SelfSearchResult {
409
439
  /** The assistant's own words (stored with speaker "me"); `[]` on non-self models. */
410
440
  self_memories: Memory[];
411
441
  }
442
+ /** What a model can do, as `listModels()` reports it. A model without a feature
443
+ * refuses the call that needs it (usually 403) or answers without that part. */
444
+ export interface ModelCapabilities {
445
+ /** Image memories: `opts.image` on `add`, `max_images`, `getImage`, `listImages`. */
446
+ images?: boolean;
447
+ /** `engram()`; `listEngrams()` names the ones this model runs. */
448
+ engrams?: boolean;
449
+ /** Delivery forms (`form` / `tz`) on search, recall and engram. */
450
+ forms?: boolean;
451
+ /** Re-ask passes (`verify`) on search. */
452
+ re_ask?: boolean;
453
+ /** The assistant's own words apart, in `self_memories`. */
454
+ self_memories?: boolean;
455
+ /** Speaker names, as the service reports them. */
456
+ speaker_names?: boolean;
457
+ [key: string]: boolean | undefined;
458
+ }
412
459
  export interface ModelInfo {
413
460
  id: string;
414
461
  name: string;
415
462
  available: boolean;
416
463
  /** "shared" — reads the common memory pool; "isolated" — its own dedicated store. */
417
464
  memory: "shared" | "isolated";
465
+ /** What this model can do. Check it before relying on a feature. */
466
+ capabilities?: ModelCapabilities;
418
467
  }
419
468
  /** One entry of the engram / delivery-form catalogue (`listEngrams`). */
420
469
  export interface EngramInfo {
@@ -480,21 +529,29 @@ export interface SpeakersList {
480
529
  * Retrieval behaves the same in every language, so these behave
481
530
  * identically in every language. Unlisted keys are dropped by the API rather than
482
531
  * rejected, so a typo silently widens the search — spell them exactly.
532
+ *
533
+ * Filters apply to `memories`. The assistant's own words (`self_memories`) are not
534
+ * filtered, and `search` merges them into its answer, so read `searchFull` when a
535
+ * filtered answer must hold only what matched.
536
+ *
537
+ * Every date takes RFC3339 or a plain date (`YYYY-MM-DD`). A plain end date
538
+ * (`time_to`, `event_to`) covers that whole day in UTC. A value that is not a date
539
+ * is refused (400) naming the field.
483
540
  */
484
541
  export interface SearchFilters {
485
542
  /** Only these categories (the `category` you see on `listMemories` results). */
486
543
  categories?: string[];
487
- /** Ingestion-time window, as the API stores it. Plain strings, matched as given. */
544
+ /** When the memory was stored. */
488
545
  time_from?: string;
489
546
  time_to?: string;
490
547
  /** WHEN THE CONTENT HAPPENED (`metadata.event_date`), not when it was written —
491
- * this is the one you usually want. RFC3339, or a plain `YYYY-MM-DD`. */
548
+ * this is the one you usually want. */
492
549
  event_from?: string;
493
550
  event_to?: string;
494
551
  /** Drop matches the engine scored below this importance (0–1). */
495
552
  min_importance?: number;
496
553
  }
497
- /** Test hook — the warn-once set is process-global by design. */
554
+ /** @deprecated Test hook. The warn-once set is process-global by design. */
498
555
  export declare function _resetFilterWarnings(): void;
499
556
  /** Known `search` options. An unknown key is refused before anything is sent — the
500
557
  * service drops keys it does not recognise and answers normally, so a misspelling
@@ -523,23 +580,22 @@ export interface SearchOptions {
523
580
  * that need several distinct memories from far apart in the history; it does little
524
581
  * on a single-fact lookup.
525
582
  *
526
- * Requires a re-ask-capable model. Older ones REFUSE the call (403) rather than
527
- * quietly charging you for passes that never happened.
583
+ * Requires a model that lists `re_ask` in its `listModels()` capabilities; any
584
+ * other refuses the call (403) rather than charging for passes that never happened.
528
585
  */
529
586
  verify?: number;
530
587
  /**
531
588
  * How many image memories the answer may carry, 0–5. Omit it and the service uses
532
- * 1; `0` asks for none. The MCP server defaults its own tool to 0 instead, so most
533
- * searches through it carry no image rows.
534
- * Out of range is refused, not clamped — silently cutting 5 to 1 would leave you
535
- * believing you got five.
589
+ * 1; `0` asks for none. Out of range is refused before the request, not clamped —
590
+ * silently cutting 6 to 5 would leave you believing you got six.
536
591
  *
537
- * Requires an image-capable model, and is refused (403) on one without it rather
538
- * than answering with no images.
592
+ * Requires a model that lists `images` in its capabilities, and is refused (403)
593
+ * on one without it rather than answering with no images.
539
594
  */
540
595
  max_images?: number;
541
- /** Delivery form, "memoir" or "archive" (Scroll 1.2+): how each memory's time is
542
- * rendered. The service refuses an unknown one (400). */
596
+ /** Delivery form, "memoir" or "archive": how each memory's time is rendered. Needs a
597
+ * model that lists `forms` in its capabilities. The service refuses an unknown
598
+ * form (400). */
543
599
  form?: string;
544
600
  /** Your UTC offset in hours, for rendering times in `form`. */
545
601
  tz?: number;
@@ -554,69 +610,128 @@ export interface SearchOptions {
554
610
  * Per-call options for a write.
555
611
  *
556
612
  * `idempotencyKey` makes repeating THIS EXACT write safe: the API replays the first
557
- * response instead of storing again, for 10 minutes, and answers 422 if the same key
558
- * arrives with a different body. Use it when a retry is your own (a job that died and
559
- * was re-run, a queue that redelivers). The SDK retries a write on exactly one
560
- * status: 429, which the service answers before it processes anything, so nothing
561
- * was stored. It never retries a write on 408 / 502 / 503 / 504 or a dropped body,
562
- * where the first attempt may already have landed — without a key the client cannot
563
- * know whether it did.
613
+ * response instead of storing again, for up to 10 minutes, and answers 422 if the
614
+ * same key arrives with a different body. Use it when a retry is your own (a job that
615
+ * died and was re-run, a queue that redelivers). The SDK retries a write on 429, and
616
+ * on a 409 that says another write to the store was in flight: the service answers
617
+ * both before it processes anything, so nothing was stored. It never retries a write
618
+ * on 408 / 502 / 503 / 504 or a dropped body, where the write may already have been
619
+ * applied — without a key the client cannot know whether it was.
620
+ *
621
+ * The key covers a retry sent after the first attempt finished. A retry that overlaps
622
+ * a first attempt still running can run twice, so wait for the first to fail before
623
+ * re-sending.
564
624
  *
565
625
  * The key must be UNIQUE PER LOGICAL WRITE — derive it from the thing being stored
566
626
  * (`` `import:${row.id}` ``), never a constant, or the second write replays the first
567
627
  * and is silently lost. Format: 1-128 chars of `[A-Za-z0-9._:-]`, checked locally.
568
628
  *
569
- * The window is in-memory on the API, so a deploy or restart clears it early. It is a
570
- * guard against a retry storm, not a durable ledger.
629
+ * The window is best-effort and can be shorter than 10 minutes; it is not a durable
630
+ * de-duplication record.
571
631
  */
572
632
  export interface WriteOptions {
573
633
  idempotencyKey?: string;
574
634
  /**
575
- * An image to store alongside the text (Tablet 2 and newer).
635
+ * An image to store alongside the text. Needs a model that lists `images` in its
636
+ * `listModels()` capabilities; any other refuses the write rather than store the
637
+ * caption and quietly drop the image.
576
638
  *
577
- * `content` may be empty when you pass one — then the image IS the memory and is
578
- * searchable on its own. Older models have no image channel and will reject the
579
- * write rather than store the caption and quietly drop the image.
639
+ * A caption is required: the service refuses empty `content` (400) even with an
640
+ * image attached.
580
641
  */
581
642
  image?: ImageInput;
582
643
  }
644
+ /** The part of an `AbortSignal` the client uses, for a runtime that declares none. */
645
+ export interface AbortSignalShape {
646
+ readonly aborted: boolean;
647
+ addEventListener(type: "abort", listener: () => void): void;
648
+ removeEventListener(type: "abort", listener: () => void): void;
649
+ }
650
+ /** The runtime's own `AbortSignal` type when it declares one (the DOM lib,
651
+ * `@types/node`), otherwise {@link AbortSignalShape}. `AbortController#signal` fits. */
652
+ export type AbortSignalLike = typeof globalThis extends {
653
+ AbortSignal: {
654
+ prototype: infer S;
655
+ };
656
+ } ? S : AbortSignalShape;
657
+ /** The `init` the client passes to `fetch`. */
658
+ export interface FetchInitLike {
659
+ method: string;
660
+ headers: Record<string, string>;
661
+ body?: string;
662
+ signal: AbortSignalLike;
663
+ redirect: "manual";
664
+ }
665
+ /** The part of a `fetch` response the client reads. */
666
+ export interface FetchResponseLike {
667
+ readonly status: number;
668
+ readonly ok: boolean;
669
+ readonly type?: string;
670
+ readonly url?: string;
671
+ readonly redirected?: boolean;
672
+ readonly headers: {
673
+ get(name: string): string | null;
674
+ };
675
+ readonly body?: {
676
+ getReader(): {
677
+ read(): Promise<{
678
+ done: boolean;
679
+ value?: Uint8Array;
680
+ }>;
681
+ cancel(reason?: unknown): Promise<void>;
682
+ };
683
+ cancel(reason?: unknown): Promise<void>;
684
+ } | null;
685
+ arrayBuffer(): Promise<ArrayBuffer>;
686
+ }
687
+ /** The runtime's own `fetch` type when it declares one (the DOM lib, `@types/node`),
688
+ * otherwise a structural signature, so these types need neither. */
689
+ export type FetchLike = typeof globalThis extends {
690
+ fetch: infer F;
691
+ } ? F : (url: string, init: FetchInitLike) => Promise<FetchResponseLike>;
583
692
  export interface ClientOptions {
584
693
  apiKey: string;
585
- /** API base URL (defaults to the hosted service). */
694
+ /** API base URL (defaults to the hosted service): an http or https URL or, where
695
+ * the runtime has a page, a URL relative to it. Whitespace at either end is
696
+ * trimmed; whitespace, a control character or a backslash left in it after that is
697
+ * refused.
698
+ * A relative URL where the runtime has no page (server-side rendering) fails the
699
+ * first call that uses it, or goes to `fetch` as given when you pass one. */
586
700
  baseUrl?: string;
587
- /** Per-request timeout in ms, applied to each retry attempt (default 30000). */
701
+ /** Per-request timeout in ms, applied to each retry attempt (default 30000). A
702
+ * value that is not a positive number means the default; values above 2147483647
703
+ * are clamped to it. */
588
704
  timeoutMs?: number;
589
705
  /** Default model for every call (sent as `X-WOS-Model`). See `listModels()`. */
590
706
  model?: string;
591
- /** Default store for every call. Override per call by passing `userId`. Defaults
592
- * to the account's built-in `default` store. */
707
+ /** Default store for every call. Override per call by passing `userId`. Leave it
708
+ * out to use the account's built-in `default` store; passing it as `undefined` is
709
+ * refused, because that is usually a lookup that found nothing. */
593
710
  userId?: string;
594
- /** How many times to retry transient failures before throwing — 429 always;
595
- * 408/502/503/504 and connection errors only when a retry can never
596
- * double-process a write. 0 disables retries (default 2). */
711
+ /** How many times to retry transient failures before throwing — 429 and a 409
712
+ * that says another write was in flight, always; 408/502/503/504 and connection
713
+ * errors only when a retry can never double-process a write. 0 disables retries
714
+ * (default 2). */
597
715
  maxRetries?: number;
598
- /** Alias of `maxRetries`. The Python SDK calls this option `retries`, and these
599
- * SDKs are published in lockstep as "the same surface" — so code ported between
600
- * them silently lost its retry setting instead of failing loudly (an unknown
601
- * key on an options object is not an error in TS at runtime). Both names work;
602
- * `maxRetries` wins if somehow both are given. */
716
+ /** Alias of `maxRetries`. `maxRetries` wins when both are given. */
603
717
  retries?: number;
604
718
  /** A total budget for one call, in ms, across every attempt.
605
719
  *
606
720
  * `timeoutMs` bounds ONE attempt. At the defaults — 30s, two retries — a single
607
721
  * call can hold a connection for 30s + backoff + 30s + backoff + 30s, over a
608
- * minute, and a server handler awaiting it has no way to say "I only have five
609
- * seconds". This is that way. Unset means no overall budget. */
722
+ * minute. Unset means no overall budget. A retry whose wait does not fit in what
723
+ * is left is not made: the call fails with the error of the last response. A
724
+ * value that is not a positive number means no budget; values above 2147483647
725
+ * are clamped to it. */
610
726
  deadlineMs?: number;
611
727
  /** The caller's `AbortSignal` — cancel work already in flight.
612
728
  *
613
729
  * The SDK aborts on its own timeout; this is the seam for the caller's reason.
614
- * When someone closes the chat window, the recall that window asked for should
615
- * end, and the backoff sleep waiting to retry it should end too, instead of
616
- * running to completion and billing for an answer nobody will read.
730
+ * When someone closes the chat window, the recall that window asked for ends, and
731
+ * so does a backoff sleep waiting to retry it.
617
732
  *
618
733
  * Per call, clone: `mem.withSignal(ctrl.signal).recall(...)`. */
619
- signal?: AbortSignal;
734
+ signal?: AbortSignalLike;
620
735
  /** The `fetch` used for every request (default: the global `fetch`).
621
736
  *
622
737
  * This is the seam for anything the runtime cannot express through options.
@@ -633,8 +748,12 @@ export interface ClientOptions {
633
748
  *
634
749
  * It is also how you add instrumentation or drive the client in a test without
635
750
  * a network. Retries, timeouts, redirect refusal and the size cap all still
636
- * apply — this replaces the transport, not the client's rules. */
637
- fetch?: typeof fetch;
751
+ * apply — this replaces the transport, not the client's rules. Pass
752
+ * `init.redirect` through unchanged: a fetch that follows a redirect sends the
753
+ * key to wherever it points, and an answer it reports as redirected
754
+ * (`res.redirected`) is refused. A fetch that sends the request to another URL
755
+ * on purpose, such as a proxy that rewrites it, is fine. */
756
+ fetch?: FetchLike;
638
757
  }
639
758
  /** Wontopos memory client. Store and recall memories, isolated per `userId`. */
640
759
  export declare class Client {
@@ -649,6 +768,13 @@ export declare class Client {
649
768
  /** Transport. Held as a field (not read off `globalThis` per call) so a caller
650
769
  * who passes one gets it for every request, including from cloned clients. */
651
770
  private readonly fetchImpl;
771
+ /** Whether `baseUrl` carries userinfo, which network errors must not show. */
772
+ private readonly userinfo;
773
+ /** Whether `baseUrl` did not resolve to a URL at construction: a relative one where
774
+ * the runtime had no page. */
775
+ private readonly pageRelative;
776
+ /** Whether the caller supplied `fetch`. */
777
+ private readonly customFetch;
652
778
  /** The store every call uses unless one passes `userId`. */
653
779
  private readonly defaultUser;
654
780
  private _rateLimit;
@@ -660,7 +786,7 @@ export declare class Client {
660
786
  /** A client whose key comes from `WONTOPOS_API_KEY` (or `WOS_API_KEY`) — keeps
661
787
  * keys out of source code. Node/Bun/Deno-with-env only. */
662
788
  static fromEnv(opts?: Omit<ClientOptions, "apiKey">): Client;
663
- /** Never expose the key: `JSON.stringify(client)` gets the redacted view. */
789
+ /** Never expose the key or a URL password: `JSON.stringify(client)` gets the redacted view. */
664
790
  toJSON(): Record<string, string>;
665
791
  /** Resolve a call's store: the explicit userId, else the client default. */
666
792
  private uid;
@@ -680,7 +806,7 @@ export declare class Client {
680
806
  * const r = await mem.withSignal(ctrl.signal).recall(q, user);
681
807
  *
682
808
  * Aborting ends the request in flight AND any backoff sleep waiting to retry it. */
683
- withSignal(signal: AbortSignal): Client;
809
+ withSignal(signal: AbortSignalLike): Client;
684
810
  /** A client with a total budget per call, across every retry (everything else
685
811
  * kept). `mem.withDeadline(5_000).search(q)` inside a handler that has five
686
812
  * seconds. */
@@ -690,19 +816,23 @@ export declare class Client {
690
816
  withTimeout(timeoutMs: number): Client;
691
817
  /** A client with a different retry budget (everything else kept). 0 disables retries. */
692
818
  withRetries(maxRetries: number): Client;
693
- /** Store one memory. `metadata` optional — e.g. `{ event_date: "2026-03-01" }` for when the
694
- * content actually happened. A plain date works (read as UTC midnight); a full RFC3339
695
- * timestamp also works; older examples here show the long form.
696
- * `metadata.speaker`: "me" = the assistant's own words, or a person's name (up to 50 per store).
819
+ /** Store one memory. `metadata` optional — the service keeps only these keys and
820
+ * drops any other (this client warns once per unknown key):
821
+ * - `event_date`: when the content actually happened, RFC3339 or a plain date
822
+ * (`YYYY-MM-DD`, read as UTC midnight); anything else is refused (400) naming the field.
823
+ * - `speaker`: "me" = the assistant's own words, or a person's name (up to 50 per store).
824
+ * - `category`, `conversation_id`.
697
825
  *
698
826
  * `opts.idempotencyKey`: see {@link WriteOptions} — pass one to make YOUR retry
699
827
  * of this exact write safe to repeat. */
700
828
  add(content: string, userId?: string, metadata?: Record<string, unknown>, opts?: WriteOptions): Promise<StoreResult>;
701
- /** Alias of `add` — store one memory. Same surface as the Python SDK's `store`. */
829
+ /** Alias of `add` — store one memory. */
702
830
  store(content: string, userId?: string, metadata?: Record<string, unknown>, opts?: WriteOptions): Promise<StoreResult>;
703
831
  /** Store a conversation turn (user + assistant). Payload first, userId last — same shape as add/search. */
704
832
  addTurn(userMsg: string, assistantMsg: string, userId?: string, opts?: WriteOptions): Promise<StatusResult>;
705
833
  /** Bulk-ingest a large blob of text in one call. For backfilling.
834
+ * `timestamp` must be RFC3339 (`2026-05-02T09:00:00Z`): a plain date or any other
835
+ * string is ignored, and the memory is filed at upload time.
706
836
  * The call most worth an `opts.idempotencyKey`: a backfill that dies halfway and is
707
837
  * re-run would otherwise ingest the whole blob a second time. */
708
838
  addBulk(content: string, userId?: string, category?: string, timestamp?: string, opts?: WriteOptions): Promise<StatusResult>;
@@ -711,22 +841,25 @@ export declare class Client {
711
841
  /** Search a store's memories. Returns them most relevant first.
712
842
  *
713
843
  * `limit` is 5-20, and out of range is refused rather than clamped: asking for 50
714
- * and silently receiving 20 reads as "that is all there is". The default is 10, so
715
- * a call that passes no count is unaffected. Before 2.2.35 the count was sent on
716
- * unchecked.
844
+ * and silently receiving 20 reads as "that is all there is". The default is 10.
845
+ *
846
+ * `limit` bounds `memories`, not the returned array. The assistant's own words (on
847
+ * a model that lists `self_memories` in its capabilities) and image memories (one
848
+ * unless `max_images` says otherwise, on a model that lists `images`) come back in
849
+ * it as well, so it can hold more than `limit`. They are billed either way. Size a
850
+ * prompt window on the array you get back, not on `limit`. `searchFull()` hands the
851
+ * fields back apart.
717
852
  *
718
- * `limit` bounds `memories`, not the returned array. The assistant's own words
719
- * (Scroll 1.2+) and image memories (Tablet 2+, one unless `max_images` says
720
- * otherwise) come back in it as well, so it can hold more than `limit`. They are
721
- * billed either way. Size a prompt window on the array you get back, not on
722
- * `limit`. `searchFull()` hands the fields back apart. */
853
+ * `filters` apply to `memories` only; the assistant's own words merged in here are
854
+ * not filtered. */
723
855
  search(query: string, userId?: string, limit?: number, opts?: SearchOptions): Promise<Memory[]>;
724
- /** Search a self-memory model (Scroll 1.2+): both fields from ONE call. Returns
725
- * `{ memories, self_memories }` — `memories` is what others said and general
856
+ /** Search, with the assistant's own words kept apart: both fields from ONE call.
857
+ * Returns `{ memories, self_memories }` — `memories` is what others said and general
726
858
  * memories, `self_memories` is the assistant's OWN words (stored with speaker
727
859
  * "me"), kept apart so whoever reads them never confuses who said what. On a model
728
- * that does not keep them apart, `self_memories` is `[]`. Image memories are not
729
- * included; `search` and `searchFull` carry them. `userId` may be omitted. */
860
+ * that does not list `self_memories` in its capabilities, `self_memories` is `[]`.
861
+ * Image memories are not included; `search` and `searchFull` carry them. `filters`
862
+ * apply to `memories` only. `userId` may be omitted. */
730
863
  searchSelf(query: string, userId?: string, limit?: number, opts?: SearchOptions): Promise<SelfSearchResult>;
731
864
  /**
732
865
  * Search, and keep every field the answer came with.
@@ -739,13 +872,15 @@ export declare class Client {
739
872
  * r.images.length; // the photos, apart from the text memories
740
873
  * r.verify_used; // how many re-ask passes actually ran (you are billed per pass)
741
874
  *
742
- * Both options need Tablet 2 or newer and are refused (403) on an older engine
743
- * rather than accepted and ignored.
875
+ * Each option needs a model that lists it in its `listModels()` capabilities
876
+ * (`images`, `re_ask`) and is refused (403) on any other rather than accepted and
877
+ * ignored. `filters` apply to `memories`; `self_memories` are not filtered.
744
878
  */
745
879
  searchFull(query: string, userId?: string, limit?: number, opts?: SearchOptions): Promise<SearchResult>;
746
880
  /** One-call LLM context: short-term turns + long-term matches + surrounding context.
747
- * `form` ("memoir"/"archive", Scroll 1.2+) renders each long-term memory's time in
748
- * that form; `tz` is your UTC-offset hours for that rendering. */
881
+ * `form` ("memoir"/"archive", on a model that lists `forms` in its capabilities)
882
+ * renders each long-term memory's time in that form; `tz` is your UTC-offset hours
883
+ * for that rendering. */
749
884
  recall(query: string, userId?: string, opts?: {
750
885
  form?: string;
751
886
  tz?: number;
@@ -753,19 +888,19 @@ export declare class Client {
753
888
  * Long-term memories to recall, 5–20. Default 10. Out of range is refused, not
754
889
  * clamped — asking for 20 and silently getting 10 reads as "that is all there is".
755
890
  *
756
- * Needs a limit-aware model. An older one recalls a fixed ten no matter what you
757
- * send, so the API refuses the call (403) rather than answering with a number you
758
- * did not ask for.
891
+ * A model that does not take a recall count refuses the call (403) rather than
892
+ * answering with a number you did not ask for.
759
893
  */
760
894
  limit?: number;
761
895
  /** How much surrounding context is attached around the best match, 0–20. Default 10;
762
- * 0 attaches none. Same model floor as `limit`. */
896
+ * 0 attaches none. Refused (403) by the same models as `limit`. */
763
897
  context_limit?: number;
764
898
  }): Promise<RecallResult>;
765
899
  /** Run a built-in engram ("deep_recall" | "timeline" | "gather" | "equilibrium" |
766
900
  * "tone_stabilizer"; the service is the authority — an unknown name comes back with
767
901
  * the list it accepts). Returns the merged result.
768
- * `form`/`tz` render memory times (memoir/archive) on Scroll 1.2+, same as search/recall. */
902
+ * `form`/`tz` render memory times (memoir/archive) on a model that lists `forms` in
903
+ * its capabilities, same as search/recall. */
769
904
  engram(name: string, query: string, userId?: string, opts?: {
770
905
  form?: string;
771
906
  tz?: number;
@@ -790,13 +925,17 @@ export declare class Client {
790
925
  usage(days?: number): Promise<UsageResult>;
791
926
  /** Fetch ONE memory by id — the text you stored, and its metadata.
792
927
  * The id is what `add`/`store` or `listMemories` returned. Same visibility as
793
- * `listMemories`: an id from another store, an internal record id, or an
794
- * invalidated memory rejects with `NotFoundError`. Pass `undefined` as `userId` for
795
- * the default store — it is positional here, not omittable as it is in Python. */
928
+ * `listMemories`: an id from another store, an id `listMemories` does not return,
929
+ * or an invalidated memory rejects with `NotFoundError`. Pass `undefined` as
930
+ * `userId` for the default store — it is positional here. */
796
931
  get(userId: string | undefined, memoryId: string): Promise<Memory>;
797
932
  /** List a store's stored memories — the text you stored, plus its metadata.
798
933
  * Paginated: pass the returned `next_cursor` back as `cursor` for the next
799
- * page; a `null` cursor means the last page. Use it to browse or export a store.
934
+ * page, and only a cursor the service returned. A `null` cursor means there is no
935
+ * next page; a non-null one can still be followed by an empty page. Use it to
936
+ * browse or export a store.
937
+ *
938
+ * `limit` is 1-500 (default 100); anything else is refused before the request.
800
939
  *
801
940
  * let cursor: string | null = null;
802
941
  * const all: Memory[] = [];
@@ -811,7 +950,11 @@ export declare class Client {
811
950
  cursor?: string;
812
951
  }): Promise<MemoryPage>;
813
952
  /** Async-iterate every stored memory in a store, paging under the hood — no cursor
814
- * bookkeeping. The text you stored and its metadata only.
953
+ * bookkeeping. The text you stored and its metadata only. `pageSize` is 1-500.
954
+ *
955
+ * A walk that cannot reach the end of the store (the service hands back a cursor it
956
+ * already gave after a non-empty page, or the page ceiling is reached) throws rather
957
+ * than end with part of the store.
815
958
  *
816
959
  * for await (const m of mem.iterMemories()) console.log(m.id, m.content);
817
960
  */
@@ -821,7 +964,7 @@ export declare class Client {
821
964
  /** Collect ALL of a store's memories into an array (the text you stored, and its metadata). */
822
965
  exportMemories(userId?: string): Promise<Memory[]>;
823
966
  /** Collect ALL of a store's image memories into an array — the image-side pair of
824
- * `exportMemories`. */
967
+ * `exportMemories`. `pageSize` is 5-20. */
825
968
  exportImages(userId?: string, opts?: {
826
969
  pageSize?: number;
827
970
  }): Promise<Memory[]>;
@@ -837,9 +980,9 @@ export declare class Client {
837
980
  *
838
981
  * The type is sniffed from the bytes themselves rather than from whatever the file
839
982
  * was called, so name the file from `contentType` rather than from what you sent.
840
- * When the format changed, the response also carries `x-wos-image-converted-from`
841
- * naming what you uploaded. Rejects with `NotFoundError` when this memory has no
842
- * image, or when the service keeps no image bytes at all — it says "no" instead of
983
+ * Rejects with `NotFoundError` when this memory has no image, or when the service
984
+ * keeps no image bytes for it — which is always the case for an image stored with
985
+ * `reference`: fetch that one from your own reference. It says "no" instead of
843
986
  * handing back something empty, so "a memory with no image" never looks the same as
844
987
  * "an image we lost".
845
988
  *
@@ -851,10 +994,9 @@ export declare class Client {
851
994
  /**
852
995
  * Remove the PHOTO from a memory, keeping its text.
853
996
  *
854
- * Except when there is no text: an image stored without a caption *is* the memory, so
855
- * deleting the image deletes it. That is the one case worth checking before you
856
- * commit, which is what `preview` is for — it reports `memory_kept` and changes
857
- * nothing.
997
+ * `preview: true` reports what would happen, including `memory_kept`, and changes
998
+ * nothing. Retried like `deleteStore`; without `preview`, a 404 after an ambiguous
999
+ * failure carries the same note.
858
1000
  *
859
1001
  * const p = await mem.forgetImage(undefined, id, { preview: true });
860
1002
  * if (p.memory_kept === false) { /* this would delete the whole memory *\/ }
@@ -870,13 +1012,16 @@ export declare class Client {
870
1012
  * `next_before` and `next_skip_ids` back as `before` / `skipIds`. The pair exists
871
1013
  * because several images can share a timestamp, and a timestamp alone would either
872
1014
  * repeat them or skip them.
1015
+ *
1016
+ * `limit` is 5-20; anything else is refused before the request.
873
1017
  */
874
1018
  listImages(userId?: string, opts?: {
875
1019
  limit?: number;
876
1020
  before?: string;
877
1021
  skipIds?: string[];
878
1022
  }): Promise<ImagePage>;
879
- /** Async-iterate every image memory, paging under the hood. */
1023
+ /** Async-iterate every image memory, paging under the hood. `pageSize` is 5-20.
1024
+ * Like `iterMemories`, a walk that cannot reach the end throws. */
880
1025
  iterImages(userId?: string, opts?: {
881
1026
  pageSize?: number;
882
1027
  }): AsyncGenerator<Memory>;
@@ -889,9 +1034,8 @@ export declare class Client {
889
1034
  * rewritten. Free, and it never reaches the retrieval path.
890
1035
  *
891
1036
  * Counts memories a transform touched (supersede, update, retract, image removed).
892
- * Deletions are NOT counted: a deleted memory leaves nothing to count. Neither are
893
- * the internal records derived from what you stored — nobody stored those directly,
894
- * so they do not belong in a ratio that answers "how much of MY memory changed".
1037
+ * Deletions are NOT counted: a deleted memory leaves nothing to count. `total`
1038
+ * counts the memories you stored.
895
1039
  *
896
1040
  * By default this returns COUNTS ONLY, and the answer is the same size for a store
897
1041
  * of a hundred memories and a store of a hundred million. That is deliberate: a model
@@ -917,10 +1061,8 @@ export declare class Client {
917
1061
  * Pages are ordered by when each memory was STORED, not by when it was edited.
918
1062
  * The response says so in `ordered_by`.
919
1063
  *
920
- * Served from `/api/v1/won/*`, not `/api/v1/memory/*`. Won is the surface for calls
921
- * a model makes ABOUT its memory rather than calls an application makes WITH it, and
922
- * the address says so. The old path still answers, for clients published before
923
- * 2026-08-18, and both share one rate-limit budget.
1064
+ * Served from `/api/v1/won/revisions`: `/api/v1/won/*` holds the calls a model makes
1065
+ * ABOUT its memory rather than calls an application makes WITH it.
924
1066
  */
925
1067
  revisions(userId?: string, opts?: {
926
1068
  /**
@@ -928,7 +1070,8 @@ export declare class Client {
928
1070
  * number. One side per call — there is no way to ask for both lists at once.
929
1071
  */
930
1072
  include?: "revised" | "unrevised";
931
- /** Memories per page. 20 is both the default and the ceiling; more is rejected. */
1073
+ /** Memories per page, 5-20; 20 is the default. Anything else is refused before
1074
+ * the request. */
932
1075
  limit?: number;
933
1076
  /** Cursor: `next_before` from the previous page. */
934
1077
  before?: string;
@@ -948,7 +1091,7 @@ export declare class Client {
948
1091
  *
949
1092
  * `speaker` is the tag written at store time (`metadata.speaker`) — `"me"` for the
950
1093
  * assistant's own words, otherwise a person's name. Same cursor paging as
951
- * `listImages`.
1094
+ * `listImages`; `limit` is 5-20.
952
1095
  *
953
1096
  * `points_to_delete` is the count to show before anyone confirms a delete of this
954
1097
  * speaker's memories.
@@ -969,9 +1112,9 @@ export declare class Client {
969
1112
  *
970
1113
  * Ask rather than hard-code: a name copied from the docs freezes a caller to the
971
1114
  * catalogue as it was that day, and anything added later stays invisible. The
972
- * service is the authority. What
973
- * comes back depends on the model (delivery forms need Scroll 1.2+), so pass
974
- * `withModel()` if you want another model's catalogue.
1115
+ * service is the authority. What comes back depends on the model (`forms` is empty
1116
+ * on one that does not list `forms` in its capabilities), so pass `withModel()` if
1117
+ * you want another model's catalogue.
975
1118
  *
976
1119
  * const { engrams, forms } = await mem.listEngrams();
977
1120
  */
@@ -984,7 +1127,10 @@ export declare class Client {
984
1127
  /** List your stores: `[{ user_id, created_at, canonical_id? }, ...]` (`default`
985
1128
  * first). Each `user_id` is the id the store was created with. */
986
1129
  listStores(): Promise<StoreInfo[]>;
987
- /** Delete a store and ALL its memories. Returns `{ user_id, status }`. */
1130
+ /** Delete a store and ALL its memories. Returns `{ user_id, status }`.
1131
+ * A delete retried after an ambiguous failure (408/502/503/504 or a dropped
1132
+ * connection) that then answers 404 rejects with a `NotFoundError` saying an
1133
+ * earlier attempt may already have deleted it. */
988
1134
  deleteStore(userId: string): Promise<StoreOpResult>;
989
1135
  /** Register a person for this store. Speakers are explicit: register once, then
990
1136
  * store with `{ speaker }`. `"me"` (the assistant itself) never needs
@@ -992,67 +1138,82 @@ export declare class Client {
992
1138
  addSpeaker(speaker: string, userId?: string): Promise<SpeakerOpResult>;
993
1139
  /** The store's registered people, each with its memory count. */
994
1140
  listSpeakers(userId?: string): Promise<SpeakersList>;
995
- /** Unregister a person. Their memories stay; the name tag goes. */
1141
+ /** Unregister a person. Their memories stay; the name tag goes. Retried like
1142
+ * `deleteStore`, with the same note on a 404 after an ambiguous failure. */
996
1143
  removeSpeaker(speaker: string, userId?: string): Promise<SpeakerOpResult>;
997
1144
  /** Delete a single memory by id. Pass `undefined` as `userId` for the default
998
- * store — it is positional here, not omittable as it is in Python. */
1145
+ * store — it is positional here. */
999
1146
  delete(userId: string | undefined, memoryId: string): Promise<StatusResult>;
1000
1147
  /** Delete ALL memories for a store (GDPR erase). `userId` is required on purpose -
1001
1148
  * this is destructive, so it never falls back to the default store. */
1002
1149
  deleteAll(userId: string): Promise<StatusResult>;
1003
1150
  private post;
1004
- /**
1005
- * One request that answers with BYTES rather than JSON.
1006
- *
1007
- * Only `/memory/image` does this, and it is why this cannot go through `request()`:
1008
- * that path reads the body as text and insists the result parses to a JSON object.
1009
- * Feeding it a JPEG would throw "invalid JSON in response" — a confusing error for a
1010
- * call that actually succeeded.
1011
- *
1012
- * Errors still arrive as JSON, so those are handed back to the normal machinery: on
1013
- * a non-2xx we re-read the body as text and reuse `errorFor`, which keeps 404
1014
- * (`NotFoundError`) and 401 behaving the same as everywhere else.
1015
- */
1151
+ /** A DELETE that removes something: a 404 after an ambiguous failure says an earlier
1152
+ * attempt may already have removed it. */
1153
+ private remove;
1016
1154
  /** Where this call's budget runs out, or `undefined` when it has none. Computed
1017
1155
  * once per call, not per attempt — a budget recomputed each attempt is not a
1018
1156
  * budget. */
1019
1157
  private deadlineAt;
1020
1158
  /** The abort wiring for ONE attempt: this SDK's per-attempt timeout, the caller's
1021
1159
  * signal, and whatever is left of the overall deadline — whichever fires first.
1022
- *
1023
- * One function, two callers (`request` and `requestBytes`), because a guard living
1024
- * in one of two request paths is exactly how `getImage` ended up with no retry loop
1025
- * while the module doc promised every call had one. */
1160
+ * With no time left it throws `answer` (the refusal that led here), or the
1161
+ * deadline error when there is none. */
1026
1162
  private beginAttempt;
1027
1163
  /** What to say when an attempt was cut short. The three reasons need different
1028
1164
  * words: a timeout may have landed server-side, a cancellation certainly did not
1029
1165
  * matter to the caller, and an exhausted budget is the caller's own setting. */
1030
1166
  private abortMessage;
1031
- /** Sleep between attempts — but wake the moment the caller aborts, and give up
1032
- * rather than wait out a backoff the budget cannot cover. A backoff that runs to
1033
- * completion after the caller gave up wastes exactly as long as the request it was
1034
- * waiting to repeat.
1167
+ /** Whether a wait of `ms` still leaves time before the deadline. */
1168
+ private fits;
1169
+ /** Sleep between attempts, waking the moment the caller aborts. */
1170
+ private pause;
1171
+ /** The error for a request that got no answer. The message names the cause code
1172
+ * (ECONNREFUSED, ENOTFOUND, CERT_HAS_EXPIRED, …) and never carries the query
1173
+ * string, which can hold a store id, or the base URL's userinfo. With either in
1174
+ * the URL the transport error is not kept as the cause, since its own message can
1175
+ * quote the URL. */
1176
+ private networkError;
1177
+ /** A redirect: a 3xx, or one a custom fetch followed. Where a custom fetch sent the
1178
+ * request (`res.url`) is its own business. */
1179
+ private isRedirected;
1180
+ /** The error an answer carries: the service's message (control characters removed,
1181
+ * capped), request id, `type` and the rest of its error object. `unread` says why
1182
+ * the body is missing, when it could not be read. */
1183
+ private errorFromAnswer;
1184
+ /**
1185
+ * Send one call, retrying what can be retried, and return the answer with its body
1186
+ * read (under the same timeout, so a body that trickles in cannot stall the call).
1187
+ * The error body of an answer about to be retried gets at most a second.
1188
+ *
1189
+ * Retried: 429, and a 409 whose error carries `retry_after_ms` (another write to the
1190
+ * store was in flight; nothing was stored), on every method; 408/502/503/504 and
1191
+ * dropped connections on idempotent methods; connect failures on every method. A
1192
+ * retry whose wait is over the cap, or does not fit the deadline, is not made: the
1193
+ * call fails with the error of the response it has. So does a retry the deadline
1194
+ * leaves no time to send, and the retry of an idempotent method or of a POST that
1195
+ * only reads that the deadline cuts short. Any other retry cut short stays a status-0
1196
+ * deadline error: a write may have been applied.
1197
+ */
1198
+ private send;
1199
+ /**
1200
+ * One request that answers with BYTES rather than JSON.
1035
1201
  *
1036
- * Clamping the wait to what is left and retrying anyway is the same answer as
1037
- * having no deadline at all: the call still spends the whole allowance, and the one
1038
- * attempt it buys has nothing left to finish in. If the wait does not fit, the
1039
- * budget is already decided. */
1040
- private backoffSleep;
1202
+ * Only `/memory/image` does this: `request()` insists the body parses to a JSON
1203
+ * object, and a JPEG would come back as "invalid JSON in response" for a call that
1204
+ * succeeded. Retries, timeouts and errors are the same as every other call's.
1205
+ */
1041
1206
  private requestBytes;
1042
1207
  /** Validate an idempotency key BEFORE the network. The API answers a malformed
1043
1208
  * key with a 400, which on a retry path reads as "my write failed" when in fact
1044
1209
  * it was never attempted — cheaper and clearer to reject it here. */
1045
1210
  private idemHeader;
1046
- /** Seconds→ms to sleep before retry `attempt` (0-based). Honors Retry-After. */
1211
+ /** Milliseconds to sleep before retry `attempt` (0-based): exponential with jitter,
1212
+ * or what a valid `Retry-After` asks for. */
1047
1213
  private backoffMs;
1048
1214
  /** Read the body with a hard size cap, so a broken/hostile endpoint can't
1049
- * make the process buffer gigabytes. */
1050
- private readCapped;
1051
- /** The same cap, for a body that is not text.
1052
- *
1053
- * `arrayBuffer()` would buffer whatever arrives. The cap exists for a hostile or
1054
- * broken `baseUrl`, and an endpoint that returns megabytes is where that costs the
1055
- * most. One implementation, two callers, so they cannot drift. */
1215
+ * make the process buffer gigabytes. With `withinMs`, a body still arriving after
1216
+ * that long is dropped and the read fails. */
1056
1217
  private readCappedBytes;
1057
1218
  private request;
1058
1219
  }