@parcha/agentrun-serve 0.1.0-beta.38 → 0.1.0-beta.40
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 +455 -0
- package/README.md +376 -125
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +0 -2
- package/dist/agents-store.d.ts +5 -5
- package/dist/agents-store.js +14 -14
- package/dist/bash-read-only.js +2 -1
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -10
- package/dist/cap.js +2 -5
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +1 -5
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +8 -0
- package/dist/composio-preset.js +8 -7
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.js +2 -2
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +7 -2
- package/dist/computer-live.js +9 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +3 -3
- package/dist/computer-setting.js +5 -5
- package/dist/computer-view.d.ts +15 -0
- package/dist/computer-view.js +16 -2
- package/dist/computer-viewer.js +14 -1
- package/dist/computers.d.ts +5 -2
- package/dist/computers.js +9 -5
- package/dist/console/assets/index-B8Zn1Iqn.css +1 -0
- package/dist/console/assets/index-Jbxjcmdp.js +705 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.js +3 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/email/account.d.ts +83 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +15 -0
- package/dist/email/answer.js +217 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +373 -0
- package/dist/email/names.d.ts +50 -0
- package/dist/email/names.js +74 -0
- package/dist/email/routes.d.ts +10 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +27 -0
- package/dist/email/tools.js +562 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -26
- package/dist/harness-opencode/facts.js +5 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -0
- package/dist/harness-opencode/host/policy.js +10 -5
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.js +8 -5
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/hosted-search.d.ts +3 -1
- package/dist/hosted-search.js +51 -11
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/learn/check.d.ts +18 -3
- package/dist/learn/check.js +328 -3
- package/dist/learn/compile.d.ts +12 -4
- package/dist/learn/compile.js +57 -20
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +4 -1
- package/dist/learn/promote.d.ts +130 -64
- package/dist/learn/promote.js +113 -202
- package/dist/learn/refit.d.ts +21 -12
- package/dist/learn/refit.js +51 -23
- package/dist/learn/replay-calls.js +1 -1
- package/dist/learn/skills.d.ts +2 -7
- package/dist/learn/skills.js +28 -14
- package/dist/learned-nodes.d.ts +15 -7
- package/dist/learned-nodes.js +29 -5
- package/dist/learned-workflow.d.ts +41 -31
- package/dist/learned-workflow.js +122 -63
- package/dist/learning-batch.js +3 -3
- package/dist/learning-cost.d.ts +35 -8
- package/dist/learning-cost.js +27 -9
- package/dist/learning-routes.d.ts +2 -4
- package/dist/learning-routes.js +20 -3
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +4 -1
- package/dist/learning.d.ts +5 -5
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/local-models.d.ts +39 -2
- package/dist/local-models.js +49 -5
- package/dist/mcp-pin-first.js +6 -0
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +25 -16
- package/dist/mcp-servers-store.js +23 -3
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +26 -6
- package/dist/model.js +126 -18
- package/dist/monid.d.ts +26 -31
- package/dist/monid.js +84 -79
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +2 -1
- package/dist/openapi.js +404 -93
- package/dist/paid-calls.d.ts +8 -3
- package/dist/paid-calls.js +6 -2
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +10 -2
- package/dist/port-models.js +6 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +1 -2
- package/dist/propose.js +10 -1
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +8 -0
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/refusal-words.d.ts +14 -0
- package/dist/refusal-words.js +16 -2
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +13 -4
- package/dist/run-learning-served.d.ts +75 -2
- package/dist/run-manifest.d.ts +3 -0
- package/dist/run-manifest.js +13 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +8 -9
- package/dist/run-view.d.ts +44 -38
- package/dist/run-view.js +93 -56
- package/dist/runnable.d.ts +13 -5
- package/dist/runnable.js +69 -60
- package/dist/runner/adapter-loop.d.ts +48 -13
- package/dist/runner/adapter-loop.js +691 -254
- package/dist/runner/adapter-run-spec.d.ts +38 -12
- package/dist/runner/adapter-run-spec.js +175 -106
- package/dist/runner/adapters/pi.d.ts +24 -0
- package/dist/runner/adapters/pi.js +59 -9
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +95 -50
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +3 -2
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.js +6 -3
- package/dist/runner/end-of-run.d.ts +2 -0
- package/dist/runner/end-of-run.js +3 -1
- package/dist/runner/feedback-round.d.ts +40 -13
- package/dist/runner/feedback-round.js +64 -16
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +59 -13
- package/dist/runner/journal-kinds.js +48 -5
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +4 -0
- package/dist/runner/learning-end.js +64 -36
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +2 -0
- package/dist/runner/learning-loop.js +19 -4
- package/dist/runner/loop.d.ts +18 -0
- package/dist/runner/loop.js +34 -0
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-run.d.ts +4 -1
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/meta-tools.d.ts +10 -3
- package/dist/runner/meta-tools.js +112 -36
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +114 -39
- package/dist/runner/model-route.d.ts +14 -3
- package/dist/runner/model-route.js +155 -19
- package/dist/runner/monid-run.d.ts +8 -6
- package/dist/runner/monid-run.js +117 -43
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +76 -10
- package/dist/runner/promotion.js +476 -154
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.js +9 -0
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +8 -4
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/workflow-first.d.ts +30 -20
- package/dist/runner/workflow-first.js +22 -32
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +18 -12
- package/dist/runner/workflow-spec.d.ts +4 -1
- package/dist/runner/workflow-spec.js +56 -45
- package/dist/runs-over-store.d.ts +30 -2
- package/dist/runs-over-store.js +46 -14
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +48 -32
- package/dist/server.js +568 -137
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +12 -8
- package/dist/store/agent-body.js +9 -4
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/connection.d.ts +11 -5
- package/dist/store/postgres/connection.js +44 -17
- package/dist/store/postgres/dialect.js +5 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.d.ts +7 -3
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +7 -0
- package/dist/store/schema.js +20 -1
- package/dist/store/sqlite/connection.js +72 -8
- package/dist/store/sqlite/run-launch.d.ts +11 -0
- package/dist/store/sqlite/run-launch.js +8 -0
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +14 -3
- package/dist/store/sqlite/store.js +170 -34
- package/dist/store/sqlite/worker.d.ts +2 -0
- package/dist/store/sqlite/worker.js +13 -10
- package/dist/store/store.d.ts +67 -7
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +5 -0
- package/dist/store-reads/journal.js +85 -41
- package/dist/store-reads/learning.d.ts +115 -18
- package/dist/store-reads/learning.js +170 -68
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +75 -21
- package/dist/template-eval.d.ts +73 -11
- package/dist/template-eval.js +535 -75
- package/dist/templates.d.ts +84 -21
- package/dist/templates.js +254 -47
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/index.d.ts +3 -2
- package/dist/timeline/index.js +3 -2
- package/dist/timeline/labels.d.ts +5 -2
- package/dist/timeline/labels.js +29 -6
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +66 -4
- package/dist/timeline/timeline.js +160 -30
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +46 -44
- package/dist/tool-gate.js +101 -92
- package/dist/tool-list.d.ts +4 -1
- package/dist/tool-list.js +8 -1
- package/dist/tool-names.d.ts +18 -13
- package/dist/tool-names.js +19 -17
- package/dist/tool-plane.d.ts +17 -13
- package/dist/tool-plane.js +12 -5
- package/dist/tools.d.ts +57 -16
- package/dist/tools.js +33 -28
- package/dist/trigger-adapter.d.ts +56 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +181 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +105 -8
- package/dist/triggers.js +286 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.js +1 -7
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +5 -1
- package/dist/web-fetch.js +8 -31
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/decision-recovery.js +5 -2
- package/dist/workflow/decisions.d.ts +7 -0
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +22 -9
- package/dist/workspace/computer-deps.js +78 -37
- package/dist/workspace/computer-for-claim.d.ts +54 -4
- package/dist/workspace/computer-for-claim.js +179 -39
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
- package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
- package/dist/workspace/resolve-computer.d.ts +15 -3
- package/dist/workspace/resolve-computer.js +10 -7
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +28 -29
- package/dist/workspace/run-tools.js +29 -30
- package/dist/wrap-up.d.ts +19 -5
- package/dist/wrap-up.js +31 -4
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +117 -23
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +18 -4
- package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +1 -1
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/skills/review/DEEP.md +2 -2
- package/templates/code-review/skills/review/REVIEWER.md +2 -2
- package/templates/code-review/skills/review/SKILL.md +7 -3
- package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
- package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
- package/templates/release-notes/evals/other-repo/case.yaml +1 -1
- package/dist/console/assets/index-CjqQirbo.css +0 -1
- package/dist/console/assets/index-b6-XY5A9.js +0 -576
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -9
- package/dist/runner/adapters/pi-computer.js +0 -51
- package/dist/workspace/computer-script.d.ts +0 -53
- package/dist/workspace/computer-script.js +0 -172
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// A template eval's link check (template-eval.ts graderInput): each http(s) link a run's answer cites, matched in code
|
|
2
|
+
// against every url its calls answered (its web calls', and the URLs any other call's result holds whole), so "every link
|
|
3
|
+
// the answer cites appears in the run's calls" is read from one block, never judged as URL equality from a rubric's prose. A link matches a url when their canonical forms do
|
|
4
|
+
// (canonicalUrl): no fragment, no trailing slash on the path, scheme and host lower-cased, no leading "www." on the host,
|
|
5
|
+
// query keys sorted; the two key
|
|
6
|
+
// sets equal, and each value equal, except that a call's value read as "…" (a timeline read elides query values,
|
|
7
|
+
// scrubUrls) matches any value for its key. Structural only: whether a cited item is in scope stays the rubric's call.
|
|
8
|
+
import { lastJsonBlock } from "./answer-json.js";
|
|
9
|
+
import { linksOf, linksWritten, TRAILING, trimmed, wholeUrl } from "./text-urls.js";
|
|
10
|
+
import { scrubUrl } from "./timeline/index.js";
|
|
11
|
+
import { WEB_FETCH_TOOL } from "./web-fetch.js";
|
|
12
|
+
import { WEB_SEARCH_TOOL } from "./web-search.js";
|
|
13
|
+
const ELIDED = "…";
|
|
14
|
+
const isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
+
const strings = (value) => (Array.isArray(value) ? value.filter((item) => typeof item === "string") : []);
|
|
16
|
+
/** `url` canonical (see the head of this file), or undefined for one that is not an http(s) URL. */
|
|
17
|
+
export function canonicalUrl(url) {
|
|
18
|
+
let parsed;
|
|
19
|
+
try {
|
|
20
|
+
parsed = new URL(url.trim());
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
26
|
+
return undefined;
|
|
27
|
+
const query = new Map();
|
|
28
|
+
for (const [key, value] of parsed.searchParams)
|
|
29
|
+
query.set(key, [...(query.get(key) ?? []), value]);
|
|
30
|
+
for (const values of query.values())
|
|
31
|
+
values.sort();
|
|
32
|
+
// A host and the same host with "www." in front are one site (cpsc.gov, www.cpsc.gov); "www." is dropped only where a
|
|
33
|
+
// domain is left after it (never www.com's), and no other subdomain is (m., amp.).
|
|
34
|
+
const host = parsed.host.replace(/^www\.(?=[^.]+\.)/, "");
|
|
35
|
+
return { base: `${parsed.protocol}//${host}${parsed.pathname.replace(/\/+$/, "")}`, query };
|
|
36
|
+
}
|
|
37
|
+
/** Whether a cited link matches a url a call answered: the same base and key set, each value equal unless the call's
|
|
38
|
+
* values are all "…". */
|
|
39
|
+
export function urlMatches(cited, called) {
|
|
40
|
+
if (cited.base !== called.base || cited.query.size !== called.query.size)
|
|
41
|
+
return false;
|
|
42
|
+
for (const [key, values] of called.query) {
|
|
43
|
+
const mine = cited.query.get(key);
|
|
44
|
+
if (!mine)
|
|
45
|
+
return false;
|
|
46
|
+
if (values.every((value) => value === ELIDED))
|
|
47
|
+
continue;
|
|
48
|
+
if (mine.length !== values.length || mine.some((value, i) => value !== values[i]))
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/** The forms a URL found in plain text may end at, longest first: as found, then less one trailing punctuation mark at a
|
|
54
|
+
* time. A URL can end in one (`/wiki/Yahoo!`), so which is the link is read from what matches, never guessed. */
|
|
55
|
+
function formsOf(raw) {
|
|
56
|
+
const forms = [raw];
|
|
57
|
+
for (let url = raw; url && TRAILING.includes(url.at(-1));)
|
|
58
|
+
forms.push((url = url.slice(0, -1)));
|
|
59
|
+
return forms;
|
|
60
|
+
}
|
|
61
|
+
/** Every http(s) URL in `text`, in order, read as a page's links are (linksWritten, text-urls.ts), each as the forms it may
|
|
62
|
+
* end at: a markdown link's target that its ")" closed as that one form; any other as formsOf gives it. A link's text
|
|
63
|
+
* and target read as two. */
|
|
64
|
+
function linksIn(text) {
|
|
65
|
+
return [...linksWritten(text)].flatMap(({ raw, exact }) => (/^https?:\/\//i.test(raw) ? [exact ? [raw] : formsOf(raw)] : []));
|
|
66
|
+
}
|
|
67
|
+
/** A JSON string's links: the string itself when it is one URL whole (wholeUrl: a field holding a link means all of it),
|
|
68
|
+
* else those in its text. */
|
|
69
|
+
const jsonLinks = (text) => {
|
|
70
|
+
const whole = wholeUrl(text);
|
|
71
|
+
return whole === undefined ? linksIn(text) : [[whole]];
|
|
72
|
+
};
|
|
73
|
+
/** Every string in `value`, property names aside. */
|
|
74
|
+
function stringsIn(value) {
|
|
75
|
+
if (typeof value === "string")
|
|
76
|
+
return [value];
|
|
77
|
+
if (Array.isArray(value))
|
|
78
|
+
return value.flatMap(stringsIn);
|
|
79
|
+
return isObj(value) ? Object.values(value).flatMap(stringsIn) : [];
|
|
80
|
+
}
|
|
81
|
+
/** Every http(s) URL an answer cites, in order, each once, as the forms it may end at (linksIn, jsonLinks): in its text,
|
|
82
|
+
* and in any string of its JSON (the whole answer, else its last json block), read from the parsed JSON so an escape in
|
|
83
|
+
* it never cuts a URL short. */
|
|
84
|
+
export function citedLinks(answer) {
|
|
85
|
+
let found;
|
|
86
|
+
try {
|
|
87
|
+
found = stringsIn(JSON.parse(answer)).flatMap(jsonLinks);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
const block = lastJsonBlock(answer);
|
|
91
|
+
let parsed;
|
|
92
|
+
try {
|
|
93
|
+
parsed = block === undefined ? undefined : JSON.parse(block);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
parsed = undefined;
|
|
97
|
+
}
|
|
98
|
+
found = parsed === undefined ? linksIn(answer) : [...linksIn(answer.replace(block, "")), ...stringsIn(parsed).flatMap(jsonLinks)];
|
|
99
|
+
}
|
|
100
|
+
return [...new Map(found.map((forms) => [forms.join("\n"), forms])).values()];
|
|
101
|
+
}
|
|
102
|
+
/** A call's urls for the check, and whether it is a web call: a web_search's results', a web_fetch's asked url, final url
|
|
103
|
+
* and page links, with how many of that page's links its output lost to a cut (`links_cut`). Any other call's are the
|
|
104
|
+
* URLs its result holds as it returned them (linksOf: a JSON string that is a URL whole counts whole). A grader reads
|
|
105
|
+
* only such a result's head (CALL_RESULT_CHARS, cut with "..." as timeline/util.ts cut ends it), so one ending in "..."
|
|
106
|
+
* may have held more past it: a cut of unknown count (1), named on a link that matches nothing, never a verdict. */
|
|
107
|
+
function sourceOf(call) {
|
|
108
|
+
const tool = call.name ?? call.tool;
|
|
109
|
+
const text = call.result ?? "";
|
|
110
|
+
if (tool !== WEB_SEARCH_TOOL && tool !== WEB_FETCH_TOOL)
|
|
111
|
+
return { urls: [...linksOf(text)], cut: text.endsWith("...") ? 1 : 0, web: false };
|
|
112
|
+
const end = text.indexOf("\n");
|
|
113
|
+
let read;
|
|
114
|
+
try {
|
|
115
|
+
read = JSON.parse(end < 0 ? text : text.slice(0, end));
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
read = undefined;
|
|
119
|
+
}
|
|
120
|
+
const out = isObj(read) ? read : {};
|
|
121
|
+
if (tool === WEB_SEARCH_TOOL)
|
|
122
|
+
return { urls: Array.isArray(out.results) ? out.results.flatMap((hit) => (isObj(hit) && typeof hit.url === "string" ? [hit.url] : [])) : [], cut: 0, web: true };
|
|
123
|
+
const asked = isObj(call.arguments) && typeof call.arguments.url === "string" ? [call.arguments.url] : [];
|
|
124
|
+
return { urls: [...asked, ...(typeof out.url === "string" ? [out.url] : []), ...strings(out.links)], cut: typeof out.links_cut === "number" ? out.links_cut : 0, web: true };
|
|
125
|
+
}
|
|
126
|
+
const callsWord = (calls) => (calls.length === 1 ? `call ${calls[0]}` : `calls ${calls.slice(0, -1).join(", ")} and ${calls.at(-1)}`);
|
|
127
|
+
/** The link check's lines for a grader, or undefined when there is nothing to check: the run made no web_search or
|
|
128
|
+
* web_fetch call, and either the answer cites no link or no call returned a URL. One line per distinct link the answer
|
|
129
|
+
* cites, shown as a call's url is (scrubUrl: no query values, fragment or userinfo), saying the first call (numbered as
|
|
130
|
+
* the grader's list numbers them) one of whose urls it matches, or that none does, naming any fetched page whose links
|
|
131
|
+
* were cut, as that page could have held it. */
|
|
132
|
+
export function linkCheck(answer, calls) {
|
|
133
|
+
const sources = calls.map(sourceOf);
|
|
134
|
+
const citations = citedLinks(answer);
|
|
135
|
+
if (!sources.some((source) => source.web) && !(citations.length && sources.some((source) => source.urls.length)))
|
|
136
|
+
return undefined;
|
|
137
|
+
const called = sources.map((source) => source.urls.flatMap((url) => canonicalUrl(url) ?? []));
|
|
138
|
+
const cut = sources.flatMap((source, i) => (source.cut ? [i + 1] : []));
|
|
139
|
+
const seen = new Set();
|
|
140
|
+
const lines = [];
|
|
141
|
+
const matchOf = (cited) => called.findIndex((urls) => urls.some((url) => urlMatches(cited, url)));
|
|
142
|
+
for (const forms of citations) {
|
|
143
|
+
// The longest form that matches a call is the link; with none, a plain-text one less the punctuation around it.
|
|
144
|
+
let [link, at] = [forms.length > 1 ? trimmed(forms[0]) : forms[0], -1];
|
|
145
|
+
for (const form of forms) {
|
|
146
|
+
const canonical = canonicalUrl(form);
|
|
147
|
+
const i = canonical ? matchOf(canonical) : -1;
|
|
148
|
+
if (i < 0)
|
|
149
|
+
continue;
|
|
150
|
+
[link, at] = [form, i];
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
const cited = canonicalUrl(link);
|
|
154
|
+
if (!cited)
|
|
155
|
+
continue;
|
|
156
|
+
const key = JSON.stringify([cited.base, [...cited.query].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))]);
|
|
157
|
+
if (seen.has(key))
|
|
158
|
+
continue;
|
|
159
|
+
seen.add(key);
|
|
160
|
+
lines.push(`${scrubUrl(link)} — ${at >= 0 ? `matches call ${at + 1}` : `no matching call${cut.length ? ` (${callsWord(cut)}'s links were cut)` : ""}`}`);
|
|
161
|
+
}
|
|
162
|
+
const intro = "Each distinct http(s) link the answer cites, checked in code against every url its calls answered (a web_search's results; a web_fetch's url, its final url and its page's links; any other call's URLs as its result holds them): a fragment, a trailing slash, a leading www. on the host and the order of the query are ignored, the query's keys must be the same, and a query value shown as … matches any value for its key. Links are shown with their query values elided.";
|
|
163
|
+
return [intro, ...(lines.length ? lines : ["(the answer cites no http(s) link)"])].join("\n");
|
|
164
|
+
}
|
package/dist/local-models.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Api, Model, MutableModels } from "@earendil-works/pi-ai";
|
|
2
|
+
import { type ModelPrice } from "@parcha/agentrun-kernel/kernel/cap";
|
|
2
3
|
/** Particle-1's price, USD per million tokens: Particle's own list price, from https://docs.particle.ai/models (read
|
|
3
4
|
* 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
|
|
4
5
|
export declare const PARTICLE_1_PRICE: {
|
|
@@ -24,6 +25,42 @@ export declare const PRICE_OVERRIDES: readonly {
|
|
|
24
25
|
readonly cost: Model<Api>["cost"];
|
|
25
26
|
readonly toolsAs?: ToolsAs;
|
|
26
27
|
}[];
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
28
|
+
/** Models serve lists that pi-ai's catalog does not: OpenRouter's free variants of models that take tools, each a copy of
|
|
29
|
+
* `like` (a catalog entry on the same provider and wire: its api, base URL, compat and reasoning settings) under its own
|
|
30
|
+
* id, name, input, context window and output ceiling, at $0, taking its tools natively (the `like` entry's `toolsAs` is
|
|
31
|
+
* not copied). Context and output ceiling are OpenRouter's (GET https://openrouter.ai/api/v1/models, read 2026-11-15:
|
|
32
|
+
* context_length and top_provider.max_completion_tokens; pricing "0" prompt and completion). Each one answered a request
|
|
33
|
+
* that defined a tool with a call to that tool, through OpenRouter, on 2026-11-15, billed $0. `mustReason` is that list's
|
|
34
|
+
* `reasoning.mandatory` (read 2026-11-16): a model that must reason has thinking off mapped to no effort (thinkingLevelMap
|
|
35
|
+
* `off: null`, as pi-ai's catalog maps Claude Sonnet 5.5's), so pi-ai never sends it `reasoning: {effort: "none"}`, which
|
|
36
|
+
* OpenRouter refuses with "Reasoning is mandatory for this endpoint and cannot be disabled", and the model reasons at
|
|
37
|
+
* its default. A model that lists `reasoning` among its supported parameters need not reason (Ling 3.2 Flash): only
|
|
38
|
+
* `mandatory` says so. */
|
|
39
|
+
export declare const ADDED_MODELS: readonly {
|
|
40
|
+
readonly provider: string;
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly like: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly input: readonly ("text" | "image")[];
|
|
45
|
+
readonly contextWindow: number;
|
|
46
|
+
readonly maxTokens: number;
|
|
47
|
+
readonly mustReason: boolean;
|
|
48
|
+
}[];
|
|
49
|
+
/** Whether `provider`/`id` is one of OpenRouter's routers, each of which picks a model per request (the kernel cap's
|
|
50
|
+
* ROUTERS, the one list). OpenRouter lists the price of `auto`, `openrouter/auto*`, `openrouter/fusion`,
|
|
51
|
+
* `openrouter/pareto-code` and `typesafe/jev-router` as -1, the routed model's (read 2026-11-15), which pi-ai's catalog
|
|
52
|
+
* writes as 0; `openrouter/free` routes to a different free model per request. Their zeros say no model's price, so
|
|
53
|
+
* none of them is free: a model serve has no price for, which a cap cannot be kept on and which is never booked at its
|
|
54
|
+
* catalog's $0 (model.ts runModels' `unpriced`). */
|
|
55
|
+
export declare const isRouter: (provider: string, id: string) => boolean;
|
|
56
|
+
/** Whether a catalog entry runs at $0: the kernel's freeModel (kernel/cap/free.ts, the one rule, what a run on it books
|
|
57
|
+
* at $0) on the entry's price, its tiers included. An entry with no cost has no price, so is not free. */
|
|
58
|
+
export declare function isFree(model: {
|
|
59
|
+
id: string;
|
|
60
|
+
api?: string;
|
|
61
|
+
cost?: ModelPrice | null;
|
|
62
|
+
}): boolean;
|
|
63
|
+
/** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries and
|
|
64
|
+
* ADDED_MODELS listed beside them, in place: a request, a price and a capability read find the catalog's entry at the
|
|
65
|
+
* overridden price, with its toolsAs, and an added model as if the catalog listed it. */
|
|
29
66
|
export declare function withLocalModels<M extends MutableModels>(models: M): M;
|
package/dist/local-models.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { freeModel, ROUTERS } from "@parcha/agentrun-kernel/kernel/cap";
|
|
1
2
|
/** Particle-1's price, USD per million tokens: Particle's own list price, from https://docs.particle.ai/models (read
|
|
2
3
|
* 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
|
|
3
4
|
export const PARTICLE_1_PRICE = { input: 0.25, output: 1, cacheRead: 0.03, cacheWrite: 0 };
|
|
@@ -22,17 +23,60 @@ const priced = (list, overrides) => list.map((model) => {
|
|
|
22
23
|
const override = overrides.find((entry) => entry.id === model.id);
|
|
23
24
|
return override ? { ...model, cost: { ...override.cost }, ...(override.toolsAs ? { toolsAs: override.toolsAs } : {}) } : model;
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const ZERO = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
27
|
+
/** Models serve lists that pi-ai's catalog does not: OpenRouter's free variants of models that take tools, each a copy of
|
|
28
|
+
* `like` (a catalog entry on the same provider and wire: its api, base URL, compat and reasoning settings) under its own
|
|
29
|
+
* id, name, input, context window and output ceiling, at $0, taking its tools natively (the `like` entry's `toolsAs` is
|
|
30
|
+
* not copied). Context and output ceiling are OpenRouter's (GET https://openrouter.ai/api/v1/models, read 2026-11-15:
|
|
31
|
+
* context_length and top_provider.max_completion_tokens; pricing "0" prompt and completion). Each one answered a request
|
|
32
|
+
* that defined a tool with a call to that tool, through OpenRouter, on 2026-11-15, billed $0. `mustReason` is that list's
|
|
33
|
+
* `reasoning.mandatory` (read 2026-11-16): a model that must reason has thinking off mapped to no effort (thinkingLevelMap
|
|
34
|
+
* `off: null`, as pi-ai's catalog maps Claude Sonnet 5.5's), so pi-ai never sends it `reasoning: {effort: "none"}`, which
|
|
35
|
+
* OpenRouter refuses with "Reasoning is mandatory for this endpoint and cannot be disabled", and the model reasons at
|
|
36
|
+
* its default. A model that lists `reasoning` among its supported parameters need not reason (Ling 3.2 Flash): only
|
|
37
|
+
* `mandatory` says so. */
|
|
38
|
+
export const ADDED_MODELS = [
|
|
39
|
+
{ provider: "openrouter", id: "baidu/ernie-5.5-flash-preview:free", like: "inclusionai/ling-3.1-flash", name: "Baidu: ERNIE 5.5 Flash Preview (free)", input: ["text"], contextWindow: 1_024_000, maxTokens: 921_600, mustReason: true },
|
|
40
|
+
{ provider: "openrouter", id: "inclusionai/ling-3.2-flash:free", like: "inclusionai/ling-3.1-flash", name: "inclusionAI: Ling 3.2 Flash (free)", input: ["text"], contextWindow: 1_048_576, maxTokens: 262_144, mustReason: false },
|
|
41
|
+
];
|
|
42
|
+
/** `list` with ADDED_MODELS appended, each built on its `like` entry in `list` (one whose `like` the list lacks is left
|
|
43
|
+
* out) and never twice: once pi-ai lists an id itself, its own entry stands. */
|
|
44
|
+
const added = (list, adds) => [
|
|
45
|
+
...list,
|
|
46
|
+
...adds.flatMap(({ id, like, name, input, contextWindow, maxTokens, mustReason }) => {
|
|
47
|
+
const base = list.find((model) => model.id === like);
|
|
48
|
+
if (!base || list.some((model) => model.id === id))
|
|
49
|
+
return [];
|
|
50
|
+
const { toolsAs: _base, ...rest } = base;
|
|
51
|
+
const levels = rest.thinkingLevelMap;
|
|
52
|
+
return [{ ...rest, id, name, input: [...input], contextWindow, maxTokens, cost: { ...ZERO }, ...(mustReason ? { reasoning: true, thinkingLevelMap: { ...levels, off: null } } : {}) }];
|
|
53
|
+
}),
|
|
54
|
+
];
|
|
55
|
+
/** Whether `provider`/`id` is one of OpenRouter's routers, each of which picks a model per request (the kernel cap's
|
|
56
|
+
* ROUTERS, the one list). OpenRouter lists the price of `auto`, `openrouter/auto*`, `openrouter/fusion`,
|
|
57
|
+
* `openrouter/pareto-code` and `typesafe/jev-router` as -1, the routed model's (read 2026-11-15), which pi-ai's catalog
|
|
58
|
+
* writes as 0; `openrouter/free` routes to a different free model per request. Their zeros say no model's price, so
|
|
59
|
+
* none of them is free: a model serve has no price for, which a cap cannot be kept on and which is never booked at its
|
|
60
|
+
* catalog's $0 (model.ts runModels' `unpriced`). */
|
|
61
|
+
export const isRouter = (provider, id) => provider === "openrouter" && ROUTERS.has(id);
|
|
62
|
+
/** Whether a catalog entry runs at $0: the kernel's freeModel (kernel/cap/free.ts, the one rule, what a run on it books
|
|
63
|
+
* at $0) on the entry's price, its tiers included. An entry with no cost has no price, so is not free. */
|
|
64
|
+
export function isFree(model) {
|
|
65
|
+
return freeModel({ id: model.id, api: model.api ?? "", price: model.cost ?? null, outputCeiling: null });
|
|
66
|
+
}
|
|
67
|
+
/** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries and
|
|
68
|
+
* ADDED_MODELS listed beside them, in place: a request, a price and a capability read find the catalog's entry at the
|
|
69
|
+
* overridden price, with its toolsAs, and an added model as if the catalog listed it. */
|
|
27
70
|
export function withLocalModels(models) {
|
|
28
|
-
for (const providerId of new Set(PRICE_OVERRIDES.map((entry) => entry.provider))) {
|
|
71
|
+
for (const providerId of new Set([...PRICE_OVERRIDES, ...ADDED_MODELS].map((entry) => entry.provider))) {
|
|
29
72
|
const own = models.getProvider(providerId);
|
|
30
73
|
if (!own)
|
|
31
74
|
continue;
|
|
32
75
|
const overrides = PRICE_OVERRIDES.filter((entry) => entry.provider === providerId);
|
|
76
|
+
const adds = ADDED_MODELS.filter((entry) => entry.provider === providerId);
|
|
33
77
|
const listed = Object.assign(Object.create(own), {
|
|
34
|
-
getModels: () => priced(own.getModels(), overrides),
|
|
35
|
-
...(own.getAllModels ? { getAllModels: () => priced(own.getAllModels(), overrides) } : {}),
|
|
78
|
+
getModels: () => added(priced(own.getModels(), overrides), adds),
|
|
79
|
+
...(own.getAllModels ? { getAllModels: () => added(priced(own.getAllModels(), overrides), adds) } : {}),
|
|
36
80
|
});
|
|
37
81
|
models.setProvider(listed);
|
|
38
82
|
}
|
package/dist/mcp-pin-first.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
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
7
|
// per-run pin (mcp_pins, dropped at the upgrade): the revision's pin is the one every run of it reads.
|
|
8
8
|
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { nativeOf } from "./native/binding.js";
|
|
10
|
+
import { sdkOf } from "./sdk/runs.js";
|
|
9
11
|
import { mcpPinOf } from "./mcp-gateway.js";
|
|
10
12
|
import { boundTool } from "./mcp-probe.js";
|
|
11
13
|
import { mcpServersOverStore } from "./mcp-servers-store.js";
|
|
@@ -18,6 +20,10 @@ import { GITHUB_UNUSABLE } from "./runner/mcp-github.js";
|
|
|
18
20
|
* pin of the other servers alone would stand for good, its missing tool never pinned), and the run is refused in the
|
|
19
21
|
* words it was (server.ts runnable at a start, the claim's own at a claim). */
|
|
20
22
|
export async function pinFirst(revision, deps) {
|
|
23
|
+
// Native source MCP names and SDK callback tools belong to their source, never this server's managed registry.
|
|
24
|
+
// Their runnable guards must refuse managed execution without listing or pinning those names first.
|
|
25
|
+
if (nativeOf(revision.body) || sdkOf(revision.body))
|
|
26
|
+
return undefined;
|
|
21
27
|
if (revision.mcpPin !== undefined && revision.mcpPin !== null)
|
|
22
28
|
return revision.mcpPin;
|
|
23
29
|
if (revision.kind !== "agentic")
|
|
@@ -65,4 +65,7 @@ registerSecretWrite("previewMcpServer", () => false);
|
|
|
65
65
|
// whatever the body (the listing sends the key too, and only the session may type one).
|
|
66
66
|
registerSecretWrite("listComposioTools", () => true);
|
|
67
67
|
registerSecretWrite("saveComposioServer", () => true);
|
|
68
|
+
// A Composio server's webhook subscription (composio-triggers.ts): a rotate seals its new secret, a delete drops it.
|
|
69
|
+
registerSecretWrite("rotateComposioSecret", () => true);
|
|
70
|
+
registerSecretWrite("deleteComposioSubscription", () => true);
|
|
68
71
|
registerNotSecretWrite("refreshMcpServer", "A refresh lists the saved server's tools again with its sealed credential, and writes no credential.");
|
|
@@ -106,15 +106,15 @@ export declare class McpServersOverStore {
|
|
|
106
106
|
headers?: string[] | undefined;
|
|
107
107
|
type: string;
|
|
108
108
|
};
|
|
109
|
-
credential: "
|
|
109
|
+
credential: "sealed" | "expired" | "unreadable" | null;
|
|
110
110
|
not_metered?: string[] | undefined;
|
|
111
111
|
tools: {
|
|
112
112
|
grant_problems?: Record<string, string>;
|
|
113
|
-
default_permission: "
|
|
114
|
-
permissions: ("
|
|
113
|
+
default_permission: "allow" | "ask" | "deny";
|
|
114
|
+
permissions: ("allow" | "ask" | "deny")[];
|
|
115
115
|
fallback_allow_reads?: true | undefined;
|
|
116
116
|
allow_reads?: true | undefined;
|
|
117
|
-
permission: "
|
|
117
|
+
permission: "allow" | "ask" | "deny";
|
|
118
118
|
effect: import("./tool-gate.js").ToolEffect;
|
|
119
119
|
name: string;
|
|
120
120
|
title?: string;
|
|
@@ -147,15 +147,15 @@ export declare class McpServersOverStore {
|
|
|
147
147
|
headers?: string[] | undefined;
|
|
148
148
|
type: string;
|
|
149
149
|
};
|
|
150
|
-
credential: "
|
|
150
|
+
credential: "sealed" | "expired" | "unreadable" | null;
|
|
151
151
|
not_metered?: string[] | undefined;
|
|
152
152
|
tools: {
|
|
153
153
|
grant_problems?: Record<string, string>;
|
|
154
|
-
default_permission: "
|
|
155
|
-
permissions: ("
|
|
154
|
+
default_permission: "allow" | "ask" | "deny";
|
|
155
|
+
permissions: ("allow" | "ask" | "deny")[];
|
|
156
156
|
fallback_allow_reads?: true | undefined;
|
|
157
157
|
allow_reads?: true | undefined;
|
|
158
|
-
permission: "
|
|
158
|
+
permission: "allow" | "ask" | "deny";
|
|
159
159
|
effect: import("./tool-gate.js").ToolEffect;
|
|
160
160
|
name: string;
|
|
161
161
|
title?: string;
|
|
@@ -210,15 +210,15 @@ export declare class McpServersOverStore {
|
|
|
210
210
|
headers?: string[] | undefined;
|
|
211
211
|
type: string;
|
|
212
212
|
};
|
|
213
|
-
credential: "
|
|
213
|
+
credential: "sealed" | "expired" | "unreadable" | null;
|
|
214
214
|
not_metered?: string[] | undefined;
|
|
215
215
|
tools: {
|
|
216
216
|
grant_problems?: Record<string, string>;
|
|
217
|
-
default_permission: "
|
|
218
|
-
permissions: ("
|
|
217
|
+
default_permission: "allow" | "ask" | "deny";
|
|
218
|
+
permissions: ("allow" | "ask" | "deny")[];
|
|
219
219
|
fallback_allow_reads?: true | undefined;
|
|
220
220
|
allow_reads?: true | undefined;
|
|
221
|
-
permission: "
|
|
221
|
+
permission: "allow" | "ask" | "deny";
|
|
222
222
|
effect: import("./tool-gate.js").ToolEffect;
|
|
223
223
|
name: string;
|
|
224
224
|
title?: string;
|
|
@@ -255,15 +255,15 @@ export declare class McpServersOverStore {
|
|
|
255
255
|
headers?: string[] | undefined;
|
|
256
256
|
type: string;
|
|
257
257
|
};
|
|
258
|
-
credential: "
|
|
258
|
+
credential: "sealed" | "expired" | "unreadable" | null;
|
|
259
259
|
not_metered?: string[] | undefined;
|
|
260
260
|
tools: {
|
|
261
261
|
grant_problems?: Record<string, string>;
|
|
262
|
-
default_permission: "
|
|
263
|
-
permissions: ("
|
|
262
|
+
default_permission: "allow" | "ask" | "deny";
|
|
263
|
+
permissions: ("allow" | "ask" | "deny")[];
|
|
264
264
|
fallback_allow_reads?: true | undefined;
|
|
265
265
|
allow_reads?: true | undefined;
|
|
266
|
-
permission: "
|
|
266
|
+
permission: "allow" | "ask" | "deny";
|
|
267
267
|
effect: import("./tool-gate.js").ToolEffect;
|
|
268
268
|
name: string;
|
|
269
269
|
title?: string;
|
|
@@ -319,6 +319,15 @@ export declare class McpServersOverStore {
|
|
|
319
319
|
/** The saved OAuth token set of `row` (the row read and checked, as opened), for a sign-in again that reuses the kept
|
|
320
320
|
* client. */
|
|
321
321
|
private openedSet;
|
|
322
|
+
/** A saved Composio preset server's key (its sealed x-api-key), the Composio user its address names (`user_id`, the
|
|
323
|
+
* preset's default when none) and its toolkit: what its Composio triggers are made with (composio-triggers.ts). Refused
|
|
324
|
+
* when `name` is no such server: on the trigger's `source.server` at its create (`field`), as a 404 on the server's own
|
|
325
|
+
* routes (`route`). The key goes only to Composio. */
|
|
326
|
+
composioOf(name: string, refusal: "field" | "route"): Promise<{
|
|
327
|
+
key: string;
|
|
328
|
+
user: string;
|
|
329
|
+
toolkit: string;
|
|
330
|
+
}>;
|
|
322
331
|
/** What the saved server `row` is, for a template's apply to match (mcp-sources.ts sourceOf): github on the GitHub App's
|
|
323
332
|
* tokens, else its record, else url with none. */
|
|
324
333
|
sourceOf(row: RecordedRow & {
|
|
@@ -15,7 +15,7 @@ import { checkPrivateHosts, privateOAuthHosts, savePrivateOAuthHosts } from "./m
|
|
|
15
15
|
import { credentialMark } from "./mcp-secret-writes.js";
|
|
16
16
|
import { secretMeta, secretName } from "./secret-writes.js";
|
|
17
17
|
import { dialAt, issuerOf, LOOPBACK, MAX_PENDING, MCP_SETTINGS_PAGE, mcpServerAt, McpSignIns, reasonOf, SIGN_IN_AGAIN, systemNetwork } from "./mcp-oauth.js";
|
|
18
|
-
import { composioServerId } from "./composio-preset.js";
|
|
18
|
+
import { COMPOSIO_USER, composioServerId } from "./composio-preset.js";
|
|
19
19
|
import { mcpSourceKey, recordedForAnother, sourceOf, sourceToWrite, standInGiven, storedSource, toolkitGiven } from "./mcp-sources.js";
|
|
20
20
|
import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
|
|
21
21
|
import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
|
|
@@ -23,7 +23,7 @@ import { serverGate } from "./tool-plane.js";
|
|
|
23
23
|
import { toolEffect } from "./tool-gate.js";
|
|
24
24
|
import { HARNESSES } from "./harness.js";
|
|
25
25
|
import { harnessOf } from "./harness-table.js";
|
|
26
|
-
import {
|
|
26
|
+
import { droppedWords, mcpGrantNameProblem, mcpToolName } from "./tool-names.js";
|
|
27
27
|
import { isObject, unknownFields } from "./validate.js";
|
|
28
28
|
/** How many writes an owner's save or tools refresh makes over a row whose credential a run's refresh keeps changing,
|
|
29
29
|
* each re-applied onto the row read again, before it is refused in words. */
|
|
@@ -533,6 +533,26 @@ export class McpServersOverStore {
|
|
|
533
533
|
const open = openMcpRow(this.sealKey, row);
|
|
534
534
|
return "credential" in open && open.credential.type === "oauth" ? open.credential.set : undefined;
|
|
535
535
|
}
|
|
536
|
+
/** A saved Composio preset server's key (its sealed x-api-key), the Composio user its address names (`user_id`, the
|
|
537
|
+
* preset's default when none) and its toolkit: what its Composio triggers are made with (composio-triggers.ts). Refused
|
|
538
|
+
* when `name` is no such server: on the trigger's `source.server` at its create (`field`), as a 404 on the server's own
|
|
539
|
+
* routes (`route`). The key goes only to Composio. */
|
|
540
|
+
async composioOf(name, refusal) {
|
|
541
|
+
const refuse = (message) => (refusal === "route" ? new ApiError("not_found", message) : invalid([{ field: "source.server", reason: "not_an_option", message }]));
|
|
542
|
+
const row = await this.store.mcp.server(name);
|
|
543
|
+
if (!row)
|
|
544
|
+
throw refusal === "route" ? notFound(name) : refuse(`No MCP server ${name}: save a Composio server in Settings → MCP servers first.`);
|
|
545
|
+
const { source, toolkit } = await this.sourceOf(row);
|
|
546
|
+
if (source !== "composio" || row.auth !== "headers")
|
|
547
|
+
throw refuse(`${name} is not a Composio server: only one saved with Settings → MCP servers → Composio makes Composio triggers.`);
|
|
548
|
+
if (!toolkit)
|
|
549
|
+
throw refuse(`${name} is a Composio server of no toolkit this server can name: save it again with its toolkit's slug.`);
|
|
550
|
+
const { headers } = await this.opened(name, row, refusal === "field" ? "source.server" : "api_key");
|
|
551
|
+
const key = Object.entries(headers).find(([header]) => header.toLowerCase() === "x-api-key")?.[1];
|
|
552
|
+
if (!key)
|
|
553
|
+
throw refuse(`${name}'s saved credential holds no Composio key: save it again with its key.`);
|
|
554
|
+
return { key, user: new URL(row.url).searchParams.get("user_id") || COMPOSIO_USER, toolkit };
|
|
555
|
+
}
|
|
536
556
|
/** What the saved server `row` is, for a template's apply to match (mcp-sources.ts sourceOf): github on the GitHub App's
|
|
537
557
|
* tokens, else its record, else url with none. */
|
|
538
558
|
async sourceOf(row) {
|
|
@@ -622,7 +642,7 @@ function grantProblemsOf(env, server, tool) {
|
|
|
622
642
|
for (const harness of HARNESSES) {
|
|
623
643
|
const dropped = harnessOf(env, harness)?.facts?.schemaProblems?.(`mcp__${server}__${tool.name}`, schema)[0];
|
|
624
644
|
if (dropped)
|
|
625
|
-
problems[harness] =
|
|
645
|
+
problems[harness] = droppedWords(mcpToolName(server, tool.name), harness, dropped);
|
|
626
646
|
}
|
|
627
647
|
}
|
|
628
648
|
return Object.keys(problems).length ? { grant_problems: problems } : {};
|
package/dist/model-form.d.ts
CHANGED
|
@@ -13,6 +13,17 @@ export declare function formOf(env: NodeJS.ProcessEnv, vendor: string, id: strin
|
|
|
13
13
|
* (harness.ts harnessOffers drops those it does not run). Behind serve's gateway every id is the gateway's own string, so
|
|
14
14
|
* the host's tier models stand for what it runs; with the faux model none is offered. */
|
|
15
15
|
export declare function pickerCandidates(env: NodeJS.ProcessEnv, harness: string): string[];
|
|
16
|
+
/** A model a person may pick that runs at $0 (local-models.ts isFree, the kernel's freeModel on its catalog price: all
|
|
17
|
+
* zeros, every tier's too), in the form it takes, with its context window in tokens. */
|
|
18
|
+
export type FreeModel = {
|
|
19
|
+
id: string;
|
|
20
|
+
context_window: number;
|
|
21
|
+
};
|
|
22
|
+
/** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
|
|
23
|
+
* it does not run): OpenRouter's chat models whose catalog price is all zeros (pi-ai's own and serve's ADDED_MODELS), on
|
|
24
|
+
* pi with OpenRouter's key, by id. None for an adapter harness (each runs its own wire's vendor), behind a gateway (its
|
|
25
|
+
* ids are its own) or with the faux model. */
|
|
26
|
+
export declare function freeCandidates(env: NodeJS.ProcessEnv, harness: string): Promise<FreeModel[]>;
|
|
16
27
|
/** The model `given` most likely means, in the form this harness takes, or undefined when none is obvious: the same id
|
|
17
28
|
* with a dot for a dash or the other way, a missing provider, or a name without its `claude-` ("Sonnet 5.5"). */
|
|
18
29
|
export declare function likelyModel(env: NodeJS.ProcessEnv, harness: string, given: string): string | undefined;
|
package/dist/model-form.js
CHANGED
|
@@ -6,6 +6,8 @@ import { ADAPTER_FACTS } from "./adapter-facts.js";
|
|
|
6
6
|
import { FAUX_ENV, MODEL_KEYS } from "./model.js";
|
|
7
7
|
import { openRouterName } from "./provider.js";
|
|
8
8
|
import { WIRES } from "./wires.js";
|
|
9
|
+
import { PLAN_PROVIDER, planOf, signedIn } from "./chatgpt-plan.js";
|
|
10
|
+
import { PLAN_HARNESSES } from "./harness.js";
|
|
9
11
|
/** The current models a person may pick, by vendor, in the vendor's own ids (Anthropic's dashes; OpenRouter's dotted name
|
|
10
12
|
* for the same model is derived, provider.ts openRouterName). The everyday model first: it is the example a refusal gives.
|
|
11
13
|
* A candidate a harness cannot run on this server (one pi-ai's catalog does not list) is dropped before it is served
|
|
@@ -39,7 +41,21 @@ export function pickerCandidates(env, harness) {
|
|
|
39
41
|
if (env.AGENT_MODEL_BASE_URL && facts?.wire !== "anthropic-messages")
|
|
40
42
|
return [...new Set([env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].filter((id) => Boolean(id)))];
|
|
41
43
|
const vendors = vendorsOf(harness);
|
|
42
|
-
|
|
44
|
+
// Signed in to a ChatGPT plan, its models first for a harness that runs on it (`chatgpt/<model-id>`).
|
|
45
|
+
const plan = PLAN_HARNESSES.includes(harness) && signedIn(env) ? (planOf(env)?.models ?? []).map((id) => `${PLAN_PROVIDER}/${id}`) : [];
|
|
46
|
+
return [...plan, ...PICKABLE.filter((p) => vendors.includes(p.vendor)).flatMap((p) => p.ids.map((id) => formOf(env, p.vendor, id)))];
|
|
47
|
+
}
|
|
48
|
+
/** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
|
|
49
|
+
* it does not run): OpenRouter's chat models whose catalog price is all zeros (pi-ai's own and serve's ADDED_MODELS), on
|
|
50
|
+
* pi with OpenRouter's key, by id. None for an adapter harness (each runs its own wire's vendor), behind a gateway (its
|
|
51
|
+
* ids are its own) or with the faux model. */
|
|
52
|
+
export async function freeCandidates(env, harness) {
|
|
53
|
+
if (env[FAUX_ENV] || env.AGENT_MODEL_BASE_URL || !env.OPENROUTER_API_KEY || ADAPTER_FACTS.some((f) => f.id === harness))
|
|
54
|
+
return [];
|
|
55
|
+
const [{ builtinModels }, { withLocalModels, isFree }] = await Promise.all([import("@earendil-works/pi-ai/providers/all"), import("./local-models.js")]);
|
|
56
|
+
return withLocalModels(builtinModels()).getModels("openrouter").filter(isFree)
|
|
57
|
+
.map((model) => ({ id: `openrouter/${model.id}`, context_window: model.contextWindow }))
|
|
58
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
43
59
|
}
|
|
44
60
|
/** A model id with its spelling taken out (case, spaces, dots, dashes), and the provider's segments off. */
|
|
45
61
|
const spelled = (given) => (given.split("/").pop() ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
package/dist/model.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ModelCost } from "@earendil-works/pi-ai";
|
|
2
2
|
import type { Wire } from "@parcha/agentrun-kernel";
|
|
3
|
+
import type { ThinkingLevelMap } from "./port-models.js";
|
|
3
4
|
import { type HarnessEntry } from "./harness-table.js";
|
|
4
5
|
import type { Revision } from "./agent-rows.js";
|
|
5
6
|
/** The child's environment names the faux module by absolute path. */
|
|
@@ -54,6 +55,14 @@ export declare const MODEL_KEYS: readonly {
|
|
|
54
55
|
* starts (MODEL_KEYS' fields), OpenRouter's named first, as its one key runs every harness. The order a default is
|
|
55
56
|
* taken in is MODEL_KEYS' own. */
|
|
56
57
|
export declare const ADD_A_KEY: string;
|
|
58
|
+
/** Whether a ChatGPT sign-in here would give `harness` its model, where it wants a key now: `signed_out` (none yet) or
|
|
59
|
+
* `expired` (sign in again). None where it would not: a harness that needs a key whatever the plan (PLAN_HARNESSES), a
|
|
60
|
+
* server that cannot sign in (a runner, a faux model), one behind serve's gateway (its model is the gateway's), one
|
|
61
|
+
* signed in, or one whose AGENT_MODEL names a key's model the harness runs (hostModel keeps it signed in or not). */
|
|
62
|
+
export declare function planWouldRun(env: NodeJS.ProcessEnv, harness: string): "signed_out" | "expired" | undefined;
|
|
63
|
+
/** `reason`, `harness`'s want of a key for its default model, with what a ChatGPT sign-in here would do about it
|
|
64
|
+
* (planWouldRun), in words; as it was where the sign-in would not. */
|
|
65
|
+
export declare function withPlanWords(env: NodeJS.ProcessEnv, harness: string, reason: string): string;
|
|
57
66
|
/** Whether `harness` runs the model `id` (its entry in the harness table: harness-table.ts): pi any; one on an adapter, its
|
|
58
67
|
* wire's vendor's model (or that vendor's on OpenRouter), or behind serve's gateway, on the wire it serves, any id. */
|
|
59
68
|
export declare const harnessRuns: (env: NodeJS.ProcessEnv, id: string, harness: string) => boolean;
|
|
@@ -65,8 +74,9 @@ export declare const harnessRuns: (env: NodeJS.ProcessEnv, id: string, harness:
|
|
|
65
74
|
export declare function hostModel(env: NodeJS.ProcessEnv, tier?: Tier, harness?: string): string | undefined;
|
|
66
75
|
/** `route_prefix`: the routing prefix this server puts before a gateway's model ids (MODEL_PROVIDER), which a reader takes off
|
|
67
76
|
* to show the gateway's own id; null with any other source. */
|
|
68
|
-
/** The values `models.source` takes here: a faux module, a gateway,
|
|
69
|
-
|
|
77
|
+
/** The values `models.source` takes here: a faux module, a gateway, each provider with its own key, or, with no key, a
|
|
78
|
+
* person's ChatGPT plan signed in here (chatgpt-plan.ts). */
|
|
79
|
+
export declare const MODEL_SOURCES: readonly ["faux", "gateway", "providers", "chatgpt"];
|
|
70
80
|
export type ModelSource = {
|
|
71
81
|
source: (typeof MODEL_SOURCES)[number];
|
|
72
82
|
route_prefix: string | null;
|
|
@@ -150,7 +160,8 @@ export type FauxHelpers = {
|
|
|
150
160
|
/** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
|
|
151
161
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
152
162
|
* The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
|
|
153
|
-
* serve has no price for (a gateway model the catalog does not list, with no price set), which a
|
|
163
|
+
* serve has no price for (a gateway model the catalog does not list, with no price set; an OpenRouter router), which a
|
|
164
|
+
* cap cannot be kept on.
|
|
154
165
|
* `tierRefs`: a model named for another tier (a subagent's model_tiers), chosen for it in place of the host's. */
|
|
155
166
|
export declare function runModels(env: NodeJS.ProcessEnv, ref: string | PinnedModel | undefined, tiers?: readonly Tier[], harness?: string, tierRefs?: Readonly<Partial<Record<Tier, string>>>): Promise<{
|
|
156
167
|
models: import("@earendil-works/pi-ai").MutableModels;
|
|
@@ -187,9 +198,10 @@ export declare function wireModels(entry: HarnessEntry, env: NodeJS.ProcessEnv,
|
|
|
187
198
|
export declare function runModelRef(env: NodeJS.ProcessEnv, revision: Revision): Promise<ModelRef | undefined>;
|
|
188
199
|
/** The models a run of `ref` (an agentic revision's own, else the host's) on `harness` would take, of `tiers`, that serve
|
|
189
200
|
* has no price for here: a gateway's (AGENT_MODEL_BASE_URL) id with no price set and none in the catalog in any form
|
|
190
|
-
* (gatewayPrices)
|
|
201
|
+
* (gatewayPrices), and OpenRouter's routers anywhere (their $0 is no price: routersOf). None else: pi-ai's providers
|
|
202
|
+
* price their own models, a $0 entry included, and a harness on a wire the gateway does not serve
|
|
191
203
|
* (Anthropic's Messages: provider.ts WIRES) prices
|
|
192
|
-
* by its catalog entry. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
|
|
204
|
+
* by its catalog entry, and a ChatGPT plan's model costs no dollars. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
|
|
193
205
|
* run. A model chooseModel cannot give is not this one's to say (its own blocker says why). */
|
|
194
206
|
export declare function unpricedModels(env: NodeJS.ProcessEnv, ref: string | undefined, tiers?: readonly Tier[], harness?: string): Promise<string[]>;
|
|
195
207
|
/** Why `models` (providerModels') send no request on Anthropic's route: ANTHROPIC_BASE_URL is a base a key may not go to,
|
|
@@ -208,9 +220,17 @@ export declare function providerModels(env: NodeJS.ProcessEnv): Promise<import("
|
|
|
208
220
|
export type Listed = {
|
|
209
221
|
provider: string;
|
|
210
222
|
cost: ModelCost;
|
|
223
|
+
thinkingLevelMap?: ThinkingLevelMap;
|
|
211
224
|
};
|
|
212
|
-
/** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order
|
|
225
|
+
/** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order, with the effort each
|
|
226
|
+
* thinking level asks for where the entry says. */
|
|
213
227
|
export declare function catalogPrices(): Promise<Map<string, Listed[]>>;
|
|
228
|
+
/** A gateway model's thinking levels in `catalog` (catalogPrices'), by its own id (the last segment of `id`) in either
|
|
229
|
+
* version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
|
|
230
|
+
* agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
|
|
231
|
+
* pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
|
|
232
|
+
* effort, as its catalog entries say (off: null), not the "none" it refuses. */
|
|
233
|
+
export declare function catalogThinking(catalog: ReadonlyMap<string, readonly Listed[]>, id: string, named: string | undefined): ThinkingLevelMap | undefined;
|
|
214
234
|
/** A gateway model's price in `catalog` (catalogPrices'), by its id as the host or the revision names it: a ref that names
|
|
215
235
|
* its provider (`named`), priced as that provider's entry, whether the id went whole or bare; a host model set whole
|
|
216
236
|
* (`vendor/model`) the catalog does not list as it is, priced as its model, the vendor named; else the id as it is. Each
|