@pi-unipi/background-tasks 2.6.2 → 2.6.4

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 (59) hide show
  1. package/package.json +3 -2
  2. package/src/tools.ts +3 -1
  3. package/src/__tests__/anthropic-attribution.test.ts +0 -195
  4. package/src/__tests__/config.test.ts +0 -137
  5. package/src/__tests__/core.test.ts +0 -493
  6. package/src/__tests__/delegate-artifacts.test.ts +0 -528
  7. package/src/__tests__/delegate-budget.test.ts +0 -456
  8. package/src/__tests__/delegate-launch.test.ts +0 -676
  9. package/src/__tests__/delegate-result-package.test.ts +0 -350
  10. package/src/__tests__/delegate-seed.test.ts +0 -392
  11. package/src/__tests__/durable-fs.test.ts +0 -559
  12. package/src/__tests__/extension-api.test.ts +0 -579
  13. package/src/__tests__/fusion-artifacts.test.ts +0 -1039
  14. package/src/__tests__/fusion-budget.test.ts +0 -1356
  15. package/src/__tests__/fusion-claude-cache.test.ts +0 -320
  16. package/src/__tests__/fusion-config.test.ts +0 -335
  17. package/src/__tests__/fusion-context-prompts.test.ts +0 -670
  18. package/src/__tests__/fusion-evaluation.test.ts +0 -315
  19. package/src/__tests__/fusion-extraction-equivalence.test.ts +0 -58
  20. package/src/__tests__/fusion-golden-bytes.test.ts +0 -35
  21. package/src/__tests__/fusion-high-cardinality.test.ts +0 -192
  22. package/src/__tests__/fusion-model-selector.test.ts +0 -205
  23. package/src/__tests__/fusion-orchestrator.test.ts +0 -1194
  24. package/src/__tests__/fusion-rpc.test.ts +0 -369
  25. package/src/__tests__/fusion-sdk.test.ts +0 -1226
  26. package/src/__tests__/fusion-v5-core.test.ts +0 -219
  27. package/src/__tests__/fusion-validate-orchestrator.test.ts +0 -240
  28. package/src/__tests__/fusion-web-fetch.test.ts +0 -485
  29. package/src/__tests__/fusion-workflows.test.ts +0 -59
  30. package/src/__tests__/helpers/delegate-deterministic-seed.ts +0 -109
  31. package/src/__tests__/helpers/delegate-seed-subprocess.ts +0 -10
  32. package/src/__tests__/helpers/fusion-canonical-subprocess.ts +0 -21
  33. package/src/__tests__/helpers/fusion-canonical.ts +0 -140
  34. package/src/__tests__/helpers/fusion-fake-pi.ts +0 -279
  35. package/src/__tests__/helpers/fusion-golden-corpus.ts +0 -500
  36. package/src/__tests__/helpers/fusion-high-cardinality.ts +0 -140
  37. package/src/__tests__/helpers/normalize.ts +0 -22
  38. package/src/__tests__/helpers/pi-hook-contract-evidence.json +0 -18
  39. package/src/__tests__/pi-launch.test.ts +0 -202
  40. package/src/__tests__/registry.test.ts +0 -1580
  41. package/src/__tests__/scripted-provider/delegate-ambient-provider.test.ts +0 -130
  42. package/src/__tests__/scripted-provider/delegate-child-guard.test.ts +0 -631
  43. package/src/__tests__/scripted-provider/delegate-guard-provider.ts +0 -403
  44. package/src/__tests__/scripted-provider/follow-up.test.ts +0 -448
  45. package/src/__tests__/scripted-provider/fusion-output-recovery.test.ts +0 -132
  46. package/src/__tests__/scripted-provider/fusion-reason.test.ts +0 -310
  47. package/src/__tests__/scripted-provider/fusion-runtime-guard.test.ts +0 -163
  48. package/src/__tests__/scripted-provider/hook-contract-provider.ts +0 -179
  49. package/src/__tests__/scripted-provider/hook-probe-a.ts +0 -3
  50. package/src/__tests__/scripted-provider/hook-probe-b.ts +0 -3
  51. package/src/__tests__/scripted-provider/hook-probe-extension.ts +0 -126
  52. package/src/__tests__/scripted-provider/output-recovery-provider.ts +0 -153
  53. package/src/__tests__/scripted-provider/pi-hook-contract-evidence.json +0 -18
  54. package/src/__tests__/scripted-provider/pi-hook-contract.test.ts +0 -477
  55. package/src/__tests__/scripted-provider/runtime-guard-probe.ts +0 -28
  56. package/src/__tests__/scripted-provider/runtime-guard-provider.ts +0 -49
  57. package/src/__tests__/scripted-provider/scripted-provider-extension.ts +0 -408
  58. package/src/__tests__/task-manager.test.ts +0 -479
  59. package/src/__tests__/windows-taskkill.test.ts +0 -161
@@ -1,205 +0,0 @@
1
- import { describe, it } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { Theme, type ThemeColor } from '@earendil-works/pi-coding-agent';
4
- import { visibleWidth } from '@earendil-works/pi-tui';
5
- import {
6
- FusionModelSelector,
7
- type FusionModelChoice,
8
- type FusionModelSelectorResult,
9
- } from '../ui/fusion-model-selector.js';
10
- import { CURRENT_MODEL_SELECTION, defaultFusionModelConfig } from '../fusion/config.js';
11
- import type { FusionModelConfigV1 } from '../fusion/types.js';
12
- import { stripAnsi } from './helpers/normalize.js';
13
-
14
- const themeColors: readonly ThemeColor[] = [
15
- 'accent',
16
- 'border',
17
- 'borderAccent',
18
- 'borderMuted',
19
- 'success',
20
- 'error',
21
- 'warning',
22
- 'muted',
23
- 'dim',
24
- 'text',
25
- 'thinkingText',
26
- 'userMessageText',
27
- 'customMessageText',
28
- 'customMessageLabel',
29
- 'toolTitle',
30
- 'toolOutput',
31
- 'mdHeading',
32
- 'mdLink',
33
- 'mdLinkUrl',
34
- 'mdCode',
35
- 'mdCodeBlock',
36
- 'mdCodeBlockBorder',
37
- 'mdQuote',
38
- 'mdQuoteBorder',
39
- 'mdHr',
40
- 'mdListBullet',
41
- 'toolDiffAdded',
42
- 'toolDiffRemoved',
43
- 'toolDiffContext',
44
- 'syntaxComment',
45
- 'syntaxKeyword',
46
- 'syntaxFunction',
47
- 'syntaxVariable',
48
- 'syntaxString',
49
- 'syntaxNumber',
50
- 'syntaxType',
51
- 'syntaxOperator',
52
- 'syntaxPunctuation',
53
- 'thinkingOff',
54
- 'thinkingMinimal',
55
- 'thinkingLow',
56
- 'thinkingMedium',
57
- 'thinkingHigh',
58
- 'thinkingXhigh',
59
- 'bashMode',
60
- ];
61
- const themeBackgrounds = [
62
- 'selectedBg',
63
- 'userMessageBg',
64
- 'customMessageBg',
65
- 'toolPendingBg',
66
- 'toolSuccessBg',
67
- 'toolErrorBg',
68
- ] as const;
69
- type ThemeForegrounds = ConstructorParameters<typeof Theme>[0];
70
- type ThemeBackgrounds = ConstructorParameters<typeof Theme>[1];
71
- const theme = new Theme(
72
- Object.fromEntries(themeColors.map((color) => [color, '#ffffff'])) as ThemeForegrounds,
73
- Object.fromEntries(themeBackgrounds.map((color) => [color, '#000000'])) as ThemeBackgrounds,
74
- 'truecolor',
75
- );
76
-
77
- const choices: readonly FusionModelChoice[] = [
78
- {
79
- value: CURRENT_MODEL_SELECTION,
80
- label: CURRENT_MODEL_SELECTION,
81
- description: 'currently pi-bg/current-model',
82
- available: true,
83
- },
84
- {
85
- value: 'pi-bg/model-one',
86
- label: 'pi-bg/model-one',
87
- description: 'Model One',
88
- available: true,
89
- },
90
- {
91
- value: 'pi-bg/model/two',
92
- label: 'pi-bg/model/two',
93
- description: 'Slash model',
94
- available: true,
95
- },
96
- {
97
- value: 'stale/model-old',
98
- label: 'stale/model-old',
99
- description: 'configured but not currently available',
100
- available: false,
101
- },
102
- ];
103
-
104
- function initialConfig(): FusionModelConfigV1 {
105
- return {
106
- schema_version: 'pi-background-tasks.fusion-models.v1',
107
- candidates: [CURRENT_MODEL_SELECTION, 'stale/model-old', CURRENT_MODEL_SELECTION],
108
- evaluator: CURRENT_MODEL_SELECTION,
109
- merger: CURRENT_MODEL_SELECTION,
110
- };
111
- }
112
-
113
- function selector(save: (config: FusionModelConfigV1) => Promise<void> = () => Promise.resolve()) {
114
- let renders = 0;
115
- let result: FusionModelSelectorResult | undefined;
116
- const instance = new FusionModelSelector({
117
- initialConfig: initialConfig(),
118
- choices,
119
- theme,
120
- onSave: save,
121
- onDone: (value) => {
122
- result = value;
123
- },
124
- onRenderRequest: () => {
125
- renders += 1;
126
- },
127
- });
128
- return {
129
- instance,
130
- get result() {
131
- return result;
132
- },
133
- get renders() {
134
- return renders;
135
- },
136
- };
137
- }
138
-
139
- function assertWidth(lines: readonly string[], width: number): void {
140
- for (const line of lines) assert.ok(visibleWidth(stripAnsi(line)) <= width, line);
141
- }
142
-
143
- void describe('FusionModelSelector component', () => {
144
- void it('renders all five slots, hints current and stale models, and remains width-safe', () => {
145
- const h = selector();
146
- const lines = h.instance.render(62);
147
- const text = stripAnsi(lines.join('\n'));
148
- for (const label of ['Candidate 1', 'Candidate 2', 'Candidate 3', 'Evaluator', 'Merger']) {
149
- assert.match(text, new RegExp(label));
150
- }
151
- assert.match(text, /currently pi-bg\/current-model/);
152
- assert.match(text, /stale\/model-old \(unavailable\)/);
153
- assertWidth(lines, 62);
154
- assertWidth(h.instance.render(24), 24);
155
- });
156
-
157
- void it('opens searchable choices, selects duplicate slash-containing models, resets, saves, and cancels', async () => {
158
- const saved: FusionModelConfigV1[] = [];
159
- const h = selector((config) => {
160
- saved.push(config);
161
- return Promise.resolve();
162
- });
163
- h.instance.handleInput('\r');
164
- h.instance.handleInput('t');
165
- h.instance.handleInput('w');
166
- assert.match(stripAnsi(h.instance.render(80).join('\n')), /pi-bg\/model\/two/);
167
- h.instance.handleInput('\r');
168
- h.instance.handleInput('\x1b[B');
169
- h.instance.handleInput('\r');
170
- h.instance.handleInput('t');
171
- h.instance.handleInput('w');
172
- h.instance.handleInput('\r');
173
- h.instance.handleInput('s');
174
- await new Promise((resolve) => setTimeout(resolve, 0));
175
- const savedConfig = saved[0];
176
- assert.ok(savedConfig, 'selector should save a draft');
177
- assert.deepEqual(savedConfig.candidates, [
178
- 'pi-bg/model/two',
179
- 'pi-bg/model/two',
180
- CURRENT_MODEL_SELECTION,
181
- ]);
182
- assert.equal(h.result?.type, 'saved');
183
-
184
- const reset = selector();
185
- reset.instance.handleInput('r');
186
- reset.instance.handleInput('s');
187
- await new Promise((resolve) => setTimeout(resolve, 0));
188
- const resetResult = reset.result;
189
- assert.ok(resetResult?.type === 'saved');
190
- assert.deepEqual(resetResult.config, defaultFusionModelConfig());
191
-
192
- const cancelled = selector();
193
- cancelled.instance.handleInput('\x1b');
194
- assert.equal(cancelled.result?.type, 'cancelled');
195
- });
196
-
197
- void it('keeps the dialog open and renders the save error when persistence fails', async () => {
198
- const h = selector(() => Promise.reject(new Error('revision conflict')));
199
- h.instance.handleInput('s');
200
- await new Promise((resolve) => setTimeout(resolve, 0));
201
- assert.equal(h.result, undefined);
202
- assert.match(stripAnsi(h.instance.render(80).join('\n')), /revision conflict/);
203
- assert.ok(h.renders > 0);
204
- });
205
- });