agentfootprint 9.74.0 → 9.76.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 (161) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +126 -0
  3. package/CLAUDE.md +24 -19
  4. package/ai-instructions/claude-code/SKILL.md +1 -1
  5. package/dist/artifacts/index.js +3 -1
  6. package/dist/artifacts/index.js.map +1 -1
  7. package/dist/artifacts/recordingArtifact.js +47 -1
  8. package/dist/artifacts/recordingArtifact.js.map +1 -1
  9. package/dist/core/Agent.js +53 -1
  10. package/dist/core/Agent.js.map +1 -1
  11. package/dist/core/agent/AgentBuilder.js +12 -0
  12. package/dist/core/agent/AgentBuilder.js.map +1 -1
  13. package/dist/core/agent/evidence/gate.js +22 -3
  14. package/dist/core/agent/evidence/gate.js.map +1 -1
  15. package/dist/core/agent/stagedRefs.js +161 -0
  16. package/dist/core/agent/stagedRefs.js.map +1 -0
  17. package/dist/core/agent/stages/callLLM.js +22 -2
  18. package/dist/core/agent/stages/callLLM.js.map +1 -1
  19. package/dist/core/agent/stages/evidenceRecheck.js +21 -2
  20. package/dist/core/agent/stages/evidenceRecheck.js.map +1 -1
  21. package/dist/core/agent/stages/toolCalls.js +42 -0
  22. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  23. package/dist/core/agent/toolDispatch.js +101 -0
  24. package/dist/core/agent/toolDispatch.js.map +1 -0
  25. package/dist/core/flowchartAsTool.js +9 -2
  26. package/dist/core/flowchartAsTool.js.map +1 -1
  27. package/dist/core/runbook/coverage.js +162 -0
  28. package/dist/core/runbook/coverage.js.map +1 -0
  29. package/dist/core/runbook/dispatch.js +119 -0
  30. package/dist/core/runbook/dispatch.js.map +1 -0
  31. package/dist/core/runbook/index.js +24 -0
  32. package/dist/core/runbook/index.js.map +1 -0
  33. package/dist/core/runbook/runbookAsTool.js +358 -0
  34. package/dist/core/runbook/runbookAsTool.js.map +1 -0
  35. package/dist/core/runbook/types.js +22 -0
  36. package/dist/core/runbook/types.js.map +1 -0
  37. package/dist/core/runbook/verdicts.js +156 -0
  38. package/dist/core/runbook/verdicts.js.map +1 -0
  39. package/dist/core/runbook/walk.js +115 -0
  40. package/dist/core/runbook/walk.js.map +1 -0
  41. package/dist/core/tools.js +55 -1
  42. package/dist/core/tools.js.map +1 -1
  43. package/dist/esm/artifacts/index.d.ts +1 -1
  44. package/dist/esm/artifacts/index.js +1 -1
  45. package/dist/esm/artifacts/index.js.map +1 -1
  46. package/dist/esm/artifacts/recordingArtifact.d.ts +36 -0
  47. package/dist/esm/artifacts/recordingArtifact.js +45 -0
  48. package/dist/esm/artifacts/recordingArtifact.js.map +1 -1
  49. package/dist/esm/core/Agent.js +53 -1
  50. package/dist/esm/core/Agent.js.map +1 -1
  51. package/dist/esm/core/agent/AgentBuilder.d.ts +12 -0
  52. package/dist/esm/core/agent/AgentBuilder.js +12 -0
  53. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  54. package/dist/esm/core/agent/evidence/gate.d.ts +11 -1
  55. package/dist/esm/core/agent/evidence/gate.js +22 -3
  56. package/dist/esm/core/agent/evidence/gate.js.map +1 -1
  57. package/dist/esm/core/agent/evidence/types.d.ts +23 -0
  58. package/dist/esm/core/agent/stagedRefs.d.ts +94 -0
  59. package/dist/esm/core/agent/stagedRefs.js +154 -0
  60. package/dist/esm/core/agent/stagedRefs.js.map +1 -0
  61. package/dist/esm/core/agent/stages/callLLM.d.ts +17 -0
  62. package/dist/esm/core/agent/stages/callLLM.js +22 -2
  63. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  64. package/dist/esm/core/agent/stages/evidenceRecheck.d.ts +19 -1
  65. package/dist/esm/core/agent/stages/evidenceRecheck.js +21 -2
  66. package/dist/esm/core/agent/stages/evidenceRecheck.js.map +1 -1
  67. package/dist/esm/core/agent/stages/toolCalls.js +42 -0
  68. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  69. package/dist/esm/core/agent/toolDispatch.d.ts +50 -0
  70. package/dist/esm/core/agent/toolDispatch.js +97 -0
  71. package/dist/esm/core/agent/toolDispatch.js.map +1 -0
  72. package/dist/esm/core/flowchartAsTool.d.ts +6 -0
  73. package/dist/esm/core/flowchartAsTool.js +9 -2
  74. package/dist/esm/core/flowchartAsTool.js.map +1 -1
  75. package/dist/esm/core/runbook/coverage.d.ts +69 -0
  76. package/dist/esm/core/runbook/coverage.js +155 -0
  77. package/dist/esm/core/runbook/coverage.js.map +1 -0
  78. package/dist/esm/core/runbook/dispatch.d.ts +69 -0
  79. package/dist/esm/core/runbook/dispatch.js +112 -0
  80. package/dist/esm/core/runbook/dispatch.js.map +1 -0
  81. package/dist/esm/core/runbook/index.d.ts +9 -0
  82. package/dist/esm/core/runbook/index.js +9 -0
  83. package/dist/esm/core/runbook/index.js.map +1 -0
  84. package/dist/esm/core/runbook/runbookAsTool.d.ts +88 -0
  85. package/dist/esm/core/runbook/runbookAsTool.js +354 -0
  86. package/dist/esm/core/runbook/runbookAsTool.js.map +1 -0
  87. package/dist/esm/core/runbook/types.d.ts +196 -0
  88. package/dist/esm/core/runbook/types.js +21 -0
  89. package/dist/esm/core/runbook/types.js.map +1 -0
  90. package/dist/esm/core/runbook/verdicts.d.ts +78 -0
  91. package/dist/esm/core/runbook/verdicts.js +148 -0
  92. package/dist/esm/core/runbook/verdicts.js.map +1 -0
  93. package/dist/esm/core/runbook/walk.d.ts +72 -0
  94. package/dist/esm/core/runbook/walk.js +110 -0
  95. package/dist/esm/core/runbook/walk.js.map +1 -0
  96. package/dist/esm/core/tools.d.ts +112 -0
  97. package/dist/esm/core/tools.js +52 -0
  98. package/dist/esm/core/tools.js.map +1 -1
  99. package/dist/esm/events/payloads.d.ts +39 -0
  100. package/dist/esm/events/registry.d.ts +3 -1
  101. package/dist/esm/events/registry.js +2 -0
  102. package/dist/esm/events/registry.js.map +1 -1
  103. package/dist/esm/index.d.ts +4 -3
  104. package/dist/esm/index.js +19 -2
  105. package/dist/esm/index.js.map +1 -1
  106. package/dist/esm/lib/mcp/toolExtras.d.ts +8 -0
  107. package/dist/esm/lib/mcp/toolExtras.js +7 -1
  108. package/dist/esm/lib/mcp/toolExtras.js.map +1 -1
  109. package/dist/events/registry.js +2 -0
  110. package/dist/events/registry.js.map +1 -1
  111. package/dist/index.js +97 -66
  112. package/dist/index.js.map +1 -1
  113. package/dist/lib/mcp/toolExtras.js +6 -0
  114. package/dist/lib/mcp/toolExtras.js.map +1 -1
  115. package/dist/types/artifacts/index.d.ts +1 -1
  116. package/dist/types/artifacts/index.d.ts.map +1 -1
  117. package/dist/types/artifacts/recordingArtifact.d.ts +36 -0
  118. package/dist/types/artifacts/recordingArtifact.d.ts.map +1 -1
  119. package/dist/types/core/Agent.d.ts.map +1 -1
  120. package/dist/types/core/agent/AgentBuilder.d.ts +12 -0
  121. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  122. package/dist/types/core/agent/evidence/gate.d.ts +11 -1
  123. package/dist/types/core/agent/evidence/gate.d.ts.map +1 -1
  124. package/dist/types/core/agent/evidence/types.d.ts +23 -0
  125. package/dist/types/core/agent/evidence/types.d.ts.map +1 -1
  126. package/dist/types/core/agent/stagedRefs.d.ts +95 -0
  127. package/dist/types/core/agent/stagedRefs.d.ts.map +1 -0
  128. package/dist/types/core/agent/stages/callLLM.d.ts +17 -0
  129. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  130. package/dist/types/core/agent/stages/evidenceRecheck.d.ts +19 -1
  131. package/dist/types/core/agent/stages/evidenceRecheck.d.ts.map +1 -1
  132. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  133. package/dist/types/core/agent/toolDispatch.d.ts +51 -0
  134. package/dist/types/core/agent/toolDispatch.d.ts.map +1 -0
  135. package/dist/types/core/flowchartAsTool.d.ts +6 -0
  136. package/dist/types/core/flowchartAsTool.d.ts.map +1 -1
  137. package/dist/types/core/runbook/coverage.d.ts +70 -0
  138. package/dist/types/core/runbook/coverage.d.ts.map +1 -0
  139. package/dist/types/core/runbook/dispatch.d.ts +70 -0
  140. package/dist/types/core/runbook/dispatch.d.ts.map +1 -0
  141. package/dist/types/core/runbook/index.d.ts +10 -0
  142. package/dist/types/core/runbook/index.d.ts.map +1 -0
  143. package/dist/types/core/runbook/runbookAsTool.d.ts +89 -0
  144. package/dist/types/core/runbook/runbookAsTool.d.ts.map +1 -0
  145. package/dist/types/core/runbook/types.d.ts +197 -0
  146. package/dist/types/core/runbook/types.d.ts.map +1 -0
  147. package/dist/types/core/runbook/verdicts.d.ts +79 -0
  148. package/dist/types/core/runbook/verdicts.d.ts.map +1 -0
  149. package/dist/types/core/runbook/walk.d.ts +73 -0
  150. package/dist/types/core/runbook/walk.d.ts.map +1 -0
  151. package/dist/types/core/tools.d.ts +112 -0
  152. package/dist/types/core/tools.d.ts.map +1 -1
  153. package/dist/types/events/payloads.d.ts +39 -0
  154. package/dist/types/events/payloads.d.ts.map +1 -1
  155. package/dist/types/events/registry.d.ts +3 -1
  156. package/dist/types/events/registry.d.ts.map +1 -1
  157. package/dist/types/index.d.ts +4 -3
  158. package/dist/types/index.d.ts.map +1 -1
  159. package/dist/types/lib/mcp/toolExtras.d.ts +8 -0
  160. package/dist/types/lib/mcp/toolExtras.d.ts.map +1 -1
  161. package/package.json +1 -1
@@ -0,0 +1,97 @@
1
+ /**
2
+ * toolDispatch — the run's own tool dispatch, delivered as `ctx.tools`.
3
+ *
4
+ * Pattern: a deps-closure factory beside `toolArtifacts` / `toolProgress` in
5
+ * the tool-calls handler; this module holds the PURE half (the
6
+ * dispatch object over a lookup + an inner-context maker) so the
7
+ * handler wires closures and nothing else.
8
+ * Role: core/agent — composition over the registry (the runbookAsTool
9
+ * substrate; any tool may consume it).
10
+ * Emits: nothing itself. Inner executes flow through the tool's own
11
+ * channels (`ctx.progress`, its result); they do NOT fire
12
+ * `tool_start`/`tool_end` — an inner call is the OUTER call's work,
13
+ * not a turn of the model's, and synthesizing model-facing events
14
+ * for it would put calls in the record the model never made.
15
+ *
16
+ * What an inner call is NOT (phase 1, refused loudly, never silently):
17
+ * - it cannot pause — a `checkIn` tool or a credential that needs
18
+ * interactive consent refuses by name;
19
+ * - it cannot redeem artifact refs — a `wants` tool refuses by name
20
+ * (dispatch-time resolution belongs to the model-facing loop);
21
+ * - it does not see ToolProvider-delivered tools — there is no build-time
22
+ * list of those (the 9.72.0 caveat, carried forward honestly);
23
+ * - it does not carry `ctx.tools` itself — composition depth stops at one,
24
+ * the same bound the runbook grammar declares for sub-runbooks.
25
+ */
26
+ /**
27
+ * Build the `ctx.tools` dispatch for one outer tool call.
28
+ *
29
+ * `call` resolves the inner tool's declared `needs` through the inner
30
+ * context's own credential provider (fail-closed — the provider throws its
31
+ * teaching refusal when none is attached), refuses the shapes an inner call
32
+ * cannot honor (see the module header), executes, and returns the result
33
+ * exactly as the tool returned it. Policy about what a result MEANS — an
34
+ * absence that should short-circuit, a coverage ledger that should fold —
35
+ * belongs to the consumer wrapping this dispatch, never here.
36
+ */
37
+ export function agentToolDispatch(deps) {
38
+ let seq = 0;
39
+ return {
40
+ has(name) {
41
+ return deps.lookup(name) !== undefined;
42
+ },
43
+ async call(name, args, opts) {
44
+ const tool = deps.lookup(name);
45
+ if (tool === undefined) {
46
+ throw new Error(`ctx.tools.call('${name}'): no tool of that name is in this agent's dispatch map ` +
47
+ `(static .tool() registrations plus skill-carried tools). Tools delivered by a ` +
48
+ `ToolProvider are not visible to inner dispatch — there is no build-time list of ` +
49
+ `them. Register the tool statically, or check ctx.tools.has() first.`);
50
+ }
51
+ if (tool.checkIn !== undefined) {
52
+ throw new Error(`ctx.tools.call('${name}'): that tool declares a human check-in, and an inner ` +
53
+ `dispatch call cannot pause — running it here would silently skip a consent ` +
54
+ `gate somebody declared. Call it as a top-level tool, where the check-in rail ` +
55
+ `holds.`);
56
+ }
57
+ if (tool.wants !== undefined) {
58
+ throw new Error(`ctx.tools.call('${name}'): that tool declares artifact arguments (wants), and ` +
59
+ `inner dispatch does not resolve refs — the tool would run believing the ` +
60
+ `framework delivered data it did not. Call it as a top-level tool, or pass the ` +
61
+ `data through a tool that takes it directly.`);
62
+ }
63
+ seq += 1;
64
+ const base = deps.innerContext(name, seq);
65
+ const ctx = {
66
+ ...base,
67
+ ...(opts?.signal !== undefined && { signal: opts.signal }),
68
+ ...(tool.needs !== undefined && {
69
+ credential: await resolveInnerCredential(name, tool, base),
70
+ }),
71
+ };
72
+ return await tool.execute(args, ctx);
73
+ },
74
+ };
75
+ }
76
+ /**
77
+ * Resolve a declared `needs` for an inner call — the simple, non-interactive
78
+ * path only. Fail-closed: anything short of an issued credential refuses by
79
+ * name, because the consent flow the outer loop would ride (pause, URL,
80
+ * resume) has no seat inside a dispatch call.
81
+ */
82
+ async function resolveInnerCredential(name, tool, ctx) {
83
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
84
+ const need = tool.needs;
85
+ const result = await ctx.credentials.getCredential({
86
+ service: need.credential,
87
+ ...(need.scopes && { scopes: need.scopes }),
88
+ ...(need.mode && { mode: need.mode }),
89
+ });
90
+ if (result.status === 'issued')
91
+ return result.credential;
92
+ throw new Error(`ctx.tools.call('${name}'): the tool's declared credential '${need.credential}' did not ` +
93
+ `resolve to an issued credential (status '${result.status}'). An inner dispatch call ` +
94
+ `cannot pause for consent — complete the authorization first, or call the tool at the ` +
95
+ `top level where the consent rail can hold the run.`);
96
+ }
97
+ //# sourceMappingURL=toolDispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolDispatch.js","sourceRoot":"","sources":["../../../../src/core/agent/toolDispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAuBH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA2B;IAC3D,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,OAAO;QACL,GAAG,CAAC,IAAY;YACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;QACz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Y,EACZ,IAAU,EACV,GAAyB;IAEzB,oEAAoE;IACpE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAM,CAAC;IACzB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC;QACjD,OAAO,EAAE,IAAI,CAAC,UAAU;QACxB,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3C,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;KACtC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,UAAU,CAAC;IACzD,MAAM,IAAI,KAAK,CACb,mBAAmB,IAAI,uCAAuC,IAAI,CAAC,UAAU,YAAY;QACvF,4CAA4C,MAAM,CAAC,MAAM,6BAA6B;QACtF,uFAAuF;QACvF,oDAAoD,CACvD,CAAC;AACJ,CAAC"}
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * flowchartAsTool — wrap a footprintjs `FlowChart` as an Agent `Tool`.
3
3
  *
4
+ * NOTE (9.76.0): for NEW procedures prefer `runbookAsTool` (core/runbook/) —
5
+ * the standard bridge whose every answer carries the honesty envelope
6
+ * (coverage, provenance, rule version, the recorded walk). This thin wrapper
7
+ * stays for compatibility; `resultMapper` users stay put and nothing here
8
+ * changes.
9
+ *
4
10
  * The Block A7 piece. footprintjs is the substrate; agentfootprint is
5
11
  * the agent layer above it. When a multi-step procedure is already
6
12
  * expressed as a footprintjs flowchart (intake validation, refund
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * flowchartAsTool — wrap a footprintjs `FlowChart` as an Agent `Tool`.
3
3
  *
4
+ * NOTE (9.76.0): for NEW procedures prefer `runbookAsTool` (core/runbook/) —
5
+ * the standard bridge whose every answer carries the honesty envelope
6
+ * (coverage, provenance, rule version, the recorded walk). This thin wrapper
7
+ * stays for compatibility; `resultMapper` users stay put and nothing here
8
+ * changes.
9
+ *
4
10
  * The Block A7 piece. footprintjs is the substrate; agentfootprint is
5
11
  * the agent layer above it. When a multi-step procedure is already
6
12
  * expressed as a footprintjs flowchart (intake validation, refund
@@ -247,8 +253,9 @@ export function flowchartAsTool(opts) {
247
253
  }
248
254
  if (executor.isPaused()) {
249
255
  keepRecordOf('paused');
250
- const err = new Error(`flowchartAsTool(${opts.name}): inner flowchart paused. ` +
251
- `Agent-side pause integration lands in v2.6. The checkpoint is on err.checkpoint.`);
256
+ const err = new Error(`flowchartAsTool(${opts.name}): inner flowchart paused. Agent-side pause ` +
257
+ `integration lands with the runbook program's approval-gate phase (see ` +
258
+ `runbookAsTool). The checkpoint is on err.checkpoint.`);
252
259
  err.checkpoint = executor.getCheckpoint();
253
260
  throw err;
254
261
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flowchartAsTool.js","sourceRoot":"","sources":["../../../src/core/flowchartAsTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqHG;AAEH,OAAO,EACL,iBAAiB,GAIlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,GAId,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAiJxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,eAAe,CAAC,IAA4B;IAC1D,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,4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AO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC1D,OAAO,kBAAkB,MAAM,GAAG,CAAC;YACrC,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,sEAAsE;IACtE,sEAAsE;IACtE,oEAAoE;IACpE,+DAA+D;IAC/D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,YAAY,GAA0B,EAAE,GAAG,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC;IACpF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CACvB,GAAY,EACZ,QAAwE;IAExE,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,mBAAmB,KAAK,UAAU,EAAE,CAAC;QACnE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,QAAQ,CAAC,mBAAmB,EAAE,CAAC;YAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3B,OAAO,OAAwE,CAAC;YAClF,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,iCAAiC;QACnC,CAAC;IACH,CAAC;IACD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAC/C,MAAM,SAAS,GACZ,GAA+B,CAAC,SAAS;QACzC,GAAsC,CAAC,gBAAgB,CAAC;IAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,OAAO,SAA0E,CAAC;IACpF,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * runbook/coverage — the spine's ledger: inner folds + chart-declared
3
+ * entries + the bridge's own, and the sentence naming the rules.
4
+ *
5
+ * Pattern: pure fold over three sources, reusing the coverage primitives'
6
+ * own recognizer and merge — no second grammar.
7
+ * Role: core/runbook.
8
+ * Emits: N/A.
9
+ *
10
+ * The three sources, in the order they land:
11
+ * 1. INNER LEDGERS — every recorded inner call's result is read by the
12
+ * same `readCoverageResult` funnel the dispatch loop uses, and its
13
+ * three lists fold upward. An inner tool's honesty is carried, never
14
+ * re-authored.
15
+ * 2. THE CHART'S OWN — the procedure states run-specific coverage by
16
+ * writing a `coverage` state key (`{ checked?, not_checked?,
17
+ * cannot_cover? }`, items as `{what, why?}` bags or bare strings).
18
+ * This is the app's vocabulary (which counters mean "not assessed" is
19
+ * the chart's to know); the ENVELOPE is the bridge's.
20
+ * 3. THE BRIDGE'S OWN — one `checked` entry naming the procedure, its
21
+ * recorded step count and the rule set it ran under; and, for a
22
+ * verdict-shaped runbook, a `not_checked` entry counting DECLINED rows
23
+ * (the three-outcome honesty: a row that reached no classification is
24
+ * ground the answer does not cover).
25
+ */
26
+ import type { CoverageItem } from '../agent/coverage/types.js';
27
+ import type { InnerCallRecord } from './dispatch.js';
28
+ import type { RunbookRules } from './types.js';
29
+ /** The three lists, mid-fold. */
30
+ export interface LedgerLists {
31
+ readonly checked: readonly CoverageItem[];
32
+ readonly notChecked: readonly CoverageItem[];
33
+ readonly cannotCover: readonly CoverageItem[];
34
+ }
35
+ /** Fold every recorded inner call's declared coverage upward. */
36
+ export declare function foldInnerCoverage(records: readonly InnerCallRecord[]): LedgerLists;
37
+ /** The chart-declared lists, read off the final state's `coverage` key.
38
+ * Accepts both spellings of the two-word keys (state is often snake_case,
39
+ * the declaration camelCase) — one reader, no drift. */
40
+ export declare function chartCoverageOf(state: Readonly<Record<string, unknown>>): LedgerLists;
41
+ /** What the composed ledger needs to know about this run. */
42
+ export interface LedgerFacts {
43
+ readonly chartName: string;
44
+ readonly stepsExecuted: number;
45
+ readonly rules?: RunbookRules;
46
+ /** Rowset facts — present only for a verdict-shaped runbook. */
47
+ readonly rowsTotal?: number;
48
+ readonly declinedRows?: number;
49
+ }
50
+ /** The composed `af_coverage` value: three merged lists + the static law
51
+ * note + this run's own sentence. */
52
+ export interface ComposedLedger {
53
+ readonly checked?: readonly CoverageItem[];
54
+ readonly not_checked?: readonly CoverageItem[];
55
+ readonly cannot_cover?: readonly CoverageItem[];
56
+ readonly note: string;
57
+ readonly sentence: string;
58
+ }
59
+ /** Compose the whole ledger. Inner folds land first, chart-declared second,
60
+ * the bridge's own last — provenance order, so a reader meets the sources
61
+ * before the summary. */
62
+ export declare function composeLedger(inner: LedgerLists, chart: LedgerLists, facts: LedgerFacts): ComposedLedger;
63
+ /**
64
+ * The carried provenance stamp: the FIRST inner result that declared an
65
+ * `af_provenance` (on its unwrapped payload, or at its top level — both are
66
+ * read, in that order). A derived answer is still an answer, and a source's
67
+ * confession (`source: 'LOCAL SEED'`) must survive composition.
68
+ */
69
+ export declare function carriedProvenanceOf(records: readonly InnerCallRecord[]): Record<string, unknown> | undefined;
@@ -0,0 +1,155 @@
1
+ /**
2
+ * runbook/coverage — the spine's ledger: inner folds + chart-declared
3
+ * entries + the bridge's own, and the sentence naming the rules.
4
+ *
5
+ * Pattern: pure fold over three sources, reusing the coverage primitives'
6
+ * own recognizer and merge — no second grammar.
7
+ * Role: core/runbook.
8
+ * Emits: N/A.
9
+ *
10
+ * The three sources, in the order they land:
11
+ * 1. INNER LEDGERS — every recorded inner call's result is read by the
12
+ * same `readCoverageResult` funnel the dispatch loop uses, and its
13
+ * three lists fold upward. An inner tool's honesty is carried, never
14
+ * re-authored.
15
+ * 2. THE CHART'S OWN — the procedure states run-specific coverage by
16
+ * writing a `coverage` state key (`{ checked?, not_checked?,
17
+ * cannot_cover? }`, items as `{what, why?}` bags or bare strings).
18
+ * This is the app's vocabulary (which counters mean "not assessed" is
19
+ * the chart's to know); the ENVELOPE is the bridge's.
20
+ * 3. THE BRIDGE'S OWN — one `checked` entry naming the procedure, its
21
+ * recorded step count and the rule set it ran under; and, for a
22
+ * verdict-shaped runbook, a `not_checked` entry counting DECLINED rows
23
+ * (the three-outcome honesty: a row that reached no classification is
24
+ * ground the answer does not cover).
25
+ */
26
+ import { readCoverageResult } from '../agent/coverage/read.js';
27
+ import { mergeItems } from '../agent/coverage/items.js';
28
+ import { COVERAGE_NOTE } from '../agent/coverage/ledger.js';
29
+ const EMPTY = { checked: [], notChecked: [], cannotCover: [] };
30
+ /** Fold every recorded inner call's declared coverage upward. */
31
+ export function foldInnerCoverage(records) {
32
+ const checked = [];
33
+ const notChecked = [];
34
+ const cannotCover = [];
35
+ for (const record of records) {
36
+ if (record.result === undefined)
37
+ continue;
38
+ const reading = readCoverageResult(record.result);
39
+ for (const declared of reading?.declared ?? []) {
40
+ checked.push(declared.coverage.checked);
41
+ notChecked.push(declared.coverage.notChecked);
42
+ cannotCover.push(declared.coverage.cannotCover);
43
+ }
44
+ }
45
+ return {
46
+ checked: mergeItems(checked),
47
+ notChecked: mergeItems(notChecked),
48
+ cannotCover: mergeItems(cannotCover),
49
+ };
50
+ }
51
+ /** One list off the chart's `coverage` state key, normalized leniently —
52
+ * this is state the chart wrote, not a foreign wire; a malformed entry is
53
+ * dropped rather than refused (the run already happened). */
54
+ function stateList(value) {
55
+ if (!Array.isArray(value))
56
+ return [];
57
+ const items = [];
58
+ for (const entry of value) {
59
+ if (typeof entry === 'string' && entry.trim() !== '') {
60
+ items.push({ what: entry.trim() });
61
+ }
62
+ else if (entry !== null &&
63
+ typeof entry === 'object' &&
64
+ typeof entry.what === 'string') {
65
+ const what = entry.what;
66
+ const why = entry.why;
67
+ items.push({ what, ...(typeof why === 'string' && { why }) });
68
+ }
69
+ }
70
+ return items;
71
+ }
72
+ /** The chart-declared lists, read off the final state's `coverage` key.
73
+ * Accepts both spellings of the two-word keys (state is often snake_case,
74
+ * the declaration camelCase) — one reader, no drift. */
75
+ export function chartCoverageOf(state) {
76
+ const bag = state.coverage;
77
+ if (bag === null || typeof bag !== 'object' || Array.isArray(bag))
78
+ return EMPTY;
79
+ const rec = bag;
80
+ return {
81
+ checked: stateList(rec.checked),
82
+ notChecked: stateList(rec.not_checked ?? rec.notChecked),
83
+ cannotCover: stateList(rec.cannot_cover ?? rec.cannotCover),
84
+ };
85
+ }
86
+ /** The rules clause every sentence carries — or the honest silence. */
87
+ function rulesClause(rules) {
88
+ return rules !== undefined ? ` under ${rules.name} ${rules.version}` : '';
89
+ }
90
+ /** Compose the whole ledger. Inner folds land first, chart-declared second,
91
+ * the bridge's own last — provenance order, so a reader meets the sources
92
+ * before the summary. */
93
+ export function composeLedger(inner, chart, facts) {
94
+ const own = [
95
+ {
96
+ what: `the declared procedure '${facts.chartName}' — ${facts.stepsExecuted} step(s) ` +
97
+ `recorded${rulesClause(facts.rules)}`,
98
+ ...(facts.rowsTotal !== undefined && {
99
+ why: `${facts.rowsTotal} row(s) assessed, one decider pass per row`,
100
+ }),
101
+ },
102
+ ];
103
+ const declinedEntries = facts.declinedRows !== undefined && facts.declinedRows > 0
104
+ ? [
105
+ {
106
+ what: `${facts.declinedRows} row(s) that reached NO classification (verdict 'declined')`,
107
+ why: 'the declared rules could not be read for them; they are in the rowset with ' +
108
+ 'everything that IS known, and nothing was guessed to fill the gap',
109
+ },
110
+ ]
111
+ : [];
112
+ const checked = mergeItems([inner.checked, chart.checked, own]);
113
+ const notChecked = mergeItems([inner.notChecked, chart.notChecked, declinedEntries]);
114
+ const cannotCover = mergeItems([inner.cannotCover, chart.cannotCover]);
115
+ const rowsPart = facts.rowsTotal !== undefined
116
+ ? `; ${facts.rowsTotal} row(s) assessed` +
117
+ (facts.declinedRows !== undefined && facts.declinedRows > 0
118
+ ? `, ${facts.declinedRows} declined (no classification reached)`
119
+ : '')
120
+ : '';
121
+ const gapsPart = notChecked.length > 0 ? `; ${notChecked.length} not-checked item(s) declared` : '';
122
+ const sentence = `Ran '${facts.chartName}'${rulesClause(facts.rules)} — ` +
123
+ `${facts.stepsExecuted} step(s) recorded${rowsPart}${gapsPart}.`;
124
+ return {
125
+ ...(checked.length > 0 && { checked }),
126
+ ...(notChecked.length > 0 && { not_checked: notChecked }),
127
+ ...(cannotCover.length > 0 && { cannot_cover: cannotCover }),
128
+ note: COVERAGE_NOTE,
129
+ sentence,
130
+ };
131
+ }
132
+ /**
133
+ * The carried provenance stamp: the FIRST inner result that declared an
134
+ * `af_provenance` (on its unwrapped payload, or at its top level — both are
135
+ * read, in that order). A derived answer is still an answer, and a source's
136
+ * confession (`source: 'LOCAL SEED'`) must survive composition.
137
+ */
138
+ export function carriedProvenanceOf(records) {
139
+ const bagOf = (value) => value !== null && typeof value === 'object' && !Array.isArray(value)
140
+ ? value
141
+ : undefined;
142
+ for (const record of records) {
143
+ const top = bagOf(record.result);
144
+ if (top === undefined)
145
+ continue;
146
+ const payload = bagOf(top.result);
147
+ for (const candidate of [payload, top]) {
148
+ const stamp = bagOf(candidate?.af_provenance);
149
+ if (stamp !== undefined)
150
+ return stamp;
151
+ }
152
+ }
153
+ return undefined;
154
+ }
155
+ //# sourceMappingURL=coverage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../../../src/core/runbook/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAY5D,MAAM,KAAK,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AAE5E,iEAAiE;AACjE,MAAM,UAAU,iBAAiB,CAAC,OAAmC;IACnE,MAAM,OAAO,GAAgC,EAAE,CAAC;IAChD,MAAM,UAAU,GAAgC,EAAE,CAAC;IACnD,MAAM,WAAW,GAAgC,EAAE,CAAC;IACpD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,SAAS;QAC1C,MAAM,OA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,CAAC;QACtC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;QACzD,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;QAC5D,IAAI,EAAE,aAAa;QACnB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAmC;IAEnC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAuC,EAAE,CACpE,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAClE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,SAAS,CAAC;IAChB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,GAAG,KAAK,SAAS;YAAE,SAAS;QAChC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,MAAM,SAAS,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;YACvC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YAC9C,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * runbook/dispatch — the bridge's wrapper over `ctx.tools`.
3
+ *
4
+ * Pattern: decorator over {@link ToolDispatch}. The RAW dispatch (delivered
5
+ * by the agent) returns every result untouched; POLICY about what a
6
+ * result means belongs to the consumer — and this is the runbook's
7
+ * policy: every inner outcome is RECORDED (for the coverage fold and
8
+ * the provenance carry), and an inner ABSENCE short-circuits the
9
+ * procedure unless the call site declared it survivable.
10
+ * Role: core/runbook, pure.
11
+ * Emits: N/A.
12
+ *
13
+ * WHY an absence short-circuits: "the inventory found nothing" IS the
14
+ * runbook's answer, and it must go back EXACTLY as it arrived so the
15
+ * framework still reads it as an absence — a verdict reached over a source
16
+ * that answered "nothing here" would be the confident-partial-answer failure
17
+ * this whole envelope exists to prevent. A stage that can genuinely carry on
18
+ * without the source says so at the call site (`{ allowAbsent: true }`) and
19
+ * owns stating the gap (usually as a coverage entry).
20
+ */
21
+ import type { ToolAbsence } from '../agent/coverage/types.js';
22
+ import type { ToolDispatch } from '../tools.js';
23
+ /** One inner call, as the bridge recorded it. */
24
+ export interface InnerCallRecord {
25
+ readonly tool: string;
26
+ readonly outcome: 'ok' | 'absent' | 'error';
27
+ /** The raw returned value (`'ok'` and `'absent'` outcomes). */
28
+ readonly result?: unknown;
29
+ }
30
+ /** The marker property that survives any error wrapping between a stage and
31
+ * the bridge's catch. */
32
+ declare const ABSENCE_SIGNAL: "af_runbook_absence";
33
+ /**
34
+ * The control signal an un-survivable inner absence throws through the
35
+ * chart. The engine commits staged state and rethrows (commit-on-error is
36
+ * the law upstream), so the bridge catches this at `executor.run` and
37
+ * returns the absence verbatim.
38
+ */
39
+ export declare class RunbookAbsenceSignal extends Error {
40
+ readonly absence: ToolAbsence;
41
+ readonly [ABSENCE_SIGNAL] = true;
42
+ constructor(absence: ToolAbsence, innerTool: string);
43
+ }
44
+ /** Recognize the signal on an error OR anywhere down its `cause` chain — an
45
+ * engine layer that wraps the stage's throw must not defeat the pass-through. */
46
+ export declare function absenceSignalOf(err: unknown): RunbookAbsenceSignal | undefined;
47
+ /** What `recordingDispatch` hands back: the dispatch the procedure closes
48
+ * over, and the record the envelope folds. */
49
+ export interface RecordedDispatch {
50
+ readonly tools: ToolDispatch;
51
+ readonly records: readonly InnerCallRecord[];
52
+ }
53
+ /**
54
+ * Wrap the delivered dispatch (or its absence) for one runbook invocation.
55
+ *
56
+ * With NO dispatch delivered (`ctx.tools` absent — a hand-built context, a
57
+ * door with no dispatch map) the wrapper is the fail-closed teacher: `has`
58
+ * answers false and `call` refuses naming the fix, so a procedure that needs
59
+ * inner tools fails loudly at its first call instead of half-running.
60
+ */
61
+ export declare function recordingDispatch(delivered: ToolDispatch | undefined, runbookName: string): RecordedDispatch;
62
+ /**
63
+ * The definition-time probe dispatch — handed to the procedure factory ONCE
64
+ * at `runbookAsTool(...)` so the bridge can read the chart's declared
65
+ * contract. Stage bodies do not run at build; a factory that calls tools at
66
+ * build time hears exactly why that cannot work.
67
+ */
68
+ export declare function probeDispatch(runbookName: string): ToolDispatch;
69
+ export {};
@@ -0,0 +1,112 @@
1
+ /**
2
+ * runbook/dispatch — the bridge's wrapper over `ctx.tools`.
3
+ *
4
+ * Pattern: decorator over {@link ToolDispatch}. The RAW dispatch (delivered
5
+ * by the agent) returns every result untouched; POLICY about what a
6
+ * result means belongs to the consumer — and this is the runbook's
7
+ * policy: every inner outcome is RECORDED (for the coverage fold and
8
+ * the provenance carry), and an inner ABSENCE short-circuits the
9
+ * procedure unless the call site declared it survivable.
10
+ * Role: core/runbook, pure.
11
+ * Emits: N/A.
12
+ *
13
+ * WHY an absence short-circuits: "the inventory found nothing" IS the
14
+ * runbook's answer, and it must go back EXACTLY as it arrived so the
15
+ * framework still reads it as an absence — a verdict reached over a source
16
+ * that answered "nothing here" would be the confident-partial-answer failure
17
+ * this whole envelope exists to prevent. A stage that can genuinely carry on
18
+ * without the source says so at the call site (`{ allowAbsent: true }`) and
19
+ * owns stating the gap (usually as a coverage entry).
20
+ */
21
+ import { readAbsence } from '../agent/coverage/absent.js';
22
+ /** The marker property that survives any error wrapping between a stage and
23
+ * the bridge's catch. */
24
+ const ABSENCE_SIGNAL = 'af_runbook_absence';
25
+ /**
26
+ * The control signal an un-survivable inner absence throws through the
27
+ * chart. The engine commits staged state and rethrows (commit-on-error is
28
+ * the law upstream), so the bridge catches this at `executor.run` and
29
+ * returns the absence verbatim.
30
+ */
31
+ export class RunbookAbsenceSignal extends Error {
32
+ absence;
33
+ [ABSENCE_SIGNAL] = true;
34
+ constructor(absence, innerTool) {
35
+ super(`runbook inner tool '${innerTool}' answered with an absence — the runbook's answer ` +
36
+ `IS that absence, passed through verbatim. (Declare the call survivable with ` +
37
+ `{ allowAbsent: true } if the procedure can carry on without this source.)`);
38
+ this.absence = absence;
39
+ this.name = 'RunbookAbsenceSignal';
40
+ }
41
+ }
42
+ /** Recognize the signal on an error OR anywhere down its `cause` chain — an
43
+ * engine layer that wraps the stage's throw must not defeat the pass-through. */
44
+ export function absenceSignalOf(err) {
45
+ let current = err;
46
+ for (let hops = 0; hops < 8 && current !== null && typeof current === 'object'; hops += 1) {
47
+ if (current[ABSENCE_SIGNAL] === true) {
48
+ return current;
49
+ }
50
+ current = current.cause;
51
+ }
52
+ return undefined;
53
+ }
54
+ /**
55
+ * Wrap the delivered dispatch (or its absence) for one runbook invocation.
56
+ *
57
+ * With NO dispatch delivered (`ctx.tools` absent — a hand-built context, a
58
+ * door with no dispatch map) the wrapper is the fail-closed teacher: `has`
59
+ * answers false and `call` refuses naming the fix, so a procedure that needs
60
+ * inner tools fails loudly at its first call instead of half-running.
61
+ */
62
+ export function recordingDispatch(delivered, runbookName) {
63
+ const records = [];
64
+ const tools = {
65
+ has(name) {
66
+ return delivered?.has(name) ?? false;
67
+ },
68
+ async call(name, args, opts) {
69
+ if (delivered === undefined) {
70
+ throw new Error(`runbookAsTool('${runbookName}'): the procedure called tools.call('${name}') but ` +
71
+ `no dispatch was delivered on ctx.tools. Register this runbook on an Agent ` +
72
+ `(agent dispatch delivers ctx.tools at execute time), or supply a ToolDispatch ` +
73
+ `on the execution context when invoking the tool directly.`);
74
+ }
75
+ let raw;
76
+ try {
77
+ raw = await delivered.call(name, args, opts);
78
+ }
79
+ catch (err) {
80
+ records.push({ tool: name, outcome: 'error' });
81
+ throw err;
82
+ }
83
+ const absence = readAbsence(raw);
84
+ if (absence !== undefined) {
85
+ records.push({ tool: name, outcome: 'absent', result: raw });
86
+ if (opts?.allowAbsent === true)
87
+ return raw;
88
+ throw new RunbookAbsenceSignal(absence, name);
89
+ }
90
+ records.push({ tool: name, outcome: 'ok', result: raw });
91
+ return raw;
92
+ },
93
+ };
94
+ return { tools, records };
95
+ }
96
+ /**
97
+ * The definition-time probe dispatch — handed to the procedure factory ONCE
98
+ * at `runbookAsTool(...)` so the bridge can read the chart's declared
99
+ * contract. Stage bodies do not run at build; a factory that calls tools at
100
+ * build time hears exactly why that cannot work.
101
+ */
102
+ export function probeDispatch(runbookName) {
103
+ return {
104
+ has: () => false,
105
+ call: (name) => {
106
+ throw new Error(`runbookAsTool('${runbookName}'): tools.call('${name}') was invoked while BUILDING ` +
107
+ `the chart. The dispatch only exists at execute time — call tools from inside ` +
108
+ `stage functions (which close over it), never from the factory body.`);
109
+ },
110
+ };
111
+ }
112
+ //# sourceMappingURL=dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../../src/core/runbook/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAY1D;0BAC0B;AAC1B,MAAM,cAAc,GAAG,oBAA6B,CAAC;AAErD;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAExB;IADZ,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACjC,YAAqB,OAAoB,EAAE,SAAiB;QAC1D,KAAK,CACH,uBAAuB,SAAS,oDAAoD;YAClF,8EAA8E;YAC9E,2EAA2E,CAC9E,CAAC;QALiB,YAAO,GAAP,OAAO,CAAa;QAMvC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;kFACkF;AAClF,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,IAAI,OAAO,GAAY,GAAG,CAAC;IAC3B,KAAK,IAA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I,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC7D,IAAI,IAAI,EAAE,WAAW,KAAK,IAAI;oBAAE,OAAO,GAAG,CAAC;gBAC3C,MAAM,IAAI,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAChD,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YACzD,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,WAAmB;IAC/C,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK;QAChB,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE;YACrB,MAAM,IAAI,KAAK,CACb,kBAAkB,WAAW,mBAAmB,IAAI,gCAAgC;gBAClF,+EAA+E;gBAC/E,qEAAqE,CACxE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * runbook — the standard bridge from a footprintjs procedure to an Agent
3
+ * tool with the mandatory honesty spine. See README.md in this folder.
4
+ */
5
+ export { runbookAsTool } from './runbookAsTool.js';
6
+ export { absenceSignalOf, probeDispatch, recordingDispatch, RunbookAbsenceSignal, type InnerCallRecord, type RecordedDispatch, } from './dispatch.js';
7
+ export { DECLINED_VERDICT, DEFAULT_MAX_ROWS, renderVerdictTable, VERDICT_RENDER_NOTE, verdictRowsOf, } from './verdicts.js';
8
+ export { DEFAULT_WALK_CAP, projectWalk, type ProjectedWalk, type WalkRow } from './walk.js';
9
+ export type { RunbookAsToolOptions, RunbookEnvelope, RunbookProcedure, RunbookRules, RunbookVerdictsOptions, RunbookWalkOptions, VerdictRow, WalkDescriptor, } from './types.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * runbook — the standard bridge from a footprintjs procedure to an Agent
3
+ * tool with the mandatory honesty spine. See README.md in this folder.
4
+ */
5
+ export { runbookAsTool } from './runbookAsTool.js';
6
+ export { absenceSignalOf, probeDispatch, recordingDispatch, RunbookAbsenceSignal, } from './dispatch.js';
7
+ export { DECLINED_VERDICT, DEFAULT_MAX_ROWS, renderVerdictTable, VERDICT_RENDER_NOTE, verdictRowsOf, } from './verdicts.js';
8
+ export { DEFAULT_WALK_CAP, projectWalk } from './walk.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/runbook/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GAGrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAoC,MAAM,WAAW,CAAC"}