@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.38
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 +282 -0
- package/README.md +155 -92
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +39 -14
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/browser-cost.js +52 -93
- package/dist/cap.d.ts +0 -390
- package/dist/cap.js +4 -937
- package/dist/catalog.js +1 -1
- package/dist/composio-preset.d.ts +17 -0
- package/dist/composio-preset.js +43 -1
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-live.d.ts +5 -0
- package/dist/computer-live.js +12 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +3 -2
- package/dist/computer-view.js +5 -4
- package/dist/computer-viewer.js +26 -12
- package/dist/computers.d.ts +4 -1
- package/dist/computers.js +12 -6
- package/dist/console/assets/index-CjqQirbo.css +1 -0
- package/dist/console/assets/index-b6-XY5A9.js +576 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +3 -0
- package/dist/decisions.js +4 -0
- package/dist/faux-computers.js +4 -2
- package/dist/harness-opencode/adapter.js +7 -3
- package/dist/harness-opencode/facts.js +0 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -5
- package/dist/harness-opencode/host/policy.js +8 -32
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +0 -2
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +0 -2
- package/dist/hosted-search.js +0 -21
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +6 -1
- package/dist/learn/check.js +12 -4
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +1 -1
- package/dist/learn/grade.js +7 -6
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +253 -0
- package/dist/learn/promote.js +428 -0
- package/dist/learn/refit.d.ts +39 -0
- package/dist/learn/refit.js +236 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +17 -9
- package/dist/learn/skills.js +132 -42
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +50 -2
- package/dist/learned-nodes.js +41 -2
- package/dist/learned-workflow.d.ts +19 -3
- package/dist/learned-workflow.js +105 -26
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +1 -1
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-routes.d.ts +14 -2
- package/dist/learning-routes.js +14 -3
- package/dist/learning-words.d.ts +7 -0
- package/dist/learning-words.js +7 -0
- package/dist/learning.d.ts +31 -6
- package/dist/learning.js +7 -4
- package/dist/llm.js +0 -3
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +107 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-servers-store.d.ts +89 -22
- package/dist/mcp-servers-store.js +131 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +46 -15
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +336 -66
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/propose.d.ts +7 -1
- package/dist/propose.js +18 -6
- package/dist/provider.js +9 -2
- package/dist/reflect-range.js +2 -1
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +13 -0
- package/dist/run-launch.js +6 -0
- package/dist/run-learning-served.d.ts +13 -2
- package/dist/run-manifest.d.ts +5 -0
- package/dist/run-manifest.js +20 -0
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +17 -6
- package/dist/run-view.js +51 -22
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +24 -10
- package/dist/runner/adapter-loop.js +852 -314
- package/dist/runner/adapter-run-spec.d.ts +12 -6
- package/dist/runner/adapter-run-spec.js +97 -46
- package/dist/runner/adapters/pi-computer.d.ts +3 -1
- package/dist/runner/adapters/pi-computer.js +13 -5
- package/dist/runner/adapters/pi.d.ts +16 -7
- package/dist/runner/adapters/pi.js +94 -33
- package/dist/runner/cli-run-spec.js +67 -27
- package/dist/runner/computer-channel.js +2 -1
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +145 -4
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +6 -5
- package/dist/runner/end-of-run.js +9 -6
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/journal-kinds.d.ts +24 -6
- package/dist/runner/journal-kinds.js +15 -0
- package/dist/runner/learning-end.d.ts +54 -19
- package/dist/runner/learning-end.js +272 -99
- package/dist/runner/learning-loop.d.ts +19 -1
- package/dist/runner/learning-loop.js +5 -2
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +16 -1
- package/dist/runner/loop.js +21 -1
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +16 -52
- package/dist/runner/mcp-run.js +12 -84
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.js +14 -3
- package/dist/runner/model-route.js +12 -3
- package/dist/runner/monid-run.d.ts +16 -0
- package/dist/runner/monid-run.js +96 -0
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +138 -49
- package/dist/runner/runner.js +26 -4
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +1 -0
- package/dist/runner/workflow-spec.js +7 -3
- package/dist/runs-over-store.d.ts +11 -2
- package/dist/runs-over-store.js +21 -11
- package/dist/server.d.ts +88 -16
- package/dist/server.js +380 -87
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/schema.d.ts +9 -0
- package/dist/store/schema.js +28 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.js +19 -7
- package/dist/store/sqlite/store.js +59 -18
- package/dist/store/store.d.ts +46 -14
- package/dist/store-reads/journal.d.ts +25 -1
- package/dist/store-reads/journal.js +63 -49
- package/dist/store-reads/learning.d.ts +101 -15
- package/dist/store-reads/learning.js +195 -61
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +35 -17
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +91 -66
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +218 -46
- package/dist/templates.js +493 -181
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +4 -3
- package/dist/timeline/index.js +4 -3
- package/dist/timeline/labels.d.ts +6 -2
- package/dist/timeline/labels.js +93 -2
- package/dist/timeline/origin.d.ts +19 -5
- package/dist/timeline/origin.js +11 -4
- package/dist/timeline/timeline.d.ts +11 -17
- package/dist/timeline/timeline.js +24 -9
- package/dist/tool-gate.d.ts +73 -46
- package/dist/tool-gate.js +133 -66
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +26 -0
- package/dist/tool-list.js +43 -0
- package/dist/tool-names.d.ts +71 -0
- package/dist/tool-names.js +99 -0
- package/dist/tool-plane.d.ts +29 -27
- package/dist/tool-plane.js +65 -37
- package/dist/tools.d.ts +22 -6
- package/dist/tools.js +24 -20
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -44
- package/dist/web-fetch.d.ts +1 -7
- package/dist/web-fetch.js +2 -22
- package/dist/workspace/computer-deps.d.ts +3 -0
- package/dist/workspace/computer-deps.js +5 -2
- package/dist/workspace/computer-for-claim.d.ts +6 -0
- package/dist/workspace/computer-for-claim.js +32 -14
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-script.d.ts +23 -7
- package/dist/workspace/computer-script.js +48 -14
- package/dist/workspace/index.d.ts +2 -2
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +13 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +4 -0
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +21 -1
- package/dist/workspace/resolve-computer.js +32 -14
- package/dist/workspace/run-tools.d.ts +28 -10
- package/dist/workspace/run-tools.js +39 -11
- package/dist/{tool-budget.d.ts → wrap-up.d.ts} +1 -18
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +9 -9
- package/templates/README.md +111 -45
- package/templates/code-review/agent.md +30 -14
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +3 -2
- package/templates/code-review/skills/review/REVIEWER.md +3 -2
- package/templates/code-review/skills/review/SKILL.md +4 -3
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.js +0 -62
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
package/dist/learning.d.ts
CHANGED
|
@@ -107,6 +107,23 @@ export type Learning = {
|
|
|
107
107
|
/** A grader's drop on two answers the host could not read: the last, cut of secrets and in size (UNREAD_MAX), kept on the
|
|
108
108
|
* run's file to diagnose it by, and served by no read. */
|
|
109
109
|
unread?: string;
|
|
110
|
+
/** The compile turn's record, when the run's end-of-run turn wrote the agent's job as a learned workflow
|
|
111
|
+
* (learn/compile.ts): the workflow, the notes it absorbed, and each attempt with what the checks refused. */
|
|
112
|
+
compiled?: LearningCompiled;
|
|
113
|
+
/** What the checks refused of a compiled draft that never passed: never silent, on the run's learning and its API. */
|
|
114
|
+
draft_errors?: string[];
|
|
115
|
+
};
|
|
116
|
+
/** A compile turn's record (learn/compile.ts CompiledRecord): `digest`, the kept draft's; `promoted`, read from the agent's
|
|
117
|
+
* promotion records when the run's learning is read, absent while undecided. */
|
|
118
|
+
export type LearningCompiled = {
|
|
119
|
+
workflow: string;
|
|
120
|
+
from_notes: string[];
|
|
121
|
+
attempts: {
|
|
122
|
+
ok: boolean;
|
|
123
|
+
errors: string[];
|
|
124
|
+
}[];
|
|
125
|
+
digest?: string;
|
|
126
|
+
promoted?: boolean;
|
|
110
127
|
};
|
|
111
128
|
/** A skill or a workflow draft a merge added or changed. */
|
|
112
129
|
export type LearnedFile = {
|
|
@@ -168,8 +185,8 @@ export declare const learningView: (learning: Learning, shown: Shown, settled: b
|
|
|
168
185
|
pending?: NoteUsed[];
|
|
169
186
|
skills?: LearnedFile[];
|
|
170
187
|
workflows?: LearnedFile[];
|
|
171
|
-
state: "
|
|
172
|
-
reason: "cancelled" | "
|
|
188
|
+
state: "proposed" | "dropped" | "merged" | "seeded" | "reflecting";
|
|
189
|
+
reason: "cancelled" | "no_budget" | "empty" | "unparsed" | "use" | "seed_failed" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
173
190
|
detail: string | null;
|
|
174
191
|
at: string;
|
|
175
192
|
};
|
|
@@ -183,10 +200,10 @@ export declare function shortOf<T extends {
|
|
|
183
200
|
detail: string | null;
|
|
184
201
|
at: string;
|
|
185
202
|
}>({ state, reason, detail, at: _, ...notes }: T): {
|
|
186
|
-
state: "
|
|
187
|
-
reason: "cancelled" | "
|
|
203
|
+
state: "proposed" | "dropped" | "merged" | "seeded" | "reflecting";
|
|
204
|
+
reason: "cancelled" | "no_budget" | "empty" | "unparsed" | "use" | "seed_failed" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
188
205
|
detail: string | null;
|
|
189
|
-
} & Omit<T, "at" | "reason" | "
|
|
206
|
+
} & Omit<T, "at" | "reason" | "state" | "detail">;
|
|
190
207
|
/** The label of the end-of-run turn's timeline rows, and the kind and label of a run's learning row. */
|
|
191
208
|
export declare const LEARNING_LABEL = "learning";
|
|
192
209
|
/** A run's proposal, in its directory (propose.ts): the seed it was checked against, each new note's file and text, its
|
|
@@ -196,9 +213,12 @@ export declare const LEARNING_LABEL = "learning";
|
|
|
196
213
|
export declare const PROPOSAL = "learning-proposal.json";
|
|
197
214
|
/** A run's proposal: its notes, skill and drafts, each draft's dry run by its workflow.json's path (learn/skills.ts
|
|
198
215
|
* draftDryRun: passed, or not run and why), the skill of each draft's name as the folder holds it at the seed
|
|
199
|
-
* (`drafted`, its SKILL.md: shown to the grader beside the draft, never graded or merged), and what was said in the run.
|
|
216
|
+
* (`drafted`, its SKILL.md: shown to the grader beside the draft, never graded or merged), and what was said in the run.
|
|
217
|
+
* `bases`: a file whose conflict base is not the seed, by its path: a revised workflow's, the commit of main its compile
|
|
218
|
+
* ask read it at. */
|
|
200
219
|
export type Proposal = {
|
|
201
220
|
seed: string;
|
|
221
|
+
bases?: Record<string, string>;
|
|
202
222
|
notes: {
|
|
203
223
|
file: string;
|
|
204
224
|
text: string;
|
|
@@ -459,6 +479,11 @@ export declare function chooseSkills(work: Workspace, seed: Seed, own: readonly
|
|
|
459
479
|
taken: LearnedSkill[];
|
|
460
480
|
left: string[];
|
|
461
481
|
}>;
|
|
482
|
+
/** Whether `text` holds a host secret (`shown`): as written, or, read as JSON, in any string it decodes to (its escapes
|
|
483
|
+
* decoded), or nested past the bound. The one check a learned workflow's text passes at a run's start (chooseWorkflows)
|
|
484
|
+
* and every text its compile turn is told (runner/learning-end.ts compileAskOf); a text that is not JSON is read as
|
|
485
|
+
* written. */
|
|
486
|
+
export declare const holdsSecret: (text: string, shown: Shown) => boolean;
|
|
462
487
|
/** Which of `seed`'s learned workflows a run may run (its `learned_workflow` tool), in the seed's order: each while its
|
|
463
488
|
* line (workflowLine) fits what is left of the tool's description budget (LEARNED_WORKFLOWS_BUDGET). One that does not,
|
|
464
489
|
* or holds a host secret (`shown`), is left out and named in `left`, but for one whose name is itself a secret, never
|
package/dist/learning.js
CHANGED
|
@@ -34,7 +34,7 @@ import { lstat, readFile, rm } from "node:fs/promises";
|
|
|
34
34
|
import { join, posix } from "node:path";
|
|
35
35
|
import { SKILL_BYTES } from "@parcha/agentrun-kernel";
|
|
36
36
|
import { bm25, queryOf } from "./learn/relevance.js";
|
|
37
|
-
import { decodedStrings, frontMatter, INDEX_BYTES, INDEX_FILE, INDEX_LINES, learnedStatus, loadedIndex, NOTE_FILE, parseNoteFile, learnedSecretShapes, redactLearned, servedSkill, servedSkills, SKILLS_DIR, valueMatcher, WORKFLOW_NAME, WORKFLOWS_DIR } from "./learn/index.js";
|
|
37
|
+
import { decodedStrings, frontMatter, INDEX_BYTES, INDEX_FILE, INDEX_LINES, learnedStatus, loadedIndex, NOTE_FILE, parseNoteFile, learnedSecretShapes, redactLearned, servedSkill, servedSkills, SKILL_NAME, SKILLS_DIR, valueMatcher, WORKFLOW_NAME, WORKFLOWS_DIR } from "./learn/index.js";
|
|
38
38
|
import { learningInit, learningWorkspace, readSnapshot } from "./learn/folder.js";
|
|
39
39
|
import { readSeed as readFolderSeed } from "./learn/seed-check.js";
|
|
40
40
|
import { agentFolderOf, serialBy, writeDurable } from "./files.js";
|
|
@@ -241,8 +241,6 @@ function compactSchema(schema, schemas, depth = 0, defs = {}) {
|
|
|
241
241
|
export const LEARNED_SKILLS_BUDGET = 256 * 1024;
|
|
242
242
|
/** Where a run's harness finds its skills in its work: the revision's, and the learned ones laid beside them. */
|
|
243
243
|
const RUN_SKILLS = [".agents", "skills"];
|
|
244
|
-
/** A learned skill's folder: the shared skills convention's name (lowercase letters, digits and single dashes). */
|
|
245
|
-
const SKILL_NAME = /^(?=.{1,64}$)[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
246
244
|
/** A file's path inside a learned skill, as every adapter takes one (agentrun-kernel skillProblems). */
|
|
247
245
|
const SKILL_FILE_PATH = /^(?:[A-Za-z0-9_][A-Za-z0-9._-]{0,99}\/){0,4}[A-Za-z0-9_][A-Za-z0-9._-]{0,99}$/;
|
|
248
246
|
/** The agent's learning folder: `learning/` in its folder on the disk, which only the host writes. The folder is files.ts
|
|
@@ -661,6 +659,11 @@ export async function chooseSkills(work, seed, own, shown) {
|
|
|
661
659
|
/** Whether a learned workflow's decoded strings (decodedStrings) hold a host secret, or can't be read past the bound:
|
|
662
660
|
* either way it is never chosen. */
|
|
663
661
|
const readsHeld = (decoded, shown) => decoded === "too_deep" || decoded.some(shown.holds);
|
|
662
|
+
/** Whether `text` holds a host secret (`shown`): as written, or, read as JSON, in any string it decodes to (its escapes
|
|
663
|
+
* decoded), or nested past the bound. The one check a learned workflow's text passes at a run's start (chooseWorkflows)
|
|
664
|
+
* and every text its compile turn is told (runner/learning-end.ts compileAskOf); a text that is not JSON is read as
|
|
665
|
+
* written. */
|
|
666
|
+
export const holdsSecret = (text, shown) => shown.holds(text) || readsHeld(decodedStrings(text), shown);
|
|
664
667
|
/** Which of `seed`'s learned workflows a run may run (its `learned_workflow` tool), in the seed's order: each while its
|
|
665
668
|
* line (workflowLine) fits what is left of the tool's description budget (LEARNED_WORKFLOWS_BUDGET). One that does not,
|
|
666
669
|
* or holds a host secret (`shown`), is left out and named in `left`, but for one whose name is itself a secret, never
|
|
@@ -671,7 +674,7 @@ export function chooseWorkflows(seed, shown) {
|
|
|
671
674
|
let room = LEARNED_WORKFLOWS_BUDGET;
|
|
672
675
|
for (const flow of seed.workflows ?? []) {
|
|
673
676
|
// Its JSON read as JSON reads it too (decodedStrings: its escapes decoded, as its learned call's run reads it).
|
|
674
|
-
if (
|
|
677
|
+
if (holdsSecret(flow.workflow, shown) || shown.holds(flow.description) || shown.holds(flow.name)) {
|
|
675
678
|
// Named, but for a name that is itself a secret.
|
|
676
679
|
if (!shown.holds(flow.name))
|
|
677
680
|
left.push(flow.name);
|
package/dist/llm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { sideRequests } from "./cap.js";
|
|
2
1
|
export const LLM_TOOL = "llm";
|
|
3
2
|
const MAX_PROMPT = 400_000;
|
|
4
3
|
/** The completer over `models`, each call on `pick(tier)`'s model at `thinking`. An answer names the model as `named`
|
|
@@ -26,8 +25,6 @@ export function completer(models, pick, thinking) {
|
|
|
26
25
|
if (!model)
|
|
27
26
|
throw new Error(`llm: the model ${ref.provider}/${ref.modelId} is not known here`);
|
|
28
27
|
const context = { ...(system ? { systemPrompt: system } : {}), messages: [{ role: "user", content: prompt, timestamp: Date.now() }] };
|
|
29
|
-
// A side request of its own (request-start.ts): its marks name it "llm", never the default a compaction's summary takes.
|
|
30
|
-
sideRequests.set(context, { label: LLM_TOOL, extraInputTokens: 0, maxFeeUsd: 0, feeUsd: () => 0 });
|
|
31
28
|
const message = await models.completeSimple(model, context, { signal, reasoning: thinking, ...(maxTokens ? { maxTokens } : {}) });
|
|
32
29
|
if (message.stopReason === "error" || message.stopReason === "aborted")
|
|
33
30
|
throw new Error(`llm: ${message.errorMessage ?? message.stopReason}`);
|
package/dist/mcp-gateway.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import type { McpCallResult, McpTool
|
|
1
|
+
import type { McpCallResult, McpTool } from "@parcha/agentrun-kernel";
|
|
2
2
|
import { type Workspace } from "./workspace/index.js";
|
|
3
|
-
/** A catalog name of an MCP tool: `mcp:<server>/<tool>`. A server name has no `_`, so `mcp__<server>__<tool>` splits one way. */
|
|
4
|
-
export declare const MCP_NAME: RegExp;
|
|
5
3
|
/** The longest answer the model reads whole; past it, the rest is filed in the run's work/ as lines read pages through
|
|
6
4
|
* (filed-answer.ts). Within the host's result bound (HOST_RESULT_MAX_CHARS), so every harness passes it whole. */
|
|
7
5
|
export declare const MCP_CLIP = 60000;
|
|
8
|
-
/** The most of one upstream answer read. */
|
|
9
|
-
export declare const MAX_RESPONSE: number;
|
|
10
6
|
/** The longest one upstream call may take, and its first connection. */
|
|
11
7
|
export declare const CALL_MS = 120000;
|
|
12
8
|
export declare const CONNECT_MS = 30000;
|
|
@@ -23,7 +19,7 @@ export type McpCredentials = Record<string, {
|
|
|
23
19
|
unopened?: string; /** When its credential ends (ms): a token minted for the run's launch (a github_app server's), whose calls past it are refused unsent, in words. */
|
|
24
20
|
expires_at?: number;
|
|
25
21
|
}>;
|
|
26
|
-
/** The servers
|
|
22
|
+
/** The servers a save pins from: each one's URL, its tools as it lists them now, and its owner's prices. */
|
|
27
23
|
export interface McpServerSource {
|
|
28
24
|
server(name: string): {
|
|
29
25
|
url: string;
|
|
@@ -31,11 +27,6 @@ export interface McpServerSource {
|
|
|
31
27
|
prices?: Readonly<Record<string, number>>;
|
|
32
28
|
} | undefined;
|
|
33
29
|
}
|
|
34
|
-
/** `mcp:<server>/<tool>` read, or undefined for a name that is not one. */
|
|
35
|
-
export declare const mcpNameOf: (name: string) => {
|
|
36
|
-
server: string;
|
|
37
|
-
tool: string;
|
|
38
|
-
} | undefined;
|
|
39
30
|
/** The most schema nodes, and the deepest nesting, a tool's declarations are checked through: past either the tool is
|
|
40
31
|
* refused, never walked further. */
|
|
41
32
|
export declare const HEADER_SCAN_NODES = 10000;
|
|
@@ -49,10 +40,10 @@ export declare const HEADER_SCAN_DEPTH = 64;
|
|
|
49
40
|
* data, never a declaration. Each object is visited once, from an explicit stack, within HEADER_SCAN_NODES and
|
|
50
41
|
* HEADER_SCAN_DEPTH. */
|
|
51
42
|
export declare function mcpHeaderProblem(inputSchema: unknown): string | undefined;
|
|
52
|
-
/** The pin of a
|
|
53
|
-
* with no prototype, as every map of names here is: a server named `constructor` is a server like any
|
|
54
|
-
* tool that cannot be pinned (its server
|
|
55
|
-
* send) throws, naming it and why: the
|
|
43
|
+
/** The pin of a revision granted `names`: each MCP tool among them, as its server lists it (the save's listing). Keyed by
|
|
44
|
+
* server name with no prototype, as every map of names here is: a server named `constructor` is a server like any
|
|
45
|
+
* other. A granted tool that cannot be pinned (its server not saved, a tool it does not list, a header declaration it
|
|
46
|
+
* cannot send) throws, naming it and why: the save is refused, never kept without it. */
|
|
56
47
|
export declare function mcpPinOf(names: readonly string[], source: McpServerSource): McpPin;
|
|
57
48
|
export interface McpGatewayOptions {
|
|
58
49
|
pin: McpPin;
|
|
@@ -81,18 +72,19 @@ export interface McpGatewayOptions {
|
|
|
81
72
|
/** The claim's per-call check of a server's credential (its custody stamp): awaited before each call is checked for
|
|
82
73
|
* sending, it may drop the credential (`credentials[server].unopened`), which the call then refuses unsent; one that
|
|
83
74
|
* throws (a store read failed, the call was stopped) refuses the call unsent too, in words, and the run goes on. Only
|
|
84
|
-
* the runner's MCP claim step passes it: a github_app token whose App was disconnected or replaced.
|
|
85
|
-
* session proxy ends in the same call. */
|
|
75
|
+
* the runner's MCP claim step passes it: a github_app token whose App was disconnected or replaced. */
|
|
86
76
|
beforeCall?: (server: string, signal: AbortSignal) => Promise<void>;
|
|
87
77
|
}
|
|
88
78
|
/** A run's journal commit. */
|
|
89
79
|
export type McpCommit = <T>(change: (tx: unknown) => Promise<T>) => Promise<T>;
|
|
90
|
-
/** What a call with no call id answers where a gate must know it by one: nothing was sent. */
|
|
91
|
-
export declare const noCallId: (name: string) => string;
|
|
92
80
|
/** The gateway: a session's servers, and their calls. `credentials` is read at every call and every request, never
|
|
93
81
|
* copied: a change the claim step makes after (a token refreshed behind the claim, a server removed) reaches it, even
|
|
94
82
|
* through a client already connected. */
|
|
95
|
-
export type McpGateway =
|
|
83
|
+
export type McpGateway = {
|
|
84
|
+
servers: readonly {
|
|
85
|
+
name: string;
|
|
86
|
+
tools: readonly McpTool[];
|
|
87
|
+
}[];
|
|
96
88
|
call(server: string, tool: string, args: Record<string, unknown>, context: {
|
|
97
89
|
signal: AbortSignal;
|
|
98
90
|
callId?: string;
|
package/dist/mcp-gateway.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// A run's remote MCP servers: the one place every harness's MCP call goes through. A claimed run's spec builds one per
|
|
2
|
-
// claim from its MCP claim step (runner/mcp-run.ts mcpForClaim);
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// claim from its MCP claim step (runner/mcp-run.ts mcpForClaim); every harness calls it through the runner's host tools.
|
|
3
|
+
// - What a run may call is pinned (mcpPinOf) when its agent's revision is saved: each granted tool as its server listed
|
|
4
|
+
// it then, and the server's URL then. A later change or refresh of the server never changes the revision's tools;
|
|
5
|
+
// saving the agent again pins them anew.
|
|
6
6
|
// - Its credentials come from the claim step, only for the servers it grants, with each server's URL now, read at every
|
|
7
7
|
// call and every request: one whose URL is not the pinned one is never sent anything.
|
|
8
8
|
// - One upstream client per server (the official SDK), connected at its first call; no redirect is followed, so a
|
|
@@ -22,23 +22,15 @@ import { filedAnswer } from "./filed-answer.js";
|
|
|
22
22
|
import { paidLedger, paidStep } from "./paid-calls.js";
|
|
23
23
|
import { metaToolOf } from "./mcp-meta.js";
|
|
24
24
|
import { SIGN_IN_AGAIN } from "./mcp-oauth.js";
|
|
25
|
-
import {
|
|
25
|
+
import { capped, mcpClient, scrub } from "./mcp-wire.js";
|
|
26
|
+
import { mcpNameOf, mcpToolName } from "./tool-names.js";
|
|
26
27
|
import { workspaceAt, workspaceErrorWords } from "./workspace/index.js";
|
|
27
|
-
/** A catalog name of an MCP tool: `mcp:<server>/<tool>`. A server name has no `_`, so `mcp__<server>__<tool>` splits one way. */
|
|
28
|
-
export const MCP_NAME = /^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/;
|
|
29
28
|
/** The longest answer the model reads whole; past it, the rest is filed in the run's work/ as lines read pages through
|
|
30
29
|
* (filed-answer.ts). Within the host's result bound (HOST_RESULT_MAX_CHARS), so every harness passes it whole. */
|
|
31
30
|
export const MCP_CLIP = 60_000;
|
|
32
|
-
/** The most of one upstream answer read. */
|
|
33
|
-
export const MAX_RESPONSE = 4 * 1024 * 1024;
|
|
34
31
|
/** The longest one upstream call may take, and its first connection. */
|
|
35
32
|
export const CALL_MS = 120_000;
|
|
36
33
|
export const CONNECT_MS = 30_000;
|
|
37
|
-
/** `mcp:<server>/<tool>` read, or undefined for a name that is not one. */
|
|
38
|
-
export const mcpNameOf = (name) => {
|
|
39
|
-
const match = MCP_NAME.exec(name);
|
|
40
|
-
return match ? { server: match[1], tool: match[2] } : undefined;
|
|
41
|
-
};
|
|
42
34
|
/** The most schema nodes, and the deepest nesting, a tool's declarations are checked through: past either the tool is
|
|
43
35
|
* refused, never walked further. */
|
|
44
36
|
export const HEADER_SCAN_NODES = 10_000;
|
|
@@ -107,10 +99,10 @@ export function mcpHeaderProblem(inputSchema) {
|
|
|
107
99
|
}
|
|
108
100
|
return undefined;
|
|
109
101
|
}
|
|
110
|
-
/** The pin of a
|
|
111
|
-
* with no prototype, as every map of names here is: a server named `constructor` is a server like any
|
|
112
|
-
* tool that cannot be pinned (its server
|
|
113
|
-
* send) throws, naming it and why: the
|
|
102
|
+
/** The pin of a revision granted `names`: each MCP tool among them, as its server lists it (the save's listing). Keyed by
|
|
103
|
+
* server name with no prototype, as every map of names here is: a server named `constructor` is a server like any
|
|
104
|
+
* other. A granted tool that cannot be pinned (its server not saved, a tool it does not list, a header declaration it
|
|
105
|
+
* cannot send) throws, naming it and why: the save is refused, never kept without it. */
|
|
114
106
|
export function mcpPinOf(names, source) {
|
|
115
107
|
const pin = Object.create(null);
|
|
116
108
|
for (const name of names) {
|
|
@@ -119,11 +111,11 @@ export function mcpPinOf(names, source) {
|
|
|
119
111
|
const tool = saved?.tools.find((t) => t.name === parsed.tool);
|
|
120
112
|
if (!parsed)
|
|
121
113
|
continue;
|
|
122
|
-
// Gone since the
|
|
114
|
+
// Gone since the save's check (deleted, or the server stopped listing the tool): the save is refused.
|
|
123
115
|
if (!saved)
|
|
124
|
-
throw new Error(`The MCP tool ${name} cannot be pinned:
|
|
116
|
+
throw new Error(`The MCP tool ${name} cannot be pinned: no MCP server ${parsed.server} is saved.`);
|
|
125
117
|
if (!tool)
|
|
126
|
-
throw new Error(`The MCP tool ${name} cannot be pinned: ${parsed.
|
|
118
|
+
throw new Error(`The MCP tool ${name} cannot be pinned: the MCP server ${parsed.server} does not list ${parsed.tool}.`);
|
|
127
119
|
// A meta tool granted before the rule (mcp-meta.ts): refused here, never run.
|
|
128
120
|
const meta = metaToolOf(saved.url, tool.name);
|
|
129
121
|
if (meta)
|
|
@@ -183,10 +175,6 @@ function unreachable(error) {
|
|
|
183
175
|
return deepest;
|
|
184
176
|
}
|
|
185
177
|
const said = (text, isError = false) => ({ content: [{ type: "text", text }], ...(isError ? { isError: true } : {}) });
|
|
186
|
-
/** `text` with every credential value in `values` replaced, whole and as its bare token (with any one-word scheme, such
|
|
187
|
-
* as `Bearer ` or `Basic `, taken off): an upstream answer or error that echoes a header, or only its token, never shows
|
|
188
|
-
* it to the model, the harness or the run's files. */
|
|
189
|
-
const scrub = (text, values) => [...values].flatMap((value) => [value, value.replace(/^[A-Za-z][A-Za-z0-9_-]*\s+(?=\S+$)/, "")]).sort((a, b) => b.length - a.length).reduce((out, value) => (value.length >= 8 ? out.split(value).join("[redacted]") : out), text);
|
|
190
178
|
/** `work` until `signal` aborts: a connection shared by calls is never held by one that stopped. */
|
|
191
179
|
const until = (work, signal) => new Promise((resolve, reject) => {
|
|
192
180
|
if (signal.aborted)
|
|
@@ -195,8 +183,6 @@ const until = (work, signal) => new Promise((resolve, reject) => {
|
|
|
195
183
|
signal.addEventListener("abort", stop, { once: true });
|
|
196
184
|
work.then(resolve, reject).finally(() => signal.removeEventListener("abort", stop));
|
|
197
185
|
});
|
|
198
|
-
/** What a call with no call id answers where a gate must know it by one: nothing was sent. */
|
|
199
|
-
export const noCallId = (name) => `The ${name} call was not sent: it came with no call id, so it cannot wait for a person's approval.`;
|
|
200
186
|
export function mcpGateway(options) {
|
|
201
187
|
const clients = new Map();
|
|
202
188
|
const pins = new Map(Object.entries(options.pin));
|
|
@@ -256,19 +242,7 @@ export function mcpGateway(options) {
|
|
|
256
242
|
status.last = response.status;
|
|
257
243
|
if (response.status >= 300 && response.status < 400)
|
|
258
244
|
throw new Error(`it answered a redirect (HTTP ${response.status}), which is never followed`);
|
|
259
|
-
|
|
260
|
-
return response;
|
|
261
|
-
let read = 0;
|
|
262
|
-
const capped = response.body.pipeThrough(new TransformStream({
|
|
263
|
-
transform(chunk, controller) {
|
|
264
|
-
read += chunk.byteLength;
|
|
265
|
-
if (read > MAX_RESPONSE)
|
|
266
|
-
controller.error(new Error(`its answer is longer than ${MAX_RESPONSE} bytes`));
|
|
267
|
-
else
|
|
268
|
-
controller.enqueue(chunk);
|
|
269
|
-
},
|
|
270
|
-
}));
|
|
271
|
-
return new Response(capped, { status: response.status, statusText: response.statusText, headers: response.headers });
|
|
245
|
+
return capped(response);
|
|
272
246
|
};
|
|
273
247
|
const connect = (server, url, headers) => {
|
|
274
248
|
let upstream = clients.get(server);
|
|
@@ -276,10 +250,8 @@ export function mcpGateway(options) {
|
|
|
276
250
|
const status = {};
|
|
277
251
|
statuses.set(server, status);
|
|
278
252
|
upstream = (async () => {
|
|
279
|
-
const {
|
|
280
|
-
|
|
281
|
-
const client = new Client({ name: "agentrun", version: "1.0.0" }, { capabilities: {}, versionNegotiation: { mode: "auto" } });
|
|
282
|
-
await client.connect(new StreamableHTTPClientTransport(new URL(url), { fetch: guarded(server, () => credentials.get(server)?.headers ?? {}, status) }), { timeout: options.bounds?.connectMs ?? CONNECT_MS });
|
|
253
|
+
const { client, transport } = mcpClient(await import("@modelcontextprotocol/client"), { name: "agentrun", version: "1.0.0", url: new URL(url), fetch: guarded(server, () => credentials.get(server)?.headers ?? {}, status) });
|
|
254
|
+
await client.connect(transport, { timeout: options.bounds?.connectMs ?? CONNECT_MS });
|
|
283
255
|
return client;
|
|
284
256
|
})();
|
|
285
257
|
clients.set(server, upstream);
|
package/dist/mcp-oauth.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OAuthClientMetadata, OAuthDiscoveryState, OAuthTokens, StoredOAuthClientInformation } from "@modelcontextprotocol/client";
|
|
2
|
+
import type { SourceRecord } from "./mcp-sources.js";
|
|
2
3
|
/** The authorization server sends the owner's browser back here; it holds no credential, so it takes none. */
|
|
3
4
|
export declare const OAUTH_CALLBACK = "/v2/settings/mcp-servers/oauth/callback";
|
|
4
5
|
/** This server's client metadata document, its client id where the authorization server takes one (CIMD). */
|
|
@@ -26,6 +27,8 @@ export type TokenSet = {
|
|
|
26
27
|
};
|
|
27
28
|
/** `keptFor`: the authorization server (its issuer) a client kept from an earlier sign-in was registered at; the client is
|
|
28
29
|
* used again only when discovery finds that same one (else it is dropped, and the sign-in registers anew). */
|
|
30
|
+
/** `source`: what the start said the server is (its source and toolkit, mcp-sources.ts), written for the row the sign-in
|
|
31
|
+
* saves. */
|
|
29
32
|
export type Pending = {
|
|
30
33
|
name: string;
|
|
31
34
|
url: string;
|
|
@@ -37,6 +40,7 @@ export type Pending = {
|
|
|
37
40
|
verifier?: string;
|
|
38
41
|
discovery?: OAuthDiscoveryState;
|
|
39
42
|
resource?: string;
|
|
43
|
+
source?: SourceRecord;
|
|
40
44
|
expires: number;
|
|
41
45
|
};
|
|
42
46
|
/** The authorization server a discovery found, by its issuer (its metadata's, else its URL). */
|
|
@@ -189,6 +193,7 @@ export declare class McpSignIns {
|
|
|
189
193
|
client?: StoredOAuthClientInformation;
|
|
190
194
|
kind?: ClientKind;
|
|
191
195
|
keptFor?: string;
|
|
196
|
+
source?: SourceRecord;
|
|
192
197
|
}): Promise<string>;
|
|
193
198
|
/** The callback's sign-in, by its state, from the pending store: once, and only within ten minutes of its start. `was`
|
|
194
199
|
* is the server's save when it started (null for none), so a sign-in the owner since replaced or forgot is not
|
package/dist/mcp-oauth.js
CHANGED
|
@@ -358,7 +358,7 @@ export class McpSignIns {
|
|
|
358
358
|
async start(name, url, options) {
|
|
359
359
|
const now = Date.now();
|
|
360
360
|
const state = randomBytes(32).toString("base64url");
|
|
361
|
-
const entry = { name, url: url.href, was: options.was, ...(options.scope ? { scope: options.scope } : {}), kind: options.kind ?? "dynamic", ...(options.client ? { client: options.client } : {}), ...(options.keptFor ? { keptFor: options.keptFor } : {}), expires: now + STATE_MS };
|
|
361
|
+
const entry = { name, url: url.href, was: options.was, ...(options.scope ? { scope: options.scope } : {}), kind: options.kind ?? "dynamic", ...(options.client ? { client: options.client } : {}), ...(options.keptFor ? { keptFor: options.keptFor } : {}), ...(options.source ? { source: options.source } : {}), expires: now + STATE_MS };
|
|
362
362
|
let opened;
|
|
363
363
|
const seen = {};
|
|
364
364
|
const reach = { own: this.own, allowed: await this.allowed(), loopback: this.loopback };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type McpPin } from "./mcp-gateway.js";
|
|
2
|
+
import type { OAuthNetwork } from "./mcp-oauth.js";
|
|
3
|
+
import { type McpServersOverStore, mcpServersOverStore } from "./mcp-servers-store.js";
|
|
4
|
+
import { type GithubAppAccess } from "./runner/mcp-github.js";
|
|
5
|
+
/** One server's listing as a save pins it (McpServersOverStore.pinListing); undefined when no such server is saved. */
|
|
6
|
+
export type PinListing = Awaited<ReturnType<McpServersOverStore["pinListing"]>>;
|
|
7
|
+
export interface PinFirstDeps {
|
|
8
|
+
/** Whether a server of this name is saved here: a grant of one that is not leaves the revision unpinned, to the run's
|
|
9
|
+
* own refusal, so the pin is made whole once the server is saved again. */
|
|
10
|
+
saved(server: string): boolean | Promise<boolean>;
|
|
11
|
+
/** The server's listing now, as a save lists it; throws when it can't be listed. */
|
|
12
|
+
pinListing(server: string): Promise<PinListing>;
|
|
13
|
+
/** Agents.pinOnce: `pin` written only while the revision has none; the pin it has then. */
|
|
14
|
+
pinOnce(revisionId: string, pin: McpPin): Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/** The revision's MCP pin: its own when it has one; else, when every server it grants a tool of is saved here and lists
|
|
17
|
+
* it, the pin made now of all of them and kept on it (or the one another first run kept first). Undefined when it grants
|
|
18
|
+
* none, or when one such server is not saved, can't be listed or no longer lists a granted tool: nothing is written (a
|
|
19
|
+
* pin of the other servers alone would stand for good, its missing tool never pinned), and the run is refused in the
|
|
20
|
+
* words it was (server.ts runnable at a start, the claim's own at a claim). */
|
|
21
|
+
export declare function pinFirst(revision: {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly kind: string;
|
|
24
|
+
readonly body: unknown;
|
|
25
|
+
readonly mcpPin?: unknown;
|
|
26
|
+
}, deps: PinFirstDeps): Promise<McpPin | undefined>;
|
|
27
|
+
/** A runner's pinListing (PinFirstDeps): the owner's registry over the one store, opened with the runner's seal key (the
|
|
28
|
+
* server's) on the first listing it is asked for, loopback allowed only for a runner beside a local install. `githubApp`:
|
|
29
|
+
* the run's GitHub App access (runner/mcp-github.ts), which lists a `github_app` server with a token of the run's
|
|
30
|
+
* repository, metadata read alone, as a save lists it with one (github-connection.ts tokenForListing); without it such a
|
|
31
|
+
* server can't be listed. `appOrigin`: a test's fake GitHub MCP (McpServersOverStore.appOrigin). */
|
|
32
|
+
export declare function registryListing(store: Parameters<typeof mcpServersOverStore>[0], sealKey: Buffer, { loopback, network, githubApp, appOrigin }?: {
|
|
33
|
+
loopback?: boolean;
|
|
34
|
+
network?: OAuthNetwork;
|
|
35
|
+
githubApp?: GithubAppAccess;
|
|
36
|
+
appOrigin?: string;
|
|
37
|
+
}): (server: string, stop?: AbortSignal) => Promise<PinListing>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// A revision saved with no MCP pin (before pins were made at save, or an inline agent's version stored then) is pinned
|
|
2
|
+
// once, at its first run, as a save would pin it: each granted server still saved here listed once
|
|
3
|
+
// (McpServersOverStore.pinListing, the save's own listing), the pin made of those listings (mcp-gateway.ts mcpPinOf), and
|
|
4
|
+
// written only while the revision still has none (Agents.pinOnce), the pin that stood read back. One path for a run's
|
|
5
|
+
// start (server.ts, before runnable) and a run's claim (runner/mcp-claim.ts, for a run that already existed when the
|
|
6
|
+
// store was upgraded): two first runs, or a start and a claim, at once agree on one pin. Nothing moves from a run's old
|
|
7
|
+
// per-run pin (mcp_pins, dropped at the upgrade): the revision's pin is the one every run of it reads.
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { mcpPinOf } from "./mcp-gateway.js";
|
|
10
|
+
import { boundTool } from "./mcp-probe.js";
|
|
11
|
+
import { mcpServersOverStore } from "./mcp-servers-store.js";
|
|
12
|
+
import { SEAL_KEY_ENV } from "./tool-keys.js";
|
|
13
|
+
import { mcpNameOf } from "./tool-names.js";
|
|
14
|
+
import { GITHUB_UNUSABLE } from "./runner/mcp-github.js";
|
|
15
|
+
/** The revision's MCP pin: its own when it has one; else, when every server it grants a tool of is saved here and lists
|
|
16
|
+
* it, the pin made now of all of them and kept on it (or the one another first run kept first). Undefined when it grants
|
|
17
|
+
* none, or when one such server is not saved, can't be listed or no longer lists a granted tool: nothing is written (a
|
|
18
|
+
* pin of the other servers alone would stand for good, its missing tool never pinned), and the run is refused in the
|
|
19
|
+
* words it was (server.ts runnable at a start, the claim's own at a claim). */
|
|
20
|
+
export async function pinFirst(revision, deps) {
|
|
21
|
+
if (revision.mcpPin !== undefined && revision.mcpPin !== null)
|
|
22
|
+
return revision.mcpPin;
|
|
23
|
+
if (revision.kind !== "agentic")
|
|
24
|
+
return undefined;
|
|
25
|
+
const granted = [];
|
|
26
|
+
for (const tool of revision.body.tools ?? []) {
|
|
27
|
+
const named = mcpNameOf(tool);
|
|
28
|
+
if (!named)
|
|
29
|
+
continue;
|
|
30
|
+
if (!(await deps.saved(named.server)))
|
|
31
|
+
return undefined;
|
|
32
|
+
granted.push(tool);
|
|
33
|
+
}
|
|
34
|
+
if (!granted.length)
|
|
35
|
+
return undefined;
|
|
36
|
+
const listings = new Map();
|
|
37
|
+
try {
|
|
38
|
+
await Promise.all([...new Set(granted.map((tool) => mcpNameOf(tool).server))].map(async (server) => {
|
|
39
|
+
const listing = await deps.pinListing(server);
|
|
40
|
+
if (!listing)
|
|
41
|
+
throw new Error(`${server} is no longer saved`);
|
|
42
|
+
listings.set(server, listing);
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
let pin;
|
|
49
|
+
try {
|
|
50
|
+
pin = mcpPinOf(granted, { server: (name) => { const listing = listings.get(name); return listing && { url: listing.url, tools: listing.tools.map(boundTool), prices: listing.prices }; } });
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
if (!Object.keys(pin).length)
|
|
56
|
+
return undefined;
|
|
57
|
+
return ((await deps.pinOnce(revision.id, pin)) ?? undefined);
|
|
58
|
+
}
|
|
59
|
+
/** A runner's pinListing (PinFirstDeps): the owner's registry over the one store, opened with the runner's seal key (the
|
|
60
|
+
* server's) on the first listing it is asked for, loopback allowed only for a runner beside a local install. `githubApp`:
|
|
61
|
+
* the run's GitHub App access (runner/mcp-github.ts), which lists a `github_app` server with a token of the run's
|
|
62
|
+
* repository, metadata read alone, as a save lists it with one (github-connection.ts tokenForListing); without it such a
|
|
63
|
+
* server can't be listed. `appOrigin`: a test's fake GitHub MCP (McpServersOverStore.appOrigin). */
|
|
64
|
+
export function registryListing(store, sealKey, { loopback = false, network, githubApp, appOrigin } = {}) {
|
|
65
|
+
let registry;
|
|
66
|
+
// The listing tokens minted and not yet revoked, and how many listings are under way: no one holds a listing token
|
|
67
|
+
// after its listing (the claim's cleanup reaches only githubTokens' tokens), so once no listing is under way, each is
|
|
68
|
+
// revoked at GitHub, whether the listing answered or failed.
|
|
69
|
+
const minted = [];
|
|
70
|
+
let listing = 0;
|
|
71
|
+
const open = async () => {
|
|
72
|
+
const { version } = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
73
|
+
const opened = mcpServersOverStore(store, { [SEAL_KEY_ENV]: sealKey.toString("base64") }, version, network);
|
|
74
|
+
opened.attach("", "", loopback);
|
|
75
|
+
if (appOrigin)
|
|
76
|
+
opened.appOrigin = appOrigin;
|
|
77
|
+
if (githubApp)
|
|
78
|
+
opened.appToken = async () => {
|
|
79
|
+
const got = await listingToken(githubApp);
|
|
80
|
+
if ("token" in got)
|
|
81
|
+
minted.push(got.token);
|
|
82
|
+
return got;
|
|
83
|
+
};
|
|
84
|
+
return opened;
|
|
85
|
+
};
|
|
86
|
+
return async (server, stop) => {
|
|
87
|
+
listing += 1;
|
|
88
|
+
try {
|
|
89
|
+
return await (await (registry ??= open())).pinListing(server, stop);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
listing -= 1;
|
|
93
|
+
if (!listing)
|
|
94
|
+
await Promise.all(minted.splice(0).map((token) => githubApp?.revoke?.(token).catch(() => undefined)));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** A token to list a github_app server's tools with, from the run's App access: its repository, metadata read alone; or
|
|
99
|
+
* why there is none, in the words its calls would be refused in. */
|
|
100
|
+
async function listingToken(access) {
|
|
101
|
+
if (!access.target)
|
|
102
|
+
return { unusable: GITHUB_UNUSABLE.noRepo };
|
|
103
|
+
const minted = await access.mint(access.target, { metadata: "read" });
|
|
104
|
+
if (minted.ok)
|
|
105
|
+
return { token: minted.token };
|
|
106
|
+
return minted.reason === "github_failed" ? { failed: minted.message } : { unusable: minted.message };
|
|
107
|
+
}
|
package/dist/mcp-probe.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ApiError, type InputIssue } from "./errors.js";
|
|
2
|
-
export declare const MCP_SERVER_NAME: RegExp;
|
|
3
2
|
/** `per_run`: the server keeps no credential; each run's caller hands one with the run (mcp_auth), held for that run alone. */
|
|
4
3
|
export declare const MCP_AUTH_TYPES: readonly ["none", "bearer", "headers", "oauth", "github_app", "per_run"];
|
|
5
4
|
/** Why a saved credential can't be used for a run's calls, each with its own remedy and no other, as the model reads it
|
|
@@ -65,18 +64,18 @@ export declare const nameOf: (name: string) => void;
|
|
|
65
64
|
export declare function pricesListed(prices: McpPrices | undefined, listed: readonly {
|
|
66
65
|
name: string;
|
|
67
66
|
}[]): McpPrices;
|
|
68
|
-
/** `listed` with each known meta tool (mcp-meta.ts) marked `grantable: false` with its reason
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
/** `listed` with each known meta tool (mcp-meta.ts) marked `grantable: false` with its reason: the one place a listing is
|
|
68
|
+
* marked, in the registry's shape of a tool or the harnesses' (a saved server's tools read by blockersOf). */
|
|
69
|
+
export declare function marked<Tool extends {
|
|
70
|
+
name: string;
|
|
71
|
+
}, T extends {
|
|
72
|
+
tools: Tool[];
|
|
71
73
|
}>(url: string, listed: T): T & {
|
|
72
|
-
tools: (
|
|
74
|
+
tools: (Tool & {
|
|
73
75
|
grantable?: false;
|
|
74
76
|
reason?: string;
|
|
75
77
|
})[];
|
|
76
78
|
};
|
|
77
|
-
/** `text` with every credential value cut out: each header's value, and a bearer's token alone, which a server may
|
|
78
|
-
* echo without its scheme. */
|
|
79
|
-
export declare const scrub: (text: string, headers: HeaderMap) => string;
|
|
80
79
|
/** JSON with sorted keys, so two listings of one tool compare equal whatever order the server sends its fields in. */
|
|
81
80
|
export declare const canonical: (value: unknown) => string;
|
|
82
81
|
/** The body's prices: each tool's USD a call, a finite number, 0 or more. Which tools the server lists is checked once
|
|
@@ -112,7 +111,7 @@ export declare const MAX_OAUTH_VALUE_BYTES = 8192;
|
|
|
112
111
|
/** Whether an OAuth client id or secret a sign-in body sends is well formed (text, not empty, no control, within the cap). */
|
|
113
112
|
export declare const oauthValueValid: (text: unknown) => boolean;
|
|
114
113
|
/** Connect to `url`, agree a protocol revision, and list every tool (all pages), each request held to REQUEST_MS and
|
|
115
|
-
*
|
|
114
|
+
* MAX_RESPONSE and the whole to PREVIEW_MS. A failure is an ApiError: 422 auth_required (with the auth the
|
|
116
115
|
* server asks for), 422 not_mcp, 422 input_invalid for a redirect, else 424 upstream_failed. `send`: how each request
|
|
117
116
|
* goes, the store-backed registry's dialled at the address its check let through (mcp-oauth.ts mcpServerAt, dialAt). */
|
|
118
117
|
export declare function listServer(url: URL, headers: HeaderMap, version: string, stop?: AbortSignal, send?: typeof fetch): Promise<Listed>;
|