@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
package/dist/learned-nodes.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Skipped } from "./learn/replay-calls.js";
|
|
2
|
-
/** The journal entry a learned_workflow call keeps beside itself: `{ call, workflow,
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
/** The journal entry a learned_workflow call keeps beside itself, its record, whatever ran: `{ call, workflow, digest,
|
|
3
|
+
* caller, nodes, loops? }`, its call's id, the workflow's name and digest (runner/workflow-first.ts workflowDigest), who
|
|
4
|
+
* called it (`platform` or `agent`: learning-cost.ts WorkflowCaller), each of its nodes that ran (LearnedNode, at most
|
|
5
|
+
* LEARNED_NODES_MAX) and every loop exit (LoopRow), never capped (a map over more items than the trace holds keeps
|
|
6
|
+
* each); on a replay run's call that a write stopped (learn/replay-calls.ts: one the agent's recording does not have),
|
|
7
|
+
* `replay_skipped: { tool, step }` too; `ended`, how the workflow ended (LearnedEnded), on a call that ended; and
|
|
8
|
+
* `refused: true` on one refused before any node ran (it ran nothing). A run's `workflow_calls` read these
|
|
9
|
+
* (runner/workflow-calls.ts). */
|
|
7
10
|
export declare const LEARNED_NODES = "agentrun.learned_nodes";
|
|
8
11
|
/** How a learned workflow's call ended: `complete` (it answered), `escalated` (it handed back: an escalate node,
|
|
9
12
|
* however many nodes failed on the way and were recovered, a map's collected item say), or `failed` (it threw, or was
|
package/dist/learned-nodes.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
/** The journal entry a learned_workflow call keeps beside itself: `{ call, workflow,
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
1
|
+
/** The journal entry a learned_workflow call keeps beside itself, its record, whatever ran: `{ call, workflow, digest,
|
|
2
|
+
* caller, nodes, loops? }`, its call's id, the workflow's name and digest (runner/workflow-first.ts workflowDigest), who
|
|
3
|
+
* called it (`platform` or `agent`: learning-cost.ts WorkflowCaller), each of its nodes that ran (LearnedNode, at most
|
|
4
|
+
* LEARNED_NODES_MAX) and every loop exit (LoopRow), never capped (a map over more items than the trace holds keeps
|
|
5
|
+
* each); on a replay run's call that a write stopped (learn/replay-calls.ts: one the agent's recording does not have),
|
|
6
|
+
* `replay_skipped: { tool, step }` too; `ended`, how the workflow ended (LearnedEnded), on a call that ended; and
|
|
7
|
+
* `refused: true` on one refused before any node ran (it ran nothing). A run's `workflow_calls` read these
|
|
8
|
+
* (runner/workflow-calls.ts). */
|
|
6
9
|
export const LEARNED_NODES = "agentrun.learned_nodes";
|
|
7
10
|
/** The most nodes a call keeps: a map over a long list runs its body once per item. */
|
|
8
11
|
export const LEARNED_NODES_MAX = 64;
|
|
@@ -150,7 +150,7 @@ export declare function handedBackText(name: string, escalation: {
|
|
|
150
150
|
/** The run's `learned_workflow` tool over `run.workflows`. */
|
|
151
151
|
export declare function learnedWorkflowTool(run: LearnedWorkflowRun): ToolRegistration;
|
|
152
152
|
/** `flow` run on `input` for `run`: its output as its tool hands it back (learnedOutput), or why it did not run, and each of its nodes that ran (at most
|
|
153
|
-
* LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
|
|
153
|
+
* LEARNED_NODES_MAX), none for one refused before any node ran (`refused`). Never throws, but on an abort. `ledger`: the tool call's,
|
|
154
154
|
* which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
|
|
155
155
|
* added as it ends, the caller's to keep when the call is aborted (and so throws) part way. `nested`: the session's tools as calls nested in this one, which its MCP nodes run as; and the values its first run
|
|
156
156
|
* fixed (`memo`), so a rerun of the call (after a park, a crash) goes on from what its model, decision and call nodes
|
|
@@ -161,5 +161,6 @@ export declare function runLearned(run: LearnedWorkflowRun, flow: LearnedWorkflo
|
|
|
161
161
|
isError: boolean;
|
|
162
162
|
nodes: LearnedNode[];
|
|
163
163
|
ended: LearnedEnded;
|
|
164
|
+
refused?: true;
|
|
164
165
|
}>;
|
|
165
166
|
export {};
|
package/dist/learned-workflow.js
CHANGED
|
@@ -46,6 +46,7 @@ import { allows, CALL_TOOLS, learnedDraftTools, toolOf } from "./tools.js";
|
|
|
46
46
|
import { isMcpName } from "./tool-names.js";
|
|
47
47
|
import { workflowNodes } from "./model.js";
|
|
48
48
|
import { SKIPPED_WRITE, toolWord, unmarkedWords } from "./learn/replay-calls.js";
|
|
49
|
+
import { WORKFLOW_FIRST_CALL, workflowDigest } from "./runner/workflow-first.js";
|
|
49
50
|
/** What a learned_workflow call's approval card says of its MCP actions' arguments: a `{name}` in one is filled in as
|
|
50
51
|
* the workflow runs. */
|
|
51
52
|
export const LEARNED_MCP_ARGUMENTS = "each {name} is filled in while the workflow runs, from its input or an earlier step";
|
|
@@ -272,13 +273,14 @@ export function learnedWorkflowTool(run) {
|
|
|
272
273
|
const loops = [];
|
|
273
274
|
// A replay's write the recording did not have (learn/replay-calls.ts) rides on the same entry, ran a node or not; so
|
|
274
275
|
// does how the workflow ended (`ended`, LearnedEnded), the one thing a replay's outcome reads (workflow-first.ts
|
|
275
|
-
// pathMetrics)
|
|
276
|
-
|
|
276
|
+
// pathMetrics). The entry is the call's record whatever ran (runner/workflow-calls.ts workflowCallsOf): its
|
|
277
|
+
// workflow's digest, who called it (the platform's call before the agent's first turn, WORKFLOW_FIRST_CALL, or the
|
|
278
|
+
// agent's own), so a refusal before any node is one call too (`refused`: it ran nothing, and the money rule counts
|
|
279
|
+
// it on no side), and a call stopped part way one with no `ended`.
|
|
280
|
+
const record = { call: ledger.call, workflow: flow.name, digest: workflowDigest(flow), caller: ledger.call === WORKFLOW_FIRST_CALL ? "platform" : "agent" };
|
|
281
|
+
const keep = (signal, ended, refused) => {
|
|
277
282
|
const skipped = run.replay?.skipped;
|
|
278
|
-
|
|
279
|
-
if (!trace.length && !loops.length && !skipped && !(run.replay && ended))
|
|
280
|
-
return undefined;
|
|
281
|
-
return api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: LEARNED_NODES, data: { call: ledger.call, workflow: flow.name, nodes: trace, ...(loops.length ? { loops } : {}), ...(skipped ? { replay_skipped: skipped } : {}), ...(ended ? { ended } : {}) } })), signal).catch(() => undefined);
|
|
283
|
+
return api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: LEARNED_NODES, data: { ...record, nodes: trace, ...(loops.length ? { loops } : {}), ...(skipped ? { replay_skipped: skipped } : {}), ...(ended ? { ended } : {}), ...(refused ? { refused } : {}) } })), signal).catch(() => undefined);
|
|
282
284
|
};
|
|
283
285
|
let said;
|
|
284
286
|
try {
|
|
@@ -288,20 +290,20 @@ export function learnedWorkflowTool(run) {
|
|
|
288
290
|
await keep(BACKGROUND_CONTEXT);
|
|
289
291
|
throw error;
|
|
290
292
|
}
|
|
291
|
-
await keep(context, said.ended);
|
|
293
|
+
await keep(context, said.ended, said.refused);
|
|
292
294
|
return forModel(said.text, { isError: said.isError });
|
|
293
295
|
},
|
|
294
296
|
});
|
|
295
297
|
}
|
|
296
298
|
/** `flow` run on `input` for `run`: its output as its tool hands it back (learnedOutput), or why it did not run, and each of its nodes that ran (at most
|
|
297
|
-
* LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
|
|
299
|
+
* LEARNED_NODES_MAX), none for one refused before any node ran (`refused`). Never throws, but on an abort. `ledger`: the tool call's,
|
|
298
300
|
* which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
|
|
299
301
|
* added as it ends, the caller's to keep when the call is aborted (and so throws) part way. `nested`: the session's tools as calls nested in this one, which its MCP nodes run as; and the values its first run
|
|
300
302
|
* fixed (`memo`), so a rerun of the call (after a park, a crash) goes on from what its model, decision and call nodes
|
|
301
303
|
* answered then, its MCP calls with the arguments they were asked and approved with, each recorded one answered from its
|
|
302
304
|
* record, never sent twice. `loops`: where each loop's exit is added (LoopRow), never capped. */
|
|
303
305
|
export async function runLearned(run, flow, input, signal, ledger, nodes = [], nested, loops = []) {
|
|
304
|
-
const refuse = (why) => ({ text: `The learned workflow ${flow.name} was not run: ${why}`, isError: true, nodes, ended: "failed" });
|
|
306
|
+
const refuse = (why) => ({ text: `The learned workflow ${flow.name} was not run: ${why}`, isError: true, nodes, ended: "failed", refused: true });
|
|
305
307
|
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
306
308
|
return refuse("its input must be a JSON object");
|
|
307
309
|
const dsl = await import("@parcha/agentrun-dsl");
|
|
@@ -480,8 +482,9 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = [], n
|
|
|
480
482
|
return skipped;
|
|
481
483
|
if (result.status === "escalated")
|
|
482
484
|
return { text: learnedText(handedBackText(flow.name, result.escalation, result.state, nodes)), isError: true, nodes, ended: "escalated" };
|
|
485
|
+
// It ran and ended neither way: failed, never a refusal (its nodes ran).
|
|
483
486
|
if (result.status !== "complete")
|
|
484
|
-
return
|
|
487
|
+
return { text: `The learned workflow ${flow.name} was not run: it ended ${result.status}`, isError: true, nodes, ended: "failed" };
|
|
485
488
|
return { text: learnedText(learnedOutput(result.output)), isError: false, nodes, ended: "complete" };
|
|
486
489
|
}
|
|
487
490
|
catch (error) {
|
package/dist/learning-cost.d.ts
CHANGED
|
@@ -9,6 +9,29 @@
|
|
|
9
9
|
* record at its end (metrics.path). */
|
|
10
10
|
export declare const RUN_PATHS: readonly ["agent", "handed_back", "workflow", "replay", "audit"];
|
|
11
11
|
export type RunPath = (typeof RUN_PATHS)[number];
|
|
12
|
+
/** Who called a learned workflow: the `platform` (it ran first, before the agent's first turn: runner/workflow-first.ts
|
|
13
|
+
* WORKFLOW_FIRST_CALL) or the `agent` (its own learned_workflow call). */
|
|
14
|
+
export declare const WORKFLOW_CALLERS: readonly ["platform", "agent"];
|
|
15
|
+
export type WorkflowCaller = (typeof WORKFLOW_CALLERS)[number];
|
|
16
|
+
/** How a learned workflow's call ended: `answered`, `handed_back` (it escalated, or a run served first took its answer
|
|
17
|
+
* back to the agent), `failed` (it threw, or was stopped), or `refused` (refused before any node ran: its input, a
|
|
18
|
+
* check, a tool its gate denies; it ran nothing, so the money rule counts it on no side). */
|
|
19
|
+
export declare const WORKFLOW_CALL_OUTCOMES: readonly ["answered", "handed_back", "failed", "refused"];
|
|
20
|
+
export type WorkflowCallOutcome = (typeof WORKFLOW_CALL_OUTCOMES)[number];
|
|
21
|
+
/** One call of a learned workflow in a run, as its record keeps it (runner/workflow-calls.ts workflowCallsOf, from the
|
|
22
|
+
* call's own journal entry): the workflow at its `digest`, who called it, how it ended, and what it booked (`usd`: the
|
|
23
|
+
* requests its nodes made, the run's one booking read; null when that can't be told apart from other work or is not
|
|
24
|
+
* known). A run's metrics keep each as `workflow_calls`, in call order; the ledger row and the money rule read them. */
|
|
25
|
+
export type WorkflowCall = {
|
|
26
|
+
readonly workflow: string;
|
|
27
|
+
readonly digest: string;
|
|
28
|
+
readonly caller: WorkflowCaller;
|
|
29
|
+
readonly outcome: WorkflowCallOutcome;
|
|
30
|
+
readonly usd: number | null;
|
|
31
|
+
};
|
|
32
|
+
/** The workflow calls a run's metrics keep (`workflow_calls`), each checked field by field: one off its shape is left
|
|
33
|
+
* out; none for a run that keeps none. */
|
|
34
|
+
export declare function workflowCallsIn(metrics: unknown): WorkflowCall[];
|
|
12
35
|
/** A booked figure with its float noise rounded off, nothing more (runner/metrics.ts floatNoiseOff, the precision a run's
|
|
13
36
|
* own cost is kept at): a decision costs millionths of a dollar, so a figure rounded to the millionth would lose it, and
|
|
14
37
|
* the run's cost here would read other than its usage row (A8). `+ 0` makes a noise-sized negative a plain 0, never -0. */
|
|
@@ -53,12 +76,6 @@ export type CostRun = {
|
|
|
53
76
|
* hand-back: costSummary counts it in `hand_backs.cut`, not `back`. */
|
|
54
77
|
export declare const NOT_SERVED: readonly ["cost_stop", "cut"];
|
|
55
78
|
export type NotServed = (typeof NOT_SERVED)[number];
|
|
56
|
-
/** The by-hand side, the one baseline both the cost page's `before` and the money rule read (costSummary,
|
|
57
|
-
* runner/workflow-first.ts costLineOf): of `runs` (oldest first), the `agent` runs before the first run a learned
|
|
58
|
-
* workflow served (SERVED_PATHS), every one when none has been served. */
|
|
59
|
-
export declare function byHandSide<T extends {
|
|
60
|
-
readonly path: unknown;
|
|
61
|
-
}>(runs: readonly T[]): T[];
|
|
62
79
|
/** The fewest runs after the takeover a "times cheaper" figure needs: fewer say too little. */
|
|
63
80
|
export declare const CHEAPER_AFTER_RUNS = 20;
|
|
64
81
|
/** How many of a learned workflow's newest runs served first at one version the money rule reads
|
|
@@ -68,8 +85,8 @@ export declare const COST_WINDOW = 10;
|
|
|
68
85
|
export declare const COST_RUNS_DEFAULT = 1000;
|
|
69
86
|
export declare const COST_RUNS_MAX = 10000;
|
|
70
87
|
/** The serving promotion's check (store-reads/learning.ts servingReplayOf): on `n` inputs, the workflow's agreement and the
|
|
71
|
-
* agent's own in percent to a tenth, whether it `cleared` the bar (learn/
|
|
72
|
-
* itself: `agreed` of the `alone` inputs it answered alone
|
|
88
|
+
* agent's own in percent to a tenth, whether it `cleared` the bar `agree_min` (learn/field-check.ts check's joint floor), and the agreement check
|
|
89
|
+
* itself: `agreed` of the `alone` inputs it answered alone were right on every field, against the bar `agree_min` (0-1).
|
|
73
90
|
* Passing that bar is all it says: never that the workflow is as accurate as the agent. */
|
|
74
91
|
export type CostReplay = {
|
|
75
92
|
n: number;
|
package/dist/learning-cost.js
CHANGED
|
@@ -15,6 +15,27 @@ import { ApiError } from "./errors.js";
|
|
|
15
15
|
* learning). One classifier (store-reads/learning.ts runPathOverStore) writes it on the run's
|
|
16
16
|
* record at its end (metrics.path). */
|
|
17
17
|
export const RUN_PATHS = ["agent", "handed_back", "workflow", "replay", "audit"];
|
|
18
|
+
/** Who called a learned workflow: the `platform` (it ran first, before the agent's first turn: runner/workflow-first.ts
|
|
19
|
+
* WORKFLOW_FIRST_CALL) or the `agent` (its own learned_workflow call). */
|
|
20
|
+
export const WORKFLOW_CALLERS = ["platform", "agent"];
|
|
21
|
+
/** How a learned workflow's call ended: `answered`, `handed_back` (it escalated, or a run served first took its answer
|
|
22
|
+
* back to the agent), `failed` (it threw, or was stopped), or `refused` (refused before any node ran: its input, a
|
|
23
|
+
* check, a tool its gate denies; it ran nothing, so the money rule counts it on no side). */
|
|
24
|
+
export const WORKFLOW_CALL_OUTCOMES = ["answered", "handed_back", "failed", "refused"];
|
|
25
|
+
/** The workflow calls a run's metrics keep (`workflow_calls`), each checked field by field: one off its shape is left
|
|
26
|
+
* out; none for a run that keeps none. */
|
|
27
|
+
export function workflowCallsIn(metrics) {
|
|
28
|
+
const calls = metrics && typeof metrics === "object" ? metrics.workflow_calls : undefined;
|
|
29
|
+
if (!Array.isArray(calls))
|
|
30
|
+
return [];
|
|
31
|
+
return calls.flatMap((one) => {
|
|
32
|
+
const c = (one ?? {});
|
|
33
|
+
const usdOk = c.usd === null || (typeof c.usd === "number" && Number.isFinite(c.usd));
|
|
34
|
+
if (typeof c.workflow !== "string" || typeof c.digest !== "string" || !WORKFLOW_CALLERS.includes(c.caller) || !WORKFLOW_CALL_OUTCOMES.includes(c.outcome) || !usdOk)
|
|
35
|
+
return [];
|
|
36
|
+
return [{ workflow: c.workflow, digest: c.digest, caller: c.caller, outcome: c.outcome, usd: c.usd }];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
18
39
|
/** A mean, rounded to the millionth: a quotient, never a booked figure. */
|
|
19
40
|
const usd = (value) => Math.round(value * 1e6) / 1e6;
|
|
20
41
|
/** A booked figure with its float noise rounded off, nothing more (runner/metrics.ts floatNoiseOff, the precision a run's
|
|
@@ -26,13 +47,6 @@ export const noiseOff = (value) => Math.round(value * 1e12) / 1e12 + 0;
|
|
|
26
47
|
* restart cut its call and the run was handed back (metrics.workflow_cut, servedOf `cut`), never the workflow's own
|
|
27
48
|
* hand-back: costSummary counts it in `hand_backs.cut`, not `back`. */
|
|
28
49
|
export const NOT_SERVED = ["cost_stop", "cut"];
|
|
29
|
-
/** The by-hand side, the one baseline both the cost page's `before` and the money rule read (costSummary,
|
|
30
|
-
* runner/workflow-first.ts costLineOf): of `runs` (oldest first), the `agent` runs before the first run a learned
|
|
31
|
-
* workflow served (SERVED_PATHS), every one when none has been served. */
|
|
32
|
-
export function byHandSide(runs) {
|
|
33
|
-
const first = runs.findIndex((run) => SERVED_PATHS.includes(run.path));
|
|
34
|
-
return (first < 0 ? runs : runs.slice(0, first)).filter((run) => run.path === "agent");
|
|
35
|
-
}
|
|
36
50
|
/** The fewest runs after the takeover a "times cheaper" figure needs: fewer say too little. */
|
|
37
51
|
export const CHEAPER_AFTER_RUNS = 20;
|
|
38
52
|
/** How many of a learned workflow's newest runs served first at one version the money rule reads
|
|
@@ -63,7 +77,8 @@ export function tookOverOf(runs) {
|
|
|
63
77
|
export const AFTER_STATES = ["priced", "no_served_runs", "cost_unknown"];
|
|
64
78
|
export function costSummary(runs, replay = null, cut = new Set()) {
|
|
65
79
|
const first = runs.findIndex((run) => SERVED_PATHS.includes(run.path));
|
|
66
|
-
|
|
80
|
+
// The by-hand side: the `agent` runs before the first one served, every one when none has been.
|
|
81
|
+
const beforeSide = (first < 0 ? runs : runs.slice(0, first)).filter((run) => run.path === "agent").map((run) => ({ value: run.cost_usd, bound: run.cost_upper_bound }));
|
|
67
82
|
// Served runs alone: a replay (a check of a new revision, at workflow cost) and a run by hand are never the after side.
|
|
68
83
|
const served = first < 0 ? [] : runs.slice(first).filter((run) => SERVED_PATHS.includes(run.path));
|
|
69
84
|
const afterSide = served.map((run) => ({ value: run.total_usd, bound: run.cost_upper_bound }));
|
package/dist/learning-reset.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface LearningResetHost {
|
|
|
7
7
|
/** The cancel path, for one run that is not final: true once a cancel stands for it, false when this server cannot
|
|
8
8
|
* end it (agent-delete.ts AgentDeleteHost.cancel). */
|
|
9
9
|
cancel(runId: string): Promise<boolean>;
|
|
10
|
-
/** `work` in agent `agentId`'s learning queue (learning.ts
|
|
10
|
+
/** `work` in agent `agentId`'s learning queue (learning.ts inLearningQueue). */
|
|
11
11
|
inQueue<T>(agentId: string, work: () => Promise<T>): Promise<T>;
|
|
12
12
|
/** How long step 1 waits for the agent's learning runs to be final, and how often it reads them meanwhile. */
|
|
13
13
|
readonly waitMs: number;
|
package/dist/learning-reset.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// DELETE /v2/agents/{agent_id}/learning: an agent's learning reset, the agent kept. What it learned goes (the learning
|
|
2
|
-
// module's deleteLearning: its learning
|
|
3
|
-
// on every Archil disk its runs used, learn/learning-of.ts namedDisksOf, then its promotions and grades); the agent, its
|
|
2
|
+
// module's deleteLearning: its learning rows, every save, note, workflow, promotion record, grade and audit row); the agent, its
|
|
4
3
|
// definition, its runs and everything kept of them (their files, journals, costs, the learning each one kept) stay, so
|
|
5
4
|
// the run list, the stats and the usage read the same before and after. A served run's cost carries its share of its
|
|
6
5
|
// revision's compile and check, read from the promotion records the reset deletes: each revision they name is kept
|
|
7
6
|
// first in the agent's reset ledger (learn/promote.ts keepResetLedger: workflow, digest and K alone), so the share reads
|
|
8
7
|
// the same after.
|
|
9
8
|
//
|
|
10
|
-
// What goes with the
|
|
11
|
-
// so it is 404 after; what the run's own record keeps of its learning end stays with the run.
|
|
9
|
+
// What goes with the rows: each run's learning diff (GET /runs/{id}/learning/diff, the text it merged) is read from its
|
|
10
|
+
// save, so it is 404 after; what the run's own record keeps of its learning end stays with the run.
|
|
12
11
|
//
|
|
13
12
|
// In order, in the agent's delete turn (server.ts agentWrite: one learning write of an agent at a time, and none once
|
|
14
13
|
// its DELETE began):
|
|
@@ -18,18 +17,17 @@
|
|
|
18
17
|
// a workflow it may be served, its compile turn and look-back at its end), and the owner's job is never cancelled
|
|
19
18
|
// to reset learning. Any such run, or a learning run this server cannot end (an SDK run, an imported one) or one
|
|
20
19
|
// not final by the wait's end, is 409 learning_busy, naming them, and the agent's learning is left as it was.
|
|
21
|
-
// 2. In the agent's learning queue (learning.ts
|
|
22
|
-
// commits), the agent's runs are read again: one still going (a run started meanwhile) is 409 learning_busy, nothing
|
|
20
|
+
// 2. In the agent's learning queue (learning.ts inLearningQueue, where a run's start reads its seed), the agent's runs are read again: one still going (a run started meanwhile) is 409 learning_busy, nothing
|
|
23
21
|
// deleted. Then deleteLearning, which reads them once more itself.
|
|
24
22
|
// Idempotent: an agent that never learned, or one reset already, has nothing to delete, and is answered as done.
|
|
25
23
|
//
|
|
26
24
|
// Step 2 sets the agent's reset watermark (learn/promote.ts resetAtKey) before it deletes: from then on learning reads
|
|
27
25
|
// only runs after it (learn/compile.ts sinceReset: compile_after's count, a compile's traces, a check's inputs, an
|
|
28
|
-
// audit's draws, the money rule). A run whose start read
|
|
26
|
+
// audit's draws, the money rule). A run whose start read its seed before step 2
|
|
29
27
|
// and whose row the store wrote after it keeps what it was started with (its corrections are in its launch), but
|
|
30
28
|
// learns nothing: its seed was read before the watermark, so its learning end drops it whole at its entry
|
|
31
|
-
// (runner/learning-end.ts, reason `reset`), and the
|
|
32
|
-
// (learning
|
|
29
|
+
// (runner/learning-end.ts, reason `reset`), and the store refuses a save on a seed the agent's learning no longer holds
|
|
30
|
+
// (Store.learning save). No workflow is laid for it either: they are read at its seed's save, which is gone.
|
|
33
31
|
import { ApiError } from "./errors.js";
|
|
34
32
|
import { LearningInFlight } from "./learn/delete.js";
|
|
35
33
|
import { isShadowRun } from "./learn/audit.js";
|
|
@@ -68,7 +66,7 @@ export async function resetLearning(host, agentId) {
|
|
|
68
66
|
if (still.length)
|
|
69
67
|
throw busy(agentId, still.map((run) => run.id), still.some((run) => !run.learning) ? OWN(still.filter((run) => !run.learning).length) : "its learning work started again");
|
|
70
68
|
// What the agent's kept runs carry of their revisions' compile and check, kept before the records it is read from go.
|
|
71
|
-
await keepResetLedger(host.store.settings, agentId, await promotionsOf(host.store.
|
|
69
|
+
await keepResetLedger(host.store.settings, agentId, await promotionsOf(host.store.learning, agentId));
|
|
72
70
|
// The watermark, before anything goes: learning reads no run that started, or read its seed, at or before it (each
|
|
73
71
|
// seed is read in this queue, so one read before this moment never holds a later time). A seed read after the reset
|
|
74
72
|
// in the same millisecond counts as before it: its run learns nothing (reason reset) and an SDK start is refused, to
|
|
@@ -80,7 +78,7 @@ export async function resetLearning(host, agentId) {
|
|
|
80
78
|
const at = Date.now();
|
|
81
79
|
await keepResetAt(host.store.settings, agentId, at);
|
|
82
80
|
try {
|
|
83
|
-
await host.deleteLearning(host.store, agentId, { keepResetLedger: true
|
|
81
|
+
await host.deleteLearning(host.store, agentId, { keepResetLedger: true });
|
|
84
82
|
}
|
|
85
83
|
catch (error) {
|
|
86
84
|
if (!(error instanceof LearningInFlight))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { type DraftDecisions } from "./learn/workflow-draft.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type ItemHistory, type LearningRows, type LogChange } from "./learn/rows.js";
|
|
4
4
|
import type { ServingState } from "./learn/promote.js";
|
|
5
5
|
import { type ItemStatus, type Learning, type Shown } from "./learning.js";
|
|
6
6
|
import type { Impact } from "./learning-run.js";
|
|
@@ -21,32 +21,21 @@ type Retired = {
|
|
|
21
21
|
from?: "active" | "pending";
|
|
22
22
|
why?: "unreadable";
|
|
23
23
|
};
|
|
24
|
-
type Change =
|
|
25
|
-
by: {
|
|
26
|
-
run: string;
|
|
27
|
-
} | {
|
|
28
|
-
user: true;
|
|
29
|
-
via?: string;
|
|
30
|
-
};
|
|
31
|
-
commit: string;
|
|
32
|
-
at: string;
|
|
33
|
-
reason: string;
|
|
34
|
-
files: string[];
|
|
35
|
-
};
|
|
24
|
+
type Change = LogChange;
|
|
36
25
|
export type Counts = {
|
|
37
26
|
merged: number;
|
|
38
27
|
dropped: Record<string, number>;
|
|
39
28
|
in_progress: number;
|
|
40
29
|
};
|
|
41
30
|
export { secretsShown, type Shown } from "./learning.js";
|
|
31
|
+
/** The store's learning, as these routes read and write it. */
|
|
32
|
+
type Rows = {
|
|
33
|
+
readonly learning: LearningRows;
|
|
34
|
+
};
|
|
42
35
|
export declare const etagOf: (oid: string) => string;
|
|
43
|
-
/** Run `runId`'s text taken off agent `agentId`'s learning folder's current files at its purge (learn/commit.ts
|
|
44
|
-
* forgetRunText: a workflow it changed last goes back to the version before it that no purged run of `store` wrote),
|
|
45
|
-
* in the agent's queue, as every write of the folder is. */
|
|
46
|
-
export declare function forgetRunLearning(data: string, agentId: string, runId: string, store: Pick<Store, "runs">): Promise<void>;
|
|
47
36
|
/** A workflow draft as the view lists it: its folder's name, its workflow.json with its `readme`, its description, its
|
|
48
|
-
* status, the run whose
|
|
49
|
-
*
|
|
37
|
+
* status, the run whose text it is, its size in bytes, and the ETag of its README.md (the file that says whether it
|
|
38
|
+
* waits, which an approval names); cut of the host's secrets (a name or a file holding one reads [redacted]).
|
|
50
39
|
* `status` is one word: its README.md's `pending` or `retired`, else where it stands as the promotions read says it
|
|
51
40
|
* (`stateOf`, learn/promote.ts servingStateOf): `serving`, `checking`, `held` or `stopped`. */
|
|
52
41
|
type WorkflowView = {
|
|
@@ -59,25 +48,26 @@ type WorkflowView = {
|
|
|
59
48
|
bytes: number;
|
|
60
49
|
etag: string;
|
|
61
50
|
retired?: Retired;
|
|
62
|
-
last_change?:
|
|
51
|
+
last_change?: ItemHistory["last"];
|
|
63
52
|
};
|
|
64
|
-
/** For tests: how many times
|
|
53
|
+
/** For tests: how many times an agent's statuses were read (once per save of its learning). */
|
|
65
54
|
export declare const pendingTestHooks: {
|
|
66
55
|
reads: number;
|
|
67
56
|
};
|
|
68
|
-
/** Each workflow draft's status
|
|
69
|
-
* `active`, `pending` or `retired`. Built once per
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
57
|
+
/** Each workflow draft's status at agent `agentId`'s newest save, by its workflow.json (as its README.md says it):
|
|
58
|
+
* `active`, `pending` or `retired`. Built once per save (a list asks for many runs): the newest save's id (of any kind,
|
|
59
|
+
* a purge's too) is read first, and the view, its items and their history, only when it moved. An agent with no save
|
|
60
|
+
* holds none; one whose learning cannot be read is undefined. */
|
|
61
|
+
export declare function statusesOf(rows: {
|
|
62
|
+
readonly learning: LearningRows & Pick<Store["learning"], "newestSave">;
|
|
63
|
+
}, agentId: string): Promise<ReadonlyMap<string, ItemStatus> | undefined>;
|
|
64
|
+
/** How many of agent `agentId`'s workflow drafts wait for its owner's OK at its newest save (statusesOf). An agent with
|
|
65
|
+
* no save has none waiting; one that cannot be read is undefined (the caller shows no count). */
|
|
66
|
+
export declare function pendingCount(rows: Parameters<typeof statusesOf>[0], agentId: string): Promise<number | undefined>;
|
|
67
|
+
/** GET /agents/{id}/learning: its newest save, its corrections.md, its workflow drafts and the first page of its log, and
|
|
68
|
+
* how the agent's runs fared and what learning changed for them (`counts`, `impact`); an agent with no save (its learning
|
|
77
69
|
* never on) has an empty one. `stateOf`: where each workflow neither pending nor retired stands, by its folder name (the
|
|
78
|
-
* promotions read's own word: learn/promote.ts servingStateOf over the agent's records).
|
|
79
|
-
* (purged-workflow.ts purgeGate, over `store`'s runs): no workflow a purged run wrote, and no purged run's merge in its
|
|
80
|
-
* log. */
|
|
70
|
+
* promotions read's own word: learn/promote.ts servingStateOf over the agent's records). */
|
|
81
71
|
type AgentView = {
|
|
82
72
|
agent: string;
|
|
83
73
|
main: string | null;
|
|
@@ -87,13 +77,13 @@ type AgentView = {
|
|
|
87
77
|
counts: Counts;
|
|
88
78
|
impact: Impact;
|
|
89
79
|
};
|
|
90
|
-
export declare function agentLearning(
|
|
91
|
-
/** GET /agents/{id}/learning/log?cursor=&limit=: a page of the
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*
|
|
96
|
-
export declare function correctionsView(
|
|
80
|
+
export declare function agentLearning(rows: Rows, agentId: string, shown: Shown, counts: Counts, impact: Impact, stateOf: (workflow: string) => ServingState): Promise<AgentView>;
|
|
81
|
+
/** GET /agents/{id}/learning/log?cursor=&limit=: a page of the agent's log, newest first. */
|
|
82
|
+
export declare function learningLog(rows: Rows, agentId: string, query: URLSearchParams, shown: Shown): Promise<Page<Change>>;
|
|
83
|
+
/** GET /agents/{id}/learning/corrections: corrections.md at the newest save as text (empty when it holds none), its ETag
|
|
84
|
+
* (its blob id; an empty file's when there is none) and the cap a PUT keeps to, cut of the host's secrets as every read
|
|
85
|
+
* is. */
|
|
86
|
+
export declare function correctionsView(rows: Rows, agentId: string, shown: Shown): Promise<{
|
|
97
87
|
text: string;
|
|
98
88
|
etag: string;
|
|
99
89
|
cap_bytes: number;
|
|
@@ -102,8 +92,8 @@ export declare function correctionsView(data: string, agentId: string, shown: Sh
|
|
|
102
92
|
* read (`ifMatch`: its ETag; none, or `*`, is 428; another version is 412). Refused whole, nothing written, when it holds
|
|
103
93
|
* what must never be stored (a host secret, text shaped like one, a hidden character) or passes the cap (422 with the
|
|
104
94
|
* problems, printable). A text read cut of a secret and sent back replaces the secret with the cut: a person's write never
|
|
105
|
-
* puts a secret back.
|
|
106
|
-
export declare function correctionsWrite(
|
|
95
|
+
* puts a secret back. One save. */
|
|
96
|
+
export declare function correctionsWrite(rows: Rows, agentId: string, input: {
|
|
107
97
|
text: string;
|
|
108
98
|
ifMatch?: string;
|
|
109
99
|
refuse: readonly string[];
|
|
@@ -112,8 +102,8 @@ export declare function correctionsWrite(data: string, agentId: string, input: {
|
|
|
112
102
|
etag: string;
|
|
113
103
|
cap_bytes: number;
|
|
114
104
|
}>;
|
|
115
|
-
/** One revision of a learned workflow: a
|
|
116
|
-
*
|
|
105
|
+
/** One revision of a learned workflow: a save that changed its workflow.json, with its text there (null when the save
|
|
106
|
+
* deleted it), cut of the host's secrets. */
|
|
117
107
|
type WorkflowRevision = {
|
|
118
108
|
commit: string;
|
|
119
109
|
at: string;
|
|
@@ -123,33 +113,26 @@ type WorkflowRevision = {
|
|
|
123
113
|
digest: string | null;
|
|
124
114
|
};
|
|
125
115
|
/** GET /agents/{id}/learning/workflows/{name}/revisions?limit=: the latest revisions of learned workflow `name` (the
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* LOG_KEEP changes). A purged run's merge is no revision (purgeGate). A workflow no commit of the log changed is
|
|
116
|
+
* saves that changed `workflows/<name>/workflow.json`), oldest first, each with the workflow's text there, so a person
|
|
117
|
+
* can step through how it changed: at most `limit` of them. `total` counts every such save; `truncated` is false, the
|
|
118
|
+
* rows keep every one. A purged run's save is no revision: its rows went with it. A workflow no save changed is
|
|
130
119
|
* not_found. */
|
|
131
|
-
export declare function workflowRevisions(
|
|
120
|
+
export declare function workflowRevisions(rows: Rows, agentId: string, name: string, query: URLSearchParams, shown: Shown): Promise<{
|
|
132
121
|
name: string;
|
|
133
122
|
revisions: WorkflowRevision[];
|
|
134
123
|
total: number;
|
|
135
124
|
truncated: boolean;
|
|
136
125
|
}>;
|
|
137
126
|
/** Learned workflow `name`'s text at `digest` (a champion's, as its promotion records name it), read by that digest and
|
|
138
|
-
* never by paging the workflow's history:
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
* old. One read-only exec per commit tried (textsAt), and one more for the commit that holds the digest, unless
|
|
142
|
-
* it is main (snapshotAt). */
|
|
143
|
-
export declare function workflowAtDigest(data: string, agentId: string, name: string, digest: string, commits: readonly string[], store: Pick<Store, "runs">): Promise<{
|
|
127
|
+
* never by paging the workflow's history: its newest version whose workflow.json is that digest's, with the save it was
|
|
128
|
+
* written at. Undefined when none is. */
|
|
129
|
+
export declare function workflowAtDigest(rows: Rows, agentId: string, name: string, digest: string): Promise<{
|
|
144
130
|
text: string;
|
|
145
131
|
commit: string;
|
|
146
132
|
} | undefined>;
|
|
147
|
-
/** GET /agents/{id}/learning/files/{file}: a draft's file
|
|
148
|
-
* JSON). A purged run's workflow
|
|
149
|
-
|
|
150
|
-
* purge took the folder's text, until its DELETE is sent again) is 410 purged, as every route of that run is
|
|
151
|
-
* (purgeGate). */
|
|
152
|
-
export declare function readLearnedFile(data: string, agentId: string, raw: string, shown: Shown, store: Pick<Store, "runs">): Promise<{
|
|
133
|
+
/** GET /agents/{id}/learning/files/{file}: a draft's file at the newest save as text, its ETag, and its type
|
|
134
|
+
* (workflow.json is JSON). A purged run's workflow went with its rows, so its files are the 404 any missing file is. */
|
|
135
|
+
export declare function readLearnedFile(rows: Rows, agentId: string, raw: string, shown: Shown): Promise<{
|
|
153
136
|
text: string;
|
|
154
137
|
etag: string;
|
|
155
138
|
type?: string;
|
|
@@ -174,22 +157,18 @@ type DraftTools = () => Promise<{
|
|
|
174
157
|
decisions?: DraftDecisions;
|
|
175
158
|
}>;
|
|
176
159
|
/** POST /agents/{id}/learning/files/{file}/approve, .../retire or .../restore, as a person, on a draft's README.md
|
|
177
|
-
* (`file`): If-Match on the version read (none, or `*`, is 428; another is 412), then one
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
|
|
185
|
-
* `store`'s runs): no person's change gives it to a run; a retire takes it out as any other. `refuse`: the host's
|
|
186
|
-
* secrets. */
|
|
187
|
-
export declare function changeWorkflow(data: string, agentId: string, raw: string, input: {
|
|
160
|
+
* (`file`): If-Match on the version read (none, or `*`, is 428; another is 412), then one save of the agent's learning
|
|
161
|
+
* (learn/rows.ts writeLearning), its reason `<approved|retired|restored> by a person: <file>`, and an approval's said to
|
|
162
|
+
* come through the console. An approval releases a held draft (status: pending) to every later run; a retire takes it
|
|
163
|
+
* out of every later run unchecked, so a leaking one can always be revoked; a restore brings it back to the status its
|
|
164
|
+
* retire recorded, checked again as a new draft is (secrets' shapes, the host's values, hidden characters, its README's
|
|
165
|
+
* format, its workflow.json against the agent's tools and gate). A retire of a retired draft saves nothing. `refuse`:
|
|
166
|
+
* the host's secrets. */
|
|
167
|
+
export declare function changeWorkflow(rows: Rows, agentId: string, raw: string, input: {
|
|
188
168
|
action: "approve" | "retire" | "restore";
|
|
189
169
|
ifMatch?: string;
|
|
190
170
|
refuse: readonly string[];
|
|
191
171
|
draftTools?: DraftTools;
|
|
192
|
-
store: Pick<Store, "runs">;
|
|
193
172
|
}): Promise<{
|
|
194
173
|
status: 200;
|
|
195
174
|
file: string;
|
|
@@ -207,7 +186,7 @@ export declare function runLearningBody(input: {
|
|
|
207
186
|
}, shown: Shown, secrets: readonly string[]): {
|
|
208
187
|
run: string;
|
|
209
188
|
state: "dropped" | "merged" | "seeded" | "reflecting";
|
|
210
|
-
reason: "cancelled" | "reset" | "
|
|
189
|
+
reason: "cancelled" | "reset" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_failed" | "empty" | "checker" | "use" | "purged_since_seed" | null;
|
|
211
190
|
detail: string | null;
|
|
212
191
|
at: string;
|
|
213
192
|
workflows: import("./learning.js").LearnedFile[];
|
|
@@ -238,13 +217,13 @@ export declare function runLearningBody(input: {
|
|
|
238
217
|
};
|
|
239
218
|
};
|
|
240
219
|
/** GET /runs/{id}/learning/diff over the one store: once merged (its learning end, store-reads/learning.ts
|
|
241
|
-
* runLearningEnd), its merge
|
|
242
|
-
* its
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
export declare function runDiffOverStore(
|
|
247
|
-
base: string;
|
|
220
|
+
* runLearningEnd), its merge's save against the one before it (learn/rows.ts runDiff); a run that merged nothing
|
|
221
|
+
* against the seed its launch's learning start names. A run that does not learn (no learning start and no learning
|
|
222
|
+
* end) is not_found, as a merge its agent's learning no longer holds is. A file's patch is withheld when too large, or
|
|
223
|
+
* when it holds one of the host's secrets now (`shown`); any other is served as every learning text is (`shown.text`:
|
|
224
|
+
* a loopback address reads "a local address"). */
|
|
225
|
+
export declare function runDiffOverStore(store: Store, runId: string, shown: Shown): Promise<{
|
|
226
|
+
base: string | null;
|
|
248
227
|
head: string;
|
|
249
228
|
files: ({
|
|
250
229
|
path: string;
|