@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.60
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 +402 -1
- package/README.md +516 -190
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/api-only.d.ts +2 -2
- package/dist/api-only.js +3 -3
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +3 -2
- package/dist/box-paths.js +5 -4
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +7 -0
- package/dist/chatgpt-plan.js +35 -11
- package/dist/claude-login-token.d.ts +20 -11
- package/dist/claude-login-token.js +175 -107
- package/dist/claude-login.d.ts +124 -33
- package/dist/claude-login.js +562 -85
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli-learning/connections.js +1 -1
- package/dist/cli.js +323 -292
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +6 -3
- package/dist/computer-attach.js +41 -29
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +2 -1
- package/dist/computers.js +6 -3
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-QnwGVBeU.js +166 -0
- package/dist/console/assets/index-DZi-muIj.js +629 -0
- package/dist/console/assets/share-pz61zIn9.js +6 -0
- package/dist/console/assets/styles-CcceGcu2.js +291 -0
- package/dist/console/assets/styles-fjQBFfMv.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.js +10 -4
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +12 -2
- package/dist/env-switch.js +23 -3
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -0
- package/dist/fal-price.d.ts +11 -1
- package/dist/fal-price.js +33 -0
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.d.ts +1 -2
- package/dist/harness-keys.js +10 -8
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +12 -0
- package/dist/harness-table.js +21 -6
- package/dist/harness.js +6 -2
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import-worker.js +2 -2
- package/dist/import.d.ts +20 -8
- package/dist/import.js +448 -187
- package/dist/key-refusal.d.ts +14 -2
- package/dist/key-refusal.js +97 -33
- package/dist/learn/audit.d.ts +28 -27
- package/dist/learn/audit.js +87 -62
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +9 -6
- package/dist/learn/compile.js +51 -28
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/ledger.d.ts +32 -29
- package/dist/learn/ledger.js +26 -19
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +119 -102
- package/dist/learn/promote.js +119 -262
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +25 -8
- package/dist/learning-cost.js +23 -8
- package/dist/learning-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +7 -0
- package/dist/live-reach.js +7 -0
- package/dist/mcp-api-only-origins.d.ts +15 -0
- package/dist/mcp-api-only-origins.js +40 -0
- package/dist/mcp-gateway.d.ts +22 -2
- package/dist/mcp-gateway.js +85 -11
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-resources.d.ts +1 -1
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +290 -79
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +58 -34
- package/dist/place-offers.js +96 -54
- package/dist/place.d.ts +41 -20
- package/dist/place.js +97 -47
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +3 -2
- package/dist/provider.js +17 -8
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +42 -9
- package/dist/redact/match.js +356 -54
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.d.ts +3 -3
- package/dist/run-launch.js +16 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +8 -5
- package/dist/runnable.js +26 -9
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +94 -47
- package/dist/runner/adapter-run-spec.d.ts +14 -1
- package/dist/runner/adapter-run-spec.js +73 -46
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +10 -9
- package/dist/runner/audit.js +64 -67
- package/dist/runner/beside.js +5 -6
- package/dist/runner/claim-secrets.d.ts +10 -3
- package/dist/runner/claim-secrets.js +29 -13
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +87 -58
- package/dist/runner/compare-end.d.ts +2 -3
- package/dist/runner/compare-end.js +30 -11
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.js +3 -4
- package/dist/runner/held.d.ts +5 -12
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +8 -2
- package/dist/runner/journal-kinds.js +23 -5
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +23 -7
- package/dist/runner/learning-end.d.ts +14 -24
- package/dist/runner/learning-end.js +52 -94
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.js +13 -12
- package/dist/runner/mcp-claim.js +21 -5
- package/dist/runner/mcp-run.d.ts +4 -0
- package/dist/runner/mcp-run.js +2 -0
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +12 -11
- package/dist/runner/presence.d.ts +1 -4
- package/dist/runner/presence.js +6 -8
- package/dist/runner/promotion.d.ts +39 -36
- package/dist/runner/promotion.js +168 -112
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +21 -14
- package/dist/runner/run-child-host.js +187 -141
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +3 -4
- package/dist/runner/runner.js +13 -9
- package/dist/runner/sdk-loop.js +10 -12
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +120 -32
- package/dist/runner/workflow-first.js +218 -94
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +26 -7
- package/dist/sdk/runs.js +194 -78
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +55 -9
- package/dist/secrets.js +345 -21
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +10 -3
- package/dist/server-keys.js +16 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +30 -18
- package/dist/server.js +520 -238
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/source-sync/auxiliary.js +2 -2
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +60 -11
- package/dist/store/schema.js +147 -17
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +17 -10
- package/dist/store/sqlite/run-patch.js +50 -13
- package/dist/store/sqlite/store.d.ts +9 -0
- package/dist/store/sqlite/store.js +194 -46
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +286 -38
- package/dist/store/store.js +27 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +50 -45
- package/dist/store-reads/learning.js +153 -116
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +49 -17
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +72 -9
- package/dist/template-eval.js +358 -64
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +8 -6
- package/dist/timeline/web-calls.js +10 -6
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +54 -13
- package/dist/tool-plane.js +103 -32
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +34 -0
- package/dist/web-holds.js +89 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +76 -28
- package/dist/web-save.js +23 -12
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +6 -2
- package/dist/workspace/attached-computers.js +5 -4
- package/dist/workspace/computer-deps.d.ts +23 -6
- package/dist/workspace/computer-deps.js +38 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +160 -54
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +19 -4
- package/dist/workspace/computer-providers.js +40 -6
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +2 -3
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.js +4 -5
- package/dist/workspace/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +7 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -14
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +22 -6
- package/templates/TOOLS.md +46 -0
- package/dist/console/assets/backend-CSAWUqtZ.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-DPh29cyz.js +0 -747
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
|
@@ -22,6 +22,7 @@ import { CAP_REFUSED, CAP_WRAPUP, COMPUTER_NOTE, endsTurn, HOST_PHASE, MESSAGE_O
|
|
|
22
22
|
import { raiseFollowUpId } from "../run-view.js";
|
|
23
23
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
24
24
|
import { genAiTracing } from "../otel/tracer.js";
|
|
25
|
+
import { tracedAgent, tracedEvent, tracedModel } from "../otel/genai.js";
|
|
25
26
|
/** The root entries a claim writes before its turn, whatever the run's turns are (its session's key, a phase row, a
|
|
26
27
|
* takeover's note, its computer's hold, the learning seed it laid, the computer it made): read past when a claim asks
|
|
27
28
|
* whether the run's root ends on its end (a fresh reopen). */
|
|
@@ -45,7 +46,7 @@ import { ClaimRefused, deniedText, noteOf, stopEnd } from "./loop-contract.js";
|
|
|
45
46
|
import { deniedText as setToDenyText, ENDED_WHILE_WAITING, refusedText, STOPPED_WHILE_WAITING } from "../refusal-words.js";
|
|
46
47
|
import { ADAPTER_API } from "../turn-end.js";
|
|
47
48
|
import { answerText, REFLECT_PREFIX, reflectRequestId } from "./end-of-run.js";
|
|
48
|
-
import { agentEntriesOf, approvalOf, BOOKING_WRITE_MS, CLOSE_MS, CUT_STEP_MS, END_PATCH_MS, END_PATCH_UNKNOWN, PARK_SIBLINGS_MS, readAgain, STOP_SETTLE_MS, commandRequest, cutLast, DEFAULT_RESTART_LIMIT, entriesOf, findData, Gate, heldReporter, INPUT_REQUEST, Interrupted, KernelFault, lastAnswerText, Parked, quiet, restartLimited, writesEntry, writesSubmission } from "./loop.js";
|
|
49
|
+
import { agentEntriesOf, approvalOf, BOOKING_WRITE_MS, CLOSE_MS, CUT_STEP_MS, END_PATCH_MS, END_PATCH_UNKNOWN, PARK_SIBLINGS_MS, REAL_TIMER, readAgain, STOP_SETTLE_MS, commandRequest, cutLast, DEFAULT_RESTART_LIMIT, entriesOf, findData, Gate, heldReporter, INPUT_REQUEST, Interrupted, KernelFault, lastAnswerText, Parked, quiet, restartLimited, writesEntry, writesSubmission } from "./loop.js";
|
|
49
50
|
import { outputMiss, outputRetryWords } from "../answer-json.js";
|
|
50
51
|
import { answerOnce, HAND_BACK, handBackOf } from "./hand-back.js";
|
|
51
52
|
import { isComputerCommand, journalHold } from "./computer-journal.js";
|
|
@@ -67,6 +68,7 @@ import { Fenced } from "../store/index.js";
|
|
|
67
68
|
import { answerAsServed } from "../answer-json.js";
|
|
68
69
|
import { reserveFor, stepAndAnswerFor, wrappingUp, wrapUpText } from "../wrap-up.js";
|
|
69
70
|
import { LEARNED_CARD_FIELDS, LEARNED_CLIP, LEARNED_WORKFLOW_TOOL, learnedApprovedTools } from "../learned-workflow.js";
|
|
71
|
+
import { LEARNED_NODES } from "../learned-nodes.js";
|
|
70
72
|
import { warnHoldShort } from "../print.js";
|
|
71
73
|
import { feedbackAsk, feedbackOf, jobEndOpen, pendingFeedbackOf } from "./feedback-round.js";
|
|
72
74
|
import { handbackText, servedAnswerOf, servedAnswerText, WORKFLOW_FIRST, WORKFLOW_FIRST_CALL } from "./workflow-first.js";
|
|
@@ -826,11 +828,11 @@ function adapterLoop(specOf, options, deps) {
|
|
|
826
828
|
* input's user entry left as pi writes it (its submission, which a re-claim answers from, unchanged), so the Timeline
|
|
827
829
|
* shows the next user entry with exactly this text as "AgentRun: …". Once per follow-up: the marker names its request
|
|
828
830
|
* id, and a re-claim that finds one under it writes none (a second would stay open, and could take a person's later
|
|
829
|
-
* message of the same words for the server's). A CLI's run records its follow-up
|
|
830
|
-
* the origin
|
|
831
|
+
* message of the same words for the server's). A CLI's run records its follow-up in its own record, written here with
|
|
832
|
+
* the origin (once under its request id, as the output retry's is), since the CLI's session keeps no user entry. */
|
|
831
833
|
const markServerFollowUp = async (theHarness, theRoot, text, requestId) => {
|
|
832
834
|
if (cliRecord)
|
|
833
|
-
return;
|
|
835
|
+
return await cliRecord.followUp(text, requestId, CAP_RAISED_ORIGIN);
|
|
834
836
|
const marked = (await entriesOf(gate.journal, theRoot.id, context)).some((entry) => entry.kind === MESSAGE_ORIGIN && entry.data?.requestId === requestId);
|
|
835
837
|
if (marked)
|
|
836
838
|
return;
|
|
@@ -1345,7 +1347,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1345
1347
|
};
|
|
1346
1348
|
/** run(claim), its trace ended with it: every span still open ends, with the claim's failure where it failed, handed to
|
|
1347
1349
|
* the exporter, which sends it in the background (tracer.ts: the claim's end never waits on a collector, and never
|
|
1348
|
-
* throws). */
|
|
1350
|
+
* throws). In a run's own process the end is posted to its runner, which exports; neither side flushes for it. */
|
|
1349
1351
|
async function traced(claim) {
|
|
1350
1352
|
try {
|
|
1351
1353
|
const end = await run(claim);
|
|
@@ -1555,8 +1557,10 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1555
1557
|
}
|
|
1556
1558
|
// The run's trace, from its claim's start, once its spec says what runs (a restart's spec changes nothing of it).
|
|
1557
1559
|
// The tracing is made long before (as the loop is): waited for only on the rare claim whose spec beat it.
|
|
1558
|
-
trace ??= (tracing ?? (await tracingMade)).now?.open({ startedAt: claimedAt
|
|
1559
|
-
|
|
1560
|
+
trace ??= (tracing ?? (await tracingMade)).now?.open({ startedAt: claimedAt });
|
|
1561
|
+
// Its agent, as the spec read it from the store, cut by the runner's redactor and of every secret shape (tracedAgent).
|
|
1562
|
+
const { agent, ...route } = spec.trace ?? {};
|
|
1563
|
+
trace?.known({ runId: claim.runId, ...(agent ? { agent: tracedAgent(agent, deps.redact) } : {}), harness: spec.adapter.id, ...(spec.facts?.wire === "plan" ? { plan: true } : {}), ...route });
|
|
1560
1564
|
mcp = spec.mcp;
|
|
1561
1565
|
specNow = spec;
|
|
1562
1566
|
specKnown = true;
|
|
@@ -1861,9 +1865,16 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1861
1865
|
return reserveOf(requestFigures(asked));
|
|
1862
1866
|
};
|
|
1863
1867
|
let bookingNow;
|
|
1864
|
-
// The
|
|
1865
|
-
//
|
|
1866
|
-
|
|
1868
|
+
// The computer's notes, in order, each until a request carrying it is answered: the replaced computer's
|
|
1869
|
+
// (spec.computerNote), then where the run's files are (spec.computerFilesNote), unless a COMPUTER_NOTE row marked
|
|
1870
|
+
// `files` says an earlier claim told it. One note per request: the replaced computer's goes before the wrap-up, so
|
|
1871
|
+
// the wrap-up waits a request; the files note goes after a wrap-up that is due, so it never holds one back.
|
|
1872
|
+
const filesTold = spec.computerFilesNote !== undefined && (await entriesOf(gate.journal, wrapUpRoot.id, context))
|
|
1873
|
+
.some((entry) => entry.kind === COMPUTER_NOTE && entry.data?.files === true);
|
|
1874
|
+
const computerNotes = [
|
|
1875
|
+
...(spec.computerNote !== undefined ? [{ words: spec.computerNote }] : []),
|
|
1876
|
+
...(spec.computerFilesNote !== undefined && !filesTold ? [{ words: spec.computerFilesNote, files: true }] : []),
|
|
1877
|
+
];
|
|
1867
1878
|
// The server's note a request carries (the replaced computer's, else the cap's wrap-up; `cap` says the wrap-up's
|
|
1868
1879
|
// figures), one request at a time: from its take until that request's admission ends, then, admitted carrying it
|
|
1869
1880
|
// (`turn`), until that request ends. Told once that request is answered (afterRequest); given back for the next
|
|
@@ -1876,7 +1887,8 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1876
1887
|
const takeNote = (model, asked) => {
|
|
1877
1888
|
if (carried && (carried.turn !== undefined || Date.now() - carried.at < WRAP_UP_OFFER_MS))
|
|
1878
1889
|
return undefined;
|
|
1879
|
-
const
|
|
1890
|
+
const first = reflecting ? undefined : computerNotes[0];
|
|
1891
|
+
const note = first !== undefined && !first.files ? first : (wrapUpNote(model, asked) ?? first);
|
|
1880
1892
|
carried = note ? { ...note, at: Date.now() } : undefined;
|
|
1881
1893
|
return note?.words;
|
|
1882
1894
|
};
|
|
@@ -1894,10 +1906,11 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1894
1906
|
what = "the free-limit wrap-up's row";
|
|
1895
1907
|
}
|
|
1896
1908
|
else if (told.cap === undefined) {
|
|
1897
|
-
|
|
1909
|
+
if (computerNotes[0]?.words === told.words)
|
|
1910
|
+
computerNotes.shift();
|
|
1898
1911
|
kind = COMPUTER_NOTE;
|
|
1899
|
-
data = { words: rowWords(told.words) };
|
|
1900
|
-
what = "the replaced computer's note row";
|
|
1912
|
+
data = { words: rowWords(told.words), ...(told.files ? { files: true } : {}) };
|
|
1913
|
+
what = told.files ? "the computer files note's row" : "the replaced computer's note row";
|
|
1901
1914
|
}
|
|
1902
1915
|
else {
|
|
1903
1916
|
const { leftUsd, capUsd } = told.cap;
|
|
@@ -2182,8 +2195,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2182
2195
|
},
|
|
2183
2196
|
});
|
|
2184
2197
|
// A call a stop cut answers whatever its tool said of the abort: it ends interrupted, never as its outcome.
|
|
2198
|
+
// A nesting tool that ended at a refused nested call (a script stopped there) ends refused, as that call did.
|
|
2185
2199
|
if (record)
|
|
2186
|
-
await record.end(toolContext.callId, stopAbort.signal.aborted ? "interrupted" : answer.isError ? "failed" : "done", answer.text);
|
|
2200
|
+
await record.end(toolContext.callId, stopAbort.signal.aborted ? "interrupted" : answer.refused && answer.isError ? "refused" : answer.isError ? "failed" : "done", answer.text);
|
|
2187
2201
|
// A CLI's question to the person (a turn-ending tool's call, answered): its turn is cut at its next request,
|
|
2188
2202
|
// as pi's ends here (TurnCut). Any other call's end after it lets the turn go on.
|
|
2189
2203
|
if (record && endsTurn(tool.name) && !answer.isError && !stopAbort.signal.aborted)
|
|
@@ -2283,8 +2297,16 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2283
2297
|
carried = undefined;
|
|
2284
2298
|
}
|
|
2285
2299
|
unbooked += 1;
|
|
2286
|
-
|
|
2287
|
-
|
|
2300
|
+
// Its chat span names the model asked only when the run knows it (a route's model, or one its price table names by
|
|
2301
|
+
// that same id: a CLI's table prices every id as the session's model, so a priced id alone proves nothing, and a
|
|
2302
|
+
// body's model is the client's words), else its route's model; whichever, cut (genai.ts tracedModel).
|
|
2303
|
+
if (ticket && trace && request.paid === undefined) {
|
|
2304
|
+
const traced = specNow?.trace;
|
|
2305
|
+
const routed = request.route === undefined ? traced?.model : traced?.routes?.get(request.route)?.model;
|
|
2306
|
+
const known = (asked) => asked === traced?.model || [...(traced?.routes?.values() ?? [])].some((via) => via.model === asked) || specNow?.runCap.modelOf(asked)?.id === asked;
|
|
2307
|
+
const model = tracedModel(request.model, { known, ...(routed ? { routed } : {}), ...(deps.redact ? { redact: deps.redact } : {}) });
|
|
2308
|
+
chats.set(ticket.turn, trace.request(model, request.route));
|
|
2309
|
+
}
|
|
2288
2310
|
// The conversation that asked, as its client named it (pi's, one of several asking at once): whose answer reads
|
|
2289
2311
|
// this request's booking (bookedCost).
|
|
2290
2312
|
const conversation = request.conversation;
|
|
@@ -2458,7 +2480,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2458
2480
|
// Every harness's events reach its trace first (its tool calls, a plan harness's turns), with a record or without.
|
|
2459
2481
|
const recorded = record ? onEvent(record) : undefined;
|
|
2460
2482
|
const traceAnd = (event) => {
|
|
2461
|
-
trace?.event(event);
|
|
2483
|
+
trace?.event(tracedEvent(event, { mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined, ...(deps.redact ? { redact: deps.redact } : {}) }));
|
|
2462
2484
|
recorded?.(event);
|
|
2463
2485
|
};
|
|
2464
2486
|
const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate: bridgeGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
|
|
@@ -2736,13 +2758,6 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2736
2758
|
memo: async (_key, value) => (typeof value === "function" ? value() : value),
|
|
2737
2759
|
});
|
|
2738
2760
|
const serveFirst = async (first) => {
|
|
2739
|
-
// The session's learned_workflow as this loop wraps a tool, but nesting nothing of the harness's: a call a crash
|
|
2740
|
-
// cut is ended interrupted and handed back, never run again (its record's start is not marked `nests`).
|
|
2741
|
-
const bare = spec.session.tools.find((tool) => tool.name === LEARNED_WORKFLOW_TOOL);
|
|
2742
|
-
if (!bare || !tools.some((tool) => tool.name === LEARNED_WORKFLOW_TOOL))
|
|
2743
|
-
return undefined;
|
|
2744
|
-
const { nests: _nests, ...plain } = bare;
|
|
2745
|
-
const learned = hosted(plain);
|
|
2746
2761
|
const [on, theRoot, theGate] = [harness, root, gate];
|
|
2747
2762
|
const args = { name: first.name, input: first.input };
|
|
2748
2763
|
const call = { callId: WORKFLOW_FIRST_CALL, tool: LEARNED_WORKFLOW_TOOL, args };
|
|
@@ -2766,9 +2781,17 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2766
2781
|
if (kept?.outcome === "answered")
|
|
2767
2782
|
return { outcome: "answered", text: ended?.output ?? "" };
|
|
2768
2783
|
// Handed back on an earlier claim whose handback never reached the agent (the session is still new): sent now, in
|
|
2769
|
-
// the words that claim would have sent (its why included)
|
|
2784
|
+
// the words that claim would have sent (its why included), with or without the tool now (the money rule may have
|
|
2785
|
+
// taken the workflow off it since: workflow-first.ts toolStopsOf).
|
|
2770
2786
|
if (kept)
|
|
2771
2787
|
return job(ended ? taken(recorded(ended)).text : "");
|
|
2788
|
+
// The session's learned_workflow as this loop wraps a tool, but nesting nothing of the harness's: a call a crash
|
|
2789
|
+
// cut is ended interrupted and handed back, never run again (its record's start is not marked `nests`).
|
|
2790
|
+
const bare = spec.session.tools.find((tool) => tool.name === LEARNED_WORKFLOW_TOOL);
|
|
2791
|
+
if (!bare || !tools.some((tool) => tool.name === LEARNED_WORKFLOW_TOOL))
|
|
2792
|
+
return undefined;
|
|
2793
|
+
const { nests: _nests, ...plain } = bare;
|
|
2794
|
+
const learned = hosted(plain);
|
|
2772
2795
|
if (!ended) {
|
|
2773
2796
|
// A deny before anything is written leaves the run its agent's, as if the workflow were not there.
|
|
2774
2797
|
const before = await spec.gate?.({ callId: call.callId, tool: call.tool, args });
|
|
@@ -2780,6 +2803,8 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2780
2803
|
await rec.person(spec.input);
|
|
2781
2804
|
}
|
|
2782
2805
|
let answer;
|
|
2806
|
+
// Refused at its gate, on this claim or the one before: it ran nothing.
|
|
2807
|
+
let refused = ended?.status === "refused";
|
|
2783
2808
|
if (ended)
|
|
2784
2809
|
answer = recorded(ended);
|
|
2785
2810
|
else {
|
|
@@ -2794,6 +2819,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2794
2819
|
else
|
|
2795
2820
|
await rec.refused(WORKFLOW_FIRST_CALL, LEARNED_WORKFLOW_TOOL, args, false, verdict.deny);
|
|
2796
2821
|
answer = { text: verdict.deny, isError: true };
|
|
2822
|
+
refused = true;
|
|
2797
2823
|
}
|
|
2798
2824
|
else {
|
|
2799
2825
|
// A CLI's record takes the call's start and end inside the wrapper; pi's step record here.
|
|
@@ -2810,9 +2836,14 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2810
2836
|
answer = taken(answer);
|
|
2811
2837
|
const outcome = answer.isError ? "handed_back" : "answered";
|
|
2812
2838
|
const data = { workflow: first.name, digest: first.digest, ...(first.promotion !== undefined ? { promotion: first.promotion } : {}), revision: first.revision, call: WORKFLOW_FIRST_CALL, outcome };
|
|
2839
|
+
// A call refused at its gate keeps its record as one the tool refused does (learned-nodes.ts LEARNED_NODES
|
|
2840
|
+
// `refused`): no workflow ran it, so the money rule charges none and the run names none.
|
|
2841
|
+
const refusal = refused ? { call: WORKFLOW_FIRST_CALL, workflow: first.name, digest: first.digest, caller: "platform", nodes: [], ended: "failed", refused: true } : undefined;
|
|
2813
2842
|
await on.commit(async (tx) => {
|
|
2814
2843
|
if (outcome === "answered")
|
|
2815
2844
|
await tx.appendEntry(theRoot.id, { kind: KINDS.message, data: { role: "model", text: answer.text, at: now() } });
|
|
2845
|
+
if (refusal)
|
|
2846
|
+
await tx.appendEntry(theRoot.id, { kind: LEARNED_NODES, data: refusal });
|
|
2816
2847
|
await tx.appendEntry(theRoot.id, { kind: WORKFLOW_FIRST, data: data });
|
|
2817
2848
|
}, context);
|
|
2818
2849
|
return outcome === "answered" ? { outcome, text: answer.text } : job(answer.text);
|
|
@@ -2822,9 +2853,10 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2822
2853
|
// under way (the handback sent) never runs it again.
|
|
2823
2854
|
let served;
|
|
2824
2855
|
// A workflow this run already served or handed back on an earlier claim (its end on the root): recovered whatever the
|
|
2825
|
-
// money rule says now, so a crash before the handback never
|
|
2826
|
-
|
|
2827
|
-
const
|
|
2856
|
+
// money rule says now (its stop, or its fail-closed read of an unreadable past), so a crash before the handback never
|
|
2857
|
+
// makes the agent redo finished work. Only a run that learns keeps one.
|
|
2858
|
+
const keptFirst = spec.workflowFirst || !spec.learningLaid || followedUp || firstUnplaced || session.state !== "new" ? undefined : findData(await entriesOf(gate.journal, root.id, context), WORKFLOW_FIRST, () => true);
|
|
2859
|
+
const recovered = keptFirst && keptFirst.outcome !== "needs_revision" ? { name: keptFirst.workflow, digest: keptFirst.digest, revision: keptFirst.revision, input: {}, ...(spec.outputSchema !== undefined ? { outputSchema: spec.outputSchema } : {}) } : undefined;
|
|
2828
2860
|
const firstToServe = spec.workflowFirst ?? recovered;
|
|
2829
2861
|
// A fitting workflow the money rule stopped: why, on the root, once for the run, as the agent takes it.
|
|
2830
2862
|
if (spec.workflowRevise && !followedUp && !firstUnplaced && session.state === "new") {
|
|
@@ -3216,7 +3248,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3216
3248
|
return { deny: wrapUpDeny };
|
|
3217
3249
|
// A CLI bridge's call run again after an attempt that may have been sent: its refusals say so (RAN_UNKNOWN).
|
|
3218
3250
|
const replayed = call.replayed === true;
|
|
3219
|
-
const given = (await spec.gate?.(kernelCall, { ...(replayed ? { replayed } : {}), ran: ranOf })) ?? "allow";
|
|
3251
|
+
const given = (await spec.gate?.(kernelCall, { ...(replayed ? { replayed } : {}), ran: ranOf, approved: approvedOf })) ?? "allow";
|
|
3220
3252
|
// An ask with its card's own fields (a learned workflow's MCP actions set to ask, each with its arguments' shape), or
|
|
3221
3253
|
// with the reason a call its setting allows asks anyway (`because`).
|
|
3222
3254
|
const shown = typeof given === "object" && "ask" in given ? given.ask : undefined;
|
|
@@ -3410,6 +3442,17 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3410
3442
|
async function ranOf(tool) {
|
|
3411
3443
|
return toolCalls(await agentEntriesOf(gate.journal, context), tool);
|
|
3412
3444
|
}
|
|
3445
|
+
/** Whether a person approved the call `callId`, as answerOf reads it: its answer in the journal stands; else the
|
|
3446
|
+
* approve or deny for it among the claim's commands (read once they are all with the loop, deps.delivered), which
|
|
3447
|
+
* answerOf takes next. */
|
|
3448
|
+
async function approvedOf(callId) {
|
|
3449
|
+
const conversation = await harness.root(context);
|
|
3450
|
+
const known = findData(await entriesOf(gate.journal, conversation.id, context), KINDS.answer, (data) => data.callId === callId);
|
|
3451
|
+
if (known)
|
|
3452
|
+
return known.approved;
|
|
3453
|
+
await (deps.delivered ?? Promise.resolve());
|
|
3454
|
+
return inbox.find((command) => (command.kind === "approve" || command.kind === "deny") && approvalOf(command) === callId)?.kind === "approve";
|
|
3455
|
+
}
|
|
3413
3456
|
async function askStands(callId) {
|
|
3414
3457
|
standing ??= (async () => {
|
|
3415
3458
|
const conversation = await harness.root(context);
|
|
@@ -3550,10 +3593,10 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3550
3593
|
return turnOfRequest(on, conversation, last.requestId);
|
|
3551
3594
|
}
|
|
3552
3595
|
/** How the job's own turn ended (`data`, and a CLI's error answer `failedWith`), as this claim decided it, kept on the
|
|
3553
|
-
* root before the end-of-run step asks its first turn (KINDS.jobEnd), for a run with a step to ask (
|
|
3554
|
-
* its time, now, which it answers; with no step to ask, nothing is kept. */
|
|
3596
|
+
* root before the end-of-run step asks its first turn (KINDS.jobEnd), for a run with a step to ask (its spec's endOfRun).
|
|
3597
|
+
* Kept with its time, now, which it answers; with no step to ask, nothing is kept. */
|
|
3555
3598
|
async function keepJobEnd(on, conversation, spec, data, failedWith) {
|
|
3556
|
-
if (!
|
|
3599
|
+
if (!spec.endOfRun)
|
|
3557
3600
|
return undefined;
|
|
3558
3601
|
const kept = jobEndOf(data, failedWith, now());
|
|
3559
3602
|
await on.commit((tx) => tx.appendEntry(conversation.id, { kind: KINDS.jobEnd, data: kept }), context);
|
|
@@ -3727,9 +3770,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3727
3770
|
return kept && typeof kept === "object" && !Array.isArray(kept) ? kept : undefined;
|
|
3728
3771
|
};
|
|
3729
3772
|
}
|
|
3730
|
-
/** The
|
|
3731
|
-
const stepOf = (spec) => spec.endOfRun ?? deps.endOfRun;
|
|
3732
|
-
/** The end-of-run step (stepOf: the spec's, else LoopDeps.endOfRun), asked once: the rows to stage with the end; `stopped` when a person's stop
|
|
3773
|
+
/** The end-of-run step (its spec's endOfRun; none without one), asked once: the rows to stage with the end; `stopped` when a person's stop
|
|
3733
3774
|
* came during it; `interrupted` when the claim was lost or the runner is closing (no end is written, and the next claim
|
|
3734
3775
|
* asks it again). A step that throws on its own writes the end without rows: the run's end never waits on it. `over`:
|
|
3735
3776
|
* the claim's overCap, read after each turn the step asks (askEndOfRun). */
|
|
@@ -3741,7 +3782,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3741
3782
|
return { kind: "interrupted" };
|
|
3742
3783
|
return undefined;
|
|
3743
3784
|
};
|
|
3744
|
-
const step =
|
|
3785
|
+
const step = spec.endOfRun;
|
|
3745
3786
|
if (!step)
|
|
3746
3787
|
return { kind: "rows", also: [] };
|
|
3747
3788
|
if (!spec.agentId)
|
|
@@ -3767,11 +3808,11 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3767
3808
|
return cut() ?? (console.warn(`[runner] ${claim.runId}: its end-of-run step failed: ${said(error)}`), { kind: "rows", also: [] });
|
|
3768
3809
|
}
|
|
3769
3810
|
}
|
|
3770
|
-
/** What a run cut before it could look back keeps beside its end (
|
|
3811
|
+
/** What a run cut before it could look back keeps beside its end (its spec's endOfRun with `cut`, never asking): a
|
|
3771
3812
|
* person's stop, before or during the end-of-run turn, or a fault. Bounded (CUT_STEP_MS): a step that reads a stalled
|
|
3772
3813
|
* store, or throws, keeps nothing, and the end is never held up by it. */
|
|
3773
3814
|
async function cutRows(claim, spec, cut) {
|
|
3774
|
-
const step =
|
|
3815
|
+
const step = spec.endOfRun;
|
|
3775
3816
|
if (!step || !spec.agentId)
|
|
3776
3817
|
return [];
|
|
3777
3818
|
const refuse = () => Promise.reject(new Error("a cut run's end-of-run step asks nothing"));
|
|
@@ -3886,9 +3927,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3886
3927
|
const spec = specNow;
|
|
3887
3928
|
if (!spec?.endPatch && !spec?.endCost)
|
|
3888
3929
|
return {};
|
|
3930
|
+
const bound = spec.endPatchTimer ?? REAL_TIMER;
|
|
3889
3931
|
let timer;
|
|
3890
|
-
const
|
|
3891
|
-
const late = new Promise((resolve) => (timer = setTimeout(() => resolve("late"), boundMs)));
|
|
3932
|
+
const late = new Promise((resolve) => (timer = bound.setTimeout(() => resolve("late"), END_PATCH_MS)));
|
|
3892
3933
|
// The cost, read apart (AdapterRunSpec.endCost): a patch whose metrics run late or fail never takes it with them. A
|
|
3893
3934
|
// read that fails is read again within the same bound (END_COST_TRIES): the stored cost is every reader's answer
|
|
3894
3935
|
// (the list, the view, usage), so a null there is kept only when the booking could not be read at all.
|
|
@@ -3896,7 +3937,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3896
3937
|
const cost = endCost
|
|
3897
3938
|
? readAgain(endCost, late, (error, tries, last) => console.warn(last ? `[runner] its end's cost failed ${tries} times, last: ${said(error)}; the end is written with its cost unknown` : `[runner] its end's cost failed: ${said(error)}; read again`)).then((answer) => {
|
|
3898
3939
|
if (answer === "late")
|
|
3899
|
-
console.warn(`[runner] its end's cost gave no answer within ${
|
|
3940
|
+
console.warn(`[runner] its end's cost gave no answer within ${END_PATCH_MS / 1000} s; the end is written with its cost unknown`);
|
|
3900
3941
|
return answer === "late" || answer === "failed" ? { costUsd: null, costUpperBound: false } : answer;
|
|
3901
3942
|
})
|
|
3902
3943
|
: undefined;
|
|
@@ -3906,7 +3947,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3906
3947
|
try {
|
|
3907
3948
|
const patch = await Promise.race([spec.endPatch(data), late]);
|
|
3908
3949
|
if (patch === "late") {
|
|
3909
|
-
console.warn(`[runner] its end's patch gave no answer within ${
|
|
3950
|
+
console.warn(`[runner] its end's patch gave no answer within ${END_PATCH_MS / 1000} s; the end is written with its ${cost ? "metrics" : "cost and metrics"} unknown`);
|
|
3910
3951
|
return END_PATCH_UNKNOWN;
|
|
3911
3952
|
}
|
|
3912
3953
|
return patch ?? {};
|
|
@@ -3921,7 +3962,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3921
3962
|
return read ? { ...patch, ...read } : patch;
|
|
3922
3963
|
}
|
|
3923
3964
|
finally {
|
|
3924
|
-
clearTimeout(timer);
|
|
3965
|
+
bound.clearTimeout(timer);
|
|
3925
3966
|
}
|
|
3926
3967
|
}
|
|
3927
3968
|
/** The run parked at its cap: its pending budget as an agentrun.budget entry, in one commit with the run parked in the
|
|
@@ -4022,12 +4063,18 @@ function adapterLoop(specOf, options, deps) {
|
|
|
4022
4063
|
}
|
|
4023
4064
|
/** At a park for `cause`, before its seal: a pass whose spec keeps its computer (AdapterRunSpec.keptWords) has it kept
|
|
4024
4065
|
* for the resume at its release (closeSession), once the run's timeline says so, for the person deciding; its owner's
|
|
4025
|
-
* live view is closed saying the cause.
|
|
4026
|
-
*
|
|
4066
|
+
* live view is closed saying the cause. The keep's row is written first (AdapterRunSpec.keep), under the claim's
|
|
4067
|
+
* fence: a park that keeps nothing (another runner's row still there, a write that failed, a claim that lost the run
|
|
4068
|
+
* and so writes nothing) says nothing of a keep, and its computer goes as at
|
|
4069
|
+
* the run's end. A commit that fails (the fence's refusal: a lost claim, whose run a later claim may hold already)
|
|
4070
|
+
* keeps nothing either: the computer goes as at the run's end, and its row with it. */
|
|
4027
4071
|
async function keepAtPark(on, cause) {
|
|
4028
|
-
const summary = specNow?.keptWords;
|
|
4072
|
+
const summary = specNow?.keptWords?.();
|
|
4029
4073
|
if (!summary)
|
|
4030
4074
|
return;
|
|
4075
|
+
const keep = specNow?.keep;
|
|
4076
|
+
if (keep && !(await keep().catch(() => false)))
|
|
4077
|
+
return;
|
|
4031
4078
|
parkedNow = await on.commit((tx) => tx.appendEntry(ROOT_CONVERSATION_ID, { kind: HOST_PHASE, data: { summary, at: Date.now() } }), context).then(() => cause, () => undefined);
|
|
4032
4079
|
}
|
|
4033
4080
|
/** The run's pause at its cap: its agentrun.budget entry, in one commit with the run parked in the cap's words. */
|
|
@@ -20,6 +20,7 @@ import { type ClaimModelKey } from "./claim-secrets.js";
|
|
|
20
20
|
import { type ClaimMcp } from "./mcp-run.js";
|
|
21
21
|
import { type AdapterLoopOptions, type AdapterRun, type AdapterRunSpec, hostLifecycle } from "./adapter-loop.js";
|
|
22
22
|
import { type RunnerHarness } from "./adapters/index.js";
|
|
23
|
+
import { type BoundTimer } from "./loop.js";
|
|
23
24
|
import { type SubagentTier } from "./subagent.js";
|
|
24
25
|
import { type Claim, type Journal } from "./loop-contract.js";
|
|
25
26
|
import type { ReplayCalls } from "../learn/replay-calls.js";
|
|
@@ -67,6 +68,8 @@ export interface ClaimComputer {
|
|
|
67
68
|
release(): Promise<void>;
|
|
68
69
|
/** The release at the run's park, which keeps the computer it `keeps` (computer-for-claim.ts ClaimComputer.park). */
|
|
69
70
|
park?(): Promise<boolean>;
|
|
71
|
+
/** The park's keep written before the run's timeline says it (computer-for-claim.ts ClaimComputer.keepRow). */
|
|
72
|
+
keepRow?(): Promise<boolean>;
|
|
70
73
|
}
|
|
71
74
|
/** The one shared claim-time computer every spec takes (computer-for-claim.ts), passed in by the runner: the composer's
|
|
72
75
|
* (workspace/computer-deps.ts computerDepsFrom), or a test's stand-in. */
|
|
@@ -102,6 +105,9 @@ export interface AdapterSpecDeps {
|
|
|
102
105
|
readonly log?: (message: string) => void;
|
|
103
106
|
/** For tests: a learning run's grade bound, as a signal (learning-dispatch.ts gradeBound). Default: GRADE_TIMEOUT_MS. */
|
|
104
107
|
readonly gradeBound?: () => AbortSignal;
|
|
108
|
+
/** For tests: the timer a native or SDK run's end arms its bound on (END_PATCH_MS, loop.ts) while it waits on its cost
|
|
109
|
+
* and metrics read, as the adapter loop's spec.endPatchTimer. Default: the real one (REAL_TIMER). */
|
|
110
|
+
readonly endPatchTimer?: BoundTimer;
|
|
105
111
|
/** The one shared claim-time computer (computer-for-claim.ts), for both the pi and the CLI spec: none for a runner place.
|
|
106
112
|
* The runner gives it; a test gives its own. */
|
|
107
113
|
readonly computerForClaim: ComputerForClaim;
|
|
@@ -159,6 +165,9 @@ export interface AdapterSpecDeps {
|
|
|
159
165
|
* on purpose does not wait out MODEL_RETRY's two and a half minutes. No environment variable, flag or setting maps onto
|
|
160
166
|
* it; absent, MODEL_RETRY and MODEL_STREAM. */
|
|
161
167
|
readonly modelRetry?: Pick<AdapterLoopOptions, "retry" | "stream">;
|
|
168
|
+
/** The runs' GenAI tracing (AdapterLoopOptions.tracing): in a run's own process, the one posted to its runner
|
|
169
|
+
* (run-child.ts); absent, this process's own. */
|
|
170
|
+
readonly tracing?: AdapterLoopOptions["tracing"];
|
|
162
171
|
/** web_save's download slots (ToolHost.saveSlots): in a run's own process, its runner's (run-child.ts). */
|
|
163
172
|
readonly saveSlots?: SaveSlots;
|
|
164
173
|
}
|
|
@@ -257,7 +266,8 @@ export declare function modelAskOf(pinned: {
|
|
|
257
266
|
* The run's computer once off for the run (RunGate.computerOff): a call of its tools is refused before any settings read.
|
|
258
267
|
* `turnedOff`: an earlier claim turned it off (computer-journal.ts computerTurnedOff), so this claim's gate starts off.
|
|
259
268
|
* `onComputerOff`: told the computer's kind, and awaited, when this claim's first deny of a call of its tools turns it off,
|
|
260
|
-
* for the run's journal (computer-journal.ts recordComputerOff), so a later claim starts it off too.
|
|
269
|
+
* for the run's journal (computer-journal.ts recordComputerOff), so a later claim starts it off too. The gate's
|
|
270
|
+
* `computerOff` says whether it is off now, so a park lets it go instead of keeping it (spec-holds.ts Held.computerOff).
|
|
261
271
|
*/
|
|
262
272
|
/** The run's tool permissions as a learned workflow's call nodes are held to them (learned-workflow.ts policy, denyFrom,
|
|
263
273
|
* refresh): the same gate as the run's own calls, its settings read again from the store before each call node. */
|
|
@@ -269,6 +279,7 @@ export type RunPermissions = {
|
|
|
269
279
|
export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pick<Claim, "runId">, revision: {
|
|
270
280
|
kind: string;
|
|
271
281
|
body: {
|
|
282
|
+
tools?: readonly string[];
|
|
272
283
|
toolSettings?: unknown;
|
|
273
284
|
harness?: string;
|
|
274
285
|
approvals?: Approvals;
|
|
@@ -283,6 +294,8 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
|
|
|
283
294
|
readonly permissions: RunPermissions;
|
|
284
295
|
readonly learn: (flows: readonly LearnedWorkflow[]) => void;
|
|
285
296
|
readonly askedOn: (host: ToolHost) => void;
|
|
297
|
+
readonly computerOff: () => boolean; /** Whether the run can write a file now, as its gate decides a save_as (RunGate.writeBar): what its files note and computer_screenshot's save_as are offered by. */
|
|
298
|
+
readonly writes: () => boolean;
|
|
286
299
|
}>;
|
|
287
300
|
/** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
|
|
288
301
|
* and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
|