zidane 5.13.26 → 5.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-CjAoILwj.js → acp-DgKEJH3P.js} +7 -7
- package/dist/{acp-CjAoILwj.js.map → acp-DgKEJH3P.js.map} +1 -1
- package/dist/acp-cli.js +11 -6
- package/dist/acp-cli.js.map +1 -1
- package/dist/acp.d.ts +2 -2
- package/dist/acp.js +1 -1
- package/dist/{tools-B32lZXLE.js → agent-B-cKanSC.js} +8035 -9459
- package/dist/agent-B-cKanSC.js.map +1 -0
- package/dist/{agent-DQIL5BFk.d.ts → agent-BAgOgS37.d.ts} +367 -208
- package/dist/agent-BAgOgS37.d.ts.map +1 -0
- package/dist/agent.d.ts +3 -0
- package/dist/agent.js +5 -0
- package/dist/anthropic-RGqsJlC8.js +807 -0
- package/dist/anthropic-RGqsJlC8.js.map +1 -0
- package/dist/{atomic-write-Bgtr5JPu.js → atomic-write-B7zr1ddF.js} +2 -2
- package/dist/{atomic-write-Bgtr5JPu.js.map → atomic-write-B7zr1ddF.js.map} +1 -1
- package/dist/{auth-DPrSP1YV.js → auth-C-ms5N2x.js} +33 -5
- package/dist/{auth-DPrSP1YV.js.map → auth-C-ms5N2x.js.map} +1 -1
- package/dist/cache-telemetry-BKAwsNxm.js +169 -0
- package/dist/cache-telemetry-BKAwsNxm.js.map +1 -0
- package/dist/chat/pure.d.ts +3 -3
- package/dist/chat/pure.js +1 -1
- package/dist/chat.d.ts +21 -7
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +30 -5
- package/dist/chat.js.map +1 -1
- package/dist/contexts/daytona.d.ts +1 -1
- package/dist/contexts/docker.js +0 -1
- package/dist/contexts/docker.js.map +1 -1
- package/dist/contexts/e2b.d.ts +1 -1
- package/dist/errors-CkTvg97v.d.ts +203 -0
- package/dist/errors-CkTvg97v.d.ts.map +1 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/eval.d.ts +1 -1
- package/dist/eval.js +2 -2
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +406 -1
- package/dist/headless.js.map +1 -0
- package/dist/{index-YY3vp2F2.d.ts → index-CLuLFFLa.d.ts} +88 -418
- package/dist/index-CLuLFFLa.d.ts.map +1 -0
- package/dist/{index-C5qw3pj7.d.ts → index-CgBIl2mX.d.ts} +2 -2
- package/dist/{index-C5qw3pj7.d.ts.map → index-CgBIl2mX.d.ts.map} +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.js +113 -167
- package/dist/index.js.map +1 -1
- package/dist/{logger-C2ngE8CY.d.ts → logger-CJ-lpKPy.d.ts} +2 -2
- package/dist/{logger-C2ngE8CY.d.ts.map → logger-CJ-lpKPy.d.ts.map} +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/messages-YZQLKaz2.js +1157 -0
- package/dist/messages-YZQLKaz2.js.map +1 -0
- package/dist/oauth-8LqbeI_Q.js +292 -0
- package/dist/oauth-8LqbeI_Q.js.map +1 -0
- package/dist/{messages-Iy_vEycX.js → openai-compat-0Y7jcncn.js} +27 -1379
- package/dist/openai-compat-0Y7jcncn.js.map +1 -0
- package/dist/output/stream-json.d.ts +2 -2
- package/dist/output/stream-json.js +1 -1
- package/dist/output/terminal.d.ts +2 -2
- package/dist/{presets-B9nDwmaz.js → presets-Pr02ZNcy.js} +3 -2
- package/dist/{presets-B9nDwmaz.js.map → presets-Pr02ZNcy.js.map} +1 -1
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +1 -1
- package/dist/prompt.d.ts +2 -0
- package/dist/prompt.js +210 -0
- package/dist/prompt.js.map +1 -0
- package/dist/providers/anthropic.d.ts +2 -0
- package/dist/providers/anthropic.js +2 -0
- package/dist/providers/arcee.d.ts +2 -0
- package/dist/providers/arcee.js +42 -0
- package/dist/providers/arcee.js.map +1 -0
- package/dist/providers/baseten.d.ts +2 -0
- package/dist/providers/baseten.js +66 -0
- package/dist/providers/baseten.js.map +1 -0
- package/dist/providers/cerebras.d.ts +2 -0
- package/dist/providers/cerebras.js +31 -0
- package/dist/providers/cerebras.js.map +1 -0
- package/dist/providers/local.d.ts +2 -0
- package/dist/providers/local.js +44 -0
- package/dist/providers/local.js.map +1 -0
- package/dist/providers/openai-compat.d.ts +2 -0
- package/dist/providers/openai-compat.js +2 -0
- package/dist/providers/openai.d.ts +2 -0
- package/dist/providers/openai.js +504 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openrouter.d.ts +2 -0
- package/dist/providers/openrouter.js +52 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/xai.d.ts +2 -0
- package/dist/providers/xai.js +2 -0
- package/dist/providers-DgmdYGKm.js +168 -0
- package/dist/providers-DgmdYGKm.js.map +1 -0
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +10 -2
- package/dist/restate.d.ts +1 -1
- package/dist/run-summary-DAnBZnrt.d.ts +249 -0
- package/dist/run-summary-DAnBZnrt.d.ts.map +1 -0
- package/dist/run-summary-nD3IQ4ZQ.js +253 -0
- package/dist/run-summary-nD3IQ4ZQ.js.map +1 -0
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/{session-CiA1_8SB.js → session-CqrAFAKJ.js} +2 -2
- package/dist/{session-CiA1_8SB.js.map → session-CqrAFAKJ.js.map} +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +2 -2
- package/dist/skills.d.ts +2 -2
- package/dist/system-prompt-BlsdjcUi.d.ts +139 -0
- package/dist/system-prompt-BlsdjcUi.d.ts.map +1 -0
- package/dist/timeout-CpFm0jJ6.d.ts +10 -0
- package/dist/timeout-CpFm0jJ6.d.ts.map +1 -0
- package/dist/timeout-kGGSXagK.js +84 -0
- package/dist/timeout-kGGSXagK.js.map +1 -0
- package/dist/{tool-formatters-w5oaoCS4.d.ts → tool-formatters-Ch8oRpYR.d.ts} +2 -2
- package/dist/{tool-formatters-w5oaoCS4.d.ts.map → tool-formatters-Ch8oRpYR.d.ts.map} +1 -1
- package/dist/tools/fetch-url.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tools-00_Nqazv.js +1689 -0
- package/dist/tools-00_Nqazv.js.map +1 -0
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +2 -1
- package/dist/{transcript-anchors-BUtOd-qa.js → transcript-anchors-BUmvPnis.js} +10 -9
- package/dist/{transcript-anchors-BUtOd-qa.js.map → transcript-anchors-BUmvPnis.js.map} +1 -1
- package/dist/{transcript-anchors-BJ-ESWnm.d.ts → transcript-anchors-CL9UM_M4.d.ts} +4 -4
- package/dist/{transcript-anchors-BJ-ESWnm.d.ts.map → transcript-anchors-CL9UM_M4.d.ts.map} +1 -1
- package/dist/tui.d.ts +3 -3
- package/dist/tui.js +38 -13
- package/dist/tui.js.map +1 -1
- package/dist/{turn-operations-BSSQHNq1.d.ts → turn-operations-Cj6v_ypW.d.ts} +3 -3
- package/dist/{turn-operations-BSSQHNq1.d.ts.map → turn-operations-Cj6v_ypW.d.ts.map} +1 -1
- package/dist/{turn-operations-B_XeuNp-.js → turn-operations-tG0vuBNc.js} +2 -2
- package/dist/{turn-operations-B_XeuNp-.js.map → turn-operations-tG0vuBNc.js.map} +1 -1
- package/dist/types-CyVGdbia.js.map +1 -1
- package/dist/types.d.ts +4 -3
- package/dist/xai-tPdbAGkq.js +379 -0
- package/dist/xai-tPdbAGkq.js.map +1 -0
- package/docs/ARCHITECTURE.md +4 -2
- package/docs/CHAT.md +4 -0
- package/docs/SKILL.md +31 -5
- package/package.json +63 -1
- package/dist/agent-DQIL5BFk.d.ts.map +0 -1
- package/dist/headless-2SH7dvoW.js +0 -656
- package/dist/headless-2SH7dvoW.js.map +0 -1
- package/dist/index-YY3vp2F2.d.ts.map +0 -1
- package/dist/messages-Iy_vEycX.js.map +0 -1
- package/dist/providers-BMw1D_lj.js +0 -2332
- package/dist/providers-BMw1D_lj.js.map +0 -1
- package/dist/tools-B32lZXLE.js.map +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { c as ExecutionContext, h as TaskExitInfo, l as ExecutionHandle } from "./types-Bs2oY7Ux.js";
|
|
2
|
+
import { c as ClassifiedError } from "./errors-CkTvg97v.js";
|
|
2
3
|
import { Hookable } from "hookable";
|
|
4
|
+
import { Message } from "@earendil-works/pi-ai";
|
|
3
5
|
import { OAuthCredentials } from "@earendil-works/pi-ai/oauth";
|
|
4
6
|
import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
5
7
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
@@ -226,207 +228,6 @@ interface ContextSnapshot {
|
|
|
226
228
|
*/
|
|
227
229
|
declare function buildContextBreakdown(snapshot: ContextSnapshot): ContextBreakdown;
|
|
228
230
|
//#endregion
|
|
229
|
-
//#region src/errors.d.ts
|
|
230
|
-
/**
|
|
231
|
-
* Typed error classes for agent runs.
|
|
232
|
-
*
|
|
233
|
-
* Providers classify native errors into one of these so downstream consumers
|
|
234
|
-
* can react without string-sniffing messages.
|
|
235
|
-
*
|
|
236
|
-
* Provider authors: implement `Provider.classifyError` to map native errors
|
|
237
|
-
* (SDK exceptions, HTTP responses) to a `ClassifiedError`. The loop wraps
|
|
238
|
-
* unclassified errors in `AgentProviderError` automatically.
|
|
239
|
-
*/
|
|
240
|
-
/** Kind of classified provider error */
|
|
241
|
-
type ClassifiedErrorKind = 'context_exceeded' | 'provider_error' | 'aborted' | 'tool_pairing_corruption';
|
|
242
|
-
/** Structured classification returned by `Provider.classifyError` */
|
|
243
|
-
interface ClassifiedError {
|
|
244
|
-
kind: ClassifiedErrorKind;
|
|
245
|
-
/** Upstream error code as surfaced by the provider (e.g. `context_length_exceeded`). Optional. */
|
|
246
|
-
providerCode?: string;
|
|
247
|
-
/** Optional human-readable message override. Falls back to the underlying error's message. */
|
|
248
|
-
message?: string;
|
|
249
|
-
/**
|
|
250
|
-
* Hint that the error is transient and a retry with backoff is reasonable
|
|
251
|
-
* (e.g. 429, 5xx, truncated stream). Omitted when the provider can't decide;
|
|
252
|
-
* callers should default to "do not retry" when absent to avoid hammering
|
|
253
|
-
* terminal failures (auth, invalid request).
|
|
254
|
-
*/
|
|
255
|
-
retryable?: boolean;
|
|
256
|
-
}
|
|
257
|
-
interface TypedErrorOptions {
|
|
258
|
-
/** Provider name, always set (e.g. `anthropic`, `openrouter`) */
|
|
259
|
-
provider: string;
|
|
260
|
-
/** Optional upstream error code */
|
|
261
|
-
providerCode?: string;
|
|
262
|
-
/** Original error from the provider SDK/HTTP layer */
|
|
263
|
-
cause?: unknown;
|
|
264
|
-
/** See {@link ClassifiedError.retryable}. */
|
|
265
|
-
retryable?: boolean;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Thrown when the model or provider signals that the context window was exceeded.
|
|
269
|
-
* Downstream consumers should catch this, prune history, and retry.
|
|
270
|
-
*/
|
|
271
|
-
declare class AgentContextExceededError extends Error {
|
|
272
|
-
readonly code: "context_exceeded";
|
|
273
|
-
readonly provider: string;
|
|
274
|
-
readonly providerCode?: string;
|
|
275
|
-
constructor(message: string, options: TypedErrorOptions);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Thrown when the provider returns a non-context error (auth, rate limit, server error, etc.).
|
|
279
|
-
* Catch-all for unclassified provider failures.
|
|
280
|
-
*/
|
|
281
|
-
declare class AgentProviderError extends Error {
|
|
282
|
-
readonly code: "provider_error";
|
|
283
|
-
readonly provider: string;
|
|
284
|
-
readonly providerCode?: string;
|
|
285
|
-
/**
|
|
286
|
-
* Whether a retry with backoff is likely to succeed. See
|
|
287
|
-
* {@link ClassifiedError.retryable}. Absent when the provider did not
|
|
288
|
-
* classify the error — callers should treat absent as "don't retry".
|
|
289
|
-
*/
|
|
290
|
-
readonly retryable?: boolean;
|
|
291
|
-
constructor(message: string, options: TypedErrorOptions);
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Thrown when a run is aborted by the consumer via `agent.abort()` or an external `AbortSignal`.
|
|
295
|
-
*/
|
|
296
|
-
declare class AgentAbortedError extends Error {
|
|
297
|
-
readonly code: "aborted";
|
|
298
|
-
constructor(message?: string, options?: {
|
|
299
|
-
cause?: unknown;
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Thrown by the loop when a run's cumulative cost, token consumption, or
|
|
304
|
-
* wall-clock elapsed time crosses a ceiling configured on
|
|
305
|
-
* {@link AgentBehavior.maxCostUsd} / {@link AgentBehavior.maxTotalTokens} /
|
|
306
|
-
* {@link AgentBehavior.maxWallMs}. Acts as a programmable circuit
|
|
307
|
-
* breaker for unattended runs — without this, the only built-in safety net
|
|
308
|
-
* is {@link AgentBehavior.maxTurns}, which doesn't bound a single very
|
|
309
|
-
* expensive turn (large context, deep reasoning).
|
|
310
|
-
*
|
|
311
|
-
* The breach is checked **after** each turn completes (post-`turn:after`),
|
|
312
|
-
* so the run may exceed the budget by one turn's worth of usage before
|
|
313
|
-
* tripping. Callers wanting a tighter pre-turn estimate should layer their
|
|
314
|
-
* own check on top of the `usage` hook.
|
|
315
|
-
*
|
|
316
|
-
* The harness treats this the same way as {@link AgentAbortedError}: the
|
|
317
|
-
* session run is finalized as `'aborted'`, persisted stats reflect what
|
|
318
|
-
* was actually consumed, and the parent agent re-throws so a caller's
|
|
319
|
-
* `try`/`catch` can branch on `err instanceof AgentBudgetExceededError`
|
|
320
|
-
* without string-sniffing.
|
|
321
|
-
*/
|
|
322
|
-
declare class AgentBudgetExceededError extends Error {
|
|
323
|
-
readonly code: "budget_exceeded";
|
|
324
|
-
/** Which ceiling tripped. `'cost'` → `maxCostUsd`, `'tokens'` → `maxTotalTokens`, `'wallClock'` → `maxWallMs`. */
|
|
325
|
-
readonly limit: 'cost' | 'tokens' | 'wallClock';
|
|
326
|
-
/** The configured cap (USD for `cost`, total tokens for `tokens`, ms for `wallClock`). */
|
|
327
|
-
readonly limitValue: number;
|
|
328
|
-
/** Actual consumed value at the moment the cap was crossed (same units as `limitValue`). */
|
|
329
|
-
readonly actualValue: number;
|
|
330
|
-
constructor(options: {
|
|
331
|
-
limit: 'cost' | 'tokens' | 'wallClock';
|
|
332
|
-
limitValue: number;
|
|
333
|
-
actualValue: number;
|
|
334
|
-
cause?: unknown;
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Thrown by the pre-send pairing repair when {@link AgentBehavior.strictToolPairing}
|
|
339
|
-
* is `true` and {@link ensureToolResultPairing} would otherwise patch over
|
|
340
|
-
* corruption. Strict mode opts into fail-fast for training-data collectors and
|
|
341
|
-
* any consumer that prefers to bail out rather than ship a transcript carrying
|
|
342
|
-
* a {@link SYNTHETIC_TOOL_RESULT_PLACEHOLDER}.
|
|
343
|
-
*
|
|
344
|
-
* The `repairs` field carries every repair the loop would have made — useful
|
|
345
|
-
* for postmortems and for surfacing exactly which transcripts were rejected.
|
|
346
|
-
*
|
|
347
|
-
* Note: callers consuming the chat layer (TUI/SDK presets) typically leave
|
|
348
|
-
* `strictToolPairing` off so user-facing sessions auto-heal instead of
|
|
349
|
-
* crashing.
|
|
350
|
-
*/
|
|
351
|
-
declare class AgentToolPairingError extends Error {
|
|
352
|
-
readonly code: "tool_pairing_corruption";
|
|
353
|
-
/** Provider whose wire format the corruption would have hit. */
|
|
354
|
-
readonly provider?: string;
|
|
355
|
-
/** Upstream error code when the corruption was detected from a 400 response. */
|
|
356
|
-
readonly providerCode?: string;
|
|
357
|
-
/**
|
|
358
|
-
* Repairs the harness would have performed had strict mode been off.
|
|
359
|
-
* Preserves the full diagnostic so consumers can route to telemetry,
|
|
360
|
-
* `/rewind` flows, or training-data quarantine without re-walking the
|
|
361
|
-
* transcript.
|
|
362
|
-
*/
|
|
363
|
-
readonly repairs: ReadonlyArray<{
|
|
364
|
-
mode: string;
|
|
365
|
-
callId?: string;
|
|
366
|
-
messageIndex: number;
|
|
367
|
-
}>;
|
|
368
|
-
constructor(options: {
|
|
369
|
-
message: string;
|
|
370
|
-
provider?: string;
|
|
371
|
-
providerCode?: string;
|
|
372
|
-
repairs: ReadonlyArray<{
|
|
373
|
-
mode: string;
|
|
374
|
-
callId?: string;
|
|
375
|
-
messageIndex: number;
|
|
376
|
-
}>;
|
|
377
|
-
cause?: unknown;
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Thrown (well — constructed; attach via the `tool:gate` block signal) when the
|
|
382
|
-
* union of `allowed-tools` across active skills does not permit a tool call.
|
|
383
|
-
*
|
|
384
|
-
* Produced by the allowed-tools middleware registered on `tool:gate` /
|
|
385
|
-
* `mcp:tool:gate`. The gate's `block = true` + `reason` carry the same message
|
|
386
|
-
* so consumers that don't look at this typed error still get a useful string.
|
|
387
|
-
*/
|
|
388
|
-
declare class AgentToolNotAllowedError extends Error {
|
|
389
|
-
readonly code: "tool_not_allowed";
|
|
390
|
-
/** Canonical tool name the agent tried to call. */
|
|
391
|
-
readonly toolName: string;
|
|
392
|
-
/** Aliased / wire name the LLM saw. */
|
|
393
|
-
readonly displayName: string;
|
|
394
|
-
/** Flattened union of `allowedTools` patterns across active skills. */
|
|
395
|
-
readonly allowedUnion: readonly string[];
|
|
396
|
-
/** Names of the skills currently active when the block fired. */
|
|
397
|
-
readonly activeSkills: readonly string[];
|
|
398
|
-
constructor(options: {
|
|
399
|
-
toolName: string;
|
|
400
|
-
displayName: string;
|
|
401
|
-
allowedUnion: readonly string[];
|
|
402
|
-
activeSkills: readonly string[];
|
|
403
|
-
cause?: unknown;
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Regex patterns matching common "context window exceeded" messages across providers.
|
|
408
|
-
*
|
|
409
|
-
* Use {@link matchesContextExceeded} to test a free-form error message against them.
|
|
410
|
-
* Provider authors can also compose these into their own `classifyError` fallbacks.
|
|
411
|
-
*/
|
|
412
|
-
declare const CONTEXT_EXCEEDED_MESSAGE_PATTERNS: readonly RegExp[];
|
|
413
|
-
/**
|
|
414
|
-
* Return true when `message` matches any of the known "context window exceeded"
|
|
415
|
-
* phrasings. Safe for `''` / non-strings (returns false).
|
|
416
|
-
*/
|
|
417
|
-
declare function matchesContextExceeded(message: unknown): boolean;
|
|
418
|
-
/**
|
|
419
|
-
* Extract a printable message from an unknown thrown value.
|
|
420
|
-
*
|
|
421
|
-
* Standardizes the `err instanceof Error ? err.message : String(err)` idiom
|
|
422
|
-
* that every `catch (err)` block was reaching for.
|
|
423
|
-
*/
|
|
424
|
-
declare function errorMessage(err: unknown): string;
|
|
425
|
-
/**
|
|
426
|
-
* Convert a `ClassifiedError` + underlying cause into the matching typed error instance.
|
|
427
|
-
*/
|
|
428
|
-
declare function toTypedError(classification: ClassifiedError, provider: string, cause: unknown): AgentContextExceededError | AgentProviderError | AgentAbortedError | AgentToolPairingError;
|
|
429
|
-
//#endregion
|
|
430
231
|
//#region src/types.d.ts
|
|
431
232
|
/**
|
|
432
233
|
* Thinking / extended-reasoning configuration.
|
|
@@ -701,6 +502,11 @@ interface RetryConfig {
|
|
|
701
502
|
* `dedupTools` for the full contract.
|
|
702
503
|
*/
|
|
703
504
|
type DedupHasher = (input: Record<string, unknown>) => string | undefined;
|
|
505
|
+
type ProgressNudgeKind = 'readOnlyTurns' | 'failedMutations' | 'noopMutations' | 'validationRejects' | 'toolErrors';
|
|
506
|
+
type ProgressNudgeMessage = string | ((ctx: {
|
|
507
|
+
kind: ProgressNudgeKind;
|
|
508
|
+
count: number;
|
|
509
|
+
}) => string);
|
|
704
510
|
/**
|
|
705
511
|
* Per-tool dedup configuration. Two equivalent forms:
|
|
706
512
|
*
|
|
@@ -1061,6 +867,15 @@ interface AgentBehavior {
|
|
|
1061
867
|
* historic behavior).
|
|
1062
868
|
*/
|
|
1063
869
|
maxTurnsWarning?: number;
|
|
870
|
+
/**
|
|
871
|
+
* Optional custom message for {@link maxTurnsWarning}. When unset, the loop
|
|
872
|
+
* uses its built-in wrap-up warning. String form is sent verbatim; function
|
|
873
|
+
* form receives the remaining/maximum turn counts and can tailor the nudge.
|
|
874
|
+
*/
|
|
875
|
+
maxTurnsWarningMessage?: string | ((ctx: {
|
|
876
|
+
remaining: number;
|
|
877
|
+
maxTurns: number;
|
|
878
|
+
}) => string);
|
|
1064
879
|
/**
|
|
1065
880
|
* Run-level cost ceiling, expressed in USD. After each turn, the sum of
|
|
1066
881
|
* `TurnUsage.cost` across the run is compared against this value; if the
|
|
@@ -1231,6 +1046,16 @@ interface AgentBehavior {
|
|
|
1231
1046
|
maxTokens?: number;
|
|
1232
1047
|
/** Thinking token budget — overrides the level-based default when set */
|
|
1233
1048
|
thinkingBudget?: number;
|
|
1049
|
+
/**
|
|
1050
|
+
* When a provider streams more thinking text than expected, optionally nudge
|
|
1051
|
+
* the next continuing turn toward concrete progress. This is advisory and
|
|
1052
|
+
* non-interrupting: same-turn tool calls are still allowed to finish.
|
|
1053
|
+
*/
|
|
1054
|
+
thinkingOverrunPolicy?: 'off' | 'steer-next-turn' | {
|
|
1055
|
+
mode?: 'off' | 'steer-next-turn';
|
|
1056
|
+
thresholdTokens?: number;
|
|
1057
|
+
message?: string;
|
|
1058
|
+
};
|
|
1234
1059
|
/**
|
|
1235
1060
|
* Default model-specific options applied to every run, keyed by option id
|
|
1236
1061
|
* (e.g. `{ fast: true }`). A per-run {@link AgentRunOptions.modelOptions}
|
|
@@ -1295,6 +1120,15 @@ interface AgentBehavior {
|
|
|
1295
1120
|
* list — see `src/chat/agents.ts`.
|
|
1296
1121
|
*/
|
|
1297
1122
|
toolOutputBudgetExcludeTools?: readonly string[];
|
|
1123
|
+
/**
|
|
1124
|
+
* Default `read_file` slice limits for calls that omit `limit` / `maxBytes`.
|
|
1125
|
+
* Explicit tool-call arguments still win. SDK default remains the tool's
|
|
1126
|
+
* built-in defaults; hosts can tighten these for context-sensitive profiles.
|
|
1127
|
+
*/
|
|
1128
|
+
readFileDefaults?: {
|
|
1129
|
+
limit?: number;
|
|
1130
|
+
maxBytes?: number;
|
|
1131
|
+
};
|
|
1298
1132
|
/**
|
|
1299
1133
|
* Deduplicate identical re-reads of the same file in `read_file`. When the
|
|
1300
1134
|
* model re-reads a file with the same slice and the bytes haven't changed
|
|
@@ -1331,6 +1165,54 @@ interface AgentBehavior {
|
|
|
1331
1165
|
factor: number;
|
|
1332
1166
|
floor: number;
|
|
1333
1167
|
} | ((runTurn: number, baseBudget: number) => number);
|
|
1168
|
+
/**
|
|
1169
|
+
* Policy for full-file writes to paths that already exist. The guard is a
|
|
1170
|
+
* `tool:gate` refusal that points the model toward `read_file` + `edit` /
|
|
1171
|
+
* `multi_edit`.
|
|
1172
|
+
*/
|
|
1173
|
+
writeFileExistingPolicy?: 'allow' | 'block-with-edit-recipe' | {
|
|
1174
|
+
mode?: 'allow' | 'block-with-edit-recipe';
|
|
1175
|
+
allowPaths?: readonly string[];
|
|
1176
|
+
denyPaths?: readonly string[];
|
|
1177
|
+
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Steer when a model emits a textual tool call instead of a provider-native
|
|
1180
|
+
* tool call. Execution of parsed text calls is intentionally not part of this
|
|
1181
|
+
* public contract.
|
|
1182
|
+
*/
|
|
1183
|
+
textToolCallRescue?: false | {
|
|
1184
|
+
mode?: 'steer';
|
|
1185
|
+
};
|
|
1186
|
+
/**
|
|
1187
|
+
* Steer when the model calls a tool name that is not registered. The unknown
|
|
1188
|
+
* tool result remains an error; this only queues a bounded follow-up nudge
|
|
1189
|
+
* with closest advertised tool-name suggestions.
|
|
1190
|
+
*/
|
|
1191
|
+
unknownToolRecovery?: false | {
|
|
1192
|
+
mode?: 'steer';
|
|
1193
|
+
maxSuggestions?: number;
|
|
1194
|
+
maxNudges?: number;
|
|
1195
|
+
message?: string | ((ctx: {
|
|
1196
|
+
called: string;
|
|
1197
|
+
suggestions: readonly string[];
|
|
1198
|
+
}) => string);
|
|
1199
|
+
};
|
|
1200
|
+
/**
|
|
1201
|
+
* Advisory progress nudges for broad stalls that exact repeat guards do not
|
|
1202
|
+
* cover: several read-only turns, failed/no-op mutations, validation rejects,
|
|
1203
|
+
* or tool errors. All nudges are non-interrupting and off by default.
|
|
1204
|
+
*/
|
|
1205
|
+
progressNudges?: false | {
|
|
1206
|
+
mode?: 'steer';
|
|
1207
|
+
readOnlyTurns?: number | false;
|
|
1208
|
+
failedMutations?: number | false;
|
|
1209
|
+
noopMutations?: number | false;
|
|
1210
|
+
validationRejects?: number | false;
|
|
1211
|
+
toolErrors?: number | false;
|
|
1212
|
+
readOnlyTools?: readonly string[];
|
|
1213
|
+
maxNudges?: number;
|
|
1214
|
+
messages?: Partial<Record<ProgressNudgeKind, ProgressNudgeMessage>>;
|
|
1215
|
+
};
|
|
1334
1216
|
/**
|
|
1335
1217
|
* Per-tool soft call budget for this run. Keyed by **canonical** tool name.
|
|
1336
1218
|
* On the first call after the run-cumulative dispatched count for that tool
|
|
@@ -2913,6 +2795,65 @@ interface AnthropicParams extends OAuthParams {
|
|
|
2913
2795
|
*/
|
|
2914
2796
|
extraHeaders?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
2915
2797
|
}
|
|
2798
|
+
/**
|
|
2799
|
+
* Build the `anthropic-beta` header value — OAuth defaults plus caller-supplied
|
|
2800
|
+
* extras, de-duped while preserving order. Returns `undefined` when no betas
|
|
2801
|
+
* apply (non-OAuth, no extras).
|
|
2802
|
+
*/
|
|
2803
|
+
declare function resolveAnthropicBetas(isOAuth: boolean, extraBetas?: readonly string[]): string | undefined;
|
|
2804
|
+
/**
|
|
2805
|
+
* Description of the Anthropic-side thinking configuration derived from a
|
|
2806
|
+
* ThinkingLevel. `null` means no thinking-related field should be set on the
|
|
2807
|
+
* request.
|
|
2808
|
+
*
|
|
2809
|
+
* Two shapes:
|
|
2810
|
+
* - `adaptive` — `thinking.type='adaptive'`. The model self-budgets per turn.
|
|
2811
|
+
* When `effort` is set, also emits `output_config.effort` to hint at the
|
|
2812
|
+
* level of reasoning the caller wants. This is the post-Claude-4.6 default
|
|
2813
|
+
* for level-based control and avoids the `thinking.type='enabled'`
|
|
2814
|
+
* deprecation warning. When `maxTokensCap` is set, the request builder
|
|
2815
|
+
* reduces `max_tokens` to `min(max_tokens, maxTokensCap)` — adaptive thinks
|
|
2816
|
+
* and replies inside one envelope, so capping the envelope soft-bounds the
|
|
2817
|
+
* thinking too.
|
|
2818
|
+
* - `enabled` — explicit-budget path: `thinking.type='enabled'` with an
|
|
2819
|
+
* explicit `budget_tokens`. `maxTokensBump` is added to the request's
|
|
2820
|
+
* `max_tokens` so the budget sits on top of the response cap. The only
|
|
2821
|
+
* way to pin a precise token budget; Anthropic emits a deprecation
|
|
2822
|
+
* warning for this shape on opus 4.6+, so we only route here when the
|
|
2823
|
+
* caller explicitly sets `behavior.thinkingBudget`.
|
|
2824
|
+
*
|
|
2825
|
+
* In both shapes Anthropic requires `temperature` to be `1`.
|
|
2826
|
+
*/
|
|
2827
|
+
type AnthropicThinkingPlan = {
|
|
2828
|
+
kind: 'enabled';
|
|
2829
|
+
budgetTokens: number;
|
|
2830
|
+
maxTokensBump: number;
|
|
2831
|
+
} | {
|
|
2832
|
+
kind: 'adaptive';
|
|
2833
|
+
effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
2834
|
+
maxTokensCap?: number;
|
|
2835
|
+
};
|
|
2836
|
+
/**
|
|
2837
|
+
* Decide how to translate a `ThinkingLevel` into Anthropic's request shape.
|
|
2838
|
+
* Pure / synchronous — exported so tests can assert routing without standing
|
|
2839
|
+
* up the SDK.
|
|
2840
|
+
*
|
|
2841
|
+
* Routing rules:
|
|
2842
|
+
* - `'off'` → `null` (no thinking field, no effort hint).
|
|
2843
|
+
* - `'adaptive'` → adaptive thinking with no effort hint (model decides
|
|
2844
|
+
* everything). When `customBudget` is set, it is carried as `maxTokensCap`
|
|
2845
|
+
* so the request builder caps `max_tokens` accordingly — adaptive has no
|
|
2846
|
+
* native budget knob, but capping the response envelope soft-bounds the
|
|
2847
|
+
* thinking that lives inside it.
|
|
2848
|
+
* - Budgeted levels → adaptive thinking with an `effort` hint, unless
|
|
2849
|
+
* `customBudget` is provided.
|
|
2850
|
+
* - Any level + `customBudget` → explicit-budget `enabled` path. The caller
|
|
2851
|
+
* has opted into precise budget control and accepts the Anthropic
|
|
2852
|
+
* deprecation warning that comes with it on opus 4.6+. `'adaptive'` is the
|
|
2853
|
+
* sole exception: it never falls back to enabled, since adaptive is the
|
|
2854
|
+
* current Anthropic API surface for self-budgeted thinking.
|
|
2855
|
+
*/
|
|
2856
|
+
declare function planAnthropicThinking(level: ThinkingLevel, customBudget?: number): AnthropicThinkingPlan | null;
|
|
2916
2857
|
/**
|
|
2917
2858
|
* Mutate an Anthropic request in place to add cache breakpoints on the three
|
|
2918
2859
|
* stable prefixes:
|
|
@@ -2938,6 +2879,26 @@ interface AnthropicParams extends OAuthParams {
|
|
|
2938
2879
|
* breakpoint placement.
|
|
2939
2880
|
*/
|
|
2940
2881
|
declare function applyAnthropicCacheBreakpoints(params: Anthropic.MessageCreateParamsStreaming, originalSystem?: string): void;
|
|
2882
|
+
/**
|
|
2883
|
+
* Classify an Anthropic SDK / HTTP error for typed-error wrapping.
|
|
2884
|
+
*
|
|
2885
|
+
* - `prompt is too long` (400 invalid_request_error) → `context_exceeded`.
|
|
2886
|
+
* - `'tool_use' ids were found without 'tool_result' blocks` /
|
|
2887
|
+
* `'tool_result must be preceded by a tool_call'` (400) →
|
|
2888
|
+
* `tool_pairing_corruption`. The local repair pass should have caught
|
|
2889
|
+
* this — the typed error tells consumers their pre-send pipeline is
|
|
2890
|
+
* shipping orphaned blocks somehow (custom `context:transform` hook,
|
|
2891
|
+
* bypassed loop, mid-stream session edit) so they can patch the root
|
|
2892
|
+
* cause instead of chasing 400s.
|
|
2893
|
+
* - Any other Anthropic `APIError`-shaped value → `provider_error` with the
|
|
2894
|
+
* native status/type code.
|
|
2895
|
+
* - Unknown errors → `null` (loop wraps in `AgentProviderError` generically).
|
|
2896
|
+
*
|
|
2897
|
+
* Anthropic's wire error shape is `{ type: 'error', error: { type, message } }` — the
|
|
2898
|
+
* SDK stores the parsed body on `err.error`. We walk both levels so callers see the
|
|
2899
|
+
* most specific `providerCode` we can find.
|
|
2900
|
+
*/
|
|
2901
|
+
declare function classifyAnthropicError(err: unknown): ClassifiedError | null;
|
|
2941
2902
|
declare function anthropic(anthropicParams?: AnthropicParams): Provider;
|
|
2942
2903
|
//#endregion
|
|
2943
2904
|
//#region src/providers/arcee.d.ts
|
|
@@ -3156,9 +3117,207 @@ interface OpenAIParams extends OAuthParams {
|
|
|
3156
3117
|
*/
|
|
3157
3118
|
extraHeaders?: Record<string, string>;
|
|
3158
3119
|
}
|
|
3120
|
+
declare function toPiMessages(messages: SessionMessage[], modelId: string): Message[];
|
|
3121
|
+
/**
|
|
3122
|
+
* Map pi-ai's `StopReason` to the zidane `TurnFinishReason` union — the same
|
|
3123
|
+
* native-stop-reason fidelity anthropic's `mapStopReason` / openai-compat's
|
|
3124
|
+
* `mapOAIFinishReason` provide. Notably `length` (max-token truncation) is no
|
|
3125
|
+
* longer misreported as a clean `stop`. `hasToolCalls` is the fallback for
|
|
3126
|
+
* messages whose stop reason is missing or doesn't carry the tool-call signal.
|
|
3127
|
+
*/
|
|
3128
|
+
declare function mapCodexStopReason(stopReason: string | undefined, hasToolCalls: boolean): TurnFinishReason;
|
|
3129
|
+
/**
|
|
3130
|
+
* Classify an OpenAI Codex error. pi-ai surfaces errors either as thrown `Error`s
|
|
3131
|
+
* (wrapping `event.error.errorMessage`) or via stream event types.
|
|
3132
|
+
*
|
|
3133
|
+
* Retryable hint is set when pi-ai's own retry budget is exhausted on a
|
|
3134
|
+
* transient failure — pattern-matched against `message` since pi-ai strips
|
|
3135
|
+
* structured fields on plain-Error throws. Set `behavior.retry.maxAttempts: 1`
|
|
3136
|
+
* to disable the loop-level retry.
|
|
3137
|
+
*/
|
|
3138
|
+
declare function classifyOpenAIError(err: unknown): ClassifiedError | null;
|
|
3159
3139
|
declare function openai(params?: OpenAIParams): Provider;
|
|
3160
3140
|
//#endregion
|
|
3161
3141
|
//#region src/providers/openai-compat.d.ts
|
|
3142
|
+
interface OAIMessage {
|
|
3143
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
3144
|
+
content?: unknown;
|
|
3145
|
+
tool_calls?: {
|
|
3146
|
+
id: string;
|
|
3147
|
+
type: 'function';
|
|
3148
|
+
function: {
|
|
3149
|
+
name: string;
|
|
3150
|
+
arguments: string;
|
|
3151
|
+
};
|
|
3152
|
+
}[];
|
|
3153
|
+
tool_call_id?: string;
|
|
3154
|
+
/**
|
|
3155
|
+
* OpenRouter normalized reasoning envelope. Echoed back unmodified on assistant
|
|
3156
|
+
* messages so the gateway can resume an extended-reasoning chain on the
|
|
3157
|
+
* upstream route. Ignored by hosts that don't speak the envelope.
|
|
3158
|
+
*/
|
|
3159
|
+
reasoning_details?: unknown[];
|
|
3160
|
+
/**
|
|
3161
|
+
* Plain reasoning string echoed back on assistant messages for vLLM-style
|
|
3162
|
+
* reasoning models (Arcee Trinity-Thinking, DeepSeek-R1). Arcee's API accepts
|
|
3163
|
+
* `reasoning_content`; some self-hosted vLLM versions read `reasoning`.
|
|
3164
|
+
*/
|
|
3165
|
+
reasoning_content?: string;
|
|
3166
|
+
reasoning?: string;
|
|
3167
|
+
}
|
|
3168
|
+
interface OAITool {
|
|
3169
|
+
type: 'function';
|
|
3170
|
+
function: {
|
|
3171
|
+
name: string;
|
|
3172
|
+
description: string;
|
|
3173
|
+
parameters: Record<string, unknown>;
|
|
3174
|
+
};
|
|
3175
|
+
}
|
|
3176
|
+
declare const TOOL_RESULTS_TAG = "__zidane_tool_results__";
|
|
3177
|
+
declare const ASSISTANT_TOOL_CALLS_TAG = "__zidane_assistant_tc__";
|
|
3178
|
+
declare class OpenAICompatStreamError extends Error {
|
|
3179
|
+
constructor(message: string);
|
|
3180
|
+
}
|
|
3181
|
+
interface OpenAICompatUsage {
|
|
3182
|
+
input: number;
|
|
3183
|
+
output: number;
|
|
3184
|
+
cost?: number;
|
|
3185
|
+
cacheRead?: number;
|
|
3186
|
+
cacheCreation?: number;
|
|
3187
|
+
}
|
|
3188
|
+
declare function consumeSSE(response: Response, callbacks: StreamCallbacks, signal?: AbortSignal): Promise<{
|
|
3189
|
+
text: string;
|
|
3190
|
+
thinking: string;
|
|
3191
|
+
toolCalls: {
|
|
3192
|
+
id: string;
|
|
3193
|
+
name: string;
|
|
3194
|
+
input: Record<string, unknown>;
|
|
3195
|
+
}[];
|
|
3196
|
+
finishReason: string;
|
|
3197
|
+
usage: OpenAICompatUsage;
|
|
3198
|
+
reasoningDetails: Record<string, unknown>[];
|
|
3199
|
+
}>;
|
|
3200
|
+
/**
|
|
3201
|
+
* Options that influence OpenAI-compat message shaping.
|
|
3202
|
+
*
|
|
3203
|
+
* `imageInToolResult` defaults to `false`: the loop routes images via a companion
|
|
3204
|
+
* user message emitted immediately after the `tool` message. Providers with
|
|
3205
|
+
* genuine multi-part tool support can set it to `true` to emit a single
|
|
3206
|
+
* multi-part `tool` message instead.
|
|
3207
|
+
*/
|
|
3208
|
+
interface ToOAIOptions {
|
|
3209
|
+
imageInToolResult?: boolean;
|
|
3210
|
+
/**
|
|
3211
|
+
* Route accepts audio input (`input_audio` content parts). When false,
|
|
3212
|
+
* audio blocks throw rather than silently dropping bytes a non-audio model
|
|
3213
|
+
* would 400 on.
|
|
3214
|
+
*/
|
|
3215
|
+
audio?: boolean;
|
|
3216
|
+
/**
|
|
3217
|
+
* Route accepts video input (`video_url` content parts, base64 data-URL).
|
|
3218
|
+
* Currently Gemini-on-OpenRouter. When false, video blocks throw.
|
|
3219
|
+
*/
|
|
3220
|
+
video?: boolean;
|
|
3221
|
+
/**
|
|
3222
|
+
* Route accepts native document/PDF input (OpenAI `file` content part with
|
|
3223
|
+
* base64 `file_data`). When false (default), base64 documents degrade to the
|
|
3224
|
+
* `[document omitted: …]` text marker. Text-encoded documents are always
|
|
3225
|
+
* inlined upstream regardless of this flag.
|
|
3226
|
+
*/
|
|
3227
|
+
documents?: boolean;
|
|
3228
|
+
/**
|
|
3229
|
+
* Host accepts provider-bound reasoning state echoed back on assistant
|
|
3230
|
+
* messages. The exact wire shape is selected by `reasoningMode`: OpenRouter's
|
|
3231
|
+
* structured `reasoning_details[]` envelope, or vLLM/Arcee's plain
|
|
3232
|
+
* `reasoning_content` / `reasoning` string. When `false` (default), stored reasoning blocks
|
|
3233
|
+
* are silently dropped to avoid 400s on hosts that strict-validate the schema.
|
|
3234
|
+
*/
|
|
3235
|
+
supportsReasoning?: boolean;
|
|
3236
|
+
/**
|
|
3237
|
+
* Reasoning round-trip shape. `'openrouter'` echoes structured
|
|
3238
|
+
* `reasoning_details[]`; `'reasoning_content'` echoes the plain reasoning
|
|
3239
|
+
* string (vLLM/Arcee). Only consulted when `supportsReasoning` is `true`.
|
|
3240
|
+
* Default: `'openrouter'`.
|
|
3241
|
+
*/
|
|
3242
|
+
reasoningMode?: 'openrouter' | 'reasoning_content';
|
|
3243
|
+
/**
|
|
3244
|
+
* Wire field used to echo plain reasoning in `'reasoning_content'` mode.
|
|
3245
|
+
* Default: `'reasoning'` (broadest vLLM compatibility).
|
|
3246
|
+
*/
|
|
3247
|
+
reasoningContentField?: 'reasoning_content' | 'reasoning';
|
|
3248
|
+
/**
|
|
3249
|
+
* Normalize `content: null` → `''` on assistant tool-call turns. Default off.
|
|
3250
|
+
*/
|
|
3251
|
+
normalizeNullContent?: boolean;
|
|
3252
|
+
/**
|
|
3253
|
+
* Active model id. Used to gate `provider_reasoning` blocks — reasoning state
|
|
3254
|
+
* is bound to the route that produced it, so a model switch invalidates the
|
|
3255
|
+
* embedded signatures.
|
|
3256
|
+
*/
|
|
3257
|
+
model?: string;
|
|
3258
|
+
}
|
|
3259
|
+
declare function toOAIMessages(system: string, messages: SessionMessage[], options?: ToOAIOptions): OAIMessage[];
|
|
3260
|
+
/**
|
|
3261
|
+
* Add `cache_control: { type: 'ephemeral' }` breakpoints to the system message's
|
|
3262
|
+
* last text part and the last message's final content part.
|
|
3263
|
+
*
|
|
3264
|
+
* Mutates `messages` in place. Converts plain-string content into a single-element
|
|
3265
|
+
* content array so the cache marker can attach — this shape is accepted verbatim by
|
|
3266
|
+
* OpenRouter's Anthropic and Gemini routes and ignored by routes with automatic
|
|
3267
|
+
* caching (OpenAI, DeepSeek, Grok, Groq, Moonshot).
|
|
3268
|
+
*
|
|
3269
|
+
* Skip conditions (safe no-ops):
|
|
3270
|
+
* - Empty messages array.
|
|
3271
|
+
* - Assistant messages with no text (tool-call-only) — attaching a cache marker to a
|
|
3272
|
+
* `tool_calls` block has no defined semantics, so we skip and let the prior
|
|
3273
|
+
* system/tools breakpoints carry caching.
|
|
3274
|
+
*
|
|
3275
|
+
* System-prompt boundary handling: when `originalSystem` (the un-rendered
|
|
3276
|
+
* system text passed to {@link toOAIMessages}) contains
|
|
3277
|
+
* {@link SYSTEM_PROMPT_BOUNDARY}, the leading system message is rewritten as
|
|
3278
|
+
* a two-part array — `cache_control` lands on the static prefix only, so
|
|
3279
|
+
* per-turn churn in the dynamic suffix doesn't invalidate the cached
|
|
3280
|
+
* doctrine above. `originalSystem` defaults to `undefined` for back-compat;
|
|
3281
|
+
* omit it (or pass a marker-free string) for the single-block historic
|
|
3282
|
+
* behavior.
|
|
3283
|
+
*/
|
|
3284
|
+
declare function applyOAICacheBreakpoints(messages: OAIMessage[], originalSystem?: string): void;
|
|
3285
|
+
/**
|
|
3286
|
+
* Return a copy of `tools` with `cache_control` on the last entry.
|
|
3287
|
+
*
|
|
3288
|
+
* OpenRouter accepts the marker alongside the standard `type` + `function` fields
|
|
3289
|
+
* and forwards it when routing to Anthropic/Gemini. Leaves the non-cached tools
|
|
3290
|
+
* unchanged so the caller's reference is not mutated.
|
|
3291
|
+
*/
|
|
3292
|
+
declare function applyOAIToolCacheBreakpoint(tools: OAITool[]): OAITool[];
|
|
3293
|
+
declare function formatTools(tools: ToolSpec[]): OAITool[];
|
|
3294
|
+
declare function userMessage(content: string): SessionMessage;
|
|
3295
|
+
/**
|
|
3296
|
+
* Build a user `SessionMessage` from multimodal prompt parts.
|
|
3297
|
+
*
|
|
3298
|
+
* Passes every kind (text/image/audio/video/document) through as a canonical
|
|
3299
|
+
* block; the actual wire emission, capability gating, and unsupported-media
|
|
3300
|
+
* throwing all happen later in {@link toOAIMessages}. Implementing this (rather
|
|
3301
|
+
* than letting the agent fall back to `defaultPromptMessage`) is what lets
|
|
3302
|
+
* openai-compat routes accept base64 documents/PDFs at all — the default
|
|
3303
|
+
* builder throws on base64 documents.
|
|
3304
|
+
*/
|
|
3305
|
+
declare function openAICompatPromptMessage(parts: PromptPart[]): SessionMessage;
|
|
3306
|
+
declare function assistantMessage(content: string): SessionMessage;
|
|
3307
|
+
declare function toolResultsMessage(results: ToolResult[]): SessionMessage;
|
|
3308
|
+
declare function buildAssistantContent(text: string, toolCalls: {
|
|
3309
|
+
id: string;
|
|
3310
|
+
name: string;
|
|
3311
|
+
input: Record<string, unknown>;
|
|
3312
|
+
}[], thinking?: string, reasoning?: {
|
|
3313
|
+
details: unknown[];
|
|
3314
|
+
producer: 'openrouter';
|
|
3315
|
+
model?: string;
|
|
3316
|
+
} | {
|
|
3317
|
+
reasoningText: string;
|
|
3318
|
+
producer: 'vllm';
|
|
3319
|
+
model?: string;
|
|
3320
|
+
}): SessionMessage;
|
|
3162
3321
|
/**
|
|
3163
3322
|
* HTTP error thrown when an OpenAI-compatible endpoint returns a non-OK response.
|
|
3164
3323
|
*
|
|
@@ -3391,6 +3550,7 @@ interface OpenRouterParams {
|
|
|
3391
3550
|
*/
|
|
3392
3551
|
pdfEngine?: 'native' | 'pdf-text' | 'mistral-ocr';
|
|
3393
3552
|
}
|
|
3553
|
+
declare function normalizeOpenRouterModelId(modelId: string): string;
|
|
3394
3554
|
/**
|
|
3395
3555
|
* OpenRouter provider.
|
|
3396
3556
|
*
|
|
@@ -5444,11 +5604,10 @@ interface AgentHooks {
|
|
|
5444
5604
|
*/
|
|
5445
5605
|
/**
|
|
5446
5606
|
* Gate a tool call before it runs. Handlers share ONE mutable `ctx` and run
|
|
5447
|
-
* sequentially in registration order (the order they were `hook()`-ed
|
|
5448
|
-
*
|
|
5449
|
-
*
|
|
5450
|
-
*
|
|
5451
|
-
* awaited) have run.
|
|
5607
|
+
* sequentially in registration order (the order they were `hook()`-ed). The
|
|
5608
|
+
* framework reads the final state once all handlers (including async ones,
|
|
5609
|
+
* which are awaited) have run. Built-in behavior gates install during run
|
|
5610
|
+
* setup and self-defer when another gate already set `block` / `result`.
|
|
5452
5611
|
*
|
|
5453
5612
|
* Precedence across the resolved state:
|
|
5454
5613
|
* - `block` beats `result`: if any handler left `block === true`, the call
|
|
@@ -6751,5 +6910,5 @@ declare function createAgent({
|
|
|
6751
6910
|
toolKill
|
|
6752
6911
|
}: AgentOptions): Agent;
|
|
6753
6912
|
//#endregion
|
|
6754
|
-
export { FileMapAdapter as $,
|
|
6755
|
-
//# sourceMappingURL=agent-
|
|
6913
|
+
export { FileMapAdapter as $, PromptDocumentPart as $n, classifyOpenAICompatError as $t, getReadState as A, planAnthropicThinking as An, TurnUsage as Ar, TurnResult as At, SkillSource as B, CompactFunction as Bn, ContextMcpGroup as Br, openrouter as Bt, wrapDiscoveredMcpTools as C, arcee as Cn, ToolResultDocumentContent as Cr, ProviderCapabilities as Ct, HydrateReadStateOptions as D, anthropic as Dn, ToolResultTextContent as Dr, ToolCall as Dt, ToolMap as E, AnthropicThinkingPlan as En, ToolResultImageRefContent as Er, TokenCountPayload as Et, resolveReadStateMap as F, AgentStats as Fn, ContextBreakdownOptions as Fr, SchemaSanitizeResult as Ft, SessionRun as G, DedupToolConfig as Gn, OpenAICompatHttpError as Gt, CreateSessionOptions as H, CompactStartHookContext as Hn, ContextUsageSplit as Hr, OAIMessage as Ht, ShellInterpolationApproval as I, AutoCompact as In, ContextCategory as Ir, sanitizeToolSchema as It, demoteStaleRunningStatus as J, McpToolSchema as Jn, TOOL_RESULTS_TAG as Jt, SessionStore as K, McpServerConfig as Kn, OpenAICompatParams as Kt, SkillConfig as L, AutoCompactConfig as Ln, ContextCategoryId as Lr, sanitizeToolSpecs as Lt, hydrateReadStateFromSession as M, AgentBehavior as Mn, toolOutputByteLength as Mr, xai as Mt, hydrateReadStateFromSessionAsync as N, AgentClock as Nn, toolResultToText as Nr, SchemaSanitizeOptions as Nt, ReadStateEntry as O, applyAnthropicCacheBreakpoints as On, ToolResultVideoContent as Or, ToolResult as Ot, readStateKey as P, AgentRunOptions as Pn, ContextBreakdown as Pr, SchemaSanitizeProfile as Pt, createMemoryStore as Q, PromptAudioPart as Qn, buildAssistantContent as Qt, SkillDiagnostic as R, ChildRunStats as Rn, ContextExactCounts as Rr, OpenRouterParams as Rt, resultToString as S, ArceeParams as Sn, ToolResultContent as Sr, Provider as St, ToolDef as T, AnthropicParams as Tn, ToolResultImageContent as Tr, StreamOptions as Tt, Session as U, DEFAULT_AGENT_CLOCK as Un, buildContextBreakdown as Ur, OAITool as Ut, SkillsConfig as V, CompactHookContext as Vn, ContextSnapshot as Vr, ASSISTANT_TOOL_CALLS_TAG as Vt, SessionData as W, DedupHasher as Wn, OpenAICompatAuthHeader as Wt, RemoteStoreOptions as X, ProgressNudgeKind as Xn, applyOAIToolCacheBreakpoint as Xt, loadSession as Y, OAuthRefreshHookContext as Yn, applyOAICacheBreakpoints as Yt, createRemoteStore as Z, ProgressNudgeMessage as Zn, assistantMessage as Zt, attachStderrWarnPump as _, CerebrasParams as _n, ThinkingLevel as _r, fromOpenAI as _t, McpConnector as a, toOAIMessages as an, RepeatGuardToolMatcher as ar, PairingRepairMode as at, normalizeMcpBlocks as b, baseten as bn, ToolOutcome as br, toOpenAI as bt, createAgent as c, OpenAIParams as cn, RetryConfig as cr, TOOL_USE_INTERRUPTED_MARKER as ct, DeactivationReason as d, openai as dn, SessionEndStatus as dr, autoDetectAndConvert as dt, consumeSSE as en, PromptImagePart as er, FileMapStoreOptions as et, SkillActivationState as f, toPiMessages as fn, SessionHookContext as fr, detectTurnInterruption as ft, McpConnection as g, cursor as gn, StreamHookContext as gr, fromAnthropic as gt, ConnectMcpServersOptions as h, CursorParams as hn, SpawnHookContext as hr, filterUnresolvedToolUses as ht, AgentOptions as i, openaiCompat as in, RepeatGuardConfig as ir, PairingRepair as it, hashContent as j, resolveAnthropicBetas as jn, toolOutputBudgetByteLength as jr, XaiParams as jt, ReadStateMap as k, classifyAnthropicError as kn, TurnFinishReason as kr, ToolSpec as kt, ActivationVia as l, classifyOpenAIError as ln, RunHookMap as lr, ToWireMessagesOptions as lt, createSkillActivationState as m, local as mn, SessionTurn as mr, ensureToolResultPairing as mt, AgentHookMap as n, mapOAIFinishReason as nn, PromptTextPart as nr, EnsureToolResultPairingOptions as nt, McpToolMeta as o, toolResultsMessage as on, ResolveContentRef as or, RemintResult as ot, SkillActivationStateOptions as p, LocalParams as pn, SessionMessage as pr, ensureEndsWithUserMessage as pt, createSession as q, McpToolHookContext as qn, OpenAICompatStreamError as qt, AgentHooks as r, openAICompatPromptMessage as rn, PromptVideoPart as rr, ORPHANED_TOOL_RESULT_MARKER as rt, McpToolWrap as s, userMessage as sn, ResolveContentRefBlock as sr, SYNTHETIC_TOOL_RESULT_PLACEHOLDER as st, Agent as t, formatTools as tn, PromptPart as tr, createFileMapStore as tt, ActiveSkill as u, mapCodexStopReason as un, SessionContentBlock as ur, TurnInterruptionState as ut, connectMcpServers as v, cerebras as vn, ToolBatchExecutor as vr, remintDuplicateToolCallIds as vt, ToolContext as w, AnthropicContextManagement as wn, ToolResultDocumentRefContent as wr, StreamCallbacks as wt, normalizeMcpServers as x, planBasetenReasoning as xn, ToolResultAudioContent as xr, toWireMessages as xt, deriveMcpToolMeta as y, BasetenParams as yn, ToolHookContext as yr, toAnthropic as yt, SkillResource as z, CompactEndHookContext as zn, ContextItem as zr, normalizeOpenRouterModelId as zt };
|
|
6914
|
+
//# sourceMappingURL=agent-BAgOgS37.d.ts.map
|