@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/store-view.js
CHANGED
|
@@ -4,15 +4,21 @@
|
|
|
4
4
|
// model sees do not change. runs.ts still answers the API from files; this is the store-backed path the server cut switches
|
|
5
5
|
// onto. viewOverStore answers the run read, summaryOverStore the run list, momentOverStore the one acceptance each act reads.
|
|
6
6
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
7
|
+
import { CAPS } from "./timeline/index.js";
|
|
7
8
|
import { runLink } from "./console-links.js";
|
|
8
9
|
import { redacted, redactedAnswer, redactedOutput, withoutLoopback } from "./key-refusal.js";
|
|
10
|
+
import { structuredAnswer } from "./answer-json.js";
|
|
9
11
|
import { currentLearning, holdsForOk, learningView, LEARNING_LABEL, secretsShown, shortOf } from "./learning.js";
|
|
12
|
+
import { said } from "./learning-words.js";
|
|
13
|
+
import { CONTENT_FILTER_WORDS, contentFiltered, MODERATED } from "./content-filter.js";
|
|
10
14
|
import { launchOf } from "./handed-values.js";
|
|
11
|
-
import { learningStartOf } from "./run-launch.js";
|
|
12
|
-
import { momentOf, pendingOf, approvalOf, asksOf, answersOf, budgetOf, browserPending, computerPending, redactorOf, servedRunErrorWith, servedReviewWith, statusOf, WITHHELD_SIGN_IN, WITHHELD_TITLE, costView, soFarOf, withAsks, withApprovalRows, } from "./run-view.js";
|
|
13
|
-
import { reflects } from "./
|
|
15
|
+
import { learningStartOf, seedFailed } from "./run-launch.js";
|
|
16
|
+
import { momentOf, pendingOf, approvalOf, asksOf, answersOf, activePauseOf, budgetOf, browserPending, computerPending, redactorOf, servedRunErrorWith, servedReviewWith, statusOf, WITHHELD_SIGN_IN, WITHHELD_TITLE, costView, soFarOf, withAsks, withApprovalRows, } from "./run-view.js";
|
|
17
|
+
import { reflects } from "./reflect-range.js";
|
|
18
|
+
import { overCapMessage, SPEND_CAP_REACHED } from "@parcha/agentrun-kernel/kernel/cap";
|
|
19
|
+
import { bookedSpend } from "./runner/metrics.js";
|
|
14
20
|
import { journalRecords, recordOf } from "./runner/journal-reader.js";
|
|
15
|
-
import { KINDS } from "./runner/journal-kinds.js";
|
|
21
|
+
import { capNowOf, KINDS } from "./runner/journal-kinds.js";
|
|
16
22
|
import { notesReadOf, runLearningEnd, withNotes } from "./store-reads/learning.js";
|
|
17
23
|
import { runReflect, runTimeline, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
|
|
18
24
|
import { readRun } from "./store-reads/runs.js";
|
|
@@ -56,9 +62,19 @@ function servedOnce(store, runId, input, values) {
|
|
|
56
62
|
}
|
|
57
63
|
/** A run's whole answer as answerOfRun read it from the rows: its newest final-answer row, never the learning turn's. */
|
|
58
64
|
const answerOf = (rows) => rows.findLast((r) => r.kind === "final_answer" && r.agent_label !== LEARNING_LABEL)?.text ?? null;
|
|
59
|
-
/** A failed run's error from its row (its own words are the summary; the store keeps no code or detail apart).
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
/** A failed run's error from its row (its own words are the summary; the store keeps no code or detail apart). A run
|
|
66
|
+
* its cap ended once its cost passed it (the kernel's overCapEnd) is code spend_cap_reached, its message the words after
|
|
67
|
+
* the code, as main served it; a provider's content-filter stop is `moderated`, in words a person can act on
|
|
68
|
+
* (content-filter.ts); every other failure is run_failed. */
|
|
69
|
+
const errorOfRow = (summary) => {
|
|
70
|
+
const over = overCapMessage(summary);
|
|
71
|
+
if (over !== undefined)
|
|
72
|
+
return { code: SPEND_CAP_REACHED, message: over, retryable: false };
|
|
73
|
+
if (summary !== null && contentFiltered(summary))
|
|
74
|
+
return { code: MODERATED, message: CONTENT_FILTER_WORDS, retryable: false };
|
|
75
|
+
return { code: "run_failed", message: summary ?? "The run failed.", retryable: false };
|
|
76
|
+
};
|
|
77
|
+
const reviewOfRow = (state, summary, kept) => (state !== "escalated" ? null : (kept ?? { kind: null, node: null, reason: summary ?? "The workflow escalated." }));
|
|
62
78
|
const reviewAt = (review, endedAt) => (review ? { kind: review.kind, node: review.node, reason: review.reason, at: endedAt } : null);
|
|
63
79
|
/** A run's facts as statusOf and momentOf read them, built from the run's journal: whether it stands parked at its cap
|
|
64
80
|
* (an active agentrun.budget park), and the browser ask it waits on (wired next). A terminal run reaches none of them
|
|
@@ -103,7 +119,12 @@ async function storeRunOf(store, runId, deps) {
|
|
|
103
119
|
const harness = launch?.harness ?? harnessOfBody((revision?.body ?? {}));
|
|
104
120
|
// Whether the run ran unattended, from the revision it is pinned to (approvals "never"), else the default (ask).
|
|
105
121
|
const approvalsMode = approvalsOf(revision?.body?.approvals);
|
|
122
|
+
const outputSchema = row.kind === "agentic" ? revision?.body?.outputSchema : undefined;
|
|
106
123
|
const terminal = row.state !== "running";
|
|
124
|
+
// Its structured answer, from the final answer as the journal keeps it: never the served text, which a held value
|
|
125
|
+
// (a number among them) or a long answer's cut would have changed, so a block that meets the schema reads as written.
|
|
126
|
+
const rawAnswer = outputSchema !== undefined && terminal ? answerOf(await runTimeline(store, runId, context, { settled: true, caps: { text: Number.POSITIVE_INFINITY } })) : null;
|
|
127
|
+
const structured = rawAnswer ? structuredAnswer(rawAnswer, outputSchema) : undefined;
|
|
107
128
|
// The timeline, then the waiting row a run asking a question shows (withAsks), as the file path's rows carried it, so a
|
|
108
129
|
// run waiting on a question reads the same status and pending.
|
|
109
130
|
// Its final answer whole (store-reads/journal.ts wholeAnswers), as main served a run's answer: a row's cut is no answer's.
|
|
@@ -123,9 +144,17 @@ async function storeRunOf(store, runId, deps) {
|
|
|
123
144
|
const records = await journalRecords(store.readJournal(runId), context);
|
|
124
145
|
const reflectRange = (await runReflect(store, runId, context));
|
|
125
146
|
const skip = reflectRange ? (id) => reflects(reflectRange, id) : undefined;
|
|
126
|
-
// The run's learning end with the notes its start gave it and those its job read (its own reads, keyed on the given
|
|
147
|
+
// The run's learning end with the notes its start gave it and those its job read (its own reads, keyed on the given, read
|
|
148
|
+
// from its rows uncut: a note whose name holds a secret is cut where it is shown, after it is matched). Before its end, a
|
|
149
|
+
// run that learns is seeded, then looking back once its end-of-run turn starts (main's seeded and reflecting).
|
|
127
150
|
const started = launch ? learningStartOf(launch) : undefined;
|
|
128
|
-
const
|
|
151
|
+
const read = started?.given.length ? notesReadOf(started.given, reflectRange, await runTimeline(store, runId, context, { settled: terminal })) : [];
|
|
152
|
+
const under = !ended && started && !seedFailed(started) ? underWay(started, reflectRange, iso(runRow.startedAt)) : null;
|
|
153
|
+
const sofar = ended ?? under;
|
|
154
|
+
const shownEnd = sofar && withNotes(sofar, started, read);
|
|
155
|
+
// What it held for its owner's OK as it reads now, on its agent's folder's main (learning.ts currentLearning); its record
|
|
156
|
+
// stays as the merge wrote it.
|
|
157
|
+
const learningEnd = shownEnd && holdsForOk(shownEnd) && deps.statuses ? currentLearning(shownEnd, await deps.statuses(row.agent)) : shownEnd;
|
|
129
158
|
const turns = new Turns();
|
|
130
159
|
turns.note(recordOf(records.entries), records.submissions ?? [], skip, liveRow?.updatedAt ?? deps.now?.() ?? Date.now());
|
|
131
160
|
const working = live && turns.open > 0;
|
|
@@ -141,14 +170,14 @@ async function storeRunOf(store, runId, deps) {
|
|
|
141
170
|
// The rows a person reads: each call that waited for approval in order (held, your approval, what came of it), its
|
|
142
171
|
// arguments and the person's notes through the run's redactor, as the file path's withApprovals served them.
|
|
143
172
|
const rows = withApprovalRows(timeline, approvals, answers, redactorOf(values));
|
|
144
|
-
// The run's cap as it stands
|
|
145
|
-
//
|
|
146
|
-
const
|
|
147
|
-
const capUsd = launch?.maxCostUsd === undefined ? undefined : Math.max(launch.maxCostUsd, raisedCapUsd?.capUsd ?? 0);
|
|
173
|
+
// The run's cap as it stands, through the one reader the runner's gate reads too (capNowOf): a raise taken shows in the
|
|
174
|
+
// run's cost.cap_usd and its budget card, never the old cap.
|
|
175
|
+
const capUsd = capNowOf(launch?.maxCostUsd, records.entries);
|
|
148
176
|
const meta = { ...(capUsd !== undefined ? { max_cost_usd: capUsd } : {}), ...(Object.keys(answers).length ? { approvals: answers } : {}) };
|
|
149
177
|
// The budget card the run shows while it stands parked at its cap, from its journal's agentrun.budget park (none once a
|
|
150
178
|
// raise clears it). Read over the same meta cap and rows the card's figures and time come from.
|
|
151
179
|
const budget = budgetOf(records.entries, { meta, rows, updatedAt: iso(updatedAtMs) });
|
|
180
|
+
const pause = activePauseOf(records.entries);
|
|
152
181
|
// Whether a workflow run stands paused in its process now (its parked row with the pause's words, its newest pause not
|
|
153
182
|
// resumed), the `paused` fact the status table reads for a paused workflow.
|
|
154
183
|
const paused = pausedOf(runRow, records.entries);
|
|
@@ -194,21 +223,31 @@ async function storeRunOf(store, runId, deps) {
|
|
|
194
223
|
// The cap pause's words, so the moment reads paused for a store budget park (the write half's raiseCap/sendMessage read
|
|
195
224
|
// moment.paused/pausedWords); the file path's turns-based pausedAt gives nothing over the store.
|
|
196
225
|
...(budget?.kind === "budget" ? { pausedWords: budget.said } : {}),
|
|
226
|
+
// The park's own id: a raise's answer names the follow-up the runner sends for this pause (raiseFollowUpId).
|
|
227
|
+
...(budget?.kind === "budget" && pause !== undefined ? { pause } : {}),
|
|
197
228
|
meta,
|
|
198
229
|
};
|
|
199
230
|
// A completed workflow run's output, from its end (the workflow loop keeps it there, as main kept it on the run).
|
|
200
231
|
const end = row.kind === "workflow" ? records.entries.findLast((entry) => entry.kind === KINDS.end) : undefined;
|
|
201
232
|
const output = end?.data?.output ?? null;
|
|
202
|
-
|
|
233
|
+
// An escalated workflow run's review, as its end kept it (the escalate node's kind, label and summary).
|
|
234
|
+
const review = end?.data?.review;
|
|
235
|
+
// What its decisions booked (their own session, never on the usage row, which counts its model requests and paid tools).
|
|
236
|
+
const booked = bookedSpend(records.entries, "decisions");
|
|
237
|
+
const decisions = booked.requests ? booked : undefined;
|
|
238
|
+
return { row, runRow, launch, rows, version, harness, learningEnd, view, unshown, values, live, updatedAtMs, lastProgressAt, budget, paused, browserAsk, computerAsk, approvalsMode, output, ...(review ? { review } : {}), structured, decisions };
|
|
203
239
|
}
|
|
204
|
-
/** A run's learning as the view shows it: its end from the store
|
|
205
|
-
*
|
|
206
|
-
* dropped) reads as it was written. */
|
|
240
|
+
/** A run's learning as the view shows it: its end from the store (what it held for the owner's OK as it reads now), in a
|
|
241
|
+
* person's words cut of the host's secrets now, and, for an ended run, the notes it read. */
|
|
207
242
|
function learningViewOf(learningEnd, shown, settled) {
|
|
208
243
|
if (!learningEnd)
|
|
209
244
|
return null;
|
|
210
|
-
|
|
211
|
-
|
|
245
|
+
return learningView(learningEnd, shown, settled);
|
|
246
|
+
}
|
|
247
|
+
/** A learning run's learning before its end (main's learning-run.ts onStart and its end-of-run turn): seeded, saying how
|
|
248
|
+
* many notes its seed held, until its end-of-run turn starts; then looking back. */
|
|
249
|
+
function underWay(started, reflect, at) {
|
|
250
|
+
return reflect ? { state: "reflecting", reason: null, detail: said.reflecting, at } : { state: "seeded", reason: null, detail: said.seeded(started.seedNotes ?? 0), at };
|
|
212
251
|
}
|
|
213
252
|
/** The cost a run's view shows (runs.ts cost): its rows' cost, else what the store kept; a cap's room noted when it has
|
|
214
253
|
* one. A terminal run holds no request in flight, so its overshoot bound is 0. */
|
|
@@ -219,8 +258,10 @@ function costOfView(run) {
|
|
|
219
258
|
// no stored cost (its column is written only at the end), so it reads undefined, which costView turns into 0 before any
|
|
220
259
|
// request — never null.
|
|
221
260
|
const stored = run.row.state === "running" ? undefined : run.runRow.costUsd;
|
|
222
|
-
|
|
223
|
-
const
|
|
261
|
+
// Its decisions' booked cost joins its usage row's (costView), one unknown making it unknown.
|
|
262
|
+
const decisions = run.decisions;
|
|
263
|
+
const usd = imported ? (stored ?? null) : costView(run.rows, stored, decisions ? decisions.usd : undefined);
|
|
264
|
+
const soFar = usd === null && !imported ? soFarOf(run.rows, decisions ? { known: decisions.known, unpriced: decisions.unpriced } : undefined) : undefined;
|
|
224
265
|
// The run's cap as it stands (its view's meta: the newest raise's, else the launch's).
|
|
225
266
|
const cap = run.view.meta.max_cost_usd;
|
|
226
267
|
const bound = cap === undefined ? {} : { overshoot_bound_usd: 0 };
|
|
@@ -231,7 +272,7 @@ export async function viewOverStore(store, runId, deps) {
|
|
|
231
272
|
const run = await storeRunOf(store, runId, deps);
|
|
232
273
|
if (!run)
|
|
233
274
|
return undefined;
|
|
234
|
-
const { row, runRow, launch, view, unshown, values, output } = run;
|
|
275
|
+
const { row, runRow, launch, view, unshown, values, output, review: kept, structured } = run;
|
|
235
276
|
const { status, state } = statusOf(view, factsOf(run));
|
|
236
277
|
const terminal = TERMINAL.has(status);
|
|
237
278
|
const endedAtMs = terminal ? (runRow.endedAt ?? runRow.startedAt) : null;
|
|
@@ -240,10 +281,26 @@ export async function viewOverStore(store, runId, deps) {
|
|
|
240
281
|
// was cut; else the rows' redactor over what was never cut): served again through redactedAnswer once per that set.
|
|
241
282
|
const servedAnswer = (text) => (text ? servedOnce(store, runId, text, values) : text);
|
|
242
283
|
const finalAnswer = row.kind === "workflow" || unshown ? null : answerOf(run.rows) ?? row.summary ?? null;
|
|
243
|
-
// A workflow run's output, as its end kept it
|
|
244
|
-
//
|
|
245
|
-
|
|
246
|
-
|
|
284
|
+
// A workflow run's output, as its end kept it; an agentic run's, its final answer's structured part when its agent has
|
|
285
|
+
// an output schema and the answer's last fenced json block meets it (storeRunOf's `structured`), else none. Served as
|
|
286
|
+
// runs.ts serves it (servedOutput): each string in it cut of the values the run holds, its shape kept; none while the
|
|
287
|
+
// run's sign-in can't be read back.
|
|
288
|
+
const ownOutput = row.kind === "workflow" ? output : status === "completed" && structured && "value" in structured ? structured.value : null;
|
|
289
|
+
const servedOutput = !unshown && ownOutput !== null && ownOutput !== undefined ? redactedOutput(ownOutput, values) : null;
|
|
290
|
+
// A run its cap ended once its cost passed it (spend_cap_reached) keeps the answer it paid for, as main kept it: the
|
|
291
|
+
// response that crossed the cap was answered and billed, so its text is the run's answer, cut as it came.
|
|
292
|
+
// Its answer is the newest answer row, else (a response cut at its length) the newest text it said; never the row's
|
|
293
|
+
// summary, which holds the cap's words.
|
|
294
|
+
const overCap = status === "failed" && overCapMessage(row.summary ?? null) !== undefined;
|
|
295
|
+
// A text the timeline cut at its cap is read whole from the journal and served as an answer row is (wholeAnswerFor).
|
|
296
|
+
const capRow = overCap && !unshown ? (run.rows.findLast((r) => r.kind === "final_answer" && r.agent_label !== LEARNING_LABEL) ?? run.rows.findLast((r) => r.kind === "text_block" && r.agent_label !== LEARNING_LABEL)) : undefined;
|
|
297
|
+
let capAnswer = capRow?.text ?? null;
|
|
298
|
+
if (capRow?.kind === "text_block" && capAnswer !== null && (capAnswer.length >= CAPS.text || capAnswer.endsWith("...") || capAnswer === "[redacted]")) {
|
|
299
|
+
const whole = (await runTimeline(store, runId, BACKGROUND_CONTEXT, { settled: true, caps: { text: Number.POSITIVE_INFINITY } })).find((r) => r.id === capRow.id)?.text;
|
|
300
|
+
if (typeof whole === "string")
|
|
301
|
+
capAnswer = wholeAnswerFor(values).serve(whole);
|
|
302
|
+
}
|
|
303
|
+
const result = status === "completed" ? { output: servedOutput, final_answer: servedAnswer(finalAnswer) } : overCap ? { output: null, final_answer: servedAnswer(capAnswer) } : null;
|
|
247
304
|
// A failed run's reason in the model's own words when the store holds them: the last model-error row's text (a provider's
|
|
248
305
|
// refusal, rendered from its pi.assistant error entry), else the run row's summary (the runner's generic "gave no answer").
|
|
249
306
|
// It reads as the run's Timeline error row does (run-cut.ts runErrorWordsOf, main's errorWords): a refused key in plain
|
|
@@ -253,7 +310,7 @@ export async function viewOverStore(store, runId, deps) {
|
|
|
253
310
|
const errorWords = status === "failed" && !unshown ? await runErrorWordsOf({ ...deps, keyEnv: deps.keyEnv ?? (() => process.env) }, store, runId, { workflow: row.kind === "workflow" }) : undefined;
|
|
254
311
|
const withheld = unshown || errorWords === "unreadable";
|
|
255
312
|
const error = status === "failed" ? (withheld ? { code: "run_failed", message: WITHHELD_SIGN_IN, retryable: false } : servedRunErrorWith(errorWords ?? shownWords, errorOfRow(failedReason))) : null;
|
|
256
|
-
const review = endedAtMs === null ? null : servedReviewWith(shownWords, unshown, reviewAt(reviewOfRow(row.state, row.summary ?? null), iso(endedAtMs)));
|
|
313
|
+
const review = endedAtMs === null ? null : servedReviewWith(shownWords, unshown, reviewAt(reviewOfRow(row.state, row.summary ?? null, kept), iso(endedAtMs)));
|
|
257
314
|
// The card the run shows while it waits, in the order the file-backed view (runs.ts) picks them: a tool call parked for a
|
|
258
315
|
// person's approval (approvalOf, its arguments shown through the run's redactor), else a run parked at its cap (the budget
|
|
259
316
|
// card), else its agent waiting on a person in its browser (browserPending), else the question its turn ended on (pendingOf).
|
|
@@ -313,6 +370,17 @@ export async function summaryOverStore(store, runId, deps) {
|
|
|
313
370
|
learning: learning ? shortOf(learning) : null,
|
|
314
371
|
};
|
|
315
372
|
}
|
|
373
|
+
/** A run's facts as its view states them, and none of its words: its kind, revision, agent, status and times, and whether
|
|
374
|
+
* its output is withheld (`unshown`). What a read that serves its own parts (the graph) needs of the run: read off the
|
|
375
|
+
* run as viewOverStore reads it, with nothing of it served, so nothing is redacted here. Undefined for an unknown run. */
|
|
376
|
+
export async function factsOverStore(store, runId, deps) {
|
|
377
|
+
const run = await storeRunOf(store, runId, deps);
|
|
378
|
+
if (!run)
|
|
379
|
+
return undefined;
|
|
380
|
+
const { status } = statusOf(run.view, factsOf(run));
|
|
381
|
+
const endedAtMs = TERMINAL.has(status) ? (run.runRow.endedAt ?? run.runRow.startedAt) : null;
|
|
382
|
+
return { kind: run.row.kind, revision: run.row.revision, agentId: run.row.agent, status, createdAt: iso(run.runRow.startedAt), endedAt: endedAtMs === null ? null : iso(endedAtMs), unshown: run.unshown };
|
|
383
|
+
}
|
|
316
384
|
/** A run's live moment from the store (momentOf), for the one acceptance each act a run takes reads. A run no runner holds
|
|
317
385
|
* (ended, or running with no live claim) reads live false. */
|
|
318
386
|
export async function momentOverStore(store, runId, deps = { origin: "", serverSecrets: () => [] }) {
|
package/dist/template-eval.d.ts
CHANGED
|
@@ -40,11 +40,26 @@ export type Grader = {
|
|
|
40
40
|
schema: string;
|
|
41
41
|
validate: Validate;
|
|
42
42
|
};
|
|
43
|
-
/** One answer of a fake tool: taken when every argument `when` lists equals the call's
|
|
43
|
+
/** One answer of a fake tool: taken when every argument `when` lists equals the call's; `when` a list, when any one of
|
|
44
|
+
* its entries does (one answer for each spelling of a call: a file by `sha` or by `ref`, say). */
|
|
44
45
|
type Answer = {
|
|
45
|
-
when: Json;
|
|
46
|
+
when: Json | Json[];
|
|
46
47
|
result: Json;
|
|
47
48
|
};
|
|
49
|
+
/** A fake code search: the call's `query` argument searched over `files` (GitHub's code search syntax, read loosely: bare
|
|
50
|
+
* and quoted terms every one of which a file holds, /.../ terms read as literal text (a backslash before punctuation
|
|
51
|
+
* dropped), never as a regular expression, so no query can stall the eval, NOT before a term or a qualifier, and the
|
|
52
|
+
* path:, filename:, extension: and language: qualifiers; the others ignored), answered as `path:line: text` lines, at
|
|
53
|
+
* most `limit` (default 100), after `note` when given. Taken when no answer of the tool matches the call. */
|
|
54
|
+
export type FakeSearch = {
|
|
55
|
+
query: string;
|
|
56
|
+
files: {
|
|
57
|
+
path: string;
|
|
58
|
+
text: string;
|
|
59
|
+
}[];
|
|
60
|
+
limit?: number;
|
|
61
|
+
note?: string;
|
|
62
|
+
};
|
|
48
63
|
export type McpFixture = {
|
|
49
64
|
server: string;
|
|
50
65
|
description: string;
|
|
@@ -53,6 +68,7 @@ export type McpFixture = {
|
|
|
53
68
|
input: Json;
|
|
54
69
|
answers: Answer[];
|
|
55
70
|
default?: Json;
|
|
71
|
+
search?: FakeSearch;
|
|
56
72
|
}>;
|
|
57
73
|
};
|
|
58
74
|
export type EvalCase = {
|
|
@@ -114,10 +130,10 @@ export type Verdict = {
|
|
|
114
130
|
cost_usd?: number | null;
|
|
115
131
|
run_id?: string;
|
|
116
132
|
};
|
|
117
|
-
/** The text of the last fenced `json` block in `text` (```json or a longer fence, ~~~ too), or undefined. */
|
|
118
|
-
export declare function lastJsonBlock(text: string): string | undefined;
|
|
119
133
|
/** Whether `fixture`'s tool answers `args` with one of its answers (the first whose `when` matches), else its default. */
|
|
120
134
|
export declare function fakeAnswer(fixture: McpFixture, tool: string, args: Json): Json;
|
|
135
|
+
/** A fake search's answer for `query` (FakeSearch). */
|
|
136
|
+
export declare function searched(search: FakeSearch, query: string): string;
|
|
121
137
|
/** A deterministic grader's verdict on one run: every type but llm. */
|
|
122
138
|
export declare function gradeDeterministic(grader: Exclude<Grader, {
|
|
123
139
|
type: "llm";
|
|
@@ -141,10 +157,26 @@ export type Fake = {
|
|
|
141
157
|
/** A fake MCP server for `fixture` on loopback, Streamable HTTP through the official SDK, one stateless server per
|
|
142
158
|
* request; every tool call is recorded (its gate name and arguments) and answered from the fixture. */
|
|
143
159
|
export declare function startFake(name: string, fixture: McpFixture): Promise<Fake>;
|
|
160
|
+
type Answered = {
|
|
161
|
+
status: number;
|
|
162
|
+
body: unknown;
|
|
163
|
+
};
|
|
164
|
+
/** `statusOnly`: the answer's status alone, its body cancelled unread (a file's existence, never its bytes). `signal`: the
|
|
165
|
+
* request and the read of its body stop when it aborts, and the call rejects. */
|
|
166
|
+
export type Api = (method: string, path: string, body?: unknown, headers?: Record<string, string>, options?: {
|
|
167
|
+
statusOnly?: true;
|
|
168
|
+
signal?: AbortSignal;
|
|
169
|
+
}) => Promise<Answered>;
|
|
144
170
|
/** The calls in a run's rows: each tool_use row by its gate name, with its result's status and preview. */
|
|
145
171
|
/** A run's tool calls, each named as a grader names it: the gate's own rule (RunGate.enter), its settings key, but a
|
|
146
172
|
* shell tool held to bash's setting (bash_background, bash_output, ...) keeps its own name, so its grader sees it. */
|
|
147
173
|
export declare function callsOf(rows: readonly Json[], harness: string, servers: readonly string[]): ToolCall[];
|
|
174
|
+
/** How long a run's metrics read may take before the run is reported without them. */
|
|
175
|
+
export declare const METRICS_TIMEOUT_MS = 10000;
|
|
176
|
+
/** The metrics of the one run `agentId` made (RunMetrics), from GET /stats?agent=; null when the server kept none (the run
|
|
177
|
+
* has not ended, or ended without them) or the read fails, takes over `timeoutMs`, or is stopped by `signal` (the eval's
|
|
178
|
+
* stop, which its caller then throws): a run's result never fails on its metrics. */
|
|
179
|
+
export declare function metricsOf(api: Api, agentId: string, signal?: AbortSignal, timeoutMs?: number): Promise<RunMetrics | null>;
|
|
148
180
|
export type EvalOptions = {
|
|
149
181
|
/** The package's folder. */
|
|
150
182
|
dir: string;
|
|
@@ -179,6 +211,24 @@ export type GraderResult = {
|
|
|
179
211
|
cost_usd: number | null;
|
|
180
212
|
run_id?: string;
|
|
181
213
|
};
|
|
214
|
+
/** A run's tokens, model requests and tool calls as its end wrote them (GET /stats over the run's agent: an eval makes a
|
|
215
|
+
* fresh agent for each run). `input` excludes cached input: the whole prompt is `input + cache_read + cache_write`.
|
|
216
|
+
* `tools` is GET /stats' 20 most-called tools, and `tool_calls` sums them: a run that called more than 20 tools counts low. */
|
|
217
|
+
export type RunMetrics = {
|
|
218
|
+
input: number;
|
|
219
|
+
cache_read: number;
|
|
220
|
+
cache_write: number;
|
|
221
|
+
output: number;
|
|
222
|
+
requests: number;
|
|
223
|
+
unmetered: number;
|
|
224
|
+
tool_calls: number;
|
|
225
|
+
tools: Record<string, {
|
|
226
|
+
calls: number;
|
|
227
|
+
errors: number;
|
|
228
|
+
}>;
|
|
229
|
+
};
|
|
230
|
+
/** `answer`, `calls`, `mcp_calls`, `created_at`, `ended_at` and `metrics`: what the run left, kept in the report so a caller scores the
|
|
231
|
+
* run itself after the eval's temp server is gone (a hill climb's parser and judge, say). */
|
|
182
232
|
export type RunResult = {
|
|
183
233
|
run: number;
|
|
184
234
|
agent_id: string | null;
|
|
@@ -188,6 +238,12 @@ export type RunResult = {
|
|
|
188
238
|
error?: string;
|
|
189
239
|
cost_usd: number | null;
|
|
190
240
|
graders: GraderResult[];
|
|
241
|
+
answer?: string;
|
|
242
|
+
calls?: ToolCall[];
|
|
243
|
+
mcp_calls?: ToolCall[];
|
|
244
|
+
created_at?: string | null;
|
|
245
|
+
ended_at?: string | null;
|
|
246
|
+
metrics?: RunMetrics | null;
|
|
191
247
|
};
|
|
192
248
|
export type CaseResult = {
|
|
193
249
|
name: string;
|
package/dist/template-eval.js
CHANGED
|
@@ -13,14 +13,14 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
13
13
|
import { chmodSync, cpSync, lstatSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
|
14
14
|
import { tmpdir } from "node:os";
|
|
15
15
|
import { join } from "node:path";
|
|
16
|
-
import { Compile } from "typebox/schema";
|
|
17
16
|
import { parseDocument } from "yaml";
|
|
17
|
+
import { answerJson, lastJsonBlock, schemaCheck } from "./answer-json.js";
|
|
18
18
|
import { checkNote } from "./learn/index.js";
|
|
19
19
|
import { NOTE_FILE } from "./learn/notes.js";
|
|
20
|
-
import { MCP_SERVER_NAME } from "./mcp-
|
|
20
|
+
import { MCP_SERVER_NAME } from "./mcp-probe.js";
|
|
21
21
|
import { settingsKeyOf, shellToolOf } from "./tool-gate.js";
|
|
22
22
|
import { ASK_TOOL, BOUND_TOOLS } from "./tools.js";
|
|
23
|
-
import { applyBodyOf, compiled, packageView, readPackage } from "./templates.js";
|
|
23
|
+
import { applyBodyOf, compiled, filledPins, packageView, readPackage } from "./templates.js";
|
|
24
24
|
import { isObject, MODEL_REF } from "./validate.js";
|
|
25
25
|
/** What a grader run is told, whatever the rubric: blind, strict, and its verdict as one JSON block. */
|
|
26
26
|
export const GRADER_INSTRUCTIONS = `You grade one run of an AI agent against one rubric. You see the rubric, the task the agent was given, its answer, and the tool calls it made; nothing else, and nothing else matters.
|
|
@@ -115,13 +115,17 @@ function fixtureOf(text, name, at, bad) {
|
|
|
115
115
|
const tools = {};
|
|
116
116
|
for (const [tool, spec] of Object.entries(value.tools)) {
|
|
117
117
|
const answers = isObject(spec) && Array.isArray(spec.answers) ? spec.answers : undefined;
|
|
118
|
-
const
|
|
119
|
-
|
|
118
|
+
const search = isObject(spec) ? spec.search : undefined;
|
|
119
|
+
const searchOk = search === undefined || (isObject(search) && !unknown(search, ["query", "files", "limit", "note"]).length && typeof search.query === "string" && search.query !== ""
|
|
120
|
+
&& Array.isArray(search.files) && search.files.every((f) => isObject(f) && typeof f.path === "string" && typeof f.text === "string")
|
|
121
|
+
&& (search.limit === undefined || (Number.isSafeInteger(search.limit) && search.limit >= 1)) && (search.note === undefined || typeof search.note === "string"));
|
|
122
|
+
const ok = isObject(spec) && !unknown(spec, ["description", "input", "answers", "default", "search"]).length && searchOk && typeof spec.description === "string" && isObject(spec.input) && spec.input.type === "object"
|
|
123
|
+
&& answers !== undefined && answers.every((a) => isObject(a) && !unknown(a, ["when", "result"]).length && (isObject(a.when) || (Array.isArray(a.when) && a.when.length > 0 && a.when.every(isObject))) && isObject(a.result)) && (spec.default === undefined || isObject(spec.default));
|
|
120
124
|
if (!ok || !/^[A-Za-z0-9_.-]{1,128}$/.test(tool)) {
|
|
121
|
-
bad(`${at}: tools.${tool} is {description, input: an object's JSON Schema, answers: [{when: {...}, result: an MCP tool result}], default?: a result}`);
|
|
125
|
+
bad(`${at}: tools.${tool} is {description, input: an object's JSON Schema, answers: [{when: {...} or [{...}, ...], result: an MCP tool result}], default?: a result, search?: {query: the argument's name, files: [{path, text}], limit?, note?}}`);
|
|
122
126
|
continue;
|
|
123
127
|
}
|
|
124
|
-
tools[tool] = { description: spec.description, input: spec.input, answers: answers, ...(isObject(spec.default) ? { default: spec.default } : {}) };
|
|
128
|
+
tools[tool] = { description: spec.description, input: spec.input, answers: answers, ...(isObject(spec.default) ? { default: spec.default } : {}), ...(isObject(spec.search) ? { search: spec.search } : {}) };
|
|
125
129
|
}
|
|
126
130
|
return { server: value.server, description: value.description, tools };
|
|
127
131
|
}
|
|
@@ -204,14 +208,10 @@ function graderOf(dir, p, file, text, mcp, bad) {
|
|
|
204
208
|
catch {
|
|
205
209
|
return bad(`${file}: ${path} is not JSON`), undefined;
|
|
206
210
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
catch (error) {
|
|
213
|
-
return bad(`${file}: ${path} does not compile as a JSON Schema: ${error.message}`), undefined;
|
|
214
|
-
}
|
|
211
|
+
const compiled = schemaCheck(schema);
|
|
212
|
+
if ("why" in compiled)
|
|
213
|
+
return bad(`${file}: ${path} ${compiled.why}`), undefined;
|
|
214
|
+
return { file, type, schema: path, validate: compiled.check };
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
return undefined;
|
|
@@ -328,35 +328,6 @@ export function readCases(dir, names) {
|
|
|
328
328
|
throw new CaseError(dir, problems);
|
|
329
329
|
return { pkg, cases };
|
|
330
330
|
}
|
|
331
|
-
/** The text of the last fenced `json` block in `text` (```json or a longer fence, ~~~ too), or undefined. */
|
|
332
|
-
export function lastJsonBlock(text) {
|
|
333
|
-
const lines = text.split(/\r?\n/);
|
|
334
|
-
let found;
|
|
335
|
-
for (let i = 0; i < lines.length; i++) {
|
|
336
|
-
const open = /^ {0,3}(`{3,}|~{3,})\s*json\s*$/i.exec(lines[i]);
|
|
337
|
-
if (!open)
|
|
338
|
-
continue;
|
|
339
|
-
const fence = open[1];
|
|
340
|
-
const end = lines.findIndex((line, j) => j > i && new RegExp(`^ {0,3}${fence[0] === "`" ? "`" : "~"}{${fence.length},}\\s*$`).test(line));
|
|
341
|
-
if (end < 0)
|
|
342
|
-
break;
|
|
343
|
-
found = lines.slice(i + 1, end).join("\n");
|
|
344
|
-
i = end;
|
|
345
|
-
}
|
|
346
|
-
return found;
|
|
347
|
-
}
|
|
348
|
-
/** The answer's last fenced json block, parsed, or why there is none. */
|
|
349
|
-
function answerJson(answer) {
|
|
350
|
-
const block = lastJsonBlock(answer);
|
|
351
|
-
if (block === undefined)
|
|
352
|
-
return { why: "the answer has no fenced json block" };
|
|
353
|
-
try {
|
|
354
|
-
return { value: JSON.parse(block) };
|
|
355
|
-
}
|
|
356
|
-
catch (error) {
|
|
357
|
-
return { why: `the answer's last json block is not JSON: ${error.message}` };
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
331
|
/** The text a grader with a `target` reads: that field of the answer's JSON (a string as it is, anything else as JSON). */
|
|
361
332
|
function targetOf(answer, target) {
|
|
362
333
|
const json = answerJson(answer);
|
|
@@ -379,8 +350,78 @@ export function fakeAnswer(fixture, tool, args) {
|
|
|
379
350
|
const spec = fixture.tools[tool];
|
|
380
351
|
if (!spec)
|
|
381
352
|
return { isError: true, content: [{ type: "text", text: `The fake ${fixture.server} has no tool ${tool}.` }] };
|
|
382
|
-
const
|
|
383
|
-
|
|
353
|
+
const matches = (when) => Object.entries(when).every(([key, value]) => Object.hasOwn(args, key) && same(args[key], value));
|
|
354
|
+
const hit = spec.answers.find((answer) => (Array.isArray(answer.when) ? answer.when.some(matches) : matches(answer.when)));
|
|
355
|
+
if (hit)
|
|
356
|
+
return hit.result;
|
|
357
|
+
if (spec.search && typeof args[spec.search.query] === "string")
|
|
358
|
+
return { content: [{ type: "text", text: searched(spec.search, args[spec.search.query]) }] };
|
|
359
|
+
return spec.default ?? { isError: true, content: [{ type: "text", text: `The fake ${fixture.server}'s ${tool} has no answer for these arguments.` }] };
|
|
360
|
+
}
|
|
361
|
+
/** Languages a search's language: qualifier names, by file extension. */
|
|
362
|
+
const LANGUAGES = {
|
|
363
|
+
typescript: [".ts", ".tsx", ".mts", ".cts"], ts: [".ts", ".tsx", ".mts", ".cts"], javascript: [".js", ".mjs", ".cjs", ".jsx"], js: [".js", ".mjs", ".cjs", ".jsx"],
|
|
364
|
+
python: [".py"], go: [".go"], rust: [".rs"], shell: [".sh", ".bash"], markdown: [".md"], json: [".json"], yaml: [".yml", ".yaml"], css: [".css"], html: [".html"],
|
|
365
|
+
};
|
|
366
|
+
/** A fake search's answer for `query` (FakeSearch). */
|
|
367
|
+
export function searched(search, query) {
|
|
368
|
+
const tokens = [...query.matchAll(/(-?)(\w+):("[^"]*"|\S+)|"([^"]*)"|\/((?:\\.|[^/])+)\/|(\S+)/g)];
|
|
369
|
+
const filters = [];
|
|
370
|
+
const terms = [];
|
|
371
|
+
let not = false;
|
|
372
|
+
for (const [, neg, key, rawValue, quoted, regex, bare] of tokens) {
|
|
373
|
+
const value = rawValue?.replace(/^"|"$/g, "");
|
|
374
|
+
if (key !== undefined && value !== undefined) {
|
|
375
|
+
const name = key.toLowerCase();
|
|
376
|
+
const keep = name === "path" ? (path) => path.includes(value.replace(/^\/+/, "").replace(/\*+/g, ""))
|
|
377
|
+
: name === "filename" ? (path) => (path.split("/").pop() ?? "").includes(value)
|
|
378
|
+
: name === "extension" ? (path) => path.endsWith(`.${value.replace(/^\./, "")}`)
|
|
379
|
+
: name === "language" && LANGUAGES[value.toLowerCase()] ? (path) => LANGUAGES[value.toLowerCase()].some((ext) => path.endsWith(ext))
|
|
380
|
+
: undefined;
|
|
381
|
+
// NOT before a qualifier excludes what it keeps, as -qualifier does; either way the NOT is spent here.
|
|
382
|
+
const exclude = (neg === "-") !== not;
|
|
383
|
+
not = false;
|
|
384
|
+
if (keep)
|
|
385
|
+
filters.push(exclude ? (path) => !keep(path) : keep);
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
if (bare === "AND" || bare === "OR")
|
|
389
|
+
continue;
|
|
390
|
+
if (bare === "NOT") {
|
|
391
|
+
not = true;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
// A /.../ term is its text, never a regular expression: the fake runs on the eval's thread, where a pattern such as
|
|
395
|
+
// /(a+)+$/ could hold it past any timeout. An escaped punctuation mark (\. \( \/) is that mark.
|
|
396
|
+
const literal = (regex !== undefined ? regex.replace(/\\([^\w\s])/g, "$1") : (quoted ?? bare ?? "")).toLowerCase();
|
|
397
|
+
if (!literal) {
|
|
398
|
+
not = false;
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
const test = (line) => line.toLowerCase().includes(literal);
|
|
402
|
+
terms.push({ test, not });
|
|
403
|
+
not = false;
|
|
404
|
+
}
|
|
405
|
+
const limit = search.limit ?? 100;
|
|
406
|
+
const wanted = terms.filter((t) => !t.not);
|
|
407
|
+
const shown = [];
|
|
408
|
+
let total = 0;
|
|
409
|
+
let files = 0;
|
|
410
|
+
for (const file of search.files) {
|
|
411
|
+
if (!filters.every((keep) => keep(file.path)))
|
|
412
|
+
continue;
|
|
413
|
+
const lines = file.text.split("\n");
|
|
414
|
+
if (!wanted.every((t) => lines.some(t.test)) || terms.some((t) => t.not && lines.some(t.test)))
|
|
415
|
+
continue;
|
|
416
|
+
files++;
|
|
417
|
+
const hits = wanted.length ? lines.flatMap((line, i) => (wanted.some((t) => t.test(line)) ? [`${file.path}:${i + 1}: ${line.trim().slice(0, 200)}`] : [])) : [`${file.path}:1: ${(lines[0] ?? "").trim().slice(0, 200)}`];
|
|
418
|
+
total += hits.length;
|
|
419
|
+
for (const hit of hits)
|
|
420
|
+
if (shown.length < limit)
|
|
421
|
+
shown.push(hit);
|
|
422
|
+
}
|
|
423
|
+
const head = `${total} matching line${total === 1 ? "" : "s"} in ${files} file${files === 1 ? "" : "s"}${total > shown.length ? ` (the first ${shown.length} shown)` : ""}`;
|
|
424
|
+
return [search.note ? `${search.note}\n${head}` : head, ...shown].join("\n");
|
|
384
425
|
}
|
|
385
426
|
/** A deterministic grader's verdict on one run: every type but llm. */
|
|
386
427
|
export function gradeDeterministic(grader, run, faked) {
|
|
@@ -512,6 +553,7 @@ function apiOf(baseUrl, token) {
|
|
|
512
553
|
method,
|
|
513
554
|
headers: { authorization: `Bearer ${token}`, ...(body === undefined ? {} : { "content-type": raw ? "text/markdown" : "application/json" }), ...headers },
|
|
514
555
|
...(body === undefined ? {} : { body: raw ? body : JSON.stringify(body) }),
|
|
556
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
515
557
|
}).catch((error) => {
|
|
516
558
|
throw new ApiFailure(`${method} ${path}: the server did not answer (${error.cause instanceof Error ? error.cause.message : error.message})`);
|
|
517
559
|
});
|
|
@@ -620,6 +662,29 @@ async function presentOf(api, runId, paths) {
|
|
|
620
662
|
return present;
|
|
621
663
|
}
|
|
622
664
|
const costOf = (view) => (isObject(view.cost) && typeof view.cost.usd === "number" ? view.cost.usd : null);
|
|
665
|
+
/** How long a run's metrics read may take before the run is reported without them. */
|
|
666
|
+
export const METRICS_TIMEOUT_MS = 10_000;
|
|
667
|
+
/** The metrics of the one run `agentId` made (RunMetrics), from GET /stats?agent=; null when the server kept none (the run
|
|
668
|
+
* has not ended, or ended without them) or the read fails, takes over `timeoutMs`, or is stopped by `signal` (the eval's
|
|
669
|
+
* stop, which its caller then throws): a run's result never fails on its metrics. */
|
|
670
|
+
export async function metricsOf(api, agentId, signal, timeoutMs = METRICS_TIMEOUT_MS) {
|
|
671
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
672
|
+
const bound = signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
673
|
+
const read = await api("GET", `/stats?agent=${encodeURIComponent(agentId)}`, undefined, {}, { signal: bound }).catch(() => undefined);
|
|
674
|
+
const analytics = read?.status === 200 && isObject(read.body) && isObject(read.body.analytics) ? read.body.analytics : undefined;
|
|
675
|
+
const totals = analytics && isObject(analytics.totals) ? analytics.totals : undefined;
|
|
676
|
+
if (!analytics || !totals || !(typeof totals.runs_with_metrics === "number" && totals.runs_with_metrics > 0))
|
|
677
|
+
return null;
|
|
678
|
+
const count = (value) => (typeof value === "number" && Number.isFinite(value) ? value : 0);
|
|
679
|
+
const tools = {};
|
|
680
|
+
for (const tool of Array.isArray(analytics.tools) ? analytics.tools : [])
|
|
681
|
+
if (isObject(tool) && typeof tool.tool === "string")
|
|
682
|
+
tools[tool.tool] = { calls: count(tool.calls), errors: count(tool.errors) };
|
|
683
|
+
return {
|
|
684
|
+
input: count(totals.input), cache_read: count(totals.cache_read), cache_write: count(totals.cache_write), output: count(totals.output),
|
|
685
|
+
requests: count(totals.requests), unmetered: count(totals.unmetered), tool_calls: Object.values(tools).reduce((sum, t) => sum + t.calls, 0), tools,
|
|
686
|
+
};
|
|
687
|
+
}
|
|
623
688
|
/** The /v2 base of an address: as given when it ends in /v2, else with /v2 added. */
|
|
624
689
|
export function v2Base(url) {
|
|
625
690
|
const trimmed = url.replace(/\/+$/, "");
|
|
@@ -809,6 +874,8 @@ async function ranOnce(ctx, one, n, fakes, agent, agentId, runId) {
|
|
|
809
874
|
const view = expectOk(`reading run ${runId}`, await api("GET", `/runs/${runId}`));
|
|
810
875
|
// A run that waits on a person (a question, an approval, its cap) is graded as it stands, then cancelled.
|
|
811
876
|
await settle(ctx, runId, ended.status);
|
|
877
|
+
// Its metrics once it has ended (a cancelled run's end writes them too), before the eval's server can go.
|
|
878
|
+
const metrics = await metricsOf(api, agentId, options.signal);
|
|
812
879
|
stopped();
|
|
813
880
|
const result = isObject(view.result) ? view.result : {};
|
|
814
881
|
const harness = isObject(agent.definition) && typeof agent.definition.harness === "string" ? agent.definition.harness : "pi";
|
|
@@ -823,7 +890,7 @@ async function ranOnce(ctx, one, n, fakes, agent, agentId, runId) {
|
|
|
823
890
|
})(),
|
|
824
891
|
};
|
|
825
892
|
stopped();
|
|
826
|
-
const base = { run: n, agent_id: agentId, run_id: runId, status: ended.status, cost_usd: costOf(view) };
|
|
893
|
+
const base = { run: n, agent_id: agentId, run_id: runId, status: ended.status, cost_usd: costOf(view), answer: record.answer, calls: record.calls, mcp_calls: record.mcpCalls, created_at: typeof view.created_at === "string" ? view.created_at : null, ended_at: typeof view.ended_at === "string" ? view.ended_at : null, metrics };
|
|
827
894
|
// Waiting on its person's answer (an ask_person question, a tool call's approval) is where such a run stops, and is
|
|
828
895
|
// graded; paused at its cap, or stopped, it did not get there.
|
|
829
896
|
const pending = isObject(view.pending) && typeof view.pending.kind === "string" ? view.pending.kind : undefined;
|
|
@@ -901,20 +968,19 @@ async function sameAsLocal(ctx, one, agent) {
|
|
|
901
968
|
throw new ApiFailure(`the server's ${pkg.name} package is not this folder's: it differs in ${[...new Set(differs)].sort().join(", ")}. The eval would measure the server's copy: run it without --server, or on a server that ships this version`);
|
|
902
969
|
}
|
|
903
970
|
/** The pins a case's apply fills (from its parameters) set on the in-process server before it applies, as an owner sets
|
|
904
|
-
* them (deploy/walk.md):
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
* owner's, left as they are: there an unpinned write stays deny and its case says so. */
|
|
971
|
+
* them (deploy/walk.md): the server's pin holds the call to the case's own target beside the agent's own, as it does in
|
|
972
|
+
* production. Another server's (--server) settings are its owner's, left as they are: there the agent's own pin alone
|
|
973
|
+
* holds the write. */
|
|
908
974
|
async function serverPins(ctx, one) {
|
|
909
975
|
const { api, pkg, options } = ctx;
|
|
910
976
|
if (options.server)
|
|
911
977
|
return;
|
|
912
978
|
const { parameters } = applyBodyOf(pkg, { parameters: one.parameters, grants: one.grants });
|
|
913
|
-
const
|
|
914
|
-
if (!
|
|
979
|
+
const pins = filledPins(pkg.mcp, parameters).filter(({ empty }) => !empty.length);
|
|
980
|
+
if (!pins.length)
|
|
915
981
|
return;
|
|
916
982
|
const settings = expectOk("reading the server's tool settings", await api("GET", "/settings/tools"));
|
|
917
|
-
for (const { tool, pin } of
|
|
983
|
+
for (const { tool, pin } of pins)
|
|
918
984
|
settings[tool] = { ...(isObject(settings[tool]) ? settings[tool] : {}), pin };
|
|
919
985
|
expectOk("pinning the case's writes on the server", await api("PUT", "/settings/tools", settings));
|
|
920
986
|
}
|