@parcha/agentrun-serve 0.1.0-beta.37 → 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 +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- 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 +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- 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.d.ts +2 -0
- package/dist/console-links.js +6 -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/decisions.js +4 -0
- 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/faux-computers.js +4 -2
- 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 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- 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.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- 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/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- 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 +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- 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 +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- 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 +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- 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 +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- 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 +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -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/connection.js +3 -1
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/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 +16 -0
- package/dist/store/schema.js +47 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- 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 +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- 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 +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- 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.d.ts +15 -7
- package/dist/validate.js +91 -50
- 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 +6 -8
- package/dist/web-fetch.js +10 -53
- 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 +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- 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 +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- 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 +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +3 -3
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/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/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +5 -4
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +5 -4
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
package/dist/learn/reflect.d.ts
CHANGED
|
@@ -1,46 +1,26 @@
|
|
|
1
|
-
import { type DraftDecisions } from "./skills.js";
|
|
2
1
|
/** The info word that opens a note's block in the answer: ```note <file>. */
|
|
3
2
|
export declare const NOTE_BLOCK = "note";
|
|
4
3
|
/** The info words that open a skill's and a workflow draft's block: ````skill <name> and ````workflow <name>, each fenced
|
|
5
4
|
* with four backticks so a ``` line inside does not close it. */
|
|
6
5
|
export declare const SKILL_BLOCK = "skill";
|
|
7
6
|
export declare const WORKFLOW_BLOCK = "workflow";
|
|
8
|
-
/** How many earlier runs of an agent a learned skill has been given to before the host asks for its job as a workflow
|
|
9
|
-
* draft (`draftFor`): a run proposes one only when it thinks to, and few do. */
|
|
10
|
-
export declare const DRAFT_AFTER_RUNS = 3;
|
|
11
7
|
/** What a later round's end-of-run prompt says first (reflectPrompt's `later`): the run looked back before, at an end a
|
|
12
8
|
* follow-up opened it again from, so only what came since is new. */
|
|
13
9
|
export declare const LATER_LOOK = "You looked back on this run before. Since then the conversation went on: keep only what the messages since then teach (a reviewer's word on your answer included), and never repeat a note you kept then.";
|
|
14
10
|
/** The end-of-run turn's message. `dir` is the run's copy of the folder relative to the run's workspace (`.learning`),
|
|
15
11
|
* where the agent can read its notes: the prompt never names a path of the host's, which a box would not see. `active`
|
|
16
|
-
* is how many notes are active in it, so how many lines the index has left.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* draft asked for: what each of `tools` takes and gives a call node, in the server's own words (tools.ts ToolEntry
|
|
21
|
-
* summary), said under the ask, one line each (at most DESCRIBED_MAX characters, unseen characters and line breaks made
|
|
22
|
-
* spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. `workflows`, false
|
|
23
|
-
* for a run of a revision that says `learning: "notes"`: the prompt asks for notes and a skill alone, says to keep no
|
|
24
|
-
* workflow draft, and asks for none (`draftFor` and `described` are not said). `decisions`, the run's decision providers
|
|
25
|
-
* (skills.ts DraftDecisions, the one the draft check reads): with a provider it has (draftDecisionProviders), a draft may
|
|
26
|
-
* use judge, pick and sift nodes; without, the prompt bans them as it always did. `later`, a later round's (a follow-up
|
|
27
|
-
* opened the run again after it looked back): the prompt says so (LATER_LOOK) after its first line. */
|
|
12
|
+
* is how many notes are active in it, so how many lines the index has left. The turn keeps notes and a skill; a job
|
|
13
|
+
* that repeats is compiled into a learned workflow by the compile turn (learn/compile.ts), never drafted here. `later`,
|
|
14
|
+
* a later round's (a follow-up opened the run again after it looked back): the prompt says so (LATER_LOOK) after its
|
|
15
|
+
* first line. */
|
|
28
16
|
export declare function reflectPrompt(options: {
|
|
29
17
|
dir: string;
|
|
30
18
|
active: number;
|
|
31
|
-
tools?: readonly string[];
|
|
32
|
-
draftFor?: readonly string[];
|
|
33
|
-
described?: readonly {
|
|
34
|
-
readonly name: string;
|
|
35
|
-
readonly does: string;
|
|
36
|
-
}[];
|
|
37
|
-
workflows?: boolean;
|
|
38
|
-
decisions?: DraftDecisions;
|
|
39
19
|
later?: boolean;
|
|
40
20
|
}): string;
|
|
41
21
|
/** The end-of-run turn asked again, once, when the parser refused its answer: why, in the parser's own words (`detail`,
|
|
42
22
|
* parseReflection's), and the whole answer again in the format. */
|
|
43
|
-
export declare function reflectAgain(detail: string
|
|
23
|
+
export declare function reflectAgain(detail: string): string;
|
|
44
24
|
/** The end-of-run turn asked again, once, when the checks left a workflow draft out because its dry run failed: which
|
|
45
25
|
* draft, in the host's own words, and why (`detail`, the check's words, made from the draft's own text: a step's label,
|
|
46
26
|
* a path) inside a data fence alone, cleaned of control and format characters and capped, its token one the detail
|
package/dist/learn/reflect.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// What a host asks of an agent once its run has answered or failed: one more turn in the same session, in which the agent
|
|
2
|
-
// answers with the notes it would keep, and a skill
|
|
3
|
-
//
|
|
2
|
+
// answers with the notes it would keep, and a skill when the work repeats, as text in a strict format, and uses no tool
|
|
3
|
+
// (a workflow is the compile turn's, learn/compile.ts, whose answer this parser reads too). The host parses the answer (parseReflection), checks what it gives (check.ts), a grader
|
|
4
4
|
// judges it (grade.ts), and the host merges it, rebuilding the index; the agent never writes the folder, and nothing it
|
|
5
5
|
// wrote during the task counts. The same on every harness: every model writes markdown, and no tool is needed.
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { CAPS } from "./check.js";
|
|
8
8
|
import { INDEX_FILE, INDEX_LINES } from "./notes.js";
|
|
9
|
-
import { draftDecisionProviders, LEARNED_MCP_TOOL, SKILL_NAME } from "./skills.js";
|
|
10
9
|
/** Control and invisible characters: none may reach the prompt through a value the host puts in it. */
|
|
11
10
|
const UNSEEN = /[\p{Cc}\p{Cf}]/u;
|
|
12
11
|
/** The info word that opens a note's block in the answer: ```note <file>. */
|
|
@@ -15,41 +14,21 @@ export const NOTE_BLOCK = "note";
|
|
|
15
14
|
* with four backticks so a ``` line inside does not close it. */
|
|
16
15
|
export const SKILL_BLOCK = "skill";
|
|
17
16
|
export const WORKFLOW_BLOCK = "workflow";
|
|
18
|
-
/** How many earlier runs of an agent a learned skill has been given to before the host asks for its job as a workflow
|
|
19
|
-
* draft (`draftFor`): a run proposes one only when it thinks to, and few do. */
|
|
20
|
-
export const DRAFT_AFTER_RUNS = 3;
|
|
21
|
-
/** A tool's name as the prompt may print it: a table tool's, or an MCP tool's a learned workflow may run (skills.ts
|
|
22
|
-
* LEARNED_MCP_TOOL). */
|
|
23
|
-
const TOOL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
24
|
-
const printable = (tool) => TOOL_NAME.test(tool) || LEARNED_MCP_TOOL.test(tool);
|
|
25
17
|
/** What a later round's end-of-run prompt says first (reflectPrompt's `later`): the run looked back before, at an end a
|
|
26
18
|
* follow-up opened it again from, so only what came since is new. */
|
|
27
19
|
export const LATER_LOOK = "You looked back on this run before. Since then the conversation went on: keep only what the messages since then teach (a reviewer's word on your answer included), and never repeat a note you kept then.";
|
|
28
20
|
/** The end-of-run turn's message. `dir` is the run's copy of the folder relative to the run's workspace (`.learning`),
|
|
29
21
|
* where the agent can read its notes: the prompt never names a path of the host's, which a box would not see. `active`
|
|
30
|
-
* is how many notes are active in it, so how many lines the index has left.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* draft asked for: what each of `tools` takes and gives a call node, in the server's own words (tools.ts ToolEntry
|
|
35
|
-
* summary), said under the ask, one line each (at most DESCRIBED_MAX characters, unseen characters and line breaks made
|
|
36
|
-
* spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. `workflows`, false
|
|
37
|
-
* for a run of a revision that says `learning: "notes"`: the prompt asks for notes and a skill alone, says to keep no
|
|
38
|
-
* workflow draft, and asks for none (`draftFor` and `described` are not said). `decisions`, the run's decision providers
|
|
39
|
-
* (skills.ts DraftDecisions, the one the draft check reads): with a provider it has (draftDecisionProviders), a draft may
|
|
40
|
-
* use judge, pick and sift nodes; without, the prompt bans them as it always did. `later`, a later round's (a follow-up
|
|
41
|
-
* opened the run again after it looked back): the prompt says so (LATER_LOOK) after its first line. */
|
|
22
|
+
* is how many notes are active in it, so how many lines the index has left. The turn keeps notes and a skill; a job
|
|
23
|
+
* that repeats is compiled into a learned workflow by the compile turn (learn/compile.ts), never drafted here. `later`,
|
|
24
|
+
* a later round's (a follow-up opened the run again after it looked back): the prompt says so (LATER_LOOK) after its
|
|
25
|
+
* first line. */
|
|
42
26
|
export function reflectPrompt(options) {
|
|
43
|
-
const { dir, active,
|
|
44
|
-
const judges = draftDecisionProviders(decisions).length > 0;
|
|
27
|
+
const { dir, active, later = false } = options;
|
|
45
28
|
if (typeof dir !== "string" || dir === "" || dir.startsWith("/") || UNSEEN.test(dir))
|
|
46
29
|
throw new Error("the directory must be a path relative to the run's workspace, with no control or unseen characters");
|
|
47
30
|
if (!Number.isSafeInteger(active) || active < 0)
|
|
48
31
|
throw new Error("the count of active notes must be a whole number, 0 or more");
|
|
49
|
-
if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== "string" || !printable(tool)))
|
|
50
|
-
throw new Error("each tool must be a tool's name");
|
|
51
|
-
if (!Array.isArray(draftFor) || draftFor.some((name) => typeof name !== "string" || !SKILL_NAME.test(name)))
|
|
52
|
-
throw new Error("each skill a draft is asked for must be a skill's name");
|
|
53
32
|
const left = Math.max(0, INDEX_LINES - active);
|
|
54
33
|
return [
|
|
55
34
|
"The task is done. Before the run ends, say what this run taught you that will help in later runs, if anything.",
|
|
@@ -93,29 +72,17 @@ export function reflectPrompt(options) {
|
|
|
93
72
|
"site, a source or a seller, or names where money or data goes.",
|
|
94
73
|
"What `# Learned` in your instructions, and this message, say about learning itself is not a lesson: never put it in a note or a skill, nor the sentence you say when you keep something.",
|
|
95
74
|
"",
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"workflow draft for that job. Most runs keep neither. Neither holds this case's data: each is about the job, not the one case.",
|
|
101
|
-
] : [
|
|
102
|
-
"## Skills, only when the work repeats",
|
|
103
|
-
"",
|
|
104
|
-
"When this run did, to the end, a job this agent will be asked to do again, you may also keep one skill for that job.",
|
|
105
|
-
"Most runs keep none. It holds none of this case's data: it is about the job, not the one case.",
|
|
106
|
-
"Keep no workflow draft: this agent learns notes and skills alone.",
|
|
107
|
-
]),
|
|
75
|
+
"## Skills, only when the work repeats",
|
|
76
|
+
"",
|
|
77
|
+
"When this run did, to the end, a job this agent will be asked to do again, you may also keep one skill for that job.",
|
|
78
|
+
"Most runs keep none. It holds none of this case's data: it is about the job, not the one case.",
|
|
108
79
|
"Steps the person asks you to follow every time a task comes back are a skill, not a note: keep them as the skill, in",
|
|
109
80
|
"their words and with the exact output format they gave, and do not repeat them in a note.",
|
|
110
81
|
"A job you keep a skill for needs no note beside it.",
|
|
111
82
|
"A rule for every reply applies whatever the job is. Keep it as a note, which every later run reads. Steps or a format",
|
|
112
83
|
"for one kind of job, named by when it applies (\"whenever I ask for a weekly summary\", \"when you open a PR\"), are a",
|
|
113
84
|
"skill. A note holds its own lesson: never repeat another note's rule in it, so a retired rule stays retired.",
|
|
114
|
-
|
|
115
|
-
"A job that runs end to end as model and tool-call steps, from a defined input to a defined output, is a workflow draft,",
|
|
116
|
-
"and so is one the person asks you to keep as a workflow; its steps may also be a skill.",
|
|
117
|
-
...(draftFor.length ? [draftAsk(draftFor), ...describedLines(described, tools)] : []),
|
|
118
|
-
] : []),
|
|
85
|
+
"Keep no workflow here: when the job repeats, the host may ask for it as a workflow in a turn of its own, from your notes.",
|
|
119
86
|
"",
|
|
120
87
|
`A skill is how to do the job, step by step, as a SKILL.md: front matter with its \`name\` (lowercase letters, digits`,
|
|
121
88
|
"and single dashes) and a `description` of when to use it, then the steps. Open its block with four backticks, so a",
|
|
@@ -129,54 +96,12 @@ export function reflectPrompt(options) {
|
|
|
129
96
|
"---",
|
|
130
97
|
"1. Open the store's policies page first.",
|
|
131
98
|
"````",
|
|
132
|
-
"",
|
|
133
|
-
...(workflows ? [
|
|
134
|
-
"A workflow draft does the job as one workflow DSL document: front matter with one line that says what it does and",
|
|
135
|
-
"when to use it, then the JSON. " + (judges
|
|
136
|
-
? "It uses model and tool-call nodes, and may use judge (answers a question about a value), pick (chooses one of several options) and sift (keeps the items that pass a test) nodes, which run on this run's decision provider under its cap and tool policy; no code node, no shell or"
|
|
137
|
-
: "It uses model and tool-call nodes only: no judge, pick or sift node, no code node, no shell or"),
|
|
138
|
-
`executor call. Its model nodes name no tool. ${tools.length ? `Its call nodes may run only these tools: ${tools.join(", ")}.` : "It has no call node on a tool."} At most ${CAPS.file} bytes of JSON.`,
|
|
139
|
-
"To change a draft you were given, give it again whole under its name.",
|
|
140
|
-
"Its schemas are declared once under `schemas`, and `input` and `output` name one each by `schemaId`, never a schema",
|
|
141
|
-
"written in place.",
|
|
142
|
-
"Give its front matter an `example:` line too: one JSON object on one line, the input this run would have given it.",
|
|
143
|
-
"The host dry-runs the draft on it before it is kept (no model or tool is called) and never keeps the example.",
|
|
144
|
-
"",
|
|
145
|
-
`\`\`\`\`${WORKFLOW_BLOCK} find-policies`,
|
|
146
|
-
"---",
|
|
147
|
-
"description: Finds a store's refund policy from its public pages; use when a case asks for it",
|
|
148
|
-
`example: ${JSON.stringify(tools.includes("web_fetch") ? { url: "https://shop.example/policies" } : { text: "Refunds are accepted within 30 days of delivery." })}`,
|
|
149
|
-
"---",
|
|
150
|
-
JSON.stringify(exampleDraft(tools.includes("web_fetch"))),
|
|
151
|
-
"````",
|
|
152
|
-
] : []),
|
|
153
99
|
].join("\n");
|
|
154
100
|
}
|
|
155
|
-
/** The most of one tool's words the draft ask's description gives it. */
|
|
156
|
-
const DESCRIBED_MAX = 600;
|
|
157
|
-
/** What each of `tools` takes and gives a call node, from `described` (a tool's name and its words), one line each, under
|
|
158
|
-
* a line that says so; none when no tool of `tools` is described. */
|
|
159
|
-
const describedLines = (described, tools) => {
|
|
160
|
-
const lines = tools.flatMap((name) => {
|
|
161
|
-
const does = described.find((one) => one.name === name)?.does;
|
|
162
|
-
if (typeof does !== "string")
|
|
163
|
-
return [];
|
|
164
|
-
const flat = does.replace(new RegExp(UNSEEN.source, "gu"), " ").replace(/\s+/g, " ").trim().slice(0, DESCRIBED_MAX).trim();
|
|
165
|
-
return flat ? [`- \`${name}\`: ${flat}`] : [];
|
|
166
|
-
});
|
|
167
|
-
return lines.length ? ["What each tool a call node may run takes and gives:", ...lines] : [];
|
|
168
|
-
};
|
|
169
|
-
/** The one line that asks for a workflow draft of a skill's job, by the skill's name. */
|
|
170
|
-
const draftAsk = (names) => {
|
|
171
|
-
const listed = names.map((name) => `\`${name}\``).join(", ");
|
|
172
|
-
return names.length === 1
|
|
173
|
-
? `Your skill ${listed} has now served ${DRAFT_AFTER_RUNS} or more runs: this time, also keep its job as a workflow draft named \`${names[0]}\`, its steps as nodes, if the job runs end to end as model and tool-call steps. Its output is the job's answer in the output format the skill gives: its last node writes it, and \`output\` names that node's text.`
|
|
174
|
-
: `Your skills ${listed} have each served ${DRAFT_AFTER_RUNS} or more runs: this time, also keep one of their jobs as a workflow draft named like its skill, its steps as nodes, if the job runs end to end as model and tool-call steps. Its output is the job's answer in the output format its skill gives: its last node writes it, and \`output\` names that node's text.`;
|
|
175
|
-
};
|
|
176
101
|
/** The end-of-run turn asked again, once, when the parser refused its answer: why, in the parser's own words (`detail`,
|
|
177
102
|
* parseReflection's), and the whole answer again in the format. */
|
|
178
|
-
export function reflectAgain(detail
|
|
179
|
-
return `Your answer could not be read: ${detail}. Give the whole answer again in the format asked for above, every
|
|
103
|
+
export function reflectAgain(detail) {
|
|
104
|
+
return `Your answer could not be read: ${detail}. Give the whole answer again in the format asked for above, every note and skill block in it, and nothing else.`;
|
|
180
105
|
}
|
|
181
106
|
/** The end-of-run turn asked again, once, when the checks left a workflow draft out because its dry run failed: which
|
|
182
107
|
* draft, in the host's own words, and why (`detail`, the check's words, made from the draft's own text: a step's label,
|
|
@@ -213,48 +138,6 @@ function retryToken(file, said) {
|
|
|
213
138
|
return token;
|
|
214
139
|
}
|
|
215
140
|
}
|
|
216
|
-
/** The prompt's example workflow draft, whole: its schemas declared once, its input and output naming them by `schemaId`,
|
|
217
|
-
* and a chain the learned runner runs (a `web_fetch` call when the agent has it, then a model node; else two model
|
|
218
|
-
* nodes), so an agent copies a draft the DSL and the checker pass (a test validates this text). */
|
|
219
|
-
const exampleDraft = (fetches) => fetches
|
|
220
|
-
? {
|
|
221
|
-
v: 2,
|
|
222
|
-
name: "find-policies",
|
|
223
|
-
schemas: {
|
|
224
|
-
Store: { type: "object", properties: { url: { type: "string" } }, required: ["url"] },
|
|
225
|
-
Page: { type: "object", properties: { text: { type: "string" } } },
|
|
226
|
-
Policies: { type: "object", properties: { refund: { type: "string" } }, required: ["refund"] },
|
|
227
|
-
},
|
|
228
|
-
input: { schemaId: "Store" },
|
|
229
|
-
output: { schemaId: "Policies", path: "policies" },
|
|
230
|
-
root: {
|
|
231
|
-
node: "chain",
|
|
232
|
-
steps: [
|
|
233
|
-
{ node: "call", label: "fetch", via: "tool", tool: "web_fetch", args: { url: "{url}" }, out: "Page", as: "page", deadline_s: 30 },
|
|
234
|
-
{ node: "extract", label: "read", instructions: "Say the store's refund policy, from the page.", out: "Policies", as: "policies" },
|
|
235
|
-
],
|
|
236
|
-
},
|
|
237
|
-
}
|
|
238
|
-
: {
|
|
239
|
-
// With no tool to fetch with, the job's input is the page's text itself: every step reads what it is given,
|
|
240
|
-
// never a guess.
|
|
241
|
-
v: 2,
|
|
242
|
-
name: "find-policies",
|
|
243
|
-
schemas: {
|
|
244
|
-
Page: { type: "object", properties: { text: { type: "string" } }, required: ["text"] },
|
|
245
|
-
Lines: { type: "object", properties: { lines: { type: "string" } }, required: ["lines"] },
|
|
246
|
-
Policies: { type: "object", properties: { refund: { type: "string" } }, required: ["refund"] },
|
|
247
|
-
},
|
|
248
|
-
input: { schemaId: "Page" },
|
|
249
|
-
output: { schemaId: "Policies", path: "policies" },
|
|
250
|
-
root: {
|
|
251
|
-
node: "chain",
|
|
252
|
-
steps: [
|
|
253
|
-
{ node: "extract", label: "quote", instructions: "Copy the lines of the page's text that are about refunds.", out: "Lines", as: "lines" },
|
|
254
|
-
{ node: "extract", label: "read", instructions: "Say the store's refund policy, from those lines.", out: "Policies", as: "policies" },
|
|
255
|
-
],
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
141
|
/** The longest answer read, in UTF-16 units: 8 notes at the note cap, a skill and a workflow draft at theirs, fenced,
|
|
259
142
|
* with room for a few lines around them. */
|
|
260
143
|
export const ANSWER_MAX = 100_000;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** The built-in tools a call node may run that read only: they change nothing outside the run (a web page or search read,
|
|
2
|
+
* a document's pages drawn into the run's own work/, one model completion). Every other built-in is a write. */
|
|
3
|
+
export declare const READ_TOOLS: readonly string[];
|
|
4
|
+
/** Why a replayed input is skipped, word for word: what a PromotionRecord's reason and the replay's row say. */
|
|
5
|
+
export declare const SKIPPED_WRITE = "needs a write the recording doesn't have";
|
|
6
|
+
/** `unmarked`: an MCP tool its server lists with no readOnlyHint and not destructive. A replay treats it as a write (nothing
|
|
7
|
+
* says it only reads), but its skip says why: the server may only have left the hint out (the hold's reason names it). */
|
|
8
|
+
export type ToolClass = "read" | "write" | "unmarked";
|
|
9
|
+
/** Whether `tool` (a catalog name) reads or writes: an MCP tool by `annotations` (its server's listing as the run's pin
|
|
10
|
+
* holds it, `{}` for a tool listed with none; undefined for one not listed): read only when readOnlyHint is true and
|
|
11
|
+
* destructiveHint is not, unmarked when it is listed with no readOnlyHint and not destructive; a built-in by READ_TOOLS;
|
|
12
|
+
* else write. */
|
|
13
|
+
export declare function toolClassOf(tool: string, annotations?: (tool: string) => Readonly<Record<string, unknown>> | undefined): ToolClass;
|
|
14
|
+
/** Why replay can't run MCP tools with no readOnlyHint (bare tool names, most-skipped first): "browse, fetch_page and 2
|
|
15
|
+
* more have no readOnlyHint, so replay can't run them: if they only read, mark them read-only in the MCP server". */
|
|
16
|
+
export declare function unmarkedWords(names: readonly string[]): string;
|
|
17
|
+
/** A catalog name as a person reads it in a reason: an MCP tool's own name, any other whole. */
|
|
18
|
+
export declare const toolWord: (tool: string) => string;
|
|
19
|
+
/** `value` as JSON with every object's keys sorted, at every depth: two argument objects that differ only in key order
|
|
20
|
+
* read the same. */
|
|
21
|
+
export declare function canonical(value: unknown): string;
|
|
22
|
+
/** A call's key: the tool's wire name (a catalog name or a wire name alike) and its canonical arguments. */
|
|
23
|
+
export declare const callKey: (tool: string, args: unknown) => string;
|
|
24
|
+
/** One recorded call's answer: its text, the structured details pi kept beside it (a built-in's whole value), and whether
|
|
25
|
+
* it ended an error. */
|
|
26
|
+
export type Recorded = {
|
|
27
|
+
readonly text: string;
|
|
28
|
+
readonly details?: unknown;
|
|
29
|
+
readonly isError: boolean;
|
|
30
|
+
};
|
|
31
|
+
type EntryLike = {
|
|
32
|
+
readonly kind: string;
|
|
33
|
+
readonly model?: readonly unknown[];
|
|
34
|
+
};
|
|
35
|
+
/** The calls a run's journal recorded (`entries`, pi-shaped: store-reads/journal.ts piShaped for a CLI's record), by
|
|
36
|
+
* callKey: each call's answer, the first one when a run made the same call twice. A call refused before it ran (its
|
|
37
|
+
* gate's deny) recorded no answer and is left out. */
|
|
38
|
+
export declare function recordedCalls(entries: readonly EntryLike[]): Map<string, Recorded>;
|
|
39
|
+
/** The write that stopped a replay's input: its tool and step, and `unmarked` when it is an MCP tool its server listed with
|
|
40
|
+
* no readOnlyHint (toolClassOf). */
|
|
41
|
+
export type Skipped = {
|
|
42
|
+
readonly tool: string;
|
|
43
|
+
readonly step: string;
|
|
44
|
+
readonly unmarked?: true;
|
|
45
|
+
};
|
|
46
|
+
/** A replay's call nodes (learned-workflow.ts runLearned's `run.replay`): `call` runs each by the rules above. `skipped`:
|
|
47
|
+
* the write that stopped it, once one did; `stop` aborts the workflow's run there. `live`: how many reads ran live. */
|
|
48
|
+
export interface ReplayCalls {
|
|
49
|
+
call(node: {
|
|
50
|
+
readonly label: string;
|
|
51
|
+
readonly tool: string;
|
|
52
|
+
}, args: unknown, live: () => Promise<unknown>): Promise<unknown>;
|
|
53
|
+
readonly skipped: Skipped | undefined;
|
|
54
|
+
readonly stop: AbortSignal;
|
|
55
|
+
readonly live: number;
|
|
56
|
+
}
|
|
57
|
+
/** What a call node throws when its write has no recording: the replay of this input stops. */
|
|
58
|
+
export declare class ReplaySkipped extends Error {
|
|
59
|
+
name: string;
|
|
60
|
+
}
|
|
61
|
+
/** The replay's call nodes over `recorded` (recordedCalls of the graded run), each tool classed by `classOf`. */
|
|
62
|
+
export declare function replayCalls(recorded: ReadonlyMap<string, Recorded>, classOf: (tool: string) => ToolClass): ReplayCalls;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// What a replay run's learned workflow does at each call node (SPEC B4: "re-run the draft offline on recorded inputs/
|
|
2
|
+
// outputs where possible, else live at workflow cost"; runner/promotion.ts starts the replay runs). Every tool is a read
|
|
3
|
+
// or a write (toolClassOf): an MCP tool by its server's own annotations (readOnlyHint true and not destructiveHint: read),
|
|
4
|
+
// a built-in by the fixed list READ_TOOLS, anything else a write (an MCP tool listed with no readOnlyHint too, its skip
|
|
5
|
+
// marked unmarked so the hold names it: a server that left the hint out holds every revision otherwise unexplained).
|
|
6
|
+
// - A read runs live through a cache keyed by (tool, canonical args), seeded from the graded run's recorded calls: a
|
|
7
|
+
// hit, recorded or already run in this replay, costs nothing and is never sent again.
|
|
8
|
+
// - A write is NEVER run in a replay: it is answered from the graded run's recording when a call there has the same
|
|
9
|
+
// tool and canonical args (its answer, an error included), else the replay of that input stops there and is skipped
|
|
10
|
+
// (SKIPPED_WRITE): no evidence either way, never scored wrong or failed (learn/refit.ts refitRowsOf).
|
|
11
|
+
// The recording is the graded run's own journal (a CLI's record shaped as pi's), each tool call by the wire name the
|
|
12
|
+
// harness called it by (catalog.ts wireName): a call node names its tool by catalog name, matched through the same map.
|
|
13
|
+
// Prior art: MCP's tool annotations (readOnlyHint, destructiveHint, 2025-03-26 spec) for the read/write line; VCR-style
|
|
14
|
+
// record/replay of HTTP interactions (Ruby's VCR, Python's vcrpy: a cassette answers a request that matches one recorded,
|
|
15
|
+
// a new one is refused in "none" record mode) for answering writes from the recording and refusing the rest.
|
|
16
|
+
import { wireName } from "../catalog.js";
|
|
17
|
+
import { LLM_TOOL } from "../llm.js";
|
|
18
|
+
import { PDF_PAGES_TOOL } from "../pdf-pages.js";
|
|
19
|
+
import { WEB_FETCH_TOOL } from "../web-fetch.js";
|
|
20
|
+
import { WEB_SEARCH_TOOL } from "../web-search.js";
|
|
21
|
+
import { CALL_REFUSED } from "../timeline/timeline.js";
|
|
22
|
+
/** The built-in tools a call node may run that read only: they change nothing outside the run (a web page or search read,
|
|
23
|
+
* a document's pages drawn into the run's own work/, one model completion). Every other built-in is a write. */
|
|
24
|
+
export const READ_TOOLS = [WEB_FETCH_TOOL, WEB_SEARCH_TOOL, PDF_PAGES_TOOL, LLM_TOOL];
|
|
25
|
+
/** Why a replayed input is skipped, word for word: what a PromotionRecord's reason and the replay's row say. */
|
|
26
|
+
export const SKIPPED_WRITE = "needs a write the recording doesn't have";
|
|
27
|
+
/** An MCP tool's catalog name, `mcp:<server>/<tool>`. */
|
|
28
|
+
const MCP_TOOL = /^mcp:([^/]+)\/(.+)$/;
|
|
29
|
+
/** Whether `tool` (a catalog name) reads or writes: an MCP tool by `annotations` (its server's listing as the run's pin
|
|
30
|
+
* holds it, `{}` for a tool listed with none; undefined for one not listed): read only when readOnlyHint is true and
|
|
31
|
+
* destructiveHint is not, unmarked when it is listed with no readOnlyHint and not destructive; a built-in by READ_TOOLS;
|
|
32
|
+
* else write. */
|
|
33
|
+
export function toolClassOf(tool, annotations) {
|
|
34
|
+
if (MCP_TOOL.test(tool)) {
|
|
35
|
+
const said = annotations?.(tool);
|
|
36
|
+
if (said?.destructiveHint === true)
|
|
37
|
+
return "write";
|
|
38
|
+
return said?.readOnlyHint === true ? "read" : said && said.readOnlyHint === undefined ? "unmarked" : "write";
|
|
39
|
+
}
|
|
40
|
+
return READ_TOOLS.includes(tool) ? "read" : "write";
|
|
41
|
+
}
|
|
42
|
+
/** Why replay can't run MCP tools with no readOnlyHint (bare tool names, most-skipped first): "browse, fetch_page and 2
|
|
43
|
+
* more have no readOnlyHint, so replay can't run them: if they only read, mark them read-only in the MCP server". */
|
|
44
|
+
export function unmarkedWords(names) {
|
|
45
|
+
const one = names.length === 1;
|
|
46
|
+
const list = names.length <= 3 ? names.join(", ").replace(/, ([^,]*)$/, " and $1") : `${names.slice(0, 2).join(", ")} and ${names.length - 2} more`;
|
|
47
|
+
return `${list} ${one ? "has" : "have"} no readOnlyHint, so replay can't run ${one ? "it" : "them"}: if ${one ? "it only reads, mark it" : "they only read, mark them"} read-only in the MCP server`;
|
|
48
|
+
}
|
|
49
|
+
/** A catalog name as a person reads it in a reason: an MCP tool's own name, any other whole. */
|
|
50
|
+
export const toolWord = (tool) => MCP_TOOL.exec(tool)?.[2] ?? tool;
|
|
51
|
+
/** `value` as JSON with every object's keys sorted, at every depth: two argument objects that differ only in key order
|
|
52
|
+
* read the same. */
|
|
53
|
+
export function canonical(value) {
|
|
54
|
+
if (Array.isArray(value))
|
|
55
|
+
return `[${value.map((one) => canonical(one === undefined ? null : one)).join(",")}]`;
|
|
56
|
+
if (value && typeof value === "object") {
|
|
57
|
+
const keys = Object.keys(value).filter((key) => value[key] !== undefined).sort();
|
|
58
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
|
|
59
|
+
}
|
|
60
|
+
return JSON.stringify(value ?? null);
|
|
61
|
+
}
|
|
62
|
+
/** A call's key: the tool's wire name (a catalog name or a wire name alike) and its canonical arguments. */
|
|
63
|
+
export const callKey = (tool, args) => `${wireName(tool)}\n${canonical(args ?? {})}`;
|
|
64
|
+
/** A tool result's text: a string, or its text blocks joined. */
|
|
65
|
+
const textOf = (content) => typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => (typeof part?.text === "string" ? [part.text] : [])).join("\n\n") : "";
|
|
66
|
+
/** The calls a run's journal recorded (`entries`, pi-shaped: store-reads/journal.ts piShaped for a CLI's record), by
|
|
67
|
+
* callKey: each call's answer, the first one when a run made the same call twice. A call refused before it ran (its
|
|
68
|
+
* gate's deny) recorded no answer and is left out. */
|
|
69
|
+
export function recordedCalls(entries) {
|
|
70
|
+
const asked = new Map();
|
|
71
|
+
const out = new Map();
|
|
72
|
+
for (const entry of entries) {
|
|
73
|
+
for (const message of entry.model ?? []) {
|
|
74
|
+
const one = (message ?? {});
|
|
75
|
+
if (entry.kind === "pi.assistant" && Array.isArray(one.content)) {
|
|
76
|
+
for (const part of one.content) {
|
|
77
|
+
const call = (part ?? {});
|
|
78
|
+
if (call.type === "toolCall" && typeof call.id === "string" && typeof call.name === "string")
|
|
79
|
+
asked.set(call.id, { name: call.name, args: call.arguments ?? {} });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (entry.kind !== "pi.tool-result" || typeof one.toolCallId !== "string")
|
|
83
|
+
continue;
|
|
84
|
+
const call = asked.get(one.toolCallId);
|
|
85
|
+
const details = one.details;
|
|
86
|
+
if (!call || details?.[CALL_REFUSED] === true)
|
|
87
|
+
continue;
|
|
88
|
+
const key = callKey(call.name, call.args);
|
|
89
|
+
if (!out.has(key))
|
|
90
|
+
out.set(key, { text: textOf(one.content), ...(details !== undefined ? { details } : {}), isError: one.isError === true });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
/** A recorded answer as the value a call node of `tool` takes: an MCP tool's text as JSON when it parses, else `{ text }`
|
|
96
|
+
* (learned-workflow.ts mcpValue, as its live call gives it); a built-in's structured details, as its effect returns
|
|
97
|
+
* them, else none (its text is what a model read, not its value). */
|
|
98
|
+
const recordedValue = (tool, recorded) => {
|
|
99
|
+
if (MCP_TOOL.test(tool)) {
|
|
100
|
+
try {
|
|
101
|
+
return { value: JSON.parse(recorded.text) };
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return { value: { text: recorded.text } };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return recorded.details && typeof recorded.details === "object" ? { value: recorded.details } : undefined;
|
|
108
|
+
};
|
|
109
|
+
/** What a call node throws when its write has no recording: the replay of this input stops. */
|
|
110
|
+
export class ReplaySkipped extends Error {
|
|
111
|
+
name = "ReplaySkipped";
|
|
112
|
+
}
|
|
113
|
+
/** The replay's call nodes over `recorded` (recordedCalls of the graded run), each tool classed by `classOf`. */
|
|
114
|
+
export function replayCalls(recorded, classOf) {
|
|
115
|
+
const cache = new Map();
|
|
116
|
+
const stop = new AbortController();
|
|
117
|
+
let skipped;
|
|
118
|
+
let live = 0;
|
|
119
|
+
return {
|
|
120
|
+
get skipped() {
|
|
121
|
+
return skipped;
|
|
122
|
+
},
|
|
123
|
+
stop: stop.signal,
|
|
124
|
+
get live() {
|
|
125
|
+
return live;
|
|
126
|
+
},
|
|
127
|
+
async call(node, args, run) {
|
|
128
|
+
const key = callKey(node.tool, args);
|
|
129
|
+
const said = recorded.get(key);
|
|
130
|
+
const kind = classOf(node.tool);
|
|
131
|
+
if (kind !== "read") {
|
|
132
|
+
// Never run: the recording's answer, or the input is skipped here.
|
|
133
|
+
const value = said ? recordedValue(node.tool, said) : undefined;
|
|
134
|
+
if (said && value) {
|
|
135
|
+
if (said.isError)
|
|
136
|
+
throw new Error(said.text);
|
|
137
|
+
return value.value;
|
|
138
|
+
}
|
|
139
|
+
skipped ??= { tool: node.tool, step: node.label, ...(kind === "unmarked" ? { unmarked: true } : {}) };
|
|
140
|
+
stop.abort(new ReplaySkipped(`${node.tool} ${SKIPPED_WRITE}`));
|
|
141
|
+
throw new ReplaySkipped(`call node "${node.label}": ${node.tool} ${SKIPPED_WRITE}`);
|
|
142
|
+
}
|
|
143
|
+
// A read: the recording's answer (an error there is run live instead), else this replay's own, else live once.
|
|
144
|
+
const value = said && !said.isError ? recordedValue(node.tool, said) : undefined;
|
|
145
|
+
if (value)
|
|
146
|
+
return value.value;
|
|
147
|
+
const known = cache.get(key);
|
|
148
|
+
if (known)
|
|
149
|
+
return known;
|
|
150
|
+
live += 1;
|
|
151
|
+
const running = run();
|
|
152
|
+
cache.set(key, running);
|
|
153
|
+
// A read that failed is not kept: the next call of it runs live again.
|
|
154
|
+
running.catch(() => cache.delete(key));
|
|
155
|
+
return running;
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
package/dist/learn/skills.d.ts
CHANGED
|
@@ -146,6 +146,11 @@ type Synthesized = {
|
|
|
146
146
|
};
|
|
147
147
|
/** What the DSL's synthesizeInstance would build of `schema` over `definitions`, counted without building it. */
|
|
148
148
|
export declare const synthesizedSize: (schema: unknown, definitions?: Readonly<Record<string, unknown>>) => Synthesized;
|
|
149
|
+
/** The nodes directly inside `node`, as the DSL reads them (recovery/execution-path.ts childrenOf): a chain's steps, a
|
|
150
|
+
* parallel's branches, a map's or a loop's body, a route's branch bodies. A composed workflow node's child is a
|
|
151
|
+
* workflow, walked as one (eachWorkflow). Only these are node positions: an object anywhere else (a schema, a const, a
|
|
152
|
+
* step's literal value) is data, never a node, whatever keys it holds. */
|
|
153
|
+
export declare function childNodes(node: Record<string, unknown>): unknown[];
|
|
149
154
|
/** The most iterations one loop of a learned draft may run (its maxIters), and the most nested loops may run together
|
|
150
155
|
* (their maxIters multiplied, outermost to innermost). A loop's iterations are work the dry run does in the host whether
|
|
151
156
|
* or not its body asks a model (an empty map, a predicate), so they are bounded here, not only by the dry run's steps. */
|
|
@@ -169,10 +174,17 @@ export declare function synthesisProblems(doc: unknown, dsl: SchemaResolver): st
|
|
|
169
174
|
* line, one JSON object), else on an input synthesized from its input schema. Every model, Jev and tool-call answer is
|
|
170
175
|
* synthesized from the node's output schema: no request is sent, nothing is paid, no tool runs, and no code it holds
|
|
171
176
|
* runs in this process (refuseCode). Only a draft the static checks pass is dry-run (propose.ts). It checks the wiring
|
|
172
|
-
* at run time (the state each step reads, its output's path and schema), never the answers.
|
|
177
|
+
* at run time (the state each step reads, its output's path and schema), never the answers. With `outputSchema` (the
|
|
178
|
+
* agent's), the output of a run that passed is held to it as a run serving the draft serves it (answer-json.ts
|
|
179
|
+
* answerAsServed over the tool's text, learned-workflow.ts learnedOutput) as far as its placeholders can decide: its
|
|
180
|
+
* shape (shapeOf: the fields, their types, the required ones). One whose shape can't meet it fails, in the schema's
|
|
181
|
+
* words, since every run it served would go back to the agent; a value constraint (a pattern, an enum, a bound) stays
|
|
182
|
+
* undecided on a placeholder, and holds a value only where the dry run has a real one (its example's own, handed
|
|
183
|
+
* through). A text answer is synthetic here, and serving takes text whose json block meets the schema, so text fails
|
|
184
|
+
* only against a schema that does not compile, as every answer does. */
|
|
173
185
|
export declare function draftDryRun(dsl: {
|
|
174
186
|
readonly dryRunWorkflow: typeof dryRunWorkflow;
|
|
175
|
-
} & SchemaResolver, json: string, example?: string): Promise<DraftDryRun>;
|
|
187
|
+
} & SchemaResolver, json: string, example?: string, outputSchema?: unknown): Promise<DraftDryRun>;
|
|
176
188
|
/** The refusal for a draft that names a tool when the host gave no tool list: the check fails closed. */
|
|
177
189
|
export declare const NO_TOOL_LIST = "no tool list was given, so a draft that names a tool is refused";
|
|
178
190
|
export type DraftProblem = {
|
|
@@ -226,13 +238,9 @@ export declare const deniedDecisionWords: (provider: string, from: SettingFrom |
|
|
|
226
238
|
/** Where a deny was set (tool-gate.ts SettingFrom), and its words (tool-gate.ts denyPlace), kept here so the learn
|
|
227
239
|
* module needs no import of the gate. */
|
|
228
240
|
type SettingFrom = "agent" | "server" | "default";
|
|
229
|
-
/** An MCP tool a learned workflow's call node may run, by its address (`via: "tool"`, `tool: "mcp:<server>/<tool>"`,
|
|
230
|
-
* LS-07): its server's name as a server is named (mcp-probe.ts MCP_SERVER_NAME) and one tool's name in MCP's own
|
|
231
|
-
* charset, never a wildcard. The one rule for it: the tools a draft may name (tools.ts learnedWorkflowTools), the
|
|
232
|
-
* end-of-run prompt that prints them (reflect.ts), and what the grader is told of a draft (grade.ts). */
|
|
233
|
-
export declare const LEARNED_MCP_TOOL: RegExp;
|
|
234
241
|
/** The MCP tools a draft's call nodes run, each once, in the order they come (LS-07): every call node in `doc`, nested
|
|
235
|
-
* ones too, whose tool is
|
|
242
|
+
* ones too, whose tool is one MCP tool's name (`via: "tool"`, `tool: "mcp:<server>/<tool>"`, tool-names.ts mcpNameOf),
|
|
243
|
+
* never a wildcard. Read from the JSON as it is, for the grader's words; never a check. */
|
|
236
244
|
export declare function draftMcpTools(doc: unknown): string[];
|
|
237
245
|
/** One step of a learned workflow that runs an MCP tool with no declared per-call price: its label, the tool and its
|
|
238
246
|
* server. */
|
|
@@ -242,7 +250,7 @@ export type UnpricedCall = {
|
|
|
242
250
|
readonly server: string;
|
|
243
251
|
};
|
|
244
252
|
/** The call nodes of a learned workflow (`doc`, its parsed workflow.json, nested ones too) whose tool is an MCP tool
|
|
245
|
-
* (
|
|
253
|
+
* (tool-names.ts mcpNameOf) that `priceOf` gives no price for (mcp-probe.ts McpPrices: none declared). Such a tool runs "not
|
|
246
254
|
* metered", outside the run's cost and cap (mcp-gateway.ts), so a learned workflow that calls one unattended waits for
|
|
247
255
|
* its owner's OK whatever the grade (LS-07): a structural fact, held in code. Each step once, in order. */
|
|
248
256
|
export declare function unpricedCalls(doc: unknown, priceOf: (tool: string) => number | undefined): UnpricedCall[];
|
|
@@ -266,11 +274,6 @@ export declare const LEARNED_MAX_TURNS = 8;
|
|
|
266
274
|
* learned runner cannot run (LEARNED_NODES: a judge's on a run with no `decisions`; with them, one whose provider the run
|
|
267
275
|
* lacks or its gate holds to ask or deny). With no list it
|
|
268
276
|
* fails closed: a draft the DSL refuses only once given an empty list names a tool. */
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
export type DraftAsk = {
|
|
272
|
-
readonly asked: readonly string[];
|
|
273
|
-
readonly fits: (asks: readonly string[]) => boolean;
|
|
274
|
-
};
|
|
275
|
-
export declare function draftProblems(dsl: DraftReader, text: string, tools?: readonly string[], gated?: Readonly<Record<string, string>>, deniedBy?: Readonly<Record<string, SettingFrom>>, ask?: DraftAsk, decisions?: DraftDecisions): DraftProblem[];
|
|
277
|
+
/** `decisions` is the managed host's registry; `adapters` is an explicit backend callback contract, when supplied. */
|
|
278
|
+
export declare function draftProblems(dsl: DraftReader, text: string, tools?: readonly string[], gated?: Readonly<Record<string, string>>, deniedBy?: Readonly<Record<string, SettingFrom>>, decisions?: DraftDecisions, adapters?: readonly ("runNode" | "runJudge")[]): DraftProblem[];
|
|
276
279
|
export {};
|