@strands-agents/cli 0.4.0 → 0.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/README.md +374 -5
- package/dist/src/agent/backend.js +2 -2
- package/dist/src/agent/backend.js.map +1 -1
- package/dist/src/agent/background.js +9 -1
- package/dist/src/agent/background.js.map +1 -1
- package/dist/src/agent/configuration.js.map +1 -1
- package/dist/src/agent/context.js +5 -1
- package/dist/src/agent/context.js.map +1 -1
- package/dist/src/agent/events.js +2 -0
- package/dist/src/agent/events.js.map +1 -1
- package/dist/src/agent/extension.js +46 -0
- package/dist/src/agent/extension.js.map +1 -0
- package/dist/src/agent/mcp.js +1 -2
- package/dist/src/agent/mcp.js.map +1 -1
- package/dist/src/agent/runtime.js +28 -5
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/cli/acp-events.js +15 -0
- package/dist/src/cli/acp-events.js.map +1 -1
- package/dist/src/cli/acp-python.js +2 -2
- package/dist/src/cli/acp-python.js.map +1 -1
- package/dist/src/cli/acp.js +2 -17
- package/dist/src/cli/acp.js.map +1 -1
- package/dist/src/cli/arguments.js +91 -11
- package/dist/src/cli/arguments.js.map +1 -1
- package/dist/src/cli/console.js +2 -0
- package/dist/src/cli/console.js.map +1 -1
- package/dist/src/cli/invocation.js +10 -2
- package/dist/src/cli/invocation.js.map +1 -1
- package/dist/src/cli/run.js +154 -15
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/cli/telemetry.js.map +1 -1
- package/dist/src/config/settings.js +67 -2
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/store.js +171 -21
- package/dist/src/config/store.js.map +1 -1
- package/dist/src/config/watch.js +24 -0
- package/dist/src/config/watch.js.map +1 -0
- package/dist/src/dev/agent-choices.js +281 -0
- package/dist/src/dev/agent-choices.js.map +1 -0
- package/dist/src/dev/agent-options.js +467 -0
- package/dist/src/dev/agent-options.js.map +1 -0
- package/dist/src/dev/base-cli.js +201 -0
- package/dist/src/dev/base-cli.js.map +1 -0
- package/dist/src/dev/chat-extension.js +42 -0
- package/dist/src/dev/chat-extension.js.map +1 -0
- package/dist/src/dev/create.js +443 -0
- package/dist/src/dev/create.js.map +1 -0
- package/dist/src/dev/errors.js +89 -0
- package/dist/src/dev/errors.js.map +1 -0
- package/dist/src/dev/evals/chat/agent-tools.js +941 -0
- package/dist/src/dev/evals/chat/agent-tools.js.map +1 -0
- package/dist/src/dev/evals/chat/background-flags.js +231 -0
- package/dist/src/dev/evals/chat/background-flags.js.map +1 -0
- package/dist/src/dev/evals/chat/command.js +140 -0
- package/dist/src/dev/evals/chat/command.js.map +1 -0
- package/dist/src/dev/evals/chat/ui-tools.js +252 -0
- package/dist/src/dev/evals/chat/ui-tools.js.map +1 -0
- package/dist/src/dev/evals/chat/workflow-skills.js +48 -0
- package/dist/src/dev/evals/chat/workflow-skills.js.map +1 -0
- package/dist/src/dev/evals/host.js +22 -0
- package/dist/src/dev/evals/host.js.map +1 -0
- package/dist/src/dev/evals/jobs.js +151 -0
- package/dist/src/dev/evals/jobs.js.map +1 -0
- package/dist/src/dev/evals/layout.js +223 -0
- package/dist/src/dev/evals/layout.js.map +1 -0
- package/dist/src/dev/evals/model.js +4 -0
- package/dist/src/dev/evals/model.js.map +1 -0
- package/dist/src/dev/evals/package.js +14 -0
- package/dist/src/dev/evals/package.js.map +1 -0
- package/dist/src/dev/evals/python/entry-files.js +70 -0
- package/dist/src/dev/evals/python/entry-files.js.map +1 -0
- package/dist/src/dev/evals/python/strands_dev_evals/__init__.py +0 -0
- package/dist/src/dev/evals/python/strands_dev_evals/errors.py +2 -0
- package/dist/src/dev/evals/python/strands_dev_evals/harness.py +265 -0
- package/dist/src/dev/evals/python/strands_dev_evals/imports.py +61 -0
- package/dist/src/dev/evals/python/strands_dev_evals/model_effort.py +120 -0
- package/dist/src/dev/evals/python/strands_dev_evals/optimize.py +152 -0
- package/dist/src/dev/evals/python/strands_dev_evals/run.py +55 -0
- package/dist/src/dev/evals/python/strands_dev_evals/space.py +212 -0
- package/dist/src/dev/evals/python/strands_dev_evals/temporary_typescript.py +313 -0
- package/dist/src/dev/evals/runs/background-runs.js +182 -0
- package/dist/src/dev/evals/runs/background-runs.js.map +1 -0
- package/dist/src/dev/evals/runs/environment.js +258 -0
- package/dist/src/dev/evals/runs/environment.js.map +1 -0
- package/dist/src/dev/evals/runs/evals-process.js +157 -0
- package/dist/src/dev/evals/runs/evals-process.js.map +1 -0
- package/dist/src/dev/evals/runs/evaluate.js +288 -0
- package/dist/src/dev/evals/runs/evaluate.js.map +1 -0
- package/dist/src/dev/evals/runs/experiment.js +319 -0
- package/dist/src/dev/evals/runs/experiment.js.map +1 -0
- package/dist/src/dev/evals/runs/layout-migration.js +302 -0
- package/dist/src/dev/evals/runs/layout-migration.js.map +1 -0
- package/dist/src/dev/evals/runs/optimize.js +249 -0
- package/dist/src/dev/evals/runs/optimize.js.map +1 -0
- package/dist/src/dev/evals/runs/typescript-runner-main.js +40 -0
- package/dist/src/dev/evals/runs/typescript-runner-main.js.map +1 -0
- package/dist/src/dev/evals/runs/typescript-runner.js +192 -0
- package/dist/src/dev/evals/runs/typescript-runner.js.map +1 -0
- package/dist/src/dev/evals/sessions/auto-optimize.js +259 -0
- package/dist/src/dev/evals/sessions/auto-optimize.js.map +1 -0
- package/dist/src/dev/evals/sessions/evals-ui.js +232 -0
- package/dist/src/dev/evals/sessions/evals-ui.js.map +1 -0
- package/dist/src/dev/evals/sessions/evaluate-session.js +252 -0
- package/dist/src/dev/evals/sessions/evaluate-session.js.map +1 -0
- package/dist/src/dev/evals/sessions/experiments-session.js +305 -0
- package/dist/src/dev/evals/sessions/experiments-session.js.map +1 -0
- package/dist/src/dev/evals/sessions/optimize-session.js +942 -0
- package/dist/src/dev/evals/sessions/optimize-session.js.map +1 -0
- package/dist/src/dev/evals/sessions/review-run.js +245 -0
- package/dist/src/dev/evals/sessions/review-run.js.map +1 -0
- package/dist/src/dev/evals/sessions/session-converter.js +110 -0
- package/dist/src/dev/evals/sessions/session-converter.js.map +1 -0
- package/dist/src/dev/evals/sessions/sessions.js +81 -0
- package/dist/src/dev/evals/sessions/sessions.js.map +1 -0
- package/dist/src/dev/evals/shell/arguments.js +26 -0
- package/dist/src/dev/evals/shell/arguments.js.map +1 -0
- package/dist/src/dev/evals/shell/cli.js +77 -0
- package/dist/src/dev/evals/shell/cli.js.map +1 -0
- package/dist/src/dev/evals/tuning/apply.js +535 -0
- package/dist/src/dev/evals/tuning/apply.js.map +1 -0
- package/dist/src/dev/evals/tuning/knobs.js +293 -0
- package/dist/src/dev/evals/tuning/knobs.js.map +1 -0
- package/dist/src/dev/evals/tuning/objective.js +273 -0
- package/dist/src/dev/evals/tuning/objective.js.map +1 -0
- package/dist/src/dev/evals/tuning/plan.js +156 -0
- package/dist/src/dev/evals/tuning/plan.js.map +1 -0
- package/dist/src/dev/evals/tuning/study.js +392 -0
- package/dist/src/dev/evals/tuning/study.js.map +1 -0
- package/dist/src/dev/failed-turns.js +31 -0
- package/dist/src/dev/failed-turns.js.map +1 -0
- package/dist/src/dev/file-edits.js +67 -0
- package/dist/src/dev/file-edits.js.map +1 -0
- package/dist/src/dev/fix-in-new-tab.js +151 -0
- package/dist/src/dev/fix-in-new-tab.js.map +1 -0
- package/dist/src/dev/picker.js +498 -0
- package/dist/src/dev/picker.js.map +1 -0
- package/dist/src/dev/prepare.js +526 -0
- package/dist/src/dev/prepare.js.map +1 -0
- package/dist/src/dev/project-setup.js +209 -0
- package/dist/src/dev/project-setup.js.map +1 -0
- package/dist/src/dev/runtime.js +55 -0
- package/dist/src/dev/runtime.js.map +1 -0
- package/dist/src/dev/search.js +466 -0
- package/dist/src/dev/search.js.map +1 -0
- package/dist/src/dev/telemetry.js +30 -0
- package/dist/src/dev/telemetry.js.map +1 -0
- package/dist/src/dev/workspace.js +547 -0
- package/dist/src/dev/workspace.js.map +1 -0
- package/dist/src/model/credential-failure.js +5 -0
- package/dist/src/model/credential-failure.js.map +1 -0
- package/dist/src/model/effort-fields.js +76 -0
- package/dist/src/model/effort-fields.js.map +1 -0
- package/dist/src/model/packages.js +2 -0
- package/dist/src/model/packages.js.map +1 -1
- package/dist/src/model/runtime.js +12 -4
- package/dist/src/model/runtime.js.map +1 -1
- package/dist/src/paths.js +9 -1
- package/dist/src/paths.js.map +1 -1
- package/dist/src/process-lock.js +89 -0
- package/dist/src/process-lock.js.map +1 -0
- package/dist/src/project/archive.js +11 -1
- package/dist/src/project/archive.js.map +1 -1
- package/dist/src/project/export.js +40 -14
- package/dist/src/project/export.js.map +1 -1
- package/dist/src/project/install.js +33 -0
- package/dist/src/project/install.js.map +1 -0
- package/dist/src/project/module-loader.js +36 -0
- package/dist/src/project/module-loader.js.map +1 -1
- package/dist/src/project/portability.js +2 -1
- package/dist/src/project/portability.js.map +1 -1
- package/dist/src/project/preparation-plan.js +182 -0
- package/dist/src/project/preparation-plan.js.map +1 -0
- package/dist/src/project/preparation.js +515 -0
- package/dist/src/project/preparation.js.map +1 -0
- package/dist/src/project/python-runtime.js +234 -0
- package/dist/src/project/python-runtime.js.map +1 -0
- package/dist/src/project/python.js +44 -11
- package/dist/src/project/python.js.map +1 -1
- package/dist/src/project/source.js +12 -7
- package/dist/src/project/source.js.map +1 -1
- package/dist/src/project/state-folder.js +15 -0
- package/dist/src/project/state-folder.js.map +1 -0
- package/dist/src/project/typescript-backend.js +18 -8
- package/dist/src/project/typescript-backend.js.map +1 -1
- package/dist/src/project/typescript-worker.js +14 -0
- package/dist/src/project/typescript-worker.js.map +1 -1
- package/dist/src/project/typescript.js +14 -1
- package/dist/src/project/typescript.js.map +1 -1
- package/dist/src/project/watch.js +37 -6
- package/dist/src/project/watch.js.map +1 -1
- package/dist/src/project/worker.py +168 -14
- package/dist/src/session/desktop-profile.js +4 -0
- package/dist/src/session/desktop-profile.js.map +1 -1
- package/dist/src/session/sessions.js +18 -2
- package/dist/src/session/sessions.js.map +1 -1
- package/dist/src/terminal/npm.js +1 -1
- package/dist/src/terminal/npm.js.map +1 -1
- package/dist/src/terminal/terminal.js +16 -2
- package/dist/src/terminal/terminal.js.map +1 -1
- package/dist/src/terminal/text.js +23 -0
- package/dist/src/terminal/text.js.map +1 -1
- package/dist/src/ui/app.js +17 -6
- package/dist/src/ui/app.js.map +1 -1
- package/dist/src/ui/chat/commands.js +3 -5
- package/dist/src/ui/chat/commands.js.map +1 -1
- package/dist/src/ui/chat/controller.js +405 -38
- package/dist/src/ui/chat/controller.js.map +1 -1
- package/dist/src/ui/chat/conversations.js +88 -10
- package/dist/src/ui/chat/conversations.js.map +1 -1
- package/dist/src/ui/chat/help.js +8 -0
- package/dist/src/ui/chat/help.js.map +1 -1
- package/dist/src/ui/chat/panel-state.js +36 -14
- package/dist/src/ui/chat/panel-state.js.map +1 -1
- package/dist/src/ui/chat/projector.js +10 -0
- package/dist/src/ui/chat/projector.js.map +1 -1
- package/dist/src/ui/chat/runtime.js +106 -9
- package/dist/src/ui/chat/runtime.js.map +1 -1
- package/dist/src/ui/chat/screen.js +215 -55
- package/dist/src/ui/chat/screen.js.map +1 -1
- package/dist/src/ui/chat/state.js +28 -0
- package/dist/src/ui/chat/state.js.map +1 -1
- package/dist/src/ui/chat/transcript-turn.js +15 -3
- package/dist/src/ui/chat/transcript-turn.js.map +1 -1
- package/dist/src/ui/chat/transcript.js +7 -5
- package/dist/src/ui/chat/transcript.js.map +1 -1
- package/dist/src/ui/chat/types.js.map +1 -1
- package/dist/src/ui/chat/view.js +84 -27
- package/dist/src/ui/chat/view.js.map +1 -1
- package/dist/src/ui/clipboard.js +41 -0
- package/dist/src/ui/clipboard.js.map +1 -0
- package/dist/src/ui/footer.js +19 -0
- package/dist/src/ui/footer.js.map +1 -1
- package/dist/src/ui/input.js +18 -0
- package/dist/src/ui/input.js.map +1 -0
- package/dist/src/ui/interaction.js +30 -8
- package/dist/src/ui/interaction.js.map +1 -1
- package/dist/src/ui/panels/dev.js +60 -0
- package/dist/src/ui/panels/dev.js.map +1 -0
- package/dist/src/ui/panels/settings.js +15 -1
- package/dist/src/ui/panels/settings.js.map +1 -1
- package/dist/src/ui/panels/wizard-request-panel.js +356 -0
- package/dist/src/ui/panels/wizard-request-panel.js.map +1 -0
- package/dist/src/ui/panels/wizard-request.js +251 -0
- package/dist/src/ui/panels/wizard-request.js.map +1 -0
- package/dist/src/ui/presentation.js +23 -7
- package/dist/src/ui/presentation.js.map +1 -1
- package/dist/src/ui/run.js +188 -11
- package/dist/src/ui/run.js.map +1 -1
- package/dist/src/ui/setup/providers.js +17 -1
- package/dist/src/ui/setup/providers.js.map +1 -1
- package/dist/src/ui/setup/steps.js +18 -6
- package/dist/src/ui/setup/steps.js.map +1 -1
- package/dist/src/ui/setup/wizard.js +12 -9
- package/dist/src/ui/setup/wizard.js.map +1 -1
- package/dist/src/ui/startup.js +32 -8
- package/dist/src/ui/startup.js.map +1 -1
- package/dist/src/ui/update.js +3 -2
- package/dist/src/ui/update.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { numberProblem, WizardInterruption, } from '../../../ui/panels/wizard-request.js';
|
|
2
|
+
const ANSWER = 'answer';
|
|
3
|
+
const MAX_FIELDS = 24;
|
|
4
|
+
const CONFIRM_OPTIONS = [
|
|
5
|
+
{ value: 'yes', label: 'yes' },
|
|
6
|
+
{ value: 'no', label: 'no' },
|
|
7
|
+
];
|
|
8
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
const stringAt = (value, what) => {
|
|
10
|
+
if (typeof value !== 'string' || !value.trim())
|
|
11
|
+
throw new Error(`${what} must be text.`);
|
|
12
|
+
return value.trim();
|
|
13
|
+
};
|
|
14
|
+
const optionalString = (value, what) => {
|
|
15
|
+
if (value === undefined || value === null)
|
|
16
|
+
return undefined;
|
|
17
|
+
if (typeof value !== 'string')
|
|
18
|
+
throw new Error(`${what} must be text.`);
|
|
19
|
+
return value.trim() || undefined;
|
|
20
|
+
};
|
|
21
|
+
const optionalWhole = (value, what) => {
|
|
22
|
+
if (value === undefined || value === null)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (typeof value !== 'number' || !Number.isInteger(value) || value < 0)
|
|
25
|
+
throw new Error(`${what} must be a whole number of 0 or more.`);
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
const optionAt = (value, what, typed) => {
|
|
29
|
+
if (!isObject(value))
|
|
30
|
+
throw new Error(`${what} must be an object with value and label.`);
|
|
31
|
+
const detail = optionalString(value.detail, `${what}.detail`);
|
|
32
|
+
const unavailable = optionalString(value.unavailable, `${what}.unavailable`);
|
|
33
|
+
if (value.input !== undefined && value.input !== null && typeof value.input !== 'boolean')
|
|
34
|
+
throw new Error(`${what}.input must be true or false.`);
|
|
35
|
+
const input = value.input === true;
|
|
36
|
+
if (input && !typed)
|
|
37
|
+
throw new Error(`${what}.input works only in strands_dev_single_select.`);
|
|
38
|
+
return {
|
|
39
|
+
value: stringAt(value.value, `${what}.value`),
|
|
40
|
+
label: stringAt(value.label, `${what}.label`),
|
|
41
|
+
...(detail === undefined ? {} : { detail }),
|
|
42
|
+
...(unavailable === undefined ? {} : { unavailable }),
|
|
43
|
+
...(input ? { input } : {}),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const optionsAt = (value, typed) => {
|
|
47
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
48
|
+
throw new Error('options must list at least one option.');
|
|
49
|
+
const options = value.map((option, index) => optionAt(option, `options[${index}]`, typed));
|
|
50
|
+
const values = options.map(({ value: name }) => name);
|
|
51
|
+
if (new Set(values).size !== values.length)
|
|
52
|
+
throw new Error('options must not repeat a value.');
|
|
53
|
+
return options;
|
|
54
|
+
};
|
|
55
|
+
const selectedAt = (value, options) => {
|
|
56
|
+
if (value === undefined || value === null)
|
|
57
|
+
return [];
|
|
58
|
+
const picked = (Array.isArray(value) ? value : [value]).map((item, index) => stringAt(item, `selected[${index}]`));
|
|
59
|
+
const unknown = picked.filter((item) => !options.some(({ value: name }) => name === item));
|
|
60
|
+
if (unknown.length > 0)
|
|
61
|
+
throw new Error(`selected names no such option: ${unknown.join(', ')}.`);
|
|
62
|
+
const typed = options.find(({ value: name, input }) => input && picked.includes(name));
|
|
63
|
+
if (typed)
|
|
64
|
+
throw new Error(`selected cannot name an input row: ${typed.value} starts empty.`);
|
|
65
|
+
return picked;
|
|
66
|
+
};
|
|
67
|
+
const selectField = (input, multiple) => {
|
|
68
|
+
const options = optionsAt(input.options, !multiple);
|
|
69
|
+
// A single select is numbered like the skill's list and starts with nothing picked.
|
|
70
|
+
if (!multiple) {
|
|
71
|
+
if (input.selected !== undefined && input.selected !== null)
|
|
72
|
+
throw new Error('A single select starts with nothing picked; leave out selected and keep (Default) in its label.');
|
|
73
|
+
return {
|
|
74
|
+
kind: 'select',
|
|
75
|
+
key: ANSWER,
|
|
76
|
+
options: options.map((option, index) => ({ ...option, label: `${index + 1}. ${option.label}` })),
|
|
77
|
+
multiple,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const selected = selectedAt(input.selected, options);
|
|
81
|
+
return { kind: 'select', key: ANSWER, options, multiple, ...(selected.length === 0 ? {} : { selected }) };
|
|
82
|
+
};
|
|
83
|
+
const numberAt = (value, what) => {
|
|
84
|
+
if (!isObject(value))
|
|
85
|
+
throw new Error(`${what} must be an object with key, label, and value.`);
|
|
86
|
+
const current = optionalWhole(value.value, `${what}.value`);
|
|
87
|
+
const min = optionalWhole(value.min, `${what}.min`);
|
|
88
|
+
const max = optionalWhole(value.max, `${what}.max`);
|
|
89
|
+
const detail = optionalString(value.detail, `${what}.detail`);
|
|
90
|
+
const field = {
|
|
91
|
+
kind: 'number',
|
|
92
|
+
key: stringAt(value.key, `${what}.key`),
|
|
93
|
+
label: stringAt(value.label, `${what}.label`),
|
|
94
|
+
...(current === undefined ? {} : { value: current }),
|
|
95
|
+
...(min === undefined ? {} : { min }),
|
|
96
|
+
...(max === undefined ? {} : { max }),
|
|
97
|
+
...(detail === undefined ? {} : { detail }),
|
|
98
|
+
};
|
|
99
|
+
if (min !== undefined && max !== undefined && min > max)
|
|
100
|
+
throw new Error(`${what}.min must not be above its max.`);
|
|
101
|
+
const problem = current === undefined ? undefined : numberProblem(field, current);
|
|
102
|
+
if (problem)
|
|
103
|
+
throw new Error(`${what}.value does not fit: ${problem}`);
|
|
104
|
+
return field;
|
|
105
|
+
};
|
|
106
|
+
const numberFields = (value) => {
|
|
107
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
108
|
+
throw new Error('fields must list at least one field.');
|
|
109
|
+
if (value.length > MAX_FIELDS)
|
|
110
|
+
throw new Error(`fields can hold at most ${MAX_FIELDS} fields.`);
|
|
111
|
+
const fields = value.map((field, index) => numberAt(field, `fields[${index}]`));
|
|
112
|
+
const keys = fields.map(({ key }) => key);
|
|
113
|
+
if (new Set(keys).size !== keys.length)
|
|
114
|
+
throw new Error('fields must not repeat a key.');
|
|
115
|
+
return fields;
|
|
116
|
+
};
|
|
117
|
+
/** One question, one component: the request the panel renders. */
|
|
118
|
+
const uiRequest = (input, fields) => ({
|
|
119
|
+
name: optionalString(input.title, 'title') ?? 'question',
|
|
120
|
+
question: stringAt(input.question, 'question'),
|
|
121
|
+
fields,
|
|
122
|
+
back: true,
|
|
123
|
+
});
|
|
124
|
+
const reply = (value) => JSON.stringify(value, null, 2);
|
|
125
|
+
const CANCELLED = reply({
|
|
126
|
+
status: 'cancelled',
|
|
127
|
+
detail: 'The developer closed the question without answering. Treat this as a no.',
|
|
128
|
+
});
|
|
129
|
+
// A chat message dropped the question: pass on what it asked and what the developer had entered.
|
|
130
|
+
const interrupted = (input, { entered }) => reply({
|
|
131
|
+
status: 'interrupted',
|
|
132
|
+
question: input.question,
|
|
133
|
+
...(Object.keys(entered).length === 0 ? {} : { unsubmitted: entered[ANSWER] ?? entered }),
|
|
134
|
+
detail: 'Not answered: the developer sent a chat message instead of submitting this question, and the message comes ' +
|
|
135
|
+
'next. unsubmitted is a draft they left on screen, never an answer. Reply to the message in chat and end your ' +
|
|
136
|
+
'turn: call no other tool, start nothing, and do not move on to the next question. If the message or the ' +
|
|
137
|
+
'draft suggests an answer, say how you read it and ask the developer to confirm it.',
|
|
138
|
+
});
|
|
139
|
+
const BACK = reply({
|
|
140
|
+
status: 'back',
|
|
141
|
+
detail: 'The developer went back. Ask the previous question again with their earlier answer selected; at the first question, stop.',
|
|
142
|
+
});
|
|
143
|
+
const COMMON = {
|
|
144
|
+
question: { type: 'string', description: 'What you are asking, in one plain line.' },
|
|
145
|
+
title: { type: 'string', description: 'The name on the top line, such as optimize. Default: question.' },
|
|
146
|
+
};
|
|
147
|
+
const OPTION = {
|
|
148
|
+
type: 'object',
|
|
149
|
+
properties: {
|
|
150
|
+
value: { type: 'string', description: 'What the answer holds when this row is picked.' },
|
|
151
|
+
label: { type: 'string', description: 'The row as the developer reads it.' },
|
|
152
|
+
detail: { type: 'string', description: 'The facts beside the label that decide the pick, such as the default.' },
|
|
153
|
+
unavailable: { type: 'string', description: 'Why this row cannot be picked; it shows and refuses the pick.' },
|
|
154
|
+
},
|
|
155
|
+
required: ['value', 'label'],
|
|
156
|
+
additionalProperties: false,
|
|
157
|
+
};
|
|
158
|
+
const TYPED_OPTION = {
|
|
159
|
+
...OPTION,
|
|
160
|
+
properties: {
|
|
161
|
+
...OPTION.properties,
|
|
162
|
+
input: {
|
|
163
|
+
type: 'boolean',
|
|
164
|
+
description: 'Makes the row a text field, such as a last "something else" or "Your own" row: the developer types in ' +
|
|
165
|
+
'it, and the answer is the typed text instead of the value. It starts empty and cannot be selected.',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
const UI_TOOLS = [
|
|
170
|
+
{
|
|
171
|
+
name: 'strands_dev_single_select',
|
|
172
|
+
description: 'Show the developer a radio list and wait for one pick. Use it when a skill asks to pick one option, such as ' +
|
|
173
|
+
'a numbered list with a (Default). The rows are numbered for you and none starts picked; keep (Default) in the ' +
|
|
174
|
+
'default row\'s label. For "Your own" or "something else", add a last row with input true; the answer is then ' +
|
|
175
|
+
'the typed text, so ask no follow-up.',
|
|
176
|
+
properties: {
|
|
177
|
+
options: { type: 'array', items: TYPED_OPTION, description: 'The rows, in the order the skill lists them.' },
|
|
178
|
+
},
|
|
179
|
+
required: ['options'],
|
|
180
|
+
fields: (input) => [selectField(input, false)],
|
|
181
|
+
answer: (outcome) => outcome[ANSWER],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'strands_dev_multi_select',
|
|
185
|
+
description: 'Show the developer a checkbox list and wait for their picks. Use it when a skill says pick any, pick several, ' +
|
|
186
|
+
'or accepts replies such as "1, 3". Put the defaults in selected. Returns the list of picked values.',
|
|
187
|
+
properties: {
|
|
188
|
+
options: { type: 'array', items: OPTION, description: 'The rows, in the order the skill lists them.' },
|
|
189
|
+
selected: { type: 'array', items: { type: 'string' }, description: 'The values that start checked.' },
|
|
190
|
+
},
|
|
191
|
+
required: ['options'],
|
|
192
|
+
fields: (input) => [selectField(input, true)],
|
|
193
|
+
answer: (outcome) => outcome[ANSWER],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'strands_dev_number_input',
|
|
197
|
+
description: 'Show the developer one whole-number field per setting, all in this one question, and wait for the values. ' +
|
|
198
|
+
'Use it when a skill asks for numbers, such as several budget settings in one message. The fields take digits ' +
|
|
199
|
+
'only, and finishing waits until every value fits its min and max. Returns {key: number} for every field.',
|
|
200
|
+
properties: {
|
|
201
|
+
fields: {
|
|
202
|
+
type: 'array',
|
|
203
|
+
description: 'One row per setting, in the order the skill lists them.',
|
|
204
|
+
items: {
|
|
205
|
+
type: 'object',
|
|
206
|
+
properties: {
|
|
207
|
+
key: { type: 'string', description: 'The name this value comes back under. Unique.' },
|
|
208
|
+
label: { type: 'string', description: 'The short name shown on the left, about 12 characters.' },
|
|
209
|
+
value: { type: 'integer', minimum: 0, description: 'The current value.' },
|
|
210
|
+
min: { type: 'integer', minimum: 0, description: 'The smallest value allowed.' },
|
|
211
|
+
max: { type: 'integer', minimum: 0, description: 'The largest value allowed.' },
|
|
212
|
+
detail: { type: 'string', description: 'What the setting does, shown after the value.' },
|
|
213
|
+
},
|
|
214
|
+
required: ['key', 'label'],
|
|
215
|
+
additionalProperties: false,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
required: ['fields'],
|
|
220
|
+
fields: (input) => numberFields(input.fields),
|
|
221
|
+
answer: (outcome) => outcome,
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'strands_dev_confirm',
|
|
225
|
+
description: 'Ask the developer a yes-or-no question and wait. Use it when a skill asks yes or no. Returns true or false. ' +
|
|
226
|
+
'It is not the approval of a paid run: ask that in chat and wait for the reply in a later turn.',
|
|
227
|
+
properties: {},
|
|
228
|
+
required: [],
|
|
229
|
+
fields: () => [{ kind: 'select', key: ANSWER, options: CONFIRM_OPTIONS, multiple: false, selected: ['yes'] }],
|
|
230
|
+
answer: (outcome) => outcome[ANSWER] === 'yes',
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
/** The tools that put a skill's questions on screen, one component per question. */
|
|
234
|
+
export const uiTools = (broker) => UI_TOOLS.map((tool) => ({
|
|
235
|
+
name: tool.name,
|
|
236
|
+
description: `${tool.description} A cancelled question is a no: do not ask it again or act as if they agreed. Back means ask the previous question again. Interrupted means not answered: reply to the developer's chat message and end the turn.`,
|
|
237
|
+
inputSchema: {
|
|
238
|
+
type: 'object',
|
|
239
|
+
properties: { ...COMMON, ...tool.properties },
|
|
240
|
+
required: ['question', ...tool.required],
|
|
241
|
+
additionalProperties: false,
|
|
242
|
+
},
|
|
243
|
+
run: async (input) => {
|
|
244
|
+
const outcome = await broker().ask(uiRequest(input, tool.fields(input)));
|
|
245
|
+
if (outcome === undefined)
|
|
246
|
+
return CANCELLED;
|
|
247
|
+
if (outcome instanceof WizardInterruption)
|
|
248
|
+
return interrupted(input, outcome);
|
|
249
|
+
return outcome === 'back' ? BACK : reply({ status: 'answered', answer: tool.answer(outcome) });
|
|
250
|
+
},
|
|
251
|
+
}));
|
|
252
|
+
//# sourceMappingURL=ui-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-tools.js","sourceRoot":"","sources":["../../../../../src/dev/evals/chat/ui-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,kBAAkB,GAMnB,MAAM,sCAAsC,CAAA;AAS7C,MAAM,MAAM,GAAG,QAAQ,CAAA;AACvB,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,eAAe,GAA4B;IAC/C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAC9B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;CAC7B,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,KAA4B,EAAyC,EAAE,CACvF,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtE,MAAM,QAAQ,GAAG,CAAC,KAA4B,EAAE,IAAY,EAAU,EAAE;IACtE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,gBAAgB,CAAC,CAAA;IACxF,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;AACrB,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,KAA4B,EAAE,IAAY,EAAsB,EAAE;IACxF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,gBAAgB,CAAC,CAAA;IACvE,OAAO,KAAK,CAAC,IAAI,EAAE,IAAI,SAAS,CAAA;AAClC,CAAC,CAAA;AAED,M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AAW,kNAAkN;IAClP,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE;QAC7C,QAAQ,EAAE,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QACxC,oBAAoB,EAAE,KAAK;KAC5B;IACD,GAAG,EAAE,KAAK,EAAE,KAAK,EAAmB,EAAE;QACpC,MAAM,OAAO,GAAG,MAAM,MAAM,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACxE,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAC3C,IAAI,OAAO,YAAY,kBAAkB;YAAE,OAAO,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC7E,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAChG,CAAC;CACF,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const DEV = `This chat runs in strands dev. Follow the active skill; only these points are specific to strands dev.
|
|
2
|
+
|
|
3
|
+
Each experiment is strands-dev/experiments/<name>/<name>.json, with its runs and optimizations in the same folder. The evals UI shows and edits them in a browser: strands_dev_open_evals_ui opens one. Whenever the skill asks the developer to choose something or to enter numbers, ask it with the strands_dev_ UI tools, one question per call, not as a numbered list in chat. Ask a free-form question on its own in chat. A cancelled question is a no. Run every strands-evals command through the background-evals skill, never from a shell.
|
|
4
|
+
|
|
5
|
+
A command that calls models costs money: name its scope in chat and end the turn, and start it only when the developer approves in a later turn. When strands_dev_status gives fileChanges, say it in each question or message that asks the developer to approve an evaluation or an optimization.`;
|
|
6
|
+
const EXPERIMENT_COMMAND = `# /experiment
|
|
7
|
+
|
|
8
|
+
The developer typed /experiment, and the strands-evals skill is active. ${DEV}
|
|
9
|
+
|
|
10
|
+
Ask which experiment with strands_dev_single_select, with exactly these rows: one per saved experiment from strands_dev_status (the name as label; as detail the case count, and when its lastTest is done, also its passed and total, such as "5 cases · 4 of 5 passed"), then "Run several experiments" with the value several when two or more are saved, then a last row "Create a new experiment" with the value new. Offer no other rows. With no saved experiment, skip the question and create a new one. For "Run several experiments", ask which ones with strands_dev_multi_select, one row per saved experiment with its case count, and the question "Which experiments should run? Each run makes paid model calls." Picking them is the approval: start each at once with strands_dev_run_background run, then say in one line what started. A cancelled question starts nothing.
|
|
11
|
+
|
|
12
|
+
For a saved experiment, ask what to do with it in a second strands_dev_single_select, with the question "What do you want to do with <name>?" and these rows, leaving out a row whose condition does not hold:
|
|
13
|
+
- "View its last report" (value report) as the first row when its lastTest is done, with its passed, total, and score as detail.
|
|
14
|
+
- "Run it again" (value run) when its lastTest is done, otherwise "Run it", with its case count and "makes paid model calls" as detail. Leave it out while its lastTest is running, and say in the question that it is running, with its done and cases.
|
|
15
|
+
- "Edit its cases" (value edit).
|
|
16
|
+
When strands_dev_status gives fileChanges, add it to this question and to the question of "Run several experiments". Picking Run is the approval: start it at once with strands_dev_run_background run, without asking again in chat, then say in one line what started; its progress shows on a line below the chat input. For the report, read it with strands_dev_evaluation_results, give the passed, total, and score in one line, then each failed case in one line with the reason its evaluator gave, and offer strands_dev_open_evals_ui with the report view for the whole of it; do not print the report file. For Edit, call strands_dev_open_file to open it in the editor of the developer, do not print the file in chat, and ask what to change. When it cannot open, give the file path, offer strands_dev_open_evals_ui, and ask in chat what to change.
|
|
17
|
+
|
|
18
|
+
For "Create a new experiment", ask the task straight away in chat: "What should this experiment test? Or say past chats to build the cases from them." Do not ask first how to build it. When the answer asks for past chats or traces, call strands_dev_session_converter and follow the skill it returns. The task, or the choice of past chats, is the only thing to ask. Do not ask about the number of cases, evaluators, the model, or other settings, even where the skill lists them: strands dev picks them. Name the experiment after what it tests, in a few lowercase words joined by dashes (for example refund-policy), not one already saved. Pass the task as --task-description, and say the name and the case count from strands_dev_status newExperiment in the approval message. When the cases are saved, offer to run them.`;
|
|
19
|
+
const OPTIMIZE_COMMAND = `# /optimize
|
|
20
|
+
|
|
21
|
+
The developer typed /optimize, and the optimize skill is active. ${DEV}
|
|
22
|
+
|
|
23
|
+
When the skill asks which experiment to use, call strands_dev_single_select with the question "Which experiment should the run tune?" and one row per saved experiment from strands_dev_status (the name as label, the case count as detail). Do not name experiments in the question or list them in chat; the rows show every one.
|
|
24
|
+
|
|
25
|
+
strands_dev_optimization_plan gives the knobs this agent can tune, the case split, and the budget; use them instead of reading the agent file. Offer exactly the knobs it returns, no others, even where the skill lists more. A list knob such as tools or MCP servers turns each entry on or off; pass --tune KEY for each one picked, such as --tune tools. A knob with notInCall is an option the call leaves out: the run starts it from the strands-harness default, and applying its edit writes the option into the call, so say that in the review. In the constraints question, leave out the skill's list of what can be constrained: no parenthetical of metrics in the question or the rows. Ask the budget in one strands_dev_number_input, one field per setting (steps, candidates, runs, finalists, trials at once), each with the plan's value and min. Any whole number from the min works; the estimate says when the total passes the rollout cap.
|
|
26
|
+
|
|
27
|
+
Print the review in chat in the skill's own format and end the turn; the developer's reply approves it or changes a row. When strands_dev_optimization_plan returns autoAccept, say in the review that the edits will be applied without a diff. When the run finishes, its edits appear on the developer's screen as a diff, and they apply or leave each one there; an applied edit is written and hot-reloaded without you. Report the run in a line or two, the score before and after, and do not print the edit text or ask which edits to apply, even where the skill says to apply the best version when asked. A diff closed without an answer keeps waiting on its line below the chat input; strands_dev_review_optimization puts it back on screen. Call strands_dev_apply_optimization only for edits the developer names in chat. Read a run through strands_dev_status, never the files of its run folder such as best.diff or best.values.json, and do not write the skill's named copy of the experiment: strands dev names every case. Skip the skill's "Resuming a run" section: strands dev continues a stopped run itself. Where the skill says a TypeScript agent's steps are traced, they are not here: strands dev runs a TypeScript agent in its own runner, which records the answer and the token usage but no trace, so an evaluator that reads the trace cannot score it. Explain an incompatible experiment instead of removing its evaluators.`;
|
|
28
|
+
const BACKGROUND_EVALS = `# Run strands-evals in the background
|
|
29
|
+
|
|
30
|
+
strands dev runs strands-evals commands for you with strands_dev_run_background, in its prepared evals environment and with the agent of this workspace. Pass the command (run, optimize run, or generate), the experiment name, and the flags the skill would pass in args; leave out --agent, the experiment file, and the output paths, which strands dev sets. Each run starts at once, shows its progress on a line below the chat input, writes run.log under strands-dev/experiments/<name>/, and posts a notice when it finishes. A run that stopped when strands dev closed continues by itself at the next start, so there is no resume command.
|
|
31
|
+
|
|
32
|
+
Read the results with strands_dev_status and strands_dev_evaluation_results. Stop a run with strands_dev_stop_background only when the developer asks; cancelling the chat turn leaves it running.`;
|
|
33
|
+
/** Runtime-only guidance that the skill commands and plain requests share. */
|
|
34
|
+
export const evalsWorkflowSkills = () => [
|
|
35
|
+
{
|
|
36
|
+
name: 'background-evals',
|
|
37
|
+
description: 'Run strands-evals commands (run, optimize run, generate) in the background inside strands dev, with ' +
|
|
38
|
+
'progress below the chat input. Use it whenever the strands-evals or optimize skill says to run a ' +
|
|
39
|
+
'strands-evals command. Not part of the exported agent.',
|
|
40
|
+
instructions: BACKGROUND_EVALS,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
/** The text that each skill command sends with its skill. */
|
|
44
|
+
export const evalsCommandWorkflows = {
|
|
45
|
+
experiment: EXPERIMENT_COMMAND,
|
|
46
|
+
optimize: OPTIMIZE_COMMAND,
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=workflow-skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-skills.js","sourceRoot":"","sources":["../../../../../src/dev/evals/chat/workflow-skills.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG;;;;oSAIwR,CAAA;AAEpS,MAAM,kBAAkB,GAAG;;0EAE+C,GAAG;;;;;;;;;;kzBAUquB,CAAA;AAElzB,MAAM,gBAAgB,GAAG;;mEAE0C,GAAG;;;;;;84CAMw0C,CAAA;AAE94C,MAAM,gBAAgB,GAAG;;;;mMAI0K,CAAA;AAEnM,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAgC,EAAE,CAAC;IACpE;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,sGAAsG;YACtG,mGAAmG;YACnG,wDAAwD;QAC1D,YAAY,EAAE,gBAAgB;KAC/B;CACF,CAAA;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU,EAAE,kBAAkB;IAC9B,QAAQ,EAAE,gBAAgB;CAClB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const announce = (host, status, text) => {
|
|
2
|
+
host.context?.report(status, text);
|
|
3
|
+
};
|
|
4
|
+
export const evalsLinkText = (host, place, runFolder) => {
|
|
5
|
+
const link = host.evalsLink?.(place, runFolder);
|
|
6
|
+
return link ? `\nevals UI: ${link}` : '';
|
|
7
|
+
};
|
|
8
|
+
export const firstLine = (text) => text
|
|
9
|
+
.split('\n')
|
|
10
|
+
.find((line) => line.trim())
|
|
11
|
+
?.trim() ?? text;
|
|
12
|
+
export const plural = (count, word) => `${count} ${word}${count === 1 ? '' : 's'}`;
|
|
13
|
+
const FILE_TOOLS = new Set(['shell', 'write', 'edit']);
|
|
14
|
+
const listed = new Intl.ListFormat('en', { type: 'conjunction' });
|
|
15
|
+
export const evalsFileChangeWarning = ({ workspace, agent }) => {
|
|
16
|
+
const tools = [...new Set((agent().tools ?? []).map(({ name }) => name).filter((name) => FILE_TOOLS.has(name)))];
|
|
17
|
+
if (tools.length === 0)
|
|
18
|
+
return undefined;
|
|
19
|
+
return (`Evaluations and optimizations run this agent in ${workspace.root}, and its ${listed.format(tools)} ` +
|
|
20
|
+
`${tools.length === 1 ? 'tool' : 'tools'} can change files there.`);
|
|
21
|
+
};
|
|
22
|
+
//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AG,CAAC,EAAE,SAAS,EAAE,KAAK,EAAoB,EAAsB,EAAE;IACnG,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAChH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACxC,OAAO,CACL,mDAAmD,SAAS,CAAC,IAAI,aAAa,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG;QACrG,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,0BAA0B,CACnE,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { open, readdir } from 'node:fs/promises';
|
|
2
|
+
import { isRecord } from '../../values.js';
|
|
3
|
+
const TAIL_INTERVAL_MS = 1000;
|
|
4
|
+
const COUNT_INTERVAL_MS = 500;
|
|
5
|
+
const JOB_BATCH_MS = 200;
|
|
6
|
+
export class Store {
|
|
7
|
+
state;
|
|
8
|
+
listeners = new Set();
|
|
9
|
+
constructor(state) {
|
|
10
|
+
this.state = state;
|
|
11
|
+
}
|
|
12
|
+
subscribe = (listener) => {
|
|
13
|
+
this.listeners.add(listener);
|
|
14
|
+
return () => {
|
|
15
|
+
this.listeners.delete(listener);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
snapshot = () => this.state;
|
|
19
|
+
set(next) {
|
|
20
|
+
this.state = next;
|
|
21
|
+
for (const listener of this.listeners)
|
|
22
|
+
listener();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const sameJobs = (left, right) => left.length === right.length &&
|
|
26
|
+
left.every((job, index) => job.id === right[index]?.id &&
|
|
27
|
+
job.label === right[index]?.label &&
|
|
28
|
+
job.done === right[index]?.done &&
|
|
29
|
+
job.total === right[index]?.total &&
|
|
30
|
+
job.waiting === right[index]?.waiting);
|
|
31
|
+
export const evalsJobsFeed = (store, jobsOf) => {
|
|
32
|
+
let state = store.snapshot();
|
|
33
|
+
let jobs = jobsOf(state);
|
|
34
|
+
const snapshot = () => {
|
|
35
|
+
const latest = store.snapshot();
|
|
36
|
+
if (latest === state)
|
|
37
|
+
return jobs;
|
|
38
|
+
state = latest;
|
|
39
|
+
const next = jobsOf(latest);
|
|
40
|
+
if (!sameJobs(next, jobs))
|
|
41
|
+
jobs = next;
|
|
42
|
+
return jobs;
|
|
43
|
+
};
|
|
44
|
+
const subscribe = (listener) => {
|
|
45
|
+
let seen = snapshot();
|
|
46
|
+
let timer;
|
|
47
|
+
let last = 0;
|
|
48
|
+
const unsubscribe = store.subscribe(() => {
|
|
49
|
+
if (snapshot() === seen || timer)
|
|
50
|
+
return;
|
|
51
|
+
timer = setTimeout(() => {
|
|
52
|
+
timer = undefined;
|
|
53
|
+
last = Date.now();
|
|
54
|
+
seen = snapshot();
|
|
55
|
+
listener();
|
|
56
|
+
}, Math.max(0, last + JOB_BATCH_MS - Date.now()));
|
|
57
|
+
timer.unref();
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
unsubscribe();
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
return { subscribe, snapshot };
|
|
65
|
+
};
|
|
66
|
+
export const tailEvalsLines = (path, onLine) => {
|
|
67
|
+
let offset = 0;
|
|
68
|
+
let partial = '';
|
|
69
|
+
let reading = Promise.resolve();
|
|
70
|
+
const read = async () => {
|
|
71
|
+
let handle;
|
|
72
|
+
try {
|
|
73
|
+
handle = await open(path, 'r');
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (isRecord(error) && error.code === 'ENOENT')
|
|
77
|
+
return;
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const { size } = await handle.stat();
|
|
82
|
+
if (size <= offset)
|
|
83
|
+
return;
|
|
84
|
+
const buffer = Buffer.alloc(size - offset);
|
|
85
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
|
|
86
|
+
offset += bytesRead;
|
|
87
|
+
const lines = (partial + buffer.subarray(0, bytesRead).toString('utf8')).split('\n');
|
|
88
|
+
partial = lines.pop() ?? '';
|
|
89
|
+
for (const line of lines)
|
|
90
|
+
onLine(line);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
await handle.close();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const tick = () => {
|
|
97
|
+
reading = reading.then(read).catch(() => undefined);
|
|
98
|
+
};
|
|
99
|
+
const timer = setInterval(tick, TAIL_INTERVAL_MS);
|
|
100
|
+
timer.unref();
|
|
101
|
+
tick();
|
|
102
|
+
return {
|
|
103
|
+
stop: async () => {
|
|
104
|
+
clearInterval(timer);
|
|
105
|
+
tick();
|
|
106
|
+
await reading;
|
|
107
|
+
if (partial.trim())
|
|
108
|
+
onLine(partial);
|
|
109
|
+
partial = '';
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export const watchEvalsFileCount = (folder, onCount) => {
|
|
114
|
+
let last = -1;
|
|
115
|
+
const count = async () => {
|
|
116
|
+
try {
|
|
117
|
+
const found = (await readdir(folder)).filter((name) => name.endsWith('.json')).length;
|
|
118
|
+
if (found !== last) {
|
|
119
|
+
last = found;
|
|
120
|
+
onCount(found);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const timer = setInterval(() => void count(), COUNT_INTERVAL_MS);
|
|
128
|
+
timer.unref();
|
|
129
|
+
void count();
|
|
130
|
+
return () => clearInterval(timer);
|
|
131
|
+
};
|
|
132
|
+
/** One jobs line for several feeds; the snapshot keeps its identity while no part changes. */
|
|
133
|
+
export const mergedJobsFeed = (...feeds) => {
|
|
134
|
+
let parts = feeds.map((feed) => feed.snapshot());
|
|
135
|
+
let jobs = parts.flat();
|
|
136
|
+
return {
|
|
137
|
+
snapshot: () => {
|
|
138
|
+
const next = feeds.map((feed) => feed.snapshot());
|
|
139
|
+
if (next.every((part, index) => part === parts[index]))
|
|
140
|
+
return jobs;
|
|
141
|
+
parts = next;
|
|
142
|
+
jobs = next.flat();
|
|
143
|
+
return jobs;
|
|
144
|
+
},
|
|
145
|
+
subscribe: (listener) => {
|
|
146
|
+
const stops = feeds.map((feed) => feed.subscribe(listener));
|
|
147
|
+
return () => stops.forEach((stop) => stop());
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../../../src/dev/evals/jobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAC7B,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAC7B,MAAM,YAAY,GAAG,GAAG,CAAA;AAOxB,MAAM,OAAO,KAAK;IAGI;IAFH,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;IAElD,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAE3B,SAAS,GAAG,CAAC,QAAoB,EAAgB,EAAE;QAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC5B,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QA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