agentfootprint 9.75.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/CHANGELOG.md +64 -0
- package/CLAUDE.md +22 -18
- 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 +30 -0
- package/dist/core/Agent.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 +30 -0
- package/dist/esm/core/Agent.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/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/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/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/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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* runbook/coverage — the spine's ledger: inner folds + chart-declared
|
|
4
|
+
* entries + the bridge's own, and the sentence naming the rules.
|
|
5
|
+
*
|
|
6
|
+
* Pattern: pure fold over three sources, reusing the coverage primitives'
|
|
7
|
+
* own recognizer and merge — no second grammar.
|
|
8
|
+
* Role: core/runbook.
|
|
9
|
+
* Emits: N/A.
|
|
10
|
+
*
|
|
11
|
+
* The three sources, in the order they land:
|
|
12
|
+
* 1. INNER LEDGERS — every recorded inner call's result is read by the
|
|
13
|
+
* same `readCoverageResult` funnel the dispatch loop uses, and its
|
|
14
|
+
* three lists fold upward. An inner tool's honesty is carried, never
|
|
15
|
+
* re-authored.
|
|
16
|
+
* 2. THE CHART'S OWN — the procedure states run-specific coverage by
|
|
17
|
+
* writing a `coverage` state key (`{ checked?, not_checked?,
|
|
18
|
+
* cannot_cover? }`, items as `{what, why?}` bags or bare strings).
|
|
19
|
+
* This is the app's vocabulary (which counters mean "not assessed" is
|
|
20
|
+
* the chart's to know); the ENVELOPE is the bridge's.
|
|
21
|
+
* 3. THE BRIDGE'S OWN — one `checked` entry naming the procedure, its
|
|
22
|
+
* recorded step count and the rule set it ran under; and, for a
|
|
23
|
+
* verdict-shaped runbook, a `not_checked` entry counting DECLINED rows
|
|
24
|
+
* (the three-outcome honesty: a row that reached no classification is
|
|
25
|
+
* ground the answer does not cover).
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.carriedProvenanceOf = exports.composeLedger = exports.chartCoverageOf = exports.foldInnerCoverage = void 0;
|
|
29
|
+
const read_js_1 = require("../agent/coverage/read.js");
|
|
30
|
+
const items_js_1 = require("../agent/coverage/items.js");
|
|
31
|
+
const ledger_js_1 = require("../agent/coverage/ledger.js");
|
|
32
|
+
const EMPTY = { checked: [], notChecked: [], cannotCover: [] };
|
|
33
|
+
/** Fold every recorded inner call's declared coverage upward. */
|
|
34
|
+
function foldInnerCoverage(records) {
|
|
35
|
+
const checked = [];
|
|
36
|
+
const notChecked = [];
|
|
37
|
+
const cannotCover = [];
|
|
38
|
+
for (const record of records) {
|
|
39
|
+
if (record.result === undefined)
|
|
40
|
+
continue;
|
|
41
|
+
const reading = (0, read_js_1.readCoverageResult)(record.result);
|
|
42
|
+
for (const declared of reading?.declared ?? []) {
|
|
43
|
+
checked.push(declared.coverage.checked);
|
|
44
|
+
notChecked.push(declared.coverage.notChecked);
|
|
45
|
+
cannotCover.push(declared.coverage.cannotCover);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
checked: (0, items_js_1.mergeItems)(checked),
|
|
50
|
+
notChecked: (0, items_js_1.mergeItems)(notChecked),
|
|
51
|
+
cannotCover: (0, items_js_1.mergeItems)(cannotCover),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.foldInnerCoverage = foldInnerCoverage;
|
|
55
|
+
/** One list off the chart's `coverage` state key, normalized leniently —
|
|
56
|
+
* this is state the chart wrote, not a foreign wire; a malformed entry is
|
|
57
|
+
* dropped rather than refused (the run already happened). */
|
|
58
|
+
function stateList(value) {
|
|
59
|
+
if (!Array.isArray(value))
|
|
60
|
+
return [];
|
|
61
|
+
const items = [];
|
|
62
|
+
for (const entry of value) {
|
|
63
|
+
if (typeof entry === 'string' && entry.trim() !== '') {
|
|
64
|
+
items.push({ what: entry.trim() });
|
|
65
|
+
}
|
|
66
|
+
else if (entry !== null &&
|
|
67
|
+
typeof entry === 'object' &&
|
|
68
|
+
typeof entry.what === 'string') {
|
|
69
|
+
const what = entry.what;
|
|
70
|
+
const why = entry.why;
|
|
71
|
+
items.push({ what, ...(typeof why === 'string' && { why }) });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return items;
|
|
75
|
+
}
|
|
76
|
+
/** The chart-declared lists, read off the final state's `coverage` key.
|
|
77
|
+
* Accepts both spellings of the two-word keys (state is often snake_case,
|
|
78
|
+
* the declaration camelCase) — one reader, no drift. */
|
|
79
|
+
function chartCoverageOf(state) {
|
|
80
|
+
const bag = state.coverage;
|
|
81
|
+
if (bag === null || typeof bag !== 'object' || Array.isArray(bag))
|
|
82
|
+
return EMPTY;
|
|
83
|
+
const rec = bag;
|
|
84
|
+
return {
|
|
85
|
+
checked: stateList(rec.checked),
|
|
86
|
+
notChecked: stateList(rec.not_checked ?? rec.notChecked),
|
|
87
|
+
cannotCover: stateList(rec.cannot_cover ?? rec.cannotCover),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.chartCoverageOf = chartCoverageOf;
|
|
91
|
+
/** The rules clause every sentence carries — or the honest silence. */
|
|
92
|
+
function rulesClause(rules) {
|
|
93
|
+
return rules !== undefined ? ` under ${rules.name} ${rules.version}` : '';
|
|
94
|
+
}
|
|
95
|
+
/** Compose the whole ledger. Inner folds land first, chart-declared second,
|
|
96
|
+
* the bridge's own last — provenance order, so a reader meets the sources
|
|
97
|
+
* before the summary. */
|
|
98
|
+
function composeLedger(inner, chart, facts) {
|
|
99
|
+
const own = [
|
|
100
|
+
{
|
|
101
|
+
what: `the declared procedure '${facts.chartName}' — ${facts.stepsExecuted} step(s) ` +
|
|
102
|
+
`recorded${rulesClause(facts.rules)}`,
|
|
103
|
+
...(facts.rowsTotal !== undefined && {
|
|
104
|
+
why: `${facts.rowsTotal} row(s) assessed, one decider pass per row`,
|
|
105
|
+
}),
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
const declinedEntries = facts.declinedRows !== undefined && facts.declinedRows > 0
|
|
109
|
+
? [
|
|
110
|
+
{
|
|
111
|
+
what: `${facts.declinedRows} row(s) that reached NO classification (verdict 'declined')`,
|
|
112
|
+
why: 'the declared rules could not be read for them; they are in the rowset with ' +
|
|
113
|
+
'everything that IS known, and nothing was guessed to fill the gap',
|
|
114
|
+
},
|
|
115
|
+
]
|
|
116
|
+
: [];
|
|
117
|
+
const checked = (0, items_js_1.mergeItems)([inner.checked, chart.checked, own]);
|
|
118
|
+
const notChecked = (0, items_js_1.mergeItems)([inner.notChecked, chart.notChecked, declinedEntries]);
|
|
119
|
+
const cannotCover = (0, items_js_1.mergeItems)([inner.cannotCover, chart.cannotCover]);
|
|
120
|
+
const rowsPart = facts.rowsTotal !== undefined
|
|
121
|
+
? `; ${facts.rowsTotal} row(s) assessed` +
|
|
122
|
+
(facts.declinedRows !== undefined && facts.declinedRows > 0
|
|
123
|
+
? `, ${facts.declinedRows} declined (no classification reached)`
|
|
124
|
+
: '')
|
|
125
|
+
: '';
|
|
126
|
+
const gapsPart = notChecked.length > 0 ? `; ${notChecked.length} not-checked item(s) declared` : '';
|
|
127
|
+
const sentence = `Ran '${facts.chartName}'${rulesClause(facts.rules)} — ` +
|
|
128
|
+
`${facts.stepsExecuted} step(s) recorded${rowsPart}${gapsPart}.`;
|
|
129
|
+
return {
|
|
130
|
+
...(checked.length > 0 && { checked }),
|
|
131
|
+
...(notChecked.length > 0 && { not_checked: notChecked }),
|
|
132
|
+
...(cannotCover.length > 0 && { cannot_cover: cannotCover }),
|
|
133
|
+
note: ledger_js_1.COVERAGE_NOTE,
|
|
134
|
+
sentence,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
exports.composeLedger = composeLedger;
|
|
138
|
+
/**
|
|
139
|
+
* The carried provenance stamp: the FIRST inner result that declared an
|
|
140
|
+
* `af_provenance` (on its unwrapped payload, or at its top level — both are
|
|
141
|
+
* read, in that order). A derived answer is still an answer, and a source's
|
|
142
|
+
* confession (`source: 'LOCAL SEED'`) must survive composition.
|
|
143
|
+
*/
|
|
144
|
+
function carriedProvenanceOf(records) {
|
|
145
|
+
const bagOf = (value) => value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
146
|
+
? value
|
|
147
|
+
: undefined;
|
|
148
|
+
for (const record of records) {
|
|
149
|
+
const top = bagOf(record.result);
|
|
150
|
+
if (top === undefined)
|
|
151
|
+
continue;
|
|
152
|
+
const payload = bagOf(top.result);
|
|
153
|
+
for (const candidate of [payload, top]) {
|
|
154
|
+
const stamp = bagOf(candidate?.af_provenance);
|
|
155
|
+
if (stamp !== undefined)
|
|
156
|
+
return stamp;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
exports.carriedProvenanceOf = carriedProvenanceOf;
|
|
162
|
+
//# 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,uDAA+D;AAC/D,yDAAwD;AACxD,2DAA4D;AAY5D,MAAM,KAAK,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AAE5E,iEAAiE;AACjE,SAAgB,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,OAAO,GAAG,IAAA,4BAAkB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAC;YAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC9C,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IACD,OAAO;QACL,OAAO,EAAE,IAAA,qBAAU,EAAC,OAAO,CAAC;QAC5B,UAAU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,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;AAjBD,kDAiBC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* runbook/dispatch — the bridge's wrapper over `ctx.tools`.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: decorator over {@link ToolDispatch}. The RAW dispatch (delivered
|
|
6
|
+
* by the agent) returns every result untouched; POLICY about what a
|
|
7
|
+
* result means belongs to the consumer — and this is the runbook's
|
|
8
|
+
* policy: every inner outcome is RECORDED (for the coverage fold and
|
|
9
|
+
* the provenance carry), and an inner ABSENCE short-circuits the
|
|
10
|
+
* procedure unless the call site declared it survivable.
|
|
11
|
+
* Role: core/runbook, pure.
|
|
12
|
+
* Emits: N/A.
|
|
13
|
+
*
|
|
14
|
+
* WHY an absence short-circuits: "the inventory found nothing" IS the
|
|
15
|
+
* runbook's answer, and it must go back EXACTLY as it arrived so the
|
|
16
|
+
* framework still reads it as an absence — a verdict reached over a source
|
|
17
|
+
* that answered "nothing here" would be the confident-partial-answer failure
|
|
18
|
+
* this whole envelope exists to prevent. A stage that can genuinely carry on
|
|
19
|
+
* without the source says so at the call site (`{ allowAbsent: true }`) and
|
|
20
|
+
* owns stating the gap (usually as a coverage entry).
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.probeDispatch = exports.recordingDispatch = exports.absenceSignalOf = exports.RunbookAbsenceSignal = void 0;
|
|
24
|
+
const absent_js_1 = require("../agent/coverage/absent.js");
|
|
25
|
+
/** The marker property that survives any error wrapping between a stage and
|
|
26
|
+
* the bridge's catch. */
|
|
27
|
+
const ABSENCE_SIGNAL = 'af_runbook_absence';
|
|
28
|
+
/**
|
|
29
|
+
* The control signal an un-survivable inner absence throws through the
|
|
30
|
+
* chart. The engine commits staged state and rethrows (commit-on-error is
|
|
31
|
+
* the law upstream), so the bridge catches this at `executor.run` and
|
|
32
|
+
* returns the absence verbatim.
|
|
33
|
+
*/
|
|
34
|
+
class RunbookAbsenceSignal extends Error {
|
|
35
|
+
absence;
|
|
36
|
+
[ABSENCE_SIGNAL] = true;
|
|
37
|
+
constructor(absence, innerTool) {
|
|
38
|
+
super(`runbook inner tool '${innerTool}' answered with an absence — the runbook's answer ` +
|
|
39
|
+
`IS that absence, passed through verbatim. (Declare the call survivable with ` +
|
|
40
|
+
`{ allowAbsent: true } if the procedure can carry on without this source.)`);
|
|
41
|
+
this.absence = absence;
|
|
42
|
+
this.name = 'RunbookAbsenceSignal';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.RunbookAbsenceSignal = RunbookAbsenceSignal;
|
|
46
|
+
/** Recognize the signal on an error OR anywhere down its `cause` chain — an
|
|
47
|
+
* engine layer that wraps the stage's throw must not defeat the pass-through. */
|
|
48
|
+
function absenceSignalOf(err) {
|
|
49
|
+
let current = err;
|
|
50
|
+
for (let hops = 0; hops < 8 && current !== null && typeof current === 'object'; hops += 1) {
|
|
51
|
+
if (current[ABSENCE_SIGNAL] === true) {
|
|
52
|
+
return current;
|
|
53
|
+
}
|
|
54
|
+
current = current.cause;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
exports.absenceSignalOf = absenceSignalOf;
|
|
59
|
+
/**
|
|
60
|
+
* Wrap the delivered dispatch (or its absence) for one runbook invocation.
|
|
61
|
+
*
|
|
62
|
+
* With NO dispatch delivered (`ctx.tools` absent — a hand-built context, a
|
|
63
|
+
* door with no dispatch map) the wrapper is the fail-closed teacher: `has`
|
|
64
|
+
* answers false and `call` refuses naming the fix, so a procedure that needs
|
|
65
|
+
* inner tools fails loudly at its first call instead of half-running.
|
|
66
|
+
*/
|
|
67
|
+
function recordingDispatch(delivered, runbookName) {
|
|
68
|
+
const records = [];
|
|
69
|
+
const tools = {
|
|
70
|
+
has(name) {
|
|
71
|
+
return delivered?.has(name) ?? false;
|
|
72
|
+
},
|
|
73
|
+
async call(name, args, opts) {
|
|
74
|
+
if (delivered === undefined) {
|
|
75
|
+
throw new Error(`runbookAsTool('${runbookName}'): the procedure called tools.call('${name}') but ` +
|
|
76
|
+
`no dispatch was delivered on ctx.tools. Register this runbook on an Agent ` +
|
|
77
|
+
`(agent dispatch delivers ctx.tools at execute time), or supply a ToolDispatch ` +
|
|
78
|
+
`on the execution context when invoking the tool directly.`);
|
|
79
|
+
}
|
|
80
|
+
let raw;
|
|
81
|
+
try {
|
|
82
|
+
raw = await delivered.call(name, args, opts);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
records.push({ tool: name, outcome: 'error' });
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
const absence = (0, absent_js_1.readAbsence)(raw);
|
|
89
|
+
if (absence !== undefined) {
|
|
90
|
+
records.push({ tool: name, outcome: 'absent', result: raw });
|
|
91
|
+
if (opts?.allowAbsent === true)
|
|
92
|
+
return raw;
|
|
93
|
+
throw new RunbookAbsenceSignal(absence, name);
|
|
94
|
+
}
|
|
95
|
+
records.push({ tool: name, outcome: 'ok', result: raw });
|
|
96
|
+
return raw;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
return { tools, records };
|
|
100
|
+
}
|
|
101
|
+
exports.recordingDispatch = recordingDispatch;
|
|
102
|
+
/**
|
|
103
|
+
* The definition-time probe dispatch — handed to the procedure factory ONCE
|
|
104
|
+
* at `runbookAsTool(...)` so the bridge can read the chart's declared
|
|
105
|
+
* contract. Stage bodies do not run at build; a factory that calls tools at
|
|
106
|
+
* build time hears exactly why that cannot work.
|
|
107
|
+
*/
|
|
108
|
+
function probeDispatch(runbookName) {
|
|
109
|
+
return {
|
|
110
|
+
has: () => false,
|
|
111
|
+
call: (name) => {
|
|
112
|
+
throw new Error(`runbookAsTool('${runbookName}'): tools.call('${name}') was invoked while BUILDING ` +
|
|
113
|
+
`the chart. The dispatch only exists at execute time — call tools from inside ` +
|
|
114
|
+
`stage functions (which close over it), never from the factory body.`);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
exports.probeDispatch = probeDispatch;
|
|
119
|
+
//# 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,2DAA0D;AAY1D;0BAC0B;AAC1B,MAAM,cAAc,GAAG,oBAA6B,CAAC;AAErD;;;;;GAKG;AACH,MAAa,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;AAVD,oDAUC;AAED;kFAC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AAA,uBAAW,EAAC,GAAG,CAAC,CAAC;YACjC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,CAAC,IAAI,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;AApCD,8CAoCC;AAED;;;;;GAKG;AACH,SAAgB,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;AAXD,sCAWC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* runbook — the standard bridge from a footprintjs procedure to an Agent
|
|
4
|
+
* tool with the mandatory honesty spine. See README.md in this folder.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.projectWalk = exports.DEFAULT_WALK_CAP = exports.verdictRowsOf = exports.VERDICT_RENDER_NOTE = exports.renderVerdictTable = exports.DEFAULT_MAX_ROWS = exports.DECLINED_VERDICT = exports.RunbookAbsenceSignal = exports.recordingDispatch = exports.probeDispatch = exports.absenceSignalOf = exports.runbookAsTool = void 0;
|
|
8
|
+
var runbookAsTool_js_1 = require("./runbookAsTool.js");
|
|
9
|
+
Object.defineProperty(exports, "runbookAsTool", { enumerable: true, get: function () { return runbookAsTool_js_1.runbookAsTool; } });
|
|
10
|
+
var dispatch_js_1 = require("./dispatch.js");
|
|
11
|
+
Object.defineProperty(exports, "absenceSignalOf", { enumerable: true, get: function () { return dispatch_js_1.absenceSignalOf; } });
|
|
12
|
+
Object.defineProperty(exports, "probeDispatch", { enumerable: true, get: function () { return dispatch_js_1.probeDispatch; } });
|
|
13
|
+
Object.defineProperty(exports, "recordingDispatch", { enumerable: true, get: function () { return dispatch_js_1.recordingDispatch; } });
|
|
14
|
+
Object.defineProperty(exports, "RunbookAbsenceSignal", { enumerable: true, get: function () { return dispatch_js_1.RunbookAbsenceSignal; } });
|
|
15
|
+
var verdicts_js_1 = require("./verdicts.js");
|
|
16
|
+
Object.defineProperty(exports, "DECLINED_VERDICT", { enumerable: true, get: function () { return verdicts_js_1.DECLINED_VERDICT; } });
|
|
17
|
+
Object.defineProperty(exports, "DEFAULT_MAX_ROWS", { enumerable: true, get: function () { return verdicts_js_1.DEFAULT_MAX_ROWS; } });
|
|
18
|
+
Object.defineProperty(exports, "renderVerdictTable", { enumerable: true, get: function () { return verdicts_js_1.renderVerdictTable; } });
|
|
19
|
+
Object.defineProperty(exports, "VERDICT_RENDER_NOTE", { enumerable: true, get: function () { return verdicts_js_1.VERDICT_RENDER_NOTE; } });
|
|
20
|
+
Object.defineProperty(exports, "verdictRowsOf", { enumerable: true, get: function () { return verdicts_js_1.verdictRowsOf; } });
|
|
21
|
+
var walk_js_1 = require("./walk.js");
|
|
22
|
+
Object.defineProperty(exports, "DEFAULT_WALK_CAP", { enumerable: true, get: function () { return walk_js_1.DEFAULT_WALK_CAP; } });
|
|
23
|
+
Object.defineProperty(exports, "projectWalk", { enumerable: true, get: function () { return walk_js_1.projectWalk; } });
|
|
24
|
+
//# 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,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,6CAOuB;AANrB,8GAAA,eAAe,OAAA;AACf,4GAAA,aAAa,OAAA;AACb,gHAAA,iBAAiB,OAAA;AACjB,mHAAA,oBAAoB,OAAA;AAItB,6CAMuB;AALrB,+GAAA,gBAAgB,OAAA;AAChB,+GAAA,gBAAgB,OAAA;AAChB,iHAAA,kBAAkB,OAAA;AAClB,kHAAA,mBAAmB,OAAA;AACnB,4GAAA,aAAa,OAAA;AAEf,qCAA4F;AAAnF,2GAAA,gBAAgB,OAAA;AAAE,sGAAA,WAAW,OAAA"}
|