@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37
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/CHANGELOG.md +298 -0
- package/README.md +417 -219
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +12 -57
- package/dist/cap.js +20 -160
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +17 -26
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +24 -2
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +79 -12
- package/dist/computers.js +147 -28
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -24
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +3 -1
- package/dist/graph-view.js +25 -1
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +36 -2
- package/dist/host-tools.d.ts +9 -10
- package/dist/host-tools.js +7 -7
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +124 -6
- package/dist/learn/commit.d.ts +43 -7
- package/dist/learn/commit.js +166 -22
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +37 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +22 -1
- package/dist/learn/grade.js +107 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +14 -2
- package/dist/learn/reflect.js +54 -30
- package/dist/learn/skills.d.ts +37 -5
- package/dist/learn/skills.js +60 -7
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +43 -9
- package/dist/learned-workflow.js +128 -37
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +32 -4
- package/dist/learning-routes.js +48 -12
- package/dist/learning-words.d.ts +9 -0
- package/dist/learning-words.js +12 -2
- package/dist/learning.d.ts +39 -19
- package/dist/learning.js +88 -46
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -3
- package/dist/mcp-probe.js +106 -29
- package/dist/mcp-secret-writes.js +8 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +120 -23
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +5 -5
- package/dist/model.js +29 -16
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +586 -64
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +96 -0
- package/dist/place-offers.js +202 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +21 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +16 -9
- package/dist/print.js +15 -17
- package/dist/propose.d.ts +4 -0
- package/dist/propose.js +34 -11
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-launch.d.ts +28 -3
- package/dist/run-launch.js +14 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +8 -5
- package/dist/run-view.js +18 -10
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +39 -8
- package/dist/runner/adapter-loop.js +770 -83
- package/dist/runner/adapter-run-spec.d.ts +36 -7
- package/dist/runner/adapter-run-spec.js +171 -37
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +20 -7
- package/dist/runner/adapters/pi.js +111 -26
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +26 -12
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +27 -3
- package/dist/runner/cli-run-spec.js +198 -74
- package/dist/runner/commands.d.ts +8 -2
- package/dist/runner/commands.js +31 -6
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +87 -18
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +6 -4
- package/dist/runner/harness-loops.js +16 -2
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +35 -6
- package/dist/runner/journal-kinds.js +20 -1
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +37 -1
- package/dist/runner/learning-end.js +115 -14
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +15 -5
- package/dist/runner/learning-loop.d.ts +139 -7
- package/dist/runner/learning-loop.js +369 -32
- package/dist/runner/learning-seed.d.ts +9 -0
- package/dist/runner/learning-seed.js +14 -1
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +16 -1
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +10 -2
- package/dist/runner/loop.js +22 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +38 -6
- package/dist/runner/mcp-claim.d.ts +11 -4
- package/dist/runner/mcp-claim.js +140 -23
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +1 -8
- package/dist/runner/mcp-run.d.ts +6 -4
- package/dist/runner/mcp-run.js +16 -3
- package/dist/runner/metrics.d.ts +15 -2
- package/dist/runner/metrics.js +21 -2
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +60 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +19 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +231 -27
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +7 -2
- package/dist/runner/store-secrets.js +21 -4
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +190 -0
- package/dist/runner/workflow-host.d.ts +24 -3
- package/dist/runner/workflow-host.js +24 -4
- package/dist/runner/workflow-loop.d.ts +6 -3
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +39 -15
- package/dist/runner/workflow-spec.js +143 -40
- package/dist/runs-over-store.d.ts +16 -6
- package/dist/runs-over-store.js +145 -29
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +75 -63
- package/dist/server.js +712 -316
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/deadline.js +9 -5
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +15 -6
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +85 -13
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -47
- package/dist/store/sqlite/run-patch.d.ts +25 -7
- package/dist/store/sqlite/run-patch.js +58 -14
- package/dist/store/sqlite/store.js +331 -59
- package/dist/store/store.d.ts +330 -21
- package/dist/store/store.js +34 -2
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +2 -4
- package/dist/store-reads/cap.js +16 -7
- package/dist/store-reads/decisions.d.ts +3 -3
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +118 -27
- package/dist/store-reads/learning.d.ts +34 -4
- package/dist/store-reads/learning.js +137 -23
- package/dist/store-reads/runs.d.ts +7 -5
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +70 -29
- package/dist/template-eval.js +8 -5
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +30 -1
- package/dist/timeline/timeline.js +29 -13
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +27 -7
- package/dist/tool-budget.js +21 -9
- package/dist/tool-gate.d.ts +23 -10
- package/dist/tool-gate.js +60 -44
- package/dist/tool-plane.d.ts +46 -28
- package/dist/tool-plane.js +73 -31
- package/dist/tools.d.ts +31 -38
- package/dist/tools.js +117 -74
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +26 -6
- package/dist/trigger-signatures.js +44 -8
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +10 -6
- package/dist/triggers.js +37 -7
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/turns.js +16 -1
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +41 -4
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +147 -103
- package/dist/webhooks.js +564 -324
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +113 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +89 -0
- package/dist/workflow/node.js +101 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +32 -0
- package/dist/workflow/pi-versions.js +65 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +77 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +412 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow-run.d.ts +2 -2
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +32 -17
- package/dist/workspace/computer-deps.js +37 -14
- package/dist/workspace/computer-for-claim.d.ts +58 -13
- package/dist/workspace/computer-for-claim.js +267 -26
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +5 -1
- package/dist/workspace/computer-ledger.js +11 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +7 -4
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +45 -11
- package/dist/workspace/resolve-computer.js +72 -14
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +35 -18
- package/dist/workspace/run-tools.js +24 -29
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +19 -21
- package/templates/README.md +9 -6
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/market-monitor/agent.md +1 -1
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/templates/code-review/rules/REVIEW.md +0 -41
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// An agent's cost per run, run after run (GET /agents/{id}/learning/cost): what each run of its cost, what learning added
|
|
2
|
+
// for it, and the path it took, so a person sees the cost fall once a learned workflow does the job, and by how much.
|
|
3
|
+
// Aggregates only: no run's input, answer or tool text. The store's reader (store-reads/learning.ts agentCostOverStore)
|
|
4
|
+
// gives each run's figures and its path (runner/learning-end.ts runPathOf); this module sums its learning and says what the
|
|
5
|
+
// series shows (costSummary), the rule the console, the CLI and the CSV all read. It imports only the errors, so the API
|
|
6
|
+
// document reads its words.
|
|
7
|
+
import { ApiError } from "./errors.js";
|
|
8
|
+
/** The path a run took: `workflow`, a learned workflow finished it alone (its job's only tool calls were learned_workflow
|
|
9
|
+
* calls, each answering, and nothing was said after its first message: the runner's own rule for a run with nothing new
|
|
10
|
+
* to look back on, runner/learning-end.ts onlyLearnedWorkflows); `handed_back`, a learned workflow ran and the agent
|
|
11
|
+
* went on (it failed, escalated, or the agent did more work after it); `agent`, no learned workflow ran. */
|
|
12
|
+
export const RUN_PATHS = ["agent", "handed_back", "workflow"];
|
|
13
|
+
const usd = (value) => Math.round(value * 1e6) / 1e6;
|
|
14
|
+
/** A run's own cost and what learning added for it, from its row's cost (`rowUsd`: the job, its look-back and any turn a
|
|
15
|
+
* person asked of it after), what it kept as it answered (`looked`, none for a run that did not look back) and what its
|
|
16
|
+
* grade spent (`gradeUsd`: its learning run's cost once that run ended, stopped or failed, 0 while it runs or when there
|
|
17
|
+
* is none, null when unknown):
|
|
18
|
+
* - `cost_usd`: the job's own $: its row's cost less its look-back, never under what it had cost when it answered (a
|
|
19
|
+
* later turn's spend is the job's too); its row's cost for a run that did not look back;
|
|
20
|
+
* - `learning_usd`: what learning cost for it: its look-back and its grade, 0 for a run that does not learn; null when
|
|
21
|
+
* either is unknown (a grade that failed or was stopped mid-ask spent what no one knows);
|
|
22
|
+
* - `total_usd`: their sum, the run's all-in $; null when either is. */
|
|
23
|
+
export function runCostOf(rowUsd, looked, gradeUsd = 0) {
|
|
24
|
+
const answered = looked?.answered_at !== undefined;
|
|
25
|
+
const asAnswered = answered ? (looked.job_cost_usd ?? null) : rowUsd;
|
|
26
|
+
const back = answered ? (looked.look_back_usd ?? null) : 0;
|
|
27
|
+
// What the row holds past the answer and its look-back is a later turn's spend, unknown once the row's cost is; with the
|
|
28
|
+
// look-back's cost unknown the two can't be told apart, and the job is what it had cost when it answered.
|
|
29
|
+
const job = !answered || asAnswered === null || back === null ? asAnswered : rowUsd === null ? null : Math.max(asAnswered, rowUsd - back);
|
|
30
|
+
const spent = back === null || gradeUsd === null ? null : back + gradeUsd;
|
|
31
|
+
return { cost_usd: job === null ? null : usd(job), learning_usd: spent === null ? null : usd(spent), total_usd: job === null || spent === null ? null : usd(job + spent) };
|
|
32
|
+
}
|
|
33
|
+
/** The fewest runs after the takeover a "times cheaper" figure needs: fewer say too little. */
|
|
34
|
+
export const CHEAPER_AFTER_RUNS = 20;
|
|
35
|
+
/** The latest runs the route answers by default, and at most. */
|
|
36
|
+
export const COST_RUNS_DEFAULT = 1000;
|
|
37
|
+
export const COST_RUNS_MAX = 10_000;
|
|
38
|
+
export function costSummary(runs) {
|
|
39
|
+
const first = runs.findIndex((run) => run.path === "workflow");
|
|
40
|
+
const mean = (values) => (values.length ? { runs: values.length, mean_usd: usd(values.reduce((a, b) => a + b, 0) / values.length) } : null);
|
|
41
|
+
const before = mean((first < 0 ? runs : runs.slice(0, first)).flatMap((run) => (run.path === "agent" && run.cost_usd !== null ? [run.cost_usd] : [])));
|
|
42
|
+
const after = first < 0 ? null : mean(runs.slice(first).flatMap((run) => (run.total_usd === null ? [] : [run.total_usd])));
|
|
43
|
+
const times = before && after && after.runs >= CHEAPER_AFTER_RUNS && after.mean_usd > 0 ? Math.round((before.mean_usd / after.mean_usd) * 10) / 10 : null;
|
|
44
|
+
return { takeover: first < 0 ? null : { n: runs[first].n, run_id: runs[first].run_id }, before, after, times_cheaper: times };
|
|
45
|
+
}
|
|
46
|
+
/** The series as CSV (RFC 4180, a header line, `\r\n` line ends): one row a run, an unknown figure empty. A text cell that
|
|
47
|
+
* a spreadsheet would read as a formula (one starting with =, +, -, @, a tab or a carriage return) starts with a `'`, so
|
|
48
|
+
* it opens as the text it is. */
|
|
49
|
+
export const COST_CSV_COLUMNS = ["n", "run_id", "started_at", "path", "workflow", "learned_revision", "cost_usd", "learning_usd", "total_usd"];
|
|
50
|
+
export function costCsv(runs) {
|
|
51
|
+
const cell = (value) => {
|
|
52
|
+
const raw = value === null || value === undefined ? "" : String(value);
|
|
53
|
+
const text = typeof value === "string" && /^[=+\-@\t\r]/.test(raw) ? `'${raw}` : raw;
|
|
54
|
+
return /[",\r\n]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text;
|
|
55
|
+
};
|
|
56
|
+
return [COST_CSV_COLUMNS.join(","), ...runs.map((run) => COST_CSV_COLUMNS.map((column) => cell(run[column])).join(","))].map((line) => `${line}\r\n`).join("");
|
|
57
|
+
}
|
|
58
|
+
/** GET /agents/{id}/learning/cost's query: `limit`, an integer from 1 to COST_RUNS_MAX (COST_RUNS_DEFAULT when absent),
|
|
59
|
+
* and `format`, `json` (the default) or `csv`. Anything else is 400. */
|
|
60
|
+
export function learningCostQuery(url) {
|
|
61
|
+
const limitText = url.searchParams.get("limit");
|
|
62
|
+
const limit = limitText === null ? COST_RUNS_DEFAULT : /^[1-9]\d*$/.test(limitText) ? Number(limitText) : NaN;
|
|
63
|
+
if (!(limit >= 1 && limit <= COST_RUNS_MAX))
|
|
64
|
+
throw new ApiError("bad_request", `limit is a whole number from 1 to ${COST_RUNS_MAX}`);
|
|
65
|
+
const format = url.searchParams.get("format") ?? "json";
|
|
66
|
+
if (format !== "json" && format !== "csv")
|
|
67
|
+
throw new ApiError("bad_request", "format is json or csv");
|
|
68
|
+
return { limit, csv: format === "csv" };
|
|
69
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Store } from "./store/store.js";
|
|
2
|
+
/** How many records an agent keeps, newest first. */
|
|
3
|
+
export declare const EVALS_KEPT = 20;
|
|
4
|
+
/** The most jobs one test may count. */
|
|
5
|
+
export declare const EVAL_JOBS_MAX = 10000000;
|
|
6
|
+
/** The longest `name` and `label_source`. */
|
|
7
|
+
export declare const EVAL_TEXT_MAX = 200;
|
|
8
|
+
/** One record: what was posted (`name`, `label_source`, the counts, each side's cost a task, the learned revision), the
|
|
9
|
+
* server's `accuracy` (correct / n) and `ci` (its 95% Wilson interval), each to four places, and when it was recorded. */
|
|
10
|
+
export type LearningEval = {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
label_source: string | null;
|
|
14
|
+
n: number;
|
|
15
|
+
correct: number;
|
|
16
|
+
accuracy: number;
|
|
17
|
+
ci: [number, number];
|
|
18
|
+
cost_per_task_usd: number | null;
|
|
19
|
+
baseline_cost_per_task_usd: number | null;
|
|
20
|
+
learned_revision: string | null;
|
|
21
|
+
recorded_at: string;
|
|
22
|
+
};
|
|
23
|
+
/** The 95% Wilson score interval of `correct` right of `n`, [low, high], each from 0 to 1, to four places: unlike the
|
|
24
|
+
* normal approximation it holds at 0 and at n right and with few jobs. */
|
|
25
|
+
export declare function wilsonOf(n: number, correct: number): [number, number];
|
|
26
|
+
/** A posted record, checked for its shape only: each field that is missing or wrong is 422 input_invalid by field, and
|
|
27
|
+
* nothing is kept. */
|
|
28
|
+
export declare function evalOf(body: unknown, now: Date): LearningEval;
|
|
29
|
+
/** Agent `agentId`'s records, newest recorded first. */
|
|
30
|
+
export declare function evalsOf(store: Store, agentId: string): Promise<LearningEval[]>;
|
|
31
|
+
/** Appends `record` first in agent `agentId`'s records, the latest EVALS_KEPT kept: a compare-and-set, so of two posts at
|
|
32
|
+
* once neither is lost. */
|
|
33
|
+
export declare function recordEval(store: Store, agentId: string, record: LearningEval): Promise<void>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// An agent's eval records (POST and GET /agents/{id}/learning/evals): the counts of a held-out test of what the agent
|
|
2
|
+
// learned, posted by whoever ran it (a bench, a script, a person): `n` jobs it never learned from, `correct` of them right,
|
|
3
|
+
// the cost a task with learning and by hand, where the labels came from and the learned revision it tested. The server
|
|
4
|
+
// computes the accuracy and its 95% Wilson interval from the counts (a caller never sends either), so the console's
|
|
5
|
+
// Learning tab can say how accurate and how cheap the learned agent is, with how many jobs and how sure. A record is only
|
|
6
|
+
// ever what was posted: the server never computes one from the agent's own runs (the jobs it learned from, never held
|
|
7
|
+
// out). Append-only, the latest first and the one shown, the latest EVALS_KEPT kept in the store's settings under the
|
|
8
|
+
// agent's key. Aggregates only: no rows, no inputs.
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
import { invalid } from "./errors.js";
|
|
11
|
+
/** How many records an agent keeps, newest first. */
|
|
12
|
+
export const EVALS_KEPT = 20;
|
|
13
|
+
/** The most jobs one test may count. */
|
|
14
|
+
export const EVAL_JOBS_MAX = 10_000_000;
|
|
15
|
+
/** The longest `name` and `label_source`. */
|
|
16
|
+
export const EVAL_TEXT_MAX = 200;
|
|
17
|
+
const FIELDS = ["name", "label_source", "n", "correct", "cost_per_task_usd", "baseline_cost_per_task_usd", "learned_revision"];
|
|
18
|
+
/** z for a two-sided 95% interval. */
|
|
19
|
+
const Z95 = 1.959963984540054;
|
|
20
|
+
const places = (value) => Math.round(value * 1e4) / 1e4;
|
|
21
|
+
/** The 95% Wilson score interval of `correct` right of `n`, [low, high], each from 0 to 1, to four places: unlike the
|
|
22
|
+
* normal approximation it holds at 0 and at n right and with few jobs. */
|
|
23
|
+
export function wilsonOf(n, correct) {
|
|
24
|
+
const p = correct / n;
|
|
25
|
+
const z2 = Z95 * Z95;
|
|
26
|
+
const over = 1 + z2 / n;
|
|
27
|
+
const centre = (p + z2 / (2 * n)) / over;
|
|
28
|
+
const half = (Z95 * Math.sqrt((p * (1 - p)) / n + z2 / (4 * n * n))) / over;
|
|
29
|
+
return [places(Math.max(0, centre - half)), places(Math.min(1, centre + half))];
|
|
30
|
+
}
|
|
31
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32
|
+
const oneLine = (value) => typeof value === "string" && !!value.trim() && value.length <= EVAL_TEXT_MAX && !/[\u0000-\u001f\u007f]/.test(value);
|
|
33
|
+
const whole = (value, least, most) => Number.isInteger(value) && value >= least && value <= most;
|
|
34
|
+
const dollars = (value) => value === null || (typeof value === "number" && Number.isFinite(value) && value >= 0);
|
|
35
|
+
/** A posted record, checked for its shape only: each field that is missing or wrong is 422 input_invalid by field, and
|
|
36
|
+
* nothing is kept. */
|
|
37
|
+
export function evalOf(body, now) {
|
|
38
|
+
if (!isObject(body))
|
|
39
|
+
throw invalid([{ field: "body", reason: "invalid", message: "the body is a JSON object" }]);
|
|
40
|
+
const issues = [];
|
|
41
|
+
for (const key of Object.keys(body)) {
|
|
42
|
+
const why = key === "accuracy" || key === "ci" ? "the server computes accuracy and ci from n and correct" : `the body takes ${FIELDS.join(", ")}`;
|
|
43
|
+
if (!FIELDS.includes(key))
|
|
44
|
+
issues.push({ field: key, reason: "unknown", message: why });
|
|
45
|
+
}
|
|
46
|
+
const { name, label_source: source = null, n, correct, cost_per_task_usd: cost = null, baseline_cost_per_task_usd: baseline = null, learned_revision: revision = null } = body;
|
|
47
|
+
if (!oneLine(name))
|
|
48
|
+
issues.push({ field: "name", reason: "invalid", message: `name says what ran the test, in one line of at most ${EVAL_TEXT_MAX} characters`, example: "invoice bench, sealed test" });
|
|
49
|
+
if (!(source === null || oneLine(source)))
|
|
50
|
+
issues.push({ field: "label_source", reason: "invalid", message: `label_source says where the right answers came from, in one line of at most ${EVAL_TEXT_MAX} characters, or null`, example: "teacher labels, 87% strict vs people" });
|
|
51
|
+
const jobs = whole(n, 1, EVAL_JOBS_MAX);
|
|
52
|
+
if (!jobs)
|
|
53
|
+
issues.push({ field: "n", reason: "invalid", message: `n is the held-out jobs counted, a whole number from 1 to ${EVAL_JOBS_MAX}`, example: 200 });
|
|
54
|
+
if (!whole(correct, 0, jobs ? n : EVAL_JOBS_MAX))
|
|
55
|
+
issues.push({ field: "correct", reason: "invalid", message: "correct is how many of the n jobs it got right, a whole number from 0 to n", example: 188 });
|
|
56
|
+
if (!dollars(cost))
|
|
57
|
+
issues.push({ field: "cost_per_task_usd", reason: "invalid", message: "cost_per_task_usd is the mean cost a task with learning, in dollars, 0 or more, or null" });
|
|
58
|
+
if (!dollars(baseline))
|
|
59
|
+
issues.push({ field: "baseline_cost_per_task_usd", reason: "invalid", message: "baseline_cost_per_task_usd is the mean cost a task by hand, in dollars, 0 or more, or null" });
|
|
60
|
+
if (!(revision === null || (typeof revision === "string" && /^[0-9a-f]{7,64}$/.test(revision))))
|
|
61
|
+
issues.push({ field: "learned_revision", reason: "invalid", message: "learned_revision is the learning folder's commit it tested (7 to 64 hex characters), or null" });
|
|
62
|
+
if (issues.length)
|
|
63
|
+
throw invalid(issues);
|
|
64
|
+
const [jobsN, right] = [n, correct];
|
|
65
|
+
return {
|
|
66
|
+
id: `eval_${randomUUID()}`,
|
|
67
|
+
name: name.trim(),
|
|
68
|
+
label_source: source === null ? null : source.trim(),
|
|
69
|
+
n: jobsN,
|
|
70
|
+
correct: right,
|
|
71
|
+
accuracy: places(right / jobsN),
|
|
72
|
+
ci: wilsonOf(jobsN, right),
|
|
73
|
+
cost_per_task_usd: cost,
|
|
74
|
+
baseline_cost_per_task_usd: baseline,
|
|
75
|
+
learned_revision: revision,
|
|
76
|
+
recorded_at: now.toISOString(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const keyOf = (agentId) => `learning.evals.${agentId}`;
|
|
80
|
+
const listOf = (value) => (Array.isArray(value) ? value : []);
|
|
81
|
+
/** Agent `agentId`'s records, newest recorded first. */
|
|
82
|
+
export async function evalsOf(store, agentId) {
|
|
83
|
+
return listOf(await store.settings.get(keyOf(agentId)));
|
|
84
|
+
}
|
|
85
|
+
/** Appends `record` first in agent `agentId`'s records, the latest EVALS_KEPT kept: a compare-and-set, so of two posts at
|
|
86
|
+
* once neither is lost. */
|
|
87
|
+
export async function recordEval(store, agentId, record) {
|
|
88
|
+
const key = keyOf(agentId);
|
|
89
|
+
for (;;) {
|
|
90
|
+
const was = await store.settings.get(key);
|
|
91
|
+
const next = [record, ...listOf(was)].slice(0, EVALS_KEPT);
|
|
92
|
+
// putIfAbsent answers what the key holds after: ours, or ours under a post that raced in between (Postgres inserts and reads
|
|
93
|
+
// back in separate calls), so ours is kept when its id is in the list, never when the list merely differs from ours.
|
|
94
|
+
const kept = was === undefined ? listOf(await store.settings.putIfAbsent(key, next)).some((e) => e.id === record.id) : await store.settings.replaceIf(key, was, next);
|
|
95
|
+
if (kept)
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DraftAsk } from "./learn/skills.js";
|
|
2
2
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
import type { DraftDecisions } from "./learn/skills.js";
|
|
3
4
|
import { type ItemStatus, type Learning, type NoteRuns, type Shown } from "./learning.js";
|
|
4
5
|
import type { Impact } from "./learning-run.js";
|
|
5
6
|
import { type LearnedUse } from "./store-reads/learning.js";
|
|
@@ -27,10 +28,15 @@ type NoteView = {
|
|
|
27
28
|
};
|
|
28
29
|
};
|
|
29
30
|
/** When a retired note, skill or draft was retired, and by whom: a person (its retire's commit), else a run. */
|
|
31
|
+
/** Who retired a retired item, and when, and `from`, the status its restore gives back; or, for a skill or draft that
|
|
32
|
+
* reads retired only because its file can't be read (its front matter reads no way: unclearFront, read from its file as
|
|
33
|
+
* the view is made), that no one did: the host could not read it (`why`), with no `from`, since its restore waits for
|
|
34
|
+
* the file to be fixed. One closed shape. */
|
|
30
35
|
type Retired = {
|
|
31
36
|
at: string;
|
|
32
|
-
by: "person" | "run";
|
|
33
|
-
from
|
|
37
|
+
by: "person" | "run" | "host";
|
|
38
|
+
from?: "active" | "pending";
|
|
39
|
+
why?: "unreadable";
|
|
34
40
|
};
|
|
35
41
|
/** The newest change to a note, skill or draft (its file: the note, a SKILL.md, a draft's README.md): what it was, by
|
|
36
42
|
* whom and when. A person's is named by its commit (`learning: <kind> by a person: <file>`); a run's merge is `learned`. */
|
|
@@ -107,6 +113,26 @@ export declare function agentLearning(data: string, agentId: string, shown: Show
|
|
|
107
113
|
export declare function learningNotes(data: string, agentId: string, query: URLSearchParams, shown: Shown, runs?: NoteRuns): Promise<Page<NoteView>>;
|
|
108
114
|
/** GET /agents/{id}/learning/log?cursor=&limit=: a page of the changes on main, newest first. */
|
|
109
115
|
export declare function learningLog(data: string, agentId: string, query: URLSearchParams, shown: Shown): Promise<Page<Change>>;
|
|
116
|
+
/** One revision of a learned workflow: a commit on main that changed its workflow.json, with that commit's text (null
|
|
117
|
+
* when the commit holds no such file: it was deleted there), cut of the host's secrets. */
|
|
118
|
+
type WorkflowRevision = {
|
|
119
|
+
commit: string;
|
|
120
|
+
at: string;
|
|
121
|
+
by: Change["by"];
|
|
122
|
+
reason: string;
|
|
123
|
+
text: string | null;
|
|
124
|
+
};
|
|
125
|
+
/** GET /agents/{id}/learning/workflows/{name}/revisions?limit=: the latest revisions of learned workflow `name` (the
|
|
126
|
+
* commits on main's log that changed `workflows/<name>/workflow.json`), oldest first, each with the workflow's text at
|
|
127
|
+
* that commit, so a person can step through how it changed. One read-only exec per revision (textsAt), at most `limit`
|
|
128
|
+
* of them. `total` counts every such commit the log holds, `truncated` says the log itself is cut (it keeps the latest
|
|
129
|
+
* LOG_KEEP changes). A workflow no commit of the log changed is not_found. */
|
|
130
|
+
export declare function workflowRevisions(data: string, agentId: string, name: string, query: URLSearchParams, shown: Shown): Promise<{
|
|
131
|
+
name: string;
|
|
132
|
+
revisions: WorkflowRevision[];
|
|
133
|
+
total: number;
|
|
134
|
+
truncated: boolean;
|
|
135
|
+
}>;
|
|
110
136
|
/** GET /agents/{id}/learning/files/{file}: the file on main as text, its ETag, and its type (a draft's workflow.json is
|
|
111
137
|
* JSON). */
|
|
112
138
|
export declare function readNote(data: string, agentId: string, raw: string, shown: Shown): Promise<{
|
|
@@ -146,6 +172,7 @@ export declare function writeNote(data: string, agentId: string, raw: string, in
|
|
|
146
172
|
gated: Record<string, string>;
|
|
147
173
|
deniedBy?: Record<string, "agent" | "server" | "default">;
|
|
148
174
|
ask?: DraftAsk;
|
|
175
|
+
decisions?: DraftDecisions;
|
|
149
176
|
}>;
|
|
150
177
|
}): Promise<{
|
|
151
178
|
status: 200 | 201;
|
|
@@ -175,6 +202,7 @@ export declare function promotable(data: string, agentId: string, raw: string, i
|
|
|
175
202
|
tools: string[];
|
|
176
203
|
gated: Record<string, string>;
|
|
177
204
|
deniedBy?: Record<string, "agent" | "server" | "default">;
|
|
205
|
+
decisions?: DraftDecisions;
|
|
178
206
|
}>;
|
|
179
207
|
}): Promise<Promotable>;
|
|
180
208
|
/** GET /runs/{id}/learning's body, from the run's learning as it reads now, the seed it started from and whether it
|
|
@@ -233,8 +261,8 @@ export declare function runLearningBody(input: {
|
|
|
233
261
|
skills?: import("./learning.js").LearnedFile[];
|
|
234
262
|
workflows?: import("./learning.js").LearnedFile[];
|
|
235
263
|
run: string;
|
|
236
|
-
state: "
|
|
237
|
-
reason: "
|
|
264
|
+
state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
|
|
265
|
+
reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
238
266
|
detail: string | null;
|
|
239
267
|
at: string;
|
|
240
268
|
};
|
package/dist/learning-routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { approve, buildIndex, CAPS, checkNote, draftProblems, frontKeys, INDEX_FILE, INDEX_LINES, isHeld, LEARNED_KEYS, learnedName, learnedPlace, learnedStatus, NOTE_FILE, NOTE_STATUSES, parseNoteFile, printable, released, retire, retiredLearned, skillProblems, SKILLS_DIR, supersede, UNCLEAR_FRONT, unstorable, WORKFLOWS_DIR, restorable, restore, restoredLearned } from "./learn/index.js";
|
|
2
|
-
import { blobOid, FolderBusy, FolderRefused, FolderTooLarge, FolderUnreadable, heldOnMain, isBodyMismatch, readLearning, PATCH_CAP, readRunDiff, readSnapshot, snapshotNotes, writeLearning } from "./learn/folder.js";
|
|
1
|
+
import { approve, buildIndex, CAPS, checkNote, draftProblems, frontKeys, INDEX_FILE, INDEX_LINES, isHeld, LEARNED_KEYS, learnedName, learnedPlace, learnedStatus, NOTE_FILE, NOTE_STATUSES, parseNoteFile, printable, released, retire, retiredLearned, skillProblems, SKILLS_DIR, supersede, UNCLEAR_FRONT, unstorable, WORKFLOWS_DIR, unclearFront, restorable, restore, restoredLearned } from "./learn/index.js";
|
|
2
|
+
import { blobOid, FolderBusy, FolderRefused, FolderTooLarge, FolderUnreadable, heldOnMain, isBodyMismatch, readLearning, PATCH_CAP, readRunDiff, readSnapshot, runDiffKey, snapshotNotes, textsAt, writeLearning } from "./learn/folder.js";
|
|
3
3
|
import { ApiError, invalid } from "./errors.js";
|
|
4
4
|
import { detailShown, learningFolderOf, notesView, reasonShown, secretsShown, withAgentRepo } from "./learning.js";
|
|
5
5
|
import { isObject } from "./validate.js";
|
|
@@ -72,8 +72,8 @@ async function reading(data, agentId, read, none) {
|
|
|
72
72
|
/** A retired item's `retired`: its newest retire by a person; else, one a person made retired another way (an edit to
|
|
73
73
|
* status: retired, or created so), their newest change; else (retired by none of theirs) its newest change's time. */
|
|
74
74
|
/** `from`: the status its restore gives back (its retire recorded it, retired_from; none recorded reads pending, as its
|
|
75
|
-
* restore gives it: only an approval makes an item active). */
|
|
76
|
-
const retiredOf = (history, from) => ({ ...(history.retire ? { at: history.retire.at, by: "person" } : history.person ? { at: history.person.at, by: "person" } : { at: history.at, by: "run" }), from: from ?? "pending" });
|
|
75
|
+
* restore gives it: only an approval makes an item active). `unread`: the host could not read its file. */
|
|
76
|
+
const retiredOf = (history, from, unread = false) => (unread ? { at: history.at, by: "host", why: "unreadable" } : { ...(history.retire ? { at: history.retire.at, by: "person" } : history.person ? { at: history.person.at, by: "person" } : { at: history.at, by: "run" }), from: from ?? "pending" });
|
|
77
77
|
/** A note as the view shows it, cut of the host's secrets: its name and the one that superseded it whole; with its
|
|
78
78
|
* ETag, the one its file's GET answers, so an edit or a retire from the card names the version it shows; its last
|
|
79
79
|
* change, and when and by whom it was retired on a retired one. */
|
|
@@ -82,13 +82,13 @@ const noteView = (note, text, shown, runs) => ({
|
|
|
82
82
|
...(note.history.last ? { last_change: note.history.last } : {}),
|
|
83
83
|
...(note.status === "retired" ? { retired: retiredOf(note.history, note.retired_from) } : {}),
|
|
84
84
|
});
|
|
85
|
-
function learnedView(item, kind, shown) {
|
|
85
|
+
function learnedView(item, kind, shown, unread = false) {
|
|
86
86
|
const file = kind === "skill" ? item.file : `${WORKFLOWS_DIR}/${item.name}/workflow.json`;
|
|
87
87
|
const bytes = item.files.find(({ path }) => path === file)?.bytes ?? item.bytes;
|
|
88
88
|
return {
|
|
89
89
|
name: shown.name(item.name), file: shown.name(file), ...(kind === "workflow" ? { readme: shown.name(item.file) } : {}), description: shown.text(item.description), status: item.status, run: item.run, bytes, etag: etagOf(item.oid),
|
|
90
90
|
...(item.history.last ? { last_change: item.history.last } : {}),
|
|
91
|
-
...(item.status === "retired" ? { retired: retiredOf(item.history, item.retired_from) } : {}),
|
|
91
|
+
...(item.status === "retired" ? { retired: retiredOf(item.history, item.retired_from, unread) } : {}),
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
/** A change on main as the log shows it, cut of the host's secrets. */
|
|
@@ -171,7 +171,10 @@ export async function agentLearning(data, agentId, shown, counts, impact, runs =
|
|
|
171
171
|
return reading(data, agentId, async ({ snapshot, body }) => {
|
|
172
172
|
const index = snapshot.index.bytes ? await body(INDEX_FILE, snapshot.index.oid) : "";
|
|
173
173
|
const notes = await notesPage(snapshot.notes, snapshot.main, 0, NOTES_PAGE, body, shown, runs);
|
|
174
|
-
|
|
174
|
+
// A retired skill or draft whose key file can't be read is said so (unclearFront), read from its file now, as the
|
|
175
|
+
// snapshot's status was: a few retired items, one read each.
|
|
176
|
+
const unread = async (item) => item.status === "retired" && unclearFront(await body(item.file, item.oid));
|
|
177
|
+
return { agent: agentId, main: snapshot.main, index: shown.text(index), notes, skills: await Promise.all(snapshot.skills.map(async (item) => learnedView(item, "skill", shown, await unread(item)))), workflows: await Promise.all(snapshot.workflows.map(async (item) => learnedView(item, "workflow", shown, await unread(item)))), log: logPage(snapshot, 0, LOG_PAGE, shown), counts, impact };
|
|
175
178
|
}, () => ({ agent: agentId, main: null, index: "", notes: EMPTY, skills: [], workflows: [], log: EMPTY, counts, impact }));
|
|
176
179
|
}
|
|
177
180
|
/** GET /agents/{id}/learning/notes?cursor=&limit=&status=: a page of the notes, ordered as the view's. A page at an
|
|
@@ -206,6 +209,38 @@ export async function learningLog(data, agentId, query, shown) {
|
|
|
206
209
|
return logPage(page.snapshot, page.offset, limit, shown);
|
|
207
210
|
}, () => EMPTY);
|
|
208
211
|
}
|
|
212
|
+
/** The most revisions a workflow's history answers, and its default. */
|
|
213
|
+
const REVISIONS_MAX = 50;
|
|
214
|
+
const REVISIONS_DEFAULT = 20;
|
|
215
|
+
/** GET /agents/{id}/learning/workflows/{name}/revisions?limit=: the latest revisions of learned workflow `name` (the
|
|
216
|
+
* commits on main's log that changed `workflows/<name>/workflow.json`), oldest first, each with the workflow's text at
|
|
217
|
+
* that commit, so a person can step through how it changed. One read-only exec per revision (textsAt), at most `limit`
|
|
218
|
+
* of them. `total` counts every such commit the log holds, `truncated` says the log itself is cut (it keeps the latest
|
|
219
|
+
* LOG_KEEP changes). A workflow no commit of the log changed is not_found. */
|
|
220
|
+
export async function workflowRevisions(data, agentId, name, query, shown) {
|
|
221
|
+
if (!learnedName("workflow", name))
|
|
222
|
+
throw new ApiError("bad_request", "A workflow's folder is named with lowercase letters, digits, dashes and underscores.");
|
|
223
|
+
const given = query.get("limit");
|
|
224
|
+
const limit = given === null ? REVISIONS_DEFAULT : Number(given);
|
|
225
|
+
if ((given !== null && !/^\d+$/.test(given)) || limit < 1 || limit > REVISIONS_MAX)
|
|
226
|
+
throw new ApiError("bad_request", `limit is an integer from 1 to ${REVISIONS_MAX}`);
|
|
227
|
+
const path = `${WORKFLOWS_DIR}/${name}/workflow.json`;
|
|
228
|
+
if (shown.name(path) !== path)
|
|
229
|
+
throw new ApiError("not_found", "the agent's learning folder has no such workflow");
|
|
230
|
+
const found = await reading(data, agentId, async ({ ws, snapshot }) => {
|
|
231
|
+
const touched = snapshot.log.filter((change) => change.files.includes(path));
|
|
232
|
+
const latest = touched.slice(0, limit).reverse();
|
|
233
|
+
const revisions = [];
|
|
234
|
+
for (const change of latest) {
|
|
235
|
+
const texts = await textsAt(ws, change.commit, [path]).catch((error) => { throw routeFailure(error); });
|
|
236
|
+
revisions.push({ commit: change.commit, at: change.at, by: change.by, reason: shown.text(change.reason), text: texts?.[path] === undefined ? null : shown.text(texts[path]) });
|
|
237
|
+
}
|
|
238
|
+
return { revisions, total: touched.length, truncated: snapshot.log_more };
|
|
239
|
+
}, () => undefined);
|
|
240
|
+
if (!found || !found.total)
|
|
241
|
+
throw new ApiError("not_found", "the agent's learning folder has no such workflow");
|
|
242
|
+
return { name, ...found };
|
|
243
|
+
}
|
|
209
244
|
/** The blob of `file` on the snapshot's main, as a route names it: the index, a note, a skill's SKILL.md, a draft's
|
|
210
245
|
* README.md or workflow.json; undefined when main holds no such file the snapshot names. */
|
|
211
246
|
function blobIn(snapshot, file) {
|
|
@@ -420,9 +455,9 @@ export async function writeNote(data, agentId, raw, input) {
|
|
|
420
455
|
// a restore never brings back a draft no run could run.
|
|
421
456
|
const draft = changes.find(({ path }) => path === `${folder}workflow.json`);
|
|
422
457
|
if (learned.kind !== "skill" && draft && input.draftTools) {
|
|
423
|
-
const { tools, gated, deniedBy, ask } = await input.draftTools();
|
|
458
|
+
const { tools, gated, deniedBy, ask, decisions } = await input.draftTools();
|
|
424
459
|
const dsl = await import("@parcha/agentrun-dsl");
|
|
425
|
-
for (const { rule, detail } of draftProblems(dsl, draft.bytes.toString("utf8"), tools, gated, deniedBy ?? {}, ask))
|
|
460
|
+
for (const { rule, detail } of draftProblems(dsl, draft.bytes.toString("utf8"), tools, gated, deniedBy ?? {}, ask, decisions))
|
|
426
461
|
problems.push(printable({ rule, path: draft.path, detail }, input.refuse));
|
|
427
462
|
}
|
|
428
463
|
if (problems.length)
|
|
@@ -556,8 +591,9 @@ export async function promotable(data, agentId, raw, input) {
|
|
|
556
591
|
problems.push(printable({ rule: "workflow", path: file, detail: "the workflow's folder holds no workflow.json" }, input.refuse));
|
|
557
592
|
const dsl = await import("@parcha/agentrun-dsl");
|
|
558
593
|
if (json && !problems.length) {
|
|
559
|
-
|
|
560
|
-
|
|
594
|
+
// A learned workflow's decision nodes (LS-07) are checked on this server's decision providers, as a restore checks them.
|
|
595
|
+
const { tools, gated, deniedBy, decisions } = await input.draftTools();
|
|
596
|
+
for (const { rule, detail } of draftProblems(dsl, json.text, tools, gated, deniedBy ?? {}, undefined, decisions))
|
|
561
597
|
problems.push(printable({ rule, path: file, detail }, input.refuse));
|
|
562
598
|
}
|
|
563
599
|
if (problems.length)
|
|
@@ -627,7 +663,7 @@ export async function runDiffOverStore(data, store, runId, shown) {
|
|
|
627
663
|
};
|
|
628
664
|
if (end?.merged) {
|
|
629
665
|
const folder = learningFolderOf(data, row.agentId);
|
|
630
|
-
const diff = await readRunDiff(folder.workspace, runId).catch((error) => Promise.reject(routeFailure(error))).finally(() => folder.end());
|
|
666
|
+
const diff = await readRunDiff(folder.workspace, runDiffKey(runId, kept?.round)).catch((error) => Promise.reject(routeFailure(error))).finally(() => folder.end());
|
|
631
667
|
if (!diff || diff.merge !== end.merged)
|
|
632
668
|
throw new ApiError("not_found", "the run's merge is not in its agent's learning folder");
|
|
633
669
|
return { base: diff.parent, head: diff.merge, files: diff.files.map((entry) => ("patch" in entry ? file(entry.path, entry.status, entry.patch) : { path: shown.name(entry.path), status: entry.status, withheld: entry.withheld })) };
|
package/dist/learning-words.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export declare const said: {
|
|
|
52
52
|
/** A run whose only work was its learned workflows, each answering, with nothing said after its first message: it was
|
|
53
53
|
* not asked to look back (runner/learning-end.ts onlyLearnedWorkflows). */
|
|
54
54
|
onlyWorkflow: string;
|
|
55
|
+
/** A run started with `learning: "use"`: it read what its agent learned and kept nothing, as asked. */
|
|
56
|
+
use: string;
|
|
55
57
|
/** A merge whose every item the owner has since retired: nothing it learned is kept now. */
|
|
56
58
|
retiredSince: string;
|
|
57
59
|
/** The run's answer gave its notes, but not in the format asked for, so none was read. */
|
|
@@ -66,6 +68,10 @@ export declare const said: {
|
|
|
66
68
|
* either way: said in one sentence true of both. */
|
|
67
69
|
stale: (problems: readonly Pick<Problem, "rule">[]) => string;
|
|
68
70
|
noBudget: string;
|
|
71
|
+
/** The run's grade did not fit what its cap left (its learning run's cap): not run, so nothing it learned is kept. */
|
|
72
|
+
noRoomToGrade: string;
|
|
73
|
+
/** A grade under a cap whose cost can't be kept within it (its spend or the grade model's price unknown). */
|
|
74
|
+
gradeUncapped: string;
|
|
69
75
|
unknownCost: string;
|
|
70
76
|
stopped: (cause: string) => string;
|
|
71
77
|
};
|
|
@@ -77,6 +83,9 @@ export declare const said: {
|
|
|
77
83
|
* skill X: …"), any other as lost with it ("Not kept, with the skill X: …"). The caller cuts the line of the host's
|
|
78
84
|
* secrets: a name is the run's to choose. */
|
|
79
85
|
export declare function notKept(verdict: Pick<Verdict, "reason" | "items">, lost?: readonly Pick<LearnedFile, "file">[]): string;
|
|
86
|
+
/** The why of a note main already holds the same (a run's new note, or a skill re-filed as one: runner/learning-loop.ts
|
|
87
|
+
* takenOnMain): no change, so no words of a run's learning say it, the merge's own or a read's rebuilt from its verdict. */
|
|
88
|
+
export declare const SAME_NOTE = "The same rule is already one of the agent's notes.";
|
|
80
89
|
/** A run's learning in words as a read says them, whole: what it learned and what waits for the owner's OK, or why the
|
|
81
90
|
* grader kept nothing, said again from its parts (`learned`, `pending`, `verdict`) each cut by `cut` first (the host's
|
|
82
91
|
* secrets as they are now), and the whole line cut again, as notKept's is: a skill's or a workflow's file names it in
|
package/dist/learning-words.js
CHANGED
|
@@ -44,6 +44,7 @@ const RULE_WORDS = {
|
|
|
44
44
|
edited: "a change to a note it had (a new note replaces an old one instead)",
|
|
45
45
|
deleted: "a deleted note",
|
|
46
46
|
exists: "a note under a name already taken",
|
|
47
|
+
duplicate: "a note that says what another one says",
|
|
47
48
|
too_large: `a note over ${CAPS.note / 1024} KB`,
|
|
48
49
|
too_many_notes: `more than ${CAPS.newNotes} new notes`,
|
|
49
50
|
note: "a note whose header is not in shape",
|
|
@@ -125,6 +126,8 @@ export const said = {
|
|
|
125
126
|
/** A run whose only work was its learned workflows, each answering, with nothing said after its first message: it was
|
|
126
127
|
* not asked to look back (runner/learning-end.ts onlyLearnedWorkflows). */
|
|
127
128
|
onlyWorkflow: "Nothing new: the run only ran a learned workflow.",
|
|
129
|
+
/** A run started with `learning: "use"`: it read what its agent learned and kept nothing, as asked. */
|
|
130
|
+
use: "Used what its agent learned; this run keeps nothing.",
|
|
128
131
|
/** A merge whose every item the owner has since retired: nothing it learned is kept now. */
|
|
129
132
|
retiredSince: "What it learned was retired since.",
|
|
130
133
|
/** The run's answer gave its notes, but not in the format asked for, so none was read. */
|
|
@@ -143,6 +146,10 @@ export const said = {
|
|
|
143
146
|
? "Not kept: a note it would replace is gone or was changed since."
|
|
144
147
|
: `Not kept: the agent's notes changed while this run ran (${rulesIn(problems)}).`,
|
|
145
148
|
noBudget: "Skipped: no budget left in this run to look back.",
|
|
149
|
+
/** The run's grade did not fit what its cap left (its learning run's cap): not run, so nothing it learned is kept. */
|
|
150
|
+
noRoomToGrade: "Not graded: no room under the cap.",
|
|
151
|
+
/** A grade under a cap whose cost can't be kept within it (its spend or the grade model's price unknown). */
|
|
152
|
+
gradeUncapped: "Not graded: the grade's cost can't be kept under the cap.",
|
|
146
153
|
unknownCost: "Skipped: this run's spend is unknown, so its budget can't cover looking back.",
|
|
147
154
|
stopped: (cause) => `Not kept: learning stopped (${cause}).`,
|
|
148
155
|
};
|
|
@@ -175,6 +182,9 @@ export function notKept(verdict, lost = []) {
|
|
|
175
182
|
const named = [subject, others.length ? `with ${listed(others)}` : ""].filter(Boolean).join(" ");
|
|
176
183
|
return said_.replace(/^Not kept: /, `Not kept, ${named}: `);
|
|
177
184
|
}
|
|
185
|
+
/** The why of a note main already holds the same (a run's new note, or a skill re-filed as one: runner/learning-loop.ts
|
|
186
|
+
* takenOnMain): no change, so no words of a run's learning say it, the merge's own or a read's rebuilt from its verdict. */
|
|
187
|
+
export const SAME_NOTE = "The same rule is already one of the agent's notes.";
|
|
178
188
|
/** A run's learning in words as a read says them, whole: what it learned and what waits for the owner's OK, or why the
|
|
179
189
|
* grader kept nothing, said again from its parts (`learned`, `pending`, `verdict`) each cut by `cut` first (the host's
|
|
180
190
|
* secrets as they are now), and the whole line cut again, as notKept's is: a skill's or a workflow's file names it in
|
|
@@ -187,10 +197,10 @@ export function wordsOf(learning, cut) {
|
|
|
187
197
|
const waiting = Array.isArray(pending) ? pending.filter((note) => typeof note?.name === "string") : [];
|
|
188
198
|
const files = [...(Array.isArray(learning.skills) ? learning.skills : []), ...(Array.isArray(learning.workflows) ? learning.workflows : [])].filter((file) => typeof file?.file === "string" && typeof file.name === "string");
|
|
189
199
|
if (kept.length || waiting.length || files.length)
|
|
190
|
-
return cut(said.merged(kept.map((note) => ({ name: cut(note.name), supersedes: note.supersedes })), waiting.map((note) => ({ name: cut(note.name) })), files.map((file) => ({ file: file.file, name: cut(file.name), ...(file.pending ? { pending: true } : {}) })), (verdict?.items ?? []).filter((item) => !item.keep && typeof item.why === "string").map((item) => ({ why: cut(item.why) })), Array.isArray(learning.problems) ? learning.problems : []));
|
|
200
|
+
return cut(said.merged(kept.map((note) => ({ name: cut(note.name), supersedes: note.supersedes })), waiting.map((note) => ({ name: cut(note.name) })), files.map((file) => ({ file: file.file, name: cut(file.name), ...(file.pending ? { pending: true } : {}) })), (verdict?.items ?? []).filter((item) => !item.keep && typeof item.why === "string" && item.why !== SAME_NOTE).map((item) => ({ why: cut(item.why) })), Array.isArray(learning.problems) ? learning.problems : []));
|
|
191
201
|
}
|
|
192
202
|
if (learning.state === "dropped" && learning.reason === "grader" && verdict) {
|
|
193
|
-
//
|
|
203
|
+
// the stored `lost` is read as untrusted: an entry out of shape is left out. The whole line is cut again, the names
|
|
194
204
|
// in it included.
|
|
195
205
|
const lost = Array.isArray(learning.lost) ? learning.lost.filter((file) => typeof file?.file === "string") : [];
|
|
196
206
|
return cut(notKept({ reason: cut(verdict.reason), items: (verdict.items ?? []).map((item) => ({ ...item, why: cut(item.why) })) }, lost));
|