@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,34 +0,0 @@
1
- import { FusionError, type FusionStage } from './types.js';
2
-
3
- /** Hard output contracts are measured over the JSON rendering embedded downstream. */
4
- export const FUSION_CANDIDATE_MAX_OUTPUT_BYTES = 48 * 1024;
5
- export const FUSION_EVALUATION_MAX_OUTPUT_BYTES = 64 * 1024;
6
- export const FUSION_MERGE_MAX_OUTPUT_BYTES = 64 * 1024;
7
- export const FUSION_DIAGNOSTICS_MAX_BYTES = 8 * 1024;
8
-
9
- const FUSION_CANDIDATE_MAX_OUTPUT_BYTES_DISPLAY =
10
- FUSION_CANDIDATE_MAX_OUTPUT_BYTES.toLocaleString('en-US');
11
-
12
- export const FUSION_CANDIDATE_OUTPUT_CONTRACT_INSTRUCTION = `Your complete response must be at most ${FUSION_CANDIDATE_MAX_OUTPUT_BYTES_DISPLAY} JSON-rendered UTF-8 bytes. If the requested scope cannot fit, prioritize the most important findings and explicitly state limitations.`;
13
-
14
- export const FUSION_CANDIDATE_OUTPUT_COMPRESSION_PROMPT = `Compress and restructure only your immediately previous answer so the complete replacement is at most ${FUSION_CANDIDATE_MAX_OUTPUT_BYTES_DISPLAY} JSON-rendered UTF-8 bytes. Do not investigate again, do not use tools, and do not add new evidence. Preserve the most important findings and evidence already present, state material limitations, obey the original output format, and output only the replacement answer.`;
15
-
16
- export function fusionJsonRenderedTextBytes(text: string): number {
17
- return Buffer.byteLength(JSON.stringify(text), 'utf8');
18
- }
19
-
20
- export function fusionOutputContractBytes(stage: FusionStage): number {
21
- if (stage === 'candidate') return FUSION_CANDIDATE_MAX_OUTPUT_BYTES;
22
- if (stage === 'evaluation') return FUSION_EVALUATION_MAX_OUTPUT_BYTES;
23
- return FUSION_MERGE_MAX_OUTPUT_BYTES;
24
- }
25
-
26
- export function assertChildOutputWithinContract(stage: FusionStage, text: string): void {
27
- const bytes = fusionJsonRenderedTextBytes(text);
28
- const allowed = fusionOutputContractBytes(stage);
29
- if (bytes <= allowed) return;
30
- throw new FusionError(
31
- `fusion ${stage} response is ${String(bytes)} JSON-rendered bytes, exceeding the ${String(allowed)}-byte output contract for that stage; the response is preserved in the run artifacts and is not forwarded or truncated`,
32
- { code: 'child_output_cap', stage, childCreated: true },
33
- );
34
- }