@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36
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 +263 -0
- package/README.md +339 -179
- package/dist/adapters.d.ts +15 -2
- package/dist/adapters.js +34 -2
- package/dist/agent-rows.d.ts +3 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +25 -5
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +90 -8
- package/dist/archil-settings.js +150 -14
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/bash-read-only.d.ts +13 -0
- package/dist/bash-read-only.js +77 -0
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +2 -2
- package/dist/browser-cost.js +6 -4
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +19 -44
- package/dist/cap.js +31 -77
- package/dist/cli.js +36 -27
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -57
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +8 -5
- package/dist/computer-setting.js +91 -26
- package/dist/computer-view.d.ts +11 -2
- package/dist/computer-view.js +2 -1
- package/dist/computers.d.ts +54 -8
- package/dist/computers.js +101 -22
- package/dist/console/assets/index-BI4Byidu.js +550 -0
- package/dist/console/assets/index-C19gUF2n.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +8 -5
- package/dist/explain.js +3 -1
- package/dist/faux-computers.js +4 -0
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +28 -4
- package/dist/github.js +46 -10
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +2 -0
- package/dist/graph-view.js +29 -2
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness.js +1 -1
- package/dist/host-tools.d.ts +8 -9
- package/dist/host-tools.js +7 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +126 -8
- package/dist/learn/commit.d.ts +40 -6
- package/dist/learn/commit.js +164 -20
- package/dist/learn/folder.d.ts +11 -3
- package/dist/learn/folder.js +40 -16
- package/dist/learn/grade.d.ts +22 -2
- package/dist/learn/grade.js +127 -19
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +11 -13
- package/dist/learn/notes.d.ts +17 -3
- package/dist/learn/notes.js +19 -6
- package/dist/learn/reflect.d.ts +5 -2
- package/dist/learn/reflect.js +48 -32
- package/dist/learn/skills.d.ts +52 -5
- package/dist/learn/skills.js +104 -21
- package/dist/learned-nodes.d.ts +18 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +27 -13
- package/dist/learned-workflow.js +110 -38
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-routes.d.ts +48 -2
- package/dist/learning-routes.js +99 -28
- package/dist/learning-run.d.ts +7 -5
- package/dist/learning-run.js +9 -6
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +6 -2
- package/dist/learning.d.ts +13 -28
- package/dist/learning.js +4 -18
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +11 -1
- package/dist/mcp-probe.d.ts +8 -1
- package/dist/mcp-probe.js +62 -20
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +12 -12
- package/dist/mcp-servers-store.js +8 -3
- package/dist/model.d.ts +8 -5
- package/dist/model.js +14 -6
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +236 -55
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/place-offers.d.ts +97 -0
- package/dist/place-offers.js +206 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +22 -32
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +31 -9
- package/dist/print.d.ts +1 -8
- package/dist/print.js +1 -14
- package/dist/propose.d.ts +3 -0
- package/dist/propose.js +25 -19
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-db.js +3 -3
- package/dist/run-launch.d.ts +18 -3
- package/dist/run-launch.js +11 -5
- package/dist/run-learning-served.d.ts +12 -1
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +4 -2
- package/dist/run-reads-over-store.js +10 -8
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.js +60 -38
- package/dist/run-view.d.ts +35 -16
- package/dist/run-view.js +64 -35
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +20 -4
- package/dist/runner/adapter-loop.d.ts +46 -5
- package/dist/runner/adapter-loop.js +381 -56
- package/dist/runner/adapter-run-spec.d.ts +46 -4
- package/dist/runner/adapter-run-spec.js +200 -45
- package/dist/runner/adapters/pi.d.ts +39 -3
- package/dist/runner/adapters/pi.js +124 -29
- package/dist/runner/beside.d.ts +8 -0
- package/dist/runner/beside.js +24 -2
- package/dist/runner/claim-secrets.d.ts +6 -0
- package/dist/runner/claim-secrets.js +15 -1
- package/dist/runner/cli-run-spec.d.ts +10 -0
- package/dist/runner/cli-run-spec.js +207 -64
- package/dist/runner/commands.d.ts +5 -1
- package/dist/runner/commands.js +3 -3
- package/dist/runner/conformance/harness.d.ts +1 -1
- package/dist/runner/conformance/harness.js +13 -10
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +46 -15
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +24 -1
- package/dist/runner/journal-kinds.d.ts +53 -7
- package/dist/runner/journal-kinds.js +29 -1
- package/dist/runner/learning-end.d.ts +15 -0
- package/dist/runner/learning-end.js +113 -20
- package/dist/runner/learning-factory.js +6 -2
- package/dist/runner/learning-loop.d.ts +75 -1
- package/dist/runner/learning-loop.js +215 -22
- package/dist/runner/learning-seed.d.ts +8 -0
- package/dist/runner/learning-seed.js +7 -1
- package/dist/runner/loop-contract.d.ts +12 -0
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +20 -0
- package/dist/runner/main.d.ts +9 -4
- package/dist/runner/main.js +38 -13
- package/dist/runner/mcp-claim.d.ts +7 -0
- package/dist/runner/mcp-claim.js +35 -2
- package/dist/runner/mcp-github.d.ts +15 -4
- package/dist/runner/mcp-github.js +55 -11
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +2 -0
- package/dist/runner/metrics.d.ts +18 -1
- package/dist/runner/metrics.js +81 -1
- package/dist/runner/model-route.d.ts +6 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +59 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +1 -0
- package/dist/runner/reflect-hook.js +3 -3
- package/dist/runner/runner.js +136 -19
- package/dist/runner/spec-holds.d.ts +13 -3
- package/dist/runner/spec-holds.js +13 -10
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/store-secrets.js +17 -1
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +188 -0
- package/dist/runner/workflow-host.d.ts +25 -4
- package/dist/runner/workflow-host.js +26 -4
- package/dist/runner/workflow-loop.d.ts +9 -3
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +28 -13
- package/dist/runner/workflow-spec.js +247 -102
- package/dist/runs-over-store.d.ts +18 -7
- package/dist/runs-over-store.js +149 -31
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +0 -2
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/server-lock.js +4 -5
- package/dist/server.d.ts +49 -63
- package/dist/server.js +429 -230
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +22 -8
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +49 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.d.ts +4 -0
- package/dist/store/postgres/connection.js +64 -13
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +11 -8
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -82
- package/dist/store/sqlite/run-patch.d.ts +18 -2
- package/dist/store/sqlite/run-patch.js +31 -2
- package/dist/store/sqlite/store.js +65 -11
- package/dist/store/store.d.ts +62 -12
- package/dist/store/store.js +22 -1
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +1 -3
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/journal.js +83 -15
- package/dist/store-reads/learning.d.ts +73 -3
- package/dist/store-reads/learning.js +232 -9
- package/dist/store-reads/runs.d.ts +6 -4
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-view.d.ts +15 -1
- package/dist/store-view.js +88 -29
- package/dist/template-eval.js +2 -1
- package/dist/templates.d.ts +73 -4
- package/dist/templates.js +113 -23
- package/dist/timeline/timeline.d.ts +11 -1
- package/dist/timeline/timeline.js +19 -4
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +26 -0
- package/dist/tool-budget.js +56 -0
- package/dist/tool-gate.d.ts +13 -3
- package/dist/tool-gate.js +15 -7
- package/dist/tool-plane.d.ts +42 -29
- package/dist/tool-plane.js +64 -27
- package/dist/tools.d.ts +53 -39
- package/dist/tools.js +174 -79
- package/dist/trigger-signatures.d.ts +1 -0
- package/dist/trigger-signatures.js +3 -1
- package/dist/triggers.d.ts +3 -3
- package/dist/triggers.js +2 -2
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +82 -9
- package/dist/usage-lines.d.ts +1 -1
- package/dist/usage.d.ts +1 -47
- package/dist/usage.js +3 -82
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +40 -3
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -2
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +112 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +88 -0
- package/dist/workflow/node.js +99 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +9 -0
- package/dist/workflow/pi-versions.js +8 -0
- package/dist/workflow/readers.d.ts +36 -0
- package/dist/workflow/readers.js +145 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +76 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +411 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow/wal.d.ts +11 -0
- package/dist/workflow/wal.js +106 -0
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +13 -2
- package/dist/workspace/archil-claim.js +22 -13
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +18 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/computer-deps.d.ts +18 -11
- package/dist/workspace/computer-deps.js +64 -40
- package/dist/workspace/computer-for-claim.d.ts +47 -9
- package/dist/workspace/computer-for-claim.js +236 -24
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +3 -8
- package/dist/workspace/computer-ledger.js +7 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +5 -4
- package/dist/workspace/index.js +2 -1
- package/dist/workspace/local.d.ts +3 -0
- package/dist/workspace/local.js +9 -0
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +48 -12
- package/dist/workspace/resolve-computer.js +88 -19
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +6 -4
- package/dist/workspace/run-tools.js +17 -9
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +2 -15
- package/package.json +11 -16
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -8
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/release-notes/agent.md +11 -0
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -76
- package/dist/budget.js +0 -204
- package/dist/console/assets/index-RPHGlXmM.js +0 -540
- package/dist/console/assets/index-opTN5Naq.css +0 -1
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/templates/code-review/rules/REVIEW.md +0 -41
package/dist/learn/reflect.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export declare const DRAFT_AFTER_RUNS = 3;
|
|
|
15
15
|
* name: the prompt gains one line asking for that job as a workflow draft. None when not given. `described`, with a
|
|
16
16
|
* draft asked for: what each of `tools` takes and gives a call node, in the server's own words (tools.ts ToolEntry
|
|
17
17
|
* summary), said under the ask, one line each (at most DESCRIBED_MAX characters, unseen characters and line breaks made
|
|
18
|
-
* spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for.
|
|
18
|
+
* spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. `workflows`, false
|
|
19
|
+
* for a run of a revision that says `learning: "notes"`: the prompt asks for notes and a skill alone, says to keep no
|
|
20
|
+
* workflow draft, and asks for none (`draftFor` and `described` are not said). */
|
|
19
21
|
export declare function reflectPrompt(options: {
|
|
20
22
|
dir: string;
|
|
21
23
|
active: number;
|
|
@@ -25,10 +27,11 @@ export declare function reflectPrompt(options: {
|
|
|
25
27
|
readonly name: string;
|
|
26
28
|
readonly does: string;
|
|
27
29
|
}[];
|
|
30
|
+
workflows?: boolean;
|
|
28
31
|
}): string;
|
|
29
32
|
/** The end-of-run turn asked again, once, when the parser refused its answer: why, in the parser's own words (`detail`,
|
|
30
33
|
* parseReflection's), and the whole answer again in the format. */
|
|
31
|
-
export declare function reflectAgain(detail: string): string;
|
|
34
|
+
export declare function reflectAgain(detail: string, workflows?: false): string;
|
|
32
35
|
/** The end-of-run turn asked again, once, when the checks left a workflow draft out because its dry run failed: which
|
|
33
36
|
* 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,
|
|
34
37
|
* 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
|
@@ -6,7 +6,7 @@
|
|
|
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 { SKILL_NAME } from "./skills.js";
|
|
9
|
+
import { LEARNED_MCP_TOOL, SKILL_NAME } from "./skills.js";
|
|
10
10
|
/** Control and invisible characters: none may reach the prompt through a value the host puts in it. */
|
|
11
11
|
const UNSEEN = /[\p{Cc}\p{Cf}]/u;
|
|
12
12
|
/** The info word that opens a note's block in the answer: ```note <file>. */
|
|
@@ -18,8 +18,10 @@ export const WORKFLOW_BLOCK = "workflow";
|
|
|
18
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
19
|
* draft (`draftFor`): a run proposes one only when it thinks to, and few do. */
|
|
20
20
|
export const DRAFT_AFTER_RUNS = 3;
|
|
21
|
-
/** A tool's name as the prompt may print it.
|
|
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). */
|
|
22
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);
|
|
23
25
|
/** The end-of-run turn's message. `dir` is the run's copy of the folder relative to the run's workspace (`.learning`),
|
|
24
26
|
* where the agent can read its notes: the prompt never names a path of the host's, which a box would not see. `active`
|
|
25
27
|
* is how many notes are active in it, so how many lines the index has left. `tools`, the tools a workflow draft's
|
|
@@ -28,14 +30,16 @@ const TOOL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
|
28
30
|
* name: the prompt gains one line asking for that job as a workflow draft. None when not given. `described`, with a
|
|
29
31
|
* draft asked for: what each of `tools` takes and gives a call node, in the server's own words (tools.ts ToolEntry
|
|
30
32
|
* summary), said under the ask, one line each (at most DESCRIBED_MAX characters, unseen characters and line breaks made
|
|
31
|
-
* spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for.
|
|
33
|
+
* spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. `workflows`, false
|
|
34
|
+
* for a run of a revision that says `learning: "notes"`: the prompt asks for notes and a skill alone, says to keep no
|
|
35
|
+
* workflow draft, and asks for none (`draftFor` and `described` are not said). */
|
|
32
36
|
export function reflectPrompt(options) {
|
|
33
|
-
const { dir, active, tools = [], draftFor = [], described = [] } = options;
|
|
37
|
+
const { dir, active, tools = [], draftFor = [], described = [], workflows = true } = options;
|
|
34
38
|
if (typeof dir !== "string" || dir === "" || dir.startsWith("/") || UNSEEN.test(dir))
|
|
35
39
|
throw new Error("the directory must be a path relative to the run's workspace, with no control or unseen characters");
|
|
36
40
|
if (!Number.isSafeInteger(active) || active < 0)
|
|
37
41
|
throw new Error("the count of active notes must be a whole number, 0 or more");
|
|
38
|
-
if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== "string" || !
|
|
42
|
+
if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== "string" || !printable(tool)))
|
|
39
43
|
throw new Error("each tool must be a tool's name");
|
|
40
44
|
if (!Array.isArray(draftFor) || draftFor.some((name) => typeof name !== "string" || !SKILL_NAME.test(name)))
|
|
41
45
|
throw new Error("each skill a draft is asked for must be a skill's name");
|
|
@@ -81,19 +85,29 @@ export function reflectPrompt(options) {
|
|
|
81
85
|
"site, a source or a seller, or names where money or data goes.",
|
|
82
86
|
"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.",
|
|
83
87
|
"",
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
...(workflows ? [
|
|
89
|
+
"## Skills and workflow drafts, only when the work repeats",
|
|
90
|
+
"",
|
|
91
|
+
"When this run did, to the end, a job this agent will be asked to do again, you may also keep one skill and one",
|
|
92
|
+
"workflow draft for that job. Most runs keep neither. Neither holds this case's data: each is about the job, not the one case.",
|
|
93
|
+
] : [
|
|
94
|
+
"## Skills, only when the work repeats",
|
|
95
|
+
"",
|
|
96
|
+
"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.",
|
|
97
|
+
"Most runs keep none. It holds none of this case's data: it is about the job, not the one case.",
|
|
98
|
+
"Keep no workflow draft: this agent learns notes and skills alone.",
|
|
99
|
+
]),
|
|
88
100
|
"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",
|
|
89
101
|
"their words and with the exact output format they gave, and do not repeat them in a note.",
|
|
90
102
|
"A job you keep a skill for needs no note beside it.",
|
|
91
103
|
"A rule for every reply applies whatever the job is. Keep it as a note, which every later run reads. Steps or a format",
|
|
92
104
|
"for one kind of job, named by when it applies (\"whenever I ask for a weekly summary\", \"when you open a PR\"), are a",
|
|
93
105
|
"skill. A note holds its own lesson: never repeat another note's rule in it, so a retired rule stays retired.",
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
...(workflows ? [
|
|
107
|
+
"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,",
|
|
108
|
+
"and so is one the person asks you to keep as a workflow; its steps may also be a skill.",
|
|
109
|
+
...(draftFor.length ? [draftAsk(draftFor), ...describedLines(described, tools)] : []),
|
|
110
|
+
] : []),
|
|
97
111
|
"",
|
|
98
112
|
`A skill is how to do the job, step by step, as a SKILL.md: front matter with its \`name\` (lowercase letters, digits`,
|
|
99
113
|
"and single dashes) and a `description` of when to use it, then the steps. Open its block with four backticks, so a",
|
|
@@ -108,22 +122,24 @@ export function reflectPrompt(options) {
|
|
|
108
122
|
"1. Open the store's policies page first.",
|
|
109
123
|
"````",
|
|
110
124
|
"",
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
...(workflows ? [
|
|
126
|
+
"A workflow draft does the job as one workflow DSL document: front matter with one line that says what it does and",
|
|
127
|
+
"when to use it, then the JSON. It uses model and tool-call nodes only: no judge, pick or sift node, no code node, no shell or",
|
|
128
|
+
`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.`,
|
|
129
|
+
"To change a draft you were given, give it again whole under its name.",
|
|
130
|
+
"Its schemas are declared once under `schemas`, and `input` and `output` name one each by `schemaId`, never a schema",
|
|
131
|
+
"written in place.",
|
|
132
|
+
"Give its front matter an `example:` line too: one JSON object on one line, the input this run would have given it.",
|
|
133
|
+
"The host dry-runs the draft on it before it is kept (no model or tool is called) and never keeps the example.",
|
|
134
|
+
"",
|
|
135
|
+
`\`\`\`\`${WORKFLOW_BLOCK} find-policies`,
|
|
136
|
+
"---",
|
|
137
|
+
"description: Finds a store's refund policy from its public pages; use when a case asks for it",
|
|
138
|
+
`example: ${JSON.stringify(tools.includes("web_fetch") ? { url: "https://shop.example/policies" } : { text: "Refunds are accepted within 30 days of delivery." })}`,
|
|
139
|
+
"---",
|
|
140
|
+
JSON.stringify(exampleDraft(tools.includes("web_fetch"))),
|
|
141
|
+
"````",
|
|
142
|
+
] : []),
|
|
127
143
|
].join("\n");
|
|
128
144
|
}
|
|
129
145
|
/** The most of one tool's words the draft ask's description gives it. */
|
|
@@ -144,13 +160,13 @@ const describedLines = (described, tools) => {
|
|
|
144
160
|
const draftAsk = (names) => {
|
|
145
161
|
const listed = names.map((name) => `\`${name}\``).join(", ");
|
|
146
162
|
return names.length === 1
|
|
147
|
-
? `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.`
|
|
148
|
-
: `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.`;
|
|
163
|
+
? `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.`
|
|
164
|
+
: `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.`;
|
|
149
165
|
};
|
|
150
166
|
/** The end-of-run turn asked again, once, when the parser refused its answer: why, in the parser's own words (`detail`,
|
|
151
167
|
* parseReflection's), and the whole answer again in the format. */
|
|
152
|
-
export function reflectAgain(detail) {
|
|
153
|
-
return `Your answer could not be read: ${detail}. Give the whole answer again in the format asked for above, every note, skill and workflow block in it, and nothing else.`;
|
|
168
|
+
export function reflectAgain(detail, workflows) {
|
|
169
|
+
return `Your answer could not be read: ${detail}. Give the whole answer again in the format asked for above, every ${workflows === false ? "note and skill" : "note, skill and workflow"} block in it, and nothing else.`;
|
|
154
170
|
}
|
|
155
171
|
/** The end-of-run turn asked again, once, when the checks left a workflow draft out because its dry run failed: which
|
|
156
172
|
* 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,
|
package/dist/learn/skills.d.ts
CHANGED
|
@@ -74,22 +74,41 @@ export declare const isHeld: (text: string) => boolean;
|
|
|
74
74
|
* retiredLearned), which take the `status:` line out whole, can edit. One set any other way reads unclear (learnedStatus:
|
|
75
75
|
* retired), never held or active, and no writer edits it, so a write never leaves part of it behind. The host writes
|
|
76
76
|
* only one-line statuses (held, retiredLearned). */
|
|
77
|
-
export declare
|
|
77
|
+
export declare const statusOnOneLine: (text: string) => boolean;
|
|
78
78
|
/** `text`, a SKILL.md or a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
|
|
79
79
|
* pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
|
|
80
80
|
* passes. */
|
|
81
81
|
export declare function held(text: string): string;
|
|
82
82
|
/** `text`, a held SKILL.md or draft README.md, as the host leaves it when its owner approves it: its front matter with
|
|
83
|
-
* no `status` line, so it is given to every later run. Throws on a text with no front matter. */
|
|
83
|
+
* no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
|
|
84
84
|
export declare function released(text: string): string;
|
|
85
|
+
/** The status a retired SKILL.md or draft README.md goes back to when a person restores it (`retired_from`, which its
|
|
86
|
+
* retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
|
|
87
|
+
* `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
|
|
88
|
+
* them (fail closed: only an approval makes a skill or a draft active). */
|
|
89
|
+
export declare function retiredFrom(text: string): "active" | "pending";
|
|
90
|
+
/** Whether a retired SKILL.md or draft README.md can be restored by the host's writer: its front matter reads one way
|
|
91
|
+
* (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
|
|
92
|
+
* One that is not is refused until it is written so (a restore never edits half a value). */
|
|
93
|
+
export declare const restorable: (text: string) => boolean;
|
|
94
|
+
/** `text`, a retired SKILL.md or draft README.md, as the host leaves it when a person restores it: back in the status its
|
|
95
|
+
* retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
|
|
96
|
+
* one way, or whose status is not one plain line (released). */
|
|
97
|
+
export declare const restoredLearned: (text: string) => string;
|
|
85
98
|
/** What a SKILL.md or a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
|
|
86
99
|
* the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
|
|
87
100
|
* it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
|
|
88
101
|
* of these, is `retired`: never active, since another reader could read it as held or retired; no run is given it, and
|
|
89
102
|
* a restore refuses it until it reads one way. A run is given only an active one. */
|
|
90
103
|
export declare function learnedStatus(text: string): "active" | "pending" | "retired";
|
|
91
|
-
/** `text
|
|
92
|
-
*
|
|
104
|
+
/** Whether `text` reads retired (learnedStatus) only because it can't be read: its front matter reads no way, its status
|
|
105
|
+
* is not one plain line, or its status is none the host writes. No one retired it: a view says the host could not read
|
|
106
|
+
* it, never that a run or a person retired it. */
|
|
107
|
+
export declare function unclearFront(text: string): boolean;
|
|
108
|
+
/** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
|
|
109
|
+
* status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
|
|
110
|
+
* them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
|
|
111
|
+
* matter. */
|
|
93
112
|
export declare function retiredLearned(text: string): string;
|
|
94
113
|
/** A draft's `README.md` as the host writes it, from the workflow's name and the one-line description its block gives. */
|
|
95
114
|
export declare const readmeOf: (name: string, description: string) => string;
|
|
@@ -180,6 +199,28 @@ export declare const LEARNED_NODES = "a learned workflow runs model and tool-cal
|
|
|
180
199
|
/** Where a deny was set (tool-gate.ts SettingFrom), and its words (tool-gate.ts denyPlace), kept here so the learn
|
|
181
200
|
* module needs no import of the gate. */
|
|
182
201
|
type SettingFrom = "agent" | "server" | "default";
|
|
202
|
+
/** An MCP tool a learned workflow's call node may run, by its address (`via: "tool"`, `tool: "mcp:<server>/<tool>"`,
|
|
203
|
+
* 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
|
|
204
|
+
* charset, never a wildcard. The one rule for it: the tools a draft may name (tools.ts learnedWorkflowTools), the
|
|
205
|
+
* end-of-run prompt that prints them (reflect.ts), and what the grader is told of a draft (grade.ts). */
|
|
206
|
+
export declare const LEARNED_MCP_TOOL: RegExp;
|
|
207
|
+
/** The MCP tools a draft's call nodes run, each once, in the order they come (LS-07): every call node in `doc`, nested
|
|
208
|
+
* ones too, whose tool is an MCP tool's address. Read from the JSON as it is, for the grader's words; never a check. */
|
|
209
|
+
export declare function draftMcpTools(doc: unknown): string[];
|
|
210
|
+
/** One step of a learned workflow that runs an MCP tool with no declared per-call price: its label, the tool and its
|
|
211
|
+
* server. */
|
|
212
|
+
export type UnpricedCall = {
|
|
213
|
+
readonly label: string;
|
|
214
|
+
readonly tool: string;
|
|
215
|
+
readonly server: string;
|
|
216
|
+
};
|
|
217
|
+
/** The call nodes of a learned workflow (`doc`, its parsed workflow.json, nested ones too) whose tool is an MCP tool
|
|
218
|
+
* (LEARNED_MCP_TOOL) that `priceOf` gives no price for (mcp-probe.ts McpPrices: none declared). Such a tool runs "not
|
|
219
|
+
* metered", outside the run's cost and cap (mcp-gateway.ts), so a learned workflow that calls one unattended waits for
|
|
220
|
+
* its owner's OK whatever the grade (LS-07): a structural fact, held in code. Each step once, in order. */
|
|
221
|
+
export declare function unpricedCalls(doc: unknown, priceOf: (tool: string) => number | undefined): UnpricedCall[];
|
|
222
|
+
/** Why a learned workflow that calls `call` waits for its owner's OK, in a person's words. */
|
|
223
|
+
export declare const unpricedLine: (call: UnpricedCall) => string;
|
|
183
224
|
/** Every string a learned workflow's workflow.json decodes to, each object's keys too, as JSON.parse reads them (its
|
|
184
225
|
* escapes decoded: what draftProblems and a learned call's run read, and a model node is given). Text a scan of the
|
|
185
226
|
* stored JSON misses, spelled in \u escapes, is there as it will be read. None for a text that does not parse (the
|
|
@@ -197,5 +238,11 @@ export declare const LEARNED_MAX_TURNS = 8;
|
|
|
197
238
|
* apply_patch) is never on the list. A model node that names any tool is refused (MODEL_NODE_TOOLS), and a node the
|
|
198
239
|
* learned runner cannot run (LEARNED_NODES: a judge's). With no list it
|
|
199
240
|
* fails closed: a draft the DSL refuses only once given an empty list names a tool. */
|
|
200
|
-
|
|
241
|
+
/** The MCP tools set to ask a learned call would ask its approver about (`asked`, learnedDraftTools), and whether a card
|
|
242
|
+
* names them all (`fits`: learned-workflow.ts learnedAskFits, the gate's own rule, handed in so it is never copied). */
|
|
243
|
+
export type DraftAsk = {
|
|
244
|
+
readonly asked: readonly string[];
|
|
245
|
+
readonly fits: (asks: readonly string[]) => boolean;
|
|
246
|
+
};
|
|
247
|
+
export declare function draftProblems(dsl: DraftReader, text: string, tools?: readonly string[], gated?: Readonly<Record<string, string>>, deniedBy?: Readonly<Record<string, SettingFrom>>, ask?: DraftAsk): DraftProblem[];
|
|
201
248
|
export {};
|
package/dist/learn/skills.js
CHANGED
|
@@ -285,16 +285,19 @@ export const isHeld = (text) => learnedStatus(text) === "pending";
|
|
|
285
285
|
* retiredLearned), which take the `status:` line out whole, can edit. One set any other way reads unclear (learnedStatus:
|
|
286
286
|
* retired), never held or active, and no writer edits it, so a write never leaves part of it behind. The host writes
|
|
287
287
|
* only one-line statuses (held, retiredLearned). */
|
|
288
|
-
export
|
|
288
|
+
export const statusOnOneLine = (text) => onOneLine(text, "status");
|
|
289
|
+
/** Whether `key`, when the front matter sets it, is one plain line (`key: <value>`, nothing of it on the lines after):
|
|
290
|
+
* statusOnOneLine's rule, for each key the host's writers take out whole (`status`, `retired_from`). */
|
|
291
|
+
function onOneLine(text, key) {
|
|
289
292
|
const front = frontMatter(text);
|
|
290
|
-
if (!front?.has(
|
|
293
|
+
if (!front?.has(key))
|
|
291
294
|
return true;
|
|
292
295
|
const lf = text.replace(/\r\n/g, "\n");
|
|
293
|
-
const own = lf.slice(4, closeOf(lf)).split("\n").find((line) => line.startsWith(
|
|
296
|
+
const own = lf.slice(4, closeOf(lf)).split("\n").find((line) => line.startsWith(`${key}:`))?.slice(key.length + 1).trim() ?? "";
|
|
294
297
|
if (!own || /^[>|]/.test(own) || (/^["']/.test(own) && !closedQuote(own)))
|
|
295
298
|
return false;
|
|
296
299
|
// A plain value that wraps onto the next lines reads longer than its own line.
|
|
297
|
-
return unquote(own) === front.get(
|
|
300
|
+
return unquote(own) === front.get(key);
|
|
298
301
|
}
|
|
299
302
|
/** `text`, a SKILL.md or a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
|
|
300
303
|
* pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
|
|
@@ -306,20 +309,36 @@ export function held(text) {
|
|
|
306
309
|
return `${front.lf.slice(0, front.end)}\nstatus: pending${front.lf.slice(front.end)}`;
|
|
307
310
|
}
|
|
308
311
|
/** `text`, a held SKILL.md or draft README.md, as the host leaves it when its owner approves it: its front matter with
|
|
309
|
-
* no `status` line, so it is given to every later run. Throws on a text with no front matter. */
|
|
312
|
+
* no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
|
|
310
313
|
export function released(text) {
|
|
311
314
|
const front = frontOf(text);
|
|
312
315
|
if (typeof front === "string")
|
|
313
316
|
throw new Error(`it cannot be approved: ${front}`);
|
|
314
|
-
|
|
317
|
+
// Its status and retired_from are taken out whole, so each must be one plain line; what is left reads back active, or
|
|
318
|
+
// the write fails: never an OK over a skill no run is given.
|
|
319
|
+
if (!statusOnOneLine(text) || !onOneLine(text, "retired_from"))
|
|
315
320
|
throw new Error("it cannot be approved: its status is not one plain line");
|
|
316
|
-
const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:"));
|
|
321
|
+
const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:") && !line.startsWith("retired_from:"));
|
|
317
322
|
const out = `---\n${kept.join("\n")}${front.lf.slice(front.end)}`;
|
|
318
|
-
// What it leaves reads back active, or the approve fails: never an OK over a skill no run is given.
|
|
319
323
|
if (learnedStatus(out) !== "active")
|
|
320
324
|
throw new Error(`it cannot be approved: its status would read ${learnedStatus(out)}`);
|
|
321
325
|
return out;
|
|
322
326
|
}
|
|
327
|
+
/** The status a retired SKILL.md or draft README.md goes back to when a person restores it (`retired_from`, which its
|
|
328
|
+
* retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
|
|
329
|
+
* `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
|
|
330
|
+
* them (fail closed: only an approval makes a skill or a draft active). */
|
|
331
|
+
export function retiredFrom(text) {
|
|
332
|
+
return onOneLine(text, "retired_from") && frontMatter(text)?.get("retired_from") === "active" ? "active" : "pending";
|
|
333
|
+
}
|
|
334
|
+
/** Whether a retired SKILL.md or draft README.md can be restored by the host's writer: its front matter reads one way
|
|
335
|
+
* (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
|
|
336
|
+
* One that is not is refused until it is written so (a restore never edits half a value). */
|
|
337
|
+
export const restorable = (text) => frontMatter(text) !== undefined && statusOnOneLine(text) && onOneLine(text, "retired_from");
|
|
338
|
+
/** `text`, a retired SKILL.md or draft README.md, as the host leaves it when a person restores it: back in the status its
|
|
339
|
+
* retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
|
|
340
|
+
* one way, or whose status is not one plain line (released). */
|
|
341
|
+
export const restoredLearned = (text) => (retiredFrom(text) === "active" ? released(text) : held(released(text)));
|
|
323
342
|
/** What a SKILL.md or a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
|
|
324
343
|
* the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
|
|
325
344
|
* it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
|
|
@@ -334,17 +353,29 @@ export function learnedStatus(text) {
|
|
|
334
353
|
const status = front.get("status") ?? "active";
|
|
335
354
|
return status === "active" || status === "pending" ? status : "retired";
|
|
336
355
|
}
|
|
337
|
-
/** `text
|
|
338
|
-
*
|
|
356
|
+
/** Whether `text` reads retired (learnedStatus) only because it can't be read: its front matter reads no way, its status
|
|
357
|
+
* is not one plain line, or its status is none the host writes. No one retired it: a view says the host could not read
|
|
358
|
+
* it, never that a run or a person retired it. */
|
|
359
|
+
export function unclearFront(text) {
|
|
360
|
+
const front = frontMatter(text);
|
|
361
|
+
return !front || !statusOnOneLine(text) || !["active", "pending", "retired"].includes(front.get("status") ?? "active");
|
|
362
|
+
}
|
|
363
|
+
/** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
|
|
364
|
+
* status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
|
|
365
|
+
* them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
|
|
366
|
+
* matter. */
|
|
339
367
|
export function retiredLearned(text) {
|
|
340
368
|
const front = frontOf(text);
|
|
341
369
|
if (typeof front === "string")
|
|
342
370
|
throw new Error(`it cannot be retired: ${front}`);
|
|
343
|
-
if (!statusOnOneLine(text))
|
|
371
|
+
if (!statusOnOneLine(text) || !onOneLine(text, "retired_from"))
|
|
344
372
|
throw new Error("it cannot be retired: its status is not one plain line");
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
373
|
+
// What it goes back to on a restore: active only when it reads active now; anything else (held, or a text read as
|
|
374
|
+
// retired already) is held again (fail closed).
|
|
375
|
+
const from = learnedStatus(text) === "active" ? "active" : "pending";
|
|
376
|
+
const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:") && !line.startsWith("retired_from:"));
|
|
377
|
+
const out = `---\n${[...kept, "status: retired", `retired_from: ${from}`].join("\n")}${front.lf.slice(front.end)}`;
|
|
378
|
+
if (!frontMatter(out) || learnedStatus(out) !== "retired" || retiredFrom(out) !== from)
|
|
348
379
|
throw new Error("it cannot be retired: its front matter would not read retired");
|
|
349
380
|
return out;
|
|
350
381
|
}
|
|
@@ -674,6 +705,59 @@ const gatedNodes = (dsl, doc, gated, deniedBy) => dsl.inspectWorkflow(doc).nodes
|
|
|
674
705
|
: `This workflow's call node calls ${tool}, which is set to ask, and a workflow's call node can't wait for an approval: set it to allow for this agent.`;
|
|
675
706
|
return [{ rule: "workflow", detail: `${words} (the call node at ${node.path})` }];
|
|
676
707
|
});
|
|
708
|
+
/** An MCP tool a learned workflow's call node may run, by its address (`via: "tool"`, `tool: "mcp:<server>/<tool>"`,
|
|
709
|
+
* 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
|
|
710
|
+
* charset, never a wildcard. The one rule for it: the tools a draft may name (tools.ts learnedWorkflowTools), the
|
|
711
|
+
* end-of-run prompt that prints them (reflect.ts), and what the grader is told of a draft (grade.ts). */
|
|
712
|
+
export const LEARNED_MCP_TOOL = /^mcp:[a-z][a-z0-9-]{0,31}\/[A-Za-z0-9_][A-Za-z0-9._-]{0,127}$/;
|
|
713
|
+
/** The MCP tools a draft's call nodes run, each once, in the order they come (LS-07): every call node in `doc`, nested
|
|
714
|
+
* ones too, whose tool is an MCP tool's address. Read from the JSON as it is, for the grader's words; never a check. */
|
|
715
|
+
export function draftMcpTools(doc) {
|
|
716
|
+
const found = new Set();
|
|
717
|
+
for (const node of callNodes(doc))
|
|
718
|
+
if (node.via === "tool" && typeof node.tool === "string" && LEARNED_MCP_TOOL.test(node.tool))
|
|
719
|
+
found.add(node.tool);
|
|
720
|
+
return [...found];
|
|
721
|
+
}
|
|
722
|
+
/** Every call node of `doc` (a parsed workflow.json), in document order: only the workflow's node positions, as the
|
|
723
|
+
* DSL's inspection visits them (its root, a chain's steps, a parallel's branches, a map's and a loop's body, a route's
|
|
724
|
+
* branches' bodies, a nested workflow's root), never an object in a call's args, a schema or any other data, however
|
|
725
|
+
* it is shaped. Walked with a stack of its own, never the call stack, so no draft's nesting can throw here. */
|
|
726
|
+
function callNodes(doc) {
|
|
727
|
+
const out = [];
|
|
728
|
+
const asNode = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : undefined);
|
|
729
|
+
const stack = [asNode(doc)?.root];
|
|
730
|
+
while (stack.length) {
|
|
731
|
+
const node = asNode(stack.pop());
|
|
732
|
+
if (!node)
|
|
733
|
+
continue;
|
|
734
|
+
if (node.node === "call")
|
|
735
|
+
out.push(node);
|
|
736
|
+
const children = node.node === "chain" && Array.isArray(node.steps) ? node.steps
|
|
737
|
+
: node.node === "parallel" && Array.isArray(node.branches) ? node.branches
|
|
738
|
+
: (node.node === "map" || node.node === "loop") ? [node.body]
|
|
739
|
+
: node.node === "route" && asNode(node.branches) ? Object.values(node.branches).map((branch) => asNode(branch)?.body)
|
|
740
|
+
: node.node === "workflow" ? [asNode(node.workflow)?.root]
|
|
741
|
+
: [];
|
|
742
|
+
for (let i = children.length - 1; i >= 0; i--)
|
|
743
|
+
stack.push(children[i]);
|
|
744
|
+
}
|
|
745
|
+
return out;
|
|
746
|
+
}
|
|
747
|
+
/** The call nodes of a learned workflow (`doc`, its parsed workflow.json, nested ones too) whose tool is an MCP tool
|
|
748
|
+
* (LEARNED_MCP_TOOL) that `priceOf` gives no price for (mcp-probe.ts McpPrices: none declared). Such a tool runs "not
|
|
749
|
+
* metered", outside the run's cost and cap (mcp-gateway.ts), so a learned workflow that calls one unattended waits for
|
|
750
|
+
* its owner's OK whatever the grade (LS-07): a structural fact, held in code. Each step once, in order. */
|
|
751
|
+
export function unpricedCalls(doc, priceOf) {
|
|
752
|
+
return callNodes(doc).flatMap((node) => {
|
|
753
|
+
if (node.via !== "tool" || typeof node.tool !== "string" || !LEARNED_MCP_TOOL.test(node.tool) || priceOf(node.tool) !== undefined)
|
|
754
|
+
return [];
|
|
755
|
+
const [server, tool] = node.tool.slice("mcp:".length).split("/");
|
|
756
|
+
return [{ label: typeof node.label === "string" ? node.label : "(unnamed)", tool, server }];
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
/** Why a learned workflow that calls `call` waits for its owner's OK, in a person's words. */
|
|
760
|
+
export const unpricedLine = (call) => `its step ${call.label} calls ${call.tool} on ${call.server}, which has no price here, so it runs outside the run's cost and cap`;
|
|
677
761
|
/** Every string a learned workflow's workflow.json decodes to, each object's keys too, as JSON.parse reads them (its
|
|
678
762
|
* escapes decoded: what draftProblems and a learned call's run read, and a model node is given). Text a scan of the
|
|
679
763
|
* stored JSON misses, spelled in \u escapes, is there as it will be read. None for a text that does not parse (the
|
|
@@ -744,13 +828,7 @@ const issuesOf = (dsl, doc, tools) => {
|
|
|
744
828
|
const valid = dsl.validateWorkflow(doc, { executeCode: false, ...(tools ? { tools } : {}) });
|
|
745
829
|
return valid.ok ? [] : valid.issues;
|
|
746
830
|
};
|
|
747
|
-
|
|
748
|
-
* `validateWorkflow` judges it, with `executeCode: false` so no code it holds is run (a code node is syntax-checked),
|
|
749
|
-
* and with `tools`, so a node that names a tool outside them is its error: a harness's own tool (Bash, exec_command,
|
|
750
|
-
* apply_patch) is never on the list. A model node that names any tool is refused (MODEL_NODE_TOOLS), and a node the
|
|
751
|
-
* learned runner cannot run (LEARNED_NODES: a judge's). With no list it
|
|
752
|
-
* fails closed: a draft the DSL refuses only once given an empty list names a tool. */
|
|
753
|
-
export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}) {
|
|
831
|
+
export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}, ask) {
|
|
754
832
|
let doc;
|
|
755
833
|
try {
|
|
756
834
|
doc = JSON.parse(text);
|
|
@@ -772,6 +850,11 @@ export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}) {
|
|
|
772
850
|
const path = doc?.output?.path;
|
|
773
851
|
if (typeof path !== "string" || !path)
|
|
774
852
|
out.push({ rule: "workflow", detail: LEARNED_OUTPUT_PATH });
|
|
853
|
+
// Its MCP tools set to ask, on one approval card per learned call (#2424): a card that can't name them all is refused
|
|
854
|
+
// at the gate at every call, so the draft is refused here, in the gate's words.
|
|
855
|
+
const asks = ask ? draftMcpTools(doc).filter((tool) => ask.asked.includes(tool)) : [];
|
|
856
|
+
if (ask && asks.length && !ask.fits(asks))
|
|
857
|
+
out.push({ rule: "workflow", detail: `its approval card can't name all ${asks.length} MCP tools it would call that are set to ask: set some of them to allow or deny for this agent.` });
|
|
775
858
|
// A composed workflow node's child too: its output is the value at its own output.path, or it fails the same way.
|
|
776
859
|
for (const node of dsl.inspectWorkflow(doc).nodes) {
|
|
777
860
|
if (node.kind !== "workflow")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The journal entry a learned_workflow call keeps beside itself: `{ call, workflow, nodes }`, its call's id, the
|
|
2
|
+
* workflow's name and each of its nodes that ran (LearnedNode). */
|
|
3
|
+
export declare const LEARNED_NODES = "agentrun.learned_nodes";
|
|
4
|
+
/** The most nodes a call keeps: a map over a long list runs its body once per item. */
|
|
5
|
+
export declare const LEARNED_NODES_MAX = 64;
|
|
6
|
+
/** One node of a learned workflow's run, as the DSL ended it (its `node.end` event): its label, its kind, how it ended
|
|
7
|
+
* (`ok`, `failed`, `escalated`) and how long it took; a model node also the model it ran on (`model`, as the run's route
|
|
8
|
+
* names it) and the tier it named (`tier`, absent for none). Never why it failed: the DSL cuts that text at 300
|
|
9
|
+
* characters, which can leave the start of a secret the run's cut no longer recognizes, so none of it is kept. A call
|
|
10
|
+
* node has no model. */
|
|
11
|
+
export type LearnedNode = {
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly kind: string;
|
|
14
|
+
readonly status: string;
|
|
15
|
+
readonly duration_ms: number;
|
|
16
|
+
readonly model?: string;
|
|
17
|
+
readonly tier?: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// What a learned_workflow call keeps of its workflow's run beside itself in the run's journal: each node that ran, as
|
|
2
|
+
// the workflow DSL ended it (learned-workflow.ts runLearned writes it; store-reads/journal.ts runTimeline puts it on the
|
|
3
|
+
// call's result row as `learned_nodes`). Its own module, so the timeline's reader needs none of the tool's imports.
|
|
4
|
+
/** The journal entry a learned_workflow call keeps beside itself: `{ call, workflow, nodes }`, its call's id, the
|
|
5
|
+
* workflow's name and each of its nodes that ran (LearnedNode). */
|
|
6
|
+
export const LEARNED_NODES = "agentrun.learned_nodes";
|
|
7
|
+
/** The most nodes a call keeps: a map over a long list runs its body once per item. */
|
|
8
|
+
export const LEARNED_NODES_MAX = 64;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ToolRegistration } from "@earendil-works/pi-durable";
|
|
2
|
+
import { type LearnedNode } from "./learned-nodes.js";
|
|
2
3
|
import { type LearnedWorkflow } from "./learning.js";
|
|
3
4
|
import type { ModelRef } from "./model.js";
|
|
4
5
|
import { type Ledger } from "./paid-calls.js";
|
|
@@ -26,11 +27,12 @@ export declare const learnedApprovedTools: (card: Readonly<Record<string, unknow
|
|
|
26
27
|
* one that does not read. The run's gate asks about them before the workflow's call runs (adapter-run-spec.ts). */
|
|
27
28
|
export declare function learnedMcpTools(workflow: string): Promise<string[]>;
|
|
28
29
|
export declare const LEARNED_WORKFLOW_TOOL = "learned_workflow";
|
|
29
|
-
/** One line of a learned workflow's output for its row: an object's fields as `name value`,
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
/** One line of a learned workflow's output for its row: an object's fields as `name value`, and a text output (learnedOutput
|
|
31
|
+
* hands one back as it is, #2412) its lines, each value or line whole or, when longer than VALUE_MAX, only as its size,
|
|
32
|
+
* and whole ones only until LINE_MAX. Nothing is ever cut inside a value or a line: the timeline redacts the line as it
|
|
33
|
+
* says it (its summary's words), and its redactor matches a held value only whole, so a cut one could leave a prefix it
|
|
34
|
+
* would not find. Newlines are flattened, so the one line it keeps holds every part. An output already cut for the
|
|
35
|
+
* model (learnedText) says so. */
|
|
34
36
|
export declare function outputLine(text: string): string | undefined;
|
|
35
37
|
/** The models a learned workflow's model nodes run on, as pi-ai's: on pi the run's own (capped and marked: app.ts), on
|
|
36
38
|
* another harness the session's port (port-models.ts). */
|
|
@@ -40,8 +42,8 @@ type RunModels = {
|
|
|
40
42
|
completeSimple(model: never, context: never, options?: never): Promise<unknown>;
|
|
41
43
|
};
|
|
42
44
|
export type LearnedWorkflowRun = {
|
|
43
|
-
/** The run's learned workflows (learning.ts chooseWorkflows):
|
|
44
|
-
*
|
|
45
|
+
/** The run's learned workflows (learning.ts chooseWorkflows): those its claim's seed lay chose
|
|
46
|
+
* (runner/learning-seed.ts). */
|
|
45
47
|
workflows: readonly LearnedWorkflow[];
|
|
46
48
|
/** The tools the agent's revision grants: a workflow's call node may name only those a call node runs here
|
|
47
49
|
* (tools.ts learnedWorkflowTools), and of those, none `plane` resolves unavailable. */
|
|
@@ -53,6 +55,10 @@ export type LearnedWorkflowRun = {
|
|
|
53
55
|
models: RunModels;
|
|
54
56
|
/** The run's model a model node of `tier` runs on: the tier's, else the run's own. */
|
|
55
57
|
modelOf(tier: string | undefined): ModelRef | undefined;
|
|
58
|
+
/** The session's model as a person reads it, the id the run's route names it by: what a node's trace says it ran on
|
|
59
|
+
* (its `model`) when modelOf answers with the session's own port (PORT_PROVIDER), whose model id names no model. A
|
|
60
|
+
* ref of another provider (a tier's own model) is named by its model id. */
|
|
61
|
+
modelName?(tier: string | undefined): string | undefined;
|
|
56
62
|
/** The `llm` tool's completion, for a call node that names it. */
|
|
57
63
|
complete?: Complete;
|
|
58
64
|
/** The run's gate's permission of a tool now (tool-gate.ts RunGate policy): a call node's tool set to ask or deny is
|
|
@@ -79,7 +85,7 @@ export type LearnedWorkflowRun = {
|
|
|
79
85
|
/** The most characters of a learned workflow's output its answer holds, monid's bound (monid.ts CLIP): within the
|
|
80
86
|
* host's result bound, which each CLI is told to pass whole (host-bounds.test). */
|
|
81
87
|
export declare const LEARNED_CLIP = 60000;
|
|
82
|
-
/** `text`, a learned workflow's output as
|
|
88
|
+
/** `text`, a learned workflow's output as its tool hands it back (learnedOutput), cut at LEARNED_CLIP characters (never inside a surrogate pair), saying
|
|
83
89
|
* so. */
|
|
84
90
|
export declare function learnedText(text: string): string;
|
|
85
91
|
/** What a learned workflow's model node is refused with when it names a tool: it runs in a session of its own here.
|
|
@@ -87,15 +93,23 @@ export declare function learnedText(text: string): string;
|
|
|
87
93
|
export declare const NODE_TOOLS_REFUSED = "a learned workflow's model node runs without tools here";
|
|
88
94
|
/** The tool's description, sent with every model request of the run, so it holds what a model needs to call it right and
|
|
89
95
|
* no more: one line of what the tool does (one call, by name, a JSON input with the listed fields, `*` marking a required
|
|
90
|
-
* one; what it answers
|
|
91
|
-
*
|
|
96
|
+
* one; what it answers: a text output as it is, to reply with unchanged, since a model handed it otherwise writes its own
|
|
97
|
+
* reply around it and a format the workflow's last node wrote is lost, #2412), then each workflow on a line of its own
|
|
98
|
+
* (workflowLine): its name, its input's fields and the line its README says what it does with. */
|
|
92
99
|
export declare const learnedWorkflowDescription: (workflows: readonly LearnedWorkflow[]) => string;
|
|
100
|
+
/** A learned workflow's output as its tool hands it back: its text when it is text, a string or an object of one string
|
|
101
|
+
* field (a node's record of one field, as a last node that writes the answer gives it), so the lines its last node wrote
|
|
102
|
+
* reach the model as lines; else JSON. */
|
|
103
|
+
export declare function learnedOutput(output: unknown): string;
|
|
93
104
|
/** The run's `learned_workflow` tool over `run.workflows`. */
|
|
94
105
|
export declare function learnedWorkflowTool(run: LearnedWorkflowRun): ToolRegistration;
|
|
95
|
-
/** `flow` run on `input` for `run`: its output as
|
|
96
|
-
*
|
|
97
|
-
|
|
106
|
+
/** `flow` run on `input` for `run`: its output as its tool hands it back (learnedOutput), or why it did not run, and each of its nodes that ran (at most
|
|
107
|
+
* LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
|
|
108
|
+
* which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
|
|
109
|
+
* added as it ends, the caller's to keep when the call is aborted (and so throws) part way. */
|
|
110
|
+
export declare function runLearned(run: LearnedWorkflowRun, flow: LearnedWorkflow, input: unknown, signal?: AbortSignal, ledger?: Ledger, nodes?: LearnedNode[]): Promise<{
|
|
98
111
|
text: string;
|
|
99
112
|
isError: boolean;
|
|
113
|
+
nodes: LearnedNode[];
|
|
100
114
|
}>;
|
|
101
115
|
export {};
|