narrarium-engine 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -157,7 +157,7 @@ Data the web app's pages used to have to guess (from the text of a step, from th
157
157
  | `conflict` | A file changed under the step and the retries are used up (`BookConflictError`); or, on a personal server, the server's work conflicts with GitHub (code `github_conflict`, with `githubConflicts` in the detail: the author chooses the version of each file, see *The personal server client*). |
158
158
  | `unknown` | Everything else. |
159
159
 
160
- `errorDetail` is `{ status?, endpoint?, model?, provider?, integration?, retryAfterMs?, attempt?, retries?, timeoutMs?, timeoutPhase?, githubConflicts? }`, short and with no secret in any field: `githubConflicts` is there only for a conflict with GitHub (an error whose `code` is `GITHUB_CONFLICT_CODE`, `"github_conflict"`, and whose `total` says how many files: never retried, the author chooses), a whole number from 1 (read back from a file the same way); `status` is the HTTP status when the provider answered; `retryAfterMs` is what the provider asked for with `Retry-After` in milliseconds, on a 429 or a 503 only and only when it said (the engine's client keeps at most five minutes of it, `0` is a value, and a value read from a file is a whole number from 0 to a day, else it is dropped), so that a client can say *the provider asks to wait 30 s* without guessing it from the retry; `endpoint` is only the **origin** of the integration's address (`new URL(address).origin`: never a path, a query, a fragment or credentials, and nothing at all for an address that is not a web address); `model`, `provider` and `integration` (the id) are passed through `redactSecrets` and cut at 160 characters. `attempt` and `retries` are there only for a failure that is retried: the retry it belongs to (the one that followed it, or the last one made when the run gave up) and how many retries this kind of failure gets, the numbers of the `failureRetry` insight; a failure that is never retried (a 401) has neither. `timeoutPhase` (`"start"`, `"idle"` or `"total"`) and `timeoutMs` are there only for a timeout of the engine's client: which deadline ran out (the provider did not begin answering, it went silent while it answered, or the call took longer than any call may) and how long it was, in milliseconds (a value read from a file is a whole number from 1 ms to a day, else it is dropped); see *Timeouts and streaming*. Where an error came from is `AiProviderError.target` (`{ provider, model, integrationId, endpoint? }`, the endpoint already an origin), which the engine's client sets on the error of the last candidate it tried; it is separate from the error's own `model`, `provider` and `integrationId`, whose presence means that the model had started to answer and is billed. A state written before the errors were classified has `lastError` with a message and no kind: `summary.lastError` then has none either.
160
+ `errorDetail` is `{ status?, endpoint?, model?, provider?, integration?, retryAfterMs?, attempt?, retries?, timeoutMs?, timeoutPhase?, githubConflicts?, transport? }`, short and with no secret in any field: `githubConflicts` is there only for a conflict with GitHub (an error whose `code` is `GITHUB_CONFLICT_CODE`, `"github_conflict"`, and whose `total` says how many files: never retried, the author chooses), a whole number from 1 (read back from a file the same way); `status` is the HTTP status when the provider answered; `retryAfterMs` is what the provider asked for with `Retry-After` in milliseconds, on a 429 or a 503 only and only when it said (the engine's client keeps at most five minutes of it, `0` is a value, and a value read from a file is a whole number from 0 to a day, else it is dropped), so that a client can say *the provider asks to wait 30 s* without guessing it from the retry; `endpoint` is only the **origin** of the integration's address (`new URL(address).origin`: never a path, a query, a fragment or credentials, and nothing at all for an address that is not a web address); `model`, `provider` and `integration` (the id) are passed through `redactSecrets` and cut at 160 characters. `attempt` and `retries` are there only for a failure that is retried: the retry it belongs to (the one that followed it, or the last one made when the run gave up) and how many retries this kind of failure gets, the numbers of the `failureRetry` insight; a failure that is never retried (a 401) has neither. `timeoutPhase` (`"start"`, `"idle"` or `"total"`) and `timeoutMs` are there only for a timeout of the engine's client: which deadline ran out (the provider did not begin answering, it went silent while it answered, or the call took longer than any call may) and how long it was, in milliseconds (a value read from a file is a whole number from 1 ms to a day, else it is dropped); see *Timeouts and streaming*. Where an error came from is `AiProviderError.target` (`{ provider, model, integrationId, endpoint? }`, the endpoint already an origin), which the engine's client sets on the error of the last candidate it tried; it is separate from the error's own `model`, `provider` and `integrationId`, whose presence means that the model had started to answer and is billed. `transport` is there for a call that failed after the provider answered and whose response said something beyond its status (it carried bytes, a request id, an end or a finish reason): `{ status?, bytes?, chunks?, events?, lastChunkAfterMs?, silentMs?, end?, finishReason?, usageReceived?, usageRequested?, tail?, requestId?, partialCharacters? }`, the numbers of `AiTransportDiagnostics`, the last 300 characters of the stream (credentials replaced, no reasoning) and how many characters of the reply had arrived; every field is checked when a state is read, and a file cannot make one longer or put a key in it. A state written before the errors were classified has `lastError` with a message and no kind: `summary.lastError` then has none either.
161
161
 
162
162
  **The retry that is waiting.** While the run waits to try a failed step again, `summary.retry` is `{ at, attempt, retries }`: `at` is the ISO time of the next attempt, `attempt` and `retries` those of the `failureRetry` insight (`retry 2 of 3`). In a wait of «Retry later» it is `{ at, attempt, retries, longTerm: { cycle, cycles } }`: `attempt` and `retries` are then the quick retries that were made, `cycle` the cycle of the wait (from 1) and `cycles` how many there are, `null` for no limit (the numbers of the `longRetryWait` insight: «ripartenza 2 di 3», *restart 2 of 3*); the rest of the summary is what it always was. It is never saved, and it is the fourth field of the summary that only a live session knows (see *What the summary says*). Every change is a `state` event, so a client counts down without guessing: one event when the wait begins (right after the `failureRetry` or `longRetryWait` insight), one when it is over and the attempt starts (the summary has no `retry` then; after «Retry now» that event follows the `retrySkipped` insight at once), and the last summary of a run that ends, or is paused, during the wait has none. A host that gets the state from a `state` event replaces its summary by the newest one it has seen, and so the retry goes away. A client offers «Retry now» (`session.retryNow()`, or `retryNow(bookId)` of the server's client) while `retry` is there.
163
163
 
@@ -606,8 +606,8 @@ What every host gets, whatever its options:
606
606
  | Timeouts | Three, in every host: how long the provider has to begin answering (an integration's `requestTimeoutMs`, else `options.defaultTimeoutMs`, else `DEFAULT_REQUEST_TIMEOUT_MS`, 600 s; never under 30 s), the longest silence while it answers (`idleTimeoutMs`, 600 s) and the most one call may take (4 h). See *Timeouts and streaming*. |
607
607
  | Hooks | `onAttempt(attempt)`: `attemptId`, the effective `messages` (with the JSON instruction a model without tools receives), the output limit, `stream`, `streamMode`, `tools`, `endpoint`, `timeoutMs` and `timeouts` (the three deadlines: see *Timeouts and streaming*), `toolsOnly` (whether Tools only was in force), `thinking` (the level sent, absent when none was), `reasoningParameter` (where it went, only when it went as the chat-template argument: see *Thinking*), `skipped` (the models left out, absent when none was: see *Tools only* and *Thinking*) and `notes` (what the attempt does not do that the configuration asked, because of what the model declares, in English; absent when there is nothing to say: see *Declared capabilities of a model*). `onAttemptEnd(end)`: the same `attemptId`, `outcome` (`ok`, `failed`, `cancelled`), `usage`, `cost`, `usageKnown`, `costKnown`, the reply `text` or the `error` (without credentials), `failureKind` (`timeout`, `cancelled`, `provider`), `status`, `retryAfterMs`, `timeoutMs` and `timeoutPhase` (for a timeout), `streamed`, `firstByteMs`, `toolCalled`, `durationMs` and, once a reply was read, `finishReason` (the provider's own word, empty when it said none), `replyCharacters` (its text without the reasoning, and the arguments of its function, `{}` being none) and `reasoningCharacters` (the reasoning field of the provider, and a `<think>` block in the text: the count, never the words), for every attempt that was sent, failed ones included; the three facts are there also for a reply the engine refused after reading it (one that was cut, or filtered), and absent for an attempt that never got one (a refusal, a connection that failed, a deadline that ran out first). The `messages` of `onAttempt` are copies and carry the roles and the parts (an image with its data URL), so a listener cannot change what is sent. A hook that throws never breaks a call. |
608
608
  | Approving endpoints | `effectiveAiBase(integration, githubModelsBaseUrl?)` is the origin and path every request of an integration starts with, defaults included (`https://api.openai.com/v1`, `https://models.github.ai/inference`). A host that approves where API keys may be sent should compare these. |
609
- | Wire format | Server-sent events with several `data:` lines are joined with a newline; the pieces of a forced function call (`delta.tool_calls[].function.arguments`) are joined into the arguments of the reply, and a last piece that carries the whole `message.tool_calls` is read too; a JSON reply to a streaming request (a server that ignores `stream`) is read as the reply; an `error` in a 200 reply is a provider error. |
610
- | Errors | `AiProviderError` carries `status`, `retryable`, `transient` (it depends on the moment: 408, 429, 502, 503, 504, network), `retryAfterMs` (the `Retry-After` of a 429 or 503, at most five minutes), `timedOut` with `timeout` (which deadline ran out, for how long), `truncated` and `reasoningOnly` (the reply was cut while the model reasoned: seen as reasoning, or, with nothing written at all, from a model declared as reasoning). `AiToolsRequiredError` (nothing can be asked: Tools only is on and no model can call a function; see *Tools only*) is the error of a call that was never sent. Keys, `Bearer …`, `api-key: …`, `?key=…` and `sk-…` are removed from every message (`redactSecrets`), also before the runner saves it. The error of a candidate that was tried carries `target` (`{ provider, model, integrationId, endpoint? }`, the endpoint only an origin: see *What the interface reads*). |
609
+ | Wire format | Server-sent events with several `data:` lines are joined with a newline; the pieces of a forced function call (`delta.tool_calls[].function.arguments`) are joined into the arguments of the reply, and a last piece that carries the whole `message.tool_calls` is read too; a JSON reply to a streaming request (a server that ignores `stream`) is read as the reply; an `error` in a 200 reply is a provider error, and so is an `event: error` whatever its data is. A line ends with LF, CR or CRLF (the three that the SSE specification allows, a CRLF cut between two chunks included); a `data:` with no space after it, a last line with no newline, and `: comments`, `id:` and `retry:` lines are read as they should be; a character that a chunk cuts in two is kept until the rest comes. The tokens are read from whichever chunk carries `usage` (`prompt_tokens`/`completion_tokens`, or `input_tokens`/`output_tokens`; the cached ones from `prompt_tokens_details.cached_tokens`, `input_tokens_details.cached_tokens`, `prompt_cache_hit_tokens` or `cache_read_input_tokens`); a count of zero never replaces a real one. |
610
+ | Errors | `AiProviderError` carries `status`, `retryable`, `transient` (it depends on the moment: 408, 429, 502, 503, 504, Cloudflare's 520-524, network, a stream that stopped), `transport` and `partialText` (what the transport saw of the call, and the reply that had arrived: see *A stream that stops halfway*), `retryAfterMs` (the `Retry-After` of a 429 or 503, at most five minutes), `timedOut` with `timeout` (which deadline ran out, for how long), `truncated` and `reasoningOnly` (the reply was cut while the model reasoned: seen as reasoning, or, with nothing written at all, from a model declared as reasoning). `AiToolsRequiredError` (nothing can be asked: Tools only is on and no model can call a function; see *Tools only*) is the error of a call that was never sent. Keys, `Bearer …`, `api-key: …`, `?key=…` and `sk-…` are removed from every message (`redactSecrets`), also before the runner saves it. The error of a candidate that was tried carries `target` (`{ provider, model, integrationId, endpoint? }`, the endpoint only an origin: see *What the interface reads*). |
611
611
 
612
612
  ### Timeouts and streaming
613
613
 
@@ -627,6 +627,16 @@ The author's `signal` wins over all three: a call cancelled is an `AbortError` a
627
627
 
628
628
  **Node's own limits.** In Node the platform's `fetch` (undici) has two limits of its own, 300 s each, whatever the engine's deadlines say: `headersTimeout` (the headers of a response) and `bodyTimeout` (the silence between two pieces of a body). A host that runs the engine in Node and wants a longer silence than five minutes (a model that thinks for ten without sending anything) passes, as `options.fetch`, a `fetch` over a dispatcher with those two raised, or off (`0`).
629
629
 
630
+ **What the server does about it.** The personal server does not have this limit: the `fetch` of its process is its outbound guard (`installOutboundNetwork`, on `node:http`), which limits the connection and nothing after it, so there the idle deadline above is the only limit of a silence (its tests pin it). The measured limit of Node's own `fetch` is 300.9 s on Node 22 and 24: a body that is silent that long ends with `TypeError: terminated` (`BodyTimeoutError`), a response whose headers take that long with `fetch failed` (`HeadersTimeoutError`), and the client reads the first as a lost connection.
631
+
632
+ **Gateways in between.** Whatever the idle deadline is, a gateway between the app and the model has its own, and the shortest one decides. LlmProxy resets the connection (`context.Abort()`: no last chunk, no `[DONE]`, no error event) when its runtime sends nothing for `Gateway:UpstreamIdleTimeoutSeconds` (300 s unless its owner changed it; 5 s to 24 h) or when the runtime's connection breaks, and answers JSON errors (`error.code`: `capacity_exhausted`, `model_not_running`, `capacity_lease_lost`, `upstream_unreachable`, `upstream_timeout`, `rate_limit_exceeded`, `token_budget_exceeded`...) only before the first byte. Cloudflare in front of it closes a connection that has been silent for 100 s (`524`). LlmProxy starts its response before the model says a word, so a long prefill is a silence of the *stream*: **Idle** is its limit, not **Start**. To let a model think for longer than a gateway allows, raise the gateway's limit and the integration's **Idle timeout** together (the gateway's first); and where a call ends as "the connection was lost" with the transport saying that the last chunk came a round number of seconds before the end (`silentMs` of about 100 000 or 300 000), it is the gateway that cut a silent stream. Without a keep-alive from the model there is nothing the client can do about that, and `: keep-alive` comments from a gateway that sends them are enough to keep the count going.
633
+
634
+ **A stream that stops halfway.** When the provider has begun to answer and the reply does not reach its end, the client does not return it and does not forget it: it throws an `AiStreamInterruptedError` (an `AiProviderError`, always `retryable` and `transient`, so the run repeats the step as it repeats any failure of the moment, and does not give up on two identical messages) whose `how` says what happened: `lost` (the connection broke), `ended` (the provider closed the stream without `[DONE]` and without a finish reason, or with one the client does not know), `provider-error` (the runtime reported a failure inside the stream, whatever status it gave it: a 500, a crash, no status) or `provider-abort` (the finish reason was `abort`, `error`...). A failure that cannot change by asking again is final even then: an invalid request (a 4xx other than 408, 409 and 429) or the credentials refused, and one that is reported before the model wrote a word keeps the rule it had (`transient` only when its status or words say so). What had arrived is kept: `error.partialText` is the text, else the arguments of the function, of at most `MAX_PARTIAL_CHARACTERS` characters (never the reasoning, never a credential), and the client **never applies it**. The tokens of the call are an estimate (`usageKnown: false`) unless the usage chunk came before it stopped.
635
+
636
+ `error.transport` (and `end.transport` of `onAttemptEnd`, for the attempt that failed and, as figures only, for one that worked) says what the transport saw: `status` (the response's: a stream that is cut still began with a 200), `bytes`, `chunks` and `events` that arrived, `lastChunkAfterMs` and `lastChunkAt`, `silentMs` (the silence before the end), `tail` (the last 300 characters that arrived, as they came, with credentials replaced and the words of the reasoning left out; only for a failed attempt, and words of the model that a host should treat as it treats the reply), `finishReason`, `usageReceived` and `usageRequested` (whether the provider reported the tokens, and whether the request asked it to), `end` (`done`: `[DONE]`; `closed`: closed without it; `reset`: the connection broke; `error`: the provider reported a failure; `timeout`: a deadline ran out) and `requestId` (`X-LlmProxy-Request-Id`, `X-Request-Id`...: what the provider or its gateway calls the request). The run keeps a short form of it in `errorDetail.transport` (see *What the interface reads*), the debug panel of the app shows its figures and never the tail, and no field of it is ever a key.
637
+
638
+ **The tokens of a stream, and `stream_options`.** The client asks every provider for them (`stream_options: { include_usage: true }`), reads them from whichever chunk carries them and, when none comes (a provider that ignores the option, a stream that stopped before the usage chunk, a count of zero), estimates them from what arrived and says so: `usageKnown: false`, `costKnown: false`, and the run counts the call among its «calls without token count». A provider that **refuses** the option (400 or 422 naming `stream_options` or `include_usage`) is asked again, at once, without it, and the attempt goes on as one attempt; `FetchAiOptions.usageOptionRefusals` is where that is remembered (default: one set for each client, so every call asks once; an embedder that wants to ask once for all its calls shares one set).
639
+
630
640
  **Progress.** `AiRequest.onProgress({ bytes, events, characters })` is called while a reply streams, at most every 250 ms, with numbers and never a word of the reply: the bytes received (comments included), the events of the stream and the characters of the reply so far (text and function arguments, not reasoning). It is how a host says "the model is answering (12 KB)" for a structured reply. A listener that throws never breaks the call.
631
641
 
632
642
  **Closures and limits.** A stream that closes without `[DONE]` and without a `finish_reason` is still *incomplete* (retried as a transient failure); the reader is cancelled however a call ends, the end of the stream aside: after `[DONE]`, an error in the stream, a deadline, the author's cancel. Two limits stop a model that loops: **256 MB** of transport (`MAX_STREAM_TRANSPORT_BYTES`; the JSON envelope of every piece counts) and **16 million characters** of reasoning (`MAX_STREAM_REASONING_CHARACTERS`). Each is an error that says what it used and what to do ("Lower the thinking effort of the model or choose another one") and is **not** retried, because the same loop would come back; what it used is counted in the cost.
@@ -640,9 +650,9 @@ The author's `signal` wins over all three: a call cancelled is an `AbortError` a
640
650
 
641
651
  An integration without its own value says `the default provider timeout` or `the default idle timeout` and where to change it.
642
652
 
643
- **What the hooks say.** `onAttempt(attempt)` carries `timeouts: { startMs, idleMs, capMs, raised?: { from } }` (the deadlines as they are applied, `raised` when the minimum lifted the provider timeout) and `streamMode`; `timeoutMs` is `timeouts.startMs`. `onAttemptEnd(end)` carries `streamed` (the reply was read as a stream), `firstByteMs` (milliseconds to the first byte of its body, or of the response for a JSON reply; absent when nothing arrived), `toolCalled` (for a structured request, whether the model delivered the result as a function call; absent otherwise) and, for a timeout, `timeoutMs` and `timeoutPhase`.
653
+ **What the hooks say.** `onAttempt(attempt)` carries `timeouts: { startMs, idleMs, capMs, raised?: { from } }` (the deadlines as they are applied, `raised` when the minimum lifted the provider timeout) and `streamMode`; `timeoutMs` is `timeouts.startMs`. `onAttemptEnd(end)` carries `streamed` (the reply was read as a stream), `firstByteMs` (milliseconds to the first byte of its body, or of the response for a JSON reply; absent when nothing arrived), `toolCalled` (for a structured request, whether the model delivered the result as a function call; absent otherwise) and, for a timeout, `timeoutMs` and `timeoutPhase`. It also carries `transport` (see *A stream that stops halfway*: for an attempt that worked, its figures only) and, for an attempt that failed after the model had begun to answer, `partialText`.
644
654
 
645
- **Providers that cannot stream.** A provider that rejects `stream_options`, or does not stream with functions, answers 400: the error then adds `If this provider cannot stream its replies, set "Streaming" of the integration "…" to "off"` (only when its own message talks about streaming), and `streamMode: "off"` brings the old behavior back for that integration. A model that cannot stream while the others of its integration can declares `supportsStreaming: false` instead (see *Declared capabilities of a model*): only that model is called without `stream`. Leave a model that reasons streaming wherever you can: its reasoning counts against the output limit, and a reply that does not stream is silent until it is whole, which a proxy or a tunnel may cut (LlmProxy's own documentation says the same of its reasoning models). A connection that is lost while the provider answers is told with what to check: the proxy or the tunnel between the app and the provider.
655
+ **Providers that cannot stream.** A provider that rejects `stream_options` is asked again without it (see *The tokens of a stream, and `stream_options`*); one that does not stream with functions answers 400, and the error then adds `If this provider cannot stream its replies, set "Streaming" of the integration "…" to "off"` (only when its own message talks about streaming), and `streamMode: "off"` brings the old behavior back for that integration. A model that cannot stream while the others of its integration can declares `supportsStreaming: false` instead (see *Declared capabilities of a model*): only that model is called without `stream`. Leave a model that reasons streaming wherever you can: its reasoning counts against the output limit, and a reply that does not stream is silent until it is whole, which a proxy or a tunnel may cut (LlmProxy's own documentation says the same of its reasoning models). A connection that is lost while the provider answers is told with what to check: the proxy or the tunnel between the app and the provider.
646
656
 
647
657
  ### Tools only
648
658
 
@@ -1 +1 @@
1
- {"version":3,"file":"deadlines.d.ts","sourceRoot":"","sources":["../../src/ai/deadlines.ts"],"names":[],"mappings":"AACA,OAAO,EAAgD,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,yJAAyJ;AACzJ,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,2IAA2I;AAC3I,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,8GAA8G;AAC9G,eAAO,MAAM,oBAAoB,QAAqB,CAAC;AAEvD,8FAA8F;AAC9F,MA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E,SAAS,EAAE,gBAAgB,GAAG,aAAa,CAiFtG"}
@@ -82,12 +82,13 @@ export function startClock(parent, deadlines) {
82
82
  let expired;
83
83
  let over = false;
84
84
  let watching = false;
85
- let reject = () => undefined;
86
- const interruption = new Promise((_resolve, rejectIt) => {
87
- reject = rejectIt;
88
- });
89
- // Nobody may be racing it when it rejects: that is not an unhandled rejection.
90
- interruption.catch(() => undefined);
85
+ /** Why the attempt was interrupted, once it was: what the waits that are open, and the ones that begin later, are rejected with. */
86
+ let interruption;
87
+ /**
88
+ * The waits that are open (`guard`): each one is its own promise, and leaves this set when its own promise settles, so that a stream of a hundred thousand reads leaves nothing
89
+ * behind (racing every read against one promise that lives as long as the call would keep a reaction on it for each read until the call is over).
90
+ */
91
+ const waits = new Set();
91
92
  let capTimer;
92
93
  let startTimer;
93
94
  let idleTimer;
@@ -95,7 +96,10 @@ export function startClock(parent, deadlines) {
95
96
  if (over || controller.signal.aborted)
96
97
  return;
97
98
  controller.abort(reason);
98
- reject(reason);
99
+ interruption = { reason };
100
+ for (const rejectWait of [...waits])
101
+ rejectWait(reason);
102
+ waits.clear();
99
103
  };
100
104
  const expire = (phase, ms) => () => {
101
105
  if (over || controller.signal.aborted)
@@ -120,7 +124,20 @@ export function startClock(parent, deadlines) {
120
124
  }
121
125
  return {
122
126
  signal: controller.signal,
123
- guard: (promise) => Promise.race([interruption, promise]),
127
+ guard: (promise) => new Promise((resolve, rejectWait) => {
128
+ if (interruption) {
129
+ rejectWait(interruption.reason);
130
+ return;
131
+ }
132
+ waits.add(rejectWait);
133
+ promise.then((value) => {
134
+ waits.delete(rejectWait);
135
+ resolve(value);
136
+ }, (error) => {
137
+ waits.delete(rejectWait);
138
+ rejectWait(error);
139
+ });
140
+ }),
124
141
  streaming() {
125
142
  if (over || controller.signal.aborted)
126
143
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"deadlines.js","sourceRoot":"","sources":["../../src/ai/deadlines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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GAAG,EAAE,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;QACpD,OAAO;YACL,IAAI,GAAG,IAAI,CAAC;YACZ,KAAK,MAAM,KAAK,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;gBAAE,IAAI,KAAK,KAAK,SAAS;oBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YACpG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;YAC9C,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACvF,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { AiPricingConfig, AiRuntimeConfig, AiStreamMode } from "./config.js";
2
2
  import { type AiReasoningEffort } from "./request.js";
3
- import { type AiMessage, type AiPort, type AiTimeoutPhase, type AiUsage } from "./types.js";
3
+ import { type AiMessage, type AiPort, type AiTimeoutPhase, type AiTransportDiagnostics, type AiUsage } from "./types.js";
4
4
  export { DEFAULT_REQUEST_TIMEOUT_MS, MIN_REQUEST_TIMEOUT_MS, TOTAL_REQUEST_CAP_MS } from "./deadlines.js";
5
5
  /**
6
6
  * Raw bytes of a stream include the JSON envelope of every piece (a few hundred bytes for a few characters), so a long reasoning phase is
@@ -113,6 +113,16 @@ export interface FetchAiAttemptEnd {
113
113
  replyCharacters?: number;
114
114
  /** Characters of reasoning that came with it (the reasoning field of the provider, and a `<think>` block in the text). Only the count, never the words. Present with `finishReason`. */
115
115
  reasoningCharacters?: number;
116
+ /**
117
+ * What the transport saw of the call: the HTTP status, the bytes and chunks that arrived, when the last one did and what the end of them said, how the provider ended the reply, whether it reported
118
+ * the tokens, and how the stream ended. It is what tells a stream that was cut from one that was slow. Absent when no response arrived (the connection failed first). Never a key.
119
+ */
120
+ transport?: AiTransportDiagnostics;
121
+ /**
122
+ * For an attempt that failed after the model had started to answer: the reply that had arrived (its text, or the arguments of its function call), at most `MAX_PARTIAL_CHARACTERS` characters, cleaned of
123
+ * credentials. The engine does not apply it; this is where a host finds it. Absent when none had arrived.
124
+ */
125
+ partialText?: string;
116
126
  durationMs: number;
117
127
  }
118
128
  /** One side of a fallback that crosses a privacy boundary. */
@@ -149,6 +159,14 @@ export interface FetchAiOptions {
149
159
  * where it is. Throw to cancel the whole call.
150
160
  */
151
161
  acknowledgeFallback?: (from: FetchAiFallbackTarget, to: FetchAiFallbackTarget, info: FetchAiFallbackInfo) => boolean | Promise<boolean>;
162
+ /**
163
+ * Where the client remembers the requests that a provider refused because of `stream_options` (`include_usage`), so that they are sent without it from then on: the key is the address of the
164
+ * request. The option is asked of every provider (it is how a stream reports its tokens), and a provider that answers 400 or 422 naming it is asked again, at once, without it and not again after
165
+ * (its replies then carry no token count, and say so: their usage is an estimate). The default is one set for each client, so a call asks every address once, whatever came before it: the
166
+ * app's hosts leave it at that, so that the same configuration builds the same requests in every host, at the price of one refusal (which costs nothing: it is answered before any work) per call
167
+ * to a provider that refuses. An embedder that wants to ask once for all its calls shares one set between its clients.
168
+ */
169
+ usageOptionRefusals?: Set<string>;
152
170
  }
153
171
  /**
154
172
  * OpenAI-compatible chat client built on `fetch`, usable from Node and browsers.
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-client.d.ts","sourceRoot":"","sources":["../../src/ai/fetch-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGlF,OAAO,EAAmC,KAAK,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AAIzG,OAAO,EAAiE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAgE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAGzN,OAAO,EAAE,0BAA0B,EA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