@graphorin/agent 0.6.0 → 0.7.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +31 -11
  3. package/dist/errors/index.d.ts +17 -4
  4. package/dist/errors/index.d.ts.map +1 -1
  5. package/dist/errors/index.js +19 -3
  6. package/dist/errors/index.js.map +1 -1
  7. package/dist/factory.d.ts.map +1 -1
  8. package/dist/factory.js +153 -1930
  9. package/dist/factory.js.map +1 -1
  10. package/dist/fanout/index.d.ts +13 -1
  11. package/dist/fanout/index.d.ts.map +1 -1
  12. package/dist/fanout/index.js +13 -4
  13. package/dist/fanout/index.js.map +1 -1
  14. package/dist/index.d.ts +7 -6
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +11 -9
  17. package/dist/index.js.map +1 -1
  18. package/dist/lateral-leak/index.js +1 -1
  19. package/dist/package.js +6 -0
  20. package/dist/package.js.map +1 -0
  21. package/dist/run-state/index.d.ts +32 -6
  22. package/dist/run-state/index.d.ts.map +1 -1
  23. package/dist/run-state/index.js +46 -22
  24. package/dist/run-state/index.js.map +1 -1
  25. package/dist/runtime/agent-surface.js +122 -0
  26. package/dist/runtime/agent-surface.js.map +1 -0
  27. package/dist/runtime/agent-to-tool.d.ts +51 -0
  28. package/dist/runtime/agent-to-tool.d.ts.map +1 -0
  29. package/dist/runtime/agent-to-tool.js +145 -0
  30. package/dist/runtime/agent-to-tool.js.map +1 -0
  31. package/dist/runtime/approvals.js +0 -0
  32. package/dist/runtime/approvals.js.map +1 -0
  33. package/dist/runtime/dispatch.js +108 -0
  34. package/dist/runtime/dispatch.js.map +1 -0
  35. package/dist/runtime/executor-wiring.js +128 -0
  36. package/dist/runtime/executor-wiring.js.map +1 -0
  37. package/dist/runtime/fallback-chain.js +139 -0
  38. package/dist/runtime/fallback-chain.js.map +1 -0
  39. package/dist/runtime/handoff.js +307 -0
  40. package/dist/runtime/handoff.js.map +1 -0
  41. package/dist/runtime/messages.d.ts +22 -0
  42. package/dist/runtime/messages.d.ts.map +1 -0
  43. package/dist/runtime/messages.js +204 -0
  44. package/dist/runtime/messages.js.map +1 -0
  45. package/dist/runtime/provider-events.js +117 -0
  46. package/dist/runtime/provider-events.js.map +1 -0
  47. package/dist/runtime/run-compaction.js +210 -0
  48. package/dist/runtime/run-compaction.js.map +1 -0
  49. package/dist/runtime/run-finish.js +48 -0
  50. package/dist/runtime/run-finish.js.map +1 -0
  51. package/dist/runtime/run-gates.js +336 -0
  52. package/dist/runtime/run-gates.js.map +1 -0
  53. package/dist/runtime/run-init.js +81 -0
  54. package/dist/runtime/run-init.js.map +1 -0
  55. package/dist/runtime/run-input.js +46 -0
  56. package/dist/runtime/run-input.js.map +1 -0
  57. package/dist/runtime/step-catalogue.js +173 -0
  58. package/dist/runtime/step-catalogue.js.map +1 -0
  59. package/dist/runtime/tool-call-walk.js +189 -0
  60. package/dist/runtime/tool-call-walk.js.map +1 -0
  61. package/dist/runtime/tool-wiring.js +159 -0
  62. package/dist/runtime/tool-wiring.js.map +1 -0
  63. package/dist/tooling/adapters.js +1 -1
  64. package/dist/tooling/dataflow.js +1 -1
  65. package/dist/tooling/policy.js +2 -0
  66. package/dist/tooling/policy.js.map +1 -1
  67. package/dist/types.d.ts +63 -13
  68. package/dist/types.d.ts.map +1 -1
  69. package/package.json +20 -20
  70. package/src/errors/index.ts +320 -0
  71. package/src/evaluator-optimizer/index.ts +212 -0
  72. package/src/factory.ts +957 -0
  73. package/src/fallback/index.ts +108 -0
  74. package/src/fanout/index.ts +523 -0
  75. package/src/filters/index.ts +347 -0
  76. package/src/index.ts +180 -0
  77. package/src/internal/ids.ts +46 -0
  78. package/src/internal/usage-accumulator.ts +90 -0
  79. package/src/lateral-leak/causality-monitor.ts +221 -0
  80. package/src/lateral-leak/index.ts +35 -0
  81. package/src/lateral-leak/merge-guard.ts +151 -0
  82. package/src/lateral-leak/protocol-guard.ts +222 -0
  83. package/src/preferred-model/index.ts +210 -0
  84. package/src/progress/index.ts +238 -0
  85. package/src/run-state/index.ts +607 -0
  86. package/src/runtime/agent-surface.ts +218 -0
  87. package/src/runtime/agent-to-tool.ts +323 -0
  88. package/src/runtime/approvals.ts +0 -0
  89. package/src/runtime/dispatch.ts +183 -0
  90. package/src/runtime/executor-wiring.ts +331 -0
  91. package/src/runtime/fallback-chain.ts +250 -0
  92. package/src/runtime/handoff.ts +428 -0
  93. package/src/runtime/messages.ts +309 -0
  94. package/src/runtime/provider-events.ts +175 -0
  95. package/src/runtime/run-compaction.ts +288 -0
  96. package/src/runtime/run-finish.ts +93 -0
  97. package/src/runtime/run-gates.ts +419 -0
  98. package/src/runtime/run-init.ts +169 -0
  99. package/src/runtime/run-input.ts +102 -0
  100. package/src/runtime/step-catalogue.ts +338 -0
  101. package/src/runtime/tool-call-walk.ts +301 -0
  102. package/src/runtime/tool-wiring.ts +218 -0
  103. package/src/testing/replay-provider.ts +121 -0
  104. package/src/tooling/adapters.ts +403 -0
  105. package/src/tooling/catalogue.ts +36 -0
  106. package/src/tooling/dataflow.ts +171 -0
  107. package/src/tooling/plan.ts +123 -0
  108. package/src/tooling/policy.ts +67 -0
  109. package/src/tooling/registry-build.ts +191 -0
  110. package/src/types.ts +696 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,101 @@
1
1
  # @graphorin/agent
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-100: `AnyTool` existential type; `createAgent({ tools })` accepts concretely-typed tools without casts.
8
+
9
+ `Tool` is invariant in `TInput` (the `needsApproval`/`idempotencyKey` predicate properties are contravariant), so a typed `Tool<{q: string}, number, D>` was never assignable to `Tool<unknown, unknown, D>` - forcing `as unknown as Tool<...>` at every collection seam. `@graphorin/core` now exports `AnyTool<TDeps> = Tool<any, any, TDeps>` (existential input/output, following the `HandoffEntry` precedent), and both `AgentConfig.tools` and `PrepareStepOverrides.tools` in `@graphorin/agent` accept `ReadonlyArray<AnyTool<TDeps>>`. Widening only - existing code keeps compiling. `ToolRegistry.register` was already per-call generic and needed no change.
10
+
11
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-005: HITL/workflow checkpoints are linked to their session and erased by the session hard-delete cascade.
12
+
13
+ HITL suspends persist the FULL serialized conversation (`RunState`) into `workflow_checkpoints`; previously nothing connected those rows to a session, so `DELETE /v1/sessions/:id` left the entire transcript recoverable forever. Now: `CheckpointMetadata` gains an optional `sessionId` (additive); migration 029 adds a `session_id` column + index to `workflow_checkpoints` and backfills historical `namespace='agent'` rows from the state blob; the agent runtime stamps `sessionId` on all three suspend write sites (step suspend, resume write-ahead intent, post-dispatch journal); and `deleteSession`/`pruneSessions` collect thread ids from BOTH `session_workflow_runs` and the new column, erasing `workflow_checkpoints` + `workflow_pending_writes` before dropping the mapping. Deleting a session now removes its suspended-run snapshots - time-travel/forensics for a deleted session is intentionally gone (that is what hard-delete means).
14
+
15
+ - [#153](https://github.com/o-stepper/graphorin/pull/153) [`832f22e`](https://github.com/o-stepper/graphorin/commit/832f22e570b8c3175c1adeb4c150070cbd131534) Thanks [@o-stepper](https://github.com/o-stepper)! - Reachable per-thread checkpoint erasure (W-005) - `CheckpointStore.deleteThread` finally has supported callers:
16
+
17
+ - `@graphorin/workflow`: the workflow handle gains `deleteThread(threadId)` next to `listCheckpoints` (idempotent; deletes every checkpoint + pending write of the thread).
18
+ - `@graphorin/server`: new route `DELETE /v1/workflows/:id/threads/:threadId` under scope `workflows:delete:<id>` (204 on success, 404 for an unknown workflow, 400 when the registered entry does not expose `deleteThread`); `ServerWorkflowLike` gains the optional `deleteThread?` member.
19
+ - `@graphorin/agent`: opt-in `AgentConfig.checkpointPolicy: 'keep' | 'delete-on-terminal'` (default `'keep'` - byte-identical to today). With `'delete-on-terminal'` the run's checkpoint thread is best-effort deleted after `completed`/`failed` runs, mirroring the TL-10 spill lifecycle; `awaiting_approval` and `aborted` runs always keep theirs (the thread is the resume state).
20
+
21
+ Full erasure cascades stay the job of the session purge path; these are the operator levers for hygiene and targeted per-thread GDPR requests.
22
+
23
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-025/W-100: export `HandoffEntry` from the package root - it is the public type of `AgentConfig.handoffs` and was previously only reachable via type inference, forcing `as unknown as Agent<TDeps, unknown>` casts in consumers that wanted a typed handoff list.
24
+
25
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-072: every export map's `import` condition becomes `default`, and the Node floor rises to `>=22.12.0`.
26
+
27
+ CJS consumers previously hit a bewildering `ERR_PACKAGE_PATH_NOT_EXPORTED` instead of a clear ESM-only signal. With the `default` condition, plain `require('@graphorin/core')` works via Node's stable `require(esm)` - which shipped in 22.12, hence the engines bump across every workspace manifest (packages, examples, benchmarks, docs; enforced by the widened mvp-readiness sweep). No dual-instance hazard: there is no CJS build, `require()` returns the same ESM module instance. ESM consumers are unaffected (`default` serves both paths; `types` stays first). The pack gate now runs attw under the full `node16` profile (was `esm-only`) and adds a runtime `require(esm)` smoke against the packed tarballs. Installs on Node 22.0-22.11 with `engine-strict` will refuse - upgrade Node (see the migration guide).
28
+
29
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-024: thinking-block signatures now actually round-trip - the whole retention pipeline was dead because nothing captured them.
30
+
31
+ `ProviderEvent` gains a `{type: 'reasoning-end', meta?: ReasoningContentMeta}` terminator (per-block, matching both AI SDK generations). The vercel adapter maps v4 `reasoning-signature`/`redacted-reasoning` chunks and v7 `reasoning-end` (`providerMetadata.anthropic.signature`/`.redactedData`) onto it; `reasoning-start` stays a no-op. The agent runtime flushes buffered deltas into per-block `ReasoningContent` parts carrying the meta (redacted blocks become meta-only parts), and the step assembles those parts instead of one meta-less collapse - adapters without block structure keep the collapsed fallback. Downstream, the already-shipped chain finally engages: `applyReasoningPolicy('pass-through-claude')` retains the signed parts and `toAssistantPart` emits `providerOptions.anthropic.signature`, so multi-step tool use with Anthropic extended thinking replays each block byte-equal (pinned end-to-end: the step-2 request carries both signatures of a two-block step-1). Known scope limit: the one-shot `generate()` path still returns no reasoning (`ProviderResponse` has no field for it). MIGRATION: external exhaustive switches over `ProviderEvent` need a case for `'reasoning-end'`; transcripts may now carry several reasoning parts per step instead of one.
32
+
33
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-101: the Rule-of-Two `untrustedInput` leg is actually enforced. It previously fed only `heldLegs`/`holdsFullTrifecta` bookkeeping - a profile giving up the leg still had every web-search/MCP tool callable while both remaining legs were live, exactly the configuration the preset promises to prevent. `buildRuleOfTwoPolicy` now compiles `untrustedInput: false` into a forbid rule over untrusted-SOURCE tools, decided by the new exported `isUntrustedTrustClass` (`@graphorin/security/dataflow`) so the preset and the taint engine share one definition of "untrusted". `ToolCallFacts` gains `untrustedSource?`; the tools executor passes the tool's `trustClass` into `ToolArgumentPolicyGuard.evaluate` (type-level breaking for custom structural guard implementations); the agent adapter derives the fact from it. Untrusted content in user messages is explicitly out of this rule's scope (documented).
34
+
35
+ - [#158](https://github.com/o-stepper/graphorin/pull/158) [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab) Thanks [@o-stepper](https://github.com/o-stepper)! - Durable HITL composes across the sub-agent boundary (W-001). A handoff target or `toTool` child that suspends on an approval-gated tool now PARKS on the parent (`RunState.pendingSubRuns`, new core type `PendingSubRun`) instead of surfacing a terminal `execution_failed`/thrown error: the child's pending approvals mirror onto the parent's `pendingApprovals` with the new `ToolApproval.subRunToolCallId` routing field, and the parent suspends once per step. Operators echo (`toolCallId`, `subRunToolCallId`) back in `ApprovalDecision` - decisions match on the composite key, so colliding child-local ids never cross-apply; nested parks route recursively via a `/`-separated path. On grant the child's side effect executes exactly once, its shaped output becomes the parent's tool message, and its usage folds into the parent. `toTool` tools are executed INLINE by the tool-call walk (marked with the well-known `SUBAGENT_TOOL` symbol) rather than through the executor; foreign harnesses mounting them outside the graphorin loop keep the plain throw. `serializeRunState`/`deserializeRunState` recurse into parked children (each nested snapshot is version-stamped and secret-redacted; the core wire codec projects them recursively). Consumers relying on the old terminal-error behavior for suspending children will observe a suspension instead; failed/aborted children still surface as tool errors.
36
+
37
+ - [#158](https://github.com/o-stepper/graphorin/pull/158) [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab) Thanks [@o-stepper](https://github.com/o-stepper)! - Child-run usage now folds into the parent run's accounting (W-033): handoff and `toTool` children fold their per-model usage into the parent's `RunState.usage`, `usageByModel` and usage accumulator on every outcome (completed or failed - tokens were spent either way), `FanOutResult` gains an additive `usage` field summing usage-reporting children, and run-level `gen_ai.usage.*` trace attributes now include delegated tokens. Operators relying on the previously near-zero parent usage should expect budget hooks and pricing to start seeing the real (larger) numbers. The handoff child seed is additionally sanitized to a well-formed transcript (the in-flight dangling tool call is stripped, orphan tool results dropped) - real providers reject those shapes with invalid-request.
38
+
39
+ - [#158](https://github.com/o-stepper/graphorin/pull/158) [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab) Thanks [@o-stepper](https://github.com/o-stepper)! - `RunState.currentAgentId` is restored to the parent when a handoff child returns (W-034): the transfer is now scoped to the child observation window (restored in `finally`, on the failed branch too), so post-handoff `RunStep.agentId`, resume-step attribution and session JSONL exports identify the agent whose model actually drove the step. Consumers that relied on the id sticking to the handoff target will observe the corrected attribution; the child's identity remains durably recorded in `RunState.handoffs` and the `handoff` event.
40
+
41
+ - [#158](https://github.com/o-stepper/graphorin/pull/158) [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab) Thanks [@o-stepper](https://github.com/o-stepper)! - `RunStep.stepNumber` stays strictly monotonic and unique across suspend/resume cycles (W-035): the loop counter seeds from the journal's max instead of restarting at 0, and the resume-dispatch step (plus its intent/dispatched checkpoints and `step.start` events) takes max + 1 instead of a hard-coded 0. Dashboards or snapshots that expected resume steps to be numbered 0, or post-resume numbering to restart at 1, will observe the corrected continuing sequence. Exactly-once resume mechanics are unaffected (they key on toolCallId, never on step numbers).
42
+
43
+ - [#158](https://github.com/o-stepper/graphorin/pull/158) [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab) Thanks [@o-stepper](https://github.com/o-stepper)! - Sub-agent transparency (W-036). New additive `AgentEvent` member `subagent.event` wraps a child's event (with the parent-side toolCallId and the child agent name) and forwards it into the parent stream per the `forwardEvents` policy on handoff entries and `AgentToToolOptions`: `'lifecycle'` (default) forwards tool execution/approval, guardrail, lateral-leak, compaction and error events - never text deltas; `'all'` forwards everything; `'none'` keeps the child a black box. Multi-agent runs now form ONE trace tree: `AgentCallOptions.parentSpan` (not persisted in RunState) parents the run span, and the runtime supplies it automatically for handoffs and `toTool` children from the live step span. The wire codec projects the wrapped event recursively. TypeScript consumers with exhaustive switches over `AgentEvent` must add the new case.
44
+
45
+ - [#158](https://github.com/o-stepper/graphorin/pull/158) [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab) Thanks [@o-stepper](https://github.com/o-stepper)! - The `onPendingApprovals` abort policy is now reachable and safe (W-038). An abort that races the durable-HITL suspend applies the policy to the just-collected approvals instead of parking them behind a stale `awaiting_approval` checkpoint; the last persisted checkpoint always reflects the final, policy-consistent state. `'deny'` now commits a tool message per drained approval so the transcript keeps no dangling `tool_use`; `'hold'` survives on the aborted state (bare `run(state)` stays parked, an explicit directive resumes); `'fail'` fails the run ONLY when approvals are actually pending - aborting with an empty queue ends `'aborted'`, never `'failed'` (this matches the documented contract; consumers relying on the old unconditional `failed` will observe `aborted`). The guide now attributes the 50 ms grace to the tools executor's `cancellationGraceMs`, where it lives.
46
+
47
+ - [#158](https://github.com/o-stepper/graphorin/pull/158) [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab) Thanks [@o-stepper](https://github.com/o-stepper)! - The ToolReturn envelope gets a symbol brand (W-115). New core exports: `TOOL_RETURN_BRAND` (`Symbol.for`, duplicate-copy safe), the `toolReturn()` factory, and the ONE shared guard `isToolReturnEnvelope` consumed by both the executor's unwrap and the registry's example-normalizer (the duplicated sniff is gone). The structural fallback for unbranded objects is deliberately narrow - own keys within `{output, contentParts, taint}` - so a tool legitimately returning `{output, exitCode, stderr}` now reaches the model whole instead of being silently stripped to `.output`; canonical unbranded literals keep unwrapping and increment `tool.result.envelope.unbranded-toolreturn.total` toward the sniff's future deprecation. First-party producers (MCP adaptCallResult, memory recall tools, toTool taint envelopes) now brand via `toolReturn()`. Downstream consumers relying on extra fields being dropped will now see them; plain data of exactly `{output: X}` remains ambiguous by contract - brand it or rename the field.
48
+
49
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-004: JSON-safe binary codec for message content and a `WireRunState` projection; run-state schema 1.2.
50
+
51
+ `@graphorin/core` gains `EncodedBytes`/`EncodedUrl` envelopes, `WireMessage`/`WireMessageContent`/`WireRunState` wire twins and pure `toJsonSafeMessage`/`fromJsonSafeMessage`, `toJsonSafeContentParts`/`fromJsonSafeContentParts`, `toJsonSafeRunState`/`fromJsonSafeRunState` codecs (plus `bytesToBase64`/`base64ToBytes`, Buffer-free). `serializeRunState` in `@graphorin/agent` now projects binary payloads (`Uint8Array | URL` in `messages` and tool-outcome `contentParts`) through the codec before its detach stringify, so a run with an image checkpointed at `awaiting_approval` and resumed no longer hands the provider corrupted bytes. `RUN_STATE_SCHEMA_VERSION` is now `graphorin-run-state/1.2`; 1.0/1.1 payloads remain readable and their stringify-corrupted numeric-key byte objects are repaired best-effort on rehydration. `SerializedRunState.messages`/`.steps` are now typed as `WireMessage[]`/`WireRunStep[]` - the on-disk truth.
52
+
53
+ ### Patch Changes
54
+
55
+ - [#154](https://github.com/o-stepper/graphorin/pull/154) [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04) Thanks [@o-stepper](https://github.com/o-stepper)! - W-047: `RunContext.state` is now typed as the new `ReadonlyRunState` projection.
56
+
57
+ Tools and hooks observe the run; they do not mutate its bookkeeping - assignments to `status`/`finishedAt` and `push`/`splice` on `steps`/`messages`/`pendingApprovals` through `ctx.state` are now compile errors. `ReadonlyRunState` is a hand-written structural mirror of `RunState` (keyof parity pinned by type tests); `RunState` remains assignable to it, so runtime call sites needed no changes. This is a compile-time contract only (no runtime freeze). BREAKING at the type level for tools that wrote to `ctx.runContext.state` - that was never supported. Companion cleanup in `@graphorin/agent`: `finishRunBase`/`finalize` take `MutableRunState & RunState`, removing the last `as unknown as RunState` cast in the runtime.
58
+
59
+ - [#160](https://github.com/o-stepper/graphorin/pull/160) [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156) Thanks [@o-stepper](https://github.com/o-stepper)! - W-049: `tool.execute.start` / `tool.execute.end` / `tool.execute.error` events now carry an optional `toolName` (the agent runtime always fills it, on every emit path: batch dispatch, handoff, inline sub-agent, approval pre-screen and resumed dispatch). Direct stream subscribers can render the tool name from any lifecycle event without a stateful join back to `tool.call.start`. The union TSDoc now states the correlation policy explicitly: cross-run attribution belongs to the server envelope (`subject`), in-lifecycle correlation is by `toolCallId`, and `runId` is deliberately NOT retrofitted onto every variant. Additive and wire-compatible (the wire projection spreads unknown fields through); old consumers keep working.
60
+
61
+ - [#162](https://github.com/o-stepper/graphorin/pull/162) [`73b19ca`](https://github.com/o-stepper/graphorin/commit/73b19caeda388bda628a48138cb7d70b1db839a3) Thanks [@o-stepper](https://github.com/o-stepper)! - Remove phantom workspace dependencies that no source file imports: agent no longer depends on provider and observability, mcp/workflow/server no longer depend on observability, sessions no longer depends on security (and its memory edge moves to devDependencies where the single test import lives), skills no longer depends on tools. Dead tsdown `external` entries for the removed edges are gone too, so a future import can no longer build as external without a declared dependency. Consumer install graphs shrink accordingly; a new repo-wide `check-phantom-deps` CI gate keeps the manifest graph honest from here on.
62
+
63
+ - [#160](https://github.com/o-stepper/graphorin/pull/160) [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156) Thanks [@o-stepper](https://github.com/o-stepper)! - W-054: the SDF-1 memory-guard region reader now calls the statically-typed `Memory.working.compile(scope, agentId)` directly instead of reaching working memory through an `as unknown as` double cast with optional-chaining. A future signature change on `WorkingMemory.compile` breaks the agent BUILD instead of silently degrading the DEC-153 guard to an empty region read. Runtime semantics are unchanged: the reader stays best-effort (a throwing compile still degrades to an empty string and never fails the run). The remaining variance cast on the plan-tool registration is registration-time-only and out of this finding's scope.
64
+
65
+ - [#160](https://github.com/o-stepper/graphorin/pull/160) [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156) Thanks [@o-stepper](https://github.com/o-stepper)! - W-056: the compaction-summary wrapper marker has a single canonical definition. `@graphorin/memory` now exports `COMPACTION_SUMMARY_TAG` / `_OPEN` / `_CLOSE` / `_MARKER` from the module that renders the summary template, and the agent runtime imports (and re-exports) `COMPACTION_SUMMARY_MARKER` instead of defining its own literal. The VALUE is unchanged and frozen - persisted summaries in existing session stores carry it - with pin tests in both packages asserting the raw literal so a change breaks CI rather than migrating silently.
66
+
67
+ - [#160](https://github.com/o-stepper/graphorin/pull/160) [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156) Thanks [@o-stepper](https://github.com/o-stepper)! - W-103 / W-104: enabling `dataFlowPolicy` without any way to arm the lethal-trifecta leg is now visible. The agent prints one construction-time warning when the policy is on, `guardTrifecta` is not disabled, `treatPiiAsSensitive` is unset and no registered tool declares a sensitivity within the effective `sensitiveTiers` (default `['secret']` - and no built-in tool ships with that tag): in that configuration the only active default signal is the best-effort verbatim probe, which paraphrasing bypasses. The security and agent-runtime guides now state this explicitly and document the recommended adoption ladder (shadow -> tag private-data tools -> widen tiers/PII -> derivedTaint strict -> enforce). Runtime policy behaviour is unchanged.
68
+
69
+ - [#164](https://github.com/o-stepper/graphorin/pull/164) [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00) Thanks [@o-stepper](https://github.com/o-stepper)! - Documentation sync on the operator-facing HITL and usage surfaces (W-125): the agent-runtime guide now describes the real `tool.approval.requested` event shape (`{ type, toolCallId, reason? }`, with tool name and args read from `RunState.pendingApprovals`), the README names the real `RunState.usageByModel` field (was `RunState.usage.byModel`), and the `ResponseVerifier` TSDoc states what actually happens when a verifier throws (treated as passed; the `verifier.result` event still fires with `ok: true` - nothing is logged, since `AgentConfig` has no logger).
70
+
71
+ - [#164](https://github.com/o-stepper/graphorin/pull/164) [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00) Thanks [@o-stepper](https://github.com/o-stepper)! - TSDoc `{@link}` hygiene sweep (W-130): all 55 broken links found by TypeDoc's now-enabled `validation.invalidLink` are fixed - two resolved to their real targets (`GraphorinMCPError` was misnamed `MCPError`), the rest (cross-package, `import()`-form, unexported-constant, and DOM-type references that have never rendered as hrefs) converted to plain inline code. The docs build now fails on any new broken `{@link}` via a scoped gate.
72
+
73
+ - [#164](https://github.com/o-stepper/graphorin/pull/164) [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00) Thanks [@o-stepper](https://github.com/o-stepper)! - Tarballs now ship `src/` so the published `dist/**/*.d.ts.map` files actually work (W-136): the maps referenced `../src/*.ts` that the `files` whitelist excluded, so go-to-definition fell back into `.d.ts` and the shipped maps were dead weight. The pack gate gains a `map-integrity` leg: every source referenced by a shipped map must resolve inside the tarball (or be embedded via `sourcesContent`), with an anti-vacuous guard - a package whose tsdown config emits declaration maps must contain a non-zero number of `.d.ts.map` files, so a cache-restored dist that silently dropped maps fails the gate instead of passing vacuously. `mvp-readiness` now requires `src` in every publishable `files` array.
74
+
75
+ - [#164](https://github.com/o-stepper/graphorin/pull/164) [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00) Thanks [@o-stepper](https://github.com/o-stepper)! - Every published package now declares its tree-shaking contract via `sideEffects` (W-137): 18 packages audited to a pure module scope get `false`, the CLI declares its bin entry (`["./dist/bin/*"]`), and `@graphorin/security` gets an explicit `true` - its secrets subsystem registers built-in resolvers and the SecretValue caller-context provider at import time, so marking it pure would let bundlers drop those registrations. `mvp-readiness` now fails any publishable manifest without a declared `sideEffects`, closing the drift for future packages.
76
+
77
+ - Updated dependencies [[`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`832f22e`](https://github.com/o-stepper/graphorin/commit/832f22e570b8c3175c1adeb4c150070cbd131534), [`c1af9c7`](https://github.com/o-stepper/graphorin/commit/c1af9c790757fbe82da6dd2b6c1fdc497b5c605e), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`832f22e`](https://github.com/o-stepper/graphorin/commit/832f22e570b8c3175c1adeb4c150070cbd131534), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`832f22e`](https://github.com/o-stepper/graphorin/commit/832f22e570b8c3175c1adeb4c150070cbd131534), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`832f22e`](https://github.com/o-stepper/graphorin/commit/832f22e570b8c3175c1adeb4c150070cbd131534), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`832f22e`](https://github.com/o-stepper/graphorin/commit/832f22e570b8c3175c1adeb4c150070cbd131534), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`832f22e`](https://github.com/o-stepper/graphorin/commit/832f22e570b8c3175c1adeb4c150070cbd131534), [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab), [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab), [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`73b19ca`](https://github.com/o-stepper/graphorin/commit/73b19caeda388bda628a48138cb7d70b1db839a3), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab), [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`32bbd03`](https://github.com/o-stepper/graphorin/commit/32bbd03b588136a355e4b5ad6ac5e19b36b4d8ab), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`4ee256e`](https://github.com/o-stepper/graphorin/commit/4ee256e30fe9190cef6c48dc6785464757707156), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`764239b`](https://github.com/o-stepper/graphorin/commit/764239b97e0e0202442e91272583f13adeb12d00), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04), [`fe98522`](https://github.com/o-stepper/graphorin/commit/fe98522ce2477c9a7dc09029f9dcfdb1f7c9aa04)]:
78
+ - @graphorin/core@0.7.0
79
+ - @graphorin/security@0.7.0
80
+ - @graphorin/memory@0.7.0
81
+ - @graphorin/tools@0.7.0
82
+ - @graphorin/skills@0.7.0
83
+
84
+ ## 0.6.1
85
+
86
+ ### Patch Changes
87
+
88
+ - [#142](https://github.com/o-stepper/graphorin/pull/142) [`436d6ca`](https://github.com/o-stepper/graphorin/commit/436d6ca5ebbd16df094e915682d3915c279a8430) Thanks [@o-stepper](https://github.com/o-stepper)! - Version constants and version-bearing strings now derive from each package's manifest at build time (`VERSION = pkg.version`; writer ids, client/server info, OTLP framework attributes, build-info metrics interpolate it). No behavioral change at the current version: the rendered strings are byte-identical. A release bump no longer edits source; the new `check-version-consistency` gate fails any reintroduced hardcoded framework version.
89
+
90
+ - Updated dependencies [[`826ee59`](https://github.com/o-stepper/graphorin/commit/826ee5933ad38693b0dd2f20a110abfecba7d23d), [`436d6ca`](https://github.com/o-stepper/graphorin/commit/436d6ca5ebbd16df094e915682d3915c279a8430)]:
91
+ - @graphorin/observability@0.6.1
92
+ - @graphorin/core@0.6.1
93
+ - @graphorin/memory@0.6.1
94
+ - @graphorin/provider@0.6.1
95
+ - @graphorin/security@0.6.1
96
+ - @graphorin/skills@0.6.1
97
+ - @graphorin/tools@0.6.1
98
+
3
99
  ## 0.6.0
4
100
 
5
101
  ### Minor Changes
package/README.md CHANGED
@@ -10,10 +10,10 @@ preservation, agent-level model fallback, post-compaction hooks,
10
10
  per-tool model-tier hints, lateral-leak defenses).
11
11
 
12
12
  The package is **library-mode-first**: every primitive that can be
13
- useful from a script (`createAgent`, `RunState.toJSON / fromJSON`,
14
- the filter library, `evaluatorOptimizer`, `Agent.fanOut`,
15
- `agent.progress.write / read`) ships from the npm package without
16
- the optional standalone server.
13
+ useful from a script (`createAgent`, `runStateToJSON` /
14
+ `runStateFromJSON`, the filter library, `evaluatorOptimizer`,
15
+ `Agent.fanOut`, `agent.progress.write / read`) ships from the npm
16
+ package without the optional standalone server.
17
17
 
18
18
  ## Dependencies
19
19
 
@@ -63,16 +63,36 @@ for await (const event of agent.stream('Plan a trip to Mars')) {
63
63
  progress artifacts, lateral-leak detections, model fallback
64
64
  transitions, …). `assertNever(...)` exhaustiveness is verified at
65
65
  compile time.
66
- - **Durable HITL.** `RunState.toJSON()` /
67
- `RunState.fromJSON(serialized, agent)` round-trip the full run
68
- state through any storage the caller picks (file, SQLite, KV, S3).
69
- - **Multi-agent.** `Agent.toTool({ exposeTurns, inputFilter })`
66
+ - **Durable HITL.** `runStateToJSON(state)` /
67
+ `runStateFromJSON(serialized)` round-trip the full run state
68
+ through any storage the caller picks (file, SQLite, KV, S3); with a
69
+ `checkpointStore` wired, resuming a granted approval executes the
70
+ approved tool exactly once.
71
+ - **Multi-agent.** `Agent.toTool({ exposeTurns, inputFilter, capability, contextFold, propagateTaint })`
70
72
  wraps an agent as a tool the parent agent can call. The parent's
71
73
  abort signal, deps, and sessionId propagate into the sub-run;
72
74
  without an `inputFilter` the sub-agent sees only the input string
73
75
  (no parent conversation crosses the boundary), and there is no
74
76
  secret-inheritance mechanism at this boundary at all - least
75
- authority by construction.
77
+ authority by construction. `capability: 'read-only'` blocks
78
+ side-effecting tools in the child, `contextFold` returns a
79
+ distilled outcome instead of the raw transcript tail, and taint
80
+ from the child's untrusted inputs propagates to the parent by
81
+ default.
82
+ - **Prompt-cache economics.** Opt-in `cachePolicy: { breakpoints: 'auto' }`
83
+ anchors provider cache breakpoints on the stable prefix so long
84
+ conversations are written once and read at the discounted rate;
85
+ cache read/write token legs flow through `Usage` and cost
86
+ tracking.
87
+ - **Verifiers + deterministic replay.** `verifiers` run deterministic
88
+ checks on every terminal response (`verifier.result` events, up to
89
+ `maxVerifierRounds` feedback rounds); opt-in
90
+ `recordProviderResponses` journals raw model responses onto
91
+ `RunState` so `createReplayProvider(state)` re-drives the run
92
+ offline and fails loudly on divergence.
93
+ - **Structured planning.** `plan: true` gives the model an
94
+ `update_plan` tool and surfaces the live plan as
95
+ `RunState.todos`.
76
96
  - **Filter library.** `filters.lastN(n)`, `filters.lastUser`,
77
97
  `filters.summary({...})`, `filters.bySensitivity({...})`,
78
98
  `filters.stripReasoning()`, `filters.stripSensitiveOutputs()`,
@@ -97,7 +117,7 @@ for await (const event of agent.stream('Plan a trip to Mars')) {
97
117
  retries the whole step against the next model on rate-limit /
98
118
  capacity / context-length errors; `agent.model.fellback` event
99
119
  fires per transition; per-model usage attribution lives in
100
- `RunState.usage.byModel`.
120
+ `RunState.usageByModel`.
101
121
  - **Post-compaction hook lifecycle.** When
102
122
  `@graphorin/memory.contextEngine` auto-compacts the buffer, the
103
123
  runtime fires every registered `postCompactionHooks[i]` between
@@ -155,5 +175,5 @@ text.
155
175
 
156
176
  ---
157
177
 
158
- **Project Graphorin** · v0.6.0 · MIT License · © 2026 Oleksiy
178
+ **Project Graphorin** · v0.7.0 · MIT License · © 2026 Oleksiy
159
179
  Stepurenko · <https://github.com/o-stepper/graphorin>
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * @stable
15
15
  */
16
- type AgentRuntimeErrorCode = 'invalid-config' | 'invalid-preferred-model' | 'invalid-fallback-policy' | 'invalid-evaluator-optimizer-config' | 'agent-resolution-failed' | 'tool-not-found' | 'handoff-target-not-found' | 'multiple-handoffs-in-step' | 'run-aborted' | 'middleware-order-violation' | 'progress-write-failed' | 'merge-blocked' | 'protocol-injection-rejected' | 'run-state-version-unsupported' | 'run-state-malformed' | 'concurrent-run';
16
+ type AgentRuntimeErrorCode = 'invalid-config' | 'invalid-preferred-model' | 'invalid-fallback-policy' | 'invalid-evaluator-optimizer-config' | 'agent-resolution-failed' | 'tool-not-found' | 'handoff-target-not-found' | 'multiple-handoffs-in-step' | 'sub-run-resume-target-not-found' | 'run-aborted' | 'middleware-order-violation' | 'progress-write-failed' | 'merge-blocked' | 'protocol-injection-rejected' | 'run-state-version-unsupported' | 'run-state-malformed' | 'concurrent-run';
17
17
  /**
18
18
  * Base class for every error thrown from `@graphorin/agent`.
19
19
  *
@@ -99,6 +99,19 @@ declare class MultipleHandoffsInStepError extends AgentRuntimeError {
99
99
  readonly handoffNames: ReadonlyArray<string>;
100
100
  constructor(handoffNames: ReadonlyArray<string>);
101
101
  }
102
+ /**
103
+ * Thrown when a resume directive routes a decision into a parked
104
+ * sub-agent run (W-001) but the resuming agent instance cannot resolve
105
+ * the target: the parked toolName matches neither a configured handoff
106
+ * target nor a `toTool` sub-agent tool. Resume a parked sub-run on the
107
+ * SAME parent instance (or an identically-configured one).
108
+ *
109
+ * @stable
110
+ */
111
+ declare class SubAgentResumeTargetNotFoundError extends AgentRuntimeError {
112
+ readonly toolName: string;
113
+ constructor(toolName: string, detail: string);
114
+ }
102
115
  /**
103
116
  * Thrown by `runStateFromJSON(...)` when the version field in the
104
117
  * serialized state is from a future major version of the framework.
@@ -112,7 +125,7 @@ declare class RunStateVersionUnsupportedError extends AgentRuntimeError {
112
125
  }
113
126
  /**
114
127
  * Thrown by `runStateFromJSON(...)` when the supplied JSON does not
115
- * shape-match the documented {@link SerializedRunState}.
128
+ * shape-match the documented `SerializedRunState`.
116
129
  *
117
130
  * @stable
118
131
  */
@@ -121,7 +134,7 @@ declare class RunStateMalformedError extends AgentRuntimeError {
121
134
  }
122
135
  /**
123
136
  * Thrown by `Agent.fanOut(...)` when the configured
124
- * {@link MergeAgentSidewaysInjectionGuard} fires with strictness
137
+ * `MergeAgentSidewaysInjectionGuard` fires with strictness
125
138
  * `'detect-and-block'`.
126
139
  *
127
140
  * @stable
@@ -166,5 +179,5 @@ declare class ProviderMiddlewareOrderError extends AgentRuntimeError {
166
179
  constructor(reason: string);
167
180
  }
168
181
  //#endregion
169
- export { AgentResolutionError, AgentRuntimeError, AgentRuntimeErrorCode, ConcurrentRunError, EvaluatorOptimizerConfigError, InvalidAgentConfigError, InvalidPreferredModelError, MergeBlockedError, MultipleHandoffsInStepError, ProgressWriteError, ProtocolInjectionRejectError, ProviderMiddlewareOrderError, RunStateMalformedError, RunStateVersionUnsupportedError, ToolNotFoundError };
182
+ export { AgentResolutionError, AgentRuntimeError, AgentRuntimeErrorCode, ConcurrentRunError, EvaluatorOptimizerConfigError, InvalidAgentConfigError, InvalidPreferredModelError, MergeBlockedError, MultipleHandoffsInStepError, ProgressWriteError, ProtocolInjectionRejectError, ProviderMiddlewareOrderError, RunStateMalformedError, RunStateVersionUnsupportedError, SubAgentResumeTargetNotFoundError, ToolNotFoundError };
170
183
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":[],"mappings":";;AAeA;AAuBA;;;;;AAgBA;AAiBA;AAoBA;AAiBA;AAkBA;AA6BA;AAUA;AACyB,KAvJb,qBAAA,GAuJa,gBAAA,GAAA,yBAAA,GAAA,yBAAA,GAAA,oCAAA,GAAA,yBAAA,GAAA,gBAAA,GAAA,0BAAA,GAAA,2BAAA,GAAA,aAAA,GAAA,4BAAA,GAAA,uBAAA,GAAA,eAAA,GAAA,6BAAA,GAAA,+BAAA,GAAA,qBAAA,GAAA,gBAAA;;;;AAiBzB;AAqBA;AAaa,cAnLA,iBAAA,SAA0B,KAAA,CAmLA;EAsB1B,SAAA,IAAA,EAxMI,qBAwMyB;EAqB7B,WAAA,CAAA,IAAA,EA5NO,qBA4NoB,EAAA,OAAA,EAAA,MAAiB,EAAA,IAAA,CAAA,EAAA,MAAA;AA6BzD;;;;;;;;cA3Oa,uBAAA,SAAgC,iBAAA;;;;;;;;;;cAiBhC,0BAAA,SAAmC,iBAAA;;;;;;;;;;;cAoBnC,6BAAA,SAAsC,iBAAA;;;;;;;;;;cAiBtC,oBAAA,SAA6B,iBAAA;;;;;;;;;;cAkB7B,iBAAA,SAA0B,iBAAA;;;;;;;;;;;;;;;;;;;;;cA6B1B,kBAAA,SAA2B,iBAAA;;;cAU3B,2BAAA,SAAoC,iBAAA;yBACxB;4BACG;;;;;;;;cAgBf,+BAAA,SAAwC,iBAAA;;;;;;;;;;;cAqBxC,sBAAA,SAA+B,iBAAA;;;;;;;;;;cAa/B,iBAAA,SAA0B,iBAAA;;;;;;;;;;;;;cAsB1B,4BAAA,SAAqC,iBAAA;;;;;;;;;;;;cAqBrC,kBAAA,SAA2B,iBAAA;;;;;;;;;;;cA6B3B,4BAAA,SAAqC,iBAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":[],"mappings":";;AAeA;AAwBA;;;;;AAgBA;AAiBA;AAoBA;AAiBA;AAkBA;AA6BA;AAUA;AACyB,KAxJb,qBAAA,GAwJa,gBAAA,GAAA,yBAAA,GAAA,yBAAA,GAAA,oCAAA,GAAA,yBAAA,GAAA,gBAAA,GAAA,0BAAA,GAAA,2BAAA,GAAA,iCAAA,GAAA,aAAA,GAAA,4BAAA,GAAA,uBAAA,GAAA,eAAA,GAAA,6BAAA,GAAA,+BAAA,GAAA,qBAAA,GAAA,gBAAA;;;;AAoBzB;AAkBA;AAqBa,cA3LA,iBAAA,SAA0B,KAAA,CA2LK;EAa/B,SAAA,IAAA,EAvMI,qBAuMsB;EAsB1B,WAAA,CAAA,IAAA,EA5NO,qBA4NsB,EAAA,OAAQ,EAAA,MAAA,EAAA,IAAiB,CAAA,EAAA,MAAA;AAqBnE;AA6BA;;;;;;;cAhQa,uBAAA,SAAgC,iBAAA;;;;;;;;;;cAiBhC,0BAAA,SAAmC,iBAAA;;;;;;;;;;;cAoBnC,6BAAA,SAAsC,iBAAA;;;;;;;;;;cAiBtC,oBAAA,SAA6B,iBAAA;;;;;;;;;;cAkB7B,iBAAA,SAA0B,iBAAA;;;;;;;;;;;;;;;;;;;;;cA6B1B,kBAAA,SAA2B,iBAAA;;;cAU3B,2BAAA,SAAoC,iBAAA;yBACxB;4BACG;;;;;;;;;;;cAmBf,iCAAA,SAA0C,iBAAA;;;;;;;;;;cAkB1C,+BAAA,SAAwC,iBAAA;;;;;;;;;;;cAqBxC,sBAAA,SAA+B,iBAAA;;;;;;;;;;cAa/B,iBAAA,SAA0B,iBAAA;;;;;;;;;;;;;cAsB1B,4BAAA,SAAqC,iBAAA;;;;;;;;;;;;cAqBrC,kBAAA,SAA2B,iBAAA;;;;;;;;;;;cA6B3B,4BAAA,SAAqC,iBAAA"}
@@ -107,6 +107,22 @@ var MultipleHandoffsInStepError = class extends AgentRuntimeError {
107
107
  }
108
108
  };
109
109
  /**
110
+ * Thrown when a resume directive routes a decision into a parked
111
+ * sub-agent run (W-001) but the resuming agent instance cannot resolve
112
+ * the target: the parked toolName matches neither a configured handoff
113
+ * target nor a `toTool` sub-agent tool. Resume a parked sub-run on the
114
+ * SAME parent instance (or an identically-configured one).
115
+ *
116
+ * @stable
117
+ */
118
+ var SubAgentResumeTargetNotFoundError = class extends AgentRuntimeError {
119
+ toolName;
120
+ constructor(toolName, detail) {
121
+ super("sub-run-resume-target-not-found", `Cannot resume parked sub-agent run for tool '${toolName}': ${detail}. Parked sub-runs resume only on a parent instance configured with the same handoff target or toTool sub-agent tool.`, "SubAgentResumeTargetNotFoundError");
122
+ this.toolName = toolName;
123
+ }
124
+ };
125
+ /**
110
126
  * Thrown by `runStateFromJSON(...)` when the version field in the
111
127
  * serialized state is from a future major version of the framework.
112
128
  *
@@ -123,7 +139,7 @@ var RunStateVersionUnsupportedError = class extends AgentRuntimeError {
123
139
  };
124
140
  /**
125
141
  * Thrown by `runStateFromJSON(...)` when the supplied JSON does not
126
- * shape-match the documented {@link SerializedRunState}.
142
+ * shape-match the documented `SerializedRunState`.
127
143
  *
128
144
  * @stable
129
145
  */
@@ -134,7 +150,7 @@ var RunStateMalformedError = class extends AgentRuntimeError {
134
150
  };
135
151
  /**
136
152
  * Thrown by `Agent.fanOut(...)` when the configured
137
- * {@link MergeAgentSidewaysInjectionGuard} fires with strictness
153
+ * `MergeAgentSidewaysInjectionGuard` fires with strictness
138
154
  * `'detect-and-block'`.
139
155
  *
140
156
  * @stable
@@ -200,5 +216,5 @@ var ProviderMiddlewareOrderError = class extends AgentRuntimeError {
200
216
  };
201
217
 
202
218
  //#endregion
203
- export { AgentResolutionError, AgentRuntimeError, ConcurrentRunError, EvaluatorOptimizerConfigError, InvalidAgentConfigError, InvalidPreferredModelError, MergeBlockedError, MultipleHandoffsInStepError, ProgressWriteError, ProtocolInjectionRejectError, ProviderMiddlewareOrderError, RunStateMalformedError, RunStateVersionUnsupportedError, ToolNotFoundError };
219
+ export { AgentResolutionError, AgentRuntimeError, ConcurrentRunError, EvaluatorOptimizerConfigError, InvalidAgentConfigError, InvalidPreferredModelError, MergeBlockedError, MultipleHandoffsInStepError, ProgressWriteError, ProtocolInjectionRejectError, ProviderMiddlewareOrderError, RunStateMalformedError, RunStateVersionUnsupportedError, SubAgentResumeTargetNotFoundError, ToolNotFoundError };
204
220
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":["/**\n * Typed error surface for `@graphorin/agent`.\n *\n * Every error class extends the base {@link AgentRuntimeError} which is\n * a thin wrapper around `Error` with a stable `code` discriminator so\n * callers can `switch` on it without parsing messages.\n *\n * @packageDocumentation\n */\n\n/**\n * Stable code discriminator surfaced on every {@link AgentRuntimeError}.\n *\n * @stable\n */\nexport type AgentRuntimeErrorCode =\n | 'invalid-config'\n | 'invalid-preferred-model'\n | 'invalid-fallback-policy'\n | 'invalid-evaluator-optimizer-config'\n | 'agent-resolution-failed'\n | 'tool-not-found'\n | 'handoff-target-not-found'\n | 'multiple-handoffs-in-step'\n | 'run-aborted'\n | 'middleware-order-violation'\n | 'progress-write-failed'\n | 'merge-blocked'\n | 'protocol-injection-rejected'\n | 'run-state-version-unsupported'\n | 'run-state-malformed'\n | 'concurrent-run';\n\n/**\n * Base class for every error thrown from `@graphorin/agent`.\n *\n * @stable\n */\nexport class AgentRuntimeError extends Error {\n readonly code: AgentRuntimeErrorCode;\n constructor(code: AgentRuntimeErrorCode, message: string, name = 'AgentRuntimeError') {\n super(message);\n this.name = name;\n this.code = code;\n }\n}\n\n/**\n * Thrown by `createAgent({...})` when the supplied options fail\n * structural validation (missing `provider`, empty `name`, an\n * `outputType` of kind `'text'` carrying a `schema`, ...).\n *\n * @stable\n */\nexport class InvalidAgentConfigError extends AgentRuntimeError {\n constructor(reason: string) {\n super(\n 'invalid-config',\n `Invalid createAgent({...}) options: ${reason}.`,\n 'InvalidAgentConfigError',\n );\n }\n}\n\n/**\n * Thrown by `createAgent({...})` when `preferredModel` carries an\n * unknown literal (any value outside the `'fast' | 'balanced' |\n * 'smart'` cost-tier vocabulary AND not a valid `ModelSpec`).\n *\n * @stable\n */\nexport class InvalidPreferredModelError extends AgentRuntimeError {\n readonly value: unknown;\n constructor(value: unknown) {\n super(\n 'invalid-preferred-model',\n `Invalid Agent.preferredModel: ${JSON.stringify(value)}. ` +\n \"Expected 'fast' | 'balanced' | 'smart' | ModelSpec.\",\n 'InvalidPreferredModelError',\n );\n this.value = value;\n }\n}\n\n/**\n * Thrown by `evaluatorOptimizer({...})` when `maxIterations < 1` at\n * construction time. The helper purposely surfaces the misuse early\n * rather than failing on the first run.\n *\n * @stable\n */\nexport class EvaluatorOptimizerConfigError extends AgentRuntimeError {\n constructor(reason: string) {\n super(\n 'invalid-evaluator-optimizer-config',\n `Invalid evaluatorOptimizer({...}) options: ${reason}.`,\n 'EvaluatorOptimizerConfigError',\n );\n }\n}\n\n/**\n * Thrown by `runStateFromJSON(...)` when the agent name in the\n * serialized state cannot be resolved against the supplied agent\n * graph (renamed agent / removed handoff).\n *\n * @stable\n */\nexport class AgentResolutionError extends AgentRuntimeError {\n readonly agentId: string;\n constructor(agentId: string) {\n super(\n 'agent-resolution-failed',\n `runStateFromJSON: agent '${agentId}' is not registered in the supplied graph.`,\n 'AgentResolutionError',\n );\n this.agentId = agentId;\n }\n}\n\n/**\n * Thrown by the agent loop when the model emits a tool call referring\n * to an unregistered tool (the model hallucinated a name).\n *\n * @stable\n */\nexport class ToolNotFoundError extends AgentRuntimeError {\n readonly toolName: string;\n constructor(toolName: string) {\n super(\n 'tool-not-found',\n `Tool '${toolName}' is not registered on this agent.`,\n 'ToolNotFoundError',\n );\n this.toolName = toolName;\n }\n}\n\n/**\n * Thrown when the model invokes more than one handoff (`transfer_to_*`)\n * tool in a single response. Per the agent-loop documentation this is\n * an error rather than a silent drop.\n *\n * @stable\n */\n/**\n * Thrown when a second `run()` / `stream()` starts while another run is\n * in flight on the same `Agent` instance (AG-11). The public surface\n * (`steer` / `followUp` / `abort` / `compact`) addresses \"the run\"\n * without a run handle, so overlapping runs would share the abort\n * controller, steer queue, and executor bridge - start the second run\n * on its own `createAgent(...)` instance instead.\n *\n * @stable\n */\nexport class ConcurrentRunError extends AgentRuntimeError {\n constructor() {\n super(\n 'concurrent-run',\n 'This Agent instance already has a run in flight. One run per instance: await the active run (or abort it), or create a separate agent instance for parallel work.',\n 'ConcurrentRunError',\n );\n }\n}\n\nexport class MultipleHandoffsInStepError extends AgentRuntimeError {\n readonly handoffNames: ReadonlyArray<string>;\n constructor(handoffNames: ReadonlyArray<string>) {\n super(\n 'multiple-handoffs-in-step',\n `The model invoked multiple handoff tools in one step: ${handoffNames.join(', ')}.`,\n 'MultipleHandoffsInStepError',\n );\n this.handoffNames = handoffNames;\n }\n}\n\n/**\n * Thrown by `runStateFromJSON(...)` when the version field in the\n * serialized state is from a future major version of the framework.\n *\n * @stable\n */\nexport class RunStateVersionUnsupportedError extends AgentRuntimeError {\n readonly version: string;\n readonly readerVersion: string;\n constructor(version: string, readerVersion: string) {\n super(\n 'run-state-version-unsupported',\n `RunState version '${version}' is newer than reader '${readerVersion}'. ` +\n 'Upgrade @graphorin/agent to load this state.',\n 'RunStateVersionUnsupportedError',\n );\n this.version = version;\n this.readerVersion = readerVersion;\n }\n}\n\n/**\n * Thrown by `runStateFromJSON(...)` when the supplied JSON does not\n * shape-match the documented {@link SerializedRunState}.\n *\n * @stable\n */\nexport class RunStateMalformedError extends AgentRuntimeError {\n constructor(reason: string) {\n super('run-state-malformed', `Malformed RunState JSON: ${reason}.`, 'RunStateMalformedError');\n }\n}\n\n/**\n * Thrown by `Agent.fanOut(...)` when the configured\n * {@link MergeAgentSidewaysInjectionGuard} fires with strictness\n * `'detect-and-block'`.\n *\n * @stable\n */\nexport class MergeBlockedError extends AgentRuntimeError {\n readonly fanOutId: string;\n readonly reason: string;\n constructor(fanOutId: string, reason: string) {\n super(\n 'merge-blocked',\n `Agent.fanOut('${fanOutId}') merge blocked by MergeAgentSidewaysInjectionGuard: ${reason}.`,\n 'MergeBlockedError',\n );\n this.fanOutId = fanOutId;\n this.reason = reason;\n }\n}\n\n/**\n * Thrown by the protocol-injection guard when the operator selected\n * the strictest deployment posture (`escapePolicy: 'reject'`) and a\n * tool result body carries control characters at the corresponding\n * outbound boundary.\n *\n * @stable\n */\nexport class ProtocolInjectionRejectError extends AgentRuntimeError {\n readonly boundary: string;\n readonly matchedPattern: string;\n constructor(boundary: string, matchedPattern: string) {\n super(\n 'protocol-injection-rejected',\n `Protocol injection guard rejected output at the '${boundary}' boundary (matched ${matchedPattern}).`,\n 'ProtocolInjectionRejectError',\n );\n this.boundary = boundary;\n this.matchedPattern = matchedPattern;\n }\n}\n\n/**\n * Thrown by `agent.progress.write(...)` when the atomic write fails\n * (disk full, permission denied, ...). The partial `.tmp` file is\n * unlinked before the error propagates.\n *\n * @stable\n */\nexport class ProgressWriteError extends AgentRuntimeError {\n readonly path: string;\n constructor(path: string, cause: unknown) {\n const message = cause instanceof Error ? cause.message : String(cause);\n super(\n 'progress-write-failed',\n `agent.progress.write('${path}') failed: ${message}.`,\n 'ProgressWriteError',\n );\n this.path = path;\n if (cause !== undefined) {\n // Preserve the underlying cause for diagnostics.\n Object.defineProperty(this, 'cause', {\n value: cause,\n enumerable: false,\n configurable: true,\n writable: true,\n });\n }\n }\n}\n\n/**\n * Thrown by `createAgent({...})` when the supplied\n * `composeProviderMiddleware` chain violates the canonical inside-out\n * ordering (DEC-145 / ADR-039).\n *\n * @stable\n */\nexport class ProviderMiddlewareOrderError extends AgentRuntimeError {\n constructor(reason: string) {\n super(\n 'middleware-order-violation',\n `Provider middleware composition violated the inside-out ordering: ${reason}.`,\n 'ProviderMiddlewareOrderError',\n );\n }\n}\n"],"mappings":";;;;;;AAsCA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,AAAS;CACT,YAAY,MAA6B,SAAiB,OAAO,qBAAqB;AACpF,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,0BAAb,cAA6C,kBAAkB;CAC7D,YAAY,QAAgB;AAC1B,QACE,kBACA,uCAAuC,OAAO,IAC9C,0BACD;;;;;;;;;;AAWL,IAAa,6BAAb,cAAgD,kBAAkB;CAChE,AAAS;CACT,YAAY,OAAgB;AAC1B,QACE,2BACA,iCAAiC,KAAK,UAAU,MAAM,CAAC,wDAEvD,6BACD;AACD,OAAK,QAAQ;;;;;;;;;;AAWjB,IAAa,gCAAb,cAAmD,kBAAkB;CACnE,YAAY,QAAgB;AAC1B,QACE,sCACA,8CAA8C,OAAO,IACrD,gCACD;;;;;;;;;;AAWL,IAAa,uBAAb,cAA0C,kBAAkB;CAC1D,AAAS;CACT,YAAY,SAAiB;AAC3B,QACE,2BACA,4BAA4B,QAAQ,6CACpC,uBACD;AACD,OAAK,UAAU;;;;;;;;;AAUnB,IAAa,oBAAb,cAAuC,kBAAkB;CACvD,AAAS;CACT,YAAY,UAAkB;AAC5B,QACE,kBACA,SAAS,SAAS,qCAClB,oBACD;AACD,OAAK,WAAW;;;;;;;;;;;;;;;;;;;;AAqBpB,IAAa,qBAAb,cAAwC,kBAAkB;CACxD,cAAc;AACZ,QACE,kBACA,qKACA,qBACD;;;AAIL,IAAa,8BAAb,cAAiD,kBAAkB;CACjE,AAAS;CACT,YAAY,cAAqC;AAC/C,QACE,6BACA,yDAAyD,aAAa,KAAK,KAAK,CAAC,IACjF,8BACD;AACD,OAAK,eAAe;;;;;;;;;AAUxB,IAAa,kCAAb,cAAqD,kBAAkB;CACrE,AAAS;CACT,AAAS;CACT,YAAY,SAAiB,eAAuB;AAClD,QACE,iCACA,qBAAqB,QAAQ,0BAA0B,cAAc,kDAErE,kCACD;AACD,OAAK,UAAU;AACf,OAAK,gBAAgB;;;;;;;;;AAUzB,IAAa,yBAAb,cAA4C,kBAAkB;CAC5D,YAAY,QAAgB;AAC1B,QAAM,uBAAuB,4BAA4B,OAAO,IAAI,yBAAyB;;;;;;;;;;AAWjG,IAAa,oBAAb,cAAuC,kBAAkB;CACvD,AAAS;CACT,AAAS;CACT,YAAY,UAAkB,QAAgB;AAC5C,QACE,iBACA,iBAAiB,SAAS,wDAAwD,OAAO,IACzF,oBACD;AACD,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;;;;;;AAYlB,IAAa,+BAAb,cAAkD,kBAAkB;CAClE,AAAS;CACT,AAAS;CACT,YAAY,UAAkB,gBAAwB;AACpD,QACE,+BACA,oDAAoD,SAAS,sBAAsB,eAAe,KAClG,+BACD;AACD,OAAK,WAAW;AAChB,OAAK,iBAAiB;;;;;;;;;;AAW1B,IAAa,qBAAb,cAAwC,kBAAkB;CACxD,AAAS;CACT,YAAY,MAAc,OAAgB;EACxC,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,QACE,yBACA,yBAAyB,KAAK,aAAa,QAAQ,IACnD,qBACD;AACD,OAAK,OAAO;AACZ,MAAI,UAAU,OAEZ,QAAO,eAAe,MAAM,SAAS;GACnC,OAAO;GACP,YAAY;GACZ,cAAc;GACd,UAAU;GACX,CAAC;;;;;;;;;;AAYR,IAAa,+BAAb,cAAkD,kBAAkB;CAClE,YAAY,QAAgB;AAC1B,QACE,8BACA,qEAAqE,OAAO,IAC5E,+BACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":["/**\n * Typed error surface for `@graphorin/agent`.\n *\n * Every error class extends the base {@link AgentRuntimeError} which is\n * a thin wrapper around `Error` with a stable `code` discriminator so\n * callers can `switch` on it without parsing messages.\n *\n * @packageDocumentation\n */\n\n/**\n * Stable code discriminator surfaced on every {@link AgentRuntimeError}.\n *\n * @stable\n */\nexport type AgentRuntimeErrorCode =\n | 'invalid-config'\n | 'invalid-preferred-model'\n | 'invalid-fallback-policy'\n | 'invalid-evaluator-optimizer-config'\n | 'agent-resolution-failed'\n | 'tool-not-found'\n | 'handoff-target-not-found'\n | 'multiple-handoffs-in-step'\n | 'sub-run-resume-target-not-found'\n | 'run-aborted'\n | 'middleware-order-violation'\n | 'progress-write-failed'\n | 'merge-blocked'\n | 'protocol-injection-rejected'\n | 'run-state-version-unsupported'\n | 'run-state-malformed'\n | 'concurrent-run';\n\n/**\n * Base class for every error thrown from `@graphorin/agent`.\n *\n * @stable\n */\nexport class AgentRuntimeError extends Error {\n readonly code: AgentRuntimeErrorCode;\n constructor(code: AgentRuntimeErrorCode, message: string, name = 'AgentRuntimeError') {\n super(message);\n this.name = name;\n this.code = code;\n }\n}\n\n/**\n * Thrown by `createAgent({...})` when the supplied options fail\n * structural validation (missing `provider`, empty `name`, an\n * `outputType` of kind `'text'` carrying a `schema`, ...).\n *\n * @stable\n */\nexport class InvalidAgentConfigError extends AgentRuntimeError {\n constructor(reason: string) {\n super(\n 'invalid-config',\n `Invalid createAgent({...}) options: ${reason}.`,\n 'InvalidAgentConfigError',\n );\n }\n}\n\n/**\n * Thrown by `createAgent({...})` when `preferredModel` carries an\n * unknown literal (any value outside the `'fast' | 'balanced' |\n * 'smart'` cost-tier vocabulary AND not a valid `ModelSpec`).\n *\n * @stable\n */\nexport class InvalidPreferredModelError extends AgentRuntimeError {\n readonly value: unknown;\n constructor(value: unknown) {\n super(\n 'invalid-preferred-model',\n `Invalid Agent.preferredModel: ${JSON.stringify(value)}. ` +\n \"Expected 'fast' | 'balanced' | 'smart' | ModelSpec.\",\n 'InvalidPreferredModelError',\n );\n this.value = value;\n }\n}\n\n/**\n * Thrown by `evaluatorOptimizer({...})` when `maxIterations < 1` at\n * construction time. The helper purposely surfaces the misuse early\n * rather than failing on the first run.\n *\n * @stable\n */\nexport class EvaluatorOptimizerConfigError extends AgentRuntimeError {\n constructor(reason: string) {\n super(\n 'invalid-evaluator-optimizer-config',\n `Invalid evaluatorOptimizer({...}) options: ${reason}.`,\n 'EvaluatorOptimizerConfigError',\n );\n }\n}\n\n/**\n * Thrown by `runStateFromJSON(...)` when the agent name in the\n * serialized state cannot be resolved against the supplied agent\n * graph (renamed agent / removed handoff).\n *\n * @stable\n */\nexport class AgentResolutionError extends AgentRuntimeError {\n readonly agentId: string;\n constructor(agentId: string) {\n super(\n 'agent-resolution-failed',\n `runStateFromJSON: agent '${agentId}' is not registered in the supplied graph.`,\n 'AgentResolutionError',\n );\n this.agentId = agentId;\n }\n}\n\n/**\n * Thrown by the agent loop when the model emits a tool call referring\n * to an unregistered tool (the model hallucinated a name).\n *\n * @stable\n */\nexport class ToolNotFoundError extends AgentRuntimeError {\n readonly toolName: string;\n constructor(toolName: string) {\n super(\n 'tool-not-found',\n `Tool '${toolName}' is not registered on this agent.`,\n 'ToolNotFoundError',\n );\n this.toolName = toolName;\n }\n}\n\n/**\n * Thrown when the model invokes more than one handoff (`transfer_to_*`)\n * tool in a single response. Per the agent-loop documentation this is\n * an error rather than a silent drop.\n *\n * @stable\n */\n/**\n * Thrown when a second `run()` / `stream()` starts while another run is\n * in flight on the same `Agent` instance (AG-11). The public surface\n * (`steer` / `followUp` / `abort` / `compact`) addresses \"the run\"\n * without a run handle, so overlapping runs would share the abort\n * controller, steer queue, and executor bridge - start the second run\n * on its own `createAgent(...)` instance instead.\n *\n * @stable\n */\nexport class ConcurrentRunError extends AgentRuntimeError {\n constructor() {\n super(\n 'concurrent-run',\n 'This Agent instance already has a run in flight. One run per instance: await the active run (or abort it), or create a separate agent instance for parallel work.',\n 'ConcurrentRunError',\n );\n }\n}\n\nexport class MultipleHandoffsInStepError extends AgentRuntimeError {\n readonly handoffNames: ReadonlyArray<string>;\n constructor(handoffNames: ReadonlyArray<string>) {\n super(\n 'multiple-handoffs-in-step',\n `The model invoked multiple handoff tools in one step: ${handoffNames.join(', ')}.`,\n 'MultipleHandoffsInStepError',\n );\n this.handoffNames = handoffNames;\n }\n}\n\n/**\n * Thrown when a resume directive routes a decision into a parked\n * sub-agent run (W-001) but the resuming agent instance cannot resolve\n * the target: the parked toolName matches neither a configured handoff\n * target nor a `toTool` sub-agent tool. Resume a parked sub-run on the\n * SAME parent instance (or an identically-configured one).\n *\n * @stable\n */\nexport class SubAgentResumeTargetNotFoundError extends AgentRuntimeError {\n readonly toolName: string;\n constructor(toolName: string, detail: string) {\n super(\n 'sub-run-resume-target-not-found',\n `Cannot resume parked sub-agent run for tool '${toolName}': ${detail}. Parked sub-runs resume only on a parent instance configured with the same handoff target or toTool sub-agent tool.`,\n 'SubAgentResumeTargetNotFoundError',\n );\n this.toolName = toolName;\n }\n}\n\n/**\n * Thrown by `runStateFromJSON(...)` when the version field in the\n * serialized state is from a future major version of the framework.\n *\n * @stable\n */\nexport class RunStateVersionUnsupportedError extends AgentRuntimeError {\n readonly version: string;\n readonly readerVersion: string;\n constructor(version: string, readerVersion: string) {\n super(\n 'run-state-version-unsupported',\n `RunState version '${version}' is newer than reader '${readerVersion}'. ` +\n 'Upgrade @graphorin/agent to load this state.',\n 'RunStateVersionUnsupportedError',\n );\n this.version = version;\n this.readerVersion = readerVersion;\n }\n}\n\n/**\n * Thrown by `runStateFromJSON(...)` when the supplied JSON does not\n * shape-match the documented `SerializedRunState`.\n *\n * @stable\n */\nexport class RunStateMalformedError extends AgentRuntimeError {\n constructor(reason: string) {\n super('run-state-malformed', `Malformed RunState JSON: ${reason}.`, 'RunStateMalformedError');\n }\n}\n\n/**\n * Thrown by `Agent.fanOut(...)` when the configured\n * `MergeAgentSidewaysInjectionGuard` fires with strictness\n * `'detect-and-block'`.\n *\n * @stable\n */\nexport class MergeBlockedError extends AgentRuntimeError {\n readonly fanOutId: string;\n readonly reason: string;\n constructor(fanOutId: string, reason: string) {\n super(\n 'merge-blocked',\n `Agent.fanOut('${fanOutId}') merge blocked by MergeAgentSidewaysInjectionGuard: ${reason}.`,\n 'MergeBlockedError',\n );\n this.fanOutId = fanOutId;\n this.reason = reason;\n }\n}\n\n/**\n * Thrown by the protocol-injection guard when the operator selected\n * the strictest deployment posture (`escapePolicy: 'reject'`) and a\n * tool result body carries control characters at the corresponding\n * outbound boundary.\n *\n * @stable\n */\nexport class ProtocolInjectionRejectError extends AgentRuntimeError {\n readonly boundary: string;\n readonly matchedPattern: string;\n constructor(boundary: string, matchedPattern: string) {\n super(\n 'protocol-injection-rejected',\n `Protocol injection guard rejected output at the '${boundary}' boundary (matched ${matchedPattern}).`,\n 'ProtocolInjectionRejectError',\n );\n this.boundary = boundary;\n this.matchedPattern = matchedPattern;\n }\n}\n\n/**\n * Thrown by `agent.progress.write(...)` when the atomic write fails\n * (disk full, permission denied, ...). The partial `.tmp` file is\n * unlinked before the error propagates.\n *\n * @stable\n */\nexport class ProgressWriteError extends AgentRuntimeError {\n readonly path: string;\n constructor(path: string, cause: unknown) {\n const message = cause instanceof Error ? cause.message : String(cause);\n super(\n 'progress-write-failed',\n `agent.progress.write('${path}') failed: ${message}.`,\n 'ProgressWriteError',\n );\n this.path = path;\n if (cause !== undefined) {\n // Preserve the underlying cause for diagnostics.\n Object.defineProperty(this, 'cause', {\n value: cause,\n enumerable: false,\n configurable: true,\n writable: true,\n });\n }\n }\n}\n\n/**\n * Thrown by `createAgent({...})` when the supplied\n * `composeProviderMiddleware` chain violates the canonical inside-out\n * ordering (DEC-145 / ADR-039).\n *\n * @stable\n */\nexport class ProviderMiddlewareOrderError extends AgentRuntimeError {\n constructor(reason: string) {\n super(\n 'middleware-order-violation',\n `Provider middleware composition violated the inside-out ordering: ${reason}.`,\n 'ProviderMiddlewareOrderError',\n );\n }\n}\n"],"mappings":";;;;;;AAuCA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,AAAS;CACT,YAAY,MAA6B,SAAiB,OAAO,qBAAqB;AACpF,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,0BAAb,cAA6C,kBAAkB;CAC7D,YAAY,QAAgB;AAC1B,QACE,kBACA,uCAAuC,OAAO,IAC9C,0BACD;;;;;;;;;;AAWL,IAAa,6BAAb,cAAgD,kBAAkB;CAChE,AAAS;CACT,YAAY,OAAgB;AAC1B,QACE,2BACA,iCAAiC,KAAK,UAAU,MAAM,CAAC,wDAEvD,6BACD;AACD,OAAK,QAAQ;;;;;;;;;;AAWjB,IAAa,gCAAb,cAAmD,kBAAkB;CACnE,YAAY,QAAgB;AAC1B,QACE,sCACA,8CAA8C,OAAO,IACrD,gCACD;;;;;;;;;;AAWL,IAAa,uBAAb,cAA0C,kBAAkB;CAC1D,AAAS;CACT,YAAY,SAAiB;AAC3B,QACE,2BACA,4BAA4B,QAAQ,6CACpC,uBACD;AACD,OAAK,UAAU;;;;;;;;;AAUnB,IAAa,oBAAb,cAAuC,kBAAkB;CACvD,AAAS;CACT,YAAY,UAAkB;AAC5B,QACE,kBACA,SAAS,SAAS,qCAClB,oBACD;AACD,OAAK,WAAW;;;;;;;;;;;;;;;;;;;;AAqBpB,IAAa,qBAAb,cAAwC,kBAAkB;CACxD,cAAc;AACZ,QACE,kBACA,qKACA,qBACD;;;AAIL,IAAa,8BAAb,cAAiD,kBAAkB;CACjE,AAAS;CACT,YAAY,cAAqC;AAC/C,QACE,6BACA,yDAAyD,aAAa,KAAK,KAAK,CAAC,IACjF,8BACD;AACD,OAAK,eAAe;;;;;;;;;;;;AAaxB,IAAa,oCAAb,cAAuD,kBAAkB;CACvE,AAAS;CACT,YAAY,UAAkB,QAAgB;AAC5C,QACE,mCACA,gDAAgD,SAAS,KAAK,OAAO,uHACrE,oCACD;AACD,OAAK,WAAW;;;;;;;;;AAUpB,IAAa,kCAAb,cAAqD,kBAAkB;CACrE,AAAS;CACT,AAAS;CACT,YAAY,SAAiB,eAAuB;AAClD,QACE,iCACA,qBAAqB,QAAQ,0BAA0B,cAAc,kDAErE,kCACD;AACD,OAAK,UAAU;AACf,OAAK,gBAAgB;;;;;;;;;AAUzB,IAAa,yBAAb,cAA4C,kBAAkB;CAC5D,YAAY,QAAgB;AAC1B,QAAM,uBAAuB,4BAA4B,OAAO,IAAI,yBAAyB;;;;;;;;;;AAWjG,IAAa,oBAAb,cAAuC,kBAAkB;CACvD,AAAS;CACT,AAAS;CACT,YAAY,UAAkB,QAAgB;AAC5C,QACE,iBACA,iBAAiB,SAAS,wDAAwD,OAAO,IACzF,oBACD;AACD,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;;;;;;AAYlB,IAAa,+BAAb,cAAkD,kBAAkB;CAClE,AAAS;CACT,AAAS;CACT,YAAY,UAAkB,gBAAwB;AACpD,QACE,+BACA,oDAAoD,SAAS,sBAAsB,eAAe,KAClG,+BACD;AACD,OAAK,WAAW;AAChB,OAAK,iBAAiB;;;;;;;;;;AAW1B,IAAa,qBAAb,cAAwC,kBAAkB;CACxD,AAAS;CACT,YAAY,MAAc,OAAgB;EACxC,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,QACE,yBACA,yBAAyB,KAAK,aAAa,QAAQ,IACnD,qBACD;AACD,OAAK,OAAO;AACZ,MAAI,UAAU,OAEZ,QAAO,eAAe,MAAM,SAAS;GACnC,OAAO;GACP,YAAY;GACZ,cAAc;GACd,UAAU;GACX,CAAC;;;;;;;;;;AAYR,IAAa,+BAAb,cAAkD,kBAAkB;CAClE,YAAY,QAAgB;AAC1B,QACE,8BACA,qEAAqE,OAAO,IAC5E,+BACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","names":[],"sources":["../src/factory.ts"],"sourcesContent":[],"mappings":";;;;;;;;;iBAy4BgB,uDACN,YAAY,OAAO,WAC1B,MAAM,OAAO"}
1
+ {"version":3,"file":"factory.d.ts","names":[],"sources":["../src/factory.ts"],"sourcesContent":[],"mappings":";;;;;;;;;iBA8HgB,uDACN,YAAY,OAAO,WAC1B,MAAM,OAAO"}