pi-background-tasks 2.5.0 → 2.6.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/BACKGROUND-TASKS-INSTRUCTIONS.md +1 -1
- package/README.md +70 -25
- package/TESTING.md +42 -2
- package/TEST_PLAN.md +7 -4
- package/dist/extensions/anthropic-attribution-child.js +4 -0
- package/dist/extensions/anthropic-attribution-child.js.map +1 -0
- package/dist/extensions/anthropic-attribution.js +107 -0
- package/dist/extensions/anthropic-attribution.js.map +1 -0
- package/dist/extensions/background-tasks.js +2 -0
- package/dist/extensions/background-tasks.js.map +1 -0
- package/dist/extensions/delegate-child.js +2 -0
- package/dist/extensions/delegate-child.js.map +1 -0
- package/dist/extensions/fusion-child.js +2 -0
- package/dist/extensions/fusion-child.js.map +1 -0
- package/dist/package.json +5 -0
- package/dist/src/core/anthropic-attribution-path.js +24 -0
- package/dist/src/core/anthropic-attribution-path.js.map +1 -0
- package/dist/src/core/anthropic-attribution.js +2247 -0
- package/dist/src/core/anthropic-attribution.js.map +1 -0
- package/dist/src/core/attested-pi-contract.js +5 -0
- package/dist/src/core/attested-pi-contract.js.map +1 -0
- package/dist/src/core/attested-pi-run.js +749 -0
- package/dist/src/core/attested-pi-run.js.map +1 -0
- package/dist/src/core/canonical-json.js +19 -0
- package/dist/src/core/canonical-json.js.map +1 -0
- package/dist/src/core/common.js +787 -0
- package/dist/src/core/common.js.map +1 -0
- package/dist/src/core/config.js +78 -0
- package/dist/src/core/config.js.map +1 -0
- package/dist/src/core/context/parent-snapshot.js +75 -0
- package/dist/src/core/context/parent-snapshot.js.map +1 -0
- package/dist/src/core/context/token-budget.js +631 -0
- package/dist/src/core/context/token-budget.js.map +1 -0
- package/dist/src/core/context/visible-conversation-v2.js +390 -0
- package/dist/src/core/context/visible-conversation-v2.js.map +1 -0
- package/dist/src/core/delegate/artifacts.js +357 -0
- package/dist/src/core/delegate/artifacts.js.map +1 -0
- package/dist/src/core/delegate/budget.js +266 -0
- package/dist/src/core/delegate/budget.js.map +1 -0
- package/dist/src/core/delegate/facade-contract.js +7 -0
- package/dist/src/core/delegate/facade-contract.js.map +1 -0
- package/dist/src/core/delegate/hook-contract-evidence.json +18 -0
- package/dist/src/core/delegate/hook-contract.js +124 -0
- package/dist/src/core/delegate/hook-contract.js.map +1 -0
- package/dist/src/core/delegate/launch.js +366 -0
- package/dist/src/core/delegate/launch.js.map +1 -0
- package/dist/src/core/delegate/result-package.js +293 -0
- package/dist/src/core/delegate/result-package.js.map +1 -0
- package/dist/src/core/delegate/runner.js +398 -0
- package/dist/src/core/delegate/runner.js.map +1 -0
- package/dist/src/core/delegate/seed.js +334 -0
- package/dist/src/core/delegate/seed.js.map +1 -0
- package/dist/src/core/delegate/types.js +103 -0
- package/dist/src/core/delegate/types.js.map +1 -0
- package/dist/src/core/durable-fs.js +372 -0
- package/dist/src/core/durable-fs.js.map +1 -0
- package/dist/src/core/extension-api.js +382 -0
- package/dist/src/core/extension-api.js.map +1 -0
- package/dist/src/core/fusion/artifacts.js +654 -0
- package/dist/src/core/fusion/artifacts.js.map +1 -0
- package/dist/src/core/fusion/budget.js +949 -0
- package/dist/src/core/fusion/budget.js.map +1 -0
- package/dist/src/core/fusion/child-protocol.js +176 -0
- package/dist/src/core/fusion/child-protocol.js.map +1 -0
- package/dist/src/core/fusion/claude-cache.js +156 -0
- package/dist/src/core/fusion/claude-cache.js.map +1 -0
- package/dist/src/core/fusion/clean-context.js +64 -0
- package/dist/src/core/fusion/clean-context.js.map +1 -0
- package/dist/src/core/fusion/config.js +349 -0
- package/dist/src/core/fusion/config.js.map +1 -0
- package/dist/src/core/fusion/context.js +184 -0
- package/dist/src/core/fusion/context.js.map +1 -0
- package/dist/src/core/fusion/evaluation.js +696 -0
- package/dist/src/core/fusion/evaluation.js.map +1 -0
- package/dist/src/core/fusion/facade-contract.js +3 -0
- package/dist/src/core/fusion/facade-contract.js.map +1 -0
- package/dist/src/core/fusion/orchestrator.js +867 -0
- package/dist/src/core/fusion/orchestrator.js.map +1 -0
- package/dist/src/core/fusion/output-contract.js +27 -0
- package/dist/src/core/fusion/output-contract.js.map +1 -0
- package/dist/src/core/fusion/pi-child.js +1741 -0
- package/dist/src/core/fusion/pi-child.js.map +1 -0
- package/dist/src/core/fusion/prompts.js +260 -0
- package/dist/src/core/fusion/prompts.js.map +1 -0
- package/dist/src/core/fusion/result-package.js +857 -0
- package/dist/src/core/fusion/result-package.js.map +1 -0
- package/dist/src/core/fusion/source-policy.js +259 -0
- package/dist/src/core/fusion/source-policy.js.map +1 -0
- package/dist/src/core/fusion/types.js +207 -0
- package/dist/src/core/fusion/types.js.map +1 -0
- package/dist/src/core/fusion/web-fetch.js +777 -0
- package/dist/src/core/fusion/web-fetch.js.map +1 -0
- package/dist/src/core/fusion/workflows.js +126 -0
- package/dist/src/core/fusion/workflows.js.map +1 -0
- package/dist/src/core/lazy-module.js +181 -0
- package/dist/src/core/lazy-module.js.map +1 -0
- package/dist/src/core/pi-launch.js +431 -0
- package/dist/src/core/pi-launch.js.map +1 -0
- package/dist/src/core/registry.js +3331 -0
- package/dist/src/core/registry.js.map +1 -0
- package/dist/src/core/reload-shell-owner.js +1396 -0
- package/dist/src/core/reload-shell-owner.js.map +1 -0
- package/dist/src/core/shell-policy.js +80 -0
- package/dist/src/core/shell-policy.js.map +1 -0
- package/dist/src/core/task-durable.js +51 -0
- package/dist/src/core/task-durable.js.map +1 -0
- package/dist/src/core/update-check.js +92 -0
- package/dist/src/core/update-check.js.map +1 -0
- package/dist/src/core/windows-taskkill.js +185 -0
- package/dist/src/core/windows-taskkill.js.map +1 -0
- package/dist/src/delegate-child-extension.js +776 -0
- package/dist/src/delegate-child-extension.js.map +1 -0
- package/dist/src/delegate-extension.js +746 -0
- package/dist/src/delegate-extension.js.map +1 -0
- package/dist/src/extension.js +953 -0
- package/dist/src/extension.js.map +1 -0
- package/dist/src/fusion-child-extension.js +760 -0
- package/dist/src/fusion-child-extension.js.map +1 -0
- package/dist/src/fusion-extension.js +1030 -0
- package/dist/src/fusion-extension.js.map +1 -0
- package/dist/src/ui/background-tasks-manager.js +689 -0
- package/dist/src/ui/background-tasks-manager.js.map +1 -0
- package/dist/src/ui/fusion-model-selector.js +277 -0
- package/dist/src/ui/fusion-model-selector.js.map +1 -0
- package/docs/INDEX.md +35 -33
- package/docs/api/eventbus-v1.md +21 -5
- package/docs/choose-a-workflow.md +2 -0
- package/docs/commands/bg-clear.md +3 -3
- package/docs/commands/bg-update.md +3 -3
- package/docs/commands/bg.md +18 -6
- package/docs/commands/claude-cache.md +4 -4
- package/docs/commands/fusion-models.md +49 -4
- package/docs/commands/fusion.md +3 -3
- package/docs/commands/jobs.md +3 -3
- package/docs/commands/kill.md +3 -3
- package/docs/commands/logs.md +3 -3
- package/docs/commands/task-manager.md +5 -5
- package/docs/concepts/completion-delivery.md +6 -2
- package/docs/getting-started.md +7 -1
- package/docs/manifest.json +228 -42
- package/docs/operations/configuration.md +58 -5
- package/docs/operations/releasing.md +4 -2
- package/docs/operations/testing.md +22 -0
- package/docs/operations/troubleshooting.md +6 -2
- package/docs/read-before-edit.md +44 -31
- package/docs/reference/runtime-contracts.md +87 -51
- package/docs/reference/shortcuts-and-dock.md +28 -14
- package/docs/subsystems/anthropic-attribution.md +23 -11
- package/docs/subsystems/attested-pi-runs.md +12 -7
- package/docs/subsystems/background-task-runtime.md +53 -11
- package/docs/subsystems/child-launch-durability-and-safety.md +28 -9
- package/docs/subsystems/delegation.md +16 -3
- package/docs/subsystems/docs-freshness-gate.md +14 -7
- package/docs/subsystems/fusion.md +36 -11
- package/docs/subsystems/host-ui-and-telemetry.md +22 -9
- package/docs/tools/bg_delegate.md +3 -1
- package/docs/tools/bg_kill.md +3 -1
- package/docs/tools/bg_logs.md +3 -1
- package/docs/tools/bg_result.md +5 -3
- package/docs/tools/bg_run.md +31 -5
- package/docs/tools/bg_run_pi_attested.md +3 -1
- package/docs/tools/bg_status.md +3 -1
- package/docs/tools/fusion_investigate.md +3 -1
- package/docs/tools/fusion_reason.md +3 -1
- package/docs/tools/fusion_research.md +3 -1
- package/docs/tools/fusion_validate.md +3 -1
- package/extensions/anthropic-attribution-child.ts +3 -0
- package/extensions/anthropic-attribution.ts +166 -1
- package/package.json +12 -10
- package/src/core/anthropic-attribution-path.ts +5 -4
- package/src/core/anthropic-attribution.ts +293 -113
- package/src/core/attested-pi-contract.ts +4 -0
- package/src/core/attested-pi-run.ts +468 -81
- package/src/core/canonical-json.ts +21 -0
- package/src/core/common.ts +450 -40
- package/src/core/config.ts +121 -0
- package/src/core/context/visible-conversation-v2.ts +3 -6
- package/src/core/delegate/artifacts.ts +13 -9
- package/src/core/delegate/budget.ts +13 -6
- package/src/core/delegate/facade-contract.ts +6 -0
- package/src/core/delegate/result-package.ts +32 -14
- package/src/core/delegate/runner.ts +129 -58
- package/src/core/delegate/seed.ts +5 -7
- package/src/core/durable-fs.ts +178 -30
- package/src/core/extension-api.ts +36 -8
- package/src/core/fusion/artifacts.ts +17 -16
- package/src/core/fusion/clean-context.ts +8 -5
- package/src/core/fusion/config.ts +2 -1
- package/src/core/fusion/context.ts +2 -6
- package/src/core/fusion/facade-contract.ts +2 -0
- package/src/core/fusion/orchestrator.ts +3 -3
- package/src/core/fusion/prompts.ts +1 -1
- package/src/core/fusion/result-package.ts +259 -72
- package/src/core/fusion/source-policy.ts +43 -17
- package/src/core/lazy-module.ts +215 -0
- package/src/core/pi-launch.ts +390 -65
- package/src/core/registry.ts +2010 -381
- package/src/core/reload-shell-owner.ts +1662 -0
- package/src/core/shell-policy.ts +134 -0
- package/src/core/task-durable.ts +67 -0
- package/src/delegate-extension.ts +404 -144
- package/src/extension.ts +387 -114
- package/src/fusion-extension.ts +202 -96
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
export const FUSION_MODEL_CONFIG_SCHEMA_VERSION = 'pi-background-tasks.fusion-models.v1';
|
|
2
|
+
export const FUSION_LEGACY_INPUT_SCHEMA_VERSION = 'pi-background-tasks.fusion-input.v4';
|
|
3
|
+
export const FUSION_INPUT_SCHEMA_VERSION = 'pi-background-tasks.fusion-input.v5';
|
|
4
|
+
export const FUSION_EVALUATION_SCHEMA_VERSION = 'pi-background-tasks.fusion-evaluation.v1';
|
|
5
|
+
export const FUSION_VALIDATE_CANDIDATE_SCHEMA_VERSION = 'pi-background-tasks.fusion-validation-candidate.v1';
|
|
6
|
+
export const FUSION_LEGACY_RESULT_SCHEMA_VERSION = 'pi-background-tasks.fusion-result.v4';
|
|
7
|
+
export const FUSION_RESULT_SCHEMA_VERSION = 'pi-background-tasks.fusion-result.v5';
|
|
8
|
+
export const FUSION_COMMITTED_RESULT_SCHEMA_VERSION = 'pi-background-tasks.fusion-committed-result.v1';
|
|
9
|
+
export const FUSION_LEGACY_MANIFEST_SCHEMA_VERSION = 'pi-background-tasks.fusion-manifest.v3';
|
|
10
|
+
export const FUSION_MANIFEST_SCHEMA_VERSION = 'pi-background-tasks.fusion-manifest.v4';
|
|
11
|
+
export const FUSION_CONTEXT_LEDGER_SCHEMA_VERSION = 'pi-background-tasks.fusion-context-ledger.v2';
|
|
12
|
+
export const FUSION_SOURCE_POLICY_SCHEMA_VERSION = 'pi-background-tasks.fusion-source-policy.v1';
|
|
13
|
+
export const FUSION_BUDGET_PLAN_SCHEMA_VERSION = 'pi-background-tasks.fusion-budget-plan.v4';
|
|
14
|
+
export const FUSION_CALIBRATION_VIOLATION_SCHEMA_VERSION = 'pi-background-tasks.fusion-calibration-violation.v2';
|
|
15
|
+
export const FUSION_VALIDATE_CANDIDATE_CONTRACT_EVENT_SCHEMA_VERSION = 'pi-background-tasks.fusion-validation-candidate-contract-event.v1';
|
|
16
|
+
export const FUSION_TOOL_CALL_LOG_SCHEMA_VERSION = 'pi-background-tasks.fusion-tool-call.v1';
|
|
17
|
+
export const FUSION_FAILURE_SUMMARY_SCHEMA_VERSION = 'pi-background-tasks.fusion-failure-summary.v1';
|
|
18
|
+
/**
|
|
19
|
+
* Conversation-projection transform shared by every Fusion entry point.
|
|
20
|
+
*
|
|
21
|
+
* The transform keeps visible user/assistant conversational text verbatim and
|
|
22
|
+
* replaces assistant thinking plus all tool traffic with deterministic,
|
|
23
|
+
* hash-accounted omission receipts. It never truncates retained text and never
|
|
24
|
+
* forwards raw image bytes.
|
|
25
|
+
*/
|
|
26
|
+
export const FUSION_CONTEXT_TRANSFORM_ID = 'visible-conversation-ledger-v2';
|
|
27
|
+
export const FUSION_BRANCH_FILTER_ID = 'exclude-active-fusion-subtree-v1';
|
|
28
|
+
/** Entry-point specific context policies. Both use the same payload-exclusion transform. */
|
|
29
|
+
export const FUSION_TOOL_CONTEXT_POLICY_ID = 'fusion-tool-explicit-v2';
|
|
30
|
+
export const FUSION_COMMAND_CONTEXT_POLICY_ID = 'fusion-command-conversation-v2';
|
|
31
|
+
export const FUSION_IMAGE_OMISSION_PREFIX = '[Image omitted from fusion text transcript: ';
|
|
32
|
+
export const FUSION_CANDIDATE_IDS = ['A', 'B', 'C'];
|
|
33
|
+
export const FUSION_STAGE_VALUES = ['candidate', 'evaluation', 'merge'];
|
|
34
|
+
export const FUSION_CAPABILITY_VALUES = Object.freeze(['reason', 'inspect', 'research']);
|
|
35
|
+
/** No-tools capability for reason candidates, evaluator, repair, and merger. */
|
|
36
|
+
export const FUSION_NO_TOOLS_CAPABILITY = 'reason';
|
|
37
|
+
/** Legacy default retained for old type imports only. New workflows never default. */
|
|
38
|
+
export const FUSION_BRAINSTORM_DEFAULT_CAPABILITY = 'inspect';
|
|
39
|
+
/** @deprecated New v5 workflows have no caller capability default. */
|
|
40
|
+
export const FUSION_DEFAULT_CAPABILITY = FUSION_BRAINSTORM_DEFAULT_CAPABILITY;
|
|
41
|
+
export const FUSION_WEB_FETCH_TOOL_NAME = 'fusion_web_fetch';
|
|
42
|
+
export const FUSION_INSPECT_TOOLS = Object.freeze(['read', 'grep', 'find', 'ls']);
|
|
43
|
+
export const FUSION_RESEARCH_TOOLS = Object.freeze([
|
|
44
|
+
'read',
|
|
45
|
+
'grep',
|
|
46
|
+
'find',
|
|
47
|
+
'ls',
|
|
48
|
+
FUSION_WEB_FETCH_TOOL_NAME,
|
|
49
|
+
]);
|
|
50
|
+
/**
|
|
51
|
+
* Workflow identities sharing one orchestrator, one context projection, one
|
|
52
|
+
* evaluation schema, and one artifact store. A workflow selects stage framing and
|
|
53
|
+
* capability policy only; it never changes the canonical input schema.
|
|
54
|
+
*/
|
|
55
|
+
export const FUSION_WORKFLOW_IDS = Object.freeze([
|
|
56
|
+
'reason',
|
|
57
|
+
'investigate',
|
|
58
|
+
'research',
|
|
59
|
+
'validate',
|
|
60
|
+
]);
|
|
61
|
+
export const FUSION_PUBLIC_WORKFLOW_NAMES = Object.freeze([
|
|
62
|
+
'fusion_reason',
|
|
63
|
+
'fusion_investigate',
|
|
64
|
+
'fusion_research',
|
|
65
|
+
'fusion_validate',
|
|
66
|
+
]);
|
|
67
|
+
/**
|
|
68
|
+
* The single capability the validate workflow ever runs candidates with.
|
|
69
|
+
*
|
|
70
|
+
* Deliberately separate from the caller-selectable brainstorm default. Although
|
|
71
|
+
* both workflows currently give candidates read-only inspection, validation pins
|
|
72
|
+
* that capability as fixed policy rather than exposing a caller override.
|
|
73
|
+
*/
|
|
74
|
+
export const FUSION_VALIDATE_CAPABILITY = 'inspect';
|
|
75
|
+
export const FUSION_FORBIDDEN_TOOLS = Object.freeze([
|
|
76
|
+
'bash',
|
|
77
|
+
'edit',
|
|
78
|
+
'write',
|
|
79
|
+
'fusion_brainstorm',
|
|
80
|
+
'fusion_reason',
|
|
81
|
+
'fusion_investigate',
|
|
82
|
+
'fusion_research',
|
|
83
|
+
'fusion_validate',
|
|
84
|
+
'bg_delegate',
|
|
85
|
+
'bg_result',
|
|
86
|
+
'bg_run',
|
|
87
|
+
'bg_kill',
|
|
88
|
+
'bg_status',
|
|
89
|
+
'bg_logs',
|
|
90
|
+
'bg_run_pi_attested',
|
|
91
|
+
]);
|
|
92
|
+
/**
|
|
93
|
+
* Prompt-expansion stages guarded by deterministic size accounting. `evaluation`
|
|
94
|
+
* and `evaluation_repair` share the evaluator model but render different prompts.
|
|
95
|
+
*/
|
|
96
|
+
export const FUSION_BUDGET_STAGE_VALUES = [
|
|
97
|
+
'candidate',
|
|
98
|
+
'evaluation',
|
|
99
|
+
'evaluation_repair',
|
|
100
|
+
'merge',
|
|
101
|
+
];
|
|
102
|
+
export const FUSION_SOURCE_VALUES = ['command', 'tool'];
|
|
103
|
+
export const FUSION_STATE_VALUES = [
|
|
104
|
+
'initializing',
|
|
105
|
+
'candidates_running',
|
|
106
|
+
'candidates_complete',
|
|
107
|
+
'evaluating',
|
|
108
|
+
'evaluation_complete',
|
|
109
|
+
'merging',
|
|
110
|
+
'completed',
|
|
111
|
+
'failed',
|
|
112
|
+
'cancelled',
|
|
113
|
+
];
|
|
114
|
+
export const FUSION_NONTERMINAL_STATE_VALUES = [
|
|
115
|
+
'initializing',
|
|
116
|
+
'candidates_running',
|
|
117
|
+
'candidates_complete',
|
|
118
|
+
'evaluating',
|
|
119
|
+
'evaluation_complete',
|
|
120
|
+
'merging',
|
|
121
|
+
];
|
|
122
|
+
export const FUSION_TERMINAL_STATE_VALUES = ['completed', 'failed', 'cancelled'];
|
|
123
|
+
export const FUSION_OMITTED_EVENT_KINDS = [
|
|
124
|
+
'assistant_thinking',
|
|
125
|
+
'tool_call',
|
|
126
|
+
'tool_result_text',
|
|
127
|
+
'tool_result_image',
|
|
128
|
+
];
|
|
129
|
+
const EMPTY_FUSION_COST = Object.freeze({
|
|
130
|
+
input: 0,
|
|
131
|
+
output: 0,
|
|
132
|
+
cacheRead: 0,
|
|
133
|
+
cacheWrite: 0,
|
|
134
|
+
total: 0,
|
|
135
|
+
});
|
|
136
|
+
export const EMPTY_FUSION_USAGE = Object.freeze({
|
|
137
|
+
input: 0,
|
|
138
|
+
output: 0,
|
|
139
|
+
cacheRead: 0,
|
|
140
|
+
cacheWrite: 0,
|
|
141
|
+
totalTokens: 0,
|
|
142
|
+
cost: EMPTY_FUSION_COST,
|
|
143
|
+
});
|
|
144
|
+
export function createEmptyFusionUsage() {
|
|
145
|
+
return cloneFusionUsage(EMPTY_FUSION_USAGE);
|
|
146
|
+
}
|
|
147
|
+
export function cloneFusionUsage(usage) {
|
|
148
|
+
return {
|
|
149
|
+
input: usage.input,
|
|
150
|
+
output: usage.output,
|
|
151
|
+
cacheRead: usage.cacheRead,
|
|
152
|
+
cacheWrite: usage.cacheWrite,
|
|
153
|
+
...(usage.cacheWrite1h === undefined ? {} : { cacheWrite1h: usage.cacheWrite1h }),
|
|
154
|
+
...(usage.reasoning === undefined ? {} : { reasoning: usage.reasoning }),
|
|
155
|
+
totalTokens: usage.totalTokens,
|
|
156
|
+
cost: {
|
|
157
|
+
input: usage.cost.input,
|
|
158
|
+
output: usage.cost.output,
|
|
159
|
+
cacheRead: usage.cost.cacheRead,
|
|
160
|
+
cacheWrite: usage.cost.cacheWrite,
|
|
161
|
+
total: usage.cost.total,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export function addFusionUsage(target, delta) {
|
|
166
|
+
target.input += delta.input;
|
|
167
|
+
target.output += delta.output;
|
|
168
|
+
target.cacheRead += delta.cacheRead;
|
|
169
|
+
target.cacheWrite += delta.cacheWrite;
|
|
170
|
+
if (delta.cacheWrite1h !== undefined) {
|
|
171
|
+
target.cacheWrite1h = (target.cacheWrite1h ?? 0) + delta.cacheWrite1h;
|
|
172
|
+
}
|
|
173
|
+
if (delta.reasoning !== undefined) {
|
|
174
|
+
target.reasoning = (target.reasoning ?? 0) + delta.reasoning;
|
|
175
|
+
}
|
|
176
|
+
target.totalTokens += delta.totalTokens;
|
|
177
|
+
target.cost.input += delta.cost.input;
|
|
178
|
+
target.cost.output += delta.cost.output;
|
|
179
|
+
target.cost.cacheRead += delta.cost.cacheRead;
|
|
180
|
+
target.cost.cacheWrite += delta.cost.cacheWrite;
|
|
181
|
+
target.cost.total += delta.cost.total;
|
|
182
|
+
}
|
|
183
|
+
export class FusionError extends Error {
|
|
184
|
+
code;
|
|
185
|
+
stage;
|
|
186
|
+
slot;
|
|
187
|
+
attempt;
|
|
188
|
+
artifactDir;
|
|
189
|
+
transient;
|
|
190
|
+
childCreated;
|
|
191
|
+
budget;
|
|
192
|
+
runProgress;
|
|
193
|
+
constructor(message, details) {
|
|
194
|
+
super(message);
|
|
195
|
+
this.name = 'FusionError';
|
|
196
|
+
this.code = details.code;
|
|
197
|
+
this.stage = details.stage;
|
|
198
|
+
this.slot = details.slot;
|
|
199
|
+
this.attempt = details.attempt;
|
|
200
|
+
this.artifactDir = details.artifactDir;
|
|
201
|
+
this.transient = details.transient ?? false;
|
|
202
|
+
this.childCreated = details.childCreated ?? true;
|
|
203
|
+
this.budget = details.budget;
|
|
204
|
+
this.runProgress = details.runProgress;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/core/fusion/types.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,kCAAkC,GAAG,sCAAsC,CAAC;AACzF,MAAM,CAAC,MAAM,kCAAkC,GAAG,qCAAqC,CAAC;AACxF,MAAM,CAAC,MAAM,2BAA2B,GAAG,qCAAqC,CAAC;AACjF,MAAM,CAAC,MAAM,gCAAgC,GAAG,0CAA0C,CAAC;AAC3F,MAAM,CAAC,MAAM,wCAAwC,GACnD,oDAAoD,CAAC;AACvD,MAAM,CAAC,MAAM,mCAAmC,GAAG,sCAAsC,CAAC;AAC1F,MAAM,CAAC,MAAM,4BAA4B,GAAG,sCAAsC,CAAC;AACnF,MAAM,CAAC,MAAM,sCAAsC,GACjD,gDAAgD,CAAC;AACnD,MAAM,CAAC,MAAM,qCAAqC,GAAG,wCAAwC,CAAC;AAC9F,MAAM,CAAC,MAAM,8BAA8B,GAAG,wCAAwC,CAAC;AACvF,MAAM,CAAC,MAAM,oCAAoC,GAAG,8C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AC;IAC9C,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;IAChD,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AACxC,CAAC;AA2LD,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IACtB,KAAK,CAA0B;IAC/B,IAAI,CAAwB;IAC5B,OAAO,CAAqB;IAC5B,WAAW,CAAqB;IAChC,SAAS,CAAU;IACnB,YAAY,CAAU;IACtB,MAAM,CAAsC;IAC5C,WAAW,CAAgC;IAEpD,YAAY,OAAe,EAAE,OAA2B;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;CACF","sourcesContent":["import type { Usage } from '@earendil-works/pi-ai';\nimport type {\n EstimateInputTokensResult,\n TokenBudgetByteClassBreakdown,\n TokenBudgetDominantByteClass,\n TokenBudgetFamily,\n TokenBudgetFamilyCalibration,\n TokenBudgetRateSource,\n} from '../context/token-budget.js';\n\nexport type FusionThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n\nexport const FUSION_MODEL_CONFIG_SCHEMA_VERSION = 'pi-background-tasks.fusion-models.v1';\nexport const FUSION_LEGACY_INPUT_SCHEMA_VERSION = 'pi-background-tasks.fusion-input.v4';\nexport const FUSION_INPUT_SCHEMA_VERSION = 'pi-background-tasks.fusion-input.v5';\nexport const FUSION_EVALUATION_SCHEMA_VERSION = 'pi-background-tasks.fusion-evaluation.v1';\nexport const FUSION_VALIDATE_CANDIDATE_SCHEMA_VERSION =\n 'pi-background-tasks.fusion-validation-candidate.v1';\nexport const FUSION_LEGACY_RESULT_SCHEMA_VERSION = 'pi-background-tasks.fusion-result.v4';\nexport const FUSION_RESULT_SCHEMA_VERSION = 'pi-background-tasks.fusion-result.v5';\nexport const FUSION_COMMITTED_RESULT_SCHEMA_VERSION =\n 'pi-background-tasks.fusion-committed-result.v1';\nexport const FUSION_LEGACY_MANIFEST_SCHEMA_VERSION = 'pi-background-tasks.fusion-manifest.v3';\nexport const FUSION_MANIFEST_SCHEMA_VERSION = 'pi-background-tasks.fusion-manifest.v4';\nexport const FUSION_CONTEXT_LEDGER_SCHEMA_VERSION = 'pi-background-tasks.fusion-context-ledger.v2';\nexport const FUSION_SOURCE_POLICY_SCHEMA_VERSION = 'pi-background-tasks.fusion-source-policy.v1';\nexport const FUSION_BUDGET_PLAN_SCHEMA_VERSION = 'pi-background-tasks.fusion-budget-plan.v4';\nexport const FUSION_CALIBRATION_VIOLATION_SCHEMA_VERSION =\n 'pi-background-tasks.fusion-calibration-violation.v2';\nexport const FUSION_VALIDATE_CANDIDATE_CONTRACT_EVENT_SCHEMA_VERSION =\n 'pi-background-tasks.fusion-validation-candidate-contract-event.v1';\nexport const FUSION_TOOL_CALL_LOG_SCHEMA_VERSION = 'pi-background-tasks.fusion-tool-call.v1';\nexport const FUSION_FAILURE_SUMMARY_SCHEMA_VERSION =\n 'pi-background-tasks.fusion-failure-summary.v1';\n\n/**\n * Conversation-projection transform shared by every Fusion entry point.\n *\n * The transform keeps visible user/assistant conversational text verbatim and\n * replaces assistant thinking plus all tool traffic with deterministic,\n * hash-accounted omission receipts. It never truncates retained text and never\n * forwards raw image bytes.\n */\nexport const FUSION_CONTEXT_TRANSFORM_ID = 'visible-conversation-ledger-v2';\nexport const FUSION_BRANCH_FILTER_ID = 'exclude-active-fusion-subtree-v1';\n\n/** Entry-point specific context policies. Both use the same payload-exclusion transform. */\nexport const FUSION_TOOL_CONTEXT_POLICY_ID = 'fusion-tool-explicit-v2';\nexport const FUSION_COMMAND_CONTEXT_POLICY_ID = 'fusion-command-conversation-v2';\n\nexport const FUSION_IMAGE_OMISSION_PREFIX = '[Image omitted from fusion text transcript: ';\n\nexport const FUSION_CANDIDATE_IDS = ['A', 'B', 'C'] as const;\nexport type FusionCandidateId = (typeof FUSION_CANDIDATE_IDS)[number];\n\nexport const FUSION_STAGE_VALUES = ['candidate', 'evaluation', 'merge'] as const;\nexport type FusionStage = (typeof FUSION_STAGE_VALUES)[number];\n\nexport const FUSION_CAPABILITY_VALUES = Object.freeze(['reason', 'inspect', 'research'] as const);\nexport type FusionCapability = (typeof FUSION_CAPABILITY_VALUES)[number];\n\n/** No-tools capability for reason candidates, evaluator, repair, and merger. */\nexport const FUSION_NO_TOOLS_CAPABILITY: FusionCapability = 'reason';\n/** Legacy default retained for old type imports only. New workflows never default. */\nexport const FUSION_BRAINSTORM_DEFAULT_CAPABILITY: FusionCapability = 'inspect';\n/** @deprecated New v5 workflows have no caller capability default. */\nexport const FUSION_DEFAULT_CAPABILITY: FusionCapability = FUSION_BRAINSTORM_DEFAULT_CAPABILITY;\n\nexport const FUSION_WEB_FETCH_TOOL_NAME = 'fusion_web_fetch' as const;\nexport const FUSION_INSPECT_TOOLS = Object.freeze(['read', 'grep', 'find', 'ls'] as const);\nexport const FUSION_RESEARCH_TOOLS = Object.freeze([\n 'read',\n 'grep',\n 'find',\n 'ls',\n FUSION_WEB_FETCH_TOOL_NAME,\n] as const);\n\n/**\n * Workflow identities sharing one orchestrator, one context projection, one\n * evaluation schema, and one artifact store. A workflow selects stage framing and\n * capability policy only; it never changes the canonical input schema.\n */\nexport const FUSION_WORKFLOW_IDS = Object.freeze([\n 'reason',\n 'investigate',\n 'research',\n 'validate',\n] as const);\nexport type FusionWorkflowId = (typeof FUSION_WORKFLOW_IDS)[number];\nexport const FUSION_PUBLIC_WORKFLOW_NAMES = Object.freeze([\n 'fusion_reason',\n 'fusion_investigate',\n 'fusion_research',\n 'fusion_validate',\n] as const);\nexport type FusionPublicWorkflowName = (typeof FUSION_PUBLIC_WORKFLOW_NAMES)[number];\nexport type FusionContextKind = 'session_projection' | 'clean_task';\n\n/**\n * The single capability the validate workflow ever runs candidates with.\n *\n * Deliberately separate from the caller-selectable brainstorm default. Although\n * both workflows currently give candidates read-only inspection, validation pins\n * that capability as fixed policy rather than exposing a caller override.\n */\nexport const FUSION_VALIDATE_CAPABILITY: FusionCapability = 'inspect';\n\nexport const FUSION_FORBIDDEN_TOOLS = Object.freeze([\n 'bash',\n 'edit',\n 'write',\n 'fusion_brainstorm',\n 'fusion_reason',\n 'fusion_investigate',\n 'fusion_research',\n 'fusion_validate',\n 'bg_delegate',\n 'bg_result',\n 'bg_run',\n 'bg_kill',\n 'bg_status',\n 'bg_logs',\n 'bg_run_pi_attested',\n] as const);\n\n/**\n * Prompt-expansion stages guarded by deterministic size accounting. `evaluation`\n * and `evaluation_repair` share the evaluator model but render different prompts.\n */\nexport const FUSION_BUDGET_STAGE_VALUES = [\n 'candidate',\n 'evaluation',\n 'evaluation_repair',\n 'merge',\n] as const;\nexport type FusionBudgetStage = (typeof FUSION_BUDGET_STAGE_VALUES)[number];\n\nexport const FUSION_SOURCE_VALUES = ['command', 'tool'] as const;\nexport type FusionSource = (typeof FUSION_SOURCE_VALUES)[number];\n\nexport const FUSION_STATE_VALUES = [\n 'initializing',\n 'candidates_running',\n 'candidates_complete',\n 'evaluating',\n 'evaluation_complete',\n 'merging',\n 'completed',\n 'failed',\n 'cancelled',\n] as const;\nexport type FusionState = (typeof FUSION_STATE_VALUES)[number];\nexport type FusionTerminalState = Extract<FusionState, 'completed' | 'failed' | 'cancelled'>;\nexport type FusionNonterminalState = Exclude<FusionState, FusionTerminalState>;\n\nexport const FUSION_NONTERMINAL_STATE_VALUES = [\n 'initializing',\n 'candidates_running',\n 'candidates_complete',\n 'evaluating',\n 'evaluation_complete',\n 'merging',\n] as const satisfies readonly FusionNonterminalState[];\n\nexport const FUSION_TERMINAL_STATE_VALUES = ['completed', 'failed', 'cancelled'] as const;\n\nexport type FusionModelSelection = '$current' | string;\n\nexport interface FusionModelConfigV1 {\n schema_version: typeof FUSION_MODEL_CONFIG_SCHEMA_VERSION;\n candidates: readonly [FusionModelSelection, FusionModelSelection, FusionModelSelection];\n evaluator: FusionModelSelection;\n merger: FusionModelSelection;\n}\n\nexport interface FusionModelConfigRevision {\n path: string;\n exists: boolean;\n sha256: string | null;\n}\n\nexport interface LoadedFusionModelConfig {\n config: FusionModelConfigV1;\n revision: FusionModelConfigRevision;\n}\n\nexport interface ResolvedFusionModel {\n selection: string;\n source: 'current' | 'configured';\n provider: string;\n model: string;\n qualifiedId: string;\n thinkingLevel: FusionThinkingLevel;\n contextWindow: number;\n maxOutputTokens: number;\n}\n\nexport interface ResolvedFusionModels {\n candidates: readonly [ResolvedFusionModel, ResolvedFusionModel, ResolvedFusionModel];\n evaluator: ResolvedFusionModel;\n merger: ResolvedFusionModel;\n}\n\nexport type FusionRequestAuthority = 'explicit_text' | 'directive_over_projected_conversation';\n\nexport interface FusionCanonicalRequestV3 {\n /** Entry point that produced this request. */\n source: FusionSource;\n /** How children must weigh `text` against the projected conversation. */\n authority: FusionRequestAuthority;\n /** Verbatim request text. Never clipped, never rewritten. */\n text: string;\n /** Lowercase SHA-256 of the UTF-8 request bytes. */\n sha256: string;\n}\n\nexport const FUSION_OMITTED_EVENT_KINDS = [\n 'assistant_thinking',\n 'tool_call',\n 'tool_result_text',\n 'tool_result_image',\n] as const;\nexport type FusionOmittedEventKind = (typeof FUSION_OMITTED_EVENT_KINDS)[number];\n\n/** One omitted conversation event. Ledger rows never leave the local artifact directory. */\nexport interface FusionOmittedEventRecord {\n index: number;\n source_ordinal: number;\n block_ordinal: number;\n kind: FusionOmittedEventKind;\n payload_bytes: number;\n payload_sha256: string;\n tool_name?: string;\n tool_call_id?: string;\n mime_type?: string;\n}\n\nexport interface FusionOmittedActivityProjectionMapEntry {\n canonical_entry_index: number;\n entry_kind: 'omitted_activity';\n ledger_index_first: number;\n ledger_index_last: number;\n}\n\nexport interface FusionLedgerOnlyImageProjectionMapEntry {\n entry_kind: 'ledger_only_tool_result_image';\n ledger_index_first: number;\n ledger_index_last: number;\n}\n\nexport type FusionContextProjectionMapEntry =\n | FusionOmittedActivityProjectionMapEntry\n | FusionLedgerOnlyImageProjectionMapEntry;\n\nexport interface FusionContextOmissionLedgerV2 {\n schema_version: typeof FUSION_CONTEXT_LEDGER_SCHEMA_VERSION;\n policy_id: string;\n transform: typeof FUSION_CONTEXT_TRANSFORM_ID;\n entries: readonly FusionOmittedEventRecord[];\n projection_map: readonly FusionContextProjectionMapEntry[];\n root_sha256: string;\n}\n\nexport type FusionProjectionTextEntry = [\n tag: 't',\n role: 'u' | 'a',\n sourceOrdinal: number,\n blockOrdinal: number,\n text: string,\n];\n\nexport type FusionProjectionOmissionCounts = [\n assistantThinking: number,\n toolCalls: number,\n toolResults: number,\n];\n\nexport type FusionProjectionOmissionEntry = [\n tag: 'o',\n sourceOrdinalSpan: [first: number, last: number],\n bytes: number,\n counts: FusionProjectionOmissionCounts,\n];\n\nexport type FusionProjectionEntry = FusionProjectionTextEntry | FusionProjectionOmissionEntry;\n\nexport interface FusionContextPolicyDescriptor {\n id: string;\n transform: typeof FUSION_CONTEXT_TRANSFORM_ID;\n version: 2;\n receipt_format: 'omitted_activity.v2';\n user_text: 'verbatim';\n assistant_text: 'verbatim';\n assistant_thinking: 'ledger_only';\n tool_call_arguments: 'ledger_only';\n tool_results: 'ledger_only';\n tool_payload_preview_bytes: 0;\n images: 'marker_or_ledger_only';\n unknown_block_behavior: 'error';\n}\n\nexport interface FusionBranchFilterDescriptor {\n id: typeof FUSION_BRANCH_FILTER_ID;\n tool_name: string;\n tool_call_id: string | null;\n active_tool_call_leaf_excluded: boolean;\n}\n\nexport interface FusionToolCallNameCount {\n name: string;\n calls: number;\n}\n\nexport interface FusionProjectionAccounting {\n message_count: number;\n included_text_entry_count: number;\n included_user_text_bytes: number;\n included_assistant_text_bytes: number;\n included_image_marker_count: number;\n empty_text_block_count: number;\n omitted_run_count: number;\n omitted_event_count: number;\n omitted_thinking_bytes: number;\n omitted_tool_call_count: number;\n omitted_tool_call_argument_bytes: number;\n omitted_tool_result_text_count: number;\n omitted_tool_result_text_bytes: number;\n omitted_tool_result_image_count: number;\n omitted_tool_result_image_bytes: number;\n tool_call_names: readonly FusionToolCallNameCount[];\n ledger_entry_count: number;\n ledger_root_sha256: string;\n omission_receipt_utf8_bytes: number;\n}\n\nexport interface FusionConversationProjectionV4 {\n policy: FusionContextPolicyDescriptor;\n branch_filter: FusionBranchFilterDescriptor;\n entries: readonly FusionProjectionEntry[];\n accounting: FusionProjectionAccounting;\n}\n\nexport type FusionConversationProjectionV3 = FusionConversationProjectionV4;\n\nexport interface FusionDeclaredSourceV1 {\n url: string;\n canonical_url: string;\n purpose: string;\n sha256: string;\n}\n\nexport interface FusionCleanTaskContextV1 {\n kind: 'clean_task';\n policy_id: 'fusion-clean-task-v1';\n declared_sources: readonly FusionDeclaredSourceV1[];\n}\n\nexport interface FusionSessionProjectionContextV1 {\n kind: 'session_projection';\n policy_id: 'fusion-session-projection-v1';\n system_prompt: string;\n conversation_projection: FusionConversationProjectionV4;\n}\n\nexport interface FusionCanonicalInputV5Base {\n schema_version: typeof FUSION_INPUT_SCHEMA_VERSION;\n workflow?: FusionWorkflowId | undefined;\n cwd: string;\n request: FusionCanonicalRequestV3;\n}\n\nexport interface FusionSessionProjectionCanonicalInputV5 extends FusionCanonicalInputV5Base {\n workflow?: FusionWorkflowId | undefined;\n /** @deprecated v4 readability alias. Present only for session-projection inputs at runtime. */\n system_prompt: string;\n /** @deprecated v4 readability alias. Present only for session-projection inputs at runtime. */\n conversation_projection: FusionConversationProjectionV4;\n context?: FusionSessionProjectionContextV1 | undefined;\n}\n\nexport interface FusionCleanTaskCanonicalInputV5 extends FusionCanonicalInputV5Base {\n workflow: Exclude<FusionWorkflowId, 'reason'>;\n context: FusionCleanTaskContextV1;\n}\n\nexport type FusionCanonicalInputV5 =\n | FusionSessionProjectionCanonicalInputV5\n | FusionCleanTaskCanonicalInputV5;\n\n/** Legacy v4 shape retained for frozen golden fixtures/readability only. */\nexport interface FusionCanonicalInputV4 {\n schema_version: typeof FUSION_LEGACY_INPUT_SCHEMA_VERSION;\n cwd: string;\n system_prompt: string;\n request: FusionCanonicalRequestV3;\n conversation_projection: FusionConversationProjectionV4;\n}\n\nexport type FusionCanonicalInputV3 = FusionCanonicalInputV5;\n\nexport interface FusionSourcePolicyV1 {\n schema_version: typeof FUSION_SOURCE_POLICY_SCHEMA_VERSION;\n workflow: 'research';\n cwd: string;\n sources: readonly FusionDeclaredSourceV1[];\n root_sha256: string;\n}\n\nexport interface FusionSourcePolicyArtifactRef extends FusionArtifactRef {\n root_sha256: string;\n}\n\nexport interface CandidateAssessment {\n candidate_id: FusionCandidateId;\n summary: string;\n strengths: readonly string[];\n limitations: readonly string[];\n useful_contributions: readonly string[];\n risks: readonly string[];\n}\n\nexport interface FusionConflictPosition {\n candidate_id: FusionCandidateId;\n position: string;\n}\n\nexport interface FusionConflict {\n topic: string;\n positions: readonly FusionConflictPosition[];\n resolution: string;\n}\n\nexport interface FusionSynthesisContribution {\n candidate_id: FusionCandidateId;\n contribution: string;\n}\n\nexport interface FusionSynthesisPlan {\n must_include: readonly FusionSynthesisContribution[];\n must_resolve: readonly string[];\n must_avoid: readonly string[];\n}\n\nexport type FusionValidationSeverity = 'critical' | 'high' | 'minor';\n\nexport interface FusionValidationFindingRecord {\n id: string;\n candidate_id: FusionCandidateId;\n severity: FusionValidationSeverity;\n location: string;\n evidence: string;\n impact: string;\n summary: string;\n}\n\nexport interface FusionValidationFindingDecision {\n source_id: string;\n disposition: 'include' | 'exclude';\n rationale: string;\n group_id?: string | undefined;\n}\n\nexport interface FusionValidationFindingGroup {\n group_id: string;\n source_ids: readonly string[];\n severity: FusionValidationSeverity;\n location: string;\n evidence: string;\n impact: string;\n summary: string;\n rationale: string;\n}\n\nexport interface FusionValidationFindingAccounting {\n findings: readonly FusionValidationFindingRecord[];\n decisions: readonly FusionValidationFindingDecision[];\n groups: readonly FusionValidationFindingGroup[];\n}\n\nexport interface FusionValidationCandidateReportV1 {\n schema_version: typeof FUSION_VALIDATE_CANDIDATE_SCHEMA_VERSION;\n findings: readonly Omit<FusionValidationFindingRecord, 'id' | 'candidate_id'>[];\n verified: readonly string[];\n limitations: readonly string[];\n}\n\nexport interface FusionEvaluationV1 {\n schema_version: typeof FUSION_EVALUATION_SCHEMA_VERSION;\n candidate_assessments: readonly [CandidateAssessment, CandidateAssessment, CandidateAssessment];\n agreements: readonly string[];\n conflicts: readonly FusionConflict[];\n synthesis_plan: FusionSynthesisPlan;\n validation_accounting?: FusionValidationFindingAccounting | undefined;\n}\n\n/** Exact Pi usage contract used at the child, artifact, and host tool-result boundaries. */\nexport type FusionUsage = Usage;\n\nconst EMPTY_FUSION_COST: Usage['cost'] = Object.freeze({\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n total: 0,\n});\n\nexport const EMPTY_FUSION_USAGE: FusionUsage = Object.freeze({\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: EMPTY_FUSION_COST,\n});\n\nexport function createEmptyFusionUsage(): FusionUsage {\n return cloneFusionUsage(EMPTY_FUSION_USAGE);\n}\n\nexport function cloneFusionUsage(usage: FusionUsage): FusionUsage {\n return {\n input: usage.input,\n output: usage.output,\n cacheRead: usage.cacheRead,\n cacheWrite: usage.cacheWrite,\n ...(usage.cacheWrite1h === undefined ? {} : { cacheWrite1h: usage.cacheWrite1h }),\n ...(usage.reasoning === undefined ? {} : { reasoning: usage.reasoning }),\n totalTokens: usage.totalTokens,\n cost: {\n input: usage.cost.input,\n output: usage.cost.output,\n cacheRead: usage.cost.cacheRead,\n cacheWrite: usage.cost.cacheWrite,\n total: usage.cost.total,\n },\n };\n}\n\nexport function addFusionUsage(target: FusionUsage, delta: FusionUsage): void {\n target.input += delta.input;\n target.output += delta.output;\n target.cacheRead += delta.cacheRead;\n target.cacheWrite += delta.cacheWrite;\n if (delta.cacheWrite1h !== undefined) {\n target.cacheWrite1h = (target.cacheWrite1h ?? 0) + delta.cacheWrite1h;\n }\n if (delta.reasoning !== undefined) {\n target.reasoning = (target.reasoning ?? 0) + delta.reasoning;\n }\n target.totalTokens += delta.totalTokens;\n target.cost.input += delta.cost.input;\n target.cost.output += delta.cost.output;\n target.cost.cacheRead += delta.cost.cacheRead;\n target.cost.cacheWrite += delta.cost.cacheWrite;\n target.cost.total += delta.cost.total;\n}\n\nexport type FusionRunStageProgressStatus = 'not_started' | 'incomplete' | 'completed';\n\nexport interface FusionRunStageProgress {\n status: FusionRunStageProgressStatus;\n attempts_recorded: number;\n children_created: number;\n children_completed: number;\n children_failed: number;\n children_cancelled: number;\n not_started_slots?: number | undefined;\n}\n\nexport interface FusionRunProgress {\n manifest_state: FusionState;\n candidates: FusionRunStageProgress;\n evaluation: FusionRunStageProgress;\n merge: FusionRunStageProgress;\n usage_so_far: FusionUsage;\n}\n\nexport interface FusionResultBudgetDetails {\n policy_id: string;\n calibration_version: string;\n route_table: readonly FusionRouteCapacity[];\n rate_sources: readonly TokenBudgetRateSource[];\n unknown_provider_warnings: readonly string[];\n calibration_warnings: readonly FusionCalibrationViolation[];\n}\n\nexport interface FusionCommittedResultV1 {\n schema_version: typeof FUSION_COMMITTED_RESULT_SCHEMA_VERSION;\n run_id: string;\n merged: FusionArtifactRef;\n details: FusionResultDetails;\n}\n\nexport interface FusionResultDetails {\n schema_version: typeof FUSION_RESULT_SCHEMA_VERSION;\n run_id: string;\n workflow: FusionWorkflowId;\n source: FusionSource;\n status: 'completed';\n context: { kind: FusionContextKind; policy_id: string };\n tool_policy: {\n candidate_tools: readonly string[];\n evaluation_tools: readonly [];\n merge_tools: readonly [];\n };\n artifact_dir: string;\n models: {\n candidates: readonly [string, string, string];\n evaluator: string;\n merger: string;\n thinking_level: string;\n };\n evaluator_attempts: number;\n usage: FusionUsage;\n budget: FusionResultBudgetDetails;\n}\n\nexport type FusionProgressEvent =\n | { type: 'state'; state: FusionState }\n | { type: 'candidate_started'; slot: 1 | 2 | 3; attempt: number }\n | { type: 'candidate_completed'; slot: 1 | 2 | 3; completed: number; total: 3 }\n | { type: 'evaluation_started'; attempt: 1 | 2; repair: boolean }\n | { type: 'evaluation_retry'; errors: readonly string[] }\n | { type: 'budget_warning'; warnings: readonly FusionBudgetWarning[]; error: string }\n | { type: 'calibration_warning'; warning: FusionCalibrationViolation; artifact: string }\n | { type: 'merge_started' }\n | { type: 'completed'; runId: string; artifactDir: string }\n | { type: 'failed'; runId: string; artifactDir: string; error: string }\n | { type: 'cancelled'; runId: string; artifactDir: string; reason: string };\n\nexport type FusionErrorCode =\n | 'config_invalid'\n | 'config_conflict'\n | 'model_unavailable'\n | 'context_capture_failed'\n | 'context_policy_unsupported_block'\n | 'prompt_budget_exceeded_forecast'\n | 'prompt_budget_exceeded_measured'\n | 'model_capacity_unknown'\n | 'child_spawn_failed'\n | 'child_stdin_failed'\n | 'child_event_invalid'\n | 'child_exit_failed'\n | 'child_runtime_limit_exceeded'\n | 'child_runtime_payload_invalid'\n | 'child_cache_policy_invalid'\n | 'child_timeout'\n | 'child_output_cap'\n | 'child_cancelled'\n | 'evaluation_invalid'\n | 'artifact_error'\n | 'state_transition_invalid'\n | 'orchestration_failed';\n\nexport type FusionBudgetCheckKind = 'input_only_preflight' | 'rendered_prompt';\n\nexport interface FusionBudgetComponentBreakdown {\n visible_text: { bytes: number; tokens: number };\n omission_receipts: { bytes: number; tokens: number };\n projection_metadata: { bytes: number; tokens: number };\n request: { bytes: number; tokens: number };\n static_stage_framing: { bytes: number; tokens: number };\n upstream_output_contracts: { bytes: number; tokens: number };\n}\n\nexport interface FusionBudgetDenseRegion {\n offset: number;\n len: number;\n detector: 'not_implemented_step_6';\n}\n\nexport interface FusionBudgetRouteTableEntry {\n role: FusionRouteCapacity['role'];\n qualified_id: string;\n allowed_input_tokens: number;\n family: TokenBudgetFamily;\n effective_rate_bytes_per_token_x100: number;\n byte_capacity_utf8_bytes: number;\n backed: boolean;\n}\n\nexport interface FusionBudgetCounterfactuals {\n empty_request: FusionBudgetEmptyRequestVerdict;\n without_reservation: {\n forecast_input_tokens_upper_bound: number;\n signed_headroom_tokens: number;\n fits: boolean;\n };\n at_median_rate: {\n forecast_input_tokens_upper_bound: number | null;\n signed_headroom_tokens: number | null;\n fits: boolean | null;\n };\n}\n\n/** Structured detail attached to a split prompt-budget failure. */\nexport interface FusionBudgetErrorDetail {\n budget_stage: FusionBudgetStage;\n slot?: 1 | 2 | 3;\n measurement_kind: 'stage_forecast' | 'rendered_prompt';\n check_kind: FusionBudgetCheckKind;\n measured_utf8_bytes: number;\n measured_input_tokens_upper_bound: number;\n allowed_input_tokens: number;\n limiting_model: {\n provider: string;\n model: string;\n qualified_id: string;\n context_window_tokens: number;\n };\n rate_source: TokenBudgetRateSource;\n backed: boolean;\n dominant_byte_class: TokenBudgetDominantByteClass;\n component_breakdown: FusionBudgetComponentBreakdown;\n byte_class_breakdown: TokenBudgetByteClassBreakdown;\n dense_regions: readonly FusionBudgetDenseRegion[];\n bytes_over: number;\n tokens_over: number;\n required_allowed_tokens: number;\n route_table: readonly FusionBudgetRouteTableEntry[];\n counterfactuals: FusionBudgetCounterfactuals;\n stage_upstream_actuals: readonly { stage: FusionStage; bytes: number }[];\n policy_id: string;\n calibration_version: string;\n context_policy_id: string;\n remediation: readonly string[];\n blockers: readonly FusionBudgetBlocker[];\n artifact_dir: string;\n}\n\nexport interface FusionErrorDetails {\n code: FusionErrorCode;\n stage?: FusionStage;\n slot?: 1 | 2 | 3;\n attempt?: number;\n artifactDir?: string;\n transient?: boolean;\n childCreated?: boolean;\n budget?: FusionBudgetErrorDetail;\n runProgress?: FusionRunProgress;\n}\n\nexport class FusionError extends Error {\n readonly code: FusionErrorCode;\n readonly stage: FusionStage | undefined;\n readonly slot: 1 | 2 | 3 | undefined;\n readonly attempt: number | undefined;\n readonly artifactDir: string | undefined;\n readonly transient: boolean;\n readonly childCreated: boolean;\n readonly budget: FusionBudgetErrorDetail | undefined;\n readonly runProgress: FusionRunProgress | undefined;\n\n constructor(message: string, details: FusionErrorDetails) {\n super(message);\n this.name = 'FusionError';\n this.code = details.code;\n this.stage = details.stage;\n this.slot = details.slot;\n this.attempt = details.attempt;\n this.artifactDir = details.artifactDir;\n this.transient = details.transient ?? false;\n this.childCreated = details.childCreated ?? true;\n this.budget = details.budget;\n this.runProgress = details.runProgress;\n }\n}\n\nexport interface FusionChildUsage extends FusionUsage {\n provider: string;\n model: string;\n qualifiedId: string;\n}\n\nexport type FusionToolCallLogStatus = 'ok' | 'error';\n\nexport interface FusionToolCallLogRecord {\n schema_version: typeof FUSION_TOOL_CALL_LOG_SCHEMA_VERSION;\n ordinal: number;\n tool_name: string;\n arguments_sha256: string;\n arguments_bytes: number;\n result_bytes: number;\n result_sha256: string;\n status: FusionToolCallLogStatus;\n duration_ms: number;\n url?: string | undefined;\n /** SHA-256 of a rejected attempted fetch URL; raw rejected URLs are never persisted. */\n rejected_url_sha256?: string | undefined;\n final_url?: string | undefined;\n http_status?: number | undefined;\n response_bytes?: number | undefined;\n content_sha256?: string | undefined;\n}\n\nexport interface FusionToolCallLogSummary {\n count: number;\n total_result_bytes: number;\n trace_complete: boolean;\n}\n\nexport interface FusionToolCallTrace {\n bytes: Buffer;\n records: readonly FusionToolCallLogRecord[];\n summary: FusionToolCallLogSummary;\n}\n\nexport interface FusionCandidateOutputRecovery {\n kind: 'same_session_compression';\n limit_bytes: number;\n original_record_index: number;\n replacement_record_index: number | null;\n original_json_rendered_bytes: number;\n replacement_json_rendered_bytes: number | null;\n original_text_sha256: string;\n original_text: string;\n status: 'completed' | 'failed';\n}\n\nexport interface FusionChildRunResult {\n stage: FusionStage;\n slot?: 1 | 2 | 3;\n attempt: number;\n provider: string;\n model: string;\n qualifiedId: string;\n text: string;\n /** Aggregate usage across the complete child agent loop. */\n usage: FusionUsage;\n /** First provider request, used for like-for-like prompt forecast calibration. */\n firstRequestUsage?: FusionUsage;\n /** Number of provider requests represented by aggregate usage. */\n providerRequestCount?: number;\n outputRecovery?: FusionCandidateOutputRecovery;\n events: Buffer;\n stderr: Buffer;\n exitCode: number;\n signal: NodeJS.Signals | null;\n toolCallTrace?: FusionToolCallTrace;\n}\n\nexport interface FusionAttemptOutputRecoveryRecord {\n kind: 'same_session_compression';\n status: 'completed' | 'failed';\n limit_bytes: number;\n original_response_path: string;\n original_record_index: number;\n replacement_record_index: number | null;\n original_json_rendered_bytes: number;\n replacement_json_rendered_bytes: number | null;\n original_text_sha256: string;\n}\n\nexport interface FusionAttemptArtifactRecord {\n stage: FusionStage;\n slot?: 1 | 2 | 3;\n attempt: number;\n status: 'completed' | 'failed' | 'cancelled';\n child_created: boolean;\n prompt_path: string;\n events_path?: string;\n stderr_path?: string;\n response_path?: string;\n partial_response_path?: string;\n tool_calls_path?: string;\n tool_calls?: FusionToolCallLogSummary;\n output_recovery?: FusionAttemptOutputRecoveryRecord;\n provider?: string;\n model?: string;\n qualifiedId?: string;\n usage?: FusionUsage;\n error?: string;\n}\n\nexport interface FusionArtifactRef {\n path: string;\n byte_length: number;\n sha256: string;\n}\n\nexport type FusionFailureArtifactClassification =\n | 'complete_stage_output'\n | 'partial_stage_output'\n | 'oversized_original'\n | 'empty_rejected_output'\n | 'evidence_only';\n\nexport interface FusionFailureEvidenceArtifact {\n name: string;\n classification: FusionFailureArtifactClassification;\n ref: FusionArtifactRef;\n}\n\nexport interface FusionFailureAttemptMetadata {\n stage: FusionStage;\n slot?: 1 | 2 | 3 | undefined;\n attempt: number;\n status: 'completed' | 'failed' | 'cancelled';\n child_created: boolean;\n}\n\nexport interface FusionFailureList<T> {\n listed: readonly T[];\n omitted_count: number;\n}\n\nexport interface FusionFailureMessageMetadata {\n byte_length: number;\n sha256: string;\n inline_message?: string | undefined;\n omission_reason?: 'exceeds_inline_message_bytes_cap' | 'result_view_byte_budget' | undefined;\n}\n\nexport interface FusionFailureSummaryV1 {\n schema_version: typeof FUSION_FAILURE_SUMMARY_SCHEMA_VERSION;\n run_id: string;\n workflow: FusionWorkflowId;\n source: FusionSource;\n terminal_state: Exclude<FusionTerminalState, 'completed'>;\n created_at: string;\n answer: { present: false; reason: 'run_did_not_commit' };\n failure: {\n code: FusionErrorCode | null;\n stage?: FusionStage | undefined;\n slot?: 1 | 2 | 3 | undefined;\n attempt?: number | undefined;\n child_created: boolean;\n message: FusionFailureMessageMetadata;\n };\n progress: FusionRunProgress;\n usage_so_far: FusionUsage;\n attempts: FusionFailureList<FusionFailureAttemptMetadata>;\n evidence_artifacts: FusionFailureList<FusionFailureEvidenceArtifact>;\n remediation_ids: readonly (\n | 'inspect_manifest_bound_evidence'\n | 'inspect_terminal_error'\n | 'split_or_reduce_work'\n | 'retry_same_route_after_operator_review'\n )[];\n}\n\nexport interface FusionFailureViewFailure {\n code?: FusionErrorCode | null | undefined;\n stage?: FusionStage | undefined;\n slot?: 1 | 2 | 3 | undefined;\n attempt?: number | undefined;\n child_created?: boolean | undefined;\n message: FusionFailureMessageMetadata;\n}\n\nexport interface FusionFailureResultView {\n schema_version: typeof FUSION_FAILURE_SUMMARY_SCHEMA_VERSION;\n summary_status: 'verified' | 'legacy_manifest_only' | 'unavailable' | 'integrity_failed';\n terminal_state: Exclude<FusionTerminalState, 'completed'>;\n answer: { present: false; reason: 'run_did_not_commit' };\n failure?: FusionFailureViewFailure | undefined;\n progress?: FusionRunProgress | undefined;\n usage_so_far?: FusionUsage | undefined;\n attempts?: FusionFailureList<FusionFailureAttemptMetadata> | undefined;\n evidence_artifacts?: FusionFailureList<FusionFailureEvidenceArtifact> | undefined;\n remediation_ids?: FusionFailureSummaryV1['remediation_ids'] | undefined;\n failure_summary_ref?: FusionArtifactRef | undefined;\n summary_unavailable_reason?: 'no_durable_summary' | 'manifest_untrusted' | 'summary_integrity_failed' | undefined;\n}\n\nexport interface FusionArtifactManifest {\n schema_version: typeof FUSION_MANIFEST_SCHEMA_VERSION;\n run_id: string;\n workflow: FusionWorkflowId;\n source: FusionSource;\n state: FusionState;\n created_at: string;\n updated_at: string;\n cwd: string;\n config: FusionModelConfigV1;\n models: {\n candidates: readonly [string, string, string];\n evaluator: string;\n merger: string;\n thinking_level: string;\n };\n capabilities: {\n candidate: FusionCapability;\n evaluation: FusionCapability;\n merge: FusionCapability;\n };\n context: {\n kind: FusionContextKind;\n policy_id: string;\n ledger_artifact?: string;\n source_policy_artifact?: string;\n };\n tool_policy: {\n candidate_tools: readonly string[];\n evaluation_tools: readonly [];\n merge_tools: readonly [];\n };\n usage: FusionUsage;\n attempts: readonly FusionAttemptArtifactRecord[];\n artifacts: Readonly<Record<string, FusionArtifactRef>>;\n anonymous_map?: Readonly<Record<FusionCandidateId, 1 | 2 | 3>>;\n error?: string;\n}\n\nexport interface FusionRunResult {\n mergedText: string;\n details: FusionResultDetails;\n}\n\n/** Snapshot of one configured route's verified input capacity for one stage. */\nexport interface FusionRouteCapacity {\n role: 'candidate-1' | 'candidate-2' | 'candidate-3' | 'evaluator' | 'merger';\n provider: string;\n model: string;\n qualified_id: string;\n context_window_tokens: number;\n reserved_output_tokens: number;\n framing_reserve_tokens: number;\n safety_reserve_tokens: number;\n allowed_input_tokens: number;\n family: TokenBudgetFamily;\n rate_source: TokenBudgetRateSource;\n byte_capacity_utf8_bytes: number;\n}\n\nexport interface FusionBudgetStageComposition {\n visible_text_bytes: number;\n omission_receipt_bytes: number;\n projection_metadata_bytes: number;\n request_bytes: number;\n static_stage_framing_bytes: number;\n upstream_output_contract_bytes: number;\n}\n\nexport interface FusionStageBudgetPlanEntry {\n budget_stage: FusionBudgetStage;\n slot?: 1 | 2 | 3;\n route: FusionRouteCapacity;\n conditional: boolean;\n check_kind: 'input_only_preflight';\n input_utf8_bytes: number;\n upstream_output_contract_bytes: number;\n forecast_utf8_bytes: number;\n input_only_input_tokens_upper_bound: number;\n forecast_input_tokens_upper_bound: number;\n allowed_input_tokens: number;\n input_only_signed_headroom_tokens: number;\n signed_headroom_tokens: number;\n input_only_utilization_basis_points: number;\n utilization_basis_points: number;\n input_only_estimate: EstimateInputTokensResult;\n reservation_estimate: EstimateInputTokensResult;\n fits: boolean;\n reservation_fits: boolean;\n}\n\nexport interface FusionBudgetBlocker extends FusionStageBudgetPlanEntry {\n overage_tokens: number;\n bytes_over: number;\n}\n\nexport interface FusionBudgetWarning extends FusionStageBudgetPlanEntry {\n warning_kind: 'input_utilization' | 'worst_case_reservation';\n threshold_basis_points: number;\n}\n\nexport interface FusionBudgetEmptyRequestVerdict {\n request_utf8_bytes: number;\n still_fails_with_empty_request: boolean;\n shortening_request_can_help: boolean;\n minimum_request_byte_reduction: number;\n maximum_safe_request_utf8_bytes: number;\n blockers_with_empty_request: readonly FusionBudgetBlocker[];\n}\n\nexport interface FusionBudgetPlanV1 {\n schema_version: typeof FUSION_BUDGET_PLAN_SCHEMA_VERSION;\n workflow: FusionWorkflowId;\n context: { kind: FusionContextKind; policy_id: string };\n fixed_candidate_policy: { capability: FusionCapability; tools: readonly string[] };\n tool_policy: {\n candidate_tools: readonly string[];\n evaluation_tools: readonly [];\n merge_tools: readonly [];\n };\n policy: FusionBudgetPolicyDescriptor;\n routes: readonly FusionRouteCapacity[];\n stages: readonly FusionStageBudgetPlanEntry[];\n blockers: readonly FusionBudgetBlocker[];\n primary_blocker?: FusionBudgetBlocker;\n primary_blocker_composition?: FusionBudgetStageComposition;\n empty_request: FusionBudgetEmptyRequestVerdict;\n warnings: readonly FusionBudgetWarning[];\n}\n\n/** Documented, versioned budget policy. */\nexport interface FusionBudgetPolicyDescriptor {\n id: 'fusion-budget-policy-v4';\n route_output_reserve_strategy: 'max_fusion_contract_or_model_max';\n calibration_version: string;\n calibration_table: Readonly<Record<TokenBudgetFamily, TokenBudgetFamilyCalibration>>;\n reserved_output_tokens: number;\n framing_reserve_tokens: number;\n safety_reserve_tokens: number;\n candidate_output_contract_bytes: number;\n evaluation_output_contract_bytes: number;\n merge_output_contract_bytes: number;\n diagnostics_contract_bytes: number;\n utilization_warning_threshold_basis_points: 8000;\n}\n\nexport interface FusionCalibrationViolation {\n schema_version: typeof FUSION_CALIBRATION_VIOLATION_SCHEMA_VERSION;\n stage: FusionStage;\n slot?: 1 | 2 | 3;\n attempt: number;\n route: {\n provider: string;\n model: string;\n qualified_id: string;\n };\n family: TokenBudgetFamily;\n rate_source: TokenBudgetRateSource;\n prompt_utf8_bytes: number;\n prompt_sha256: string;\n observation_scope: 'first_provider_request';\n provider_request_count: number;\n forecast_input_tokens: number;\n billed_input_tokens: number;\n billed_input_breakdown: {\n input: number;\n cache_read: number;\n cache_write: number;\n };\n under_forecast_tokens: number;\n byte_class_breakdown: TokenBudgetByteClassBreakdown;\n dominant_byte_class: TokenBudgetDominantByteClass;\n}\n"]}
|