@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
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import type { MessageOrigin } from "
|
|
1
|
+
import type { MessageOrigin } from "../timeline/index.js";
|
|
2
|
+
/** The session (sessions.ts journalSessions) a workflow run's call nodes log their effects on (KINDS.nodeEffect). */
|
|
3
|
+
export declare const NODE_LOG_SESSION = "node-log";
|
|
4
|
+
/** The phase row before a message a CLI run sends again (adapter-loop.ts CliRecord.sending): its runner was lost after
|
|
5
|
+
* sending it, before the message was recorded, so the model may read it twice, and the turn it starts is paid like any
|
|
6
|
+
* other. */
|
|
7
|
+
export declare const MESSAGE_SENT_AGAIN = "Your message was sent again after the runner restarted: it may have reached the model before, and this turn is paid again.";
|
|
2
8
|
export declare const KINDS: {
|
|
3
9
|
/** A tool call about to run: written before it runs (and before the flush that precedes a side effect). */
|
|
4
10
|
readonly callStart: "agentrun.call.start";
|
|
11
|
+
/** A call whose start was written at its park (CallStartData.parked) is about to be sent: committed and flushed before
|
|
12
|
+
* the send, once. Only a parked call with this mark may have been sent; one without it never left. */
|
|
13
|
+
readonly callSent: "agentrun.call.sent";
|
|
5
14
|
/** How it ended: written after it ran, or by recovery for a start with no end (replay-safe reruns and ends done;
|
|
6
15
|
* any other ends interrupted, and the model is told). */
|
|
7
16
|
readonly callEnd: "agentrun.call.end";
|
|
8
17
|
/** A message: the person's, a steer, or the model's. */
|
|
9
18
|
readonly message: "agentrun.message";
|
|
19
|
+
/** A message a CLI run took mid-turn is about to be sent as a turn of its own (adapter-loop.ts sendAfterTurn): its
|
|
20
|
+
* command row's id, committed and flushed before the send. Its row is taken only after the send, so a runner lost in
|
|
21
|
+
* between leaves this mark with the row untaken: the next claim sends it again and says so (MESSAGE_SENT_AGAIN). Neither
|
|
22
|
+
* a call nor a message, so the reader passes over it. */
|
|
23
|
+
readonly messageSending: "agentrun.message.sending";
|
|
10
24
|
/** A pi input the person did not type (a trigger's message): pi's user entry under the host's kind, its `data.origin`
|
|
11
25
|
* the Timeline's attribution (pi-durable-agent's originMatcher reads a host's user entry's own origin). The model
|
|
12
26
|
* reads it as any message. */
|
|
@@ -35,11 +49,23 @@ export declare const KINDS: {
|
|
|
35
49
|
/** The resume of a paused workflow run (a `resume` row), taken: the workflow goes on from its journal. Neither a call nor
|
|
36
50
|
* a message, so the reader passes over it. */
|
|
37
51
|
readonly resume: "agentrun.resume";
|
|
52
|
+
/** A paid call the cap refused for room, kept at its refusal (the Refusal): its pause lands at the model's next request
|
|
53
|
+
* (adapter-loop.ts pauseFor), and a claim lost before that restores it from here (pendingPauseOf). No run patch, and
|
|
54
|
+
* neither a call nor a message, so the reader passes over it. */
|
|
55
|
+
readonly pausePending: "agentrun.pause.pending";
|
|
56
|
+
/** A workflow call node's effect, as it starts and as it ends (pause.ts NodeLine: its path, item, tool, label, input,
|
|
57
|
+
* then its status and output or error), on the run's node-log session (NODE_LOG_SESSION): the run's graph lists its
|
|
58
|
+
* effects from these. Written as the effect runs, never for one the driver answers from its receipt. */
|
|
59
|
+
readonly nodeEffect: "agentrun.node.effect";
|
|
38
60
|
/** A CLI run's end-of-run turn (the loop's record): its prompt (`role: "person"`) and its answer (`role: "model"`, the
|
|
39
61
|
* text in `model` as pi's answer carries it), the entry and the answer of the submission its request id names, the
|
|
40
62
|
* same submission pi's adapter writes, so the step reads both alike. Neither a call nor a message: the reader passes
|
|
41
63
|
* over it, and the turn is never on the run's visible record. */
|
|
42
64
|
readonly endOfRunTurn: "agentrun.end-of-run.turn";
|
|
65
|
+
/** What a learning run's claim laid of its seed: the learned skills it was given (`skills`, by name) and the learned
|
|
66
|
+
* workflows its learned_workflow tool runs (`workflows`, by name). Written once per claim, on the root; the newest is
|
|
67
|
+
* what the run was given. Neither a call nor a message. */
|
|
68
|
+
readonly learningLaid: "agentrun.learning.laid";
|
|
43
69
|
/** A learning run's grade: the verdict and what it spent, written before its merge (a resumed run never asks again). */
|
|
44
70
|
readonly learningGraded: "agentrun.learning.graded";
|
|
45
71
|
/** A learning run's merge: the new main and its commit, with the run's end. */
|
|
@@ -95,6 +121,13 @@ export interface RaiseData {
|
|
|
95
121
|
readonly capUsd: number;
|
|
96
122
|
readonly takes: readonly number[];
|
|
97
123
|
}
|
|
124
|
+
/** The cap a run is held to now, from its journal: its newest raise's (a KINDS.raise entry above 0), else its launch's;
|
|
125
|
+
* none for a run launched with no cap. The one figure every reader of the run's cap takes: each request's admission
|
|
126
|
+
* (adapter-loop.ts capNow), the run's view, and its end-of-run look back (learning-end.ts). */
|
|
127
|
+
export declare function capNowOf(launchCapUsd: number | undefined, entries: readonly {
|
|
128
|
+
readonly kind: string;
|
|
129
|
+
readonly data?: unknown;
|
|
130
|
+
}[]): number | undefined;
|
|
98
131
|
/** What a run parked at its cap waits on (the kernel cap's parkOf): its cap, what the cap counted as taken, the least the
|
|
99
132
|
* refused request needs, the least cap that sends it and the raise offered, in the run's money units (dollars). */
|
|
100
133
|
export interface BudgetData {
|
|
@@ -118,6 +151,15 @@ export interface CallStartData {
|
|
|
118
151
|
readonly input: unknown;
|
|
119
152
|
/** May run again after a crash (it changes nothing outside the run): the tool registry's own flag. */
|
|
120
153
|
readonly replaySafe: boolean;
|
|
154
|
+
/** Written as the call reached its gate through a CLI's own MCP client, or its tool bridge's gate asked about it, before
|
|
155
|
+
* any answer: nothing is sent until its agentrun.call.sent mark (KINDS.callSent). */
|
|
156
|
+
readonly parked?: true;
|
|
157
|
+
/** Parked in its CLI's tool bridge (adapter-loop.ts bridgeGate), not at an MCP door: the bridge holds the call and hands
|
|
158
|
+
* the CLI nothing while it waits, so no waiting result shows for it (store-reads/journal.ts piShaped), as on pi. */
|
|
159
|
+
readonly bridge?: true;
|
|
160
|
+
/** The harness's working directory (a CLI's), which an absolute path in `input` is built from: the run's rows name a
|
|
161
|
+
* path under it by its name in the workspace (store-reads/journal.ts runTimeline). */
|
|
162
|
+
readonly cwd?: string;
|
|
121
163
|
/** When it was written (ms, the loop's clock): the Timeline dates the call's row by it. */
|
|
122
164
|
readonly at?: number;
|
|
123
165
|
}
|
|
@@ -166,12 +208,12 @@ export interface AskData {
|
|
|
166
208
|
/** Its approval price (the spec's approvalPrice); null when it has none. */
|
|
167
209
|
readonly price?: ApprovalPrice | null;
|
|
168
210
|
}
|
|
169
|
-
/** How an ask was answered: approved, denied,
|
|
170
|
-
export type AnswerDecision = "allow" | "deny" | "withdrawn";
|
|
211
|
+
/** How an ask was answered: approved, denied, withdrawn (a stop while the call waited) or canceled (a cancel). */
|
|
212
|
+
export type AnswerDecision = "allow" | "deny" | "withdrawn" | "canceled";
|
|
171
213
|
export interface AnswerData {
|
|
172
214
|
readonly callId: string;
|
|
173
215
|
readonly approved: boolean;
|
|
174
|
-
/** allow, deny, or
|
|
216
|
+
/** allow, deny, withdrawn or canceled: main's resolved entry. Optional for an answer written before it. */
|
|
175
217
|
readonly decision?: AnswerDecision;
|
|
176
218
|
/** When it was answered (ISO), from the loop's clock (or the runner's, for an end it writes itself). */
|
|
177
219
|
readonly answeredAt?: string;
|
|
@@ -191,12 +233,13 @@ export interface AnswerData {
|
|
|
191
233
|
/** The withdrawn answers a stopped end writes in `entries`: for every call still waiting (an ask with no answer), and
|
|
192
234
|
* for every approved call that had not finished (no result, or one its abort wrote), which the stop overrides, keeping
|
|
193
235
|
* the allow it was given (main's supersede: an answer the run had not acted on to the end is withdrawn by the stop). A
|
|
194
|
-
* call that finished before the stop keeps its allow and its result.
|
|
236
|
+
* call that finished before the stop keeps its allow and its result. `decision`: "canceled" for a cancel's end, whose
|
|
237
|
+
* calls read cancelled with their run; "withdrawn" for a stop's. */
|
|
195
238
|
export declare function withdrawnAnswers(entries: readonly {
|
|
196
239
|
readonly kind: string;
|
|
197
240
|
readonly data?: unknown;
|
|
198
241
|
readonly model?: unknown;
|
|
199
|
-
}[], answeredAt: string): AnswerData[];
|
|
242
|
+
}[], answeredAt: string, decision?: "withdrawn" | "canceled"): AnswerData[];
|
|
200
243
|
export interface EndData {
|
|
201
244
|
readonly state: "ended" | "stopped" | "failed";
|
|
202
245
|
readonly summary?: string;
|
|
@@ -209,9 +252,20 @@ export interface EndData {
|
|
|
209
252
|
/** A completed workflow run's output: the value at its workflow's output path (readWorkflowRun's `output`, null when it
|
|
210
253
|
* has none), kept at its end as main's server kept it on the run (runs.ts workflowEnd), and served as result.output. */
|
|
211
254
|
readonly output?: unknown;
|
|
255
|
+
/** An escalated workflow run's review (outcome escalated): why it waits for a person, as its escalate node said it. */
|
|
256
|
+
readonly review?: EndReview;
|
|
257
|
+
}
|
|
258
|
+
/** An escalated workflow run's review as its end keeps it: the escalation's kind, the escalate node's label (else the node
|
|
259
|
+
* it escalated at), and its summary (else the run's). Served as the run's `review`, `at` its end. */
|
|
260
|
+
export interface EndReview {
|
|
261
|
+
readonly kind: string | null;
|
|
262
|
+
readonly node: string | null;
|
|
263
|
+
readonly reason: string;
|
|
212
264
|
}
|
|
213
265
|
export interface SessionKeyData {
|
|
214
266
|
readonly key: string;
|
|
215
267
|
/** The conversation whose entries are this session's resume log. */
|
|
216
268
|
readonly conversation: number;
|
|
217
269
|
}
|
|
270
|
+
/** The session a workflow's model requests are booked under, in its run's journal. */
|
|
271
|
+
export declare const WORKFLOW_SESSION = "workflow";
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { INTERRUPTED_TEXT } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
+
/** The session (sessions.ts journalSessions) a workflow run's call nodes log their effects on (KINDS.nodeEffect). */
|
|
3
|
+
export const NODE_LOG_SESSION = "node-log";
|
|
4
|
+
/** The phase row before a message a CLI run sends again (adapter-loop.ts CliRecord.sending): its runner was lost after
|
|
5
|
+
* sending it, before the message was recorded, so the model may read it twice, and the turn it starts is paid like any
|
|
6
|
+
* other. */
|
|
7
|
+
export const MESSAGE_SENT_AGAIN = "Your message was sent again after the runner restarted: it may have reached the model before, and this turn is paid again.";
|
|
2
8
|
export const KINDS = {
|
|
3
9
|
/** A tool call about to run: written before it runs (and before the flush that precedes a side effect). */
|
|
4
10
|
callStart: "agentrun.call.start",
|
|
11
|
+
/** A call whose start was written at its park (CallStartData.parked) is about to be sent: committed and flushed before
|
|
12
|
+
* the send, once. Only a parked call with this mark may have been sent; one without it never left. */
|
|
13
|
+
callSent: "agentrun.call.sent",
|
|
5
14
|
/** How it ended: written after it ran, or by recovery for a start with no end (replay-safe reruns and ends done;
|
|
6
15
|
* any other ends interrupted, and the model is told). */
|
|
7
16
|
callEnd: "agentrun.call.end",
|
|
8
17
|
/** A message: the person's, a steer, or the model's. */
|
|
9
18
|
message: "agentrun.message",
|
|
19
|
+
/** A message a CLI run took mid-turn is about to be sent as a turn of its own (adapter-loop.ts sendAfterTurn): its
|
|
20
|
+
* command row's id, committed and flushed before the send. Its row is taken only after the send, so a runner lost in
|
|
21
|
+
* between leaves this mark with the row untaken: the next claim sends it again and says so (MESSAGE_SENT_AGAIN). Neither
|
|
22
|
+
* a call nor a message, so the reader passes over it. */
|
|
23
|
+
messageSending: "agentrun.message.sending",
|
|
10
24
|
/** A pi input the person did not type (a trigger's message): pi's user entry under the host's kind, its `data.origin`
|
|
11
25
|
* the Timeline's attribution (pi-durable-agent's originMatcher reads a host's user entry's own origin). The model
|
|
12
26
|
* reads it as any message. */
|
|
@@ -35,11 +49,23 @@ export const KINDS = {
|
|
|
35
49
|
/** The resume of a paused workflow run (a `resume` row), taken: the workflow goes on from its journal. Neither a call nor
|
|
36
50
|
* a message, so the reader passes over it. */
|
|
37
51
|
resume: "agentrun.resume",
|
|
52
|
+
/** A paid call the cap refused for room, kept at its refusal (the Refusal): its pause lands at the model's next request
|
|
53
|
+
* (adapter-loop.ts pauseFor), and a claim lost before that restores it from here (pendingPauseOf). No run patch, and
|
|
54
|
+
* neither a call nor a message, so the reader passes over it. */
|
|
55
|
+
pausePending: "agentrun.pause.pending",
|
|
56
|
+
/** A workflow call node's effect, as it starts and as it ends (pause.ts NodeLine: its path, item, tool, label, input,
|
|
57
|
+
* then its status and output or error), on the run's node-log session (NODE_LOG_SESSION): the run's graph lists its
|
|
58
|
+
* effects from these. Written as the effect runs, never for one the driver answers from its receipt. */
|
|
59
|
+
nodeEffect: "agentrun.node.effect",
|
|
38
60
|
/** A CLI run's end-of-run turn (the loop's record): its prompt (`role: "person"`) and its answer (`role: "model"`, the
|
|
39
61
|
* text in `model` as pi's answer carries it), the entry and the answer of the submission its request id names, the
|
|
40
62
|
* same submission pi's adapter writes, so the step reads both alike. Neither a call nor a message: the reader passes
|
|
41
63
|
* over it, and the turn is never on the run's visible record. */
|
|
42
64
|
endOfRunTurn: "agentrun.end-of-run.turn",
|
|
65
|
+
/** What a learning run's claim laid of its seed: the learned skills it was given (`skills`, by name) and the learned
|
|
66
|
+
* workflows its learned_workflow tool runs (`workflows`, by name). Written once per claim, on the root; the newest is
|
|
67
|
+
* what the run was given. Neither a call nor a message. */
|
|
68
|
+
learningLaid: "agentrun.learning.laid",
|
|
43
69
|
/** A learning run's grade: the verdict and what it spent, written before its merge (a resumed run never asks again). */
|
|
44
70
|
learningGraded: "agentrun.learning.graded",
|
|
45
71
|
/** A learning run's merge: the new main and its commit, with the run's end. */
|
|
@@ -67,6 +93,15 @@ export const ASK_PERSON_WAITING = "Waiting for your reply";
|
|
|
67
93
|
export const HANDOVER_WAITING = "Waiting for you in the browser";
|
|
68
94
|
/** The summaries of a run held in its claim while it waits on its person: the server tells run.needs_input by them. */
|
|
69
95
|
export const HELD_WAITS = new Set([ASK_PERSON_WAITING, HANDOVER_WAITING]);
|
|
96
|
+
/** The cap a run is held to now, from its journal: its newest raise's (a KINDS.raise entry above 0), else its launch's;
|
|
97
|
+
* none for a run launched with no cap. The one figure every reader of the run's cap takes: each request's admission
|
|
98
|
+
* (adapter-loop.ts capNow), the run's view, and its end-of-run look back (learning-end.ts). */
|
|
99
|
+
export function capNowOf(launchCapUsd, entries) {
|
|
100
|
+
if (launchCapUsd === undefined)
|
|
101
|
+
return undefined;
|
|
102
|
+
const raised = entries.findLast((entry) => entry.kind === KINDS.raise && typeof entry.data?.capUsd === "number" && entry.data.capUsd > 0);
|
|
103
|
+
return raised ? raised.data.capUsd : launchCapUsd;
|
|
104
|
+
}
|
|
70
105
|
/** What a call that already ended answers when it is asked for again (a parked call's resume, a CLI's re-issue of its id):
|
|
71
106
|
* its recorded output; for one a crash cut with none, the kernel's words for an outcome not known (INTERRUPTED_TEXT);
|
|
72
107
|
* else that `tool`'s call ended so. An error unless it ended done. */
|
|
@@ -90,8 +125,9 @@ function finished(entries, callId) {
|
|
|
90
125
|
/** The withdrawn answers a stopped end writes in `entries`: for every call still waiting (an ask with no answer), and
|
|
91
126
|
* for every approved call that had not finished (no result, or one its abort wrote), which the stop overrides, keeping
|
|
92
127
|
* the allow it was given (main's supersede: an answer the run had not acted on to the end is withdrawn by the stop). A
|
|
93
|
-
* call that finished before the stop keeps its allow and its result.
|
|
94
|
-
|
|
128
|
+
* call that finished before the stop keeps its allow and its result. `decision`: "canceled" for a cancel's end, whose
|
|
129
|
+
* calls read cancelled with their run; "withdrawn" for a stop's. */
|
|
130
|
+
export function withdrawnAnswers(entries, answeredAt, decision = "withdrawn") {
|
|
95
131
|
const answers = new Map();
|
|
96
132
|
for (const entry of entries)
|
|
97
133
|
if (entry.kind === KINDS.answer)
|
|
@@ -107,10 +143,12 @@ export function withdrawnAnswers(entries, answeredAt) {
|
|
|
107
143
|
seen.add(callId);
|
|
108
144
|
const given = answers.get(callId);
|
|
109
145
|
if (!given)
|
|
110
|
-
out.push({ callId, approved: false, decision
|
|
111
|
-
else if (given.approved && given.decision !== "withdrawn" && !finished(entries, callId)) {
|
|
112
|
-
out.push({ callId, approved: false, decision
|
|
146
|
+
out.push({ callId, approved: false, decision, answeredAt });
|
|
147
|
+
else if (given.approved && given.decision !== "withdrawn" && given.decision !== "canceled" && !finished(entries, callId)) {
|
|
148
|
+
out.push({ callId, approved: false, decision, answeredAt, superseded: { decision: "allow", ...(given.answeredAt ? { answeredAt: given.answeredAt } : {}) } });
|
|
113
149
|
}
|
|
114
150
|
}
|
|
115
151
|
return out;
|
|
116
152
|
}
|
|
153
|
+
/** The session a workflow's model requests are booked under, in its run's journal. */
|
|
154
|
+
export const WORKFLOW_SESSION = "workflow";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
|
-
import { type MessageOrigin } from "
|
|
2
|
+
import { type MessageOrigin } from "../timeline/index.js";
|
|
3
3
|
import type { EntryRecord, SubmissionRecord, TaskRecord } from "@earendil-works/pi-durable";
|
|
4
4
|
import { type CallEndData, type MessageRole } from "./journal-kinds.js";
|
|
5
5
|
import type { JournalReads } from "../store/store.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { originOf } from "
|
|
1
|
+
import { originOf } from "../timeline/index.js";
|
|
2
2
|
import { reflectFrom } from "./end-of-run.js";
|
|
3
3
|
import { KINDS } from "./journal-kinds.js";
|
|
4
4
|
const PAGE = 500;
|
|
@@ -97,7 +97,7 @@ export function messagesOf(from) {
|
|
|
97
97
|
const out = [];
|
|
98
98
|
const records = asRecords(from);
|
|
99
99
|
// The end-of-run turn's, from the entry its input placed on (the reader's tag, as the server's labelled() reads it).
|
|
100
|
-
const from_ = reflectFrom(records.submissions ?? []);
|
|
100
|
+
const from_ = reflectFrom(records.submissions ?? [], records.entries);
|
|
101
101
|
const turn = (entry) => (from_ !== undefined && entry >= from_ ? { learning: true } : {});
|
|
102
102
|
for (const entry of recordOf(records.entries)) {
|
|
103
103
|
const at = entryNumber(entry);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type BeforeRequest, type Wire } from "@parcha/agentrun-kernel";
|
|
2
2
|
import type { LearningLoopDeps } from "./learning-loop.js";
|
|
3
|
+
/** How long the ask waits, once the grade answered, for the proxy to book its request: the proxy books a request after its
|
|
4
|
+
* client has the whole answer (when the provider's stream ends, which can come later), so the spend is read once it is
|
|
5
|
+
* booked. One booked later than this reads unknown (null), never $0. */
|
|
6
|
+
export declare const GRADE_BOOKING_WAIT_MS = 10000;
|
|
3
7
|
/** The session the grader's requests are booked under, in the learning run's journal. */
|
|
4
8
|
export declare const GRADE_SESSION = "learning.grade";
|
|
5
9
|
/** Where the grader's request goes: the route's wire (`api`, Anthropic's Messages or OpenAI's Responses) at `origin`, for
|
|
@@ -13,6 +13,10 @@ import { startModelProxy } from "@parcha/agentrun-kernel/host";
|
|
|
13
13
|
import { sessionProvider } from "../port-models.js";
|
|
14
14
|
import { policyFor } from "./adapters/pi.js";
|
|
15
15
|
import { journalSessions } from "./sessions.js";
|
|
16
|
+
/** How long the ask waits, once the grade answered, for the proxy to book its request: the proxy books a request after its
|
|
17
|
+
* client has the whole answer (when the provider's stream ends, which can come later), so the spend is read once it is
|
|
18
|
+
* booked. One booked later than this reads unknown (null), never $0. */
|
|
19
|
+
export const GRADE_BOOKING_WAIT_MS = 10_000;
|
|
16
20
|
/** The session the grader's requests are booked under, in the learning run's journal. */
|
|
17
21
|
export const GRADE_SESSION = "learning.grade";
|
|
18
22
|
const PROVIDER = "agentrun-grade";
|
|
@@ -40,6 +44,8 @@ export function bookedAsk(options) {
|
|
|
40
44
|
// The cap is the learning run's: asked with every session of the run summed, never this one's alone.
|
|
41
45
|
const hostCheck = options.beforeRequest ? runBooking(sessions, options.beforeRequest) : undefined;
|
|
42
46
|
let refused;
|
|
47
|
+
// Told once the grade's own request is booked (its request_end), never by a cut request booked before it.
|
|
48
|
+
let booked;
|
|
43
49
|
const booking = await modelPortFor(writer, {
|
|
44
50
|
key: GRADE_SESSION,
|
|
45
51
|
label: "grade",
|
|
@@ -53,11 +59,14 @@ export function bookedAsk(options) {
|
|
|
53
59
|
onEvent: async (event) => {
|
|
54
60
|
if (event.type === "request_start")
|
|
55
61
|
await run.flush();
|
|
62
|
+
if (event.type === "request_end")
|
|
63
|
+
booked?.();
|
|
56
64
|
},
|
|
57
65
|
});
|
|
58
66
|
// A grade request an earlier attempt sent and a crash cut is booked first, at its held figure.
|
|
59
67
|
await booking.bookCut();
|
|
60
68
|
const before = booking.spentUsd();
|
|
69
|
+
const bookedOnce = new Promise((resolve) => (booked = () => resolve(true)));
|
|
61
70
|
// The policy of the route's wire, as pi's session takes it (pi.ts policyFor: claude-agent's on Messages, codex's on
|
|
62
71
|
// Responses, no fork); the grade offers no tool.
|
|
63
72
|
const proxy = await startModelProxy({
|
|
@@ -81,7 +90,12 @@ export function bookedAsk(options) {
|
|
|
81
90
|
if (answer.stopReason === "error" || answer.stopReason === "aborted")
|
|
82
91
|
throw new Error(`the grade's request failed: ${answer.errorMessage ?? answer.stopReason}`);
|
|
83
92
|
const text = answer.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join("");
|
|
84
|
-
|
|
93
|
+
// The spend once the proxy booked this request: read before, it is the spend without it ($0 for the grade). Not
|
|
94
|
+
// booked within the wait: unknown.
|
|
95
|
+
let timer;
|
|
96
|
+
const inTime = await Promise.race([bookedOnce, new Promise((resolve) => (timer = setTimeout(() => resolve(false), GRADE_BOOKING_WAIT_MS)))]);
|
|
97
|
+
clearTimeout(timer);
|
|
98
|
+
const after = inTime ? booking.spentUsd() : null;
|
|
85
99
|
const usd = before === null || after === null ? null : after - before;
|
|
86
100
|
// pi-ai counts cache reads and writes apart from input, as the grade's tokens do.
|
|
87
101
|
const used = answer.usage;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TimelineEvent } from "../timeline/index.js";
|
|
2
|
+
import { type LearningFolder } from "../learn/folder.js";
|
|
2
3
|
import { type RunLaunch } from "../run-launch.js";
|
|
3
4
|
import { type SignInReader } from "../run-view.js";
|
|
4
5
|
import type { Store } from "../store/store.js";
|
|
@@ -23,9 +24,23 @@ export interface LearningEndDeps {
|
|
|
23
24
|
/** Every secret the server keeps sealed, read once at the run's end (store-secrets.ts storeSecrets over the store, the
|
|
24
25
|
* seal key and the data directory), never learned. A throw is a list that can't be read: the run learns nothing. */
|
|
25
26
|
readonly stored?: () => Promise<readonly string[]>;
|
|
26
|
-
/** The grade model the server names (learning.ts gradeModelOf); none, from `env` as the server reads it. */
|
|
27
|
-
readonly gradeModel?: string;
|
|
28
27
|
}
|
|
29
28
|
/** The end-of-run step for a run launched with `launch`: undefined when its launch records no learning start (a run that
|
|
30
29
|
* does not learn is asked nothing and keeps nothing), else the reflect hook over the run's store. */
|
|
31
30
|
export declare function learningEndOfRun(launch: RunLaunch, deps: LearningEndDeps): EndOfRunTurn | undefined;
|
|
31
|
+
/** Whether a run's job, by its timeline `rows` (the end-of-run turn's own, labelled LEARNING_LABEL, left out), gave
|
|
32
|
+
* nothing new to look back on: it called tools, every one of them learned_workflow (a workflow's own nested calls are
|
|
33
|
+
* its), each answering; no tool result failed or was refused; no error, approval or wait; and one message, its first,
|
|
34
|
+
* came in. Anything else is asked its end-of-run turn. */
|
|
35
|
+
export declare function onlyLearnedWorkflows(rows: readonly TimelineEvent[]): boolean;
|
|
36
|
+
/** How many of an agent's latest runs draftForOf reads at most: a skill offered to fewer than DRAFT_AFTER_RUNS of them is
|
|
37
|
+
* no repeated job. */
|
|
38
|
+
export declare const DRAFT_SCAN_RUNS = 200;
|
|
39
|
+
/** The learned skill whose job the end-of-run turn asks for as a workflow draft: of the skills run `runId` was offered
|
|
40
|
+
* (its launch's learning start), the first in the seed's order (the one changed last first) offered to DRAFT_AFTER_RUNS
|
|
41
|
+
* or more runs of agent `agentId` started before it (each run's launch says what it was offered; its latest
|
|
42
|
+
* DRAFT_SCAN_RUNS runs are read newest first, those after `runId` in that order counted, only until every skill has its
|
|
43
|
+
* count), with no learned workflow of its name on the agent's main, active or waiting for
|
|
44
|
+
* its owner's OK (the folder's snapshot). One at most: a turn keeps one workflow draft. None when no skill qualifies, or
|
|
45
|
+
* when the folder can't be read: a read that fails asks for nothing, never a draft that may be there already. */
|
|
46
|
+
export declare function draftForOf(deps: Pick<LearningEndDeps, "store" | "learningFolder">, agentId: string, runId: string, offered: readonly string[]): Promise<string[]>;
|