@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35
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 +368 -0
- package/README.md +341 -208
- package/dist/adapters.d.ts +3 -4
- package/dist/adapters.js +18 -15
- package/dist/agent-rows.d.ts +99 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +75 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/archil-settings.d.ts +11 -1
- package/dist/archil-settings.js +10 -0
- package/dist/bash-read-only.d.ts +35 -0
- package/dist/bash-read-only.js +778 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +95 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/budget.d.ts +0 -5
- package/dist/budget.js +0 -5
- package/dist/cap.d.ts +14 -8
- package/dist/cap.js +19 -9
- package/dist/cli.js +71 -18
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -54
- package/dist/computer-setting.d.ts +20 -3
- package/dist/computer-setting.js +58 -10
- package/dist/computers.d.ts +35 -2
- package/dist/computers.js +72 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-B7NKTU8E.css +1 -0
- package/dist/console/assets/index-CXZMgJE7.js +550 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +1 -2
- package/dist/errors.js +9 -9
- package/dist/explain.js +3 -1
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +6 -2
- package/dist/github.js +5 -3
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +9 -16
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +8 -2
- package/dist/learn/check.js +85 -31
- package/dist/learn/folder.d.ts +11 -4
- package/dist/learn/folder.js +17 -19
- package/dist/learn/grade.d.ts +18 -1
- package/dist/learn/grade.js +108 -14
- package/dist/learn/index.d.ts +5 -5
- package/dist/learn/index.js +5 -5
- package/dist/learn/learning.sh +1 -14
- package/dist/learn/notes.d.ts +14 -3
- package/dist/learn/notes.js +16 -6
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +83 -6
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +159 -18
- package/dist/learn/skills.js +644 -64
- package/dist/learned-nodes.d.ts +14 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +41 -6
- package/dist/learned-workflow.js +153 -18
- package/dist/learning-routes.d.ts +49 -4
- package/dist/learning-routes.js +113 -31
- package/dist/learning-run.d.ts +16 -31
- package/dist/learning-run.js +31 -38
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +91 -97
- package/dist/learning.js +176 -320
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +17 -49
- package/dist/mcp-gateway.js +55 -136
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +18 -18
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +9 -7
- package/dist/model.js +51 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +156 -58
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +26 -61
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/port-models.d.ts +10 -3
- package/dist/port-models.js +26 -6
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +80 -45
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +21 -2
- package/dist/run-launch.js +14 -5
- package/dist/run-learning-served.d.ts +21 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +5 -3
- package/dist/run-reads-over-store.js +25 -14
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +27 -6
- package/dist/run-view.d.ts +37 -22
- package/dist/run-view.js +85 -38
- package/dist/runnable.d.ts +21 -10
- package/dist/runnable.js +35 -12
- package/dist/runner/adapter-loop.d.ts +36 -5
- package/dist/runner/adapter-loop.js +663 -69
- package/dist/runner/adapter-run-spec.d.ts +42 -8
- package/dist/runner/adapter-run-spec.js +186 -52
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +40 -2
- package/dist/runner/adapters/pi.js +110 -27
- package/dist/runner/beside.d.ts +38 -3
- package/dist/runner/beside.js +54 -5
- package/dist/runner/claim-secrets.d.ts +16 -1
- package/dist/runner/claim-secrets.js +62 -14
- package/dist/runner/cli-run-spec.d.ts +5 -0
- package/dist/runner/cli-run-spec.js +159 -41
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.d.ts +1 -0
- package/dist/runner/conformance/harness.js +123 -13
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +47 -16
- package/dist/runner/harness-loops.d.ts +15 -2
- package/dist/runner/harness-loops.js +38 -2
- package/dist/runner/journal-kinds.d.ts +60 -6
- package/dist/runner/journal-kinds.js +43 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +194 -20
- package/dist/runner/learning-loop.d.ts +7 -0
- package/dist/runner/learning-loop.js +36 -8
- package/dist/runner/learning-seed.d.ts +6 -0
- package/dist/runner/learning-seed.js +6 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.d.ts +61 -9
- package/dist/runner/main.js +144 -20
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +7 -3
- package/dist/runner/mcp-github.d.ts +11 -2
- package/dist/runner/mcp-github.js +55 -4
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +16 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +46 -1
- package/dist/runner/metrics.js +156 -1
- package/dist/runner/model-route.d.ts +16 -0
- package/dist/runner/model-route.js +134 -10
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +146 -18
- package/dist/runner/spec-holds.d.ts +7 -2
- package/dist/runner/spec-holds.js +4 -3
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-host.d.ts +7 -2
- package/dist/runner/workflow-host.js +3 -1
- package/dist/runner/workflow-loop.d.ts +10 -1
- package/dist/runner/workflow-loop.js +14 -6
- package/dist/runner/workflow-spec.d.ts +21 -0
- package/dist/runner/workflow-spec.js +217 -93
- package/dist/runs-over-store.d.ts +14 -3
- package/dist/runs-over-store.js +100 -23
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +5 -45
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +5 -85
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +37 -56
- package/dist/server.js +322 -134
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +12 -2
- package/dist/store/agent-body.js +22 -4
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +45 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +22 -2
- package/dist/store/postgres/connection.js +211 -41
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +14 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +129 -18
- package/dist/store-reads/learning.d.ts +82 -8
- package/dist/store-reads/learning.js +184 -11
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +19 -1
- package/dist/store-view.js +95 -27
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +33 -14
- package/dist/templates.js +82 -46
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +282 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-budget.d.ts +18 -0
- package/dist/tool-budget.js +50 -0
- package/dist/tool-gate.d.ts +47 -218
- package/dist/tool-gate.js +87 -545
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +23 -52
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +67 -25
- package/dist/tools.js +170 -119
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +83 -10
- package/dist/usage.d.ts +1 -49
- package/dist/usage.js +3 -84
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +33 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/archil-claim.d.ts +2 -2
- package/dist/workspace/archil-claim.js +4 -3
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +16 -0
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +26 -9
- package/dist/workspace/computer-deps.js +144 -43
- package/dist/workspace/computer-for-claim.d.ts +17 -14
- package/dist/workspace/computer-for-claim.js +99 -26
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-ledger.d.ts +1 -8
- package/dist/workspace/computer-ledger.js +0 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +6 -5
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +14 -2
- package/dist/workspace/local.js +170 -43
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +55 -10
- package/dist/workspace/resolve-computer.js +66 -14
- package/dist/workspace/run-tools.d.ts +15 -31
- package/dist/workspace/run-tools.js +19 -30
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +4 -110
- package/package.json +14 -14
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -5
- package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +11 -0
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/propose.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
// Learning, after a run: the notes its end-of-run turn answered with, and a skill or a workflow draft beside them, are read
|
|
2
|
-
// by the host (learn/reflect.ts parseReflection), checked against the commit the run started from (learn/check.ts
|
|
3
|
-
// checkProposal), and kept in the run's own directory as its proposal (`learning-proposal.json`), or dropped. The answer
|
|
4
|
-
// is read from what the run's directory kept as the run settled (learning.ts keepTurn), never from the run's work or its
|
|
5
|
-
// rows, which a follow-up may change; and no file the run wrote is read at all, in `.learning/` or anywhere. The seed is
|
|
6
|
-
// read from the agent's learning folder through its Workspace, as the reflect hook's check reads it (learn/seed-check.ts):
|
|
7
|
-
// the snapshot and its bodies when main is the seed (no exec), else one read-only exec of the learning script at that
|
|
8
|
-
// commit. Nothing is written to git here, and nothing is written at all before the checks pass: what they refuse (a
|
|
9
|
-
// note holding a secret among them) is never kept anywhere.
|
|
10
1
|
import { join } from "node:path";
|
|
11
|
-
import { checkProposal, draftFiles, unstorable, parseReflection, redactSecrets, shortMessage, SKILLS_DIR, WORKFLOWS_DIR } from "./learn/index.js";
|
|
2
|
+
import { checkProposal, draftDryRun, draftFiles, NOTE_BLOCK, unstorable, parseReflection, redactSecrets, shortMessage, SKILL_BLOCK, SKILLS_DIR, WORKFLOW_BLOCK, WORKFLOWS_DIR } from "./learn/index.js";
|
|
12
3
|
import { folderAt, readLearning, readSnapshot } from "./learn/folder.js";
|
|
13
4
|
import { baseOf } from "./learn/seed-check.js";
|
|
14
5
|
import { writeDurable } from "./files.js";
|
|
15
6
|
import { PROPOSAL } from "./learning.js";
|
|
16
|
-
/** The rules that refuse a proposal whole, whatever item they name:
|
|
17
|
-
*
|
|
18
|
-
* not see), which says the run's answer is not to be trusted for any item, and text that is
|
|
19
|
-
* read for one. Every other problem is its item's alone
|
|
20
|
-
|
|
7
|
+
/** The rules that refuse a proposal whole, whatever item they name: a path outside what a run may write, a deletion,
|
|
8
|
+
* the folder's index full (the notes' total, which no one item is past), anything that must never be stored (a secret,
|
|
9
|
+
* a character a reader does not see), which says the run's answer is not to be trusted for any item, and text that is
|
|
10
|
+
* not UTF-8, which cannot be read for one. Every other problem is its item's alone: a count cap names the items past it
|
|
11
|
+
* (learn/check.ts), a size cap the item over it, and they are left out and the rest kept; unstorable reads every item's
|
|
12
|
+
* text whole first. */
|
|
13
|
+
const WHOLE = new Set(["outside", "deleted", "index_full", "secret_value", "secret_shape", "invisible_unicode", "encoding"]);
|
|
21
14
|
/** The item a changed file belongs to: a draft's two files are one item (its folder), every other file is itself. */
|
|
22
15
|
const itemOf = (path) => (path.startsWith(`${WORKFLOWS_DIR}/`) ? path.split("/").slice(0, 2).join("/") : path);
|
|
23
16
|
const utf8 = new TextDecoder("utf-8", { fatal: true });
|
|
@@ -82,14 +75,21 @@ async function seedAt(lw, seed, wanted) {
|
|
|
82
75
|
* `tools`, those a draft may name (tools.ts learnedWorkflowTools); `refuse`: this host's secrets. */
|
|
83
76
|
export const proposeRun = async (input) => {
|
|
84
77
|
const parsed = parseReflection(input.turn.answer);
|
|
85
|
-
// Each skill and draft as the folder would hold it
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
// Each skill and draft as the folder would hold it, keyed by its block (kind and name) so the changes keep the
|
|
79
|
+
// answer's order; a draft is its two files, given together or not at all. A draft's `example:` line, by its
|
|
80
|
+
// workflow.json's path: the input its dry run runs on, never a file's (draftFiles leaves it out of the README).
|
|
81
|
+
const fileGroups = new Map();
|
|
82
|
+
const examples = new Map();
|
|
83
|
+
const keyOf = (kind, name) => `${kind}\u0000${name}`;
|
|
84
|
+
for (const { name, text } of parsed.ok ? (parsed.skills ?? []) : [])
|
|
85
|
+
fileGroups.set(keyOf(SKILL_BLOCK, name), [{ file: `${SKILLS_DIR}/${name}/SKILL.md`, text }]);
|
|
86
|
+
for (const { name, text } of parsed.ok ? (parsed.workflows ?? []) : []) {
|
|
87
|
+
const { json, readme, example } = draftFiles(name, text);
|
|
88
|
+
if (example !== undefined)
|
|
89
|
+
examples.set(`${WORKFLOWS_DIR}/${name}/workflow.json`, example);
|
|
90
|
+
fileGroups.set(keyOf(WORKFLOW_BLOCK, name), [{ file: `${WORKFLOWS_DIR}/${name}/workflow.json`, text: json }, { file: `${WORKFLOWS_DIR}/${name}/README.md`, text: readme }]);
|
|
91
|
+
}
|
|
92
|
+
const given = [...fileGroups.values()];
|
|
93
93
|
// The seed is read whatever the answer: a seed the folder does not hold fails the check.
|
|
94
94
|
const { snapshot, texts } = await seedAt(input.folder, input.seed, () => (parsed.ok ? [...parsed.notes.map(({ file }) => file), ...given.flat().map(({ file }) => file)] : []));
|
|
95
95
|
if (!parsed.ok)
|
|
@@ -97,39 +97,72 @@ export const proposeRun = async (input) => {
|
|
|
97
97
|
const { base, kept } = baseOf(snapshot);
|
|
98
98
|
const held = new Set(base.files);
|
|
99
99
|
const files = given.filter((group) => group.some(({ file, text }) => texts.get(file) !== text)).flat();
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
];
|
|
100
|
+
const changeOf = ({ file, text }) => ({ path: file, status: held.has(file) ? "modified" : "added", mode: "100644", bytes: Buffer.from(text) });
|
|
101
|
+
// Each changed item in the order the answer gave its block, whatever its kind: a count cap names the items past it in
|
|
102
|
+
// that order (learn/check.ts), so a skill the answer led with is never the one past the changed-path cap.
|
|
103
|
+
const noteTexts = new Map(parsed.notes.map(({ file, text }) => [file, text]));
|
|
104
|
+
const changed = new Set(files.map(({ file }) => file));
|
|
105
|
+
const changes = parsed.order.flatMap(({ kind, name }) => {
|
|
106
|
+
if (kind === NOTE_BLOCK) {
|
|
107
|
+
const text = noteTexts.get(name);
|
|
108
|
+
return texts.get(name) !== text ? [changeOf({ file: name, text })] : [];
|
|
109
|
+
}
|
|
110
|
+
return (fileGroups.get(keyOf(kind, name)) ?? []).filter(({ file }) => changed.has(file)).map(changeOf);
|
|
111
|
+
});
|
|
104
112
|
// The workflow DSL reads a draft, and is loaded only when there is one to read.
|
|
105
113
|
const dsl = files.some(({ file }) => file.endsWith("/workflow.json")) ? await import("@parcha/agentrun-dsl") : undefined;
|
|
114
|
+
// A draft's example: the run's own input, so read as every text the run gave is, for what must never be stored (a
|
|
115
|
+
// held secret, a secret's shape): one that holds any refuses the whole answer, said at the draft's README, though it
|
|
116
|
+
// is never written there.
|
|
117
|
+
const exampled = files.filter(({ file }) => examples.has(file)).map(({ file }) => ({ path: file.replace(/workflow\.json$/, "README.md"), status: "added", mode: "100644", bytes: Buffer.from(examples.get(file)) }));
|
|
118
|
+
const leaky = unstorable(exampled, input.refuse);
|
|
119
|
+
if (leaky.length)
|
|
120
|
+
return { state: "dropped", reason: "checker", problems: leaky };
|
|
106
121
|
// A skill or a draft whose seed text has a status is a person's call (retired, or waiting for their OK): never changed.
|
|
107
|
-
const
|
|
122
|
+
const dryRuns = {};
|
|
123
|
+
const check = (some) => checkProposal({ base, changes: some, refuseValues: input.refuse, ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.ask ? { ask: input.ask } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
|
|
124
|
+
// The static checks first, every one (validateWorkflow with executeCode: false, draftProblems' refusal of code nodes,
|
|
125
|
+
// caps, secrets): a draft they refuse is never dry-run, nor is any when they refuse the answer whole. Then each draft
|
|
126
|
+
// left is dry-run on its example, else on a synthesized input (learn/skills.ts draftDryRun): every model and tool
|
|
127
|
+
// answer synthesized, nothing sent, paid or run, and no code it holds run in this process.
|
|
128
|
+
if (dsl) {
|
|
129
|
+
const statics = check(changes).problems;
|
|
130
|
+
const whole = statics.some((problem) => WHOLE.has(problem.rule) || problem.path === undefined);
|
|
131
|
+
const refused = new Set(statics.flatMap((problem) => (problem.path === undefined ? [] : [itemOf(problem.path)])));
|
|
132
|
+
if (!whole)
|
|
133
|
+
for (const { file, text } of files)
|
|
134
|
+
if (file.endsWith("/workflow.json") && !refused.has(itemOf(file)))
|
|
135
|
+
dryRuns[file] = await draftDryRun(dsl, text, examples.get(file));
|
|
136
|
+
}
|
|
108
137
|
// A verdict per item from the checks too: the items a problem names are left out (a draft's two files together),
|
|
109
|
-
// and the rest is checked again; a problem that names no item, or one that refuses the whole (WHOLE),
|
|
110
|
-
// as does a rest
|
|
138
|
+
// and the rest is checked again, until it passes; a problem that names no item, or one that refuses the whole (WHOLE),
|
|
139
|
+
// drops it all, as does a rest with nothing left. A later pass can name what an earlier one did not reach (the
|
|
140
|
+
// supersedes count, asked only of a rest with no other problem); each pass leaves out at least one item, so it ends.
|
|
111
141
|
let checked = check(changes);
|
|
112
142
|
let left = [];
|
|
113
|
-
|
|
143
|
+
const out = new Set();
|
|
114
144
|
if (checked.problems.length) {
|
|
115
145
|
const named = new Set(changes.map(({ path }) => itemOf(path)));
|
|
116
|
-
if (checked.problems.some((problem) => WHOLE.has(problem.rule) || problem.path === undefined || !named.has(itemOf(problem.path))))
|
|
117
|
-
return { state: "dropped", reason: "checker", problems: checked.problems };
|
|
118
146
|
// Before any item is kept from an answer the checks refuse: every name and text it gave, read whole. Something
|
|
119
147
|
// that must never be stored anywhere in it (in an item the checks refused unread, too) refuses it all.
|
|
120
148
|
const never = unstorable(changes, input.refuse);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
149
|
+
for (;;) {
|
|
150
|
+
if (checked.problems.some((problem) => WHOLE.has(problem.rule) || problem.path === undefined || !named.has(itemOf(problem.path))))
|
|
151
|
+
return { state: "dropped", reason: "checker", problems: [...left, ...checked.problems] };
|
|
152
|
+
if (never.length)
|
|
153
|
+
return { state: "dropped", reason: "checker", problems: [...left, ...checked.problems, ...never] };
|
|
154
|
+
left = [...left, ...checked.problems];
|
|
155
|
+
for (const problem of checked.problems)
|
|
156
|
+
out.add(itemOf(problem.path));
|
|
157
|
+
const rest = changes.filter(({ path }) => !out.has(itemOf(path)));
|
|
158
|
+
if (!rest.length)
|
|
159
|
+
return { state: "dropped", reason: "checker", problems: left };
|
|
160
|
+
checked = check(rest);
|
|
161
|
+
if (!checked.problems.length)
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
132
164
|
}
|
|
165
|
+
const passing = files.filter(({ file }) => !out.has(itemOf(file)));
|
|
133
166
|
if (!checked.notes.length && !passing.length)
|
|
134
167
|
return { state: "dropped", reason: "empty" };
|
|
135
168
|
// Each message cut of the host's secrets whole first, and only then shortened: a secret the cut fell inside would
|
|
@@ -138,7 +171,9 @@ export const proposeRun = async (input) => {
|
|
|
138
171
|
const asked = input.turn.asked.map((message) => shortMessage(redactSecrets(message, input.refuse, Number.POSITIVE_INFINITY)));
|
|
139
172
|
// A trigger's input, apart from what the user said, cut and shortened the same way.
|
|
140
173
|
const triggered = (input.turn.triggered ?? []).map(({ source, text }) => ({ source, text: shortMessage(redactSecrets(text, input.refuse, Number.POSITIVE_INFINITY)) }));
|
|
141
|
-
|
|
174
|
+
// How each kept draft's dry run went, for the grader: passed, or not run and why.
|
|
175
|
+
const ran = Object.fromEntries(passing.filter(({ file }) => dryRuns[file]).map(({ file }) => [file, dryRuns[file]]));
|
|
176
|
+
const proposal = { seed: input.seed, notes: checked.notes.map(({ file, text }) => ({ file, text })), ...(passing.length ? { files: passing } : {}), ...(Object.keys(ran).length ? { dryRuns: ran } : {}), asked, ...(triggered.length ? { triggered } : {}) };
|
|
142
177
|
await writeDurable(join(input.runDir, PROPOSAL), `${JSON.stringify(proposal)}\n`);
|
|
143
178
|
const count = (suffix) => passing.filter(({ file }) => file.endsWith(suffix)).length;
|
|
144
179
|
return { state: "proposed", notes: proposal.notes.length, skills: count("/SKILL.md"), workflows: count("/workflow.json"), ...(left.length ? { left } : {}) };
|
package/dist/push-handler.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type PushDeps = {
|
|
|
37
37
|
status: number;
|
|
38
38
|
body: Record<string, unknown>;
|
|
39
39
|
} | undefined>;
|
|
40
|
-
/** A source's sealed setting (sealed-settings.ts): its key, for a scope. */
|
|
40
|
+
/** A source's sealed setting (sealed-settings-store.ts): its key, for a scope. */
|
|
41
41
|
setting(adapterId: string, scope: string, field: string): string | undefined;
|
|
42
42
|
/** A refusal, said: its route and why. */
|
|
43
43
|
refused(route: string, reason: string): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TimelineEvent } from "./timeline/index.js";
|
|
2
|
+
import type { Status } from "./run-view.js";
|
|
3
|
+
/** A run's end-of-run turn: the job's outcome, the newest store entry before the turn and, once the run ended, the newest
|
|
4
|
+
* after it (its rows are those between), its deadline, and how it ended. */
|
|
5
|
+
export type Reflect = {
|
|
6
|
+
outcome: Status;
|
|
7
|
+
after: number;
|
|
8
|
+
until?: number;
|
|
9
|
+
deadline: string;
|
|
10
|
+
ended?: true;
|
|
11
|
+
timedOut?: true;
|
|
12
|
+
};
|
|
13
|
+
/** The run asked its end-of-run turn and has not ended since. */
|
|
14
|
+
export declare const reflecting: (run: {
|
|
15
|
+
meta: {
|
|
16
|
+
reflect?: Reflect;
|
|
17
|
+
};
|
|
18
|
+
}) => boolean;
|
|
19
|
+
/** Whether entry `id` (a number), or the row `id`, is the end-of-run turn's. Before the run has ended every later entry
|
|
20
|
+
* is, and so is a live row. */
|
|
21
|
+
export declare function reflects(reflect: Reflect | undefined, id: string | number): boolean;
|
|
22
|
+
/** `rows` with the end-of-run turn's labelled: never the run's answer (meaningful skips the label), its answer shown as
|
|
23
|
+
* a text row, and its message as the host's, in a person's words (learning-words.ts): what the model is asked stays in
|
|
24
|
+
* the run's store, and no row shows it. */
|
|
25
|
+
export declare function labelled(reflect: Reflect | undefined, rows: TimelineEvent[]): TimelineEvent[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LEARNING_LABEL } from "./learning.js";
|
|
2
|
+
import { said } from "./learning-words.js";
|
|
3
|
+
import { askedForDryRun } from "./learn/reflect.js";
|
|
4
|
+
/** The run asked its end-of-run turn and has not ended since. */
|
|
5
|
+
export const reflecting = (run) => run.meta.reflect !== undefined && run.meta.reflect.until === undefined;
|
|
6
|
+
/** A row's store entry, from its id (`<conversation>:<entry>[:...]`); NaN for a row no entry made (a live one, usage). */
|
|
7
|
+
const entryOf = (id) => Number(id.split(":")[1]);
|
|
8
|
+
/** Whether entry `id` (a number), or the row `id`, is the end-of-run turn's. Before the run has ended every later entry
|
|
9
|
+
* is, and so is a live row. */
|
|
10
|
+
export function reflects(reflect, id) {
|
|
11
|
+
if (!reflect)
|
|
12
|
+
return false;
|
|
13
|
+
const entry = typeof id === "number" ? id : entryOf(id);
|
|
14
|
+
if (Number.isInteger(entry))
|
|
15
|
+
return entry > reflect.after && (reflect.until === undefined || entry <= reflect.until);
|
|
16
|
+
return reflect.until === undefined && typeof id === "string" && id.includes(":live:");
|
|
17
|
+
}
|
|
18
|
+
/** `rows` with the end-of-run turn's labelled: never the run's answer (meaningful skips the label), its answer shown as
|
|
19
|
+
* a text row, and its message as the host's, in a person's words (learning-words.ts): what the model is asked stays in
|
|
20
|
+
* the run's store, and no row shows it. */
|
|
21
|
+
export function labelled(reflect, rows) {
|
|
22
|
+
if (!reflect)
|
|
23
|
+
return rows;
|
|
24
|
+
return rows.map((row) => (!reflects(reflect, row.id) ? row : {
|
|
25
|
+
...row, agent_label: LEARNING_LABEL,
|
|
26
|
+
...(row.kind === "final_answer" ? { kind: "text_block" } : {}),
|
|
27
|
+
// The turn asked again for a draft whose dry run failed says so; every other message of the turn is its ask.
|
|
28
|
+
...(row.kind === "user_message" ? (askedForDryRun(row.text) ? { summary: said.askedDryRun, text: said.askedDryRun } : { summary: said.asked, text: said.asked }) : {}),
|
|
29
|
+
}));
|
|
30
|
+
}
|
package/dist/refusal-words.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export declare const NOT_RUN = "It was not run: nothing was sent and nothing was
|
|
|
3
3
|
/** What a refusal says instead when an earlier attempt of the call may have been sent: an approved call cut mid-flight,
|
|
4
4
|
* or a replay-safe call the kernel runs again after a crash. Never a claim that nothing was charged. */
|
|
5
5
|
export declare const RAN_UNKNOWN = "It had started before the deny, and whether it took effect is not known.";
|
|
6
|
+
/** A call that waited for approval when its run was stopped: withdrawn, never sent (its row's words, and its end's). */
|
|
7
|
+
export declare const STOPPED_WHILE_WAITING = "Not run: the run was stopped while it waited";
|
|
8
|
+
/** A call that waited when its run ended (completed or failed) without anyone stopping it: never sent. */
|
|
9
|
+
export declare const ENDED_WHILE_WAITING = "Not run: the run ended while it waited";
|
|
6
10
|
/** Where a permission was set (permissionFrom's `from`): the agent's own tool settings, the server's, or the default; or
|
|
7
11
|
* "unattended": an ask the agent's approvals "never" allowed. */
|
|
8
12
|
export type SettingFrom = "agent" | "server" | "default" | "unattended";
|
|
@@ -15,7 +19,7 @@ export declare const denyPlace: (from?: SettingFrom) => string;
|
|
|
15
19
|
export declare const deniedText: (tool: string, heldTo?: string, from?: SettingFrom, ran?: "no" | "unknown") => string;
|
|
16
20
|
/** A workflow model node's tool set to ask: a model node cannot wait for a person's approval (the gate parks no workflow
|
|
17
21
|
* call), so the call is refused unrun and the model reads why (tool-gate.ts RunGate, on main and on the runner). */
|
|
18
|
-
export declare const modelNodeAskText: (tool: string) => string;
|
|
22
|
+
export declare const modelNodeAskText: (tool: string, ran?: "no" | "unknown") => string;
|
|
19
23
|
/** A workflow call node's tool set to ask: a call node cannot wait for a person's approval, so it is refused unrun
|
|
20
24
|
* (main's per-run process and the runner's workflow spec, the same words). */
|
|
21
25
|
export declare const callNodeAskText: (tool: string) => string;
|
package/dist/refusal-words.js
CHANGED
|
@@ -5,6 +5,10 @@ export const NOT_RUN = "It was not run: nothing was sent and nothing was charged
|
|
|
5
5
|
/** What a refusal says instead when an earlier attempt of the call may have been sent: an approved call cut mid-flight,
|
|
6
6
|
* or a replay-safe call the kernel runs again after a crash. Never a claim that nothing was charged. */
|
|
7
7
|
export const RAN_UNKNOWN = "It had started before the deny, and whether it took effect is not known.";
|
|
8
|
+
/** A call that waited for approval when its run was stopped: withdrawn, never sent (its row's words, and its end's). */
|
|
9
|
+
export const STOPPED_WHILE_WAITING = "Not run: the run was stopped while it waited";
|
|
10
|
+
/** A call that waited when its run ended (completed or failed) without anyone stopping it: never sent. */
|
|
11
|
+
export const ENDED_WHILE_WAITING = "Not run: the run ended while it waited";
|
|
8
12
|
/** Where a deny was set, in words: the place a person changes it. */
|
|
9
13
|
export const denyPlace = (from = "server") => (from === "agent" ? "for this agent" : from === "default" ? "by default" : "on this server");
|
|
10
14
|
/** The refusal of a call whose tool is set to deny; of one held to another tool's setting (`heldTo`, a shell tool's
|
|
@@ -17,7 +21,7 @@ export const deniedText = (tool, heldTo, from = "server", ran = "no") => {
|
|
|
17
21
|
};
|
|
18
22
|
/** A workflow model node's tool set to ask: a model node cannot wait for a person's approval (the gate parks no workflow
|
|
19
23
|
* call), so the call is refused unrun and the model reads why (tool-gate.ts RunGate, on main and on the runner). */
|
|
20
|
-
export const modelNodeAskText = (tool) => `This ${tool} call needs a person's approval, which a workflow's model node cannot wait for; it was not run
|
|
24
|
+
export const modelNodeAskText = (tool, ran = "no") => `This ${tool} call needs a person's approval, which a workflow's model node cannot wait for; ${ran === "no" ? "it was not run." : `it was not run again. ${RAN_UNKNOWN}`}`;
|
|
21
25
|
/** A workflow call node's tool set to ask: a call node cannot wait for a person's approval, so it is refused unrun
|
|
22
26
|
* (main's per-run process and the runner's workflow spec, the same words). */
|
|
23
27
|
export const callNodeAskText = (tool) => `This ${tool} call needs a person's approval, which a workflow's call node cannot wait for; it was not run.`;
|
package/dist/rows.d.ts
CHANGED
package/dist/run-cut.d.ts
CHANGED
|
@@ -13,12 +13,6 @@ export declare function runCutValues(deps: {
|
|
|
13
13
|
}): Promise<{
|
|
14
14
|
values: string[];
|
|
15
15
|
} | "unreadable">;
|
|
16
|
-
/** Run `runId`'s cut as a function of a text: the one rule its served words are shown by (run-view.ts shownOf: no value
|
|
17
|
-
* of the cut set, in any spelling, and no loopback address), or `unreadable` when the run is withheld. */
|
|
18
|
-
export declare function runCutOf(deps: {
|
|
19
|
-
serverSecrets: () => string[];
|
|
20
|
-
signIns?: SignInReader;
|
|
21
|
-
}, store: Pick<Store, "runs">, runId: string): Promise<((text: string) => string) | "unreadable">;
|
|
22
16
|
/** Run `runId`'s error words: how its error text reads wherever it is served (its view's error, its Timeline's error
|
|
23
17
|
* rows), main's errorWords: a refused key in plain words (key-refusal.ts keyRefusal, the key its harness's route sends
|
|
24
18
|
* by this server's settings and keys), else the text by the one rule (shownOf); `unreadable` when the run is withheld.
|
package/dist/run-cut.js
CHANGED
|
@@ -18,12 +18,6 @@ export async function runCutValues(deps, store, runId, known) {
|
|
|
18
18
|
return "unreadable";
|
|
19
19
|
return { values: [...deps.serverSecrets(), ...handed.refs.filter((ref) => ref.length >= MIN_SECRET)] };
|
|
20
20
|
}
|
|
21
|
-
/** Run `runId`'s cut as a function of a text: the one rule its served words are shown by (run-view.ts shownOf: no value
|
|
22
|
-
* of the cut set, in any spelling, and no loopback address), or `unreadable` when the run is withheld. */
|
|
23
|
-
export async function runCutOf(deps, store, runId) {
|
|
24
|
-
const cut = await runCutValues(deps, store, runId);
|
|
25
|
-
return cut === "unreadable" ? "unreadable" : shownOf(cut.values);
|
|
26
|
-
}
|
|
27
21
|
/** Run `runId`'s error words: how its error text reads wherever it is served (its view's error, its Timeline's error
|
|
28
22
|
* rows), main's errorWords: a refused key in plain words (key-refusal.ts keyRefusal, the key its harness's route sends
|
|
29
23
|
* by this server's settings and keys), else the text by the one rule (shownOf); `unreadable` when the run is withheld.
|
package/dist/run-db.d.ts
CHANGED
|
@@ -3,17 +3,16 @@ import { DatabaseSync } from "node:sqlite";
|
|
|
3
3
|
/** `dropped`: a read of the file alone whose file changed during it, made again (readRunDbSync). */
|
|
4
4
|
export type RunDbOpen = {
|
|
5
5
|
file: string;
|
|
6
|
-
mode: "read" | "
|
|
6
|
+
mode: "read" | "dropped";
|
|
7
7
|
held: boolean;
|
|
8
8
|
};
|
|
9
9
|
/** Tells `observer` of every open of a run's database from here on (tests); the returned call stops it. */
|
|
10
10
|
export declare function observeRunDbOpens(observer: (open: RunDbOpen) => void): () => void;
|
|
11
11
|
/** Tests' seams: `afterPlan`, called between a read's choice of how to open the file and its open; `madeReads`, called
|
|
12
|
-
* with each MonotonicReads made
|
|
12
|
+
* with each MonotonicReads made. */
|
|
13
13
|
export declare const runDbTestHooks: {
|
|
14
14
|
afterPlan?: (file: string) => void;
|
|
15
15
|
madeReads?: (reads: MonotonicReads) => void;
|
|
16
|
-
beforeCheckpoint?: (db: DatabaseSync) => void;
|
|
17
16
|
};
|
|
18
17
|
/** A read of a run's database file alone whose file changed during it (a run's process wrote and a take-back checkpointed
|
|
19
18
|
* meanwhile), every try: none of them is shown. */
|
|
@@ -52,11 +51,3 @@ export declare class MonotonicReads {
|
|
|
52
51
|
/** Forgets run `runId`'s reads: a run that is gone, or whose store was replaced. */
|
|
53
52
|
forget(runId: string): void;
|
|
54
53
|
}
|
|
55
|
-
/** A read-write open of a run's database while a process holds the run: refused, never made. */
|
|
56
|
-
export declare class HeldRunDbError extends Error {
|
|
57
|
-
constructor(file: string);
|
|
58
|
-
}
|
|
59
|
-
/** Checkpoints the run database at `file` into its database file and removes its WAL, once no process holds the run
|
|
60
|
-
* (`held` false; true throws HeldRunDbError before any open). A database with no WAL left is untouched but for the
|
|
61
|
-
* open. The one read-write open the server makes of a run's database. */
|
|
62
|
-
export declare function checkpointRunDb(file: string, held: boolean, platform?: NodeJS.Platform): Promise<void>;
|
package/dist/run-db.js
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
// guard). The one read-write open is the checkpoint when the server takes the run back (runs.ts), with no process left.
|
|
8
8
|
import { closeSync, openSync, readSync, statSync } from "node:fs";
|
|
9
9
|
import { DatabaseSync } from "node:sqlite";
|
|
10
|
-
import {
|
|
11
|
-
import { profilePragmas } from "@parcha/pi-durable-disk/internals";
|
|
10
|
+
import { walHasCommit } from "@parcha/agentrun-pi/durable";
|
|
12
11
|
const observers = new Set();
|
|
13
12
|
/** Tells `observer` of every open of a run's database from here on (tests); the returned call stops it. */
|
|
14
13
|
export function observeRunDbOpens(observer) {
|
|
@@ -33,7 +32,7 @@ function fileMark(file) {
|
|
|
33
32
|
return `${at.ino}:${at.size}:${at.mtimeNs}:${header.toString("hex")}`;
|
|
34
33
|
}
|
|
35
34
|
/** Tests' seams: `afterPlan`, called between a read's choice of how to open the file and its open; `madeReads`, called
|
|
36
|
-
* with each MonotonicReads made
|
|
35
|
+
* with each MonotonicReads made. */
|
|
37
36
|
export const runDbTestHooks = {};
|
|
38
37
|
/** A read of a run's database file alone whose file changed during it (a run's process wrote and a take-back checkpointed
|
|
39
38
|
* meanwhile), every try: none of them is shown. */
|
|
@@ -115,37 +114,3 @@ export class MonotonicReads {
|
|
|
115
114
|
this.#seen.delete(runId);
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
|
-
/** A read-write open of a run's database while a process holds the run: refused, never made. */
|
|
119
|
-
export class HeldRunDbError extends Error {
|
|
120
|
-
constructor(file) {
|
|
121
|
-
super(`the server never opens a run's database read-write while a process holds the run (${file})`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** Checkpoints the run database at `file` into its database file and removes its WAL, once no process holds the run
|
|
125
|
-
* (`held` false; true throws HeldRunDbError before any open). A database with no WAL left is untouched but for the
|
|
126
|
-
* open. The one read-write open the server makes of a run's database. */
|
|
127
|
-
export async function checkpointRunDb(file, held, platform = process.platform) {
|
|
128
|
-
for (const observer of observers)
|
|
129
|
-
observer({ file, mode: "checkpoint", held });
|
|
130
|
-
if (held)
|
|
131
|
-
throw new HeldRunDbError(file);
|
|
132
|
-
const db = new DatabaseSync(file, { timeout: 0 });
|
|
133
|
-
try {
|
|
134
|
-
// As its writer opened it (pi-durable-disk's exclusive profile): the WAL index in heap, so no -shm is made; and on
|
|
135
|
-
// macOS F_FULLFSYNC (`fullfsync`, `checkpoint_fullfsync`), as fsync there leaves the drive's cache unflushed. And
|
|
136
|
-
// synchronous FULL whatever level the run's journal runs at, so the checkpoint's copy is synced into the database file
|
|
137
|
-
// before the WAL that held it is removed (pi-durable-disk barriers.ts lists this store as FULL).
|
|
138
|
-
for (const [pragma, value] of Object.entries(profilePragmas("exclusive", platform, "FULL")))
|
|
139
|
-
db.exec(`PRAGMA ${pragma} = ${value}`);
|
|
140
|
-
db.prepare("SELECT count(*) FROM sqlite_schema").get();
|
|
141
|
-
runDbTestHooks.beforeCheckpoint?.(db);
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
// The close checkpoints: it copies into the database file only pages the WAL holds too, so a lock-free reader still
|
|
145
|
-
// reading the WAL reads the same bytes either way; then it removes the WAL, which a reader that holds it open goes on
|
|
146
|
-
// reading. Never wal_checkpoint(TRUNCATE): that cuts the WAL under such a reader, whose read then fails.
|
|
147
|
-
db.close();
|
|
148
|
-
// The WAL is gone, and with it what was kept of its walk (walHasCommit).
|
|
149
|
-
forgetWalWalk(`${file}-wal`);
|
|
150
|
-
}
|
|
151
|
-
}
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MessageOrigin } from "
|
|
1
|
+
import { type MessageOrigin } from "./timeline/index.js";
|
|
2
2
|
import type { Plane } from "./tool-plane.js";
|
|
3
3
|
import type { RunTrigger } from "./triggers.js";
|
|
4
4
|
import { type Json } from "./validate.js";
|
|
@@ -32,6 +32,9 @@ export interface RunLaunch {
|
|
|
32
32
|
readonly documents?: string;
|
|
33
33
|
/** What a run's box may reach, as the server resolved it: the list, or "none". */
|
|
34
34
|
readonly boxAllow?: readonly string[] | "none";
|
|
35
|
+
/** The operator set AGENTRUN_BOX_ALLOW (box-settings.ts boxAllowSetIn): `boxAllow` is theirs, not the default. A
|
|
36
|
+
* browser is held to an operator's list and runs open under the default. Absent: the default. */
|
|
37
|
+
readonly boxAllowSet?: true;
|
|
35
38
|
/** The uploaded file ids the run was started with, in order (the create body's file_ids, already checked ready): the
|
|
36
39
|
* runner copies them into the run's work/inputs/ at its claim, as the old start copied them before the process ran. */
|
|
37
40
|
readonly files?: readonly string[];
|
|
@@ -40,7 +43,12 @@ export interface RunLaunch {
|
|
|
40
43
|
* shows them); `seed`, the learning commit's sha (or null when the seed could not be read); and `section`, the exact
|
|
41
44
|
* # Learned text to lay into the prompt for those notes (what the old layLearned laid), within the learning budget; and
|
|
42
45
|
* `seedNotes`, the count of all notes in the seed before the budget picked `given` (present with a read seed; absent when
|
|
43
|
-
* the seed could not be read)
|
|
46
|
+
* the seed could not be read); `skills`, the names of the learned skills the seed offers the run (each active one that
|
|
47
|
+
* fits a run's skill budget at all; its claim lays them), absent when none; `workflows`, the names of the learned
|
|
48
|
+
* workflows the seed offers its learned_workflow tool (chooseWorkflows), absent when none; `gradeModel`, the model the
|
|
49
|
+
* server names to grade what the run proposes (learning.ts gradeModelOf: --grade-model, else AGENTRUN_SERVE_GRADE_MODEL,
|
|
50
|
+
* else AGENT_MODEL_STRONG), absent when it names none and the agent's own grades it; and `seedFailed`, why it starts with
|
|
51
|
+
* nothing learned when it does (SeedFailed). Absent when the run does not learn. */
|
|
44
52
|
readonly learning?: {
|
|
45
53
|
readonly given: readonly {
|
|
46
54
|
readonly file: string;
|
|
@@ -49,6 +57,10 @@ export interface RunLaunch {
|
|
|
49
57
|
readonly seed: string | null;
|
|
50
58
|
readonly section: string;
|
|
51
59
|
readonly seedNotes?: number;
|
|
60
|
+
readonly skills?: readonly string[];
|
|
61
|
+
readonly workflows?: readonly string[];
|
|
62
|
+
readonly gradeModel?: string;
|
|
63
|
+
readonly seedFailed?: SeedFailed;
|
|
52
64
|
};
|
|
53
65
|
/** The trigger and firing that started the run, or none for a person's run. */
|
|
54
66
|
readonly trigger?: RunTrigger;
|
|
@@ -70,3 +82,10 @@ export declare function readLaunchBody(stored: unknown): RunLaunch | undefined;
|
|
|
70
82
|
/** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
|
|
71
83
|
* routes and the runner; undefined when the run does not learn. */
|
|
72
84
|
export declare const learningStartOf: (launch: RunLaunch) => RunLaunch["learning"];
|
|
85
|
+
/** Why a learning run starts with nothing learned, as main says it: its agent's learning folder could not be read
|
|
86
|
+
* (`unreadable`, STOPPED.unreadable), or what was read could not be made into its start (`not_copied`,
|
|
87
|
+
* STOPPED.notCopied). */
|
|
88
|
+
export type SeedFailed = "unreadable" | "not_copied";
|
|
89
|
+
/** A learning start with no seed (no commit of main, runs-over-store.ts learningStartFor): the run learns nothing, is
|
|
90
|
+
* never asked what to keep, and so is never told it learns. Why is its `seedFailed`, when its start records one. */
|
|
91
|
+
export declare const seedFailed: (start: NonNullable<RunLaunch["learning"]>) => boolean;
|
package/dist/run-launch.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// The input's origin keeps its fail-safe on read (#1856): a run started by a trigger keeps an origin only when it names
|
|
7
7
|
// the run's own trigger with owner === (the source is a schedule, whose words its owner wrote when they set it up), else
|
|
8
8
|
// that trigger's own with owner false, so a forged or lost origin never reads as the person's or the owner's.
|
|
9
|
-
import { originOf } from "
|
|
9
|
+
import { originOf } from "./timeline/index.js";
|
|
10
10
|
import { isObject } from "./validate.js";
|
|
11
11
|
/** The trigger a launch body names, as read back: `{ id, firing_key }`, or null (triggerOf of the old serve.json). */
|
|
12
12
|
function readTrigger(value) {
|
|
@@ -54,22 +54,26 @@ export function launchBody(launch) {
|
|
|
54
54
|
...(launch.approvers !== undefined ? { approvers: launch.approvers } : {}),
|
|
55
55
|
...(launch.documents !== undefined ? { documents: launch.documents } : {}),
|
|
56
56
|
...(launch.boxAllow !== undefined ? { box_allow: launch.boxAllow } : {}),
|
|
57
|
+
...(launch.boxAllowSet ? { box_allow_set: true } : {}),
|
|
57
58
|
...(launch.files?.length ? { files: launch.files } : {}),
|
|
58
|
-
...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}) } } : {}),
|
|
59
|
+
...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}) } } : {}),
|
|
59
60
|
...(launch.trigger ? { trigger: launch.trigger } : {}),
|
|
60
61
|
...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
|
|
61
62
|
...(launch.followUp ? { follow_up: true } : {}),
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
|
-
/** The learning start a launch body names, as read back: its given notes (each {file, name}), its seed sha
|
|
65
|
-
* section text,
|
|
65
|
+
/** The learning start a launch body names, as read back: its given notes (each {file, name}), its seed sha, its # Learned
|
|
66
|
+
* section text, the learned skills and workflows it was offered, its grade model and why its seed failed, or undefined
|
|
67
|
+
* when the body names none (a run that does not learn). */
|
|
66
68
|
function readLearning(value) {
|
|
67
69
|
if (!isObject(value))
|
|
68
70
|
return undefined;
|
|
69
71
|
const given = Array.isArray(value.given) ? value.given.flatMap((note) => (isObject(note) && typeof note.file === "string" && typeof note.name === "string" ? [{ file: note.file, name: note.name }] : [])) : [];
|
|
70
72
|
const seed = typeof value.seed === "string" ? value.seed : null;
|
|
71
73
|
const section = typeof value.section === "string" ? value.section : "";
|
|
72
|
-
|
|
74
|
+
const names = (list) => (Array.isArray(list) ? list.filter((name) => typeof name === "string") : []);
|
|
75
|
+
const [skills, workflows] = [names(value.skills), names(value.workflows)];
|
|
76
|
+
return { given, seed, section, ...(typeof value.seedNotes === "number" ? { seedNotes: value.seedNotes } : {}), ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}), ...(typeof value.gradeModel === "string" && value.gradeModel !== "" ? { gradeModel: value.gradeModel } : {}), ...(typeof value.seedFailed === "string" && SEED_FAILURES.includes(value.seedFailed) ? { seedFailed: value.seedFailed } : {}) };
|
|
73
77
|
}
|
|
74
78
|
/** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
|
|
75
79
|
* undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
|
|
@@ -96,6 +100,7 @@ export function readLaunchBody(stored) {
|
|
|
96
100
|
...(typeof stored.approvers === "boolean" ? { approvers: stored.approvers } : {}),
|
|
97
101
|
...(typeof stored.documents === "string" ? { documents: stored.documents } : {}),
|
|
98
102
|
...(boxAllow !== undefined ? { boxAllow } : {}),
|
|
103
|
+
...(stored.box_allow_set === true ? { boxAllowSet: true } : {}),
|
|
99
104
|
...(Array.isArray(stored.files) && stored.files.every((id) => typeof id === "string") ? { files: stored.files } : {}),
|
|
100
105
|
...(stored.learning !== undefined ? { learning: readLearning(stored.learning) ?? { given: [], seed: null, section: "" } } : {}),
|
|
101
106
|
...(trigger ? { trigger } : {}),
|
|
@@ -106,3 +111,7 @@ export function readLaunchBody(stored) {
|
|
|
106
111
|
/** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
|
|
107
112
|
* routes and the runner; undefined when the run does not learn. */
|
|
108
113
|
export const learningStartOf = (launch) => launch.learning;
|
|
114
|
+
const SEED_FAILURES = ["unreadable", "not_copied"];
|
|
115
|
+
/** A learning start with no seed (no commit of main, runs-over-store.ts learningStartFor): the run learns nothing, is
|
|
116
|
+
* never asked what to keep, and so is never told it learns. Why is its `seedFailed`, when its start records one. */
|
|
117
|
+
export const seedFailed = (start) => start.seed === null;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type ItemStatus } from "./learning.js";
|
|
1
2
|
import { type SignInReader } from "./run-view.js";
|
|
2
3
|
import type { Store } from "./store/store.js";
|
|
3
4
|
/** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
|
|
4
5
|
export declare function servedRunLearning(deps: {
|
|
5
6
|
serverSecrets: () => string[];
|
|
6
7
|
signIns?: SignInReader;
|
|
8
|
+
statuses?: (agentId: string) => Promise<ReadonlyMap<string, ItemStatus> | undefined>;
|
|
7
9
|
}, store: Store, runId: string): Promise<{
|
|
8
10
|
seed: string | null;
|
|
9
11
|
merged: string | null;
|
|
@@ -23,13 +25,28 @@ export declare function servedRunLearning(deps: {
|
|
|
23
25
|
keep: boolean;
|
|
24
26
|
}[];
|
|
25
27
|
} | null;
|
|
26
|
-
problems:
|
|
28
|
+
problems: {
|
|
29
|
+
detail: string;
|
|
30
|
+
path?: string | undefined;
|
|
31
|
+
rule: import("./learn/check.js").Rule;
|
|
32
|
+
}[];
|
|
27
33
|
cost_usd: {
|
|
28
34
|
grade: number | null;
|
|
29
35
|
};
|
|
30
36
|
tokens: {
|
|
31
37
|
grade: import("./learning.js").Tokens | null;
|
|
32
38
|
};
|
|
39
|
+
used: {
|
|
40
|
+
skills: {
|
|
41
|
+
name: string;
|
|
42
|
+
read: boolean;
|
|
43
|
+
}[];
|
|
44
|
+
workflows: {
|
|
45
|
+
name: string;
|
|
46
|
+
calls: number;
|
|
47
|
+
failed: number;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
33
50
|
given?: import("./learning.js").NoteUsed[];
|
|
34
51
|
read?: import("./learning.js").NoteUsed[];
|
|
35
52
|
learned?: import("./learning.js").NoteLearned[];
|
|
@@ -37,12 +54,12 @@ export declare function servedRunLearning(deps: {
|
|
|
37
54
|
workflows?: import("./learning.js").LearnedFile[];
|
|
38
55
|
run: string;
|
|
39
56
|
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
40
|
-
reason: "empty" | "
|
|
57
|
+
reason: "empty" | "cancelled" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
41
58
|
detail: string | null;
|
|
42
59
|
at: string;
|
|
43
60
|
} | null>;
|
|
44
|
-
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut
|
|
45
|
-
*
|
|
61
|
+
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut as its
|
|
62
|
+
* learning is, or ApiError forbidden for a withheld run. */
|
|
46
63
|
export declare function servedRunDiff(deps: {
|
|
47
64
|
serverSecrets: () => string[];
|
|
48
65
|
signIns?: SignInReader;
|