@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** A check's disagreement with what it copied from its run blanked: its run id and which way the draft went (an answer,
|
|
2
|
+
* a hand-back, a failed step) and the fields it had wrong (the definition's names, no run text) and where each known
|
|
3
|
+
* answer came from kept, its input, the agent's answer, the draft's, the known answers' values and the grader's words
|
|
4
|
+
* gone. */
|
|
5
|
+
export const blankCheck = (one) => ({
|
|
6
|
+
run: one.run, input: "", agent: null,
|
|
7
|
+
...(one.draft !== undefined ? { draft: "" } : {}),
|
|
8
|
+
...(one.escalated !== undefined ? { escalated: "" } : {}),
|
|
9
|
+
...(one.failed ? { failed: true } : {}),
|
|
10
|
+
...(one.fields ? { fields: one.fields } : {}),
|
|
11
|
+
...(one.expected ? { expected: one.expected.map(({ field, known, value }) => ({ field, known, ...(value !== undefined ? { value: "" } : {}) })) } : {}),
|
|
12
|
+
});
|
|
13
|
+
/** An audit's disagreement blanked the same way: its run ids and whether a grade wrote it kept, its known answer empty. */
|
|
14
|
+
export const blankAudit = (one) => ({ run: one.run, served: one.served, input: "", agent: null, draft: null, ...(one.graded ? { graded: true } : {}), ...(one.expected !== undefined ? { expected: "" } : {}) });
|
|
15
|
+
/** `record` with what it copied from run `runId` blanked: each disagreement naming it (a check's agent run, a connected
|
|
16
|
+
* agent's collected turn too; an audit's served run or shadow run), and the grader's words its reason quotes from one
|
|
17
|
+
* (differentDecisionWords' example). Its decision, numbers and run ids stay. The record itself when it names no such
|
|
18
|
+
* disagreement. */
|
|
19
|
+
export function forgetRunIn(record, runId) {
|
|
20
|
+
if (!record || typeof record !== "object")
|
|
21
|
+
return record;
|
|
22
|
+
const check = record.check?.disagreements?.some((one) => one.run === runId);
|
|
23
|
+
const turns = record.check?.turns?.disagreements?.some((one) => one.run === runId);
|
|
24
|
+
const audit = record.audit?.disagreements.some((one) => one.run === runId || one.served === runId);
|
|
25
|
+
if (!check && !turns && !audit)
|
|
26
|
+
return record;
|
|
27
|
+
let reason = record.reason;
|
|
28
|
+
for (const one of record.check?.disagreements ?? [])
|
|
29
|
+
if (one.run === runId && one.differs_on !== undefined)
|
|
30
|
+
reason = reason.replace(` (for example: ${one.differs_on})`, "");
|
|
31
|
+
const blanked = (list) => list.map((one) => (one.run === runId ? blankCheck(one) : one));
|
|
32
|
+
return {
|
|
33
|
+
...record,
|
|
34
|
+
reason,
|
|
35
|
+
...((check || turns) && record.check ? { check: {
|
|
36
|
+
...record.check,
|
|
37
|
+
...(check ? { disagreements: blanked(record.check.disagreements) } : {}),
|
|
38
|
+
...(turns ? { turns: { ...record.check.turns, disagreements: blanked(record.check.turns.disagreements) } } : {}),
|
|
39
|
+
} } : {}),
|
|
40
|
+
...(audit && record.audit ? { audit: { ...record.audit, disagreements: record.audit.disagreements.map((one) => (one.run === runId || one.served === runId ? blankAudit(one) : one)) } } : {}),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** The runs whose copies `record` holds (forgetRunIn blanks them): each disagreement's run, a connected agent's collected
|
|
44
|
+
* turn's, an audit's served run and shadow run. */
|
|
45
|
+
export function runsNamedIn(record) {
|
|
46
|
+
if (!record || typeof record !== "object")
|
|
47
|
+
return [];
|
|
48
|
+
return [...new Set([
|
|
49
|
+
...(record.check?.disagreements ?? []).map((one) => one.run),
|
|
50
|
+
...(record.check?.turns?.disagreements ?? []).map((one) => one.run),
|
|
51
|
+
...(record.audit?.disagreements ?? []).flatMap((one) => [one.run, one.served]),
|
|
52
|
+
].filter((run) => typeof run === "string"))];
|
|
53
|
+
}
|
package/dist/learn/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The server's learning code, as one surface: a workflow draft's format and checks (workflow-draft.ts, check.ts), the
|
|
2
2
|
// owner's corrections (corrections.ts), and the hidden-character and secret matchers they use (invisible.ts,
|
|
3
|
-
// secrets.ts). SPEC.md, beside it, is the learning
|
|
3
|
+
// secrets.ts). SPEC.md, beside it, is the learning's contract. The rest of the server imports it from here.
|
|
4
4
|
export { CAPS, checkDraft, printable, unstorable } from "./check.js";
|
|
5
5
|
export { CORRECTIONS_CAP, CORRECTIONS_FILE, correctionLine, correctionsProblems, problemWords } from "./corrections.js";
|
|
6
6
|
export { hiddenCharacter } from "./invisible.js";
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { RunLaunch } from "../run-launch.js";
|
|
2
|
-
import type { Store } from "../store/store.js";
|
|
3
2
|
/** The disk a run's launch names as its own: the launch's `archilDisk` of kind "launch", by its id; null for none or its
|
|
4
3
|
* agent's own (the default disk). The store keeps the same on the run's row (RunRow.disk). */
|
|
5
4
|
export declare const learningDiskOf: (launch: Pick<RunLaunch, "archilDisk">) => string | null;
|
|
6
|
-
/** Each named disk a run of agent `agentId` used (Store.runs.every: its built-in learning runs and purged runs included,
|
|
7
|
-
* a purged run's tombstone keeping its disk): where a learning folder of the agent may be, past the server's own. */
|
|
8
|
-
export declare function namedDisksOf(store: Pick<Store, "runs">, agentId: string): Promise<string[]>;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
/** The disk a run's launch names as its own: the launch's `archilDisk` of kind "launch", by its id; null for none or its
|
|
2
2
|
* agent's own (the default disk). The store keeps the same on the run's row (RunRow.disk). */
|
|
3
3
|
export const learningDiskOf = (launch) => launch.archilDisk?.kind === "launch" ? launch.archilDisk.diskId : null;
|
|
4
|
-
/** Each named disk a run of agent `agentId` used (Store.runs.every: its built-in learning runs and purged runs included,
|
|
5
|
-
* a purged run's tombstone keeping its disk): where a learning folder of the agent may be, past the server's own. */
|
|
6
|
-
export async function namedDisksOf(store, agentId) {
|
|
7
|
-
return [...new Set((await store.runs.every(agentId)).map((run) => run.disk).filter((disk) => disk !== null))];
|
|
8
|
-
}
|
package/dist/learn/ledger.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Bill, type CostRun, type CostSummary, type NotServed, type RevisionSpend, type RunPath } from "../learning-cost.js";
|
|
1
|
+
import { type Bill, type CostRun, type CostSummary, type NotServed, type RevisionSpend, type RunPath, type WorkflowCall } from "../learning-cost.js";
|
|
2
|
+
import { type RunRow } from "../store/store.js";
|
|
2
3
|
/** A run's own cost as its row stores it: `known`, an exact figure; `unknown`, none; `at_most`, only a bound (a request
|
|
3
4
|
* cut at its cap hold), never shown as a cost. */
|
|
4
5
|
export declare const COST_STATES: readonly ["known", "unknown", "at_most"];
|
|
@@ -6,7 +7,9 @@ export type CostState = (typeof COST_STATES)[number];
|
|
|
6
7
|
/** One ended run: who answered it (`path`, null when its end named none), the learned workflow revision that ran it
|
|
7
8
|
* (`workflow` at `digest`; for an audit's shadow, the revision it audits), why that workflow did not serve it alone,
|
|
8
9
|
* the job's own $ (`jobUsd`: what it had cost when its answer was final, its look-back left out) and everything its
|
|
9
|
-
* rounds looked back for (`lookBackUsd`: its compile turns and its follow-up rounds' turns); each null when unknown
|
|
10
|
+
* rounds looked back for (`lookBackUsd`: its compile turns and its follow-up rounds' turns); each null when unknown; and
|
|
11
|
+
* every learned workflow call it made (`workflowCalls`: its metrics' `workflow_calls`, the platform's and the agent's,
|
|
12
|
+
* each with its digest, caller, outcome and booked $), none for a run that made none. */
|
|
10
13
|
export type LedgerRow = {
|
|
11
14
|
readonly runId: string;
|
|
12
15
|
readonly agentId: string;
|
|
@@ -18,6 +21,7 @@ export type LedgerRow = {
|
|
|
18
21
|
readonly jobUsd: number | null;
|
|
19
22
|
readonly lookBackUsd: number | null;
|
|
20
23
|
readonly cost: CostState;
|
|
24
|
+
readonly workflowCalls: readonly WorkflowCall[];
|
|
21
25
|
};
|
|
22
26
|
/** What a spend row paid for: a compile turn that drafted a revision (`compile`), a replay run checking one (`check`), or
|
|
23
27
|
* an audit's shadow run of a served run (`audit`). */
|
|
@@ -37,7 +41,9 @@ export type SpendRow = {
|
|
|
37
41
|
readonly usd: number | null;
|
|
38
42
|
};
|
|
39
43
|
/** What record() reads of an ended run: its row (its cost, the bound beside it, its metrics: the run-end classifier's
|
|
40
|
-
* path, workflow and digest, runner/workflow-first.ts pathMetrics)
|
|
44
|
+
* path, workflow and digest, runner/workflow-first.ts pathMetrics), every round its learning kept (learning_proposals)
|
|
45
|
+
* and, for an audit's shadow run, the run its launch audits (`auditOf`: its end may name no audit, when it failed first).
|
|
46
|
+
* `learns`: whether its launch learns (learnsOfLaunch); false, an end that named no path is the agent's. */
|
|
41
47
|
export type RunEnd = {
|
|
42
48
|
readonly id: string;
|
|
43
49
|
readonly agentId: string;
|
|
@@ -49,7 +55,15 @@ export type RunEnd = {
|
|
|
49
55
|
readonly round: number;
|
|
50
56
|
readonly proposal: unknown;
|
|
51
57
|
}[];
|
|
58
|
+
readonly auditOf?: string | null;
|
|
59
|
+
readonly learns?: boolean;
|
|
52
60
|
};
|
|
61
|
+
/** RunEnd.auditOf of run `runId` from its stored launch body (`body`, undefined with none): the run its launch audits
|
|
62
|
+
* (null when it names none) for an audit's shadow run (learn/audit.ts SHADOW_PREFIX "audit."), undefined for any other. */
|
|
63
|
+
export declare const auditOfLaunch: (runId: string, body: unknown) => string | null | undefined;
|
|
64
|
+
/** RunEnd.learns from a run's stored launch body (`body`, undefined with none): whether it holds a learning start, as
|
|
65
|
+
* run-launch.ts learningStartOfStored reads one. No launch reads as a run that does not learn. */
|
|
66
|
+
export declare const learnsOfLaunch: (body: unknown) => boolean;
|
|
53
67
|
/** What a kept round says of its job as it answered (runner/reflect-hook.ts): when, what the job had cost by then, and
|
|
54
68
|
* what looking back cost after it. */
|
|
55
69
|
export type Answered = {
|
|
@@ -80,22 +94,10 @@ export declare function record(end: RunEnd): {
|
|
|
80
94
|
row: LedgerRow;
|
|
81
95
|
spend: SpendRow[];
|
|
82
96
|
};
|
|
83
|
-
/** The audit spend row of shadow run `shadow` of run `ofRun`, from its row alone: for a shadow whose end named no audit
|
|
84
|
-
* (it failed before its end wrote its metrics), found by its id (learn/audit.ts shadowRunId). Its cost is the row's,
|
|
85
|
-
* null when unknown or only a bound. */
|
|
86
|
-
export declare function shadowSpend(shadow: Pick<RunEnd, "id" | "agentId" | "costUsd" | "costAtMostUsd">, ofRun: string): SpendRow;
|
|
87
97
|
/** An audit's shadow run of a run, as the reader finds it: `open` while it is queued or running (its cost not known yet),
|
|
88
98
|
* `ended` once it ended, stopped or failed. A run with none has no entry. */
|
|
89
99
|
export type Shadow = "open" | "ended";
|
|
90
|
-
/** A run's figures,
|
|
91
|
-
* - `usd`: the job's own $ (GET /runs/{id} `cost.usd`, the series' `cost_usd`);
|
|
92
|
-
* - `compile_usd`, `followup_usd`, `shadow_usd`: its own compile turns, the rest of its look-back (its follow-up rounds'
|
|
93
|
-
* turns) and its audit's shadow run;
|
|
94
|
-
* - `share_usd`: its share of its revision's compile and check (amortize), 0 for a run that carries none;
|
|
95
|
-
* - `series_learning_usd` and `series_total_usd`: the cost series' `learning_usd` (its whole look-back and its shadow)
|
|
96
|
-
* and `total_usd`, the all-in both sides of the money rule read;
|
|
97
|
-
* - `learning_usd` and `all_in_usd`: GET /runs/{id}'s (its follow-ups, its shadow and its share: its compile turns are
|
|
98
|
-
* its revision's), 0 for a replay or a shadow run, whose spend is on the runs it serves. */
|
|
100
|
+
/** A run's figures (figuresOf), null when unknown: `series_*` are the cost series', the rest GET /runs/{id}'s. */
|
|
99
101
|
export type RunFigures = {
|
|
100
102
|
readonly usd: number | null;
|
|
101
103
|
readonly compile_usd: number | null;
|
|
@@ -119,8 +121,19 @@ export declare function spendByRun(spend: readonly SpendRow[]): {
|
|
|
119
121
|
compile: Map<string, number | null>;
|
|
120
122
|
audit: Map<string, number | null>;
|
|
121
123
|
};
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
+
/** An audit's shadow run as its cost reads: `ended` once it is final (FINAL_STATES), `usd` its cost (null while unknown
|
|
125
|
+
* or only a bound). */
|
|
126
|
+
export type ShadowCost = {
|
|
127
|
+
readonly ended: boolean;
|
|
128
|
+
readonly usd: number | null;
|
|
129
|
+
};
|
|
130
|
+
/** A shadow run's row as a ShadowCost. */
|
|
131
|
+
export declare const shadowOfRun: (run: Pick<RunRow, "state" | "costUsd" | "costAtMostUsd">) => ShadowCost;
|
|
132
|
+
/** A run's shadow cost, the one rule the ledger, GET /stats and analytics read: 0 with no shadow (undefined); unknown
|
|
133
|
+
* (null) while it is queued or running, or once it ended at an unknown cost, never $0; its cost once known. */
|
|
134
|
+
export declare const shadowUsdOf: (shadow: ShadowCost | undefined) => number | null;
|
|
135
|
+
/** A run's shadow cost (shadowUsdOf) from the reader's shadows and the audit spend rows: an ended shadow costs its
|
|
136
|
+
* spend row's, unknown with none. */
|
|
124
137
|
export declare function shadowCostOf(runId: string, audit: ReadonlyMap<string, number | null>, shadows: ReadonlyMap<string, Shadow>): number | null;
|
|
125
138
|
/** A revision of a learned workflow as its records say it now (store-reads/learning.ts revisionsOf): the served runs its
|
|
126
139
|
* spend is spread over (`k`, its check's compile_after) and where it stands. Order is the records'. */
|
|
@@ -130,17 +143,7 @@ export type RevisionAt = {
|
|
|
130
143
|
readonly k: number;
|
|
131
144
|
readonly state: RevisionSpend["state"];
|
|
132
145
|
};
|
|
133
|
-
/** What summarize reads:
|
|
134
|
-
* - `rows`, the runs of the series (ended, neither imported nor archived nor purged, no workflow revision's run, no
|
|
135
|
-
* shadow), any order, each with its path (null: its end named none);
|
|
136
|
-
* - `spend`, the agent's spend rows: a compile or a check of a run `rows` leaves out is left out as its run is, an
|
|
137
|
-
* audit's by the run it audits;
|
|
138
|
-
* - `shadows`, each run's audit shadow by the run it audits;
|
|
139
|
-
* - `learning`, the runs of `rows` whose spend and service make up a revision's (on no named disk: one on a named disk
|
|
140
|
-
* learns nothing and serves nothing, learn/learning-of.ts); absent, every one;
|
|
141
|
-
* - `revisions`, as the records say them; `compileAfter`, the K of a revision no record names;
|
|
142
|
-
* - `named`, the workflow name a run's series row shows (its row's when absent).
|
|
143
|
-
* The summary's `replay` is the records' (store-reads/learning.ts servingReplayOf), null here. */
|
|
146
|
+
/** What summarize reads: the series' rows and spend, shadows by audited run, learning runs (absent: all), revisions. */
|
|
144
147
|
export type LedgerRead = {
|
|
145
148
|
readonly rows: readonly LedgerRow[];
|
|
146
149
|
readonly spend: readonly SpendRow[];
|
package/dist/learn/ledger.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// transaction (store/sqlite/run-patch.ts); summarize() is the one reading of them, which GET /agents/{id}/learning/cost,
|
|
4
4
|
// GET /runs/{id}'s cost and the money rule (runner/workflow-first.ts costLineOf, over RunFigures) all take. Pure: no
|
|
5
5
|
// store, no clock.
|
|
6
|
-
import { amortize, billOf, costSummary, JOB_PATHS, NOT_SERVED, noiseOff, RUN_PATHS, SERVED_PATHS, tookOverOf } from "../learning-cost.js";
|
|
6
|
+
import { amortize, billOf, costSummary, JOB_PATHS, NOT_SERVED, noiseOff, RUN_PATHS, SERVED_PATHS, tookOverOf, workflowCallsIn } from "../learning-cost.js";
|
|
7
|
+
import { FINAL_STATES } from "../store/store.js";
|
|
7
8
|
/** A run's own cost as its row stores it: `known`, an exact figure; `unknown`, none; `at_most`, only a bound (a request
|
|
8
9
|
* cut at its cap hold), never shown as a cost. */
|
|
9
10
|
export const COST_STATES = ["known", "unknown", "at_most"];
|
|
@@ -13,6 +14,12 @@ export const SPEND_KINDS = ["compile", "check", "audit"];
|
|
|
13
14
|
const usdOrNull = (value) => (typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
14
15
|
const textOrNull = (value) => (typeof value === "string" ? value : null);
|
|
15
16
|
const objectOf = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : {});
|
|
17
|
+
/** RunEnd.auditOf of run `runId` from its stored launch body (`body`, undefined with none): the run its launch audits
|
|
18
|
+
* (null when it names none) for an audit's shadow run (learn/audit.ts SHADOW_PREFIX "audit."), undefined for any other. */
|
|
19
|
+
export const auditOfLaunch = (runId, body) => runId.startsWith("audit.") ? textOrNull(objectOf(objectOf(body).audit).of) : undefined;
|
|
20
|
+
/** RunEnd.learns from a run's stored launch body (`body`, undefined with none): whether it holds a learning start, as
|
|
21
|
+
* run-launch.ts learningStartOfStored reads one. No launch reads as a run that does not learn. */
|
|
22
|
+
export const learnsOfLaunch = (body) => objectOf(body).learning !== undefined;
|
|
16
23
|
/** A sum of parts, null once one is unknown; 0 for none. */
|
|
17
24
|
const sumOf = (parts) => (parts.some((one) => one === null) ? null : noiseOff(parts.reduce((total, one) => total + one, 0)));
|
|
18
25
|
/** A kept round's Answered; undefined for one that never answered. */
|
|
@@ -80,9 +87,13 @@ export function record(end) {
|
|
|
80
87
|
// What the row holds past the answer and its look-back is a later turn's spend, unknown once the row's cost is; with the
|
|
81
88
|
// look-back's cost unknown the two can't be told apart, and the job is what it had cost when it answered.
|
|
82
89
|
const job = !looked || asAnswered === null || back === null ? asAnswered : rowUsd === null ? null : Math.max(asAnswered, rowUsd - back);
|
|
83
|
-
const
|
|
90
|
+
const audited = metrics.path === "audit" || end.auditOf !== undefined;
|
|
91
|
+
// The one by-hand rule (the window's read and Learning.byHandBefore read the row's path, each leaving a workflow
|
|
92
|
+
// revision's runs out): a run whose end named no path is the agent's when its launch does not learn; one that learns
|
|
93
|
+
// and named none is unknown (null).
|
|
94
|
+
const named = RUN_PATHS.includes(metrics.path) ? metrics.path : null;
|
|
95
|
+
const path = audited ? "audit" : named ?? (end.learns === false ? "agent" : null);
|
|
84
96
|
const audit = objectOf(metrics.audit);
|
|
85
|
-
const audited = path === "audit";
|
|
86
97
|
const workflow = textOrNull(audited ? audit.workflow : metrics.workflow);
|
|
87
98
|
const digest = textOrNull(audited ? audit.digest : metrics.workflow_digest);
|
|
88
99
|
// A hand-back a restart cut (pathMetrics workflow_cut) is `cut`, never the workflow's own `back`.
|
|
@@ -90,23 +101,16 @@ export function record(end) {
|
|
|
90
101
|
const notServed = cut ? "cut" : NOT_SERVED.includes(metrics.not_served) ? metrics.not_served : null;
|
|
91
102
|
const row = {
|
|
92
103
|
runId: end.id, agentId: end.agentId, startedAt: end.startedAt, path, workflow, digest, notServed,
|
|
93
|
-
jobUsd: job === null ? null : noiseOff(job), lookBackUsd: back === null ? null : noiseOff(back), cost,
|
|
104
|
+
jobUsd: job === null ? null : noiseOff(job), lookBackUsd: back === null ? null : noiseOff(back), cost, workflowCalls: workflowCallsIn(metrics),
|
|
94
105
|
};
|
|
95
106
|
const base = { runId: end.id, agentId: end.agentId };
|
|
96
107
|
const spend = compilesIn(rounds).map((one) => ({ ...base, round: one.round, kind: "compile", ofRun: null, workflow: one.workflow, digest: one.digest, usd: one.usd }));
|
|
97
108
|
if (path === "replay")
|
|
98
109
|
spend.push({ ...base, round: 0, kind: "check", ofRun: null, workflow, digest, usd: rowUsd });
|
|
99
110
|
if (audited)
|
|
100
|
-
spend.push({ ...base, round: 0, kind: "audit", ofRun: textOrNull(audit.of), workflow, digest, usd: rowUsd });
|
|
111
|
+
spend.push({ ...base, round: 0, kind: "audit", ofRun: textOrNull(audit.of) ?? end.auditOf ?? null, workflow, digest, usd: rowUsd });
|
|
101
112
|
return { row, spend };
|
|
102
113
|
}
|
|
103
|
-
/** The audit spend row of shadow run `shadow` of run `ofRun`, from its row alone: for a shadow whose end named no audit
|
|
104
|
-
* (it failed before its end wrote its metrics), found by its id (learn/audit.ts shadowRunId). Its cost is the row's,
|
|
105
|
-
* null when unknown or only a bound. */
|
|
106
|
-
export function shadowSpend(shadow, ofRun) {
|
|
107
|
-
const usd = typeof shadow.costAtMostUsd === "number" ? null : shadow.costUsd;
|
|
108
|
-
return { runId: shadow.id, agentId: shadow.agentId, round: 0, kind: "audit", ofRun, workflow: null, digest: null, usd };
|
|
109
|
-
}
|
|
110
114
|
/** One run's figures (RunFigures) from its row and the parts the spend rows give it (its compile turns, its shadow's
|
|
111
115
|
* cost, its share): the one formula every reader of a run's cost takes. */
|
|
112
116
|
export function figuresOf(row, parts) {
|
|
@@ -135,15 +139,18 @@ export function spendByRun(spend) {
|
|
|
135
139
|
}
|
|
136
140
|
return { compile, audit };
|
|
137
141
|
}
|
|
138
|
-
/** A run's
|
|
139
|
-
|
|
142
|
+
/** A shadow run's row as a ShadowCost. */
|
|
143
|
+
export const shadowOfRun = (run) => ({ ended: FINAL_STATES.includes(run.state), usd: typeof run.costAtMostUsd === "number" ? null : run.costUsd });
|
|
144
|
+
/** A run's shadow cost, the one rule the ledger, GET /stats and analytics read: 0 with no shadow (undefined); unknown
|
|
145
|
+
* (null) while it is queued or running, or once it ended at an unknown cost, never $0; its cost once known. */
|
|
146
|
+
export const shadowUsdOf = (shadow) => (shadow === undefined ? 0 : shadow.ended ? shadow.usd : null);
|
|
147
|
+
/** A run's shadow cost (shadowUsdOf) from the reader's shadows and the audit spend rows: an ended shadow costs its
|
|
148
|
+
* spend row's, unknown with none. */
|
|
140
149
|
export function shadowCostOf(runId, audit, shadows) {
|
|
141
150
|
const state = shadows.get(runId);
|
|
142
|
-
if (state ===
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
return audit.get(runId);
|
|
146
|
-
return state === "ended" ? null : 0;
|
|
151
|
+
if (state === undefined && !audit.has(runId))
|
|
152
|
+
return 0;
|
|
153
|
+
return shadowUsdOf({ ended: state !== "open", usd: audit.has(runId) ? audit.get(runId) : null });
|
|
147
154
|
}
|
|
148
155
|
/** What the ledger says over an agent's series: each run of it (`runs`, oldest first, every one), what they show
|
|
149
156
|
* (`summary`), the owner's bill (`bill`, its holds aside: they are the records'), each run's figures by id (`figures`)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Workspace } from "../../workspace/index.js";
|
|
2
|
+
import { type LearningPlace as OneLearningPlace, type LearningWorkspace as OneLearningWorkspace } from "./place.js";
|
|
2
3
|
/** The host's folder inside the learning folder: the snapshot, the diffs and the script. Never learned, never seeded. */
|
|
3
4
|
export declare const HOST_DIR = ".agentrun";
|
|
4
5
|
export declare const SNAPSHOT_FILE = ".agentrun/snapshot.json";
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
// (audits.jsonl, never served to a run), nothing else.
|
|
22
22
|
import { createHash, randomBytes } from "node:crypto";
|
|
23
23
|
import { readFileSync } from "node:fs";
|
|
24
|
-
import { isWorkspaceError
|
|
25
|
-
import { CORRECTIONS_FILE } from "
|
|
26
|
-
import { learnedFront, learnedStatus, retiredFrom, WORKFLOW_NAME, WORKFLOWS_DIR } from "
|
|
27
|
-
import {
|
|
24
|
+
import { isWorkspaceError } from "../../workspace/index.js";
|
|
25
|
+
import { CORRECTIONS_FILE } from "../corrections.js";
|
|
26
|
+
import { learnedFront, learnedStatus, retiredFrom, WORKFLOW_NAME, WORKFLOWS_DIR } from "../workflow-draft.js";
|
|
27
|
+
import { learningWorkspace as oneLearningWorkspace } from "./place.js";
|
|
28
28
|
/** The host's folder inside the learning folder: the snapshot, the diffs and the script. Never learned, never seeded. */
|
|
29
29
|
export const HOST_DIR = ".agentrun";
|
|
30
30
|
export const SNAPSHOT_FILE = `${HOST_DIR}/snapshot.json`;
|
|
@@ -376,9 +376,6 @@ const withMain = (snapshot, main) => JSON.parse(JSON.stringify(snapshot).replace
|
|
|
376
376
|
export function learningWorkspace(place) {
|
|
377
377
|
if (folderTestHooks.workspace)
|
|
378
378
|
return folderTestHooks.workspace(place);
|
|
379
|
-
// A run's own process never opens a learning folder itself: its runner does, the claim's agent's (held.ts).
|
|
380
|
-
if (held())
|
|
381
|
-
return heldLearningFolder();
|
|
382
379
|
return oneLearningWorkspace(place);
|
|
383
380
|
}
|
|
384
381
|
/** What a learning folder's script run is, as a runner checks one a run's process asks of it (run-child-host.ts): its
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Workspace } from "../../workspace/workspace.js";
|
|
2
|
+
/** Agent `agentId`'s legacy learning folder: `<data>/disk/agents/<agent>/learning`. */
|
|
3
|
+
export declare const legacyLearningFolder: (data: string, agentId: string) => string;
|
|
4
|
+
/** Where an agent's legacy learning folder is: the local folder under the data directory. */
|
|
5
|
+
export type LearningPlace = {
|
|
6
|
+
readonly agentId: string;
|
|
7
|
+
readonly mode: "local"; /** The data directory. */
|
|
8
|
+
readonly data: string;
|
|
9
|
+
};
|
|
10
|
+
/** The folder's Workspace, and its end. */
|
|
11
|
+
export interface LearningWorkspace {
|
|
12
|
+
readonly workspace: Workspace;
|
|
13
|
+
end(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/** Agent `agentId`'s legacy learning Workspace. */
|
|
16
|
+
export declare function learningWorkspace(place: LearningPlace): LearningWorkspace;
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// server reads learning's snapshot back with read, stat and list. Given synchronously; its end() is called in a finally
|
|
6
|
-
// after every use.
|
|
7
|
-
//
|
|
8
|
-
// The local folder is made by the first call that writes (anything but read, stat, list, grep and mountSpec), one level
|
|
9
|
-
// at a time from the data directory, and its .git is checked too. A read makes nothing: while a level is missing, a
|
|
10
|
-
// read is NOT_FOUND "the learning folder is not made yet" (no main yet). A level that is a symbolic link is refused as
|
|
11
|
-
// ESCAPE naming it, so nothing is read, made or run where a link points; one that is not a folder is UNAVAILABLE. The
|
|
12
|
-
// local end() does nothing.
|
|
13
|
-
// The Archil folder makes nothing by reading either (the file API answers a missing key as NOT_FOUND). Its end() sweeps
|
|
14
|
-
// the learning folder's exec spill folder once; what an exec's cleanup leaves, or a sweep that fails, goes to the log,
|
|
15
|
-
// never failing the caller.
|
|
1
|
+
// The learning folder kept from before learning moved to the store's rows (changes/learning-store-rows.md): an agent's
|
|
2
|
+
// git folder under the data directory, <data>/disk/agents/<agent>/learning. Nothing reads it any more; a run's purge
|
|
3
|
+
// alone opens it, to take that run's text off it (legacy/scrub.ts). Local only: on an Archil disk the purge deletes the
|
|
4
|
+
// agent's folder there whole (archil-routes.ts removeLearningFolder), as it did before.
|
|
16
5
|
import { lstat, mkdir } from "node:fs/promises";
|
|
17
6
|
import { dirname, join } from "node:path";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
7
|
+
import { localWorkspace } from "../../workspace/local.js";
|
|
8
|
+
import { agentDirName, DISK_DIR } from "../../workspace/paths.js";
|
|
9
|
+
import { WorkspaceError } from "../../workspace/workspace.js";
|
|
10
|
+
/** Agent `agentId`'s legacy learning folder: `<data>/disk/agents/<agent>/learning`. */
|
|
11
|
+
export const legacyLearningFolder = (data, agentId) => join(data, DISK_DIR, "agents", agentDirName(agentId), "learning");
|
|
22
12
|
/** The Workspace calls that only read: they never make the folder. */
|
|
23
13
|
const READS = new Set(["read", "stat", "list", "grep", "mountSpec"]);
|
|
24
14
|
/** `dir` checked: a folder, never a symbolic link; made first where absent when `make`. Missing and not made: false. */
|
|
@@ -47,7 +37,7 @@ async function level(data, dir, make) {
|
|
|
47
37
|
}
|
|
48
38
|
/** The local learning folder's Workspace: made by the first write, never by a read. */
|
|
49
39
|
function localLearning(data, agentId) {
|
|
50
|
-
const root =
|
|
40
|
+
const root = legacyLearningFolder(data, agentId);
|
|
51
41
|
const levels = [];
|
|
52
42
|
// Every level from <data>/disk down to the folder (the walk stops at the data directory, or the top of the tree).
|
|
53
43
|
for (let dir = root; dir !== join(data, DISK_DIR, "..") && dir !== dirname(dir); dir = dirname(dir))
|
|
@@ -81,27 +71,7 @@ function localLearning(data, agentId) {
|
|
|
81
71
|
get process() { return localWorkspace(root).process; },
|
|
82
72
|
};
|
|
83
73
|
}
|
|
84
|
-
/** Agent `agentId`'s learning Workspace. */
|
|
74
|
+
/** Agent `agentId`'s legacy learning Workspace. */
|
|
85
75
|
export function learningWorkspace(place) {
|
|
86
|
-
|
|
87
|
-
if (place.mode === "local")
|
|
88
|
-
return { workspace: localLearning(place.data, agentId), end: async () => { } };
|
|
89
|
-
const claim = place.archil;
|
|
90
|
-
if (claim === undefined)
|
|
91
|
-
throw new TypeError("an Archil learning Workspace is opened with its claim's Archil claim (archilClaim)");
|
|
92
|
-
const say = (line) => {
|
|
93
|
-
try {
|
|
94
|
-
place.log?.(line);
|
|
95
|
-
}
|
|
96
|
-
catch { /* the caller's log */ }
|
|
97
|
-
};
|
|
98
|
-
const workspace = archilWorkspace(claim.disk, learningKey(agentId), {
|
|
99
|
-
...(claim.image === undefined ? {} : { image: claim.image }),
|
|
100
|
-
onCleanupFailed: say,
|
|
101
|
-
});
|
|
102
|
-
let ended;
|
|
103
|
-
const end = () => (ended ??= workspace.sweep().catch((error) => {
|
|
104
|
-
say(`the learning folder's exec spill folder could not be swept (the next sweep takes what is left): ${error?.message ?? error}`);
|
|
105
|
-
}));
|
|
106
|
-
return { workspace, end };
|
|
76
|
+
return { workspace: localLearning(place.data, place.agentId), end: async () => { } };
|
|
107
77
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Settings, Store } from "../../store/index.js";
|
|
2
|
+
import { type Workspace } from "../../workspace/index.js";
|
|
3
|
+
/** The legacy settings keys a purge scrubs: the agent's kept grades and its promotion records. */
|
|
4
|
+
export declare const legacyGradesKey: (agentId: string) => string;
|
|
5
|
+
export declare const legacyPromotionsKey: (agentId: string) => string;
|
|
6
|
+
/** Run `runId`'s text off agent `agentId`'s legacy learning: its folder under `data` (forgetRunText: a workflow it
|
|
7
|
+
* changed last goes back to the version before it that no purged run of `store` wrote), in the agent's queue, then its
|
|
8
|
+
* copies in the legacy settings keys. A folder that can't be read or written now is 503 unavailable (the next DELETE
|
|
9
|
+
* does it again); a folder never made is no work. */
|
|
10
|
+
export declare function forgetLegacyRunLearning(data: string, agentId: string, runId: string, store: Pick<Store, "runs" | "settings">): Promise<void>;
|
|
11
|
+
/** What the legacy settings keys copied from run `runId`, gone: its kept grades dropped, its promotion records'
|
|
12
|
+
* disagreements naming it blanked (forget-run.ts forgetRunIn), each record's decision, numbers and run ids kept. No write
|
|
13
|
+
* when nothing names it. */
|
|
14
|
+
export declare function forgetLegacyRunCopies(settings: Pick<Settings, "get" | "replaceIf">, agentId: string, runId: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Run `runId`'s text taken off the folder's current files, at its purge (agent-delete.ts purgeRun): first its learned
|
|
17
|
+
* workflows (forgetRunWorkflows; `purged`: whether another run is purged), whether or not it left a diff file; then the
|
|
18
|
+
* lines each of its merges added to corrections.md, as its diff file keeps them, dropped from main in one host commit
|
|
19
|
+
* per merge (a line a person edited since is theirs and stays); each other merge's diff that shows such a line as
|
|
20
|
+
* context written without it; then the run's diff files deleted, last, so a call stopped part way finds what it has
|
|
21
|
+
* left to do. Its merges stay in the folder's git history until its agent's purge deletes the
|
|
22
|
+
* folder. Idempotent: each merge's scrub lands once, nothing left to drop makes no commit, and a run with no diff file
|
|
23
|
+
* and no workflow here is no work.
|
|
24
|
+
* `commit`: the host's last commit, when one was made.
|
|
25
|
+
*/
|
|
26
|
+
export declare function forgetRunText(ws: Workspace, runId: string, purged: (run: string) => Promise<boolean>): Promise<{
|
|
27
|
+
commit?: string;
|
|
28
|
+
}>;
|