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.
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +126 -0
- package/CLAUDE.md +24 -19
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/artifacts/index.js +3 -1
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/recordingArtifact.js +47 -1
- package/dist/artifacts/recordingArtifact.js.map +1 -1
- package/dist/core/Agent.js +53 -1
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +12 -0
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/evidence/gate.js +22 -3
- package/dist/core/agent/evidence/gate.js.map +1 -1
- package/dist/core/agent/stagedRefs.js +161 -0
- package/dist/core/agent/stagedRefs.js.map +1 -0
- package/dist/core/agent/stages/callLLM.js +22 -2
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/evidenceRecheck.js +21 -2
- package/dist/core/agent/stages/evidenceRecheck.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +42 -0
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/agent/toolDispatch.js +101 -0
- package/dist/core/agent/toolDispatch.js.map +1 -0
- package/dist/core/flowchartAsTool.js +9 -2
- package/dist/core/flowchartAsTool.js.map +1 -1
- package/dist/core/runbook/coverage.js +162 -0
- package/dist/core/runbook/coverage.js.map +1 -0
- package/dist/core/runbook/dispatch.js +119 -0
- package/dist/core/runbook/dispatch.js.map +1 -0
- package/dist/core/runbook/index.js +24 -0
- package/dist/core/runbook/index.js.map +1 -0
- package/dist/core/runbook/runbookAsTool.js +358 -0
- package/dist/core/runbook/runbookAsTool.js.map +1 -0
- package/dist/core/runbook/types.js +22 -0
- package/dist/core/runbook/types.js.map +1 -0
- package/dist/core/runbook/verdicts.js +156 -0
- package/dist/core/runbook/verdicts.js.map +1 -0
- package/dist/core/runbook/walk.js +115 -0
- package/dist/core/runbook/walk.js.map +1 -0
- package/dist/core/tools.js +55 -1
- package/dist/core/tools.js.map +1 -1
- package/dist/esm/artifacts/index.d.ts +1 -1
- package/dist/esm/artifacts/index.js +1 -1
- package/dist/esm/artifacts/index.js.map +1 -1
- package/dist/esm/artifacts/recordingArtifact.d.ts +36 -0
- package/dist/esm/artifacts/recordingArtifact.js +45 -0
- package/dist/esm/artifacts/recordingArtifact.js.map +1 -1
- package/dist/esm/core/Agent.js +53 -1
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +12 -0
- package/dist/esm/core/agent/AgentBuilder.js +12 -0
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/evidence/gate.d.ts +11 -1
- package/dist/esm/core/agent/evidence/gate.js +22 -3
- package/dist/esm/core/agent/evidence/gate.js.map +1 -1
- package/dist/esm/core/agent/evidence/types.d.ts +23 -0
- package/dist/esm/core/agent/stagedRefs.d.ts +94 -0
- package/dist/esm/core/agent/stagedRefs.js +154 -0
- package/dist/esm/core/agent/stagedRefs.js.map +1 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +17 -0
- package/dist/esm/core/agent/stages/callLLM.js +22 -2
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/evidenceRecheck.d.ts +19 -1
- package/dist/esm/core/agent/stages/evidenceRecheck.js +21 -2
- package/dist/esm/core/agent/stages/evidenceRecheck.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.js +42 -0
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/toolDispatch.d.ts +50 -0
- package/dist/esm/core/agent/toolDispatch.js +97 -0
- package/dist/esm/core/agent/toolDispatch.js.map +1 -0
- package/dist/esm/core/flowchartAsTool.d.ts +6 -0
- package/dist/esm/core/flowchartAsTool.js +9 -2
- package/dist/esm/core/flowchartAsTool.js.map +1 -1
- package/dist/esm/core/runbook/coverage.d.ts +69 -0
- package/dist/esm/core/runbook/coverage.js +155 -0
- package/dist/esm/core/runbook/coverage.js.map +1 -0
- package/dist/esm/core/runbook/dispatch.d.ts +69 -0
- package/dist/esm/core/runbook/dispatch.js +112 -0
- package/dist/esm/core/runbook/dispatch.js.map +1 -0
- package/dist/esm/core/runbook/index.d.ts +9 -0
- package/dist/esm/core/runbook/index.js +9 -0
- package/dist/esm/core/runbook/index.js.map +1 -0
- package/dist/esm/core/runbook/runbookAsTool.d.ts +88 -0
- package/dist/esm/core/runbook/runbookAsTool.js +354 -0
- package/dist/esm/core/runbook/runbookAsTool.js.map +1 -0
- package/dist/esm/core/runbook/types.d.ts +196 -0
- package/dist/esm/core/runbook/types.js +21 -0
- package/dist/esm/core/runbook/types.js.map +1 -0
- package/dist/esm/core/runbook/verdicts.d.ts +78 -0
- package/dist/esm/core/runbook/verdicts.js +148 -0
- package/dist/esm/core/runbook/verdicts.js.map +1 -0
- package/dist/esm/core/runbook/walk.d.ts +72 -0
- package/dist/esm/core/runbook/walk.js +110 -0
- package/dist/esm/core/runbook/walk.js.map +1 -0
- package/dist/esm/core/tools.d.ts +112 -0
- package/dist/esm/core/tools.js +52 -0
- package/dist/esm/core/tools.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +39 -0
- package/dist/esm/events/registry.d.ts +3 -1
- package/dist/esm/events/registry.js +2 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +19 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/mcp/toolExtras.d.ts +8 -0
- package/dist/esm/lib/mcp/toolExtras.js +7 -1
- package/dist/esm/lib/mcp/toolExtras.js.map +1 -1
- package/dist/events/registry.js +2 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/index.js +97 -66
- package/dist/index.js.map +1 -1
- package/dist/lib/mcp/toolExtras.js +6 -0
- package/dist/lib/mcp/toolExtras.js.map +1 -1
- package/dist/types/artifacts/index.d.ts +1 -1
- package/dist/types/artifacts/index.d.ts.map +1 -1
- package/dist/types/artifacts/recordingArtifact.d.ts +36 -0
- package/dist/types/artifacts/recordingArtifact.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +12 -0
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/evidence/gate.d.ts +11 -1
- package/dist/types/core/agent/evidence/gate.d.ts.map +1 -1
- package/dist/types/core/agent/evidence/types.d.ts +23 -0
- package/dist/types/core/agent/evidence/types.d.ts.map +1 -1
- package/dist/types/core/agent/stagedRefs.d.ts +95 -0
- package/dist/types/core/agent/stagedRefs.d.ts.map +1 -0
- package/dist/types/core/agent/stages/callLLM.d.ts +17 -0
- package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/evidenceRecheck.d.ts +19 -1
- package/dist/types/core/agent/stages/evidenceRecheck.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/toolDispatch.d.ts +51 -0
- package/dist/types/core/agent/toolDispatch.d.ts.map +1 -0
- package/dist/types/core/flowchartAsTool.d.ts +6 -0
- package/dist/types/core/flowchartAsTool.d.ts.map +1 -1
- package/dist/types/core/runbook/coverage.d.ts +70 -0
- package/dist/types/core/runbook/coverage.d.ts.map +1 -0
- package/dist/types/core/runbook/dispatch.d.ts +70 -0
- package/dist/types/core/runbook/dispatch.d.ts.map +1 -0
- package/dist/types/core/runbook/index.d.ts +10 -0
- package/dist/types/core/runbook/index.d.ts.map +1 -0
- package/dist/types/core/runbook/runbookAsTool.d.ts +89 -0
- package/dist/types/core/runbook/runbookAsTool.d.ts.map +1 -0
- package/dist/types/core/runbook/types.d.ts +197 -0
- package/dist/types/core/runbook/types.d.ts.map +1 -0
- package/dist/types/core/runbook/verdicts.d.ts +79 -0
- package/dist/types/core/runbook/verdicts.d.ts.map +1 -0
- package/dist/types/core/runbook/walk.d.ts +73 -0
- package/dist/types/core/runbook/walk.d.ts.map +1 -0
- package/dist/types/core/tools.d.ts +112 -0
- package/dist/types/core/tools.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +39 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +3 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/mcp/toolExtras.d.ts +8 -0
- package/dist/types/lib/mcp/toolExtras.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
* (offline, cheap, fast). Set membership over normalized tokens is the entire
|
|
52
52
|
* mechanism, it costs microseconds, and it is the same on every run.
|
|
53
53
|
*/
|
|
54
|
+
import type { StagedRefsMatch } from '../stagedRefs.js';
|
|
54
55
|
import type { EvidenceCorpus } from './evidenceIndex.js';
|
|
55
56
|
import { EVIDENCE_CHECK_FRAME_PREFIX } from './frames.js';
|
|
56
57
|
import type { EvidencePosture, EvidenceVerdict, NamesAndNumbersOptions, ResolvedEvidenceGate, UnsupportedValue } from './types.js';
|
|
@@ -90,8 +91,17 @@ export declare function describeValues(values: readonly UnsupportedValue[]): str
|
|
|
90
91
|
* come first and untrusted text never gets the last line is the same rule the
|
|
91
92
|
* compaction frame and the schema frame follow, and a rule with an exception
|
|
92
93
|
* is not a rule.
|
|
94
|
+
*
|
|
95
|
+
* `stagedRefs` (optional) is the staged-refs join computed by the recheck
|
|
96
|
+
* stage: when this turn holds placed artifact tickets a served `wants` tool
|
|
97
|
+
* can spend, the frame names the refs and the spender by their declared names
|
|
98
|
+
* — "call the tool that provides it" without saying WHICH tool over WHICH ref
|
|
99
|
+
* leaves the model to head-math again. The clause sits INSIDE the authored
|
|
100
|
+
* frame (ref ids and tool names are declarations, not model output), so the
|
|
101
|
+
* quoted values still come last and `isLibraryAuthoredTurn`'s prefix match is
|
|
102
|
+
* untouched.
|
|
93
103
|
*/
|
|
94
|
-
export declare function buildEvidenceCorrection(failedAnswer: string, values: readonly UnsupportedValue[]): readonly [{
|
|
104
|
+
export declare function buildEvidenceCorrection(failedAnswer: string, values: readonly UnsupportedValue[], stagedRefs?: StagedRefsMatch): readonly [{
|
|
95
105
|
role: 'assistant';
|
|
96
106
|
content: string;
|
|
97
107
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/evidence/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EACV,eAAe,EAEf,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAEvC,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAUtC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,sBAA2B,GAAG,oBAAoB,
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/evidence/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EACV,eAAe,EAEf,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAEvC,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAUtC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,sBAA2B,GAAG,oBAAoB,CAuE3F;AAcD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IACJ,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtC,GACA,eAAe,CAajB;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,CAK1E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,SAAS,gBAAgB,EAAE,EACnC,UAAU,CAAC,EAAE,eAAe,GAC3B,SAAS,CAAC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAetF;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,gBAAgB,EAAE,EACnC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,OAAO,GACf,MAAM,CAcR"}
|
|
@@ -73,6 +73,27 @@ export interface NamesAndNumbersOptions {
|
|
|
73
73
|
* positives that follow.
|
|
74
74
|
*/
|
|
75
75
|
readonly minDigits?: number;
|
|
76
|
+
/**
|
|
77
|
+
* The staged-refs nudge. Default `false` — off, byte-identical.
|
|
78
|
+
*
|
|
79
|
+
* When an iteration's context carries tool results staged by reference
|
|
80
|
+
* (`artifacts.placement` tickets) AND a tool the model can currently call
|
|
81
|
+
* declares `wants` over one of their kinds, the library appends ONE short
|
|
82
|
+
* line at the END of that request naming the refs and the spender tool:
|
|
83
|
+
* derived numbers come from the tool, not from mental arithmetic. Composed
|
|
84
|
+
* entirely from declarations (`Tool.resultKind` / `Tool.wants`) — no app
|
|
85
|
+
* prose — and placed late because the measured failure was recency: the
|
|
86
|
+
* app's own "use the compute tool" instruction sat at the top of the
|
|
87
|
+
* context while the numbers sat at the bottom, and the model summed them
|
|
88
|
+
* in its head. The line is request-only (never history) and recomposed per
|
|
89
|
+
* iteration, so it exists exactly while both conditions hold. Each firing
|
|
90
|
+
* lands as `agentfootprint.agent.grounding_nudged`.
|
|
91
|
+
*
|
|
92
|
+
* Advisory — the postures above stay the guarantee. An agent with no
|
|
93
|
+
* artifact placement or no `wants`-declaring tool arms nothing and keeps
|
|
94
|
+
* byte-identical requests.
|
|
95
|
+
*/
|
|
96
|
+
readonly nudge?: boolean;
|
|
76
97
|
}
|
|
77
98
|
/** One value in the answer that no tool result carried. */
|
|
78
99
|
export interface UnsupportedValue {
|
|
@@ -99,6 +120,8 @@ export interface ResolvedEvidenceGate {
|
|
|
99
120
|
readonly exemptValues: ReadonlySet<string>;
|
|
100
121
|
readonly exemptPatterns: readonly RegExp[];
|
|
101
122
|
readonly minDigits: number;
|
|
123
|
+
/** The staged-refs nudge dial. `false` is today's bytes. */
|
|
124
|
+
readonly nudge: boolean;
|
|
102
125
|
}
|
|
103
126
|
/** The gate's verdict on one answer. */
|
|
104
127
|
export interface EvidenceVerdict {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/evidence/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,OAA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,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;+CAC2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IAC1C,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClD,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/agent/stagedRefs — the join between data staged BY REFERENCE and the
|
|
3
|
+
* tool declared to spend it, composed into one sentence the model reads.
|
|
4
|
+
*
|
|
5
|
+
* ── The measured failure ────────────────────────────────────────────────────
|
|
6
|
+
* A traced production run: four tool results carried real numbers, a compute
|
|
7
|
+
* tool that could sum them was on the wire, and the app's prompt SAID to use
|
|
8
|
+
* it — yet the model summed the four numbers in its head and stated the total.
|
|
9
|
+
* The evidence gate recorded the truth ("appears in no tool result") and the
|
|
10
|
+
* answer shipped anyway, because the posture only observed. The prose
|
|
11
|
+
* instruction sat at the top of a long context; the numbers sat at the bottom.
|
|
12
|
+
* Recency won.
|
|
13
|
+
*
|
|
14
|
+
* ── The intervention: say it LATE, from DECLARATIONS ────────────────────────
|
|
15
|
+
* The library already holds both halves of the fix as data, no prose surface
|
|
16
|
+
* needed:
|
|
17
|
+
*
|
|
18
|
+
* • a placed tool result (`artifacts.placement` / `Tool.resultKind`) is a
|
|
19
|
+
* ticket in the conversation — `{ placed: true, ref, kind, … }` — naming
|
|
20
|
+
* data staged by reference;
|
|
21
|
+
* • a tool's `wants` (`{ arg: 'dataset/rows' }`) is the DECLARED promise
|
|
22
|
+
* that it spends refs of exactly that kind — matched by the same
|
|
23
|
+
* exact-string law the dispatch matcher uses, never by tool name.
|
|
24
|
+
*
|
|
25
|
+
* When both hold in one iteration, this module composes ONE short line naming
|
|
26
|
+
* the refs and the spender tool, placed at the END of the request — beside the
|
|
27
|
+
* data, where recency works for the instruction instead of against it. The
|
|
28
|
+
* line is ephemeral (request assembly only, never history) and recomposed
|
|
29
|
+
* each iteration, so it exists exactly while both conditions hold.
|
|
30
|
+
*
|
|
31
|
+
* The same join feeds the evidence correction: a revision that says "call the
|
|
32
|
+
* tool that provides it" without naming WHICH tool over WHICH ref leaves the
|
|
33
|
+
* model to head-math again.
|
|
34
|
+
*
|
|
35
|
+
* Pure functions, no scope, no events — the callers own delivery and record.
|
|
36
|
+
*/
|
|
37
|
+
import type { LLMMessage } from '../../adapters/types.js';
|
|
38
|
+
import type { Tool } from '../tools.js';
|
|
39
|
+
/** One staged parcel a spender tool could be handed. */
|
|
40
|
+
export interface StagedRef {
|
|
41
|
+
/** The artifact ref, verbatim — what the model passes as the argument. */
|
|
42
|
+
readonly ref: string;
|
|
43
|
+
/** The minted kind — the exact string a `wants` declaration matched. */
|
|
44
|
+
readonly kind: string;
|
|
45
|
+
}
|
|
46
|
+
/** The join: which refs are in this iteration's context, and which served
|
|
47
|
+
* tools declared `wants` over their kinds. Both lists are non-empty. */
|
|
48
|
+
export interface StagedRefsMatch {
|
|
49
|
+
/** Distinct matched refs, oldest first, capped at {@link MAX_NUDGE_REFS}. */
|
|
50
|
+
readonly refs: readonly StagedRef[];
|
|
51
|
+
/** Matched refs beyond the cap — stated rather than silently dropped. */
|
|
52
|
+
readonly refsOmitted: number;
|
|
53
|
+
/** The spender tools' REGISTERED names, capped at {@link MAX_NUDGE_TOOLS}. */
|
|
54
|
+
readonly tools: readonly string[];
|
|
55
|
+
}
|
|
56
|
+
/** Most refs one nudge line names. Bounded so a fan-out that staged fifty
|
|
57
|
+
* parcels cannot turn the one-line nudge into a page. */
|
|
58
|
+
export declare const MAX_NUDGE_REFS = 6;
|
|
59
|
+
/** Most spender tools one nudge line names. */
|
|
60
|
+
export declare const MAX_NUDGE_TOOLS = 3;
|
|
61
|
+
/**
|
|
62
|
+
* Harvest `Tool.wants` from the declared catalog — the `toolGrounding`
|
|
63
|
+
* harvest verbatim, and with the same caveat: ToolProvider-DELIVERED tools
|
|
64
|
+
* are invisible here (`list(ctx)` is opaque and per-iteration), so a provider
|
|
65
|
+
* tool declaring `wants` arms nothing. The runtime check stays correctly
|
|
66
|
+
* scoped on its own: the join below intersects this map with the tools the
|
|
67
|
+
* current call actually serves.
|
|
68
|
+
*/
|
|
69
|
+
export declare function toolWantsOf(registryByName: ReadonlyMap<string, Tool>): ReadonlyMap<string, readonly string[]>;
|
|
70
|
+
/**
|
|
71
|
+
* The join itself: scan the conversation for placed tickets whose `kind` a
|
|
72
|
+
* currently-served `wants` tool declares, by the exact-string law the
|
|
73
|
+
* dispatch matcher uses. Returns `undefined` unless BOTH sides hold — no
|
|
74
|
+
* staged ref, or no served spender for any staged kind, means no match and
|
|
75
|
+
* the caller composes nothing.
|
|
76
|
+
*
|
|
77
|
+
* A `role: 'tool'` message carrying a placed result holds the ticket as JSON
|
|
78
|
+
* (`placedToolResult` is what wrote it); anything that does not parse to the
|
|
79
|
+
* ticket shape is an ordinary result and is skipped without a sound.
|
|
80
|
+
*/
|
|
81
|
+
export declare function findStagedRefs(messages: readonly LLMMessage[], toolWants: ReadonlyMap<string, readonly string[]>, servedToolNames: ReadonlySet<string>): StagedRefsMatch | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* The one late-positioned line (`nudge: true` on
|
|
84
|
+
* `.namesAndNumbersFromEvidence()`). Appended at request assembly as the LAST
|
|
85
|
+
* message of the iteration — never written to history — so the direction sits
|
|
86
|
+
* beside the data instead of a thousand tokens above it.
|
|
87
|
+
*/
|
|
88
|
+
export declare function stagedRefsNudgeLine(match: StagedRefsMatch): string;
|
|
89
|
+
/**
|
|
90
|
+
* The refs sentence the evidence CORRECTION carries when the join holds at
|
|
91
|
+
* recheck time (see `buildEvidenceCorrection`) — the same facts, spoken
|
|
92
|
+
* inside the authored frame so the untrusted values still come last.
|
|
93
|
+
*/
|
|
94
|
+
export declare function stagedRefsTeachingClause(match: StagedRefsMatch): string;
|
|
95
|
+
//# sourceMappingURL=stagedRefs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stagedRefs.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/stagedRefs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,wDAAwD;AACxD,MAAM,WAAW,SAAS;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;yEACyE;AACzE,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAC;IACpC,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;0DAC0D;AAC1D,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,+CAA+C;AAC/C,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,GACxC,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAQxC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EACjD,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,eAAe,GAAG,SAAS,CAoC7B;AAaD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAOlE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAMvE"}
|
|
@@ -68,6 +68,23 @@ export interface CallLLMStageDeps {
|
|
|
68
68
|
* label. Absent → the corpus is exactly what it always was.
|
|
69
69
|
*/
|
|
70
70
|
readonly externalGrounds?: () => readonly ExternalGround[];
|
|
71
|
+
/**
|
|
72
|
+
* The staged-refs nudge's harvest (`.namesAndNumbersFromEvidence({ nudge:
|
|
73
|
+
* true })`) — `Tool.wants` by tool name, present ONLY when the dial is on
|
|
74
|
+
* AND at least one registered tool declares `wants`; absent → this stage
|
|
75
|
+
* reads nothing new and every request keeps its exact bytes.
|
|
76
|
+
*
|
|
77
|
+
* When present, an iteration whose conversation holds placed artifact
|
|
78
|
+
* tickets a currently-served spender can consume gets ONE extra `role:
|
|
79
|
+
* 'user'` line appended at request assembly — never written to history —
|
|
80
|
+
* naming the refs and the spender: derived numbers come from the tool, not
|
|
81
|
+
* from mental arithmetic. Appended HERE for the wrap-up's reason (this is
|
|
82
|
+
* the one seam that decides what goes on the wire) and at the END for the
|
|
83
|
+
* measured reason: the failure this closes was recency — the app's own
|
|
84
|
+
* "use the compute tool" prose sat at the top of the context, the numbers
|
|
85
|
+
* at the bottom, and the model summed them in its head.
|
|
86
|
+
*/
|
|
87
|
+
readonly toolWants?: ReadonlyMap<string, readonly string[]>;
|
|
71
88
|
/**
|
|
72
89
|
* The per-run disposition ledger, by REFERENCE (9.60.0) — plumbing shared
|
|
73
90
|
* through the build closure like ProviderToolCache, never scope state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callLLM.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/callLLM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAEV,WAAW,EAGX,aAAa,EACb,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI1E,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"callLLM.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/callLLM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAEV,WAAW,EAGX,aAAa,EACb,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI1E,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kDAAkD,C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,0CAA0C,EAAE,iBAAiB,GAAG,SAAS,CAAC;KAC3F,CAAC;IACF;;;;;uBAKmB;IACnB,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IACzC;;;;;;oCAMgC;IAChC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1D;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IACpC;;yDAEqD;IACrD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAC;IACzD;;;;;;OAMG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,GACrB,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CA+hBlD"}
|
|
@@ -24,9 +24,27 @@
|
|
|
24
24
|
import type { TypedScope } from 'footprintjs';
|
|
25
25
|
import type { ResolvedEvidenceGate } from '../evidence/types.js';
|
|
26
26
|
import type { AgentState } from '../types.js';
|
|
27
|
+
/**
|
|
28
|
+
* The staged-refs join's build-time half, threaded only when at least one
|
|
29
|
+
* registered tool declares `wants` (the `toolGrounding` law: absent means the
|
|
30
|
+
* stage reads no new scope key and the correction keeps its exact bytes).
|
|
31
|
+
*/
|
|
32
|
+
export interface EvidenceStagedRefsDeps {
|
|
33
|
+
/** Harvested `Tool.wants` — tool name → the kinds it spends. */
|
|
34
|
+
readonly toolWants: ReadonlyMap<string, readonly string[]>;
|
|
35
|
+
/** The static tool-schema names, late-bound (the `toolSchemas` getter
|
|
36
|
+
* pattern) — the fallback before the tools slot has written
|
|
37
|
+
* `dynamicToolSchemas`. */
|
|
38
|
+
readonly staticToolNames: () => readonly string[];
|
|
39
|
+
}
|
|
27
40
|
/**
|
|
28
41
|
* Build the recheck stage. The decider already found the values and wrote the
|
|
29
42
|
* carrier immediately before routing here — this stage does the work of asking.
|
|
43
|
+
*
|
|
44
|
+
* `stagedRefs` (optional): when this turn holds placed artifact tickets a
|
|
45
|
+
* currently-served `wants` tool can spend, the correction names the refs and
|
|
46
|
+
* the spender tool — the route to a grounded number, not just the demand for
|
|
47
|
+
* one. The revision-asked event carries the same facts, additively.
|
|
30
48
|
*/
|
|
31
|
-
export declare function buildEvidenceRecheckStage(gate: ResolvedEvidenceGate): (scope: TypedScope<AgentState>) => void;
|
|
49
|
+
export declare function buildEvidenceRecheckStage(gate: ResolvedEvidenceGate, stagedRefs?: EvidenceStagedRefsDeps): (scope: TypedScope<AgentState>) => void;
|
|
32
50
|
//# sourceMappingURL=evidenceRecheck.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evidenceRecheck.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/evidenceRecheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"evidenceRecheck.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/evidenceRecheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,sBAAsB,CAAC;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC3D;;gCAE4B;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;CACnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,oBAAoB,EAC1B,UAAU,CAAC,EAAE,sBAAsB,GAClC,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAkFzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolCalls.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/toolCalls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AASpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAQjF,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG9F,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAQ9E,OAAO,EAIL,KAAK,qBAAqB,EAG3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"toolCalls.d.ts","sourceRoot":"","sources":["../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;;;;OAYG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC,MAAM,EAAE;QAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,KAAK,IAAI,CAAC;IACX;;;;;;;OAOG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D;AAsMD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,oBAAoB,GACzB,eAAe,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAm3GzC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
import type { Tool, ToolDispatch, ToolExecutionContext } from '../tools.js';
|
|
27
|
+
/** What the handler wires in — everything the dispatch cannot know itself. */
|
|
28
|
+
export interface AgentToolDispatchDeps {
|
|
29
|
+
/** Name → Tool over the agent's dispatch map (static + skill-carried).
|
|
30
|
+
* Provider-delivered tools are invisible by construction. */
|
|
31
|
+
readonly lookup: (name: string) => Tool | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Compose the execution context for ONE inner call: the outer call's own
|
|
34
|
+
* facts with `hasArtifacts: false`, a derived `toolCallId` (`seq` makes it
|
|
35
|
+
* unique within the outer call), and NO `tools` of its own.
|
|
36
|
+
*/
|
|
37
|
+
readonly innerContext: (toolName: string, seq: number) => ToolExecutionContext;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build the `ctx.tools` dispatch for one outer tool call.
|
|
41
|
+
*
|
|
42
|
+
* `call` resolves the inner tool's declared `needs` through the inner
|
|
43
|
+
* context's own credential provider (fail-closed — the provider throws its
|
|
44
|
+
* teaching refusal when none is attached), refuses the shapes an inner call
|
|
45
|
+
* cannot honor (see the module header), executes, and returns the result
|
|
46
|
+
* exactly as the tool returned it. Policy about what a result MEANS — an
|
|
47
|
+
* absence that should short-circuit, a coverage ledger that should fold —
|
|
48
|
+
* belongs to the consumer wrapping this dispatch, never here.
|
|
49
|
+
*/
|
|
50
|
+
export declare function agentToolDispatch(deps: AgentToolDispatchDeps): ToolDispatch;
|
|
51
|
+
//# sourceMappingURL=toolDispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolDispatch.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/toolDispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EACV,IAAI,EACJ,YAAY,EAEZ,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,8EAA8E;AAC9E,MAAM,WAAW,qBAAqB;IACpC;kEAC8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAC;IACpD;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,oBAAoB,CAAC;CAChF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,YAAY,CA4C3E"}
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowchartAsTool.d.ts","sourceRoot":"","sources":["../../../src/core/flowchartAsTool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"flowchartAsTool.d.ts","sourceRoot":"","sources":["../../../src/core/flowchartAsTool.ts"],"names":[],"mappings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IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAsJlE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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;
|
|
70
|
+
//# sourceMappingURL=coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,SAAS,YAAY,EAAE,CAAC;CAC/C;AAID,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,GAAG,WAAW,CAkBlF;AAwBD;;yDAEyD;AACzD,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,WAAW,CASrF;AAED,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,gEAAgE;IAChE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;sCACsC;AACtC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/C,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAOD;;0BAE0B;AAC1B,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,WAAW,GACjB,cAAc,CA8ChB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAerC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 {};
|
|
70
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,aAAa,CAAC;AAEzE,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC5C,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;0BAC0B;AAC1B,QAAA,MAAM,cAAc,sBAAgC,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAEjC,QAAQ,CAAC,OAAO,EAAE,WAAW;IADzC,QAAQ,CAAC,CAAC,cAAc,CAAC,QAAQ;gBACZ,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM;CAQ7D;AAED;kFACkF;AAClF,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAS9E;AAED;+CAC+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,YAAY,GAAG,SAAS,EACnC,WAAW,EAAE,MAAM,GAClB,gBAAgB,CAiClB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAW/D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","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,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,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,EAAE,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAC5F,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runbookAsTool — turn a written operational procedure into a tool whose
|
|
3
|
+
* every answer is EVIDENCE: who decided what, against which threshold, on
|
|
4
|
+
* which rule version, with the recorded walk to check it against.
|
|
5
|
+
*
|
|
6
|
+
* The standard bridge from a footprintjs chart to the Agent's tool surface.
|
|
7
|
+
* Where `flowchartAsTool` returns bare `JSON.stringify(values)`,
|
|
8
|
+
* runbookAsTool supplies the missing middle — the honesty envelope every
|
|
9
|
+
* hand-rolled triage tool was building for itself:
|
|
10
|
+
*
|
|
11
|
+
* THE MANDATORY SPINE (every runbook, whatever its shape):
|
|
12
|
+
* - `af_coverage` — the three-list ledger, with every INNER tool's own
|
|
13
|
+
* ledger folded upward through the run's dispatch, plus the sentence
|
|
14
|
+
* naming the rule set and version;
|
|
15
|
+
* - `result.af_provenance` — re-emitted FIRST (a carried `LOCAL SEED`
|
|
16
|
+
* confession survives composition);
|
|
17
|
+
* - `result.rule_version` — the declared rules' version, or the honest
|
|
18
|
+
* `'undeclared'`;
|
|
19
|
+
* - `result.walk` — the recorded walk's descriptor. The walk itself
|
|
20
|
+
* ships as an artifact ticket (kind `recording/chart-walk`), never as
|
|
21
|
+
* bytes; when it does not fit, the CONTROL FLOW survives and the
|
|
22
|
+
* projection is declared.
|
|
23
|
+
*
|
|
24
|
+
* THE OPTIONAL PROJECTION (selected by `resultKind: 'verdict/*'`):
|
|
25
|
+
* verdict rows off the chart's `verdicts` state key, capped with
|
|
26
|
+
* truthful counters, a pre-rendered table over the SAME rows, and
|
|
27
|
+
* `verdict_meanings` GENERATED from the decider's declared branches +
|
|
28
|
+
* the rule labels this run's decide() evidence carried.
|
|
29
|
+
*
|
|
30
|
+
* THREE OUTCOMES, honestly: a clean envelope; an inner ABSENCE passed
|
|
31
|
+
* through verbatim (the framework still reads it as an absence); and
|
|
32
|
+
* DECLINED rows counted into the ledger as not-checked ground.
|
|
33
|
+
*
|
|
34
|
+
* The procedure is a FACTORY invoked per call with the run's own tool
|
|
35
|
+
* dispatch (`ctx.tools`) — fresh chart every run, stages close over the
|
|
36
|
+
* dispatch, and every inner tool's honesty ledger folds into this tool's
|
|
37
|
+
* answer.
|
|
38
|
+
*
|
|
39
|
+
* Reserved state keys the bridge reads off the final scope:
|
|
40
|
+
* - `verdicts` — the rowset (verdict projection only);
|
|
41
|
+
* - `coverage` — chart-declared coverage entries (`{checked?, not_checked?,
|
|
42
|
+
* cannot_cover?}`);
|
|
43
|
+
* - `report` — the app's own result fields, spread into `result` verbatim
|
|
44
|
+
* (spine keys win).
|
|
45
|
+
*
|
|
46
|
+
* Pause: NOT yet bridged. A paused inner chart throws with the checkpoint
|
|
47
|
+
* attached, exactly like `flowchartAsTool` — the approval-gate integration
|
|
48
|
+
* is the next phase of the runbook program.
|
|
49
|
+
*
|
|
50
|
+
* @example the smallest legal call — still yields the honest spine
|
|
51
|
+
* const tool = runbookAsTool({
|
|
52
|
+
* name: 'restart_check',
|
|
53
|
+
* description: 'Run the restart-safety procedure.',
|
|
54
|
+
* procedure: () =>
|
|
55
|
+
* flowChart<{ safe: boolean }>('restart-safety', (scope) => {
|
|
56
|
+
* scope.safe = true;
|
|
57
|
+
* }, 'check').build(),
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* @example a triage runbook with rules, verdicts, and an inner tool
|
|
61
|
+
* const triage = runbookAsTool({
|
|
62
|
+
* name: 'backup_triage',
|
|
63
|
+
* description: 'Assess backup protection posture for every subject.',
|
|
64
|
+
* resultKind: 'verdict/backup-posture',
|
|
65
|
+
* rules: { name: 'health-signal', version: 'v1' },
|
|
66
|
+
* verdicts: { decider: 'posture' },
|
|
67
|
+
* composedOf: ['backup_inventory'],
|
|
68
|
+
* procedure: (tools) =>
|
|
69
|
+
* flowChart<TriageState>('backup-triage', async (scope) => {
|
|
70
|
+
* const inner = (await tools.call('backup_inventory', {})) as InventoryResult;
|
|
71
|
+
* scope.subjects = inner.result.rows;
|
|
72
|
+
* }, 'inventory')
|
|
73
|
+
* .addDeciderFunction('Posture', postureDecider, 'posture')
|
|
74
|
+
* .addFunctionBranch('protected', 'Protected', landProtected)
|
|
75
|
+
* .addFunctionBranch('unprotected', 'Unprotected', landUnprotected)
|
|
76
|
+
* .end()
|
|
77
|
+
* .build(),
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
80
|
+
import { type Tool } from '../tools.js';
|
|
81
|
+
import type { RunbookAsToolOptions } from './types.js';
|
|
82
|
+
/**
|
|
83
|
+
* Wrap a footprintjs procedure as a `Tool` whose every answer carries the
|
|
84
|
+
* honesty spine. See the module header for the envelope; see
|
|
85
|
+
* {@link RunbookAsToolOptions} for the full options bag. The smallest legal
|
|
86
|
+
* call is `{ name, description, procedure }`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function runbookAsTool(opts: RunbookAsToolOptions): Tool;
|
|
89
|
+
//# sourceMappingURL=runbookAsTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runbookAsTool.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/runbookAsTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AAaH,OAAO,EAAc,KAAK,IAAI,EAA6B,MAAM,aAAa,CAAC;AAQ/E,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,YAAY,CAAC;AAuCpF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAiR9D"}
|