@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35
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 +368 -0
- package/README.md +341 -208
- package/dist/adapters.d.ts +3 -4
- package/dist/adapters.js +18 -15
- package/dist/agent-rows.d.ts +99 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +75 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/archil-settings.d.ts +11 -1
- package/dist/archil-settings.js +10 -0
- package/dist/bash-read-only.d.ts +35 -0
- package/dist/bash-read-only.js +778 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +95 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/budget.d.ts +0 -5
- package/dist/budget.js +0 -5
- package/dist/cap.d.ts +14 -8
- package/dist/cap.js +19 -9
- package/dist/cli.js +71 -18
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -54
- package/dist/computer-setting.d.ts +20 -3
- package/dist/computer-setting.js +58 -10
- package/dist/computers.d.ts +35 -2
- package/dist/computers.js +72 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-B7NKTU8E.css +1 -0
- package/dist/console/assets/index-CXZMgJE7.js +550 -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/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +1 -2
- package/dist/errors.js +9 -9
- package/dist/explain.js +3 -1
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- 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 +6 -2
- package/dist/github.js +5 -3
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +9 -16
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +8 -2
- package/dist/learn/check.js +85 -31
- package/dist/learn/folder.d.ts +11 -4
- package/dist/learn/folder.js +17 -19
- package/dist/learn/grade.d.ts +18 -1
- package/dist/learn/grade.js +108 -14
- package/dist/learn/index.d.ts +5 -5
- package/dist/learn/index.js +5 -5
- package/dist/learn/learning.sh +1 -14
- package/dist/learn/notes.d.ts +14 -3
- package/dist/learn/notes.js +16 -6
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +83 -6
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +159 -18
- package/dist/learn/skills.js +644 -64
- package/dist/learned-nodes.d.ts +14 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +41 -6
- package/dist/learned-workflow.js +153 -18
- package/dist/learning-routes.d.ts +49 -4
- package/dist/learning-routes.js +113 -31
- package/dist/learning-run.d.ts +16 -31
- package/dist/learning-run.js +31 -38
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +91 -97
- package/dist/learning.js +176 -320
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +17 -49
- package/dist/mcp-gateway.js +55 -136
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +18 -18
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +9 -7
- package/dist/model.js +51 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +156 -58
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +26 -61
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/port-models.d.ts +10 -3
- package/dist/port-models.js +26 -6
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +80 -45
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +21 -2
- package/dist/run-launch.js +14 -5
- package/dist/run-learning-served.d.ts +21 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +5 -3
- package/dist/run-reads-over-store.js +25 -14
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +27 -6
- package/dist/run-view.d.ts +37 -22
- package/dist/run-view.js +85 -38
- package/dist/runnable.d.ts +21 -10
- package/dist/runnable.js +35 -12
- package/dist/runner/adapter-loop.d.ts +36 -5
- package/dist/runner/adapter-loop.js +663 -69
- package/dist/runner/adapter-run-spec.d.ts +42 -8
- package/dist/runner/adapter-run-spec.js +186 -52
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +40 -2
- package/dist/runner/adapters/pi.js +110 -27
- package/dist/runner/beside.d.ts +38 -3
- package/dist/runner/beside.js +54 -5
- package/dist/runner/claim-secrets.d.ts +16 -1
- package/dist/runner/claim-secrets.js +62 -14
- package/dist/runner/cli-run-spec.d.ts +5 -0
- package/dist/runner/cli-run-spec.js +159 -41
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.d.ts +1 -0
- package/dist/runner/conformance/harness.js +123 -13
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +47 -16
- package/dist/runner/harness-loops.d.ts +15 -2
- package/dist/runner/harness-loops.js +38 -2
- package/dist/runner/journal-kinds.d.ts +60 -6
- package/dist/runner/journal-kinds.js +43 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +194 -20
- package/dist/runner/learning-loop.d.ts +7 -0
- package/dist/runner/learning-loop.js +36 -8
- package/dist/runner/learning-seed.d.ts +6 -0
- package/dist/runner/learning-seed.js +6 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.d.ts +61 -9
- package/dist/runner/main.js +144 -20
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +7 -3
- package/dist/runner/mcp-github.d.ts +11 -2
- package/dist/runner/mcp-github.js +55 -4
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +16 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +46 -1
- package/dist/runner/metrics.js +156 -1
- package/dist/runner/model-route.d.ts +16 -0
- package/dist/runner/model-route.js +134 -10
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +146 -18
- package/dist/runner/spec-holds.d.ts +7 -2
- package/dist/runner/spec-holds.js +4 -3
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-host.d.ts +7 -2
- package/dist/runner/workflow-host.js +3 -1
- package/dist/runner/workflow-loop.d.ts +10 -1
- package/dist/runner/workflow-loop.js +14 -6
- package/dist/runner/workflow-spec.d.ts +21 -0
- package/dist/runner/workflow-spec.js +217 -93
- package/dist/runs-over-store.d.ts +14 -3
- package/dist/runs-over-store.js +100 -23
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +5 -45
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +5 -85
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +37 -56
- package/dist/server.js +322 -134
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +12 -2
- package/dist/store/agent-body.js +22 -4
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +45 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +22 -2
- package/dist/store/postgres/connection.js +211 -41
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +14 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +129 -18
- package/dist/store-reads/learning.d.ts +82 -8
- package/dist/store-reads/learning.js +184 -11
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +19 -1
- package/dist/store-view.js +95 -27
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +33 -14
- package/dist/templates.js +82 -46
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +282 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-budget.d.ts +18 -0
- package/dist/tool-budget.js +50 -0
- package/dist/tool-gate.d.ts +47 -218
- package/dist/tool-gate.js +87 -545
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +23 -52
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +67 -25
- package/dist/tools.js +170 -119
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +83 -10
- package/dist/usage.d.ts +1 -49
- package/dist/usage.js +3 -84
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +33 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/archil-claim.d.ts +2 -2
- package/dist/workspace/archil-claim.js +4 -3
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +16 -0
- 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/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +26 -9
- package/dist/workspace/computer-deps.js +144 -43
- package/dist/workspace/computer-for-claim.d.ts +17 -14
- package/dist/workspace/computer-for-claim.js +99 -26
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-ledger.d.ts +1 -8
- package/dist/workspace/computer-ledger.js +0 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +6 -5
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +14 -2
- package/dist/workspace/local.js +170 -43
- 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 +55 -10
- package/dist/workspace/resolve-computer.js +66 -14
- package/dist/workspace/run-tools.d.ts +15 -31
- package/dist/workspace/run-tools.js +19 -30
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +4 -110
- package/package.json +14 -14
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -5
- 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/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/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +11 -0
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
|
@@ -0,0 +1,14 @@
|
|
|
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. Never why it failed: the DSL cuts that text at 300 characters,
|
|
8
|
+
* which can leave the start of a secret the run's cut no longer recognizes, so none of it is kept. */
|
|
9
|
+
export type LearnedNode = {
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly kind: string;
|
|
12
|
+
readonly status: string;
|
|
13
|
+
readonly duration_ms: number;
|
|
14
|
+
};
|
|
@@ -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,10 +1,31 @@
|
|
|
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";
|
|
5
6
|
import type { Plane } from "./tool-plane.js";
|
|
6
7
|
import { type SettingFrom } from "./tool-gate.js";
|
|
7
8
|
import type { Complete } from "./llm.js";
|
|
9
|
+
/** What a learned_workflow call's approval card says of its MCP calls' arguments: the workflow decides them as it runs. */
|
|
10
|
+
export declare const LEARNED_MCP_ARGUMENTS = "decided by the workflow while it runs, from its input and its earlier steps";
|
|
11
|
+
/** What a learned_workflow call's card shows of the MCP tools set to ask that the workflow can call: that their arguments
|
|
12
|
+
* are the workflow's to decide, then every one of them by name. The card leads with these (the call's own input after
|
|
13
|
+
* them), so they are never cut behind a long input. */
|
|
14
|
+
export declare const learnedAskShown: (asks: readonly string[]) => Record<string, unknown>;
|
|
15
|
+
/** The most bytes of the card those fields may take: the card's preview is cut at ARGS_PREVIEW_BYTES (2 KB), and its
|
|
16
|
+
* braces and the call's name follow them. A workflow whose ask-gated MCP tools would not all show is refused, never
|
|
17
|
+
* approved by a person who could not see what they approved. */
|
|
18
|
+
export declare const LEARNED_ASK_CARD_BYTES: number;
|
|
19
|
+
/** Whether every MCP tool set to ask that the workflow can call fits on its card (learnedAskShown, LEARNED_ASK_CARD_BYTES). */
|
|
20
|
+
export declare const learnedAskFits: (asks: readonly string[]) => boolean;
|
|
21
|
+
/** The MCP tools a person's approval of a learned_workflow call covers: exactly those its card named (learnedAskShown's
|
|
22
|
+
* `mcp_calls`, read from the card they approved, host-calls.ts HostCalls.approved). None when no person approved it,
|
|
23
|
+
* or the card named none. A tool set to ask that the card did not name (one set to ask after the card was shown) is
|
|
24
|
+
* never run under that approval. */
|
|
25
|
+
export declare const learnedApprovedTools: (card: Readonly<Record<string, unknown>> | undefined) => ReadonlySet<string>;
|
|
26
|
+
/** The MCP tools a learned workflow's call nodes name (`via: "tool"`, `tool: "mcp:<server>/<tool>"`), each once; none for
|
|
27
|
+
* one that does not read. The run's gate asks about them before the workflow's call runs (adapter-run-spec.ts). */
|
|
28
|
+
export declare function learnedMcpTools(workflow: string): Promise<string[]>;
|
|
8
29
|
export declare const LEARNED_WORKFLOW_TOOL = "learned_workflow";
|
|
9
30
|
/** One line of a learned workflow's output for its row: an object's fields as `name value`, each value whole or, when
|
|
10
31
|
* longer than VALUE_MAX, only as its size, and whole fields only until LINE_MAX. Nothing is ever cut inside a value:
|
|
@@ -20,8 +41,8 @@ type RunModels = {
|
|
|
20
41
|
completeSimple(model: never, context: never, options?: never): Promise<unknown>;
|
|
21
42
|
};
|
|
22
43
|
export type LearnedWorkflowRun = {
|
|
23
|
-
/** The run's learned workflows (learning.ts chooseWorkflows):
|
|
24
|
-
*
|
|
44
|
+
/** The run's learned workflows (learning.ts chooseWorkflows): those its claim's seed lay chose
|
|
45
|
+
* (runner/learning-seed.ts). */
|
|
25
46
|
workflows: readonly LearnedWorkflow[];
|
|
26
47
|
/** The tools the agent's revision grants: a workflow's call node may name only those a call node runs here
|
|
27
48
|
* (tools.ts learnedWorkflowTools), and of those, none `plane` resolves unavailable. */
|
|
@@ -47,6 +68,14 @@ export type LearnedWorkflowRun = {
|
|
|
47
68
|
* each call node runs, before `policy` is asked: a tool set to deny since the call began is then refused. None: the
|
|
48
69
|
* gate reads its settings live (main's process). */
|
|
49
70
|
refresh?: () => Promise<void>;
|
|
71
|
+
/** The run's MCP tools by catalog name (`mcp:<server>/<tool>`): those the claim's pin holds, which its revision grants.
|
|
72
|
+
* A call node may name one of these; it runs through the run's own MCP, as the loop wrapped it (host-calls.ts). */
|
|
73
|
+
mcpTools?: readonly string[];
|
|
74
|
+
/** The gate's whole decision of an MCP node's call with its arguments, as the run's own call of the tool gets it
|
|
75
|
+
* (RunGate.decide: deny, argument pins, ask, no approver). Required for an MCP node: one with none is never sent. */
|
|
76
|
+
decide?: (tool: string, args: unknown) => Promise<"allow" | "ask" | {
|
|
77
|
+
deny: string;
|
|
78
|
+
}>;
|
|
50
79
|
};
|
|
51
80
|
/** The most characters of a learned workflow's output its answer holds, monid's bound (monid.ts CLIP): within the
|
|
52
81
|
* host's result bound, which each CLI is told to pass whole (host-bounds.test). */
|
|
@@ -57,14 +86,20 @@ export declare function learnedText(text: string): string;
|
|
|
57
86
|
/** What a learned workflow's model node is refused with when it names a tool: it runs in a session of its own here.
|
|
58
87
|
* The check before the run refuses such a workflow first (draftProblems); this one holds should it not. */
|
|
59
88
|
export declare const NODE_TOOLS_REFUSED = "a learned workflow's model node runs without tools here";
|
|
60
|
-
/** The tool's description
|
|
89
|
+
/** The tool's description, sent with every model request of the run, so it holds what a model needs to call it right and
|
|
90
|
+
* no more: one line of what the tool does (one call, by name, a JSON input with the listed fields, `*` marking a required
|
|
91
|
+
* one; what it answers), then each workflow on a line of its own (workflowLine): its name, its input's fields and the
|
|
92
|
+
* line its README says what it does with. */
|
|
61
93
|
export declare const learnedWorkflowDescription: (workflows: readonly LearnedWorkflow[]) => string;
|
|
62
94
|
/** The run's `learned_workflow` tool over `run.workflows`. */
|
|
63
95
|
export declare function learnedWorkflowTool(run: LearnedWorkflowRun): ToolRegistration;
|
|
64
|
-
/** `flow` run on `input` for `run`: its output as JSON, or why it did not run
|
|
65
|
-
*
|
|
66
|
-
|
|
96
|
+
/** `flow` run on `input` for `run`: its output as JSON, or why it did not run, and each of its nodes that ran (at most
|
|
97
|
+
* LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
|
|
98
|
+
* which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
|
|
99
|
+
* added as it ends, the caller's to keep when the call is aborted (and so throws) part way. */
|
|
100
|
+
export declare function runLearned(run: LearnedWorkflowRun, flow: LearnedWorkflow, input: unknown, signal?: AbortSignal, ledger?: Ledger, nodes?: LearnedNode[]): Promise<{
|
|
67
101
|
text: string;
|
|
68
102
|
isError: boolean;
|
|
103
|
+
nodes: LearnedNode[];
|
|
69
104
|
}>;
|
|
70
105
|
export {};
|
package/dist/learned-workflow.js
CHANGED
|
@@ -1,12 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// learned_workflow: a run of an agent that learned a workflow runs it as one tool call, on any harness. The tool is the
|
|
2
|
+
// run's when its pin names a learned workflow (learning.ts: one whose README sets no status, or `active`; a pending or
|
|
3
|
+
// retired one is never named), with no edit of the agent's definition; its description names each one and what it does,
|
|
4
|
+
// so the model needs no hint. A call checks the workflow again against the agent's own tools as its run has them (S1's
|
|
5
|
+
// checker, draftProblems, as at learn time: a call node on a tool the agent was not granted or its run resolves
|
|
6
|
+
// unavailable, a model node that names any tool, a code node or a shell or executor call is refused before any node
|
|
7
|
+
// runs, never after earlier ones spent), then runs it with the workflow DSL's runWorkflow:
|
|
8
|
+
// - a model node (agent, decide, extract, report) on the run's model of its tier, else the run's own model (the one
|
|
9
|
+
// model the run was made with and handed the key of: app.ts), in a fresh session of its own (agentrun-pi's host
|
|
10
|
+
// runner), with no tool of its own;
|
|
11
|
+
// - a call node `via: "tool"` on the tool table's effect, as a workflow revision's (app.ts), for a tool the agent has,
|
|
12
|
+
// its paid requests booked under the tool's call (paid-calls.ts), each node's under a call of its own; web_search
|
|
13
|
+
// where it resolves native on the provider's hosted search through the run's models (hosted-search.ts), on a harness
|
|
14
|
+
// whose own search it is too (harness-app.ts gives that harness no host tool of the name).
|
|
15
|
+
// Each model request is a request on the run's one route, so what the workflow spends is the run's cost, under its cap:
|
|
16
|
+
// on pi the run's models, as a side request (request-start.ts, cap.ts: marked, and costed on the run's timeline as
|
|
17
|
+
// `learned_workflow`); on another harness the session's model proxy, under a side key (port-models.ts): the harness's
|
|
18
|
+
// own policy, provider, key and price, booked on the session's records labelled `learned_workflow`. A call a crash cut
|
|
19
|
+
// off is never run again (`replay: "never"`): it is answered interrupted.
|
|
20
|
+
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
21
|
+
import { defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
22
|
+
import { registerLabel, registerOutcome } from "./timeline/index.js";
|
|
3
23
|
import { sideRequests } from "./cap.js";
|
|
24
|
+
import { LEARNED_NODES, LEARNED_NODES_MAX } from "./learned-nodes.js";
|
|
4
25
|
import { draftProblems, LEARNED_MAX_TURNS } from "./learn/index.js";
|
|
5
26
|
import { workflowLine } from "./learning.js";
|
|
6
27
|
import { ledgerOf } from "./paid-calls.js";
|
|
7
28
|
import { forModel } from "./result.js";
|
|
8
|
-
import { deniedText } from "./tool-gate.js";
|
|
9
|
-
import { allows, CALL_TOOLS, learnedDraftTools, toolOf } from "./tools.js";
|
|
29
|
+
import { ARGS_PREVIEW_BYTES, deniedText } from "./tool-gate.js";
|
|
30
|
+
import { allows, CALL_TOOLS, learnedDraftTools, toolOf, workflowTools } from "./tools.js";
|
|
31
|
+
import { hostCalls } from "./host-calls.js";
|
|
32
|
+
import { workflowNodes } from "./model.js";
|
|
33
|
+
/** What a learned_workflow call's approval card says of its MCP calls' arguments: the workflow decides them as it runs. */
|
|
34
|
+
export const LEARNED_MCP_ARGUMENTS = "decided by the workflow while it runs, from its input and its earlier steps";
|
|
35
|
+
/** What a learned_workflow call's card shows of the MCP tools set to ask that the workflow can call: that their arguments
|
|
36
|
+
* are the workflow's to decide, then every one of them by name. The card leads with these (the call's own input after
|
|
37
|
+
* them), so they are never cut behind a long input. */
|
|
38
|
+
export const learnedAskShown = (asks) => ({ mcp_arguments: LEARNED_MCP_ARGUMENTS, mcp_calls: [...asks] });
|
|
39
|
+
/** The most bytes of the card those fields may take: the card's preview is cut at ARGS_PREVIEW_BYTES (2 KB), and its
|
|
40
|
+
* braces and the call's name follow them. A workflow whose ask-gated MCP tools would not all show is refused, never
|
|
41
|
+
* approved by a person who could not see what they approved. */
|
|
42
|
+
export const LEARNED_ASK_CARD_BYTES = ARGS_PREVIEW_BYTES - 128;
|
|
43
|
+
/** Whether every MCP tool set to ask that the workflow can call fits on its card (learnedAskShown, LEARNED_ASK_CARD_BYTES). */
|
|
44
|
+
export const learnedAskFits = (asks) => Buffer.byteLength(JSON.stringify(learnedAskShown(asks)), "utf8") <= LEARNED_ASK_CARD_BYTES;
|
|
45
|
+
/** The MCP tools a person's approval of a learned_workflow call covers: exactly those its card named (learnedAskShown's
|
|
46
|
+
* `mcp_calls`, read from the card they approved, host-calls.ts HostCalls.approved). None when no person approved it,
|
|
47
|
+
* or the card named none. A tool set to ask that the card did not name (one set to ask after the card was shown) is
|
|
48
|
+
* never run under that approval. */
|
|
49
|
+
export const learnedApprovedTools = (card) => new Set(Array.isArray(card?.mcp_calls) ? card.mcp_calls.filter((name) => typeof name === "string") : []);
|
|
50
|
+
/** An MCP tool's catalog name, `mcp:<server>/<tool>`: a call node that names one runs it through the run's own MCP. */
|
|
51
|
+
const MCP_TOOL = /^mcp:[^/]+\/.+$/;
|
|
52
|
+
/** The MCP tools a learned workflow's call nodes name (`via: "tool"`, `tool: "mcp:<server>/<tool>"`), each once; none for
|
|
53
|
+
* one that does not read. The run's gate asks about them before the workflow's call runs (adapter-run-spec.ts). */
|
|
54
|
+
export async function learnedMcpTools(workflow) {
|
|
55
|
+
let doc;
|
|
56
|
+
try {
|
|
57
|
+
doc = JSON.parse(workflow);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const { inspectWorkflow } = await import("@parcha/agentrun-dsl");
|
|
63
|
+
try {
|
|
64
|
+
return workflowTools(workflowNodes(doc, inspectWorkflow(doc))).calls.filter((tool) => MCP_TOOL.test(tool));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** A call node's MCP result as the workflow's value: its text as JSON when it parses, else `{ text }`. */
|
|
71
|
+
const mcpValue = (text) => {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(text);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return { text };
|
|
77
|
+
}
|
|
78
|
+
};
|
|
10
79
|
export const LEARNED_WORKFLOW_TOOL = "learned_workflow";
|
|
11
80
|
/** The most of a learned workflow's output its result line shows, and the longest value it shows as written. */
|
|
12
81
|
const LINE_MAX = 120;
|
|
@@ -66,10 +135,12 @@ export function learnedText(text) {
|
|
|
66
135
|
/** What a learned workflow's model node is refused with when it names a tool: it runs in a session of its own here.
|
|
67
136
|
* The check before the run refuses such a workflow first (draftProblems); this one holds should it not. */
|
|
68
137
|
export const NODE_TOOLS_REFUSED = "a learned workflow's model node runs without tools here";
|
|
69
|
-
/** The tool's description
|
|
138
|
+
/** The tool's description, sent with every model request of the run, so it holds what a model needs to call it right and
|
|
139
|
+
* no more: one line of what the tool does (one call, by name, a JSON input with the listed fields, `*` marking a required
|
|
140
|
+
* one; what it answers), then each workflow on a line of its own (workflowLine): its name, its input's fields and the
|
|
141
|
+
* line its README says what it does with. */
|
|
70
142
|
export const learnedWorkflowDescription = (workflows) => [
|
|
71
|
-
"
|
|
72
|
-
"schema says. It answers the workflow's output as JSON, or why it did not run. The workflows:",
|
|
143
|
+
"Runs one of this agent's learned workflows in one call, by name, on a JSON input with the fields below (* required). Answers its output as JSON, or why it did not run.",
|
|
73
144
|
...workflows.map(workflowLine),
|
|
74
145
|
].join("\n");
|
|
75
146
|
/** One model request as a pi-ai event stream, sent through `models.completeSimple` as the run's own request, under its
|
|
@@ -109,8 +180,9 @@ export function learnedWorkflowTool(run) {
|
|
|
109
180
|
additionalProperties: false,
|
|
110
181
|
required: ["name", "input"],
|
|
111
182
|
properties: {
|
|
112
|
-
|
|
113
|
-
|
|
183
|
+
// No words of their own: the description says what each is, and the parameters go with every request too.
|
|
184
|
+
name: { type: "string", enum: names },
|
|
185
|
+
input: { type: "object" },
|
|
114
186
|
},
|
|
115
187
|
},
|
|
116
188
|
execute: async (args, api, context) => {
|
|
@@ -118,15 +190,31 @@ export function learnedWorkflowTool(run) {
|
|
|
118
190
|
const flow = run.workflows.find((workflow) => workflow.name === name);
|
|
119
191
|
if (!flow)
|
|
120
192
|
return forModel(`No learned workflow of this agent is named ${JSON.stringify(name)}. Its workflows: ${names.join(", ")}.`, { isError: true });
|
|
121
|
-
const
|
|
193
|
+
const ledger = ledgerOf(api, context);
|
|
194
|
+
// Which of its nodes ran, kept beside the call in the run's journal (LEARNED_NODES), for its timeline row; a trace
|
|
195
|
+
// that can't be kept never fails the call. A call stopped part way keeps the nodes that ended before it stopped,
|
|
196
|
+
// written outside the stopped call's context, and still ends as a stop.
|
|
197
|
+
const trace = [];
|
|
198
|
+
const keep = (signal) => (trace.length ? api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: LEARNED_NODES, data: { call: ledger.call, workflow: flow.name, nodes: trace } })), signal).catch(() => undefined) : undefined);
|
|
199
|
+
let said;
|
|
200
|
+
try {
|
|
201
|
+
said = await runLearned(run, flow, input, context?.abortSignal, ledger, trace);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
await keep(BACKGROUND_CONTEXT);
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
await keep(context);
|
|
122
208
|
return forModel(said.text, { isError: said.isError });
|
|
123
209
|
},
|
|
124
210
|
});
|
|
125
211
|
}
|
|
126
|
-
/** `flow` run on `input` for `run`: its output as JSON, or why it did not run
|
|
127
|
-
*
|
|
128
|
-
|
|
129
|
-
|
|
212
|
+
/** `flow` run on `input` for `run`: its output as JSON, or why it did not run, and each of its nodes that ran (at most
|
|
213
|
+
* LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
|
|
214
|
+
* which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
|
|
215
|
+
* added as it ends, the caller's to keep when the call is aborted (and so throws) part way. */
|
|
216
|
+
export async function runLearned(run, flow, input, signal, ledger, nodes = []) {
|
|
217
|
+
const refuse = (why) => ({ text: `The learned workflow ${flow.name} was not run: ${why}`, isError: true, nodes });
|
|
130
218
|
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
131
219
|
return refuse("its input must be a JSON object");
|
|
132
220
|
const dsl = await import("@parcha/agentrun-dsl");
|
|
@@ -137,6 +225,20 @@ export async function runLearned(run, flow, input, signal, ledger) {
|
|
|
137
225
|
if (typeof run.policy !== "function" || typeof run.denyFrom !== "function")
|
|
138
226
|
return refuse("its run gave no tool policy for its call nodes");
|
|
139
227
|
const { tools, gated, deniedBy } = learnedDraftTools(run.granted, run.policy, run.plane, run.denyFrom);
|
|
228
|
+
// The run's MCP tools, held to the same gate: one set to allow may be named, and one set to ask only when a person
|
|
229
|
+
// approved this call with a card that named it (its ask is the call's own: adapter-run-spec.ts adapterRunGate); one set
|
|
230
|
+
// to deny is refused in its words. One the run's pin does not hold is no tool of the run at all.
|
|
231
|
+
const approved = learnedApprovedTools(hostCalls()?.approved);
|
|
232
|
+
for (const name of run.mcpTools ?? []) {
|
|
233
|
+
const setting = run.policy(name);
|
|
234
|
+
if (setting === "allow" || (setting === "ask" && approved.has(name)))
|
|
235
|
+
tools.push(name);
|
|
236
|
+
else {
|
|
237
|
+
gated[name] = setting;
|
|
238
|
+
if (setting === "deny")
|
|
239
|
+
deniedBy[name] = run.denyFrom(name);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
140
242
|
const problems = draftProblems(dsl, flow.workflow, tools, gated, deniedBy);
|
|
141
243
|
if (problems.length)
|
|
142
244
|
return refuse(problems.map(({ detail }) => detail).join("; "));
|
|
@@ -168,6 +270,32 @@ export async function runLearned(run, flow, input, signal, ledger) {
|
|
|
168
270
|
};
|
|
169
271
|
const runEffect = async ({ node, input: given, signal: own, executionPath, item }) => {
|
|
170
272
|
const tool = node.via === "tool" ? node.tool : undefined;
|
|
273
|
+
// Its call id under the workflow's call: the node, its execution path, its item in a map. Its paid requests are booked
|
|
274
|
+
// under it, as a call of its own.
|
|
275
|
+
const callId = `${ledger?.call ?? LEARNED_WORKFLOW_TOOL}/${node.label}@${executionPath ?? ""}${item ? `#${item.index}` : ""}`;
|
|
276
|
+
if (tool && MCP_TOOL.test(tool)) {
|
|
277
|
+
// An MCP tool of the run, through the run's own MCP as the loop wrapped it (its flush, its booking on the run's one
|
|
278
|
+
// ledger, a CLI's record, the stop's abort), after the gate's rule read again now, as the harness's own call is.
|
|
279
|
+
const send = (run.mcpTools ?? []).includes(tool) && run.decide ? hostCalls()?.mcp(tool) : undefined;
|
|
280
|
+
if (!send || !run.decide)
|
|
281
|
+
throw new Error(`call node "${node.label}": this agent runs no tool ${tool}`);
|
|
282
|
+
// The gate's whole decision of this call with the arguments the workflow resolved, as the harness's own call of the
|
|
283
|
+
// tool gets it: its deny, its argument pins (a messaging tool held to one channel), its ask, or no one to approve.
|
|
284
|
+
// The call's approval lifts only an ask, never a pin or a deny, and only for a tool its card named: one set to ask
|
|
285
|
+
// since the card was shown was never approved.
|
|
286
|
+
await run.refresh?.();
|
|
287
|
+
const verdict = await run.decide(tool, given);
|
|
288
|
+
if (typeof verdict === "object")
|
|
289
|
+
throw new Error(verdict.deny);
|
|
290
|
+
const card = hostCalls()?.approved;
|
|
291
|
+
if (verdict === "ask" && !learnedApprovedTools(card).has(tool)) {
|
|
292
|
+
throw new Error(card ? `This ${tool} call needs a person's approval, and the approval given for this learned workflow did not cover it: its card did not name ${tool}. It was not run.` : `This ${tool} call needs a person's approval, which was not given for this call; it was not run.`);
|
|
293
|
+
}
|
|
294
|
+
const answer = await send(given, { callId, signal: own });
|
|
295
|
+
if (answer.isError)
|
|
296
|
+
throw new Error(answer.text);
|
|
297
|
+
return mcpValue(answer.text);
|
|
298
|
+
}
|
|
171
299
|
const effect = tool && allows(CALL_TOOLS, tool) && tools.includes(tool) ? toolOf(tool)?.effect : undefined;
|
|
172
300
|
if (!effect)
|
|
173
301
|
throw new Error(`call node "${node.label}": this agent runs no tool ${tool ?? `via ${node.via}`}`);
|
|
@@ -181,18 +309,25 @@ export async function runLearned(run, flow, input, signal, ledger) {
|
|
|
181
309
|
if (permission === "ask")
|
|
182
310
|
throw new Error(`This ${tool} call needs a person's approval, which a workflow's call node cannot wait for; it was not run.`);
|
|
183
311
|
// Its paid requests booked under the tool's call, as a call of its own: the node, its execution path, its item in a map.
|
|
184
|
-
const booked = ledger ? { ledger: { call:
|
|
312
|
+
const booked = ledger ? { ledger: { call: callId, record: ledger.record } } : {};
|
|
185
313
|
return effect(given, { signal: own, env: run.env, work: run.work, ...(run.complete ? { complete: run.complete } : {}), ...booked });
|
|
186
314
|
};
|
|
315
|
+
// Each node as it ends, by the DSL's own event: what the call's timeline row shows of it.
|
|
316
|
+
const onEvent = (event) => {
|
|
317
|
+
if (event.type !== "node.end" || nodes.length >= LEARNED_NODES_MAX)
|
|
318
|
+
return;
|
|
319
|
+
const detail = (event.detail ?? {});
|
|
320
|
+
nodes.push({ label: String(event.label), kind: String(detail.kind ?? ""), status: String(detail.status ?? ""), duration_ms: typeof detail.duration_ms === "number" ? detail.duration_ms : 0 });
|
|
321
|
+
};
|
|
187
322
|
try {
|
|
188
|
-
const result = await dsl.runWorkflow(doc, input, { runNode: runNode, runEffect: runEffect, ...(signal ? { signal } : {}) });
|
|
323
|
+
const result = await dsl.runWorkflow(doc, input, { runNode: runNode, runEffect: runEffect, onEvent, ...(signal ? { signal } : {}) });
|
|
189
324
|
if (result.status !== "complete")
|
|
190
325
|
return refuse(`it ended ${result.status}`);
|
|
191
|
-
return { text: learnedText(JSON.stringify(result.output ?? null)), isError: false };
|
|
326
|
+
return { text: learnedText(JSON.stringify(result.output ?? null)), isError: false, nodes };
|
|
192
327
|
}
|
|
193
328
|
catch (error) {
|
|
194
329
|
if (signal?.aborted)
|
|
195
330
|
throw error;
|
|
196
|
-
return { text: `The learned workflow ${flow.name} failed: ${String(error?.message ?? error).slice(0, 1000)}`, isError: true };
|
|
331
|
+
return { text: `The learned workflow ${flow.name} failed: ${String(error?.message ?? error).slice(0, 1000)}`, isError: true, nodes };
|
|
197
332
|
}
|
|
198
333
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { DraftAsk } from "./learn/skills.js";
|
|
1
2
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import { type Problem } from "./learn/index.js";
|
|
3
3
|
import { type ItemStatus, type Learning, type NoteRuns, type Shown } from "./learning.js";
|
|
4
4
|
import type { Impact } from "./learning-run.js";
|
|
5
|
+
import { type LearnedUse } from "./store-reads/learning.js";
|
|
5
6
|
import type { Store } from "./store/store.js";
|
|
6
7
|
type Page<T> = {
|
|
7
8
|
items: T[];
|
|
@@ -29,6 +30,7 @@ type NoteView = {
|
|
|
29
30
|
type Retired = {
|
|
30
31
|
at: string;
|
|
31
32
|
by: "person" | "run";
|
|
33
|
+
from: "active" | "pending";
|
|
32
34
|
};
|
|
33
35
|
/** The newest change to a note, skill or draft (its file: the note, a SKILL.md, a draft's README.md): what it was, by
|
|
34
36
|
* whom and when. A person's is named by its commit (`learning: <kind> by a person: <file>`); a run's merge is `learned`. */
|
|
@@ -142,6 +144,8 @@ export declare function writeNote(data: string, agentId: string, raw: string, in
|
|
|
142
144
|
draftTools?: () => Promise<{
|
|
143
145
|
tools: string[];
|
|
144
146
|
gated: Record<string, string>;
|
|
147
|
+
deniedBy?: Record<string, "agent" | "server" | "default">;
|
|
148
|
+
ask?: DraftAsk;
|
|
145
149
|
}>;
|
|
146
150
|
}): Promise<{
|
|
147
151
|
status: 200 | 201;
|
|
@@ -149,6 +153,30 @@ export declare function writeNote(data: string, agentId: string, raw: string, in
|
|
|
149
153
|
text: string;
|
|
150
154
|
etag: string;
|
|
151
155
|
}>;
|
|
156
|
+
/** A learned workflow as a promotion makes it into an agent of its own: its folder's name, its README's description,
|
|
157
|
+
* its workflow.json parsed, and the tools its call nodes call. */
|
|
158
|
+
export type Promotable = {
|
|
159
|
+
name: string;
|
|
160
|
+
description: string;
|
|
161
|
+
workflow: Record<string, unknown>;
|
|
162
|
+
calls: string[];
|
|
163
|
+
};
|
|
164
|
+
/** POST /agents/{id}/learning/workflows/{name}/promote's read of the learned workflow `raw` (percent-encoded) on agent
|
|
165
|
+
* `agentId`'s main: an active one alone, as every later run is given it. One that waits for its owner's OK, or that a
|
|
166
|
+
* person retired, is 409 learned_not_active: a promotion never runs what the owner has not let every run use. Each of
|
|
167
|
+
* its files is checked again as a restore checks it (unstorable: a secret's shape, the host's values as they are now,
|
|
168
|
+
* a hidden character), and its workflow.json as the learning checker checks a run's draft against the agent's tools and
|
|
169
|
+
* its gate (draftProblems: the DSL's validation with no code run, no code node, no shell or executor call, no call node
|
|
170
|
+
* on a tool the agent does not have or the gate holds to ask or deny). Any of those is 400 with `problems`, printable.
|
|
171
|
+
* Reads only: the folder is never written. */
|
|
172
|
+
export declare function promotable(data: string, agentId: string, raw: string, input: {
|
|
173
|
+
refuse: readonly string[];
|
|
174
|
+
draftTools: () => Promise<{
|
|
175
|
+
tools: string[];
|
|
176
|
+
gated: Record<string, string>;
|
|
177
|
+
deniedBy?: Record<string, "agent" | "server" | "default">;
|
|
178
|
+
}>;
|
|
179
|
+
}): Promise<Promotable>;
|
|
152
180
|
/** GET /runs/{id}/learning's body, from the run's learning as it reads now, the seed it started from and whether it
|
|
153
181
|
* settled: the one shape, read from the one store (store-reads/learning.ts
|
|
154
182
|
* runLearningOverStore). */
|
|
@@ -157,6 +185,7 @@ export declare function runLearningBody(input: {
|
|
|
157
185
|
readonly learning: Learning;
|
|
158
186
|
readonly seed: string | null;
|
|
159
187
|
readonly settled: boolean;
|
|
188
|
+
readonly used?: LearnedUse;
|
|
160
189
|
}, shown: Shown, secrets: readonly string[]): {
|
|
161
190
|
seed: string | null;
|
|
162
191
|
merged: string | null;
|
|
@@ -176,13 +205,28 @@ export declare function runLearningBody(input: {
|
|
|
176
205
|
keep: boolean;
|
|
177
206
|
}[];
|
|
178
207
|
} | null;
|
|
179
|
-
problems:
|
|
208
|
+
problems: {
|
|
209
|
+
detail: string;
|
|
210
|
+
path?: string | undefined;
|
|
211
|
+
rule: import("./learn/check.js").Rule;
|
|
212
|
+
}[];
|
|
180
213
|
cost_usd: {
|
|
181
214
|
grade: number | null;
|
|
182
215
|
};
|
|
183
216
|
tokens: {
|
|
184
217
|
grade: import("./learning.js").Tokens | null;
|
|
185
218
|
};
|
|
219
|
+
used: {
|
|
220
|
+
skills: {
|
|
221
|
+
name: string;
|
|
222
|
+
read: boolean;
|
|
223
|
+
}[];
|
|
224
|
+
workflows: {
|
|
225
|
+
name: string;
|
|
226
|
+
calls: number;
|
|
227
|
+
failed: number;
|
|
228
|
+
}[];
|
|
229
|
+
};
|
|
186
230
|
given?: import("./learning.js").NoteUsed[];
|
|
187
231
|
read?: import("./learning.js").NoteUsed[];
|
|
188
232
|
learned?: import("./learning.js").NoteLearned[];
|
|
@@ -190,7 +234,7 @@ export declare function runLearningBody(input: {
|
|
|
190
234
|
workflows?: import("./learning.js").LearnedFile[];
|
|
191
235
|
run: string;
|
|
192
236
|
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
193
|
-
reason: "empty" | "
|
|
237
|
+
reason: "empty" | "cancelled" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
194
238
|
detail: string | null;
|
|
195
239
|
at: string;
|
|
196
240
|
};
|
|
@@ -199,7 +243,8 @@ export declare function runLearningBody(input: {
|
|
|
199
243
|
* its agent's learning folder); before, its kept proposal (new notes only, from its learning_proposals row) against its
|
|
200
244
|
* seed; a run that proposed nothing, no file, against the seed its launch's learning start names. A run that does not
|
|
201
245
|
* learn (no learning start and no learning end) is not_found. A file's patch is withheld when too large (as the script
|
|
202
|
-
* wrote it), or when it holds one of the host's secrets now (`shown`)
|
|
246
|
+
* wrote it), or when it holds one of the host's secrets now (`shown`); any other is served as every learning text is
|
|
247
|
+
* (`shown.text`: a loopback address reads "a local address"). */
|
|
203
248
|
export declare function runDiffOverStore(data: string, store: Store, runId: string, shown: Shown): Promise<{
|
|
204
249
|
base: string;
|
|
205
250
|
head: string;
|