@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/templates.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type InputIssue } from "./errors.js";
|
|
|
2
2
|
import type { GitHubConnectionView } from "./github-connection.js";
|
|
3
3
|
import { type Tier } from "./model.js";
|
|
4
4
|
import { type PinValue } from "./tool-gate.js";
|
|
5
|
+
import { type BashPolicy } from "./bash-read-only.js";
|
|
5
6
|
import { type Json } from "./validate.js";
|
|
6
7
|
import { type Approvals } from "./approvals.js";
|
|
7
8
|
/** The packages this server ships. */
|
|
@@ -15,6 +16,9 @@ export declare const MANIFEST = "agent.md";
|
|
|
15
16
|
/** A package's model tier, mapped to the server's own (model.ts Tier: AGENT_MODEL_FAST, AGENT_MODEL, AGENT_MODEL_STRONG). */
|
|
16
17
|
export declare const MODEL_TIERS: Readonly<Record<string, Tier>>;
|
|
17
18
|
export declare const PARAMETER_TYPES: readonly ["string", "number", "integer", "boolean"];
|
|
19
|
+
/** What a string parameter's value is, for a form to ask for it as such: a schedule's cron line, or an IANA time zone
|
|
20
|
+
* (market-monitor's schedule). A form shows a schedule picker and a time-zone choice; the value is the same text. */
|
|
21
|
+
export declare const PARAMETER_FORMATS: readonly ["cron", "timezone"];
|
|
18
22
|
export declare const GRADER_TYPES: readonly ["llm", "regex", "tool_used", "file_exists", "schema"];
|
|
19
23
|
/** The keys a package may need: those Settings saves (a tool's or a model provider's), each one a run is handed. */
|
|
20
24
|
export declare const PACKAGE_SECRETS: readonly string[];
|
|
@@ -22,6 +26,9 @@ export declare const PACKAGE_SECRETS: readonly string[];
|
|
|
22
26
|
export declare const MAX_FILE_BYTES: number;
|
|
23
27
|
export declare const MAX_PACKAGE_BYTES: number;
|
|
24
28
|
export declare const MAX_PACKAGE_FILES = 256;
|
|
29
|
+
/** A file of a package's evals/ (a case's fake MCP server fixture, say), which no agent is given: its own bound, apart
|
|
30
|
+
* from the agent's files' limits above. The answer's schema is given to the agent, so under evals/ too it keeps those. */
|
|
31
|
+
export declare const MAX_EVAL_FILE_BYTES: number;
|
|
25
32
|
/** An MCP server a package uses: its tools, granted to the agent, and `allow`, those of them the package asks the owner to
|
|
26
33
|
* allow (a consent screen shows it). The package sets no permission itself: an apply's `grants`, the owner's answer, do.
|
|
27
34
|
* `pin`, by tool: the arguments each of its calls must carry (a value, or `${parameters.<name>}`), which apply writes as
|
|
@@ -39,6 +46,7 @@ type Parameter = {
|
|
|
39
46
|
description: string;
|
|
40
47
|
pattern?: string;
|
|
41
48
|
enum?: (string | number | boolean)[];
|
|
49
|
+
format?: (typeof PARAMETER_FORMATS)[number];
|
|
42
50
|
default?: string | number | boolean;
|
|
43
51
|
};
|
|
44
52
|
export type Package = {
|
|
@@ -62,10 +70,18 @@ export type Package = {
|
|
|
62
70
|
/** MCP servers by the name a server saves them under, and the tools of each the agent is granted. One `required`
|
|
63
71
|
* refuses an apply on a server that has not saved it; any other is skipped there, with a warning. */
|
|
64
72
|
mcp: McpNeed[];
|
|
73
|
+
/** A policy by tool (bash only: `read-only`, bash-read-only.ts), which apply writes as the tool's `policy` in the
|
|
74
|
+
* agent's tool settings, so the gate holds its runs to it whatever the tool's permission. */
|
|
75
|
+
toolPolicy?: {
|
|
76
|
+
bash: BashPolicy;
|
|
77
|
+
};
|
|
65
78
|
parameters: Record<string, Parameter>;
|
|
66
79
|
secrets: string[];
|
|
80
|
+
/** Each run's limits: its spend cap (the agent's max_cost_usd) and the tool calls each of its conversations may make
|
|
81
|
+
* (the agent's max_tool_calls, tool-budget.ts). */
|
|
67
82
|
budget?: {
|
|
68
|
-
per_run_usd
|
|
83
|
+
per_run_usd?: number;
|
|
84
|
+
tool_calls?: number;
|
|
69
85
|
};
|
|
70
86
|
learning?: boolean;
|
|
71
87
|
/** Whether the agent asks its person before a tool runs (`ask`) or runs unattended (`never`): the package's default,
|
|
@@ -94,8 +110,9 @@ export declare class PackageError extends Error {
|
|
|
94
110
|
* to acme/widgets." The package's name says what runs; the events are its accept's, the repositories its where
|
|
95
111
|
* conditions on /repository/full_name, when every rule names some. */
|
|
96
112
|
export declare function githubTriggerWords(packageName: string, source: Json): string;
|
|
97
|
-
/** What an apply says of a github trigger it skipped because GitHub is not connected here
|
|
98
|
-
|
|
113
|
+
/** What an apply says of a github trigger it skipped because GitHub is not connected here: what to do, and what the
|
|
114
|
+
* trigger would then run on, in the package's own words ("Code review runs on each pull request to acme/widgets."). */
|
|
115
|
+
export declare const githubTriggerUnconnected: (packageName: string, source: Json) => string;
|
|
99
116
|
/** Reads `dir` checked whole: a valid package, or PackageError with every problem found. */
|
|
100
117
|
export declare function readPackage(dir: string): Package;
|
|
101
118
|
/** What is wrong with the trigger bodies an apply makes (compiled's `triggers`), as POST /v2/triggers checks a body, all
|
|
@@ -125,6 +142,9 @@ export declare function packageView(p: Package): {
|
|
|
125
142
|
} | null;
|
|
126
143
|
effort: string | null;
|
|
127
144
|
tools: string[] | null;
|
|
145
|
+
tool_policy: {
|
|
146
|
+
bash: BashPolicy;
|
|
147
|
+
} | null;
|
|
128
148
|
mcp: {
|
|
129
149
|
server: string;
|
|
130
150
|
required: boolean;
|
|
@@ -138,7 +158,8 @@ export declare function packageView(p: Package): {
|
|
|
138
158
|
parameters: Record<string, Parameter>;
|
|
139
159
|
secrets: string[];
|
|
140
160
|
budget: {
|
|
141
|
-
per_run_usd
|
|
161
|
+
per_run_usd?: number;
|
|
162
|
+
tool_calls?: number;
|
|
142
163
|
} | null;
|
|
143
164
|
learning: boolean;
|
|
144
165
|
approvals_default: "ask" | "never";
|
|
@@ -171,18 +192,13 @@ export declare function packageModel(env: NodeJS.ProcessEnv, model: Package["mod
|
|
|
171
192
|
* owner's own setting; `grants`, the owner's answer at apply, alone are set to allow. A tool the package pins gets its
|
|
172
193
|
* pin, filled, in the agent's tool settings, whatever its permission; one whose pin fills empty (its parameter not
|
|
173
194
|
* given) is set to deny instead, granted or not, and named in `unpinned` (by gate name, with the parameters not given):
|
|
174
|
-
* a send with no destination set never runs.
|
|
175
|
-
* default) a filled pin is not written: it is named in `unkept`, with its values, for the server's settings, and the tool is
|
|
176
|
-
* set to deny unless the server's settings already pin it (`serverPinned`, by gate name): a write a template grants
|
|
177
|
-
* never runs without its pin, whatever the agent's approvals. */
|
|
195
|
+
* a send with no destination set never runs. */
|
|
178
196
|
export declare function compiled(p: Package, parameters: Json, chosen: {
|
|
179
197
|
harness?: string;
|
|
180
198
|
model?: string;
|
|
181
199
|
mcp: McpNeed[];
|
|
182
200
|
defaultTools: readonly string[];
|
|
183
201
|
grants: readonly string[];
|
|
184
|
-
pins?: boolean;
|
|
185
|
-
serverPinned?: ReadonlySet<string>;
|
|
186
202
|
approvals?: Approvals;
|
|
187
203
|
}, _deps?: TemplatesDeps): {
|
|
188
204
|
agent: Json;
|
|
@@ -191,9 +207,12 @@ export declare function compiled(p: Package, parameters: Json, chosen: {
|
|
|
191
207
|
tool: string;
|
|
192
208
|
parameters: string[];
|
|
193
209
|
}[];
|
|
194
|
-
unkept: {
|
|
195
|
-
tool: string;
|
|
196
|
-
pin: Record<string, PinValue>;
|
|
197
|
-
}[];
|
|
198
210
|
};
|
|
211
|
+
/** Each pin the package's MCP servers (`mcp`) set, by the tool's gate name, its values filled from `parameters`, and the
|
|
212
|
+
* parameters it names that were not given (`empty`, none when it fills whole). */
|
|
213
|
+
export declare function filledPins(mcp: readonly McpNeed[], parameters: Json): {
|
|
214
|
+
tool: string;
|
|
215
|
+
pin: Record<string, PinValue>;
|
|
216
|
+
empty: string[];
|
|
217
|
+
}[];
|
|
199
218
|
export {};
|
package/dist/templates.js
CHANGED
|
@@ -11,22 +11,26 @@ import { parseDocument } from "yaml";
|
|
|
11
11
|
import { invalid } from "./errors.js";
|
|
12
12
|
import { HARNESSES } from "./harness.js";
|
|
13
13
|
import { TOOL_KEY_ROWS } from "./key-words.js";
|
|
14
|
-
import { MCP_SERVER_NAME } from "./mcp-
|
|
14
|
+
import { MCP_SERVER_NAME } from "./mcp-probe.js";
|
|
15
15
|
import { chooseModel, harnessRuns, hostModel, MODEL_KEYS, THINKING_LEVELS } from "./model.js";
|
|
16
16
|
import { mcpToolName } from "./tool-gate.js";
|
|
17
|
-
import {
|
|
17
|
+
import { pinIssues, sortedPin } from "./tool-plane.js";
|
|
18
|
+
import { BASH_POLICIES } from "./bash-read-only.js";
|
|
18
19
|
import { BOUND_TOOLS } from "./tools.js";
|
|
19
20
|
import { TRIGGER_ADAPTERS } from "./trigger-adapters.js";
|
|
20
21
|
import { triggerBodyIssues } from "./triggers.js";
|
|
21
|
-
import { DEFAULT_INPUT_SCHEMA, definitionBodyIssues, inputIssues, isObject, MODEL_REF, unknownFields } from "./validate.js";
|
|
22
|
+
import { DEFAULT_INPUT_SCHEMA, definitionBodyIssues, inputIssues, isObject, MAX_TOOL_CALLS, MODEL_REF, unknownFields } from "./validate.js";
|
|
22
23
|
import { APPROVALS } from "./approvals.js";
|
|
23
24
|
export const TEMPLATES_DIR = fileURLToPath(new URL("../templates/", import.meta.url));
|
|
24
25
|
export const MANIFEST = "agent.md";
|
|
25
26
|
/** A package's model tier, mapped to the server's own (model.ts Tier: AGENT_MODEL_FAST, AGENT_MODEL, AGENT_MODEL_STRONG). */
|
|
26
27
|
export const MODEL_TIERS = { fast: "fast", balanced: "default", strong: "strong" };
|
|
27
28
|
export const PARAMETER_TYPES = ["string", "number", "integer", "boolean"];
|
|
29
|
+
/** What a string parameter's value is, for a form to ask for it as such: a schedule's cron line, or an IANA time zone
|
|
30
|
+
* (market-monitor's schedule). A form shows a schedule picker and a time-zone choice; the value is the same text. */
|
|
31
|
+
export const PARAMETER_FORMATS = ["cron", "timezone"];
|
|
28
32
|
export const GRADER_TYPES = ["llm", "regex", "tool_used", "file_exists", "schema"];
|
|
29
|
-
const FIELDS = ["name", "display_name", "version", "description", "license", "author", "repository", "harness", "model", "effort", "tools", "mcp", "computer", "parameters", "secrets", "budget", "learning", "approvals", "triggers", "output", "checks"];
|
|
33
|
+
const FIELDS = ["name", "display_name", "version", "description", "license", "author", "repository", "harness", "model", "effort", "tools", "mcp", "tool_policy", "computer", "parameters", "secrets", "budget", "learning", "approvals", "triggers", "output", "checks"];
|
|
30
34
|
const NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
31
35
|
const PARAMETER = /^[a-z][a-z0-9_]{0,63}$/;
|
|
32
36
|
/** The keys a package may need: those Settings saves (a tool's or a model provider's), each one a run is handed. */
|
|
@@ -37,6 +41,9 @@ const MCP_TOOL = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
|
37
41
|
export const MAX_FILE_BYTES = 256 << 10;
|
|
38
42
|
export const MAX_PACKAGE_BYTES = 1 << 20;
|
|
39
43
|
export const MAX_PACKAGE_FILES = 256;
|
|
44
|
+
/** A file of a package's evals/ (a case's fake MCP server fixture, say), which no agent is given: its own bound, apart
|
|
45
|
+
* from the agent's files' limits above. The answer's schema is given to the agent, so under evals/ too it keeps those. */
|
|
46
|
+
export const MAX_EVAL_FILE_BYTES = 32 << 20;
|
|
40
47
|
/** A parameter's sample, of its type, for the check that compiles a package before any apply. */
|
|
41
48
|
const SAMPLES = { string: "x", number: 1, integer: 1, boolean: true };
|
|
42
49
|
/** An agent id in the shape an apply gives a trigger's target, for that check. */
|
|
@@ -91,9 +98,10 @@ export function githubTriggerWords(packageName, source) {
|
|
|
91
98
|
const or = (words) => (words.length < 2 ? words.join("") : `${words.slice(0, -1).join(", ")} or ${words.at(-1)}`);
|
|
92
99
|
return `${subject} runs on each ${or(events)} ${repos.length ? `to ${or(repos)}` : "to a repository the GitHub App is installed on"}.`;
|
|
93
100
|
}
|
|
94
|
-
const GITHUB_EVENT_WORDS = { pull_request: "pull request", pull_request_review: "pull request review", pull_request_review_comment: "review comment", issue_comment: "comment", issues: "issue" };
|
|
95
|
-
/** What an apply says of a github trigger it skipped because GitHub is not connected here
|
|
96
|
-
|
|
101
|
+
const GITHUB_EVENT_WORDS = { pull_request: "pull request", pull_request_review: "pull request review", pull_request_review_comment: "review comment", issue_comment: "comment", issues: "issue", release: "release" };
|
|
102
|
+
/** What an apply says of a github trigger it skipped because GitHub is not connected here: what to do, and what the
|
|
103
|
+
* trigger would then run on, in the package's own words ("Code review runs on each pull request to acme/widgets."). */
|
|
104
|
+
export const githubTriggerUnconnected = (packageName, source) => `Connect GitHub in Settings, then apply again so it runs by itself: ${githubTriggerWords(packageName, source)}`;
|
|
97
105
|
/** Every string in `value`, deep. */
|
|
98
106
|
const strings = (value) => (typeof value === "string" ? [value] : Array.isArray(value) ? value.flatMap(strings) : isObject(value) ? Object.values(value).flatMap(strings) : []);
|
|
99
107
|
/** `value` with each `${parameters.x}` in its strings replaced by the value given for x (its own: never an inherited
|
|
@@ -208,12 +216,19 @@ export function readPackage(dir) {
|
|
|
208
216
|
bad(`${entry.name}/`, "a package's folders are skills/, rules/ and evals/");
|
|
209
217
|
}
|
|
210
218
|
// Bounded before anything is read: a file, the files together, and how many there are.
|
|
211
|
-
|
|
219
|
+
// The agent's files' bytes (evals/ is the package's own test data, never part of an agent) under POST /v2/agents'
|
|
220
|
+
// limits, an eval's file under MAX_EVAL_FILE_BYTES alone; every file, evals/ too, counts toward MAX_PACKAGE_FILES. A
|
|
221
|
+
// file under evals/ an agent is given all the same (the answer's schema, which ships beside each SKILL.md) keeps the
|
|
222
|
+
// agent's limits: checked once the manifest names it, before it is read.
|
|
223
|
+
const listed = files("");
|
|
224
|
+
const all = listed.filter((path) => !path.startsWith("evals/"));
|
|
212
225
|
const sizes = all.map((path) => [path, lstatSync(join(dir, path)).size]);
|
|
226
|
+
const agentBytes = sizes.reduce((sum, [, size]) => sum + size, 0);
|
|
213
227
|
const limits = [
|
|
228
|
+
...listed.filter((path) => path.startsWith("evals/") && lstatSync(join(dir, path)).size > MAX_EVAL_FILE_BYTES).map((path) => `${path}: is over ${MAX_EVAL_FILE_BYTES} bytes, an eval file's limit`),
|
|
214
229
|
...sizes.filter(([, size]) => size > MAX_FILE_BYTES).map(([path]) => `${path}: is over ${MAX_FILE_BYTES} bytes, a package file's limit`),
|
|
215
|
-
...(
|
|
216
|
-
...(
|
|
230
|
+
...(agentBytes > MAX_PACKAGE_BYTES ? [`the package's files are over ${MAX_PACKAGE_BYTES} bytes together, POST /v2/agents' own limit`] : []),
|
|
231
|
+
...(listed.length > MAX_PACKAGE_FILES ? [`the package holds over ${MAX_PACKAGE_FILES} files`] : []),
|
|
217
232
|
];
|
|
218
233
|
if (limits.length)
|
|
219
234
|
throw new PackageError(dir, [...problems, ...limits]);
|
|
@@ -265,14 +280,26 @@ export function readPackage(dir) {
|
|
|
265
280
|
mcp.push({ server: need.server, tools: names, required: need.required === true, allow: allow, pin: pinned });
|
|
266
281
|
}
|
|
267
282
|
}
|
|
283
|
+
// A policy by tool: bash's alone (bash-read-only.ts), on a package that grants bash or names no tools (a new agent's
|
|
284
|
+
// tools, the box's shell among them where there is one).
|
|
285
|
+
let toolPolicy;
|
|
286
|
+
if (f.tool_policy !== undefined) {
|
|
287
|
+
const given = f.tool_policy;
|
|
288
|
+
if (!isObject(given) || !Object.keys(given).length || unknownFields(given, ["bash"]).length || !BASH_POLICIES.includes(given.bash))
|
|
289
|
+
bad(MANIFEST, `tool_policy is {bash: ${BASH_POLICIES.join(" | ")}}: read-only refuses, before it runs, any command that could write, run code or read outside the run's folder`);
|
|
290
|
+
else if (tools && !tools.includes("bash"))
|
|
291
|
+
bad(MANIFEST, "tool_policy.bash: the package's tools grant no bash, so its policy would hold nothing: add bash to tools, or leave tool_policy out");
|
|
292
|
+
else
|
|
293
|
+
toolPolicy = { bash: given.bash };
|
|
294
|
+
}
|
|
268
295
|
// Computers by name come with the computer protocol; until then a package runs where this server puts a new agent.
|
|
269
296
|
if (f.computer !== undefined && f.computer !== "default")
|
|
270
297
|
bad(MANIFEST, "computer is default (this server's own place): no other computer is known yet");
|
|
271
298
|
const parameters = {};
|
|
272
299
|
for (const [key, p] of Object.entries(f.parameters === undefined ? {} : isObject(f.parameters) ? f.parameters : (bad(MANIFEST, "parameters is a mapping of names"), {}))) {
|
|
273
|
-
const ok = PARAMETER.test(key) && isObject(p) && !unknownFields(p, ["type", "required", "pattern", "enum", "description", "default"]).length && PARAMETER_TYPES.includes(p.type) && (p.required === undefined || typeof p.required === "boolean") && typeof p.description === "string" && p.description.trim() !== "" && (p.pattern === undefined || (p.type === "string" && typeof p.pattern === "string"));
|
|
300
|
+
const ok = PARAMETER.test(key) && isObject(p) && !unknownFields(p, ["type", "required", "pattern", "enum", "format", "description", "default"]).length && PARAMETER_TYPES.includes(p.type) && (p.required === undefined || typeof p.required === "boolean") && typeof p.description === "string" && p.description.trim() !== "" && (p.pattern === undefined || (p.type === "string" && typeof p.pattern === "string"));
|
|
274
301
|
if (!ok) {
|
|
275
|
-
bad(MANIFEST, `parameters.${key} is {type: ${PARAMETER_TYPES.join(" | ")}, required?, pattern? (strings), enum?, default?, description}, its name lowercase`);
|
|
302
|
+
bad(MANIFEST, `parameters.${key} is {type: ${PARAMETER_TYPES.join(" | ")}, required?, pattern? (strings), enum?, format? (strings), default?, description}, its name lowercase`);
|
|
276
303
|
continue;
|
|
277
304
|
}
|
|
278
305
|
try {
|
|
@@ -282,6 +309,8 @@ export function readPackage(dir) {
|
|
|
282
309
|
catch {
|
|
283
310
|
bad(MANIFEST, `parameters.${key}.pattern is not a regular expression`);
|
|
284
311
|
}
|
|
312
|
+
// What a string's value is (a cron line, a time zone), for a form to ask for it as such.
|
|
313
|
+
const format = p.format === undefined ? undefined : p.type === "string" && PARAMETER_FORMATS.includes(p.format) ? p.format : (bad(MANIFEST, `parameters.${key}.format is one of ${PARAMETER_FORMATS.join(", ")}, on a string parameter`), undefined);
|
|
285
314
|
// A closed set of values (a form shows a choice, never a pattern): one or more, each of the parameter's type, once.
|
|
286
315
|
const choices = p.enum === undefined ? undefined : Array.isArray(p.enum) && p.enum.length > 0 && p.enum.every((one) => ofType(p.type, one)) && new Set(p.enum).size === p.enum.length ? p.enum : (bad(MANIFEST, `parameters.${key}.enum is a list of one or more distinct ${p.type} values`), undefined);
|
|
287
316
|
if (choices && typeof p.pattern === "string")
|
|
@@ -296,13 +325,17 @@ export function readPackage(dir) {
|
|
|
296
325
|
if (p.required === true)
|
|
297
326
|
bad(MANIFEST, `parameters.${key} is required and has a default: a default is for a parameter apply may leave out`);
|
|
298
327
|
}
|
|
299
|
-
parameters[key] = { type: p.type, required: p.required === true, description: p.description, ...(typeof p.pattern === "string" ? { pattern: p.pattern } : {}), ...(choices ? { enum: choices } : {}), ...(p.default !== undefined && ofType(p.type, p.default) ? { default: p.default } : {}) };
|
|
328
|
+
parameters[key] = { type: p.type, required: p.required === true, description: p.description, ...(typeof p.pattern === "string" ? { pattern: p.pattern } : {}), ...(choices ? { enum: choices } : {}), ...(format ? { format } : {}), ...(p.default !== undefined && ofType(p.type, p.default) ? { default: p.default } : {}) };
|
|
300
329
|
}
|
|
301
330
|
const secrets = list(f.secrets, "secrets", (secret) => /^[A-Z][A-Z0-9_]{0,127}$/.test(secret));
|
|
302
331
|
for (const secret of secrets.filter((name) => !PACKAGE_SECRETS.includes(name)))
|
|
303
332
|
bad(MANIFEST, `secrets names ${secret}, a key this server cannot hold: a package needs the keys Settings saves and a run is handed (${PACKAGE_SECRETS.join(", ")})`);
|
|
304
|
-
|
|
305
|
-
|
|
333
|
+
// Each run's limits: its spend cap (per_run_usd, the agent's max_cost_usd) and its tool-call budget (tool_calls, the
|
|
334
|
+
// agent's max_tool_calls: each conversation's calls), one of them at least.
|
|
335
|
+
const perRun = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
336
|
+
const toolCalls = (value) => Number.isSafeInteger(value) && value > 0 && value <= MAX_TOOL_CALLS;
|
|
337
|
+
if (f.budget !== undefined && !(isObject(f.budget) && Object.keys(f.budget).length && !unknownFields(f.budget, ["per_run_usd", "tool_calls"]).length && (f.budget.per_run_usd === undefined || perRun(f.budget.per_run_usd)) && (f.budget.tool_calls === undefined || toolCalls(f.budget.tool_calls))))
|
|
338
|
+
bad(MANIFEST, `budget is {per_run_usd?: a number above 0, tool_calls?: a whole number from 1 to ${MAX_TOOL_CALLS}}, one of them at least`);
|
|
306
339
|
if (f.learning !== undefined && typeof f.learning !== "boolean")
|
|
307
340
|
bad(MANIFEST, "learning is true or false");
|
|
308
341
|
if (f.approvals !== undefined && f.approvals !== "ask" && f.approvals !== "never")
|
|
@@ -322,12 +355,19 @@ export function readPackage(dir) {
|
|
|
322
355
|
if (!isObject(target) || target.kind !== "start_run" || target.agent_id !== undefined)
|
|
323
356
|
bad(MANIFEST, `triggers[${i}].target is a start_run with no agent_id: the agent is the one the package makes`);
|
|
324
357
|
});
|
|
325
|
-
if (triggers.length && f.budget
|
|
358
|
+
if (triggers.length && !(isObject(f.budget) && f.budget.per_run_usd !== undefined))
|
|
326
359
|
bad(MANIFEST, "budget is required when the package has triggers: {per_run_usd}, each run's cap");
|
|
327
360
|
let outputSchema;
|
|
361
|
+
let schemaBounded = true;
|
|
328
362
|
if (f.output !== undefined) {
|
|
329
|
-
|
|
363
|
+
const at = isObject(f.output) ? f.output.schema : undefined;
|
|
364
|
+
const evalSize = typeof at === "string" && at.startsWith("evals/") && inside(at) ? lstatSync(join(dir, at)).size : 0;
|
|
365
|
+
if (!isObject(f.output) || unknownFields(f.output, ["schema"]).length || !inside(at))
|
|
330
366
|
bad(MANIFEST, "output is {schema: a JSON Schema file in the package}");
|
|
367
|
+
else if (evalSize > MAX_FILE_BYTES || agentBytes + evalSize > MAX_PACKAGE_BYTES) {
|
|
368
|
+
schemaBounded = false;
|
|
369
|
+
bad(at, evalSize > MAX_FILE_BYTES ? `is over ${MAX_FILE_BYTES} bytes, a package file's limit: the answer's schema ships beside each SKILL.md, so it keeps an agent file's limits, under evals/ too` : `takes the agent's files over ${MAX_PACKAGE_BYTES} bytes together, POST /v2/agents' own limit: the answer's schema ships beside each SKILL.md, so it counts as an agent file, under evals/ too`);
|
|
370
|
+
}
|
|
331
371
|
else {
|
|
332
372
|
try {
|
|
333
373
|
outputSchema = JSON.parse(text(f.output.schema));
|
|
@@ -415,7 +455,7 @@ export function readPackage(dir) {
|
|
|
415
455
|
}
|
|
416
456
|
}
|
|
417
457
|
// The answer's schema ships beside each SKILL.md too, as a rule does: the agent reads it there, and the skill names it.
|
|
418
|
-
const schemaFile = isObject(f.output) && inside(f.output.schema) ? f.output.schema : undefined;
|
|
458
|
+
const schemaFile = schemaBounded && isObject(f.output) && inside(f.output.schema) ? f.output.schema : undefined;
|
|
419
459
|
for (const skill of schemaFile ? skillDirs.filter((d) => d.isDirectory()) : []) {
|
|
420
460
|
const path = `${skill.name}/${basename(schemaFile)}`;
|
|
421
461
|
if (Object.hasOwn(skills, path))
|
|
@@ -461,7 +501,7 @@ export function readPackage(dir) {
|
|
|
461
501
|
name, ...(typeof f.display_name === "string" ? { displayName: f.display_name } : {}), version: f.version, description: f.description,
|
|
462
502
|
...(typeof f.license === "string" ? { license: f.license } : {}), ...(isObject(f.author) ? { author: f.author } : {}), ...(typeof f.repository === "string" ? { repository: f.repository } : {}),
|
|
463
503
|
...(harness ? { harness } : {}), ...(isObject(f.model) ? { model: f.model } : {}), ...(typeof f.effort === "string" ? { effort: f.effort } : {}),
|
|
464
|
-
...(tools ? { tools } : {}), mcp, parameters, secrets, ...(isObject(f.budget) ? { budget: { per_run_usd: f.budget.per_run_usd } } : {}), ...(typeof f.learning === "boolean" ? { learning: f.learning } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
|
|
504
|
+
...(tools ? { tools } : {}), mcp, ...(toolPolicy ? { toolPolicy } : {}), parameters, secrets, ...(isObject(f.budget) ? { budget: { ...(typeof f.budget.per_run_usd === "number" ? { per_run_usd: f.budget.per_run_usd } : {}), ...(typeof f.budget.tool_calls === "number" ? { tool_calls: f.budget.tool_calls } : {}) } } : {}), ...(typeof f.learning === "boolean" ? { learning: f.learning } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
|
|
465
505
|
triggers: triggers, ...(isObject(f.output) ? { output: { schema: f.output.schema } } : {}), ...(isObject(outputSchema) ? { outputSchema } : {}), checks, instructions, skills, evals,
|
|
466
506
|
};
|
|
467
507
|
// What an apply makes, made here with each parameter's default, else a sample of its type, and checked as POST
|
|
@@ -500,7 +540,7 @@ export function packageView(p) {
|
|
|
500
540
|
return {
|
|
501
541
|
name: p.name, display_name: p.displayName ?? null, version: p.version, description: p.description, license: p.license ?? null, author: p.author ?? null, repository: p.repository ?? null,
|
|
502
542
|
output: p.output ? { schema: p.output.schema, json_schema: p.outputSchema ?? null } : null,
|
|
503
|
-
harness: p.harness ?? null, model: p.model ?? null, effort: p.effort ?? null, tools: p.tools ?? null,
|
|
543
|
+
harness: p.harness ?? null, model: p.model ?? null, effort: p.effort ?? null, tools: p.tools ?? null, tool_policy: p.toolPolicy ?? null,
|
|
504
544
|
mcp: p.mcp.map(({ server, tools, required, allow, pin }) => ({ server, required, tools: tools.map((name) => ({ name, tool: mcpToolName(server, name), asks: allow.includes(name) ? "allow" : "ask", ...(Object.hasOwn(pin, name) ? { pin: pin[name] } : {}) })) })), parameters: p.parameters, secrets: p.secrets,
|
|
505
545
|
budget: p.budget ?? null, learning: p.learning ?? false, approvals_default: p.approvals ?? "ask", triggers: p.triggers, skills: Object.keys(p.skills).filter((path) => /^[^/]+\/SKILL\.md$/.test(path)).map((path) => path.slice(0, -"/SKILL.md".length)), evals: p.evals,
|
|
506
546
|
};
|
|
@@ -592,46 +632,42 @@ export async function packageModel(env, model, harness) {
|
|
|
592
632
|
* owner's own setting; `grants`, the owner's answer at apply, alone are set to allow. A tool the package pins gets its
|
|
593
633
|
* pin, filled, in the agent's tool settings, whatever its permission; one whose pin fills empty (its parameter not
|
|
594
634
|
* given) is set to deny instead, granted or not, and named in `unpinned` (by gate name, with the parameters not given):
|
|
595
|
-
* a send with no destination set never runs.
|
|
596
|
-
* default) a filled pin is not written: it is named in `unkept`, with its values, for the server's settings, and the tool is
|
|
597
|
-
* set to deny unless the server's settings already pin it (`serverPinned`, by gate name): a write a template grants
|
|
598
|
-
* never runs without its pin, whatever the agent's approvals. */
|
|
635
|
+
* a send with no destination set never runs. */
|
|
599
636
|
export function compiled(p, parameters, chosen, _deps) {
|
|
600
637
|
const skills = Object.keys(p.skills).filter((path) => /^[^/]+\/SKILL\.md$/.test(path)).map((path) => path.slice(0, -"/SKILL.md".length));
|
|
601
638
|
const granted = chosen.mcp.flatMap(({ server, tools }) => tools.map((tool) => mcpToolName(server, tool)));
|
|
602
639
|
const allowed = chosen.grants.filter((tool) => granted.includes(tool));
|
|
603
640
|
const tools = granted.length ? [...(p.tools ?? chosen.defaultTools), ...granted] : p.tools;
|
|
604
641
|
const settings = Object.fromEntries(allowed.map((tool) => [tool, { permission: "allow" }]));
|
|
642
|
+
// A tool's policy (bash's read-only), written as its setting, whatever its permission: never one an apply grants.
|
|
643
|
+
if (p.toolPolicy)
|
|
644
|
+
settings.bash = { ...settings.bash, policy: p.toolPolicy.bash };
|
|
605
645
|
const unpinned = [];
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
const each = Object.entries(args).map(([arg, value]) => [arg, pinFilled(value, parameters)]);
|
|
611
|
-
const empty = [...new Set(each.flatMap(([, one]) => one.empty))];
|
|
612
|
-
if (empty.length) {
|
|
613
|
-
settings[name] = { permission: "deny" };
|
|
614
|
-
unpinned.push({ tool: name, parameters: empty });
|
|
615
|
-
}
|
|
616
|
-
else {
|
|
617
|
-
const filledPin = Object.fromEntries(each.map(([arg, one]) => [arg, one.value]));
|
|
618
|
-
if (chosen.pins ?? AGENT_LAYER_PINS)
|
|
619
|
-
settings[name] = { ...settings[name], pin: sortedPin(filledPin) };
|
|
620
|
-
else {
|
|
621
|
-
unkept.push({ tool: name, pin: filledPin });
|
|
622
|
-
if (!chosen.serverPinned?.has(name))
|
|
623
|
-
settings[name] = { permission: "deny" };
|
|
624
|
-
}
|
|
625
|
-
}
|
|
646
|
+
for (const { tool: name, pin, empty } of filledPins(chosen.mcp, parameters)) {
|
|
647
|
+
if (empty.length) {
|
|
648
|
+
settings[name] = { permission: "deny" };
|
|
649
|
+
unpinned.push({ tool: name, parameters: empty });
|
|
626
650
|
}
|
|
651
|
+
else
|
|
652
|
+
settings[name] = { ...settings[name], pin: sortedPin(pin) };
|
|
627
653
|
}
|
|
628
654
|
const definition = {
|
|
629
655
|
name: p.displayName ? filled(p.displayName, parameters) : p.name, description: p.description, instructions: filled(p.instructions, parameters),
|
|
630
656
|
...(chosen.harness ? { harness: chosen.harness } : {}), ...(chosen.model ? { model: chosen.model } : {}), ...(p.effort ? { thinking: p.effort } : {}),
|
|
631
657
|
...(tools ? { tools } : {}), ...(Object.keys(settings).length ? { tool_settings: settings } : {}),
|
|
632
|
-
...(p.learning !== undefined ? { learning: p.learning } : {}), ...(p.budget ? { max_cost_usd: p.budget.per_run_usd } : {}), skills,
|
|
658
|
+
...(p.learning !== undefined ? { learning: p.learning } : {}), ...(p.budget?.per_run_usd ? { max_cost_usd: p.budget.per_run_usd } : {}), ...(p.budget?.tool_calls ? { max_tool_calls: p.budget.tool_calls } : {}), skills,
|
|
633
659
|
// The apply's choice: unattended only when it says never (none given: the agent asks).
|
|
634
660
|
...(chosen.approvals === "never" ? { approvals: "never" } : {}),
|
|
661
|
+
// The package's answer schema (manifest `output`): each completed run's structured answer, checked, is its result.output.
|
|
662
|
+
...(isObject(p.outputSchema) ? { output_schema: p.outputSchema } : {}),
|
|
635
663
|
};
|
|
636
|
-
return { agent: { definition, skills: { ...p.skills } }, triggers: p.triggers.map((trigger) => filled(trigger, parameters)), unpinned
|
|
664
|
+
return { agent: { definition, skills: { ...p.skills } }, triggers: p.triggers.map((trigger) => filled(trigger, parameters)), unpinned };
|
|
665
|
+
}
|
|
666
|
+
/** Each pin the package's MCP servers (`mcp`) set, by the tool's gate name, its values filled from `parameters`, and the
|
|
667
|
+
* parameters it names that were not given (`empty`, none when it fills whole). */
|
|
668
|
+
export function filledPins(mcp, parameters) {
|
|
669
|
+
return mcp.flatMap(({ server, pin }) => Object.entries(pin).map(([tool, args]) => {
|
|
670
|
+
const each = Object.entries(args).map(([arg, value]) => [arg, pinFilled(value, parameters)]);
|
|
671
|
+
return { tool: mcpToolName(server, tool), pin: Object.fromEntries(each.map(([arg, one]) => [arg, one.value])), empty: [...new Set(each.flatMap(([, one]) => one.empty))] };
|
|
672
|
+
}));
|
|
637
673
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TimelineEvent } from "./timeline.js";
|
|
2
|
+
/** One call: its row, the row that closed it (by `tool_use_id`, never by time), and what it spawned. */
|
|
3
|
+
export type Call = {
|
|
4
|
+
use: TimelineEvent;
|
|
5
|
+
result?: TimelineEvent;
|
|
6
|
+
inner: Group[];
|
|
7
|
+
};
|
|
8
|
+
export type Group = {
|
|
9
|
+
type: "row";
|
|
10
|
+
row: TimelineEvent;
|
|
11
|
+
}
|
|
12
|
+
/** `rounds` counts the assistant entries the calls came from; one call per round is what a later round may fold into. */
|
|
13
|
+
| {
|
|
14
|
+
type: "calls";
|
|
15
|
+
round?: number;
|
|
16
|
+
conv?: number;
|
|
17
|
+
rounds: number;
|
|
18
|
+
calls: Call[];
|
|
19
|
+
};
|
|
20
|
+
/** Adjacent calls of one tool, shown as one line. */
|
|
21
|
+
export type Fold = {
|
|
22
|
+
tool: string;
|
|
23
|
+
calls: Call[];
|
|
24
|
+
};
|
|
25
|
+
export declare const failedCall: (call: Call) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Rows to groups. A round is the calls of one assistant entry, in the order written. A row that names a parent call (a
|
|
28
|
+
* nested call, a subagent's rows) sits inside that call. Adjacent rounds of one call of the same tool fold into one
|
|
29
|
+
* group; any other row, a failed call or a call with inner rows ends the fold. Calls are never deduped.
|
|
30
|
+
*/
|
|
31
|
+
export declare function groupTimeline(rows: readonly TimelineEvent[]): Group[];
|
|
32
|
+
/** Adjacent calls of one tool inside a group, folded; a call with inner rows keeps its own line. */
|
|
33
|
+
export declare function foldCalls(calls: readonly Call[]): Fold[];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const failedCall = (call) => call.result?.tool_status === "failed";
|
|
2
|
+
const plain = (call) => !failedCall(call) && call.inner.length === 0;
|
|
3
|
+
const foldable = (group) => group.type === "calls" && group.calls.length === group.rounds && group.calls.every(plain);
|
|
4
|
+
/**
|
|
5
|
+
* Rows to groups. A round is the calls of one assistant entry, in the order written. A row that names a parent call (a
|
|
6
|
+
* nested call, a subagent's rows) sits inside that call. Adjacent rounds of one call of the same tool fold into one
|
|
7
|
+
* group; any other row, a failed call or a call with inner rows ends the fold. Calls are never deduped.
|
|
8
|
+
*/
|
|
9
|
+
export function groupTimeline(rows) {
|
|
10
|
+
const uses = new Map();
|
|
11
|
+
const results = new Map();
|
|
12
|
+
for (const row of rows) {
|
|
13
|
+
if (row.kind === "tool_use" && row.tool_use_id)
|
|
14
|
+
uses.set(row.tool_use_id, row);
|
|
15
|
+
else if (row.kind === "tool_result" && row.tool_use_id)
|
|
16
|
+
results.set(row.tool_use_id, row);
|
|
17
|
+
}
|
|
18
|
+
const inside = new Map();
|
|
19
|
+
const top = [];
|
|
20
|
+
for (const row of rows) {
|
|
21
|
+
const spawned = row.kind === "subagent_started" || row.kind === "subagent_completed";
|
|
22
|
+
const named = spawned ? row.tool_use_id : row.parent_tool_use_id;
|
|
23
|
+
const parent = named && uses.has(named) && !(row.kind === "tool_use" && named === row.tool_use_id) ? named : undefined;
|
|
24
|
+
if (parent)
|
|
25
|
+
inside.set(parent, [...(inside.get(parent) ?? []), row]);
|
|
26
|
+
else if (!(row.kind === "tool_result" && row.tool_use_id && uses.has(row.tool_use_id)))
|
|
27
|
+
top.push(row);
|
|
28
|
+
}
|
|
29
|
+
const order = new Map(rows.map((row, index) => [row, index]));
|
|
30
|
+
const lead = (row) => (row.kind === "subagent_started" ? 0 : row.kind === "subagent_completed" ? 2 : 1);
|
|
31
|
+
/** Every row under a call, at any depth, in log order: the rows of a nested call's own nested calls included. */
|
|
32
|
+
const within = (id, seen = new Set()) => {
|
|
33
|
+
if (seen.has(id))
|
|
34
|
+
return [];
|
|
35
|
+
seen.add(id);
|
|
36
|
+
const direct = inside.get(id) ?? [];
|
|
37
|
+
const all = [...direct, ...direct.flatMap((row) => (row.kind === "tool_use" && row.tool_use_id ? within(row.tool_use_id, seen) : []))];
|
|
38
|
+
return all.sort((a, b) => order.get(a) - order.get(b));
|
|
39
|
+
};
|
|
40
|
+
const groups = [];
|
|
41
|
+
for (const row of top) {
|
|
42
|
+
if (row.kind !== "tool_use" || !row.tool_use_id) {
|
|
43
|
+
groups.push({ type: "row", row });
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const call = { use: row, result: results.get(row.tool_use_id), inner: groupTimeline(within(row.tool_use_id).sort((a, b) => lead(a) - lead(b))) };
|
|
47
|
+
const last = groups.at(-1);
|
|
48
|
+
if (last?.type === "calls" && row.round !== undefined && last.round === row.round && last.conv === row.conversation_id)
|
|
49
|
+
last.calls.push(call);
|
|
50
|
+
else
|
|
51
|
+
groups.push({ type: "calls", round: row.round, conv: row.conversation_id, rounds: 1, calls: [call] });
|
|
52
|
+
}
|
|
53
|
+
const folded = [];
|
|
54
|
+
for (const group of groups) {
|
|
55
|
+
const last = folded.at(-1);
|
|
56
|
+
if (last && foldable(last) && foldable(group) && last.conv === group.conv && last.calls[0].use.tool_name === group.calls[0].use.tool_name) {
|
|
57
|
+
last.calls.push(...group.calls);
|
|
58
|
+
last.rounds += group.rounds;
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
folded.push(group);
|
|
62
|
+
}
|
|
63
|
+
return folded;
|
|
64
|
+
}
|
|
65
|
+
/** Adjacent calls of one tool inside a group, folded; a call with inner rows keeps its own line. */
|
|
66
|
+
export function foldCalls(calls) {
|
|
67
|
+
const folds = [];
|
|
68
|
+
for (const call of calls) {
|
|
69
|
+
const tool = call.use.tool_name ?? "";
|
|
70
|
+
const last = folds.at(-1);
|
|
71
|
+
if (last && last.tool === tool && call.inner.length === 0 && last.calls.every((other) => other.inner.length === 0))
|
|
72
|
+
last.calls.push(call);
|
|
73
|
+
else
|
|
74
|
+
folds.push({ tool, calls: [call] });
|
|
75
|
+
}
|
|
76
|
+
return folds;
|
|
77
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { groupTimeline, foldCalls, failedCall, type Call, type Fold, type Group } from "./group.js";
|
|
2
|
+
export { callFailed, foldLabel, inputPreview, labelOf, nameOf, registerLabel, registerOutcome, registerTurnEnding, type FoldSpec, type LabelFn, type OutcomeFn, type ToolResultView } from "./labels.js";
|
|
3
|
+
export { renderText } from "./render-text.js";
|
|
4
|
+
export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, TURN_END } from "./timeline.js";
|
|
5
|
+
export { isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES, type MessageOrigin, type TriggerSource } from "./origin.js";
|
|
6
|
+
export { cut, scrubUrls } from "./util.js";
|
|
7
|
+
export { BROWSER_CHARGE, CALL_REFUSED, CAP_WRAPUP, CAPS, chargedTool, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, type AgentEventLike, type DecisionLike, type EntryLike, type RunMetrics, type TimelineEvent, type TimelineKind, type TimelineOptions, type ToolMetrics, } from "./timeline.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { groupTimeline, foldCalls, failedCall } from "./group.js";
|
|
2
|
+
export { callFailed, foldLabel, inputPreview, labelOf, nameOf, registerLabel, registerOutcome, registerTurnEnding } from "./labels.js";
|
|
3
|
+
export { renderText } from "./render-text.js";
|
|
4
|
+
export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, TURN_END } from "./timeline.js";
|
|
5
|
+
export { isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES } from "./origin.js";
|
|
6
|
+
export { cut, scrubUrls } from "./util.js";
|
|
7
|
+
export { BROWSER_CHARGE, CALL_REFUSED, CAP_WRAPUP, CAPS, chargedTool, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, } from "./timeline.js";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type Obj } from "./util.js";
|
|
2
|
+
/** A tool result as a label sees it: its text blocks joined, its `details`, its error flag. */
|
|
3
|
+
export type ToolResultView = {
|
|
4
|
+
text: string;
|
|
5
|
+
details: unknown;
|
|
6
|
+
isError: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type LabelFn = (args: Obj, result?: ToolResultView) => string | undefined;
|
|
9
|
+
/** How calls of one tool fold into one line; `subject` names one call from its input and output previews. */
|
|
10
|
+
export type FoldSpec = {
|
|
11
|
+
many: (count: number) => string;
|
|
12
|
+
subject?: (input: string | null, output: string | null) => string | undefined;
|
|
13
|
+
/** The input preview is the call's file path: a host's `path` option names it, as the call's own row does. */
|
|
14
|
+
path?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** Registers the label of one tool, in the past tense, and with `name` what the tool is called where calls are counted
|
|
17
|
+
* (a run's analytics). A host adds its own tools here. */
|
|
18
|
+
export declare function registerLabel(tool: string, label: LabelFn, fold?: FoldSpec, { name }?: {
|
|
19
|
+
name?: string;
|
|
20
|
+
}): void;
|
|
21
|
+
/** What a tool is called where its calls are counted, in plain words: its registered name, else the name it was called by. */
|
|
22
|
+
export declare const nameOf: (tool: string) => string;
|
|
23
|
+
/** A finished call's outcome, when its own result says more than that the call returned: a tool that answers a refusal
|
|
24
|
+
* or a failure as its result, not as an error (a fetch's `{ok: false, refused}`), reads as refused or failed. */
|
|
25
|
+
export type OutcomeFn = (result: {
|
|
26
|
+
text: string;
|
|
27
|
+
isError: boolean;
|
|
28
|
+
}) => {
|
|
29
|
+
failed: boolean;
|
|
30
|
+
text: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
/** Registers how one tool's result tells its outcome. A host adds its own tools here. */
|
|
33
|
+
export declare function registerOutcome(tool: string, outcome: OutcomeFn): void;
|
|
34
|
+
/** The outcome of a call that returned (not one that errored), when its tool tells one. */
|
|
35
|
+
export declare const outcomeOf: (tool: string, result: {
|
|
36
|
+
text: string;
|
|
37
|
+
isError: boolean;
|
|
38
|
+
}) => {
|
|
39
|
+
failed: boolean;
|
|
40
|
+
text: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
/** Whether a finished call failed: an error, or a result its tool's outcome reads as failed (a refused fetch). The one
|
|
43
|
+
* rule a call's row and a run's tool counts both read; `outcome` is the result's own (outcomeOf), so a caller that has
|
|
44
|
+
* read it already (a row, which also shows it) reads it once: a fetch's outcome parses its whole page. */
|
|
45
|
+
export declare const failedWith: (result: {
|
|
46
|
+
isError: boolean;
|
|
47
|
+
}, outcome: ReturnType<OutcomeFn>) => boolean;
|
|
48
|
+
/** failedWith, the outcome read here. */
|
|
49
|
+
export declare const callFailed: (tool: string, result: {
|
|
50
|
+
text: string;
|
|
51
|
+
isError: boolean;
|
|
52
|
+
}) => boolean;
|
|
53
|
+
/** Registers a tool that ends its turn (pi's `terminate`): what the person sends after a round of such tools is their
|
|
54
|
+
* next message, never a steer into a running turn. A host adds its own tools here. */
|
|
55
|
+
export declare function registerTurnEnding(tool: string): void;
|
|
56
|
+
/** Whether `tool` ends its turn (registerTurnEnding). */
|
|
57
|
+
export declare const endsTurn: (tool: string) => boolean;
|
|
58
|
+
/** The label of a call; `result` is given once the call has finished. Unknown tools get Grep's own fallback. */
|
|
59
|
+
export declare function labelOf(tool: string, args: Obj, result?: ToolResultView, extra?: Record<string, LabelFn>): string;
|
|
60
|
+
/** One line for several calls of one tool: `Read 4 pages: a.example, b.example, +2 more`. */
|
|
61
|
+
export declare function foldLabel(tool: string, calls: readonly {
|
|
62
|
+
input: string | null;
|
|
63
|
+
output: string | null;
|
|
64
|
+
}[], options?: {
|
|
65
|
+
path?: (path: string) => string;
|
|
66
|
+
}): string;
|
|
67
|
+
/** The input worth showing: Grep's keys first, then the browser and file ones. */
|
|
68
|
+
export declare function inputPreview(args: Obj, max: number): string | null;
|
|
69
|
+
/** Files a finished call put in the workspace. */
|
|
70
|
+
export declare function savedPaths(tool: string, args: Obj, result: ToolResultView): string[];
|
|
71
|
+
/** Tools that use the browser session; the first of them opens one. */
|
|
72
|
+
export declare const BROWSER_OPENERS: ReadonlySet<string>;
|
|
73
|
+
/** Every tool of the browser (pi-browser's): the calls a browser charge with no call of its own may fold into. */
|
|
74
|
+
export declare const BROWSER_STEPS: ReadonlySet<string>;
|
|
75
|
+
/** A call refused before it ran, in plain words: "Refused: " and the tool's name with what it would have acted on (the
|
|
76
|
+
* path it would have read or written, the command it would have run, the page it would have fetched), never a label's
|
|
77
|
+
* past tense ("Wrote deny.md"), which says it ran. Any tool: one with none of those reads as its name alone (an MCP
|
|
78
|
+
* server's tool as its server and name, "fake · send_message", as its label reads it). */
|
|
79
|
+
export declare function refusedLabel(tool: string, args: Obj): string;
|