@parcha/agentrun-serve 0.1.0-beta.38 → 0.1.0-beta.39
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 +418 -0
- package/README.md +325 -124
- 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-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -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 +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -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 +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -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 +9 -2
- package/dist/learn/compile.js +52 -16
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +4 -1
- package/dist/learn/promote.d.ts +106 -51
- package/dist/learn/promote.js +82 -189
- 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 +26 -8
- package/dist/learning-cost.js +17 -7
- 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 +33 -2
- package/dist/local-models.js +43 -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 +1 -0
- package/dist/openapi.js +394 -85
- 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 +7 -2
- package/dist/port-models.js +5 -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 +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/run-launch.d.ts +10 -1
- package/dist/run-launch.js +11 -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 +42 -35
- package/dist/run-view.js +79 -44
- package/dist/runnable.d.ts +13 -5
- package/dist/runnable.js +69 -60
- package/dist/runner/adapter-loop.d.ts +42 -11
- package/dist/runner/adapter-loop.js +651 -247
- package/dist/runner/adapter-run-spec.d.ts +37 -12
- package/dist/runner/adapter-run-spec.js +139 -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 +94 -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 +37 -13
- package/dist/runner/journal-kinds.js +9 -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 +12 -3
- package/dist/runner/model-route.js +139 -18
- 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 +74 -8
- package/dist/runner/promotion.js +365 -124
- 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 +554 -130
- 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/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/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.js +3 -0
- package/dist/store/schema.d.ts +7 -0
- package/dist/store/schema.js +20 -1
- 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 +133 -18
- package/dist/store/store.d.ts +52 -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 +85 -5
- package/dist/store-reads/learning.js +45 -17
- 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 +70 -20
- package/dist/templates.js +191 -34
- 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 +42 -42
- package/dist/tool-gate.js +97 -91
- 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 +44 -16
- package/dist/tools.js +28 -28
- package/dist/trigger-adapter.d.ts +85 -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 +228 -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 +94 -9
- package/dist/triggers.js +263 -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/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
|
@@ -27,31 +27,33 @@ import { tmpdir } from "node:os";
|
|
|
27
27
|
import { join } from "node:path";
|
|
28
28
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
29
29
|
import { isMessageRow } from "../timeline/index.js";
|
|
30
|
-
import { bookedCapSpend } from "./metrics.js";
|
|
31
30
|
import { Hearing } from "../heard.js";
|
|
32
31
|
import { readLearning, readSnapshot } from "../learn/folder.js";
|
|
33
32
|
import { compileDue, compilePrompt, compileReference, COMPILE_AFTER_RUNS, COMPILE_QUIET_RUNS, COMPILE_TRACES, heldNamesOf } from "../learn/compile.js";
|
|
34
|
-
import { promotionOf, promotionsOf } from "../learn/promote.js";
|
|
33
|
+
import { promotionOf, promotionsOf, scoreOf } from "../learn/promote.js";
|
|
35
34
|
import { draftDecisionProviders } from "../learn/skills.js";
|
|
36
35
|
import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
|
|
37
36
|
import { handedValuesOf } from "../handed-values.js";
|
|
38
37
|
import { MIN_SECRET, redactSecrets } from "../learn/secrets.js";
|
|
39
38
|
import { LEARNED_WORKFLOW_TOOL } from "../learned-workflow.js";
|
|
39
|
+
import { META_TOOLS } from "../meta-tool-names.js";
|
|
40
40
|
import { holdsSecret, LEARNING_LABEL, PROPOSAL, secretsShown } from "../learning.js";
|
|
41
41
|
import { reflects } from "../reflect-range.js";
|
|
42
42
|
import { said, STOPPED } from "../learning-words.js";
|
|
43
43
|
import { proposeRun } from "../propose.js";
|
|
44
|
-
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
44
|
+
import { learningStartOf, readLaunchBody, seedFailed } from "../run-launch.js";
|
|
45
45
|
import { costOf } from "../run-view.js";
|
|
46
|
-
import { getMcpServer
|
|
46
|
+
import { getMcpServer } from "../mcp-store.js";
|
|
47
47
|
import { readApprovers } from "../server-approvers.js";
|
|
48
48
|
import { runEntries, runReflect, runTimeline, withFeedback, withoutFeedbackRounds } from "../store-reads/journal.js";
|
|
49
49
|
import { capNowOf } from "./journal-kinds.js";
|
|
50
|
+
import { bookedCapSpend, bookedSpend } from "./metrics.js";
|
|
50
51
|
import { fits, reviseOf, servedAnswerOf, servedOf, workflowDigest } from "./workflow-first.js";
|
|
51
52
|
import { pendingFeedbackOf } from "./feedback-round.js";
|
|
52
53
|
import { createReflectHook } from "./reflect-hook.js";
|
|
54
|
+
import { sdkDraftTools } from "../sdk/workflows.js";
|
|
53
55
|
import { runnerSecrets } from "./redact.js";
|
|
54
|
-
import {
|
|
56
|
+
import { mcpNameOf } from "../tool-names.js";
|
|
55
57
|
/** The end-of-run step for a run launched with `launch`: undefined when its launch records no learning start (a run that
|
|
56
58
|
* does not learn is asked nothing and keeps nothing), else the reflect hook over the run's store. */
|
|
57
59
|
export function learningEndOfRun(launch, deps) {
|
|
@@ -73,10 +75,22 @@ export function learningEndOfRun(launch, deps) {
|
|
|
73
75
|
// rounds' grades took beside it counts toward that cap as its own spend does (Learning.spentBeside, the figure its
|
|
74
76
|
// gates read). Either unknown: the spend is unknown, said so, never read as the whole cap.
|
|
75
77
|
facts: async (runId) => {
|
|
76
|
-
const
|
|
78
|
+
const [rows, entries] = await Promise.all([
|
|
79
|
+
runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false }),
|
|
80
|
+
runEntries(deps.store, runId, BACKGROUND_CONTEXT),
|
|
81
|
+
]);
|
|
82
|
+
// A pi retry's Timeline carries the answered requests alone. Its earlier cut request is still an unknown charge
|
|
83
|
+
// in the booking: keep it unknown in the task snapshot too, as the run's end does, never just the retry's subtotal.
|
|
84
|
+
// A request a crash cut booked at its hold (`bounded`) is an upper bound, not a spend: the job's and look-back's
|
|
85
|
+
// figures say no "at most", so they stay unknown, as the run's stored cost reads once it ends (RunRow.costUsd null,
|
|
86
|
+
// the bound apart in costAtMostUsd). This reads the booking before the run's row has a cost, hence its own check.
|
|
87
|
+
const unknown = ["model", "paid", "decisions"].some((kind) => {
|
|
88
|
+
const spend = bookedSpend(entries, kind);
|
|
89
|
+
return spend.usd === null || spend.bounded > 0;
|
|
90
|
+
});
|
|
91
|
+
const costUsd = unknown ? null : costOf(rows);
|
|
77
92
|
if (launch.maxCostUsd === undefined)
|
|
78
93
|
return { learns: true, costUsd };
|
|
79
|
-
const entries = await runEntries(deps.store, runId, BACKGROUND_CONTEXT);
|
|
80
94
|
const capUsd = capNowOf(launch.maxCostUsd, entries);
|
|
81
95
|
const spentUsd = await capSpendOf(deps.store, runId, entries);
|
|
82
96
|
return { learns: true, costUsd, capUsd, spentUsd, capReached: spentUsd !== null && spentUsd >= capUsd };
|
|
@@ -202,6 +216,13 @@ export const learningRunIdOf = (runId, round = 1) => (round > 1 ? `${runId}-lear
|
|
|
202
216
|
/** learned_workflow by every name a harness calls it: its own, and claude-agent's host-tool alias (`mcp__hands__<name>`).
|
|
203
217
|
* A harness that names it another way reads as another tool, so its run is asked as before. */
|
|
204
218
|
export const LEARNED_NAMES = new Set([LEARNED_WORKFLOW_TOOL, `mcp__hands__${LEARNED_WORKFLOW_TOOL}`]);
|
|
219
|
+
/** Over a run's timeline `rows`: whether a row is a call the job's model made, or its result: one at the top, or one a
|
|
220
|
+
* script or tools_call made for it (a call nested in a META_TOOLS call, by any harness's name for it), never a
|
|
221
|
+
* subagent's row or a call another tool nested (a learned workflow's own). */
|
|
222
|
+
export function modelsOwn(rows) {
|
|
223
|
+
const named = new Map(rows.flatMap((row) => (row.kind === "tool_use" && row.tool_use_id ? [[row.tool_use_id, row.tool_name ?? ""]] : [])));
|
|
224
|
+
return (row) => !row.parent_tool_use_id || META_TOOLS.has((named.get(row.parent_tool_use_id) ?? "").replace(/^(?:mcp__hands__|hands_)/, ""));
|
|
225
|
+
}
|
|
205
226
|
/** Whether a run's job, by its timeline `rows` (the end-of-run turn's own, labelled LEARNING_LABEL, left out), gave
|
|
206
227
|
* nothing new to look back on: it called tools, every one of them learned_workflow (a workflow's own nested calls are
|
|
207
228
|
* its), each answering; no tool result failed or was refused; no error, approval or wait; and one message, its first,
|
|
@@ -213,13 +234,14 @@ export function onlyLearnedWorkflows(rows) {
|
|
|
213
234
|
return false;
|
|
214
235
|
if (own.filter(isMessageRow).length !== 1)
|
|
215
236
|
return false;
|
|
216
|
-
const
|
|
237
|
+
const models = modelsOwn(own);
|
|
238
|
+
const calls = own.filter((row) => row.kind === "tool_use" && models(row));
|
|
217
239
|
if (!calls.length || calls.some((row) => !LEARNED_NAMES.has(row.tool_name ?? "")))
|
|
218
240
|
return false;
|
|
219
241
|
const results = own.filter((row) => row.kind === "tool_result");
|
|
220
242
|
if (results.some((row) => row.tool_status !== "success"))
|
|
221
243
|
return false;
|
|
222
|
-
const answered = new Set(results.filter(
|
|
244
|
+
const answered = new Set(results.filter(models).map((row) => row.tool_use_id));
|
|
223
245
|
return calls.every((row) => answered.has(row.tool_use_id));
|
|
224
246
|
}
|
|
225
247
|
/** The path a run took (learning-cost.ts RunPath), by its timeline `rows` as runTimeline labels them (its end-of-run
|
|
@@ -227,7 +249,8 @@ export function onlyLearnedWorkflows(rows) {
|
|
|
227
249
|
* onlyLearnedWorkflows asks of a run with nothing new to look back on, `handed_back` when it called a learned workflow
|
|
228
250
|
* otherwise, `agent` when it called none. */
|
|
229
251
|
export function runPathOf(rows) {
|
|
230
|
-
const
|
|
252
|
+
const models = modelsOwn(rows);
|
|
253
|
+
const ran = rows.some((row) => row.agent_label !== LEARNING_LABEL && row.kind === "tool_use" && models(row) && LEARNED_NAMES.has(row.tool_name ?? ""));
|
|
231
254
|
if (!ran)
|
|
232
255
|
return "agent";
|
|
233
256
|
return onlyLearnedWorkflows(rows) ? "workflow" : "handed_back";
|
|
@@ -245,7 +268,7 @@ export function workflowNameOf(calls) {
|
|
|
245
268
|
/** Why each draft of `proposal` waits for its owner's OK whatever the grade: its steps calling an MCP tool with no
|
|
246
269
|
* declared price (skills.ts unpricedCalls), by its workflow.json's path, from the prices each server's row keeps
|
|
247
270
|
* (mcp-probe.ts McpPrices). A server the store can't read gives no price: held. */
|
|
248
|
-
async function heldOf(store, proposal) {
|
|
271
|
+
async function heldOf(store, proposal, manifest) {
|
|
249
272
|
const files = (proposal?.files ?? []).filter((one) => typeof one?.file === "string" && one.file.endsWith("/workflow.json") && typeof one.text === "string");
|
|
250
273
|
const { draftMcpTools, unpricedCalls, unpricedLine } = await import("../learn/skills.js");
|
|
251
274
|
const rows = new Map();
|
|
@@ -262,6 +285,10 @@ async function heldOf(store, proposal) {
|
|
|
262
285
|
// Every MCP tool its call nodes run, as the workflow's own read reads them (draftMcpTools over the parsed JSON: an
|
|
263
286
|
// escaped "\/" is a slash there), its price read first (unpricedCalls asks synchronously).
|
|
264
287
|
for (const name of draftMcpTools(doc)) {
|
|
288
|
+
if (manifest) {
|
|
289
|
+
priced.set(name, manifest.find((tool) => tool.name === name)?.price_usd);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
265
292
|
const { server, tool } = mcpNameOf(name);
|
|
266
293
|
if (!rows.has(server))
|
|
267
294
|
rows.set(server, getMcpServer(store, server).catch(() => undefined));
|
|
@@ -274,12 +301,9 @@ async function heldOf(store, proposal) {
|
|
|
274
301
|
}
|
|
275
302
|
return held;
|
|
276
303
|
}
|
|
277
|
-
/** The
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const rows = await listMcpServers(store).catch(() => []);
|
|
281
|
-
const byName = new Map(rows.map((row) => [row.name, (row.tools ?? []).flatMap((tool) => (typeof tool?.name === "string" ? [tool.name] : []))]));
|
|
282
|
-
return (server) => byName.get(server) ?? [];
|
|
304
|
+
/** The backend manifest is data describing existing callbacks, not a server MCP connection. */
|
|
305
|
+
function sdkDescribed(manifest) {
|
|
306
|
+
return manifest.map((tool) => ({ name: tool.name, does: `${tool.description}. Takes ${JSON.stringify(tool.input_schema)}.${tool.output_schema ? ` Gives ${JSON.stringify(tool.output_schema)}.` : ""}` }));
|
|
283
307
|
}
|
|
284
308
|
/** What each of `tools` takes and gives a workflow's call node, in the server's own words for it (tools.ts ToolEntry's
|
|
285
309
|
* summary): the draft ask's `describe`. An MCP tool (`mcp:<server>/<tool>`, LS-07) is described by its server's listing
|
|
@@ -332,7 +356,8 @@ export function traceFrom(timeline, refuse) {
|
|
|
332
356
|
const cut = (text) => redactSecrets(String(text ?? ""), refuse, Number.POSITIVE_INFINITY).replace(/\s+/g, " ").trim().slice(0, TRACE_TEXT);
|
|
333
357
|
const messages = rows.filter(isMessageRow);
|
|
334
358
|
const failed = new Set(rows.filter((row) => row.kind === "tool_result" && row.tool_status === "failed").map((row) => row.tool_use_id));
|
|
335
|
-
const
|
|
359
|
+
const models = modelsOwn(rows);
|
|
360
|
+
const calls = rows.filter((row) => row.kind === "tool_use" && models(row)).slice(0, TRACE_CALLS).map((row) => ({ tool: cut(row.tool_name), input: cut(row.tool_input_preview), ...(failed.has(row.tool_use_id) ? { failed: true } : {}) }));
|
|
336
361
|
const answer = rows.findLast((row) => row.kind === "final_answer")?.text;
|
|
337
362
|
const first = messages[0];
|
|
338
363
|
return { input: first ? cut(first.text ?? first.summary) : "", calls, answer: cut(answer), feedback: messages.slice(1).filter((row) => row.kind === "user_message").map((row) => cut(row.text ?? row.summary)) };
|
|
@@ -464,7 +489,7 @@ export async function compileAskOf(deps, input) {
|
|
|
464
489
|
if (!kept || kept.some((one) => !(one.createdAt < since) && compiledOf(one)?.workflow === read.held.workflow))
|
|
465
490
|
return sayLeftOut(), undefined;
|
|
466
491
|
const { workflow, digest, source, reason, replay } = read.held;
|
|
467
|
-
held = { workflow, digest, source, reason, ...(replay ? { replay:
|
|
492
|
+
held = { workflow, digest, source, reason, ...(replay ? { replay: scoreOf(replay) } : {}) };
|
|
468
493
|
revising = workflow;
|
|
469
494
|
}
|
|
470
495
|
if (!revising && !dueWith(read.notes.length, read.workflows))
|
|
@@ -479,16 +504,17 @@ export async function compileAskOf(deps, input) {
|
|
|
479
504
|
leftOut.traces += 1;
|
|
480
505
|
return false;
|
|
481
506
|
});
|
|
482
|
-
const { tools, decisions, outputSchema } = await draftTools(deps, input.runId);
|
|
507
|
+
const { tools, decisions, outputSchema, workflowAdapters, described: sdkCatalog } = await draftTools(deps, input.runId);
|
|
483
508
|
const allowed = draftDecisionProviders(decisions);
|
|
484
|
-
const judges = allowed.length > 0;
|
|
509
|
+
const judges = workflowAdapters !== undefined ? workflowAdapters.includes("runJudge") : allowed.length > 0;
|
|
485
510
|
// Jev by default: a run that can call Jev (a decision provider its gate does not deny) asks every step for a guard it reads.
|
|
486
|
-
const jev = allowed.includes("jev");
|
|
487
|
-
const described = await describedOf(tools, deps.store);
|
|
511
|
+
const jev = workflowAdapters === undefined && allowed.includes("jev");
|
|
512
|
+
const described = sdkCatalog ?? await describedOf(tools, deps.store);
|
|
488
513
|
const object = input.input !== null && typeof input.input === "object" && !Array.isArray(input.input);
|
|
489
514
|
leftOut.input = object && holds(input.input);
|
|
490
515
|
const fields = object && !leftOut.input ? { input: input.input } : {};
|
|
491
|
-
const
|
|
516
|
+
const bridge = workflowAdapters !== undefined ? { workflowAdapters } : {};
|
|
517
|
+
const base = { ...bridge, reference: compileReference(dsl, { tools, judges, jev, ...bridge }), notes: read.notes, traces, tools, described, judges, jev, ...fields, ...(outputSchema !== undefined ? { outputSchema } : {}) };
|
|
492
518
|
// A wrong grade of the answer its workflow gave alone: that answer and the grade's words, cut of the runner's secrets.
|
|
493
519
|
const cut = (text) => redactSecrets(text, input.refuse, Number.POSITIVE_INFINITY);
|
|
494
520
|
const graded = revising && gradedOf && fed ? { answer: cut(servedAnswerOf(entries)?.answer ?? ""), words: cut(fed.text) } : undefined;
|
|
@@ -507,29 +533,32 @@ export async function compileAskOf(deps, input) {
|
|
|
507
533
|
* with the server's settings (from the store) and the agent's; none for a workflow revision. */
|
|
508
534
|
async function draftTools(deps, runId) {
|
|
509
535
|
const run = await deps.store.runs.get(runId);
|
|
536
|
+
const launch = run ? readLaunchBody((await deps.store.runs.launch(runId)).body) : undefined;
|
|
510
537
|
const revision = run ? await deps.store.agents.revision(run.revisionId) : undefined;
|
|
511
538
|
if (revision?.kind !== "agentic")
|
|
512
|
-
return { tools: [], gated: {}, deniedBy: {}
|
|
539
|
+
return { tools: [], gated: {}, deniedBy: {} };
|
|
513
540
|
const body = revision.body;
|
|
514
541
|
// The agent's output schema, which a learned workflow's answer is served shaped to (answer-json.ts answerAsServed): the
|
|
515
542
|
// compile turn is told it and a draft's dry run holds its answer to it.
|
|
516
543
|
const shaped = body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {};
|
|
517
|
-
|
|
544
|
+
if (launch?.sdk?.workflow_tools) {
|
|
545
|
+
const catalog = sdkDraftTools(launch.sdk.workflow_tools);
|
|
546
|
+
return { ...catalog, ...shaped, workflowAdapters: launch.sdk.workflow_adapters ?? [], described: sdkDescribed(launch.sdk.workflow_tools.filter(tool => catalog.tools.includes(tool.name))) };
|
|
547
|
+
}
|
|
548
|
+
const [{ learnedDraftTools }, { permissionFrom }, { loadToolSettings }] = await Promise.all([import("../tools.js"), import("../tool-gate.js"), import("../tool-plane.js")]);
|
|
518
549
|
// The server's settings from the one store, as the run's gate reads them: a stored row that does not read carries
|
|
519
550
|
// SETTINGS_UNREAD, which permissionFrom honours (no ask is lifted over a deny the row may hold).
|
|
520
551
|
const server = (await loadToolSettings(deps.store)).settings;
|
|
521
552
|
const agent = (body.toolSettings ?? {});
|
|
522
553
|
const approvals = body.approvals === "never" ? "never" : "ask";
|
|
523
|
-
// A server's wildcard grant read as the tools its server lists now (tools.ts mcpGrantsListed, LS-07).
|
|
524
|
-
const granted = (body.tools ?? []).some(isMcpWildcard) ? mcpGrantsListed(body.tools ?? [], await mcpListedOf(deps.store)) : (body.tools ?? []);
|
|
525
554
|
// `deniedBy`: where each deny was set (the agent's tool settings, the server's, a default), which a left-out draft's
|
|
526
555
|
// words name.
|
|
527
|
-
const { tools, gated, deniedBy
|
|
556
|
+
const { tools, gated, deniedBy } = learnedDraftTools(body.tools ?? [], (name) => permissionFrom(name, server, agent, approvals).permission, undefined, (name) => permissionFrom(name, server, agent, approvals).from, { mcp: true, approvers: await readApprovers(deps.store.settings) });
|
|
528
557
|
// A draft's decision nodes (LS-07): the host's decision providers, each held to the gate by its bare id as the run's
|
|
529
558
|
// gate holds it (tool-plane.ts DECISION_PROVIDER_KEYS); deny alone refuses one.
|
|
530
559
|
const providers = await deps.decisionProviders?.();
|
|
531
560
|
if (!providers)
|
|
532
|
-
return { tools, gated, deniedBy,
|
|
561
|
+
return { tools, gated, deniedBy, ...shaped };
|
|
533
562
|
const decided = {};
|
|
534
563
|
const decisionDeniedBy = {};
|
|
535
564
|
for (const id of DECISION_PROVIDER_KEYS) {
|
|
@@ -540,7 +569,7 @@ async function draftTools(deps, runId) {
|
|
|
540
569
|
if (permission === "deny")
|
|
541
570
|
decisionDeniedBy[id] = from;
|
|
542
571
|
}
|
|
543
|
-
return { tools, gated, deniedBy,
|
|
572
|
+
return { tools, gated, deniedBy, decisions: { providers: providers.providers, default: providers.default, gated: decided, deniedBy: decisionDeniedBy }, ...shaped };
|
|
544
573
|
}
|
|
545
574
|
/** The commit main of the agent's learning folder is at now; none for a folder with no main yet. */
|
|
546
575
|
async function mainOf(deps, agentId) {
|
|
@@ -558,14 +587,13 @@ async function mainOf(deps, agentId) {
|
|
|
558
587
|
async function checkedOf(deps, input) {
|
|
559
588
|
const runDir = await mkdtemp(join(tmpdir(), "agentrun-learning-end-"));
|
|
560
589
|
try {
|
|
561
|
-
const { tools, gated, deniedBy,
|
|
562
|
-
|
|
563
|
-
const { learnedAskFits } = await import("../learned-workflow.js");
|
|
590
|
+
const { tools, gated, deniedBy, decisions, outputSchema } = await draftTools(deps, input.runId);
|
|
591
|
+
const sdk = readLaunchBody((await deps.store.runs.launch(input.runId)).body)?.sdk;
|
|
564
592
|
const turn = { answer: input.turn.answer, asked: [...input.turn.asked], ...(input.turn.triggered?.length ? { triggered: input.turn.triggered.map((one) => ({ ...one })) } : {}) };
|
|
565
593
|
const folder = deps.learningFolder(input.agentId);
|
|
566
594
|
let proposed;
|
|
567
595
|
try {
|
|
568
|
-
proposed = await proposeRun({ folder: folder.workspace, runDir, seed: input.seed, ...(input.notesSeed ? { notesSeed: input.notesSeed } : {}), ...(input.revised ? { revised: input.revised } : {}), turn, refuse: input.refuse, outcome: input.outcome, tools, ...(Object.keys(gated).length ? { gated } : {}), ...(Object.keys(deniedBy).length ? { deniedBy } : {}),
|
|
596
|
+
proposed = await proposeRun({ ...(sdk?.workflow_tools ? { workflowAdapters: sdk.workflow_adapters ?? [] } : {}), folder: folder.workspace, runDir, seed: input.seed, ...(input.notesSeed ? { notesSeed: input.notesSeed } : {}), ...(input.revised ? { revised: input.revised } : {}), turn, refuse: input.refuse, outcome: input.outcome, tools, ...(Object.keys(gated).length ? { gated } : {}), ...(Object.keys(deniedBy).length ? { deniedBy } : {}), ...(decisions ? { decisions } : {}), ...(input.workflows === false ? { workflows: false } : {}), ...(outputSchema !== undefined ? { outputSchema } : {}) });
|
|
569
597
|
}
|
|
570
598
|
finally {
|
|
571
599
|
await folder.end();
|
|
@@ -575,7 +603,7 @@ async function checkedOf(deps, input) {
|
|
|
575
603
|
const proposal = JSON.parse(await readFile(join(runDir, PROPOSAL), "utf8"));
|
|
576
604
|
// A draft calling an MCP tool with no declared price waits for its owner's OK whatever the grade (LS-07): held here,
|
|
577
605
|
// from the prices the store keeps now, and said to the grader.
|
|
578
|
-
const held = await heldOf(deps.store, proposal);
|
|
606
|
+
const held = await heldOf(deps.store, proposal, sdk?.workflow_tools);
|
|
579
607
|
return { ...proposed, proposal: Object.keys(held).length ? { ...proposal, held } : proposal };
|
|
580
608
|
}
|
|
581
609
|
finally {
|
|
@@ -7,6 +7,9 @@ export interface LearningFactoryDeps extends Pick<LearningLoopDeps, "ask" | "now
|
|
|
7
7
|
readonly store: Pick<Store, "runs" | "agents" | "learning">;
|
|
8
8
|
/** The server's data directory: where each agent's learning folder is. */
|
|
9
9
|
readonly data: string;
|
|
10
|
+
/** Optional immutable source-run policy snapshot (native jobs). This is quoted as task policy data by gradePrompt,
|
|
11
|
+
* never installed as the grader's own native instructions. */
|
|
12
|
+
readonly sourceInstructions?: (runId: string) => Promise<string>;
|
|
10
13
|
/** Where the folder's script says what it did (learningWorkspace's log). */
|
|
11
14
|
readonly log?: (line: string) => void;
|
|
12
15
|
}
|
|
@@ -28,9 +28,15 @@ export function learningLoopFactory(deps) {
|
|
|
28
28
|
const source = await store.runs.get(runId);
|
|
29
29
|
if (!source)
|
|
30
30
|
return undefined;
|
|
31
|
-
const instructions = objectOf((await store.agents.revision(source.revisionId))?.body).instructions;
|
|
32
31
|
const round = Number.isSafeInteger(input.round) && input.round > 1 ? { round: input.round } : {};
|
|
33
|
-
|
|
32
|
+
let instructions;
|
|
33
|
+
try {
|
|
34
|
+
instructions = deps.sourceInstructions ? await deps.sourceInstructions(runId) : objectOf((await store.agents.revision(source.revisionId))?.body).instructions;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return { runId, ...round, agentId: source.agentId, policyError: error instanceof Error ? error.message : String(error) };
|
|
38
|
+
}
|
|
39
|
+
return { runId, ...round, agentId: source.agentId, ...(typeof instructions === "string" ? { instructions } : {}), ...(deps.sourceInstructions ? { nativeInstructions: true } : {}) };
|
|
34
40
|
},
|
|
35
41
|
proposal: (runId, round) => store.learning.proposal(runId, round),
|
|
36
42
|
ask: deps.ask,
|
|
@@ -147,6 +147,8 @@ export interface LearningLoopDeps {
|
|
|
147
147
|
readonly round?: number;
|
|
148
148
|
readonly agentId: string;
|
|
149
149
|
readonly instructions?: string;
|
|
150
|
+
readonly policyError?: string;
|
|
151
|
+
readonly nativeInstructions?: true;
|
|
150
152
|
} | undefined>;
|
|
151
153
|
/** Its kept proposal of that round (store.learning.proposal). */
|
|
152
154
|
proposal(runId: string, round: number): Promise<LearningProposal | undefined>;
|
|
@@ -308,6 +308,10 @@ export function createLearningLoop(learning) {
|
|
|
308
308
|
await append(KINDS.learningDropped, { source: "", reason: "no_source", detail: said.stopped(STOPPED.notChecked) }, "failed");
|
|
309
309
|
return { state: "failed", error: { code: "learning_no_source", message: "the learning run names no run that learned" } };
|
|
310
310
|
}
|
|
311
|
+
if (source.policyError) {
|
|
312
|
+
await append(KINDS.learningDropped, { source: source.runId, reason: "checker", detail: source.policyError }, "ended");
|
|
313
|
+
return { state: "ended" };
|
|
314
|
+
}
|
|
311
315
|
const round = source.round ?? 1;
|
|
312
316
|
const kept = await learning.proposal(source.runId, round);
|
|
313
317
|
if (!kept) {
|
|
@@ -451,10 +455,21 @@ export function createLearningLoop(learning) {
|
|
|
451
455
|
return { state: "ended" };
|
|
452
456
|
}
|
|
453
457
|
const items = gradedItems(grading, (proposal.files ?? []));
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
+
let prompt;
|
|
459
|
+
try {
|
|
460
|
+
prompt = gradePrompt({
|
|
461
|
+
run: source.runId, ...(source.instructions ? { instructions: source.instructions } : {}), active: main.active, superseded, proposed: grading,
|
|
462
|
+
...(source.nativeInstructions ? { nativeInstructions: true } : {}),
|
|
463
|
+
...(proposal.files?.length ? { files: proposal.files } : {}), ...(proposal.dryRuns ? { dryRuns: proposal.dryRuns } : {}), ...(proposal.drafted?.length ? { drafted: proposal.drafted } : {}), ...(proposal.asked ? { asked: proposal.asked } : {}), ...(proposal.triggered ? { triggered: proposal.triggered } : {}), ...(proposal.held ? { held: proposal.held } : {}),
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
// A full native policy can fill the remaining prompt budget. Refuse the whole proposal visibly;
|
|
468
|
+
// no grader was called and no standing instruction or proposal is silently omitted.
|
|
469
|
+
// Keep what the generality pre-check already spent.
|
|
470
|
+
await append(KINDS.learningDropped, { source: source.runId, reason: "checker", detail: error instanceof Error ? error.message : "The grading evidence exceeds the supported prompt budget.", usd: spent(), tokens, ...(unchecked !== undefined ? { unchecked } : {}) }, "ended");
|
|
471
|
+
return { state: "ended" };
|
|
472
|
+
}
|
|
458
473
|
/** The asks of this attempt that answered: the records holding more requests than these is an earlier attempt's. */
|
|
459
474
|
let answered = 0;
|
|
460
475
|
// Once an ask read the grade's records (`booked`), its dollars are theirs: an earlier attempt's requests counted too.
|
package/dist/runner/loop.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare const quiet: KernelHooks;
|
|
|
15
15
|
export declare const CLOSE_MS = 2000;
|
|
16
16
|
/** How long a person's stop waits for the turn to settle, by default. */
|
|
17
17
|
export declare const STOP_SETTLE_MS = 30000;
|
|
18
|
+
/** How long a park waits, by default, for the calls already running beside the parked one to end before it seals: as long
|
|
19
|
+
* as a stop gives a turn to settle, the loop's one bound for calls already under way. Past it, what still runs is cut. */
|
|
20
|
+
export declare const PARK_SIBLINGS_MS = 30000;
|
|
18
21
|
/** The most a cut run's end-of-run step (a store read) may take before the end is written without it. */
|
|
19
22
|
export declare const CUT_STEP_MS = 2000;
|
|
20
23
|
/** The most the end's patch (the run's cost and metrics, read from its journal and the store) may take before the end is
|
|
@@ -28,6 +31,21 @@ export declare const END_PATCH_UNKNOWN: {
|
|
|
28
31
|
readonly costUsd: null;
|
|
29
32
|
readonly metrics: null;
|
|
30
33
|
};
|
|
34
|
+
/** How many times an end reads its cost before it is written unknown, and the pause between reads: all within the end's
|
|
35
|
+
* bound (END_PATCH_MS), so a store that refused one read never leaves the cost null. The stored cost is every reader's
|
|
36
|
+
* answer for an ended run (the list, the view, usage, learning), so a null there stays only when no read could be made. */
|
|
37
|
+
export declare const END_COST_TRIES = 3;
|
|
38
|
+
export declare const END_COST_PAUSE_MS = 100;
|
|
39
|
+
/** `read`'s answer, read again after a failure (END_COST_TRIES in all, END_COST_PAUSE_MS apart), each failure said by
|
|
40
|
+
* `failed` (its error, how many reads failed, whether it was the last): "late" once `late` resolves first, "failed" when
|
|
41
|
+
* every read failed. */
|
|
42
|
+
export declare function readAgain<T>(read: () => Promise<T>, late: Promise<"late">, failed: (error: unknown, tries: number, last: boolean) => void): Promise<T | "late" | "failed">;
|
|
43
|
+
/** How long a booking whose write has begun (its request answered, its runner.turn on its way to the store) is waited
|
|
44
|
+
* for, by an answer's cost and by a park's or an end's release, before either goes on without it. A busy store queues
|
|
45
|
+
* that write behind every other run's; an end written ahead of it has no booking for the last request and reads the
|
|
46
|
+
* run's cost unknown for good, so it waits as long as the end's own patch would (END_PATCH_MS). A request still
|
|
47
|
+
* streaming is waited for CLOSE_MS only, as before: past it, it reads at its hold. */
|
|
48
|
+
export declare const BOOKING_WRITE_MS = 30000;
|
|
31
49
|
/** Where a commit's batches hold what an expectation waits for: the batch's index and the matched record's id. */
|
|
32
50
|
type Matched = {
|
|
33
51
|
readonly index: number;
|
package/dist/runner/loop.js
CHANGED
|
@@ -17,6 +17,9 @@ export const quiet = { beforeIntent: async () => { }, beforeResult: async () =>
|
|
|
17
17
|
export const CLOSE_MS = 2_000;
|
|
18
18
|
/** How long a person's stop waits for the turn to settle, by default. */
|
|
19
19
|
export const STOP_SETTLE_MS = 30_000;
|
|
20
|
+
/** How long a park waits, by default, for the calls already running beside the parked one to end before it seals: as long
|
|
21
|
+
* as a stop gives a turn to settle, the loop's one bound for calls already under way. Past it, what still runs is cut. */
|
|
22
|
+
export const PARK_SIBLINGS_MS = 30_000;
|
|
20
23
|
/** The most a cut run's end-of-run step (a store read) may take before the end is written without it. */
|
|
21
24
|
export const CUT_STEP_MS = 2_000;
|
|
22
25
|
/** The most the end's patch (the run's cost and metrics, read from its journal and the store) may take before the end is
|
|
@@ -27,6 +30,37 @@ export const END_PATCH_MS = 30_000;
|
|
|
27
30
|
/** What an end whose patch was late or failed writes: its cost and metrics unknown (null), never left as an earlier end
|
|
28
31
|
* of the run stored them, never read as a run that cost $0 by the agent's own path. */
|
|
29
32
|
export const END_PATCH_UNKNOWN = { costUsd: null, metrics: null };
|
|
33
|
+
/** How many times an end reads its cost before it is written unknown, and the pause between reads: all within the end's
|
|
34
|
+
* bound (END_PATCH_MS), so a store that refused one read never leaves the cost null. The stored cost is every reader's
|
|
35
|
+
* answer for an ended run (the list, the view, usage, learning), so a null there stays only when no read could be made. */
|
|
36
|
+
export const END_COST_TRIES = 3;
|
|
37
|
+
export const END_COST_PAUSE_MS = 100;
|
|
38
|
+
/** `read`'s answer, read again after a failure (END_COST_TRIES in all, END_COST_PAUSE_MS apart), each failure said by
|
|
39
|
+
* `failed` (its error, how many reads failed, whether it was the last): "late" once `late` resolves first, "failed" when
|
|
40
|
+
* every read failed. */
|
|
41
|
+
export async function readAgain(read, late, failed) {
|
|
42
|
+
for (let tries = 1;; tries += 1) {
|
|
43
|
+
try {
|
|
44
|
+
return await Promise.race([read(), late]);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
failed(error, tries, tries >= END_COST_TRIES);
|
|
48
|
+
if (tries >= END_COST_TRIES)
|
|
49
|
+
return "failed";
|
|
50
|
+
let timer;
|
|
51
|
+
const paused = await Promise.race([new Promise((resolve) => (timer = setTimeout(() => resolve("again"), END_COST_PAUSE_MS))), late]);
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
if (paused === "late")
|
|
54
|
+
return "late";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** How long a booking whose write has begun (its request answered, its runner.turn on its way to the store) is waited
|
|
59
|
+
* for, by an answer's cost and by a park's or an end's release, before either goes on without it. A busy store queues
|
|
60
|
+
* that write behind every other run's; an end written ahead of it has no booking for the last request and reads the
|
|
61
|
+
* run's cost unknown for good, so it waits as long as the end's own patch would (END_PATCH_MS). A request still
|
|
62
|
+
* streaming is waited for CLOSE_MS only, as before: past it, it reads at its hold. */
|
|
63
|
+
export const BOOKING_WRITE_MS = END_PATCH_MS;
|
|
30
64
|
/**
|
|
31
65
|
* The run's journal with the loop's staging matched to commits. stage() replaces what was staged, so the loop never
|
|
32
66
|
* calls it directly: `expect(match, expected)` stages `expected` on the first commit whose batches `match`, merged with
|
package/dist/runner/main.d.ts
CHANGED
|
@@ -118,7 +118,8 @@ export declare const RUNNER_DRAIN_TIMEOUT = "6s";
|
|
|
118
118
|
export declare const RUNNER_DRAIN_ENV = "AGENTRUN_DRAIN_TIMEOUT";
|
|
119
119
|
/** What a runner process holds, from its arguments and `env`: --loops, else the server's --max-runs default
|
|
120
120
|
* (AGENTRUN_MAX_RUNS, else as many pi runs as this host's memory holds; maxRunsOf); --drain-timeout, else
|
|
121
|
-
* AGENTRUN_DRAIN_TIMEOUT, else RUNNER_DRAIN_TIMEOUT. A bad AGENTRUN_MAX_RUNS
|
|
121
|
+
* AGENTRUN_DRAIN_TIMEOUT, else RUNNER_DRAIN_TIMEOUT. A bad AGENTRUN_MAX_RUNS, AGENTRUN_DRAIN_TIMEOUT or
|
|
122
|
+
* AGENTRUN_FREE_MODEL_REQUESTS is RunnerRefused. */
|
|
122
123
|
export declare function runnerHolds(args: {
|
|
123
124
|
loops?: number;
|
|
124
125
|
drainMs?: number;
|
|
@@ -149,6 +150,10 @@ export declare function runUntilSignalled(process: RunnerProcess, signals?: read
|
|
|
149
150
|
* next epoch, and the fence refuses the dead loop's late writes. The line is written to stderr synchronously
|
|
150
151
|
* (writeSync), so a pipe's slow reader still gets the whole stack before the exit. Exported for its test. */
|
|
151
152
|
export declare function lastResort(name: string, write?: (line: string) => void, exit?: (code: number) => void): (reason: unknown) => void;
|
|
153
|
+
/** The line of a runner's trouble, in its name: a claim it lost, and an error (a renew or a stop that failed), which
|
|
154
|
+
* goes to stderr. Undefined for any other event. The runner beside a server says them the same way (beside.ts), so a
|
|
155
|
+
* lapse of every claim at once shows its cause. */
|
|
156
|
+
export declare function troubleLine(name: string, event: RunnerEvent): string | undefined;
|
|
152
157
|
/** `agentrun-serve runner ...`: the exit code. 2: bad arguments; 3: a store schema this runner does not know (or none
|
|
153
158
|
* set up yet); 1: anything else; 0: closed on a signal, or --check found a fresh heartbeat. AGENTRUN_RUNNER_NAME names
|
|
154
159
|
* it when --name does not. */
|
package/dist/runner/main.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { mkdirSync, statSync, utimesSync, writeFileSync, writeSync } from "node:fs";
|
|
14
14
|
import { join, resolve } from "node:path";
|
|
15
15
|
import { PROVIDERS } from "@parcha/agentrun-computer";
|
|
16
|
+
import { freeModelRequestsOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
16
17
|
import { ArchilSettingsEnvInvalid, archilSettingsFromEnv } from "../archil-settings.js";
|
|
17
18
|
import { dockerPathsForRuns } from "../box-paths.js";
|
|
18
19
|
import { hostCommandRefusals } from "../computers.js";
|
|
@@ -33,6 +34,7 @@ import { envValue } from "../key-meta.js";
|
|
|
33
34
|
import { fauxComputers } from "../faux-computers.js";
|
|
34
35
|
import { computerDepsFrom } from "../workspace/computer-deps.js";
|
|
35
36
|
import { startJanitor } from "../workspace/computer-janitor.js";
|
|
37
|
+
import { runEndComputers } from "../workspace/run-end-computers.js";
|
|
36
38
|
import { createDispatchLoop } from "./dispatch.js";
|
|
37
39
|
import { resolveRunnerLoop } from "./harness-loops.js";
|
|
38
40
|
import { routeOf } from "./model-route.js";
|
|
@@ -197,6 +199,8 @@ export async function startRunnerProcess(options) {
|
|
|
197
199
|
janitor = startJanitor({ store, computers: parts.computers, env: parts.env, log: warn });
|
|
198
200
|
// Before it claims: the scratch folders of runs that ended after their runner died (scratch-sweep.ts), said as warnings.
|
|
199
201
|
await sweepEndedScratch(store, options.dataDir, { log: warn });
|
|
202
|
+
// A run's end lets go of what its earlier claims' computers left, with the same computers (run-end-computers.ts).
|
|
203
|
+
const runEnded = typeof parts !== "function" ? runEndComputers({ store, computers: parts.computers, log: warn }) : undefined;
|
|
200
204
|
runner = startRunner({
|
|
201
205
|
store,
|
|
202
206
|
createLoop,
|
|
@@ -205,6 +209,7 @@ export async function startRunnerProcess(options) {
|
|
|
205
209
|
...(options.drainMs ? { drainMs: options.drainMs } : {}),
|
|
206
210
|
memory,
|
|
207
211
|
...(options.onEvent ? { onEvent: options.onEvent } : {}),
|
|
212
|
+
...(runEnded ? { runEnded } : {}),
|
|
208
213
|
onBeat: heartbeat(options.dataDir, name, options.now ?? Date.now),
|
|
209
214
|
});
|
|
210
215
|
}
|
|
@@ -248,7 +253,8 @@ export const RUNNER_DRAIN_TIMEOUT = "6s";
|
|
|
248
253
|
export const RUNNER_DRAIN_ENV = "AGENTRUN_DRAIN_TIMEOUT";
|
|
249
254
|
/** What a runner process holds, from its arguments and `env`: --loops, else the server's --max-runs default
|
|
250
255
|
* (AGENTRUN_MAX_RUNS, else as many pi runs as this host's memory holds; maxRunsOf); --drain-timeout, else
|
|
251
|
-
* AGENTRUN_DRAIN_TIMEOUT, else RUNNER_DRAIN_TIMEOUT. A bad AGENTRUN_MAX_RUNS
|
|
256
|
+
* AGENTRUN_DRAIN_TIMEOUT, else RUNNER_DRAIN_TIMEOUT. A bad AGENTRUN_MAX_RUNS, AGENTRUN_DRAIN_TIMEOUT or
|
|
257
|
+
* AGENTRUN_FREE_MODEL_REQUESTS is RunnerRefused. */
|
|
252
258
|
export function runnerHolds(args, env) {
|
|
253
259
|
let loops = args.loops;
|
|
254
260
|
if (loops === undefined) {
|
|
@@ -266,6 +272,14 @@ export function runnerHolds(args, env) {
|
|
|
266
272
|
if (drainMs === undefined)
|
|
267
273
|
throw new RunnerRefused(`${RUNNER_DRAIN_ENV} is a duration such as 6s, 500ms or 1m, not ${JSON.stringify(given)}`);
|
|
268
274
|
}
|
|
275
|
+
// The limit on each run's requests on free models (AGENTRUN_FREE_MODEL_REQUESTS), read again at each claim: a bad one refuses
|
|
276
|
+
// the runner here, never a run at its claim.
|
|
277
|
+
try {
|
|
278
|
+
freeModelRequestsOf(env);
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
throw new RunnerRefused(error.message);
|
|
282
|
+
}
|
|
269
283
|
return { loops, drainMs };
|
|
270
284
|
}
|
|
271
285
|
/** The runner process's arguments: `--data D [--loops N] [--drain-timeout D] [--name N] [--faux M]`, or `--check --data D
|
|
@@ -351,10 +365,18 @@ function said(name, event) {
|
|
|
351
365
|
return `Runner ${name} claimed ${event.claim.runId} (epoch ${event.claim.epoch})`;
|
|
352
366
|
if (event.type === "released")
|
|
353
367
|
return `Runner ${name} released ${event.runId} (${event.end})`;
|
|
354
|
-
if (event.type === "claim-lost")
|
|
355
|
-
return `Runner ${name} lost its claim on ${event.runId} (${event.why})`;
|
|
356
368
|
if (event.type === "started" || event.type === "ended")
|
|
357
369
|
return runLine(event);
|
|
370
|
+
return troubleLine(name, event);
|
|
371
|
+
}
|
|
372
|
+
/** The line of a runner's trouble, in its name: a claim it lost, and an error (a renew or a stop that failed), which
|
|
373
|
+
* goes to stderr. Undefined for any other event. The runner beside a server says them the same way (beside.ts), so a
|
|
374
|
+
* lapse of every claim at once shows its cause. */
|
|
375
|
+
export function troubleLine(name, event) {
|
|
376
|
+
if (event.type === "claim-lost")
|
|
377
|
+
return `Runner ${name} lost its claim on ${event.runId} (${event.why})`;
|
|
378
|
+
if (event.type === "error")
|
|
379
|
+
return `Runner ${name}: ${event.step}${event.runId ? ` ${event.runId}` : ""}: ${event.message}`;
|
|
358
380
|
return undefined;
|
|
359
381
|
}
|
|
360
382
|
/** `agentrun-serve runner ...`: the exit code. 2: bad arguments; 3: a store schema this runner does not know (or none
|
|
@@ -434,7 +456,7 @@ export async function runnerMain(argv, given = process.env, hooks = {}) {
|
|
|
434
456
|
janitor: true,
|
|
435
457
|
onEvent: (event) => {
|
|
436
458
|
if (event.type === "error")
|
|
437
|
-
return void console.error(
|
|
459
|
+
return void console.error(troubleLine(runnerOf, event));
|
|
438
460
|
const line = said(runnerOf, event);
|
|
439
461
|
if (line)
|
|
440
462
|
console.log(line);
|
package/dist/runner/mcp-run.d.ts
CHANGED
|
@@ -66,7 +66,8 @@ export interface ClaimMcp {
|
|
|
66
66
|
* a pin in any layer to (tool-gate.ts pinRefusal). Undefined for a listing with no `properties` object, and for any
|
|
67
67
|
* other tool. */
|
|
68
68
|
argumentsOf(name: string): ReadonlySet<string> | undefined;
|
|
69
|
-
/** What an asked call of a pinned tool costs on its card (main's: its price, else "not metered"
|
|
69
|
+
/** What an asked call of a pinned tool costs on its card (main's: its price, else "not metered"; a monid endpoint priced
|
|
70
|
+
* by usage, "priced by usage", never read from monid before the person answers); undefined otherwise. */
|
|
70
71
|
priceOf(name: string): ApprovalPrice | undefined;
|
|
71
72
|
/** A pinned tool's effect (`mcp:<server>/<tool>`), by its annotations as the pin holds them (tool-gate.ts toolEffect):
|
|
72
73
|
* what the gate's "allow reads" and a destructive call's card read; never a later listing. Undefined for any other. */
|
|
@@ -77,6 +78,8 @@ export interface ClaimMcp {
|
|
|
77
78
|
/** Drops every credential held: the pass ended, the claim is lost, or its signal aborted. */
|
|
78
79
|
release(): void;
|
|
79
80
|
}
|
|
81
|
+
/** The wire names a subagent's `grant` gives of the run's MCP and monid tools, by the gate's keys; else the grant's own. */
|
|
82
|
+
export declare function catalogSessionNames(catalog: Pick<ClaimMcp, "tools" | "catalogOf"> | undefined, grant: string): string[];
|
|
80
83
|
/** The run's MCP for one claim: undefined when it grants no MCP tool. Throws McpClaimRefused (a granted tool its pin lacks,
|
|
81
84
|
* a pinned tool that is a meta tool now: the loop ends the run in those words, before its session opens) or Fenced (the
|
|
82
85
|
* claim lost while a refresh was awaited: the loop ends interrupted). A builder calls it before it takes anything it
|
package/dist/runner/mcp-run.js
CHANGED
|
@@ -3,9 +3,15 @@ import { wireName } from "../catalog.js";
|
|
|
3
3
|
import { mcpGateway } from "../mcp-gateway.js";
|
|
4
4
|
import { dialAt, mcpServerAt, systemNetwork } from "../mcp-oauth.js";
|
|
5
5
|
import { privateOAuthHosts } from "../mcp-private-hosts.js";
|
|
6
|
-
import {
|
|
6
|
+
import { mcpNameOf } from "../tool-names.js";
|
|
7
|
+
import { mcpToolName, permissionKeys, pinnedEffect } from "../tool-gate.js";
|
|
7
8
|
import { mcpClaim } from "./mcp-claim.js";
|
|
8
9
|
import { registryListing } from "../mcp-pin-first.js";
|
|
10
|
+
/** The wire names a subagent's `grant` gives of the run's MCP and monid tools, by the gate's keys; else the grant's own. */
|
|
11
|
+
export function catalogSessionNames(catalog, grant) {
|
|
12
|
+
const given = (catalog?.tools ?? []).flatMap((tool) => (permissionKeys(catalog.catalogOf(tool.name) ?? "").includes(grant) ? [tool.name] : []));
|
|
13
|
+
return given.length ? given : [wireName(grant)];
|
|
14
|
+
}
|
|
9
15
|
/** The run's MCP for one claim: undefined when it grants no MCP tool. Throws McpClaimRefused (a granted tool its pin lacks,
|
|
10
16
|
* a pinned tool that is a meta tool now: the loop ends the run in those words, before its session opens) or Fenced (the
|
|
11
17
|
* claim lost while a refresh was awaited: the loop ends interrupted). A builder calls it before it takes anything it
|
|
@@ -91,11 +97,11 @@ export async function mcpForClaim(options) {
|
|
|
91
97
|
catalogOf: (tool) => catalog.get(tool),
|
|
92
98
|
argumentsOf: (name) => declared.get(name),
|
|
93
99
|
priceOf(name) {
|
|
94
|
-
const parsed =
|
|
95
|
-
const pinned = parsed && Object.hasOwn(pin, parsed
|
|
96
|
-
if (!pinned?.tools.some((tool) => tool.name === parsed
|
|
100
|
+
const parsed = mcpNameOf(name);
|
|
101
|
+
const pinned = parsed && Object.hasOwn(pin, parsed.server) ? pin[parsed.server] : undefined;
|
|
102
|
+
if (!pinned?.tools.some((tool) => tool.name === parsed.tool))
|
|
97
103
|
return undefined;
|
|
98
|
-
return pinned.prices && Object.hasOwn(pinned.prices, parsed
|
|
104
|
+
return pinned.prices && Object.hasOwn(pinned.prices, parsed.tool) ? pinned.prices[parsed.tool] : "not metered";
|
|
99
105
|
},
|
|
100
106
|
effectOf: (name) => pinnedEffect(pin, name),
|
|
101
107
|
fresh: () => step.fresh(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HostTool } from "@parcha/agentrun-kernel";
|
|
2
2
|
import { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH } from "../meta-tool-names.js";
|
|
3
|
+
import type { ScriptComputer } from "../workspace/run-tools.js";
|
|
3
4
|
export { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH };
|
|
4
5
|
/** How many tools a search answers with when its call names no limit, and the most it may name. */
|
|
5
6
|
export declare const SEARCH_DEFAULT_LIMIT = 8;
|
|
@@ -15,10 +16,11 @@ export interface FoundTool {
|
|
|
15
16
|
/** The tools of `tools` (the run's own, none of the three here) whose names `granted` holds, ranked for `query`. */
|
|
16
17
|
export declare function searchTools(query: string, tools: readonly HostTool[], granted: (name: string) => Promise<boolean>, limit?: number): Promise<FoundTool[]>;
|
|
17
18
|
/** The run's tool a model's name for it names: its own name, or one a harness gives it on its tool channel (claude-agent's
|
|
18
|
-
* `mcp__hands__<name>`, OpenCode's `hands_<name>`, Codex's `mcp_<server>__<tool>` for an MCP tool)
|
|
19
|
-
|
|
19
|
+
* `mcp__hands__<name>`, OpenCode's `hands_<name>`, Codex's `mcp_<server>__<tool>` for an MCP tool): `hostName` is the
|
|
20
|
+
* harness's own map from that name to the host's (AdapterFacts.hostName). */
|
|
21
|
+
export declare function toolNamed(name: string, tools: readonly HostTool[], hostName?: (given: string) => string): HostTool | undefined;
|
|
20
22
|
/** Why `name` can't be called through tools_call or a script, or undefined: one of the three, or no tool of this run. */
|
|
21
|
-
export declare function refusedName(caller: string, name: string, tools: readonly HostTool[]): string | undefined;
|
|
23
|
+
export declare function refusedName(caller: string, name: string, tools: readonly HostTool[], hostName?: (given: string) => string): string | undefined;
|
|
22
24
|
export interface MetaToolsOptions {
|
|
23
25
|
/** The run's tools as the session gives them, the three left out (each call reads them now). */
|
|
24
26
|
tools: () => readonly HostTool[];
|
|
@@ -32,6 +34,11 @@ export interface MetaToolsOptions {
|
|
|
32
34
|
search: boolean;
|
|
33
35
|
call: boolean;
|
|
34
36
|
};
|
|
37
|
+
/** The harness's map from the model's name for a host tool to the host's (AdapterFacts.hostName); absent: the same. */
|
|
38
|
+
hostName?: (given: string) => string;
|
|
39
|
+
/** The run's desktop or phone as a script gets it (RunTools.computer): a script's `computer`, bound to its card, each of
|
|
40
|
+
* whose calls is a nested call of the run's computer tools (scriptComputer). Absent: no `computer` in a script. */
|
|
41
|
+
computer?: ScriptComputer;
|
|
35
42
|
}
|
|
36
43
|
/** The three tools for a session: each `nests` (but the search, which calls nothing). */
|
|
37
44
|
export declare function metaTools(options: MetaToolsOptions): HostTool[];
|