zidane 5.6.11 → 5.6.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.
Files changed (64) hide show
  1. package/README.md +19 -2
  2. package/dist/{agent-C9AKTU_V.d.ts → agent-ClkpElCZ.d.ts} +540 -55
  3. package/dist/agent-ClkpElCZ.d.ts.map +1 -0
  4. package/dist/chat.d.ts +47 -17
  5. package/dist/chat.d.ts.map +1 -1
  6. package/dist/chat.js +3 -3
  7. package/dist/{index-6f4T7Gc0.d.ts → index-CTDMMdIy.d.ts} +348 -3
  8. package/dist/index-CTDMMdIy.d.ts.map +1 -0
  9. package/dist/{index-DPN7TcXK.d.ts → index-v3Tzobqr.d.ts} +2 -2
  10. package/dist/{index-DPN7TcXK.d.ts.map → index-v3Tzobqr.d.ts.map} +1 -1
  11. package/dist/index.d.ts +4 -4
  12. package/dist/index.js +169 -8
  13. package/dist/index.js.map +1 -1
  14. package/dist/{login-BindcfKi.js → login-DS3sf6b5.js} +4 -4
  15. package/dist/{login-BindcfKi.js.map → login-DS3sf6b5.js.map} +1 -1
  16. package/dist/{mcp-0jRkIV0g.js → mcp-DGeB7-3D.js} +13 -2
  17. package/dist/mcp-DGeB7-3D.js.map +1 -0
  18. package/dist/mcp.d.ts +1 -1
  19. package/dist/mcp.js +1 -1
  20. package/dist/{messages-BfmXLDT4.js → messages-Dym8S_YH.js} +303 -8
  21. package/dist/messages-Dym8S_YH.js.map +1 -0
  22. package/dist/{presets-CmzMeWg2.js → presets-CZXS_87d.js} +2 -2
  23. package/dist/{presets-CmzMeWg2.js.map → presets-CZXS_87d.js.map} +1 -1
  24. package/dist/presets.d.ts +2 -2
  25. package/dist/presets.js +1 -1
  26. package/dist/{providers-C_ahnRBS.js → providers-beXyD9W9.js} +137 -21
  27. package/dist/providers-beXyD9W9.js.map +1 -0
  28. package/dist/providers.d.ts +2 -2
  29. package/dist/providers.js +3 -3
  30. package/dist/restate.d.ts +1 -1
  31. package/dist/session/sqlite.d.ts +1 -1
  32. package/dist/{session-PUzXZlG6.js → session-BRIsmBSY.js} +5 -2
  33. package/dist/session-BRIsmBSY.js.map +1 -0
  34. package/dist/session.d.ts +2 -2
  35. package/dist/session.js +3 -3
  36. package/dist/skills.d.ts +2 -2
  37. package/dist/{tools-CxOfTt3R.js → tools-DE9pR_NG.js} +515 -116
  38. package/dist/tools-DE9pR_NG.js.map +1 -0
  39. package/dist/tools.d.ts +3 -3
  40. package/dist/tools.js +1 -1
  41. package/dist/{transcript-anchors-DDCHSDdX.d.ts → transcript-anchors-D0TR6djV.d.ts} +4 -4
  42. package/dist/transcript-anchors-D0TR6djV.d.ts.map +1 -0
  43. package/dist/tui.d.ts +2 -2
  44. package/dist/tui.d.ts.map +1 -1
  45. package/dist/tui.js +12 -8
  46. package/dist/tui.js.map +1 -1
  47. package/dist/{turn-operations-CxE8BBau.js → turn-operations-6Yls2HuG.js} +907 -42
  48. package/dist/turn-operations-6Yls2HuG.js.map +1 -0
  49. package/dist/types-oKPBdCmL.js.map +1 -1
  50. package/dist/types.d.ts +3 -3
  51. package/docs/ARCHITECTURE.md +101 -20
  52. package/docs/CHAT.md +27 -5
  53. package/docs/RESTATE.md +1 -1
  54. package/docs/SKILL.md +39 -3
  55. package/package.json +5 -2
  56. package/dist/agent-C9AKTU_V.d.ts.map +0 -1
  57. package/dist/index-6f4T7Gc0.d.ts.map +0 -1
  58. package/dist/mcp-0jRkIV0g.js.map +0 -1
  59. package/dist/messages-BfmXLDT4.js.map +0 -1
  60. package/dist/providers-C_ahnRBS.js.map +0 -1
  61. package/dist/session-PUzXZlG6.js.map +0 -1
  62. package/dist/tools-CxOfTt3R.js.map +0 -1
  63. package/dist/transcript-anchors-DDCHSDdX.d.ts.map +0 -1
  64. package/dist/turn-operations-CxE8BBau.js.map +0 -1
@@ -2,6 +2,8 @@ import { a as ExecutionContext, o as ExecutionHandle } from "./types-KukEp-mi.js
2
2
  import { Hookable } from "hookable";
3
3
  import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
4
4
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
5
+ import Anthropic from "@anthropic-ai/sdk";
6
+
5
7
  //#region src/errors.d.ts
6
8
  /**
7
9
  * Typed error classes for agent runs.
@@ -422,6 +424,131 @@ interface McpServerConfig {
422
424
  */
423
425
  lazyConnect?: boolean;
424
426
  }
427
+ /**
428
+ * Configuration for the loop's retry-with-backoff policy around
429
+ * `provider.stream()`. See {@link AgentBehavior.retry}.
430
+ */
431
+ interface RetryConfig {
432
+ /**
433
+ * Maximum number of attempts including the initial call. `1` disables retry.
434
+ * Values below `1`, non-finite, or non-integer fall back to the default.
435
+ *
436
+ * Default: `3`.
437
+ */
438
+ maxAttempts?: number;
439
+ /**
440
+ * Initial backoff delay in milliseconds. Subsequent delays double
441
+ * (exponential) before jitter is applied and the cap enforced.
442
+ *
443
+ * Default: `1000`.
444
+ */
445
+ initialDelayMs?: number;
446
+ /**
447
+ * Upper bound on any single backoff delay in milliseconds. Caps both the
448
+ * exponential schedule and any `retry-after` header the server returns.
449
+ *
450
+ * Default: `30_000`.
451
+ */
452
+ maxDelayMs?: number;
453
+ }
454
+ /**
455
+ * Per-tool argument hasher used by {@link AgentBehavior.dedupTools}.
456
+ *
457
+ * Returning a non-empty string activates dedup with that string as the
458
+ * cache key. Returning `undefined` (or `''` / non-string) opts THIS call
459
+ * out — the tool runs normally and no state is recorded. See
460
+ * `dedupTools` for the full contract.
461
+ */
462
+ type DedupHasher = (input: Record<string, unknown>) => string | undefined;
463
+ /**
464
+ * Per-tool dedup configuration. Two equivalent forms:
465
+ *
466
+ * - **Hasher only** (legacy form): a bare function. The framework runs
467
+ * in `'replay'` mode — identical re-calls replay the prior result.
468
+ * Existing consumers that pass a function continue working unchanged.
469
+ * - **Config object**: explicit `hasher` plus a `mode`:
470
+ * - `'replay'` (default) — replay the cached result on identical re-
471
+ * calls. Cheap loop, but doesn't BREAK the loop — the model keeps
472
+ * seeing the same tool_result and keeps trying.
473
+ * - `'block-after'` — replay for the first `threshold` identical calls,
474
+ * then refuse with `Blocked: <reason>` via `tool:gate`. Designed to
475
+ * break tight loops where the model fixates on a single failing
476
+ * call. The block lands on the Nth identical call (i.e. once the
477
+ * total count reaches `threshold`); the cap is sticky — every
478
+ * subsequent identical call also blocks until a different input
479
+ * resets the counter.
480
+ *
481
+ * `reason` is the model-visible refusal text. The framework formats the
482
+ * final tool_result as `Blocked: <reason>` (see `tool:gate` docs).
483
+ * Strings are used verbatim; the callback form receives the input and
484
+ * the (now-blocking) repeat count so it can produce per-invocation
485
+ * messaging like `Blocked: 4 identical "shell" calls — try a different
486
+ * approach`. Default reason is generic but actionable.
487
+ */
488
+ /**
489
+ * Pluggable client-side context compactor — see
490
+ * {@link AgentBehavior.compactStrategy}. The loop invokes this in place
491
+ * of the built-in tail elision when `compactStrategy` is a function.
492
+ *
493
+ * Contract:
494
+ * - Operates on the wire-level message list — the post-alias / post-
495
+ * sanitize / post-`context:transform` view the provider will see.
496
+ * The framework treats the returned array as the new wire payload;
497
+ * `ctx.session` / `ctx.turns` are never modified.
498
+ * - Must preserve `tool_use ↔ tool_result` adjacency. Stranding a
499
+ * `tool_use` without its matching `tool_result` (or vice versa) will
500
+ * trip the loop's pair-repair pass and either repair the violation
501
+ * or throw (`strictToolPairing`).
502
+ * - The trailing user message must remain — providers reject
503
+ * assistant-tail wire payloads. If unsure, leave the last user turn
504
+ * intact and operate on the prefix only.
505
+ * - May return the input verbatim (e.g. when the total stays under the
506
+ * host's threshold).
507
+ * - Sync or async. The loop awaits the result, so a long-running LLM
508
+ * summarizer will block the next turn — keep latency in mind.
509
+ *
510
+ * `ctx.threshold` and `ctx.keepTurns` are forwarded from
511
+ * `behavior.compactThreshold` / `behavior.compactKeepTurns` so hosts
512
+ * can reuse the same knobs the built-in tail mode uses.
513
+ * `ctx.totalBytes` is the pre-compaction total — the same number the
514
+ * tail mode uses to gate its threshold check, exposed so the function
515
+ * can short-circuit on under-threshold inputs without recomputing.
516
+ */
517
+ type CompactFunction = (messages: SessionMessage[], ctx: {
518
+ /** Resolved `behavior.compactThreshold` (default `131_072` when unset). */threshold: number; /** Resolved `behavior.compactKeepTurns` (default `4` when unset). */
519
+ keepTurns: number;
520
+ /**
521
+ * Pre-compaction sum of `tool_result` output bytes across `messages`
522
+ * — the same heuristic the built-in tail mode uses to decide
523
+ * whether to act. Forwarded so the function can `return messages`
524
+ * verbatim on a quick under-threshold check.
525
+ */
526
+ totalBytes: number;
527
+ }) => SessionMessage[] | Promise<SessionMessage[]>;
528
+ type DedupToolConfig = DedupHasher | {
529
+ hasher: DedupHasher;
530
+ mode?: 'replay' | 'block-after';
531
+ /**
532
+ * For `mode: 'block-after'` only — total count of identical calls
533
+ * (including the first dispatch) at which the gate switches from
534
+ * replay to block. Threshold `4` blocks the 4th identical call;
535
+ * the first 3 (one dispatch + two replays) still go through.
536
+ *
537
+ * Ignored for `mode: 'replay'`. Default: `4`. Values `<= 1` are
538
+ * clamped to `2` (anything less would block the very first replay,
539
+ * which would behave the same as not having a hasher at all).
540
+ */
541
+ threshold?: number;
542
+ /**
543
+ * Refusal text rendered into the model-visible tool_result as
544
+ * `Blocked: <reason>`. Either a literal string or a callback that
545
+ * receives the call's input and the repeat count (1-indexed total
546
+ * of identical calls so far, including this blocking one).
547
+ *
548
+ * Default: a generic "identical call repeated N times" message.
549
+ */
550
+ reason?: string | ((input: Record<string, unknown>, count: number) => string);
551
+ };
425
552
  interface AgentBehavior {
426
553
  /**
427
554
  * Maximum number of tools that may be in flight concurrently within a
@@ -476,6 +603,28 @@ interface AgentBehavior {
476
603
  * Default: unbounded. Set `0` to disable explicitly.
477
604
  */
478
605
  maxTotalTokens?: number;
606
+ /**
607
+ * Bounded retry-with-backoff policy applied around `provider.stream()`.
608
+ *
609
+ * Triggers only on errors the provider classifies as `retryable: true`
610
+ * (typically 429 / 5xx HTTP responses and mid-stream SSE errors like
611
+ * Anthropic's `overloaded_error`). Terminal failures (auth, invalid
612
+ * request, context exceeded, aborts) skip retry and propagate.
613
+ *
614
+ * Skipped when any output has already streamed to the user this turn —
615
+ * replaying over partial text would produce a confusing transcript.
616
+ * Mid-stream continuation (replaying with the partial assistant response
617
+ * appended for the model to continue from) is a separate, larger change.
618
+ *
619
+ * The Anthropic SDK already retries pre-stream errors up to twice
620
+ * internally; this loop-level retry catches mid-stream failures and
621
+ * other providers that don't ship an SDK-side retry.
622
+ *
623
+ * Default: 3 attempts, 1s → 2s → 4s exponential with full jitter,
624
+ * capped at 30s per delay, with `retry-after` / `retry-after-ms`
625
+ * headers honored when present. Set `maxAttempts: 1` to disable.
626
+ */
627
+ retry?: RetryConfig;
479
628
  /** Max tokens per LLM response (default: 16384) */
480
629
  maxTokens?: number;
481
630
  /** Thinking token budget — overrides the level-based default when set */
@@ -671,7 +820,7 @@ interface AgentBehavior {
671
820
  *
672
821
  * Default: `undefined` (no per-tool dedup).
673
822
  */
674
- dedupTools?: Record<string, (input: Record<string, unknown>) => string | undefined>;
823
+ dedupTools?: Record<string, DedupToolConfig>;
675
824
  /**
676
825
  * Require `read_file` before `edit` / `multi_edit` on the same path, and
677
826
  * reject edits when the file has changed on disk since the last read in
@@ -698,10 +847,18 @@ interface AgentBehavior {
698
847
  * short stub, keeping the newest `compactKeepTurns` turns intact. The
699
848
  * compaction is applied to the wire-level message list only; the
700
849
  * underlying session turns are not modified.
850
+ * - **Function** ({@link CompactFunction}) — a pluggable replacement
851
+ * that the loop calls instead of the built-in tail elision. The
852
+ * function receives the post-`context:transform` wire messages and
853
+ * returns the compacted view (sync or async). Use this to plug in
854
+ * an LLM summarizer ("`<analysis>` / `<summary>`" style), a custom
855
+ * semantic-aware compactor, or anything else hosts need beyond the
856
+ * built-ins. The framework never modifies session turns — the same
857
+ * wire-only contract as `'tail'` applies.
701
858
  *
702
859
  * Default: `'off'`.
703
860
  */
704
- compactStrategy?: 'off' | 'tail';
861
+ compactStrategy?: 'off' | 'tail' | CompactFunction;
705
862
  /**
706
863
  * Soft byte threshold that triggers tail compaction when
707
864
  * `compactStrategy === 'tail'`. Counts the post-`context:transform` bytes
@@ -766,12 +923,17 @@ interface AgentBehavior {
766
923
  * - Auto-injects a `tool_search` native tool (opt out via
767
924
  * {@link AgentBehavior.toolSearch}) the model uses to load schemas on
768
925
  * demand. Surfaced tools persist for the rest of the run.
769
- * - Rebuilds the wire-level tool list each turn, appending newly-unlocked
770
- * tools at the end so the prefix-cache breakpoint advances cleanly.
771
- *
772
- * Trade-off: every `tool_search` invocation expands the tool list and
773
- * invalidates the tool-list cache breakpoint for one turn. With many
774
- * MCP servers, the savings on cold turns (fewer schemas in context) are
926
+ * - Rebuilds the wire-level tool list each turn in two phases: every
927
+ * initially-eager tool in registry order (the cache-stable prefix),
928
+ * then every dynamically-unlocked tool in **unlock order** at the
929
+ * tail. Newly-unlocked tools never get inserted into the prefix, so
930
+ * the provider tool-list cache (Anthropic ephemeral) only invalidates
931
+ * the suffix from the first new schema onwards not the full array.
932
+ *
933
+ * Trade-off: every `tool_search` invocation extends the tool list and
934
+ * invalidates the tool-list cache breakpoint for the appended tail on
935
+ * one turn. The eager-prefix portion stays cache-hit. With many MCP
936
+ * servers, the savings on cold turns (fewer schemas in context) are
775
937
  * substantial; with one tiny MCP server, the overhead may not pay back.
776
938
  *
777
939
  * Default: `'eager'`.
@@ -804,6 +966,57 @@ interface AgentBehavior {
804
966
  tool?: false;
805
967
  limit?: number;
806
968
  };
969
+ /**
970
+ * Render the per-server `instructions` payload from the MCP `initialize`
971
+ * handshake as a `# MCP Server Instructions` section appended to the
972
+ * system prompt. Each server may return free-form guidance (e.g. "the
973
+ * database is already provisioned, use `apply_migration` directly")
974
+ * that materially changes how the model uses the server's tools.
975
+ *
976
+ * Matches the Claude Code SDK's default. Without this, models often
977
+ * try to bootstrap state the server already advertises as ready —
978
+ * e.g. running `npx supabase init` in a loop when the MCP server's
979
+ * instructions would have said "skip the init, use `apply_migration`".
980
+ *
981
+ * The section is built once per run and embedded into the system
982
+ * prompt next to the skills + searchable-tools catalogs, so it rides
983
+ * the same system-prompt cache breakpoint. Server insertion order
984
+ * matches `mcpServers` config order for byte-stable output.
985
+ *
986
+ * Only eager-connect servers contribute. `lazyConnect: true` servers
987
+ * are excluded by design — pulling their instructions would force the
988
+ * connection the host asked to defer. Empty / whitespace-only payloads
989
+ * are normalized to "no instructions" so a server that returns `""`
990
+ * doesn't produce a stub heading.
991
+ *
992
+ * Default: `true`. Set `false` for paranoid embedders that want full
993
+ * control of the system prompt or need to avoid leaking server
994
+ * advisories into untrusted contexts.
995
+ */
996
+ surfaceMcpInstructions?: boolean;
997
+ /**
998
+ * Hard cap on consecutive Anthropic `pause_turn` recoveries within a
999
+ * single run. Anthropic 4.6+ may return `stop_reason: 'pause_turn'`
1000
+ * mid-turn for server-side reasons; the loop injects a "Please continue."
1001
+ * user message and re-enters. With some 4.6 streaming edge cases the
1002
+ * model returns empty pauses indefinitely, which without this cap spins
1003
+ * forever burning tokens (the host's only escape was an external abort).
1004
+ *
1005
+ * When the consecutive-empty-pause counter reaches this value, the loop
1006
+ * exits cleanly. The last turn's `TurnUsage.finishReason` stays
1007
+ * `'pause'` so consumers can detect pause exhaustion from `stats`. The
1008
+ * `agent:abort` hook does NOT fire — this is graceful termination, not
1009
+ * user cancel.
1010
+ *
1011
+ * Only turns with no tool calls, no text, AND no thinking count toward
1012
+ * the cap (the case Claude Code's v2 SDK collapses to `stop` outright).
1013
+ * A pause turn with text resets the counter — productive turns are
1014
+ * never penalised.
1015
+ *
1016
+ * Set `0` to disable (loop will continue indefinitely on pauses; useful
1017
+ * only for tests). Default: `5`.
1018
+ */
1019
+ maxConsecutivePauseTurns?: number;
807
1020
  /**
808
1021
  * Persist large `tool_result` outputs to disk and replace the in-message
809
1022
  * content with a `<persisted-output>` stub (preview + filesystem path).
@@ -1525,6 +1738,31 @@ interface AnthropicParams {
1525
1738
  */
1526
1739
  extraBodyParams?: Record<string, unknown>;
1527
1740
  }
1741
+ /**
1742
+ * Mutate an Anthropic request in place to add cache breakpoints on the three
1743
+ * stable prefixes:
1744
+ * 1. System prompt — `cache_control` on the static prefix only (see below).
1745
+ * 2. Tool definitions — last tool.
1746
+ * 3. Conversation — last content block of the last message.
1747
+ *
1748
+ * Each breakpoint tells Anthropic to cache the prefix ending at that block;
1749
+ * subsequent turns reuse the cached prefix and pay only for the delta. Safe
1750
+ * no-op when any prefix is empty (no tools, empty system, etc.).
1751
+ *
1752
+ * System-prompt boundary handling (`SYSTEM_PROMPT_BOUNDARY`):
1753
+ *
1754
+ * - When `originalSystem` is provided AND carries the marker, the system
1755
+ * block is rewritten as a 2-block array: static (cached) then dynamic
1756
+ * (uncached). The caller is expected to have already stripped the marker
1757
+ * from `params.system` via {@link renderSystemForWire} — this helper
1758
+ * only re-splits to apply `cache_control` cleanly.
1759
+ * - When `originalSystem` is omitted or marker-free, the existing single-
1760
+ * block treatment applies: `cache_control` on the whole system string.
1761
+ * - Array system prompts: existing semantics — `cache_control` lands on the
1762
+ * last block. Callers building their own multi-block layout own the
1763
+ * breakpoint placement.
1764
+ */
1765
+ declare function applyAnthropicCacheBreakpoints(params: Anthropic.MessageCreateParamsStreaming, originalSystem?: string): void;
1528
1766
  declare function anthropic(anthropicParams?: AnthropicParams): Provider;
1529
1767
  //#endregion
1530
1768
  //#region src/providers/cerebras.d.ts
@@ -1952,42 +2190,6 @@ interface Provider {
1952
2190
  classifyError?: (err: unknown) => ClassifiedError | null;
1953
2191
  }
1954
2192
  //#endregion
1955
- //#region src/session/file-map.d.ts
1956
- /**
1957
- * Host-provided file-map adapter. Three methods exchanging `Record<string, string>`
1958
- * payloads — the whole persistence surface the wrapper needs.
1959
- */
1960
- interface FileMapAdapter {
1961
- /** Load the current file map. Returns an empty `files` record when nothing is persisted. */
1962
- get: () => Promise<{
1963
- files: Record<string, string>;
1964
- }>;
1965
- /** Replace the persisted file map. Full-rewrite semantics. */
1966
- save: (files: Record<string, string>) => Promise<void>;
1967
- /** Delete all persisted state. */
1968
- delete: () => Promise<void>;
1969
- }
1970
- interface FileMapStoreOptions {
1971
- /** Filename for the JSONL turns log. Default: `turns.jsonl`. */
1972
- turnsFile?: string;
1973
- /** Filename for the metadata JSON. Default: `meta.json`. */
1974
- metaFile?: string;
1975
- }
1976
- /**
1977
- * Create a single-session `SessionStore` backed by a file-map adapter.
1978
- *
1979
- * @example
1980
- * ```ts
1981
- * const session = await createSession({
1982
- * store: createFileMapStore(hostSessionStore),
1983
- * })
1984
- * ```
1985
- */
1986
- declare function createFileMapStore(adapter: FileMapAdapter, options?: FileMapStoreOptions): SessionStore;
1987
- //#endregion
1988
- //#region src/session/memory.d.ts
1989
- declare function createMemoryStore(): SessionStore;
1990
- //#endregion
1991
2193
  //#region src/session/messages.d.ts
1992
2194
  declare function fromAnthropic(msg: {
1993
2195
  role: string;
@@ -2150,11 +2352,139 @@ declare function detectTurnInterruption<T extends {
2150
2352
  role: string;
2151
2353
  content: SessionContentBlock[];
2152
2354
  }>(turns: T[]): TurnInterruptionState;
2355
+ /**
2356
+ * Guarantee a message list ends with a `role: 'user'` message, appending a
2357
+ * synthetic directive when it doesn't.
2358
+ *
2359
+ * Why: Anthropic's API (and several OpenAI-compat reasoning models — opus
2360
+ * 4.7, the o-series translation layers on Bedrock/Vertex) rejects requests
2361
+ * whose final message is `role: 'assistant'` with
2362
+ * "This model does not support assistant message prefill. The conversation
2363
+ * must end with a user message."
2364
+ *
2365
+ * Triggers in zidane:
2366
+ * - Compaction over a session whose last turn is the agent's response
2367
+ * (the common case — autocompact fires right after `agent.run()`).
2368
+ * - Schema enforcement after an assistant text turn (no `tool_use`, so
2369
+ * `ensureToolResultPairing` doesn't synthesize a user tail).
2370
+ * - `context:transform` hooks that strip the trailing user turn.
2371
+ *
2372
+ * The pair-repair pass {@link ensureToolResultPairing} already covers the
2373
+ * orphan-`tool_use` case via mode 2; this helper closes the plain-text
2374
+ * assistant-tail case. They compose: run pair-repair first, then this
2375
+ * pass, so an assistant turn with orphan tool_uses gets its synthetic
2376
+ * `tool_result` user turn AND this pass is a no-op (the synthetic turn
2377
+ * is already user-role).
2378
+ *
2379
+ * Empty input passes through unchanged — the caller's "nothing to send"
2380
+ * guard is responsible for that case; we don't materialize a conversation
2381
+ * out of an empty list.
2382
+ *
2383
+ * Idempotent: returns the input reference unchanged when the list is
2384
+ * already user-terminated (or empty).
2385
+ *
2386
+ * @param messages Wire-ready message list.
2387
+ * @param provider Provider whose `userMessage()` shape we use so the
2388
+ * synthetic turn matches the wire format the rest of
2389
+ * the list already follows.
2390
+ * @param directive Text to put in the synthetic user message. Defaults
2391
+ * to {@link DEFAULT_USER_TAIL_DIRECTIVE} ("Continue.").
2392
+ * Compaction overrides this with a summary-specific cue.
2393
+ */
2394
+ declare function ensureEndsWithUserMessage(messages: SessionMessage[], provider: Provider, directive?: string): SessionMessage[];
2395
+ interface ToWireMessagesOptions {
2396
+ /**
2397
+ * Pairing-repair telemetry. Fires once per repair the underlying
2398
+ * {@link ensureToolResultPairing} pass performs. Mirrors the
2399
+ * `pairing:repair` hook surface so consumers can wire structured logging
2400
+ * without an agent instance.
2401
+ */
2402
+ onRepair?: (repair: PairingRepair) => void;
2403
+ /**
2404
+ * When set, also runs {@link ensureEndsWithUserMessage} so the result is
2405
+ * safe for assistant-prefill-rejecting models (opus 4.7, o-series
2406
+ * translation layers). Omit to skip — pure pairing repair only.
2407
+ */
2408
+ provider?: Provider;
2409
+ /**
2410
+ * Override for the synthetic user-tail directive. Only consulted when
2411
+ * `provider` is set. Defaults to {@link DEFAULT_USER_TAIL_DIRECTIVE}.
2412
+ */
2413
+ userTailDirective?: string;
2414
+ }
2415
+ /**
2416
+ * Build a wire-ready `SessionMessage[]` from raw persisted `SessionTurn[]`.
2417
+ *
2418
+ * **The canonical "I want to send these to a provider" projection.** Use
2419
+ * this — not raw `session.turns` / `store.getTurns()` — when constructing a
2420
+ * provider request outside `agent.run()`. The agent's own wire pipeline
2421
+ * (`executeTurn` in `src/loop.ts`) applies the same repair just-in-time;
2422
+ * downstream consumers that bypass the loop hit `tool_result must be
2423
+ * preceded by a tool_call` 400s precisely because they shipped raw turns.
2424
+ *
2425
+ * Pipeline:
2426
+ * 1. Filter `system`-role turns (the wire only carries user/assistant).
2427
+ * 2. {@link ensureToolResultPairing} — repairs all six orphan / dup
2428
+ * corruption modes by inserting synthetic placeholders rather than
2429
+ * dropping (preserves the model's tool_use shape).
2430
+ * 3. {@link ensureEndsWithUserMessage} when `options.provider` is set —
2431
+ * guards against assistant-tail prefill rejection (opus 4.7, o-series).
2432
+ *
2433
+ * Pure + idempotent. Does not mutate the input turns. Re-running on the
2434
+ * output is a no-op.
2435
+ *
2436
+ * **Do not feed the result back into `session.setTurns` / `appendTurns`.**
2437
+ * The repair can insert `SYNTHETIC_TOOL_RESULT_PLACEHOLDER` / `[Orphaned
2438
+ * tool result removed …]` markers; round-tripping those into persisted
2439
+ * state contaminates the session's reasoning history and defeats the
2440
+ * "don't rewrite the past" invariant the wire-only repair was designed
2441
+ * around.
2442
+ */
2443
+ declare function toWireMessages(turns: readonly {
2444
+ role: 'user' | 'assistant' | 'system';
2445
+ content: SessionContentBlock[];
2446
+ }[], options?: ToWireMessagesOptions): SessionMessage[];
2153
2447
  declare function autoDetectAndConvert(msg: {
2154
2448
  role: string;
2155
2449
  content: unknown;
2156
2450
  }): SessionMessage;
2157
2451
  //#endregion
2452
+ //#region src/session/file-map.d.ts
2453
+ /**
2454
+ * Host-provided file-map adapter. Three methods exchanging `Record<string, string>`
2455
+ * payloads — the whole persistence surface the wrapper needs.
2456
+ */
2457
+ interface FileMapAdapter {
2458
+ /** Load the current file map. Returns an empty `files` record when nothing is persisted. */
2459
+ get: () => Promise<{
2460
+ files: Record<string, string>;
2461
+ }>;
2462
+ /** Replace the persisted file map. Full-rewrite semantics. */
2463
+ save: (files: Record<string, string>) => Promise<void>;
2464
+ /** Delete all persisted state. */
2465
+ delete: () => Promise<void>;
2466
+ }
2467
+ interface FileMapStoreOptions {
2468
+ /** Filename for the JSONL turns log. Default: `turns.jsonl`. */
2469
+ turnsFile?: string;
2470
+ /** Filename for the metadata JSON. Default: `meta.json`. */
2471
+ metaFile?: string;
2472
+ }
2473
+ /**
2474
+ * Create a single-session `SessionStore` backed by a file-map adapter.
2475
+ *
2476
+ * @example
2477
+ * ```ts
2478
+ * const session = await createSession({
2479
+ * store: createFileMapStore(hostSessionStore),
2480
+ * })
2481
+ * ```
2482
+ */
2483
+ declare function createFileMapStore(adapter: FileMapAdapter, options?: FileMapStoreOptions): SessionStore;
2484
+ //#endregion
2485
+ //#region src/session/memory.d.ts
2486
+ declare function createMemoryStore(): SessionStore;
2487
+ //#endregion
2158
2488
  //#region src/session/remote.d.ts
2159
2489
  interface RemoteStoreOptions {
2160
2490
  /** Base URL of the session API */
@@ -2279,7 +2609,22 @@ interface Session {
2279
2609
  * Set once on creation; surfaces here for read-only inspection.
2280
2610
  */
2281
2611
  readonly projectRoot?: string;
2282
- /** Current turn history */
2612
+ /**
2613
+ * Raw persisted turn history — kept pristine for fidelity (the model's
2614
+ * reasoning chain stays intact across reloads).
2615
+ *
2616
+ * **DO NOT pass this directly to a provider request.** Mid-pair
2617
+ * persistence (interrupted runs, partial-result writes, compaction
2618
+ * boundaries) leaves orphan `tool_use` / `tool_result` blocks here that
2619
+ * every provider 400s on (`tool_result must be preceded by a tool_call
2620
+ * with the same toolCallId`). The agent's own loop repairs these
2621
+ * just-in-time at wire-send time and never writes the repair back to
2622
+ * `turns`.
2623
+ *
2624
+ * For provider requests built outside `agent.run()`, use
2625
+ * {@link Session.toMessages} — it applies the same defensive pairing
2626
+ * repair and returns a guaranteed-safe `SessionMessage[]`.
2627
+ */
2283
2628
  readonly turns: SessionTurn[];
2284
2629
  /**
2285
2630
  * True when this session has no turns yet.
@@ -2360,6 +2705,27 @@ interface Session {
2360
2705
  setMeta: (key: string, value: unknown) => void;
2361
2706
  /** Persist the full session document to the store */
2362
2707
  save: () => Promise<void>;
2708
+ /**
2709
+ * Project the session's persisted turns into a wire-ready
2710
+ * `SessionMessage[]` safe to hand to any provider.
2711
+ *
2712
+ * The canonical answer to "I need to send these turns to Anthropic /
2713
+ * OpenAI from outside `agent.run()`" (sub-agent classifier, side-channel
2714
+ * summarizer, replay worker, …). Runs the same defensive pairing repair
2715
+ * the agent loop applies just-in-time at wire-send time
2716
+ * ({@link ensureToolResultPairing}), so orphan `tool_use` blocks and
2717
+ * dangling `tool_result`s never reach the provider as the 400
2718
+ * "tool_result must be preceded by a tool_call with the same toolCallId".
2719
+ *
2720
+ * Pass `provider` to also enforce the user-tail invariant
2721
+ * ({@link ensureEndsWithUserMessage}) — required for opus 4.7 / o-series
2722
+ * style models that reject assistant-prefill.
2723
+ *
2724
+ * Pure + idempotent. Does NOT mutate `session.turns`. **Do not write the
2725
+ * result back via `setTurns` / `appendTurns`** — synthetic placeholders
2726
+ * inserted by the repair will contaminate persisted history.
2727
+ */
2728
+ toMessages: (options?: ToWireMessagesOptions) => SessionMessage[];
2363
2729
  /** Serialize to SessionData */
2364
2730
  toJSON: () => SessionData;
2365
2731
  }
@@ -2721,6 +3087,29 @@ type ToolMap = Map<string, ToolDef>;
2721
3087
  //#region src/mcp/index.d.ts
2722
3088
  interface McpConnection {
2723
3089
  tools: Record<string, ToolDef>;
3090
+ /**
3091
+ * Per-server `instructions` payload from the MCP `initialize` handshake,
3092
+ * keyed by server name. Each server may return free-form guidance the
3093
+ * model is meant to read alongside the tool catalog — typical content
3094
+ * is "the database is already provisioned, use `apply_migration`
3095
+ * directly" or "always wrap SELECTs in a transaction". The agent
3096
+ * renders these into a system-prompt section when
3097
+ * `behavior.surfaceMcpInstructions` is on (default).
3098
+ *
3099
+ * Servers that omit the field, return an empty string, or fail to
3100
+ * connect contribute no entry. Lazy-connected servers contribute an
3101
+ * entry only once their first connect resolves — until then the model
3102
+ * never sees their instructions, matching the schema-loading semantics
3103
+ * of `lazyConnect`.
3104
+ *
3105
+ * Map (not Record) so insertion order matches server config order and
3106
+ * the rendered section is byte-stable for the cache breakpoint.
3107
+ *
3108
+ * Optional so custom `mcpConnector` implementations from before this
3109
+ * field existed still type-check; the framework's own
3110
+ * `connectMcpServers` always returns a Map (possibly empty).
3111
+ */
3112
+ instructions?: Map<string, string>;
2724
3113
  close: () => Promise<void>;
2725
3114
  }
2726
3115
  /**
@@ -2895,6 +3284,18 @@ interface AgentHooks {
2895
3284
  startedAt: number;
2896
3285
  tracingContext?: Readonly<Record<string, string>>;
2897
3286
  }) => void;
3287
+ /**
3288
+ * Fires immediately before each turn's `provider.stream()` call, after
3289
+ * `context:transform` + pairing repair + `system:transform`. The
3290
+ * `options` object IS mutable as a last-mile escape hatch (per-turn
3291
+ * reminders, dynamic tags, audit wrapping), but prefer
3292
+ * {@link AgentHooks['context:transform']} for any mutation that touches
3293
+ * `messages` — it runs upstream of the defensive pairing pass and stays
3294
+ * cheaper. Loop re-runs `ensureToolResultPairing` + `ensureEndsWithUserMessage`
3295
+ * after this hook so a `messages` mutation here can't leak a
3296
+ * `tool_result must be preceded by a tool_call` 400 to the wire, but you
3297
+ * pay one extra walk for the privilege.
3298
+ */
2898
3299
  'turn:before': (ctx: {
2899
3300
  turn: number;
2900
3301
  turnId: string;
@@ -3020,14 +3421,61 @@ interface AgentHooks {
3020
3421
  statusCode?: number;
3021
3422
  requestId?: string;
3022
3423
  }) => void;
3424
+ /**
3425
+ * Fires when the loop catches a `retryable` provider error and is about
3426
+ * to sleep before re-issuing `provider.stream()`. Does NOT fire on the
3427
+ * terminal failure (the attempt the loop gives up on) — that lands on
3428
+ * `stream:error` instead, same as today.
3429
+ *
3430
+ * Use this hook to surface "Anthropic overloaded — retrying in Ns" in
3431
+ * the TUI, count retries in observability, or short-circuit further
3432
+ * retry logic from an outer harness.
3433
+ *
3434
+ * - `attempt` — 1-indexed number of the attempt that just failed.
3435
+ * - `nextAttempt` — `attempt + 1`, the attempt that will run after the sleep.
3436
+ * - `delayMs` — the wait the loop is about to take. Already accounts for
3437
+ * any `retry-after` / `retry-after-ms` header the server returned and
3438
+ * the configured `maxDelayMs` cap.
3439
+ * - `err` — the raw thrown value (same as `stream:error.err`).
3440
+ * - `statusCode` / `requestId` — extracted via the same helper as
3441
+ * `stream:error` when available.
3442
+ *
3443
+ * Observational — handlers cannot cancel the retry. To disable retry,
3444
+ * set `behavior.retry.maxAttempts: 1`.
3445
+ */
3446
+ 'stream:retry': (ctx: StreamHookContext & {
3447
+ attempt: number;
3448
+ nextAttempt: number;
3449
+ delayMs: number;
3450
+ err: unknown;
3451
+ statusCode?: number;
3452
+ requestId?: string;
3453
+ }) => void;
3023
3454
  'oauth:refresh': (ctx: OAuthRefreshHookContext) => void;
3024
3455
  /**
3025
3456
  * Fires before validation, `tool:before`, and `execute`. Two ways to
3026
3457
  * intercept:
3027
3458
  *
3028
3459
  * - Set `block = true` (with a `reason`) to refuse the call. The model
3029
- * sees a `Blocked: <reason>` tool result; `tool:before` / `tool:after`
3030
- * do **not** fire.
3460
+ * sees a `tool_result` block with `content` = `Blocked: <reason>` and
3461
+ * `is_error: true`. `tool:before` / `tool:after` do **not** fire;
3462
+ * `tool:dispatched` does (with `outcome: 'gate-block'`) so trace /
3463
+ * audit consumers see the refusal. The exact wire payload is:
3464
+ *
3465
+ * ```jsonc
3466
+ * {
3467
+ * "type": "tool_result",
3468
+ * "tool_use_id": "<call id>",
3469
+ * "content": "Blocked: <reason>", // verbatim, no wrapping XML
3470
+ * "is_error": true
3471
+ * }
3472
+ * ```
3473
+ *
3474
+ * The `Blocked: ` prefix is fixed (single space, no colon variations);
3475
+ * the `<reason>` is whatever string the gate handler assigned to
3476
+ * `ctx.reason` (defaults to `'Tool execution was blocked'` if no
3477
+ * handler set it). Pinned by `test/dedup-tools.test.ts` so SDK
3478
+ * consumers can safely string-match for telemetry / eval scoring.
3031
3479
  * - Set `result` to substitute a successful tool_result and skip
3032
3480
  * execution. The model sees the substitute as a normal tool_result;
3033
3481
  * `tool:before` does not fire, but `tool:after` and `tool:transform`
@@ -3068,6 +3516,26 @@ interface AgentHooks {
3068
3516
  * for `write_file` on a fresh-create.
3069
3517
  */
3070
3518
  priorContent?: string;
3519
+ /**
3520
+ * `true` when the call's name has no matching registered tool — the
3521
+ * model invented it (hallucination) or referenced a tool whose
3522
+ * registration is gone (an MCP server dropped, an alias removed).
3523
+ *
3524
+ * Fires immediately BEFORE the `tool:unknown` substitute path so UI
3525
+ * consumers using `tool:before` to render a tool card still see
3526
+ * the model's attempt — otherwise the call was silently swallowed
3527
+ * and the model's intent never surfaced in the transcript.
3528
+ *
3529
+ * Pairing contract for `unknown: true` events:
3530
+ * - `tool:after` does NOT fire (the body never executed).
3531
+ * - `tool:error` fires next (unless the `tool:unknown` handler
3532
+ * sets `suppressError`).
3533
+ * - `tool:dispatched` fires with `outcome: 'unknown'`.
3534
+ *
3535
+ * Mutations to `ctx.input` / `ctx.coercions` on this path are
3536
+ * observational only — there's no body to dispatch them into.
3537
+ */
3538
+ unknown?: boolean;
3071
3539
  }) => void;
3072
3540
  /**
3073
3541
  * Symmetric notification fired ONCE per call the model dispatched,
@@ -3076,12 +3544,14 @@ interface AgentHooks {
3076
3544
  * get a guaranteed `tool` ↔ `tool-result` event pairing for downstream
3077
3545
  * consumers reconstructing message history from live events.
3078
3546
  *
3079
- * Distinct from `tool:before`: `tool:before` only fires when the tool
3080
- * body is about to execute (the legacy "I'm running this tool" notification),
3081
- * skipping gate-block / gate-substitute / unknown-tool / validation-reject
3082
- * paths. `tool:dispatched` fires on all five paths with an `outcome`
3083
- * discriminator so live consumers never see a `tool:after` whose
3084
- * matching dispatch event was suppressed.
3547
+ * Distinct from `tool:before`: `tool:before` fires when a tool's body
3548
+ * is about to execute (the legacy "I'm running this tool" notification)
3549
+ * OR as a special case — once with `unknown: true` for hallucinated
3550
+ * tool names, so UI consumers rendering tool cards still see the
3551
+ * model's attempt. It still skips gate-block / gate-substitute /
3552
+ * validation-reject paths. `tool:dispatched` fires on all five paths
3553
+ * with an `outcome` discriminator so live consumers never see a
3554
+ * `tool:after` whose matching dispatch event was suppressed.
3085
3555
  *
3086
3556
  * Strict ordering: `tool:dispatched` fires AFTER `tool:gate` /
3087
3557
  * `validation:reject` / `tool:unknown` so the resolved `outcome` is
@@ -3970,6 +4440,21 @@ interface Agent {
3970
4440
  * model / capability defaults, construct a new provider.
3971
4441
  */
3972
4442
  readonly meta: Readonly<Record<string, unknown>>;
4443
+ /**
4444
+ * TC39 explicit-resource-management `await using` sink — alias for
4445
+ * {@link Agent.destroy}. Lets hosts write:
4446
+ *
4447
+ * ```ts
4448
+ * await using agent = createAgent({ ... })
4449
+ * await agent.run({ prompt: 'go' })
4450
+ * // agent.destroy() runs automatically at scope exit
4451
+ * ```
4452
+ *
4453
+ * Requires Node 20+ (or any runtime that ships the TC39
4454
+ * explicit-resource-management proposal). Older runtimes simply ignore
4455
+ * the symbol; nothing breaks. Idempotent because `destroy()` is.
4456
+ */
4457
+ [Symbol.asyncDispose]: () => Promise<void>;
3973
4458
  }
3974
4459
  declare function createAgent({
3975
4460
  provider,
@@ -3989,5 +4474,5 @@ declare function createAgent({
3989
4474
  clock: agentClock
3990
4475
  }: AgentOptions): Agent;
3991
4476
  //#endregion
3992
- export { fromOpenAI as $, SpawnHookContext as $t, SkillSource as A, cerebras as At, createRemoteStore as B, McpToolHookContext as Bt, getReadState as C, OpenAICompatParams as Ct, SkillConfig as D, OpenAIParams as Dt, resolveReadStateMap as E, openaiCompat as Et, SessionRun as F, AgentRunOptions as Ft, SYNTHETIC_TOOL_RESULT_PLACEHOLDER as G, PromptPart as Gt, ORPHANED_TOOL_RESULT_MARKER as H, OAuthRefreshHookContext as Ht, SessionStore as I, AgentStats as It, autoDetectAndConvert as J, SessionContentBlock as Jt, TOOL_USE_INTERRUPTED_MARKER as K, PromptTextPart as Kt, createSession as L, ChildRunStats as Lt, CreateSessionOptions as M, anthropic as Mt, Session as N, AgentBehavior as Nt, SkillDiagnostic as O, openai as Ot, SessionData as P, AgentClock as Pt, fromAnthropic as Q, SessionTurn as Qt, loadSession as R, DEFAULT_AGENT_CLOCK as Rt, ReadStateMap as S, OpenAICompatHttpError as St, readStateKey as T, mapOAIFinishReason as Tt, PairingRepair as U, PromptDocumentPart as Ut, EnsureToolResultPairingOptions as V, McpToolSchema as Vt, PairingRepairMode as W, PromptImagePart as Wt, ensureToolResultPairing as X, SessionHookContext as Xt, detectTurnInterruption as Y, SessionEndStatus as Yt, filterUnresolvedToolUses as Z, SessionMessage as Zt, resultToString as _, ClassifiedError as _n, sanitizeToolSchema as _t, createAgent as a, ToolResultTextContent as an, createFileMapStore as at, ToolMap as b, matchesContextExceeded as bn, openrouter as bt, DeactivationReason as c, toolOutputByteLength as cn, StreamCallbacks as ct, createSkillActivationState as d, AgentBudgetExceededError as dn, ToolResult as dt, StreamHookContext as en, toAnthropic as et, ConnectMcpServersOptions as f, AgentContextExceededError as fn, ToolSpec as ft, normalizeMcpServers as g, CONTEXT_EXCEEDED_MESSAGE_PATTERNS as gn, SchemaSanitizeResult as gt, normalizeMcpBlocks as h, AgentToolPairingError as hn, SchemaSanitizeProfile as ht, AgentOptions as i, ToolResultImageContent as in, FileMapStoreOptions as it, SkillsConfig as j, AnthropicParams as jt, SkillResource as k, CerebrasParams as kt, SkillActivationState as l, toolResultToText as ln, StreamOptions as lt, connectMcpServers as m, AgentToolNotAllowedError as mn, SchemaSanitizeOptions as mt, AgentHookMap as n, ToolHookContext as nn, createMemoryStore as nt, ActivationVia as o, TurnFinishReason as on, Provider as ot, McpConnection as p, AgentProviderError as pn, TurnResult as pt, TurnInterruptionState as q, RunHookMap as qt, AgentHooks as r, ToolResultContent as rn, FileMapAdapter as rt, ActiveSkill as s, TurnUsage as sn, ProviderCapabilities as st, Agent as t, ThinkingLevel as tn, toOpenAI as tt, SkillActivationStateOptions as u, AgentAbortedError as un, ToolCall as ut, ToolContext as v, ClassifiedErrorKind as vn, sanitizeToolSpecs as vt, hashContent as w, classifyOpenAICompatError as wt, ReadStateEntry as x, toTypedError as xn, OpenAICompatAuthHeader as xt, ToolDef as y, errorMessage as yn, OpenRouterParams as yt, RemoteStoreOptions as z, McpServerConfig as zt };
3993
- //# sourceMappingURL=agent-C9AKTU_V.d.ts.map
4477
+ export { autoDetectAndConvert as $, PromptTextPart as $t, SkillSource as A, OpenAIParams as At, createRemoteStore as B, AgentStats as Bt, getReadState as C, AgentToolPairingError as Cn, openrouter as Ct, SkillConfig as D, errorMessage as Dn, classifyOpenAICompatError as Dt, resolveReadStateMap as E, ClassifiedErrorKind as En, OpenAICompatParams as Et, SessionRun as F, anthropic as Ft, EnsureToolResultPairingOptions as G, DedupToolConfig as Gt, FileMapAdapter as H, CompactFunction as Ht, SessionStore as I, applyAnthropicCacheBreakpoints as It, PairingRepairMode as J, McpToolSchema as Jt, ORPHANED_TOOL_RESULT_MARKER as K, McpServerConfig as Kt, createSession as L, AgentBehavior as Lt, CreateSessionOptions as M, CerebrasParams as Mt, Session as N, cerebras as Nt, SkillDiagnostic as O, matchesContextExceeded as On, mapOAIFinishReason as Ot, SessionData as P, AnthropicParams as Pt, TurnInterruptionState as Q, PromptPart as Qt, loadSession as R, AgentClock as Rt, ReadStateMap as S, AgentToolNotAllowedError as Sn, OpenRouterParams as St, readStateKey as T, ClassifiedError as Tn, OpenAICompatHttpError as Tt, FileMapStoreOptions as U, DEFAULT_AGENT_CLOCK as Ut, createMemoryStore as V, ChildRunStats as Vt, createFileMapStore as W, DedupHasher as Wt, TOOL_USE_INTERRUPTED_MARKER as X, PromptDocumentPart as Xt, SYNTHETIC_TOOL_RESULT_PLACEHOLDER as Y, OAuthRefreshHookContext as Yt, ToWireMessagesOptions as Z, PromptImagePart as Zt, resultToString as _, toolResultToText as _n, SchemaSanitizeOptions as _t, createAgent as a, SessionMessage as an, fromOpenAI as at, ToolMap as b, AgentContextExceededError as bn, sanitizeToolSchema as bt, DeactivationReason as c, StreamHookContext as cn, toWireMessages as ct, createSkillActivationState as d, ToolResultContent as dn, StreamCallbacks as dt, RetryConfig as en, detectTurnInterruption as et, ConnectMcpServersOptions as f, ToolResultImageContent as fn, StreamOptions as ft, normalizeMcpServers as g, toolOutputByteLength as gn, TurnResult as gt, normalizeMcpBlocks as h, TurnUsage as hn, ToolSpec as ht, AgentOptions as i, SessionHookContext as in, fromAnthropic as it, SkillsConfig as j, openai as jt, SkillResource as k, toTypedError as kn, openaiCompat as kt, SkillActivationState as l, ThinkingLevel as ln, Provider as lt, connectMcpServers as m, TurnFinishReason as mn, ToolResult as mt, AgentHookMap as n, SessionContentBlock as nn, ensureToolResultPairing as nt, ActivationVia as o, SessionTurn as on, toAnthropic as ot, McpConnection as p, ToolResultTextContent as pn, ToolCall as pt, PairingRepair as q, McpToolHookContext as qt, AgentHooks as r, SessionEndStatus as rn, filterUnresolvedToolUses as rt, ActiveSkill as s, SpawnHookContext as sn, toOpenAI as st, Agent as t, RunHookMap as tn, ensureEndsWithUserMessage as tt, SkillActivationStateOptions as u, ToolHookContext as un, ProviderCapabilities as ut, ToolContext as v, AgentAbortedError as vn, SchemaSanitizeProfile as vt, hashContent as w, CONTEXT_EXCEEDED_MESSAGE_PATTERNS as wn, OpenAICompatAuthHeader as wt, ReadStateEntry as x, AgentProviderError as xn, sanitizeToolSpecs as xt, ToolDef as y, AgentBudgetExceededError as yn, SchemaSanitizeResult as yt, RemoteStoreOptions as z, AgentRunOptions as zt };
4478
+ //# sourceMappingURL=agent-ClkpElCZ.d.ts.map