@pi-unipi/background-tasks 2.6.1
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/README.md +87 -0
- package/extensions/anthropic-attribution.ts +1 -0
- package/extensions/delegate-child.ts +1 -0
- package/extensions/fusion-child.ts +1 -0
- package/package.json +40 -0
- package/src/__tests__/anthropic-attribution.test.ts +195 -0
- package/src/__tests__/config.test.ts +137 -0
- package/src/__tests__/core.test.ts +493 -0
- package/src/__tests__/delegate-artifacts.test.ts +528 -0
- package/src/__tests__/delegate-budget.test.ts +456 -0
- package/src/__tests__/delegate-launch.test.ts +676 -0
- package/src/__tests__/delegate-result-package.test.ts +350 -0
- package/src/__tests__/delegate-seed.test.ts +392 -0
- package/src/__tests__/durable-fs.test.ts +559 -0
- package/src/__tests__/extension-api.test.ts +579 -0
- package/src/__tests__/fusion-artifacts.test.ts +1039 -0
- package/src/__tests__/fusion-budget.test.ts +1356 -0
- package/src/__tests__/fusion-claude-cache.test.ts +320 -0
- package/src/__tests__/fusion-config.test.ts +335 -0
- package/src/__tests__/fusion-context-prompts.test.ts +670 -0
- package/src/__tests__/fusion-evaluation.test.ts +315 -0
- package/src/__tests__/fusion-extraction-equivalence.test.ts +58 -0
- package/src/__tests__/fusion-golden-bytes.test.ts +35 -0
- package/src/__tests__/fusion-high-cardinality.test.ts +192 -0
- package/src/__tests__/fusion-model-selector.test.ts +205 -0
- package/src/__tests__/fusion-orchestrator.test.ts +1194 -0
- package/src/__tests__/fusion-rpc.test.ts +369 -0
- package/src/__tests__/fusion-sdk.test.ts +1226 -0
- package/src/__tests__/fusion-v5-core.test.ts +219 -0
- package/src/__tests__/fusion-validate-orchestrator.test.ts +240 -0
- package/src/__tests__/fusion-web-fetch.test.ts +485 -0
- package/src/__tests__/fusion-workflows.test.ts +59 -0
- package/src/__tests__/helpers/delegate-deterministic-seed.ts +109 -0
- package/src/__tests__/helpers/delegate-seed-subprocess.ts +10 -0
- package/src/__tests__/helpers/fusion-canonical-subprocess.ts +21 -0
- package/src/__tests__/helpers/fusion-canonical.ts +140 -0
- package/src/__tests__/helpers/fusion-fake-pi.ts +279 -0
- package/src/__tests__/helpers/fusion-golden-corpus.ts +500 -0
- package/src/__tests__/helpers/fusion-high-cardinality.ts +140 -0
- package/src/__tests__/helpers/normalize.ts +22 -0
- package/src/__tests__/helpers/pi-hook-contract-evidence.json +18 -0
- package/src/__tests__/pi-launch.test.ts +202 -0
- package/src/__tests__/registry.test.ts +1580 -0
- package/src/__tests__/scripted-provider/delegate-ambient-provider.test.ts +130 -0
- package/src/__tests__/scripted-provider/delegate-child-guard.test.ts +631 -0
- package/src/__tests__/scripted-provider/delegate-guard-provider.ts +403 -0
- package/src/__tests__/scripted-provider/follow-up.test.ts +448 -0
- package/src/__tests__/scripted-provider/fusion-output-recovery.test.ts +132 -0
- package/src/__tests__/scripted-provider/fusion-reason.test.ts +310 -0
- package/src/__tests__/scripted-provider/fusion-runtime-guard.test.ts +163 -0
- package/src/__tests__/scripted-provider/hook-contract-provider.ts +179 -0
- package/src/__tests__/scripted-provider/hook-probe-a.ts +3 -0
- package/src/__tests__/scripted-provider/hook-probe-b.ts +3 -0
- package/src/__tests__/scripted-provider/hook-probe-extension.ts +126 -0
- package/src/__tests__/scripted-provider/output-recovery-provider.ts +153 -0
- package/src/__tests__/scripted-provider/pi-hook-contract-evidence.json +18 -0
- package/src/__tests__/scripted-provider/pi-hook-contract.test.ts +477 -0
- package/src/__tests__/scripted-provider/runtime-guard-probe.ts +28 -0
- package/src/__tests__/scripted-provider/runtime-guard-provider.ts +49 -0
- package/src/__tests__/scripted-provider/scripted-provider-extension.ts +408 -0
- package/src/__tests__/task-manager.test.ts +479 -0
- package/src/__tests__/windows-taskkill.test.ts +161 -0
- package/src/anthropic-attribution-path.ts +21 -0
- package/src/anthropic-attribution.ts +1983 -0
- package/src/attested-pi-run.ts +612 -0
- package/src/child-process.ts +55 -0
- package/src/common.ts +8 -0
- package/src/config.ts +292 -0
- package/src/context-parent-snapshot.ts +142 -0
- package/src/context-token-budget.ts +903 -0
- package/src/context-visible-conversation-v2.ts +551 -0
- package/src/delegate/artifacts.ts +487 -0
- package/src/delegate/budget.ts +415 -0
- package/src/delegate/hook-contract-evidence.json +18 -0
- package/src/delegate/hook-contract.ts +154 -0
- package/src/delegate/launch.ts +497 -0
- package/src/delegate/result-package.ts +459 -0
- package/src/delegate/runner.ts +449 -0
- package/src/delegate/seed.ts +423 -0
- package/src/delegate/types.ts +323 -0
- package/src/delegate-child-extension.ts +978 -0
- package/src/delegate-extension.ts +806 -0
- package/src/durable-fs.ts +386 -0
- package/src/extension-api.ts +548 -0
- package/src/fixtures/delegate-context-incident.json +17 -0
- package/src/fixtures/fusion-golden-bytes.json +310 -0
- package/src/fixtures/fusion-validate-golden-bytes.json +282 -0
- package/src/fusion/artifacts.ts +967 -0
- package/src/fusion/budget.ts +1162 -0
- package/src/fusion/child-protocol.ts +305 -0
- package/src/fusion/claude-cache.ts +207 -0
- package/src/fusion/clean-context.ts +91 -0
- package/src/fusion/config.ts +449 -0
- package/src/fusion/context.ts +265 -0
- package/src/fusion/evaluation.ts +800 -0
- package/src/fusion/orchestrator.ts +1288 -0
- package/src/fusion/output-contract.ts +34 -0
- package/src/fusion/pi-child.ts +2373 -0
- package/src/fusion/prompts.ts +345 -0
- package/src/fusion/result-package.ts +959 -0
- package/src/fusion/source-policy.ts +257 -0
- package/src/fusion/types.ts +1139 -0
- package/src/fusion/web-fetch.ts +1060 -0
- package/src/fusion/workflows.ts +184 -0
- package/src/fusion-child-extension.ts +1052 -0
- package/src/fusion-extension.ts +1293 -0
- package/src/index.ts +295 -0
- package/src/pi-launch.ts +225 -0
- package/src/registry.ts +2424 -0
- package/src/settings-overlay.ts +208 -0
- package/src/task-manager.ts +774 -0
- package/src/tools.ts +530 -0
- package/src/turndown.d.ts +15 -0
- package/src/types.ts +963 -0
- package/src/ui/fusion-model-selector.ts +322 -0
- package/src/windows-taskkill.ts +250 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import type { Usage } from '@earendil-works/pi-ai';
|
|
2
|
+
import type {
|
|
3
|
+
TokenBudgetByteClassBreakdown,
|
|
4
|
+
TokenBudgetDominantByteClass,
|
|
5
|
+
TokenBudgetFamily,
|
|
6
|
+
TokenBudgetRateSource,
|
|
7
|
+
} from '../context-token-budget.js';
|
|
8
|
+
import type {
|
|
9
|
+
ContextProjectionMapEntry,
|
|
10
|
+
OmittedEventRecord,
|
|
11
|
+
ProjectionAccounting,
|
|
12
|
+
ProjectionEntry,
|
|
13
|
+
} from '../context-visible-conversation-v2.js';
|
|
14
|
+
|
|
15
|
+
export const DELEGATE_SEED_SCHEMA_VERSION = 'pi-background-tasks.delegate-seed.v2' as const;
|
|
16
|
+
export const DELEGATE_LEDGER_SCHEMA_VERSION = 'pi-background-tasks.delegate-ledger.v1' as const;
|
|
17
|
+
export const DELEGATE_RESULT_PACKAGE_SCHEMA_VERSION =
|
|
18
|
+
'pi-background-tasks.delegate-result.v1' as const;
|
|
19
|
+
export const DELEGATE_RECEIPT_SCHEMA_VERSION = 'pi-background-tasks.delegate-receipt.v1' as const;
|
|
20
|
+
export const DELEGATE_BUDGET_PLAN_SCHEMA_VERSION =
|
|
21
|
+
'pi-background-tasks.delegate-budget-plan.v3' as const;
|
|
22
|
+
export const DELEGATE_MANIFEST_SCHEMA_VERSION = 'pi-background-tasks.delegate-manifest.v2' as const;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Delegate's own context policy id. It shares the frozen
|
|
26
|
+
* `visible-conversation-ledger-v2` transform with Fusion but is a distinct
|
|
27
|
+
* consumer identity, so a delegate artifact can never be mistaken for a Fusion
|
|
28
|
+
* artifact and neither can claim the other's provenance.
|
|
29
|
+
*/
|
|
30
|
+
export const DELEGATE_CONTEXT_POLICY_ID = 'delegate-inspect-v1';
|
|
31
|
+
export const DELEGATE_BRANCH_FILTER_ID = 'exclude-active-delegate-batch-v1';
|
|
32
|
+
export const DELEGATE_TOOL_NAME = 'bg_delegate';
|
|
33
|
+
export const DELEGATE_RESULT_TOOL_NAME = 'bg_result';
|
|
34
|
+
|
|
35
|
+
export const DELEGATE_CAPABILITIES = ['inspect'] as const;
|
|
36
|
+
export type DelegateCapability = (typeof DELEGATE_CAPABILITIES)[number];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Controls only Pi's ambient extension discovery for delegate children.
|
|
40
|
+
* Tool and project-resource restrictions remain independently enforced.
|
|
41
|
+
*/
|
|
42
|
+
export const DELEGATE_EXTENSION_MODES = ['isolated', 'ambient'] as const;
|
|
43
|
+
export type DelegateExtensionMode = (typeof DELEGATE_EXTENSION_MODES)[number];
|
|
44
|
+
|
|
45
|
+
export const DELEGATE_AUTO_DELIVER_MODES = ['never', 'when_small', 'always'] as const;
|
|
46
|
+
export type DelegateAutoDeliverMode = (typeof DELEGATE_AUTO_DELIVER_MODES)[number];
|
|
47
|
+
|
|
48
|
+
export const DELEGATE_DELIVERY_MODES = ['inline', 'artifact'] as const;
|
|
49
|
+
export type DelegateDeliveryMode = (typeof DELEGATE_DELIVERY_MODES)[number];
|
|
50
|
+
|
|
51
|
+
export interface DelegateRoute {
|
|
52
|
+
provider: string;
|
|
53
|
+
model: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface DelegatePinnedRoute extends DelegateRoute {
|
|
57
|
+
qualified_id: string;
|
|
58
|
+
context_window_tokens: number;
|
|
59
|
+
thinking_level: string;
|
|
60
|
+
/** Whether the route came from the parent's current model or an explicit argument. */
|
|
61
|
+
origin: 'parent_current' | 'explicit';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface DelegateBudgetRouteSource {
|
|
65
|
+
family: TokenBudgetFamily;
|
|
66
|
+
rate_source: TokenBudgetRateSource;
|
|
67
|
+
conservative_rate_source?: TokenBudgetRateSource | undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface DelegateContextPolicyDescriptor {
|
|
71
|
+
id: typeof DELEGATE_CONTEXT_POLICY_ID;
|
|
72
|
+
transform: 'visible-conversation-ledger-v2';
|
|
73
|
+
version: 1;
|
|
74
|
+
receipt_format: 'omitted_activity.v2';
|
|
75
|
+
user_text: 'verbatim';
|
|
76
|
+
assistant_text: 'verbatim';
|
|
77
|
+
assistant_thinking: 'ledger_only';
|
|
78
|
+
tool_call_arguments: 'ledger_only';
|
|
79
|
+
tool_results: 'ledger_only';
|
|
80
|
+
tool_payload_preview_bytes: 0;
|
|
81
|
+
images: 'marker_or_ledger_only';
|
|
82
|
+
unknown_block_behavior: 'error';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface DelegateBranchFilterDescriptor {
|
|
86
|
+
id: typeof DELEGATE_BRANCH_FILTER_ID;
|
|
87
|
+
tool_name: typeof DELEGATE_TOOL_NAME;
|
|
88
|
+
tool_call_id: string | null;
|
|
89
|
+
active_tool_call_leaf_excluded: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface DelegateConversationProjection {
|
|
93
|
+
policy: DelegateContextPolicyDescriptor;
|
|
94
|
+
branch_filter: DelegateBranchFilterDescriptor;
|
|
95
|
+
entries: readonly ProjectionEntry[];
|
|
96
|
+
accounting: ProjectionAccounting;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface DelegateLedgerV1 {
|
|
100
|
+
schema_version: typeof DELEGATE_LEDGER_SCHEMA_VERSION;
|
|
101
|
+
policy_id: typeof DELEGATE_CONTEXT_POLICY_ID;
|
|
102
|
+
transform: 'visible-conversation-ledger-v2';
|
|
103
|
+
entries: readonly OmittedEventRecord[];
|
|
104
|
+
projection_map: readonly ContextProjectionMapEntry[];
|
|
105
|
+
root_sha256: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface DelegateTaskDirective {
|
|
109
|
+
/** Verbatim operator/agent prompt. Always authoritative over projected history. */
|
|
110
|
+
text: string;
|
|
111
|
+
sha256: string;
|
|
112
|
+
authority: 'explicit_text';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface DelegateSeedV1 {
|
|
116
|
+
schema_version: typeof DELEGATE_SEED_SCHEMA_VERSION;
|
|
117
|
+
task_id: string;
|
|
118
|
+
launch_nonce: string;
|
|
119
|
+
cwd: string;
|
|
120
|
+
capability: DelegateCapability;
|
|
121
|
+
extension_mode: DelegateExtensionMode;
|
|
122
|
+
route: DelegatePinnedRoute;
|
|
123
|
+
parent_system_prompt: string;
|
|
124
|
+
parent_leaf_id: string | null;
|
|
125
|
+
directive: DelegateTaskDirective;
|
|
126
|
+
conversation_projection: DelegateConversationProjection;
|
|
127
|
+
limits: DelegateLimits;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface DelegateLimits {
|
|
131
|
+
max_turns: number;
|
|
132
|
+
max_tool_calls: number;
|
|
133
|
+
timeout_seconds: number;
|
|
134
|
+
/** Per-tool-result transcript cap; larger results spill to hashed artifacts. */
|
|
135
|
+
max_tool_result_bytes: number;
|
|
136
|
+
/** Cumulative spilled+inline tool output across the whole run. */
|
|
137
|
+
max_total_tool_output_bytes: number;
|
|
138
|
+
/** Cap on the child's captured final answer. */
|
|
139
|
+
max_answer_bytes: number;
|
|
140
|
+
/** Usable input tokens for the pinned route after reserves. */
|
|
141
|
+
allowed_input_tokens: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface DelegateAnswerBlock {
|
|
145
|
+
kind: 'text';
|
|
146
|
+
byte_length: number;
|
|
147
|
+
sha256: string;
|
|
148
|
+
data_base64: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface DelegateRouteAttestation {
|
|
152
|
+
provider: string;
|
|
153
|
+
model: string;
|
|
154
|
+
stop_reason: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Usage that is explicitly absent is reported as absent.
|
|
159
|
+
*
|
|
160
|
+
* A child that never produced a usable usage record must not be reported as
|
|
161
|
+
* having cost zero, so the status is carried alongside the value.
|
|
162
|
+
*/
|
|
163
|
+
export type DelegateUsageReport =
|
|
164
|
+
| { status: 'observed'; usage: Usage }
|
|
165
|
+
| { status: 'unavailable'; reason: string };
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The single atomically-committed answer data plane.
|
|
169
|
+
*
|
|
170
|
+
* The child writes exactly this document to a temporary file, fsyncs it, and
|
|
171
|
+
* renames it into place. The rename is the commit point: a package that exists
|
|
172
|
+
* under its final name is complete, and one that does not exist means the child
|
|
173
|
+
* produced no accepted answer. There is no second channel to reconcile.
|
|
174
|
+
*/
|
|
175
|
+
export interface DelegateResultPackageV1 {
|
|
176
|
+
schema_version: typeof DELEGATE_RESULT_PACKAGE_SCHEMA_VERSION;
|
|
177
|
+
task_id: string;
|
|
178
|
+
launch_nonce: string;
|
|
179
|
+
seed_sha256: string;
|
|
180
|
+
directive_sha256: string;
|
|
181
|
+
route: DelegateRoute;
|
|
182
|
+
route_attestations: readonly DelegateRouteAttestation[];
|
|
183
|
+
stop_reason: string;
|
|
184
|
+
turns: number;
|
|
185
|
+
tool_calls: number;
|
|
186
|
+
usage: DelegateUsageReport;
|
|
187
|
+
answer: {
|
|
188
|
+
encoding: 'utf-8';
|
|
189
|
+
byte_length: number;
|
|
190
|
+
sha256: string;
|
|
191
|
+
blocks: readonly DelegateAnswerBlock[];
|
|
192
|
+
};
|
|
193
|
+
spilled_artifacts: readonly DelegateSpillReceipt[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type DelegateSpillContentFormat =
|
|
197
|
+
| 'single_text_utf8'
|
|
198
|
+
| 'tool_result_content_json_v1'
|
|
199
|
+
| 'opaque_bytes';
|
|
200
|
+
|
|
201
|
+
export interface DelegateSpillReceipt {
|
|
202
|
+
schema_version: typeof DELEGATE_RECEIPT_SCHEMA_VERSION;
|
|
203
|
+
artifact: string;
|
|
204
|
+
tool_name: string;
|
|
205
|
+
tool_call_id: string;
|
|
206
|
+
turn_sequence: number;
|
|
207
|
+
source_call_index: number;
|
|
208
|
+
byte_length: number;
|
|
209
|
+
sha256: string;
|
|
210
|
+
/**
|
|
211
|
+
* Encoding of the hashed artifact bytes. Optional only for compatibility
|
|
212
|
+
* with v1 receipts written before content formats were recorded.
|
|
213
|
+
*/
|
|
214
|
+
content_format?: DelegateSpillContentFormat | undefined;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const DELEGATE_ERROR_CODES = [
|
|
218
|
+
// Admission failures. No child process exists in these states.
|
|
219
|
+
'delegate_hook_contract_unsupported',
|
|
220
|
+
'delegate_isolation_unsupported',
|
|
221
|
+
'route_unresolved',
|
|
222
|
+
'route_capacity_unknown',
|
|
223
|
+
'seed_projection_failed',
|
|
224
|
+
'seed_budget_exceeded',
|
|
225
|
+
'seed_persist_failed',
|
|
226
|
+
'invalid_arguments',
|
|
227
|
+
// Launch and execution.
|
|
228
|
+
'child_spawn_failed',
|
|
229
|
+
'child_startup_failed',
|
|
230
|
+
'child_timeout',
|
|
231
|
+
'child_cancelled',
|
|
232
|
+
'child_turn_limit',
|
|
233
|
+
'child_tool_call_limit',
|
|
234
|
+
'child_exited_without_commit',
|
|
235
|
+
// Budget, split by which budget was exhausted.
|
|
236
|
+
'provider_context_budget_exhausted',
|
|
237
|
+
'aggregate_tool_output_cap',
|
|
238
|
+
'child_model_output_limit',
|
|
239
|
+
'child_capture_limit',
|
|
240
|
+
// Integrity.
|
|
241
|
+
'child_result_invalid',
|
|
242
|
+
'child_result_encoding_invalid',
|
|
243
|
+
'route_attestation_missing',
|
|
244
|
+
'route_mismatch',
|
|
245
|
+
'seed_hash_mismatch',
|
|
246
|
+
'answer_hash_mismatch',
|
|
247
|
+
'artifact_spill_failed',
|
|
248
|
+
'artifact_read_failed',
|
|
249
|
+
'artifact_error',
|
|
250
|
+
// Retrieval states and outcomes.
|
|
251
|
+
'result_not_ready',
|
|
252
|
+
'result_unavailable',
|
|
253
|
+
'result_too_large_for_inline',
|
|
254
|
+
'task_unknown',
|
|
255
|
+
] as const;
|
|
256
|
+
|
|
257
|
+
export type DelegateErrorCode = (typeof DELEGATE_ERROR_CODES)[number];
|
|
258
|
+
|
|
259
|
+
export interface DelegateBudgetErrorDetail {
|
|
260
|
+
measurement_kind: 'launch_admission' | 'runtime_context';
|
|
261
|
+
measured_utf8_bytes: number;
|
|
262
|
+
measured_input_tokens_upper_bound: number;
|
|
263
|
+
allowed_input_tokens: number;
|
|
264
|
+
rate_source: TokenBudgetRateSource;
|
|
265
|
+
backed: boolean;
|
|
266
|
+
dominant_byte_class: TokenBudgetDominantByteClass;
|
|
267
|
+
byte_class_breakdown: TokenBudgetByteClassBreakdown;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface DelegateErrorDetails {
|
|
271
|
+
code: DelegateErrorCode;
|
|
272
|
+
/** True only when an OS process was actually created. Admission failures are false. */
|
|
273
|
+
childCreated?: boolean;
|
|
274
|
+
taskId?: string;
|
|
275
|
+
artifactDir?: string;
|
|
276
|
+
budget?: DelegateBudgetErrorDetail;
|
|
277
|
+
/** What is preserved on disk despite the failure. */
|
|
278
|
+
preserved?: readonly string[];
|
|
279
|
+
/** Concrete operator actions. */
|
|
280
|
+
remediation?: readonly string[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Typed delegate failure.
|
|
285
|
+
*
|
|
286
|
+
* Every instance states what happened, what was preserved, and what the operator
|
|
287
|
+
* can do. There is no untyped delegate failure path.
|
|
288
|
+
*/
|
|
289
|
+
export class DelegateError extends Error {
|
|
290
|
+
readonly code: DelegateErrorCode;
|
|
291
|
+
readonly childCreated: boolean;
|
|
292
|
+
readonly taskId: string | undefined;
|
|
293
|
+
readonly artifactDir: string | undefined;
|
|
294
|
+
readonly budget: DelegateBudgetErrorDetail | undefined;
|
|
295
|
+
readonly preserved: readonly string[];
|
|
296
|
+
readonly remediation: readonly string[];
|
|
297
|
+
|
|
298
|
+
constructor(message: string, details: DelegateErrorDetails) {
|
|
299
|
+
super(message);
|
|
300
|
+
this.name = 'DelegateError';
|
|
301
|
+
this.code = details.code;
|
|
302
|
+
this.childCreated = details.childCreated ?? false;
|
|
303
|
+
this.taskId = details.taskId;
|
|
304
|
+
this.artifactDir = details.artifactDir;
|
|
305
|
+
this.budget = details.budget;
|
|
306
|
+
this.preserved = details.preserved ?? [];
|
|
307
|
+
this.remediation = details.remediation ?? [];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Operator-facing rendering: cause, preserved evidence, and next action. */
|
|
311
|
+
describe(): string {
|
|
312
|
+
const lines = [`[${this.code}] ${this.message}`];
|
|
313
|
+
lines.push(`Child process created: ${this.childCreated ? 'yes' : 'no'}`);
|
|
314
|
+
if (this.artifactDir !== undefined) lines.push(`Artifacts: ${this.artifactDir}`);
|
|
315
|
+
lines.push(
|
|
316
|
+
this.preserved.length > 0
|
|
317
|
+
? `Preserved: ${this.preserved.join(', ')}`
|
|
318
|
+
: 'Preserved: nothing was written for this failure',
|
|
319
|
+
);
|
|
320
|
+
if (this.remediation.length > 0) lines.push(`Remediation: ${this.remediation.join(' ')}`);
|
|
321
|
+
return lines.join('\n');
|
|
322
|
+
}
|
|
323
|
+
}
|