@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/harness-install.js
CHANGED
|
@@ -215,22 +215,6 @@ export async function npmInstall(entry, dir, pins, { lock = entry.lock, env = pr
|
|
|
215
215
|
throw error instanceof HarnessNotInstalled ? error : fail(error.message);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
/** What an earlier build left at the top of `<data>/harnesses`, when it installed Claude Code there itself: its
|
|
219
|
-
* package.json, its lock and its node_modules, and nothing else. */
|
|
220
|
-
const FLAT_INSTALL = new Set(["package.json", "package-lock.json", "node_modules"]);
|
|
221
|
-
/** Removes Claude Code as an earlier build installed it, at the top of `harnesses` (read-only, as it left it), so the
|
|
222
|
-
* per-harness installs can go in beside nothing: only when the directory holds that layout and nothing else (any other
|
|
223
|
-
* entry, a per-harness install among them, and it is left as it is). Nothing of the old tree is read or kept. Resolves
|
|
224
|
-
* true when it removed one. */
|
|
225
|
-
export async function removeFlatInstall(harnesses) {
|
|
226
|
-
const entries = await readdir(harnesses).catch((error) => (error.code === "ENOENT" ? [] : Promise.reject(error)));
|
|
227
|
-
if (!entries.length || !entries.every((name) => FLAT_INSTALL.has(name)) || !(entries.includes("package.json") || entries.includes("node_modules")))
|
|
228
|
-
return false;
|
|
229
|
-
await chmod(harnesses, (await lstat(harnesses)).mode | 0o700);
|
|
230
|
-
for (const name of entries)
|
|
231
|
-
await writable(join(harnesses, name), true).then(() => rm(join(harnesses, name), { recursive: true, force: true }));
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
218
|
/** Every file and directory under `dir` (no link followed) made writable by its owner, or read-only for everyone. */
|
|
235
219
|
async function writable(dir, on) {
|
|
236
220
|
const walk = async (path) => {
|
|
@@ -302,8 +286,7 @@ function runNpm(args, env, timeoutMs, signal, onKilled) {
|
|
|
302
286
|
/** The file an install of a harness into `dir` (`<data>/harnesses/<harness>`) keeps in the data directory while it runs,
|
|
303
287
|
* for every process on this data (a runner beside the server, one of its own, or one in another container on the same
|
|
304
288
|
* volume): the installing host and process, and since when. A failed install leaves why in it until the next install;
|
|
305
|
-
* one that lands removes it. In the data directory,
|
|
306
|
-
* its flat install in it, which the install removes first (removeFlatInstall) and which a file of ours would keep. */
|
|
289
|
+
* one that lands removes it. In the data directory, beside `<data>/harnesses`: that directory holds the installs alone. */
|
|
307
290
|
export const installMarkOf = (dir) => join(dirname(dirname(dir)), `.harness-install-${basename(dir)}.json`);
|
|
308
291
|
/** The mark written whole, beside it then renamed over it: a claim reading it while it changes reads the last mark or the
|
|
309
292
|
* new one, never part of one (which would read as no install). */
|
|
@@ -42,4 +42,11 @@ export interface OpenCodeAdapterOptions {
|
|
|
42
42
|
/** For tests: the fetch the model proxy forwards with. */
|
|
43
43
|
fetch?: typeof fetch;
|
|
44
44
|
}
|
|
45
|
+
/** The skills as the instructions list them: each by name and description, read with `read_skill_file`. The
|
|
46
|
+
* description as YAML reads it (learnedFront, the one front-matter reader: a quoted one's escapes decoded), so a quote
|
|
47
|
+
* in it reaches the model as a quote, never as `\"`; on one line. A SKILL.md that reader can't read whole is a
|
|
48
|
+
* revision's own skill the adapter's check accepted (skillProblems reads its name and description lines alone; a
|
|
49
|
+
* learned one never reaches a run unread, as the learning checker refuses it): its description is that line's
|
|
50
|
+
* (descriptionLine). */
|
|
51
|
+
export declare function skillsNote(skills: readonly Pick<HostSkill, "name" | "files">[]): string;
|
|
45
52
|
export declare function openCodeAdapter(options: OpenCodeAdapterOptions): AgentAdapter;
|
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
// skill's files with `read_skill_file`: OpenCode's own skills are off.
|
|
11
11
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
12
12
|
import { join } from "node:path";
|
|
13
|
-
import { READ_SKILL_FILE, readSkillFileTool, skillProblems, toolSchemaProblems } from "@parcha/agentrun-kernel";
|
|
13
|
+
import { READ_SKILL_FILE, hostedTool, readSkillFileTool, skillProblems, toolSchemaProblems } from "@parcha/agentrun-kernel";
|
|
14
14
|
import { abortedOutcome, openDrive, pendingSubmissions, SessionHalt } from "@parcha/agentrun-kernel/kernel";
|
|
15
15
|
import { recoveryNote, settleTurn, transcriptOf } from "@parcha/agentrun-kernel/process";
|
|
16
16
|
import { serialWriter, startModelProxy } from "@parcha/agentrun-kernel/host";
|
|
17
17
|
import { openCodeHarness, sentSubmissions } from "./harness.js";
|
|
18
18
|
import { openCodePolicy, TOOL_PREFIX } from "./host/policy.js";
|
|
19
19
|
import { verifyOpenCode } from "./verify.js";
|
|
20
|
+
import { learnedFront } from "../learn/skills.js";
|
|
20
21
|
/** A name OpenCode keeps whole for an MCP tool (it turns anything else into `_`), short enough that `hands_<name>` is a
|
|
21
22
|
* function name the Responses API takes (at most 64). */
|
|
22
23
|
const TOOL_NAME = new RegExp(`^[A-Za-z0-9_-]{1,${64 - TOOL_PREFIX.length}}$`);
|
|
@@ -56,16 +57,32 @@ function adapterEvent(event) {
|
|
|
56
57
|
return undefined;
|
|
57
58
|
}
|
|
58
59
|
const turnsIn = (drive) => transcriptOf(drive.state()).filter((r) => r.data?.type === "turn");
|
|
59
|
-
/** The skills as the instructions list them: each by name and description, read with `read_skill_file`.
|
|
60
|
-
|
|
60
|
+
/** The skills as the instructions list them: each by name and description, read with `read_skill_file`. The
|
|
61
|
+
* description as YAML reads it (learnedFront, the one front-matter reader: a quoted one's escapes decoded), so a quote
|
|
62
|
+
* in it reaches the model as a quote, never as `\"`; on one line. A SKILL.md that reader can't read whole is a
|
|
63
|
+
* revision's own skill the adapter's check accepted (skillProblems reads its name and description lines alone; a
|
|
64
|
+
* learned one never reaches a run unread, as the learning checker refuses it): its description is that line's
|
|
65
|
+
* (descriptionLine). */
|
|
66
|
+
export function skillsNote(skills) {
|
|
61
67
|
const lines = ["You have these skills. Read a skill's SKILL.md with read_skill_file before you use it, and the files it names the same way."];
|
|
62
68
|
for (const skill of skills) {
|
|
63
|
-
const
|
|
64
|
-
const
|
|
69
|
+
const md = skill.files["SKILL.md"] ?? "";
|
|
70
|
+
const front = learnedFront(md);
|
|
71
|
+
const description = ((front ? front.description : descriptionLine(md)) ?? "").replace(/\s+/g, " ").trim();
|
|
65
72
|
lines.push(`- ${skill.name}: ${description}`);
|
|
66
73
|
}
|
|
67
74
|
return lines.join("\n");
|
|
68
75
|
}
|
|
76
|
+
/** A SKILL.md's `description:` line as the adapter's check reads it (skillProblems: the front matter's first
|
|
77
|
+
* `description:` line), its value without one pair of surrounding quotes; undefined with none. */
|
|
78
|
+
function descriptionLine(md) {
|
|
79
|
+
const front = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/.exec(md)?.[1];
|
|
80
|
+
const value = front === undefined ? undefined : /^description:[ \t]*(\S.*?)\s*$/m.exec(front)?.[1];
|
|
81
|
+
if (value === undefined)
|
|
82
|
+
return undefined;
|
|
83
|
+
const quoted = /^(['"])(.*)\1$/.exec(value);
|
|
84
|
+
return quoted ? quoted[2] : value;
|
|
85
|
+
}
|
|
69
86
|
export function openCodeAdapter(options) {
|
|
70
87
|
const skills = options.skills ?? [];
|
|
71
88
|
const skillsWrong = skillProblems(skills);
|
|
@@ -120,7 +137,7 @@ export function openCodeAdapter(options) {
|
|
|
120
137
|
throw new Error("opencode: a session needs a private directory: the host lends one (io.dir), or pass sessionsDir");
|
|
121
138
|
// With skills the model also reads their files (read_skill_file), from the session's own copy of them.
|
|
122
139
|
const skillsDir = join(dir, "skills");
|
|
123
|
-
const tools = skills.length ? [...spec.tools, readSkillFileTool(skillsDir, skills.map((skill) => ({ name: skill.name, files: Object.keys(skill.files) })))] : spec.tools;
|
|
140
|
+
const tools = skills.length ? [...spec.tools, hostedTool(io, readSkillFileTool(skillsDir, skills.map((skill) => ({ name: skill.name, files: Object.keys(skill.files) }))))] : spec.tools;
|
|
124
141
|
if (skills.length) {
|
|
125
142
|
const { mkdirSync, writeFileSync } = await import("node:fs");
|
|
126
143
|
const { dirname } = await import("node:path");
|
|
@@ -339,7 +339,6 @@ export function openCodeHarness(options, control) {
|
|
|
339
339
|
}
|
|
340
340
|
if (event.type === "session.error" && turn) {
|
|
341
341
|
const error = isPlain(p.error) ? p.error : {};
|
|
342
|
-
const data = isPlain(error.data) ? error.data : {};
|
|
343
342
|
if (error.name === "MessageAbortedError")
|
|
344
343
|
turn.error = undefined;
|
|
345
344
|
else
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { providerInputOverhead, ProxyRefusal } from "@parcha/agentrun-kernel/host";
|
|
1
|
+
import { providerInputOverhead, ProxyRefusal, responsesImagesIn } from "@parcha/agentrun-kernel/host";
|
|
2
2
|
/** The prefix OpenCode gives the adapter's MCP tools: the server is `hands`. */
|
|
3
3
|
export const TOOL_PREFIX = "hands_";
|
|
4
4
|
export const OPENCODE_RESPONSES_ROUTES = Object.freeze([
|
|
@@ -229,7 +229,7 @@ function itemsIn(value, type) {
|
|
|
229
229
|
export function responsesServerInputOverhead(body) {
|
|
230
230
|
if (itemsIn(body.input, "input_file") > 0)
|
|
231
231
|
throw new Error("a file input's billed size has no stated bound");
|
|
232
|
-
return providerInputOverhead("openai-responses", { tools: Array.isArray(body.tools) && body.tools.length > 0, images:
|
|
232
|
+
return providerInputOverhead("openai-responses", { tools: Array.isArray(body.tools) && body.tools.length > 0, images: responsesImagesIn(body.input), ...(typeof body.model === "string" ? { model: body.model } : {}) });
|
|
233
233
|
}
|
|
234
234
|
/** An event that is not whole by this many characters is not read. */
|
|
235
235
|
const EVENT_CAP = 4 * 1024 * 1024;
|
|
@@ -5,5 +5,5 @@ export type { HostSkill } from "@parcha/agentrun-kernel";
|
|
|
5
5
|
export type { OpenCodeAdapterOptions, OpenCodeProvider } from "./adapter.js";
|
|
6
6
|
export type { ChildCommand, ConfineChild } from "./host/server.js";
|
|
7
7
|
export { OPENCODE_VERSION, findOpenCode, openCodeBinary } from "./binary.js";
|
|
8
|
-
export { verifyOpenCode, verifyOpenCodeBinary } from "./verify.js";
|
|
8
|
+
export { verifyOpenCode, verifyOpenCodeAsync, verifyOpenCodeBinary, verifyOpenCodeBinaryAsync } from "./verify.js";
|
|
9
9
|
export { OPENCODE_BINARY_SHA256, OPENCODE_INSTALL, OPENCODE_NPM_INTEGRITY, OpenCodeNotInstalled, OpenCodePinMismatch } from "./versions.js";
|
|
@@ -2,5 +2,5 @@ export { openCodeAdapter } from "./adapter.js";
|
|
|
2
2
|
/** The check the adapter runs on the host's skills when it is made: @parcha/agentrun-kernel's own, as the other adapters'. */
|
|
3
3
|
export { skillProblems } from "@parcha/agentrun-kernel";
|
|
4
4
|
export { OPENCODE_VERSION, findOpenCode, openCodeBinary } from "./binary.js";
|
|
5
|
-
export { verifyOpenCode, verifyOpenCodeBinary } from "./verify.js";
|
|
5
|
+
export { verifyOpenCode, verifyOpenCodeAsync, verifyOpenCodeBinary, verifyOpenCodeBinaryAsync } from "./verify.js";
|
|
6
6
|
export { OPENCODE_BINARY_SHA256, OPENCODE_INSTALL, OPENCODE_NPM_INTEGRITY, OpenCodeNotInstalled, OpenCodePinMismatch } from "./versions.js";
|
|
@@ -22,6 +22,14 @@ export declare function verifyOpenCodeBinary(found: {
|
|
|
22
22
|
} | undefined, pins?: OpenCodePins): {
|
|
23
23
|
path: string;
|
|
24
24
|
} | OpenCodePinMismatch | OpenCodeNotInstalled;
|
|
25
|
+
/** verifyOpenCodeBinary without holding the event loop (the kernel's checkedOnceAsync), its pass kept for it too. */
|
|
26
|
+
export declare function verifyOpenCodeBinaryAsync(found: {
|
|
27
|
+
path: string;
|
|
28
|
+
pkg?: string;
|
|
29
|
+
packageVersion?: string;
|
|
30
|
+
} | undefined, pins?: OpenCodePins): Promise<{
|
|
31
|
+
path: string;
|
|
32
|
+
} | OpenCodePinMismatch | OpenCodeNotInstalled>;
|
|
25
33
|
/** This machine's OpenCode checked against the pins: its path, or the typed error thrown. */
|
|
26
34
|
export declare function verifyOpenCode(found?: {
|
|
27
35
|
path: string;
|
|
@@ -30,3 +38,12 @@ export declare function verifyOpenCode(found?: {
|
|
|
30
38
|
} | undefined, pins?: OpenCodePins): {
|
|
31
39
|
path: string;
|
|
32
40
|
};
|
|
41
|
+
/** verifyOpenCode without holding the event loop: what a host awaits before it makes the adapter, whose own check then
|
|
42
|
+
* answers from what this kept. */
|
|
43
|
+
export declare function verifyOpenCodeAsync(found?: {
|
|
44
|
+
path: string;
|
|
45
|
+
pkg?: string;
|
|
46
|
+
packageVersion?: string;
|
|
47
|
+
} | undefined, pins?: OpenCodePins): Promise<{
|
|
48
|
+
path: string;
|
|
49
|
+
}>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// The installed OpenCode checked against the pins (src/versions.ts) before anything runs, with the typed errors a host
|
|
2
2
|
// maps to a run's failure line. Written for AgentRun.
|
|
3
|
-
import { execFileSync } from "node:child_process";
|
|
4
3
|
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
5
4
|
import { tmpdir } from "node:os";
|
|
6
5
|
import { join, resolve } from "node:path";
|
|
7
6
|
import { env } from "node:process";
|
|
8
|
-
import { checkedOnce,
|
|
7
|
+
import { checkedOnce, checkedOnceAsync } from "@parcha/agentrun-kernel/host";
|
|
9
8
|
import { findOpenCode, openCodePackages } from "./binary.js";
|
|
10
9
|
import { OPENCODE_BINARY_SHA256, OPENCODE_VERSION, OpenCodeNotInstalled, OpenCodePinMismatch } from "./versions.js";
|
|
11
10
|
/** The pins this package holds. */
|
|
@@ -19,6 +18,21 @@ export const openCodePins = () => ({ version: OPENCODE_VERSION, sha256: OPENCODE
|
|
|
19
18
|
* directory, where a relative `OPENCODE_BIN` names nothing.
|
|
20
19
|
*/
|
|
21
20
|
export function verifyOpenCodeBinary(found, pins = openCodePins()) {
|
|
21
|
+
const at = located(found, pins);
|
|
22
|
+
// Hashed a chunk at a time, and checked once per binary in this process while it stays the same file, unchanged (the
|
|
23
|
+
// kernel's checkedOnce): a host that checks it for each model it resolves, and a run's process that makes its adapter,
|
|
24
|
+
// check it once. Its reads hold the event loop: a host checks with verifyOpenCodeBinaryAsync first.
|
|
25
|
+
return at instanceof Error ? at : checkedOnce(at.path, at.key, () => checkBinary(at.path, pins.version, at.expected), passed);
|
|
26
|
+
}
|
|
27
|
+
/** verifyOpenCodeBinary without holding the event loop (the kernel's checkedOnceAsync), its pass kept for it too. */
|
|
28
|
+
export async function verifyOpenCodeBinaryAsync(found, pins = openCodePins()) {
|
|
29
|
+
const at = located(found, pins);
|
|
30
|
+
return at instanceof Error ? at : checkedOnceAsync(at.path, at.key, () => checkBinary(at.path, pins.version, at.expected), passed);
|
|
31
|
+
}
|
|
32
|
+
const passed = (result) => !(result instanceof Error);
|
|
33
|
+
/** The absolute path of `found`, there and of the pinned version, with the sha256 values it may have and the pins' key;
|
|
34
|
+
* or why not. */
|
|
35
|
+
function located(found, pins) {
|
|
22
36
|
if (!found)
|
|
23
37
|
return new OpenCodeNotInstalled("no OpenCode binary found for this platform, and OPENCODE_BIN is not set");
|
|
24
38
|
const path = resolve(found.path);
|
|
@@ -29,17 +43,15 @@ export function verifyOpenCodeBinary(found, pins = openCodePins()) {
|
|
|
29
43
|
// A binary from a platform package is checked against that package's pin; one named by OPENCODE_BIN (no package) against
|
|
30
44
|
// the pins of every package this machine may run.
|
|
31
45
|
const expected = (found.pkg ? [found.pkg] : openCodePackages()).map((pkg) => pins.sha256[pkg]).filter((sha) => typeof sha === "string");
|
|
32
|
-
|
|
33
|
-
// kernel's checkedOnce): a host that checks it for each model it resolves, and a run's process that makes its adapter,
|
|
34
|
-
// check it once.
|
|
35
|
-
return checkedOnce(path, JSON.stringify({ version: pins.version, expected }), () => checkBinary(path, pins.version, expected), (result) => !(result instanceof Error));
|
|
46
|
+
return { path, expected, key: JSON.stringify({ version: pins.version, expected }) };
|
|
36
47
|
}
|
|
37
|
-
/** The binary at `path` (absolute, there) against the sha256 values it may have and the version it must report
|
|
38
|
-
|
|
48
|
+
/** The binary at `path` (absolute, there) against the sha256 values it may have and the version it must report, as the
|
|
49
|
+
* steps it reads (the kernel's BinaryCheck). */
|
|
50
|
+
function* checkBinary(path, version, expected) {
|
|
39
51
|
if (expected.length) {
|
|
40
52
|
let sha256;
|
|
41
53
|
try {
|
|
42
|
-
sha256 =
|
|
54
|
+
sha256 = yield { kind: "sha256", path };
|
|
43
55
|
}
|
|
44
56
|
catch (error) {
|
|
45
57
|
return new OpenCodeNotInstalled(`${path} could not be read: ${String(error?.message ?? error).slice(0, 120)}`);
|
|
@@ -53,7 +65,7 @@ function checkBinary(path, version, expected) {
|
|
|
53
65
|
const home = mkdtempSync(join(tmpdir(), "agentrun-opencode-version-"));
|
|
54
66
|
try {
|
|
55
67
|
const dirs = { HOME: home, XDG_CONFIG_HOME: join(home, "config"), XDG_DATA_HOME: join(home, "data"), XDG_CACHE_HOME: join(home, "cache"), XDG_STATE_HOME: join(home, "state") };
|
|
56
|
-
reported =
|
|
68
|
+
reported = (yield { kind: "run", path, args: ["--version"], env: { PATH: env.PATH ?? "/usr/bin:/bin", ...dirs, OPENCODE_DISABLE_AUTOUPDATE: "1" }, cwd: home, timeoutMs: 20_000 }).trim();
|
|
57
69
|
}
|
|
58
70
|
catch (error) {
|
|
59
71
|
return new OpenCodeNotInstalled(`${path} could not be run: ${String(error?.message ?? error).slice(0, 120)}`);
|
|
@@ -73,3 +85,11 @@ export function verifyOpenCode(found = findOpenCode(), pins = openCodePins()) {
|
|
|
73
85
|
throw result;
|
|
74
86
|
return result;
|
|
75
87
|
}
|
|
88
|
+
/** verifyOpenCode without holding the event loop: what a host awaits before it makes the adapter, whose own check then
|
|
89
|
+
* answers from what this kept. */
|
|
90
|
+
export async function verifyOpenCodeAsync(found = findOpenCode(), pins = openCodePins()) {
|
|
91
|
+
const result = await verifyOpenCodeBinaryAsync(found, pins);
|
|
92
|
+
if (result instanceof Error)
|
|
93
|
+
throw result;
|
|
94
|
+
return result;
|
|
95
|
+
}
|
package/dist/harness-table.js
CHANGED
|
@@ -111,7 +111,12 @@ const BUILTIN = Object.freeze({
|
|
|
111
111
|
pins: async () => (await import("./adapters.js")).codexPins(),
|
|
112
112
|
}),
|
|
113
113
|
[openCodeFacts.id]: adapterEntry(openCodeFacts, async (env, needs) => (await import("./adapters.js")).opencodeOf(env, needs), {
|
|
114
|
-
|
|
114
|
+
// Checked as OpenCode is handed them (servedSkills, opencodeOf's): one size check on what it gets.
|
|
115
|
+
skillCheck: async () => {
|
|
116
|
+
const [{ packageSkillCheck }, { servedSkills }] = await Promise.all([import("./adapters.js"), import("./learn/skills.js")]);
|
|
117
|
+
const check = await packageSkillCheck(() => import("./harness-opencode/index.js"));
|
|
118
|
+
return check && ((skills) => check(servedSkills(skills)));
|
|
119
|
+
},
|
|
115
120
|
}),
|
|
116
121
|
});
|
|
117
122
|
const loaded = new Map();
|
package/dist/heard.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// - a trigger's firing whose words come from outside (a webhook body, a Slack or GitHub event): a trigger's input,
|
|
7
7
|
// with its source, never the user's;
|
|
8
8
|
// - any other message the server wrote (a raised cap's follow-up, an approval's resume): left out.
|
|
9
|
-
import { isUserEntry, originMatcher } from "
|
|
9
|
+
import { isUserEntry, originMatcher } from "./timeline/index.js";
|
|
10
10
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
11
|
/** A user message's text parts, joined as the timeline joins them: an image or a file the message carries is no words. */
|
|
12
12
|
const textOf = (message) => {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FileHandle } from "node:fs/promises";
|
|
2
|
+
/** Keeps `handle` reachable until it is closed. A handle held and never closed stays open until the process exits. */
|
|
3
|
+
export declare function hold(handle: FileHandle): FileHandle;
|
|
4
|
+
/** `/proc/self/fd/<n>` for `handle`, held until it is closed (`hold`). */
|
|
5
|
+
export declare function fdPath(handle: FileHandle): string;
|
package/dist/held-fd.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const HELD = new Set();
|
|
2
|
+
/** Keeps `handle` reachable until it is closed. A handle held and never closed stays open until the process exits. */
|
|
3
|
+
export function hold(handle) {
|
|
4
|
+
if (!HELD.has(handle)) {
|
|
5
|
+
HELD.add(handle);
|
|
6
|
+
// A FileHandle is an EventEmitter that emits `close` once closed (Node's typings leave that out).
|
|
7
|
+
handle.once("close", () => HELD.delete(handle));
|
|
8
|
+
}
|
|
9
|
+
return handle;
|
|
10
|
+
}
|
|
11
|
+
/** `/proc/self/fd/<n>` for `handle`, held until it is closed (`hold`). */
|
|
12
|
+
export function fdPath(handle) {
|
|
13
|
+
return `/proc/self/fd/${hold(handle).fd}`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A host tool's answer, as HostTool.call gives it. */
|
|
2
|
+
export type HostAnswer = {
|
|
3
|
+
text: string;
|
|
4
|
+
isError?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/** What the loop lends a call it runs: an MCP tool of the run by its catalog name (`mcp:<server>/<tool>`), as the loop
|
|
7
|
+
* wrapped it, or undefined when the run has no such tool; and, when a person approved the call it runs, the arguments
|
|
8
|
+
* its approval card showed them (the call's ask as journaled: what they saw, never what the gate would show now);
|
|
9
|
+
* undefined when no person approved it. */
|
|
10
|
+
export type HostCalls = {
|
|
11
|
+
readonly mcp: (tool: string) => ((args: unknown, ctx: {
|
|
12
|
+
callId: string;
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
}) => Promise<HostAnswer>) | undefined;
|
|
15
|
+
readonly approved: Readonly<Record<string, unknown>> | undefined;
|
|
16
|
+
};
|
|
17
|
+
/** `work` with `lent` as the calls its tool may make. */
|
|
18
|
+
export declare const withHostCalls: <T>(lent: HostCalls, work: () => Promise<T>) => Promise<T>;
|
|
19
|
+
/** The calls the tool running now may make; undefined outside a loop's call (a server-side run, a test calling a tool). */
|
|
20
|
+
export declare const hostCalls: () => HostCalls | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// A call the run's own tools make of another tool of the run, through the same path the harness's calls take: the
|
|
2
|
+
// adapter loop sets it around each host tool's call (runner/adapter-loop.ts hosted), so a learned workflow's call node
|
|
3
|
+
// that names an MCP tool (learned-workflow.ts runEffect) runs that tool as the loop wrapped it: its flush before the side
|
|
4
|
+
// effect, its paid requests booked on the run's one ledger under the call id given, its record on a CLI's timeline, and
|
|
5
|
+
// the stop's abort. The gate is the caller's to ask first, with the run's own permissions; the loop says only what card
|
|
6
|
+
// a person approved the call it runs inside with (`approved`), so an approval covers what that card named and no more.
|
|
7
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
+
const calls = new AsyncLocalStorage();
|
|
9
|
+
/** `work` with `lent` as the calls its tool may make. */
|
|
10
|
+
export const withHostCalls = (lent, work) => calls.run(lent, work);
|
|
11
|
+
/** The calls the tool running now may make; undefined outside a loop's call (a server-side run, a test calling a tool). */
|
|
12
|
+
export const hostCalls = () => calls.getStore();
|
package/dist/host-tools.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
2
|
import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { HostTool } from "@parcha/agentrun-kernel";
|
|
4
|
-
import type { DurableRun } from "@parcha/pi-durable-disk";
|
|
5
|
-
import type { Park, RunGate } from "./tool-gate.js";
|
|
6
4
|
export { workspaceRelative } from "./workspace-paths.js";
|
|
7
5
|
/** Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again.
|
|
8
6
|
* `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL, named here as a string so the modules do not import
|
|
@@ -28,10 +26,9 @@ export type ToolResults = Map<string, {
|
|
|
28
26
|
export declare const HOST_API_MEMBERS: readonly ["env", "callId", "commit", "output", "outputWindow", "retainedOutput", "diagnostic", "agent", "models", "conversationId", "snapshot", "conversation", "waitForTask"];
|
|
29
27
|
/** The members a host tool's api gives only on a run's Harness: a remote executor's api has none of them. */
|
|
30
28
|
export declare const RUN_ONLY_MEMBERS: readonly ["conversationId", "snapshot", "conversation", "waitForTask"];
|
|
31
|
-
/** What one host tool's call reads of the run
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* (runner/adapter-run-spec.ts), so a tool runs and answers one way on both. */
|
|
29
|
+
/** What one host tool's call reads of the run: the run's environment (its file environment, the api's `env`), its
|
|
30
|
+
* harness's commit and its root agent (a paid call's booking and pi's read), the context and the results map, and the
|
|
31
|
+
* paid-call money seam, over the runner's claim Harness (runner/adapter-run-spec.ts). */
|
|
35
32
|
export interface HostToolCtx {
|
|
36
33
|
readonly context: Context;
|
|
37
34
|
readonly results: ToolResults;
|
|
@@ -44,12 +41,6 @@ export interface HostToolCtx {
|
|
|
44
41
|
readonly snapshot: ToolExecutionApi["snapshot"];
|
|
45
42
|
readonly conversation: ToolExecutionApi["conversation"];
|
|
46
43
|
readonly waitForTask: ToolExecutionApi["waitForTask"];
|
|
47
|
-
/** The run's tool gate and the park it takes; none for the gate's own run of an approved call (the adapter loop's own
|
|
48
|
-
* gate, which gates every host-tool call before its intent). */
|
|
49
|
-
readonly gated?: {
|
|
50
|
-
gate: RunGate;
|
|
51
|
-
park: Park;
|
|
52
|
-
};
|
|
53
44
|
/** A gate for a tool that cannot be run on the runner yet: undefined to run the call, else the refusal that is its answer,
|
|
54
45
|
* so the tool is listed but never run as a stub. No tool sets it now (learned_workflow runs for real on every session's
|
|
55
46
|
* model port); it stays the seam a not-yet-runnable tool refuses through. The paid tools the loop can book
|
|
@@ -59,15 +50,7 @@ export interface HostToolCtx {
|
|
|
59
50
|
} | undefined;
|
|
60
51
|
}
|
|
61
52
|
/** One pi ToolRegistration `tool` (named `name` by its catalog name) as the kernel's HostTool an adapter session takes:
|
|
62
|
-
* the
|
|
53
|
+
* the paid-call seam, then the tool on the run's environment and harness, its answer the text a
|
|
63
54
|
* model reads (the output or the failure, a write's or an error's path named relative to the run's folder). Undefined when
|
|
64
55
|
* `name` is not one a host runs (REPLAY). */
|
|
65
56
|
export declare function hostToolOf(name: string, tool: ToolRegistration, ctx: HostToolCtx): HostTool | undefined;
|
|
66
|
-
/** The host tools `names` names, on the run's coding source `coding`. `gated`: the run's tool gate, which every call
|
|
67
|
-
* passes, and the park it takes (harness-app.ts), told of a call it parked, whose turn the harness ends; none (the
|
|
68
|
-
* gate's own run of an approved call), each call runs as asked. `extra`: the run's own tools beyond the table (its
|
|
69
|
-
* learned_workflow, learned-workflow.ts), which the gate passes like the rest. */
|
|
70
|
-
export declare function hostTools(run: DurableRun, names: readonly string[], context: Context, results: ToolResults, coding?: readonly ToolRegistration[], gated?: {
|
|
71
|
-
gate: RunGate;
|
|
72
|
-
park: Park;
|
|
73
|
-
}, extra?: readonly ToolRegistration[]): HostTool[];
|
package/dist/host-tools.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { withAbortSignal } from "@earendil-works/chord/context";
|
|
2
2
|
import { createModels } from "@earendil-works/pi-ai/models";
|
|
3
3
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { monidTools } from "./monid.js";
|
|
7
|
-
import { booking } from "./paid-calls.js";
|
|
8
|
-
import { withSecrets } from "./secrets.js";
|
|
9
|
-
import { WEB_FETCH_TOOL, webFetchTool } from "./web-fetch.js";
|
|
10
|
-
import { WEB_SEARCH_TOOL, webSearchTool } from "./web-search.js";
|
|
4
|
+
import { WEB_FETCH_TOOL } from "./web-fetch.js";
|
|
5
|
+
import { WEB_SEARCH_TOOL } from "./web-search.js";
|
|
11
6
|
import { realOf, workspaceRelative } from "./workspace-paths.js";
|
|
12
|
-
import { localWorkspace } from "./workspace/index.js";
|
|
13
7
|
import { bounded, imagesOf, textOf } from "./workspace/executors.js";
|
|
14
8
|
export { workspaceRelative } from "./workspace-paths.js";
|
|
15
9
|
/** Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again.
|
|
@@ -42,7 +36,7 @@ const hostApi = (given) => new Proxy(given, {
|
|
|
42
36
|
/** The tools whose result is pi's own words about a path (`Successfully wrote to <path>`), never a file's text. */
|
|
43
37
|
const SAYS_PATH = new Set(["write", "edit"]);
|
|
44
38
|
/** One pi ToolRegistration `tool` (named `name` by its catalog name) as the kernel's HostTool an adapter session takes:
|
|
45
|
-
* the
|
|
39
|
+
* the paid-call seam, then the tool on the run's environment and harness, its answer the text a
|
|
46
40
|
* model reads (the output or the failure, a write's or an error's path named relative to the run's folder). Undefined when
|
|
47
41
|
* `name` is not one a host runs (REPLAY). */
|
|
48
42
|
export function hostToolOf(name, tool, ctx) {
|
|
@@ -54,15 +48,7 @@ export function hostToolOf(name, tool, ctx) {
|
|
|
54
48
|
description: tool.description,
|
|
55
49
|
inputSchema: tool.parameters,
|
|
56
50
|
replay,
|
|
57
|
-
async call(args, { callId, signal
|
|
58
|
-
// A replay (the kernel's attempt above 0) may follow an attempt that was sent: the gate's refusal then says so.
|
|
59
|
-
const refused = await ctx.gated?.gate.enter(name, args, callId, ctx.gated.park, (attempt ?? 0) > 0 ? { replayed: true } : {});
|
|
60
|
-
if (refused) {
|
|
61
|
-
const answer = { text: refused.text, isError: refused.isError };
|
|
62
|
-
ctx.results.set(callId, answer);
|
|
63
|
-
// A parked call did not run: the harness's session records it so (HostTool's `parked`).
|
|
64
|
-
return refused.parked ? { ...answer, parked: true } : answer;
|
|
65
|
-
}
|
|
51
|
+
async call(args, { callId, signal }) {
|
|
66
52
|
// The unready-tool seam: a tool that cannot be run on the runner yet is refused in words, never run as a stub.
|
|
67
53
|
const unsettled = ctx.settle?.(name, args, callId);
|
|
68
54
|
if (unsettled) {
|
|
@@ -100,46 +86,3 @@ export function hostToolOf(name, tool, ctx) {
|
|
|
100
86
|
},
|
|
101
87
|
};
|
|
102
88
|
}
|
|
103
|
-
/** The host tools `names` names, on the run's coding source `coding`. `gated`: the run's tool gate, which every call
|
|
104
|
-
* passes, and the park it takes (harness-app.ts), told of a call it parked, whose turn the harness ends; none (the
|
|
105
|
-
* gate's own run of an approved call), each call runs as asked. `extra`: the run's own tools beyond the table (its
|
|
106
|
-
* learned_workflow, learned-workflow.ts), which the gate passes like the rest. */
|
|
107
|
-
export function hostTools(run, names, context, results, coding = CodingTools.tools ?? [], gated, extra = []) {
|
|
108
|
-
// The coding source gives the coding tools and nothing else: the network tools are this machine's own, below.
|
|
109
|
-
const stray = coding.map((tool) => tool.name).filter((name) => !BOXED_TOOLS.includes(name));
|
|
110
|
-
if (stray.length)
|
|
111
|
-
throw new Error(`the coding source holds ${stray.join(", ")}, which is no coding tool`);
|
|
112
|
-
// Their paid requests (Parallel's) are booked under the call, in the run's store, as pi's are (paid-calls.ts).
|
|
113
|
-
const web = [webFetchTool(process.env), webSearchTool(process.env)].map(booking);
|
|
114
|
-
// monid's, only for a run that names one: its key is the one this process was handed over its pipe (secrets.ts),
|
|
115
|
-
// never in its environment, and its long answers go in the run's work/, the claim's as pi's (`where.work`), read at
|
|
116
|
-
// the call. They are outside the coding source, which holds the coding tools only.
|
|
117
|
-
const monid = names.some((name) => name.startsWith("monid.")) ? monidTools(withSecrets(process.env), () => localWorkspace(run.claim.work)) : [];
|
|
118
|
-
// `extra`: the run's own tools beyond the table, its learned_workflow (learned-workflow.ts) when its pin names one.
|
|
119
|
-
const tools = new Map([...coding, ...web, ...monid, ...extra].map((tool) => [tool.name, tool]));
|
|
120
|
-
// What each call reads of the run: its environment, its harness's commit and root agent (pi's read asks the calling
|
|
121
|
-
// agent for its model, for an image's limits; a non-pi run's root agent has no pi model, so read uses its default).
|
|
122
|
-
const ctx = {
|
|
123
|
-
context,
|
|
124
|
-
results,
|
|
125
|
-
...(gated ? { gated } : {}),
|
|
126
|
-
env: async () => await run.env({ conversationId: ROOT_CONVERSATION_ID, read: undefined }, context),
|
|
127
|
-
commit: (change, at, options) => run.harness.commit(change, at, options),
|
|
128
|
-
// The run's own Harness, read at the call as commit's is: a document, conversation or task of this run only.
|
|
129
|
-
snapshot: ((...args) => Reflect.apply(run.harness.snapshot, run.harness, args)),
|
|
130
|
-
conversation: ((id, at) => run.harness.conversation(id, at)),
|
|
131
|
-
waitForTask: (id, at) => run.harness.waitForTask(id, at),
|
|
132
|
-
agent: async (at) => {
|
|
133
|
-
const root = await run.harness.conversation(ROOT_CONVERSATION_ID, at);
|
|
134
|
-
if (!root)
|
|
135
|
-
throw new Error("the run has no root conversation");
|
|
136
|
-
return root.agent(at);
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
// The registrations are keyed by their wire names: the same name for every tool here but monid's.
|
|
140
|
-
return names.flatMap((name) => {
|
|
141
|
-
const tool = tools.get(wireName(name));
|
|
142
|
-
const host = tool ? hostToolOf(name, tool, ctx) : undefined;
|
|
143
|
-
return host ? [host] : [];
|
|
144
|
-
});
|
|
145
|
-
}
|
package/dist/host.d.ts
CHANGED
|
@@ -22,10 +22,8 @@ export declare function runsThatFit(harness: string, memory: number): number;
|
|
|
22
22
|
export declare const defaultMaxRuns: (memory: number) => number;
|
|
23
23
|
/** Why no run of `harness` can ever start on a host of `memory` bytes, in words; undefined when one fits. */
|
|
24
24
|
export declare function neverFits(harness: string, memory: number): string | undefined;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
/** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. The
|
|
28
|
-
* memory each run reserves is checked beside it (runs.ts): both apply. */
|
|
25
|
+
/** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. A runner
|
|
26
|
+
* holds at most this many; a run past it waits queued, never refused for a place. */
|
|
29
27
|
export declare function maxRunsOf(env: NodeJS.ProcessEnv, given?: number): number;
|
|
30
28
|
export type Health = {
|
|
31
29
|
status: "ok" | "failing";
|
package/dist/host.js
CHANGED
|
@@ -47,13 +47,8 @@ export function neverFits(harness, memory) {
|
|
|
47
47
|
const fit = HARNESSES.filter((id) => runsThatFit(id, memory) > 0);
|
|
48
48
|
return `This server has ${sizeOf(memory / MiB)} of memory and keeps ${sizeOf(SERVER_MIB)} for itself; ${aRun(harness)} needs about ${sizeOf(runMibOf(harness))} more, so it can't start here. ${listed(fit)} runs fit.`;
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
const free = Math.max(0, runsMemoryMib(memory) - heldMib);
|
|
53
|
-
return `This server's memory is held by the runs it has going: ${aRun(harness)} needs about ${sizeOf(runMibOf(harness))}, and ${sizeOf(free)} of the ${sizeOf(runsMemoryMib(memory))} it has for runs is free; start this one when another ends.`;
|
|
54
|
-
}
|
|
55
|
-
/** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. The
|
|
56
|
-
* memory each run reserves is checked beside it (runs.ts): both apply. */
|
|
50
|
+
/** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. A runner
|
|
51
|
+
* holds at most this many; a run past it waits queued, never refused for a place. */
|
|
57
52
|
export function maxRunsOf(env, given) {
|
|
58
53
|
const value = given ?? (env.AGENTRUN_MAX_RUNS ? Number(env.AGENTRUN_MAX_RUNS) : defaultMaxRuns(hostMemory()));
|
|
59
54
|
if (!Number.isSafeInteger(value) || value < 1)
|
package/dist/import-summary.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { RunMetrics } from "@parcha/pi-durable-agent/timeline";
|
|
1
|
+
import type { RunMetrics } from "./timeline/index.js";
|
|
3
2
|
import { type Source } from "./import-sources.js";
|
|
4
3
|
/** A session an import found: its source and agent; what it used (undefined: unknown), with its time at work; and its
|
|
5
4
|
* model requests by local hour of the day (undefined: their times are unknown). `untied`: a subagent's session whose
|
|
@@ -15,9 +14,6 @@ export type Found = {
|
|
|
15
14
|
};
|
|
16
15
|
/** Requests by local hour of the day, from their times (ms). */
|
|
17
16
|
export declare function hoursOf(times: Iterable<number>): number[];
|
|
18
|
-
/** An imported run of `store`, as found: its metrics as the store keeps them, and its requests' times from its transcript,
|
|
19
|
-
* read by SQLite's JSON functions (no record is parsed here). Undefined for a run the store does not hold as imported. */
|
|
20
|
-
export declare function foundIn(store: AgentStoreReader, runId: string): Promise<Found | undefined>;
|
|
21
17
|
/** The summary's lines for `found`, ending with where to open the server (`open`, its address). `dryRun`: what an import
|
|
22
18
|
* would take, nothing taken yet. */
|
|
23
19
|
export declare function summaryLines(everything: readonly Found[], open: string, { dryRun }?: {
|
package/dist/import-summary.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
// The lines an import ends with: how many sessions it found and from where, how many agents they make, and what they
|
|
2
|
-
// used, from every session found, those imported before included. A number with no data behind it reads unknown.
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
1
|
import { SOURCES } from "./import-sources.js";
|
|
5
|
-
import { readRunDbSync } from "./run-db.js";
|
|
6
2
|
const NAMES = { "claude-code": "Claude Code", codex: "Codex", pi: "pi" };
|
|
7
3
|
/** Requests by local hour of the day, from their times (ms). */
|
|
8
4
|
export function hoursOf(times) {
|
|
@@ -12,23 +8,6 @@ export function hoursOf(times) {
|
|
|
12
8
|
hours[new Date(at).getHours()] += 1;
|
|
13
9
|
return hours;
|
|
14
10
|
}
|
|
15
|
-
/** An imported run of `store`, as found: its metrics as the store keeps them, and its requests' times from its transcript,
|
|
16
|
-
* read by SQLite's JSON functions (no record is parsed here). Undefined for a run the store does not hold as imported. */
|
|
17
|
-
export async function foundIn(store, runId) {
|
|
18
|
-
const run = store.readRun(runId);
|
|
19
|
-
if (!run?.importedFrom)
|
|
20
|
-
return undefined;
|
|
21
|
-
const metrics = store.runMetrics(runId);
|
|
22
|
-
const file = store.runStorePath(runId);
|
|
23
|
-
let hours;
|
|
24
|
-
if (existsSync(file)) {
|
|
25
|
-
hours = readRunDbSync(file, false, (db) => {
|
|
26
|
-
const rows = db.prepare("SELECT json_extract(record, '$.model[0].timestamp') AS at FROM entries WHERE json_extract(record, '$.kind') = 'pi.assistant'").all();
|
|
27
|
-
return hoursOf(rows.map((row) => Number(row.at)));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return { source: run.importedFrom.source, agent: run.agent, ...(metrics ? { metrics } : {}), ...(hours ? { hours } : {}) };
|
|
31
|
-
}
|
|
32
11
|
const count = (n) => n.toLocaleString("en-US");
|
|
33
12
|
const compact = new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 });
|
|
34
13
|
const plural = (n, one) => `${count(n)} ${one}${n === 1 ? "" : "s"}`;
|
package/dist/import.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StorageWrite } from "@earendil-works/pi-durable";
|
|
2
|
-
import { type EntryLike } from "
|
|
2
|
+
import { type EntryLike } from "./timeline/index.js";
|
|
3
3
|
import { type Session, type Source } from "./import-sources.js";
|
|
4
4
|
import { type Found } from "./import-summary.js";
|
|
5
5
|
import { type Store } from "./store/index.js";
|
|
@@ -130,11 +130,11 @@ export declare function transcriptOf(session: Session, cut: (value: unknown) =>
|
|
|
130
130
|
entries: EntryLike[];
|
|
131
131
|
};
|
|
132
132
|
/** The secrets this server made and keeps, by value: its API token and its sign-in sessions' secret (still files beside the
|
|
133
|
-
* store), its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed,
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
|
|
137
|
-
* `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A
|
|
133
|
+
* store), and its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, as
|
|
134
|
+
* store rows (server-secrets-store.ts), opened with the seal key of `env`, which the caller has (a dry run over a store that
|
|
135
|
+
* keeps no secret has none, and does not ask); each signing secret's key in every spelling too. One pasted into a
|
|
136
|
+
* session is this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
|
|
137
|
+
* `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A sealed value that does not
|
|
138
138
|
* open is said to `say`: the import goes on, and does not cut it. */
|
|
139
139
|
export declare function ownSecrets(store: {
|
|
140
140
|
triggerSettings: Pick<Store["triggerSettings"], "get" | "put" | "removeScope">;
|