@pi-unipi/background-tasks 2.16.1 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +21 -27
  2. package/package.json +3 -4
  3. package/src/cards.ts +76 -0
  4. package/src/child-process.ts +1 -1
  5. package/src/config.ts +0 -42
  6. package/src/context-visible-conversation-v2.ts +1 -1
  7. package/src/delegate/artifacts.ts +1 -1
  8. package/src/delegate/launch.ts +17 -30
  9. package/src/delegate/result-package.ts +1 -1
  10. package/src/delegate/runner.ts +1 -20
  11. package/src/delegate/seed.ts +1 -1
  12. package/src/delegate-extension.ts +16 -168
  13. package/src/index.ts +53 -25
  14. package/src/json-utils.ts +56 -0
  15. package/src/package-assets.ts +51 -0
  16. package/src/registry.ts +8 -459
  17. package/src/task-manager.ts +13 -2
  18. package/src/tools.ts +4 -189
  19. package/src/types.ts +17 -70
  20. package/extensions/anthropic-attribution.ts +0 -1
  21. package/extensions/fusion-child.ts +0 -1
  22. package/src/anthropic-attribution-path.ts +0 -21
  23. package/src/anthropic-attribution.ts +0 -1983
  24. package/src/attested-pi-run.ts +0 -612
  25. package/src/fixtures/fusion-golden-bytes.json +0 -310
  26. package/src/fixtures/fusion-validate-golden-bytes.json +0 -282
  27. package/src/fusion/artifacts.ts +0 -967
  28. package/src/fusion/budget.ts +0 -1162
  29. package/src/fusion/child-protocol.ts +0 -305
  30. package/src/fusion/claude-cache.ts +0 -207
  31. package/src/fusion/clean-context.ts +0 -91
  32. package/src/fusion/config.ts +0 -449
  33. package/src/fusion/context.ts +0 -265
  34. package/src/fusion/evaluation.ts +0 -800
  35. package/src/fusion/orchestrator.ts +0 -1288
  36. package/src/fusion/output-contract.ts +0 -34
  37. package/src/fusion/pi-child.ts +0 -2373
  38. package/src/fusion/prompts.ts +0 -345
  39. package/src/fusion/result-package.ts +0 -959
  40. package/src/fusion/source-policy.ts +0 -257
  41. package/src/fusion/types.ts +0 -1139
  42. package/src/fusion/web-fetch.ts +0 -1060
  43. package/src/fusion/workflows.ts +0 -184
  44. package/src/fusion-child-extension.ts +0 -1052
  45. package/src/fusion-extension.ts +0 -1293
  46. package/src/ui/fusion-model-selector.ts +0 -322
@@ -1,184 +0,0 @@
1
- import {
2
- FUSION_EVALUATION_REPAIR_SYSTEM_PROMPT,
3
- FUSION_EVALUATOR_SYSTEM_PROMPT,
4
- FUSION_MERGER_SYSTEM_PROMPT,
5
- FUSION_VALIDATE_EVALUATION_REPAIR_SYSTEM_PROMPT,
6
- FUSION_VALIDATE_EVALUATOR_SYSTEM_PROMPT,
7
- FUSION_VALIDATE_MERGER_SYSTEM_PROMPT,
8
- fusionCandidateSystemPrompt,
9
- fusionValidateCandidateSystemPrompt,
10
- } from './prompts.js';
11
- import {
12
- FUSION_INSPECT_TOOLS,
13
- FUSION_NO_TOOLS_CAPABILITY,
14
- FUSION_RESEARCH_TOOLS,
15
- FUSION_VALIDATE_CAPABILITY,
16
- FusionError,
17
- type FusionCapability,
18
- type FusionContextKind,
19
- type FusionPublicWorkflowName,
20
- type FusionWorkflowId,
21
- } from './types.js';
22
-
23
- export const FUSION_REASON_TOOL_NAME = 'fusion_reason' as const;
24
- export const FUSION_INVESTIGATE_TOOL_NAME = 'fusion_investigate' as const;
25
- export const FUSION_RESEARCH_TOOL_NAME = 'fusion_research' as const;
26
- export const FUSION_VALIDATE_TOOL_NAME = 'fusion_validate' as const;
27
-
28
- /** @deprecated v4 recursion-denylist compatibility only; do not register new public APIs with this name. */
29
- export const FUSION_BRAINSTORM_TOOL_NAME = 'fusion_brainstorm' as const;
30
-
31
- export interface FusionWorkflowProfile {
32
- readonly id: FusionWorkflowId;
33
- readonly publicName: FusionPublicWorkflowName;
34
- readonly toolName: FusionPublicWorkflowName;
35
- /** Human-readable run-id prefix, e.g. `reason-<hex>`. */
36
- readonly runIdPrefix: `${FusionWorkflowId}-`;
37
- readonly contextKind: FusionContextKind;
38
- readonly candidateCapability: FusionCapability;
39
- readonly candidateTools: readonly string[];
40
- readonly evaluatorCapability: typeof FUSION_NO_TOOLS_CAPABILITY;
41
- readonly evaluatorTools: readonly [];
42
- readonly mergeCapability: typeof FUSION_NO_TOOLS_CAPABILITY;
43
- readonly mergeTools: readonly [];
44
- readonly candidateSystemPrompt: (capability: FusionCapability) => string;
45
- readonly evaluatorSystemPrompt: string;
46
- readonly evaluationRepairSystemPrompt: string;
47
- readonly mergerSystemPrompt: string;
48
- readonly label: string;
49
- }
50
-
51
- function freezeProfile(profile: FusionWorkflowProfile): FusionWorkflowProfile {
52
- const empty = Object.freeze([]) as readonly [];
53
- return Object.freeze({
54
- ...profile,
55
- candidateTools: Object.freeze([...profile.candidateTools]),
56
- evaluatorTools: empty,
57
- mergeTools: empty,
58
- });
59
- }
60
-
61
- export const FUSION_REASON_WORKFLOW = freezeProfile({
62
- id: 'reason',
63
- publicName: FUSION_REASON_TOOL_NAME,
64
- toolName: FUSION_REASON_TOOL_NAME,
65
- runIdPrefix: 'reason-',
66
- contextKind: 'session_projection',
67
- candidateCapability: FUSION_NO_TOOLS_CAPABILITY,
68
- candidateTools: [],
69
- evaluatorCapability: FUSION_NO_TOOLS_CAPABILITY,
70
- evaluatorTools: [],
71
- mergeCapability: FUSION_NO_TOOLS_CAPABILITY,
72
- mergeTools: [],
73
- candidateSystemPrompt: fusionCandidateSystemPrompt,
74
- evaluatorSystemPrompt: FUSION_EVALUATOR_SYSTEM_PROMPT,
75
- evaluationRepairSystemPrompt: FUSION_EVALUATION_REPAIR_SYSTEM_PROMPT,
76
- mergerSystemPrompt: FUSION_MERGER_SYSTEM_PROMPT,
77
- label: 'fusion reason',
78
- });
79
-
80
- export const FUSION_INVESTIGATE_WORKFLOW = freezeProfile({
81
- id: 'investigate',
82
- publicName: FUSION_INVESTIGATE_TOOL_NAME,
83
- toolName: FUSION_INVESTIGATE_TOOL_NAME,
84
- runIdPrefix: 'investigate-',
85
- contextKind: 'clean_task',
86
- candidateCapability: 'inspect',
87
- candidateTools: FUSION_INSPECT_TOOLS,
88
- evaluatorCapability: FUSION_NO_TOOLS_CAPABILITY,
89
- evaluatorTools: [],
90
- mergeCapability: FUSION_NO_TOOLS_CAPABILITY,
91
- mergeTools: [],
92
- candidateSystemPrompt: fusionCandidateSystemPrompt,
93
- evaluatorSystemPrompt: FUSION_EVALUATOR_SYSTEM_PROMPT,
94
- evaluationRepairSystemPrompt: FUSION_EVALUATION_REPAIR_SYSTEM_PROMPT,
95
- mergerSystemPrompt: FUSION_MERGER_SYSTEM_PROMPT,
96
- label: 'fusion investigate',
97
- });
98
-
99
- export const FUSION_RESEARCH_WORKFLOW = freezeProfile({
100
- id: 'research',
101
- publicName: FUSION_RESEARCH_TOOL_NAME,
102
- toolName: FUSION_RESEARCH_TOOL_NAME,
103
- runIdPrefix: 'research-',
104
- contextKind: 'clean_task',
105
- candidateCapability: 'research',
106
- candidateTools: FUSION_RESEARCH_TOOLS,
107
- evaluatorCapability: FUSION_NO_TOOLS_CAPABILITY,
108
- evaluatorTools: [],
109
- mergeCapability: FUSION_NO_TOOLS_CAPABILITY,
110
- mergeTools: [],
111
- candidateSystemPrompt: fusionCandidateSystemPrompt,
112
- evaluatorSystemPrompt: FUSION_EVALUATOR_SYSTEM_PROMPT,
113
- evaluationRepairSystemPrompt: FUSION_EVALUATION_REPAIR_SYSTEM_PROMPT,
114
- mergerSystemPrompt: FUSION_MERGER_SYSTEM_PROMPT,
115
- label: 'fusion research',
116
- });
117
-
118
- export const FUSION_VALIDATE_WORKFLOW = freezeProfile({
119
- id: 'validate',
120
- publicName: FUSION_VALIDATE_TOOL_NAME,
121
- toolName: FUSION_VALIDATE_TOOL_NAME,
122
- runIdPrefix: 'validate-',
123
- contextKind: 'clean_task',
124
- candidateCapability: FUSION_VALIDATE_CAPABILITY,
125
- candidateTools: FUSION_INSPECT_TOOLS,
126
- evaluatorCapability: FUSION_NO_TOOLS_CAPABILITY,
127
- evaluatorTools: [],
128
- mergeCapability: FUSION_NO_TOOLS_CAPABILITY,
129
- mergeTools: [],
130
- candidateSystemPrompt: fusionValidateCandidateSystemPrompt,
131
- evaluatorSystemPrompt: FUSION_VALIDATE_EVALUATOR_SYSTEM_PROMPT,
132
- evaluationRepairSystemPrompt: FUSION_VALIDATE_EVALUATION_REPAIR_SYSTEM_PROMPT,
133
- mergerSystemPrompt: FUSION_VALIDATE_MERGER_SYSTEM_PROMPT,
134
- label: 'fusion validate',
135
- });
136
-
137
- const PROFILES_BY_ID: Readonly<Record<FusionWorkflowId, FusionWorkflowProfile>> = Object.freeze({
138
- reason: FUSION_REASON_WORKFLOW,
139
- investigate: FUSION_INVESTIGATE_WORKFLOW,
140
- research: FUSION_RESEARCH_WORKFLOW,
141
- validate: FUSION_VALIDATE_WORKFLOW,
142
- });
143
-
144
- export const FUSION_WORKFLOW_PROFILES = Object.freeze([
145
- FUSION_REASON_WORKFLOW,
146
- FUSION_INVESTIGATE_WORKFLOW,
147
- FUSION_RESEARCH_WORKFLOW,
148
- FUSION_VALIDATE_WORKFLOW,
149
- ] as const);
150
-
151
- export function fusionWorkflowProfile(id: FusionWorkflowId): FusionWorkflowProfile {
152
- const profile = PROFILES_BY_ID[id];
153
- if (profile === undefined) {
154
- throw new FusionError(`unknown fusion workflow ${String(id)}`, {
155
- code: 'orchestration_failed',
156
- childCreated: false,
157
- });
158
- }
159
- return profile;
160
- }
161
-
162
- export function assertWorkflowCapability(
163
- profile: FusionWorkflowProfile,
164
- requested: FusionCapability | undefined,
165
- ): FusionCapability {
166
- if (requested !== undefined && requested !== profile.candidateCapability) {
167
- throw new FusionError(
168
- `fusion workflow ${profile.id} always runs candidates with the ${profile.candidateCapability} capability; received ${String(requested)}`,
169
- { code: 'orchestration_failed', childCreated: false },
170
- );
171
- }
172
- return profile.candidateCapability;
173
- }
174
-
175
- /** @deprecated v4 artifact/testing alias. The retired public tool is never registered. */
176
- export const FUSION_BRAINSTORM_WORKFLOW = FUSION_REASON_WORKFLOW;
177
-
178
- export const FUSION_REASON = FUSION_REASON_WORKFLOW;
179
- export const FUSION_INVESTIGATE = FUSION_INVESTIGATE_WORKFLOW;
180
- export const FUSION_RESEARCH = FUSION_RESEARCH_WORKFLOW;
181
- export const FUSION_VALIDATE = FUSION_VALIDATE_WORKFLOW;
182
-
183
- /** @deprecated v5 workflows do not default; retained for old imports. */
184
- export const resolveWorkflowCapability = assertWorkflowCapability;