@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/key-refusal.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export type RunKey = {
|
|
|
9
9
|
/** The key `harness`'s run of model `ref` (the revision's; none, this host's default for the harness) sends, by the route
|
|
10
10
|
* its wire takes (provider.ts; pi's, model.ts); undefined where it is not a model key this server names. */
|
|
11
11
|
export declare function runKeyOf(env: NodeJS.ProcessEnv, harness?: string, ref?: string): RunKey | undefined;
|
|
12
|
+
/** How many texts redacted and withheldWhole have read in this process: a test reads it to see a read of a run's rows
|
|
13
|
+
* cut only the texts an earlier read had not (store-reads/journal.ts rowCutsOnce). */
|
|
14
|
+
export declare const cutPasses: {
|
|
15
|
+
count: number;
|
|
16
|
+
};
|
|
12
17
|
/** `text`, a run's error as serve shows it, with no held secret in it: the one rule learning's checker uses
|
|
13
18
|
* (learn/secrets.ts redactSecrets: each value as written, JSON-escaped, base64 at each offset, hex and percent-encoded,
|
|
14
19
|
* and secret-shaped text), over `secrets`, the values the server holds and handed its run.
|
|
@@ -52,8 +57,10 @@ export declare function redactedAnswer(text: string, secrets: readonly string[])
|
|
|
52
57
|
export declare function redactedCall(text: string, secrets: readonly string[], shown: number, show?: (piece: string) => string): string;
|
|
53
58
|
/** Whether redactSecrets withholds `text` whole: it holds a held value or a secret shape no cut in place takes (split by
|
|
54
59
|
* whitespace, encoded, written as JSON's \uXXXX escapes). Read whole, never in pieces: the caller bounds what it reads
|
|
55
|
-
* (a web call's
|
|
56
|
-
|
|
60
|
+
* (a call's arguments or a web call's output: TimelineOptions.holds). `held`: spans of `text` cut in place beside its
|
|
61
|
+
* own finds, so a value read wholly inside one of them is taken there (sdk/runs.ts withheldParts: a part withheld by
|
|
62
|
+
* itself). */
|
|
63
|
+
export declare function withheldWhole(text: string, secrets: readonly string[], held?: readonly (readonly [number, number])[]): boolean;
|
|
57
64
|
/** Whether a number shows a held value. A held value can be all digits (a gateway's key), and a record or a call's
|
|
58
65
|
* arguments can quote it as a number: one whose digits hold a held value, by the same rule as a string's, is held. A
|
|
59
66
|
* number can also EQUAL a held value whose text differs from its own (a leading zero, 1e21, a long key read lossy). A
|
|
@@ -63,6 +70,11 @@ export declare function heldNumber(value: number | bigint, secrets: readonly str
|
|
|
63
70
|
* included (a dictionary field can be keyed by anything a run wrote), its shape kept. Two names of one object that come
|
|
64
71
|
* out the same would merge one value over the other: that object is withheld whole, as "[redacted]". */
|
|
65
72
|
export declare function redactedOutput(value: unknown, secrets: readonly string[]): unknown;
|
|
73
|
+
/** `value` as redactedOutput cuts it, read whole first: an object or an array whose JSON holds a held value no cut in
|
|
74
|
+
* place takes (withheldWhole, whose join view reads its strings joined: one split across two of its fields, or across a
|
|
75
|
+
* property name and its value) is withheld whole, as "[redacted]", as a call's arguments are (timeline.ts argsOf). A
|
|
76
|
+
* bigint is read as its digits; a value JSON cannot write is withheld. */
|
|
77
|
+
export declare function redactedOutputWhole(value: unknown, secrets: readonly string[]): unknown;
|
|
66
78
|
/** What a thinking or text block may show while it streams: what has streamed so far,
|
|
67
79
|
* redacted by the same rule as redacted(), less a fixed tail held back until the block ends, when its settled row
|
|
68
80
|
* replaces this one whole. A key whose head has streamed but not its tail cannot be found by any redactor, and a key
|
package/dist/key-refusal.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// count, a file name, a duration, another service's status) is no refused key, and the error is left as it is.
|
|
5
5
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
6
6
|
import { harnessOf } from "./harness-table.js";
|
|
7
|
-
import { cutSecrets, endsInScheme, redactSecrets, secretShapes, valueLeft, valueMatcher } from "./learn/secrets.js";
|
|
7
|
+
import { cutSecrets, endsInScheme, foldsHeld, redactSecrets, secretShapes, valueLeft, valueMatcher } from "./learn/secrets.js";
|
|
8
8
|
import { hostModel, MODEL_KEYS } from "./model.js";
|
|
9
9
|
import { modelWire, openRouterOnly, WIRES } from "./provider.js";
|
|
10
|
-
import { jsonEscapeAt, privateKeyEnd, scanned, squeeze } from "./redact/match.js";
|
|
10
|
+
import { entityAt, jsonEscapeAt, privateKeyEnd, pythonEscapeAt, scanned, squeeze } from "./redact/match.js";
|
|
11
11
|
import { savedGatewayIn } from "./model-gateway.js";
|
|
12
12
|
const row = (id) => {
|
|
13
13
|
const found = MODEL_KEYS.find((r) => r.id === id);
|
|
@@ -49,6 +49,9 @@ function detailOf(rest) {
|
|
|
49
49
|
const text = rest.replace(/^[\s:.-]*(unauthorized\b)?[\s:.-]*/i, "").replace(/,?\s*url:.*$/is, "").trim();
|
|
50
50
|
return (text.split(/(?<=[.!?])\s/)[0] ?? "").slice(0, 200).replace(/[.\s]+$/, "");
|
|
51
51
|
}
|
|
52
|
+
/** How many texts redacted and withheldWhole have read in this process: a test reads it to see a read of a run's rows
|
|
53
|
+
* cut only the texts an earlier read had not (store-reads/journal.ts rowCutsOnce). */
|
|
54
|
+
export const cutPasses = { count: 0 };
|
|
52
55
|
/** The most of a run's error or a tool's output serve ever shows: a Timeline row's text, cut at 2000 characters
|
|
53
56
|
* (`CAPS.text` in timeline/; a summary and a tool result's preview at 500), which the error box reads too. */
|
|
54
57
|
const SHOWN = 2000;
|
|
@@ -62,6 +65,7 @@ const SHOWN = 2000;
|
|
|
62
65
|
* error costs no more to redact than a short one, whatever it holds. `shown`: a head of another length, for a reader
|
|
63
66
|
* that is shown more. */
|
|
64
67
|
export function redacted(text, secrets, shown = SHOWN) {
|
|
68
|
+
cutPasses.count++;
|
|
65
69
|
const longest = secrets.reduce((most, value) => Math.max(most, value.length), 0);
|
|
66
70
|
const window = shown + 6 * longest + 16;
|
|
67
71
|
if (text.length <= window)
|
|
@@ -122,9 +126,12 @@ export function redactedCall(text, secrets, shown, show = (piece) => piece) {
|
|
|
122
126
|
}
|
|
123
127
|
/** Whether redactSecrets withholds `text` whole: it holds a held value or a secret shape no cut in place takes (split by
|
|
124
128
|
* whitespace, encoded, written as JSON's \uXXXX escapes). Read whole, never in pieces: the caller bounds what it reads
|
|
125
|
-
* (a web call's
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
* (a call's arguments or a web call's output: TimelineOptions.holds). `held`: spans of `text` cut in place beside its
|
|
130
|
+
* own finds, so a value read wholly inside one of them is taken there (sdk/runs.ts withheldParts: a part withheld by
|
|
131
|
+
* itself). */
|
|
132
|
+
export function withheldWhole(text, secrets, held = []) {
|
|
133
|
+
cutPasses.count++;
|
|
134
|
+
return redactSecrets(text, secrets, Number.POSITIVE_INFINITY, held) === "[redacted]";
|
|
128
135
|
}
|
|
129
136
|
/** Whether the text a reader is about to be shown (`shown`, what the caller returns) holds a held value, or the joined
|
|
130
137
|
* pieces still hold one or a secret shape: one a cut split. `shown` is read whole for a held value (valueMatcher, one
|
|
@@ -152,6 +159,7 @@ function heldIn(seen, secrets, shown) {
|
|
|
152
159
|
* Each piece is redacted, then shown as `show` makes it: `out` is what the pieces show, the pass reads them unshown. */
|
|
153
160
|
function inPieces(text, secrets, enough = Number.POSITIVE_INFINITY, show = (piece) => piece) {
|
|
154
161
|
const hold = 6 * secrets.reduce((most, value) => Math.max(most, value.length), 0) + 16;
|
|
162
|
+
const fold = foldsHeld(secrets);
|
|
155
163
|
const out = [];
|
|
156
164
|
const shapes = [];
|
|
157
165
|
const reads = [];
|
|
@@ -176,8 +184,8 @@ function inPieces(text, secrets, enough = Number.POSITIVE_INFINITY, show = (piec
|
|
|
176
184
|
// The run is shown as "[redacted]": its head is read, covered, for the rest of a value split before it, and its
|
|
177
185
|
// tail (tailOf: `hold` characters the matcher sees, at most a piece), covered too, for the head of a value whose
|
|
178
186
|
// rest comes after it. One read, the two joined by a line break, as each piece is one.
|
|
179
|
-
const head = peek(text, start, hold);
|
|
180
|
-
const tail = head === undefined ? undefined : tailOf(text, start, to, hold);
|
|
187
|
+
const head = peek(text, start, hold, fold);
|
|
188
|
+
const tail = head === undefined ? undefined : tailOf(text, start, to, hold, fold);
|
|
181
189
|
if (head === undefined || tail === undefined)
|
|
182
190
|
unread = true;
|
|
183
191
|
else {
|
|
@@ -210,7 +218,7 @@ function inPieces(text, secrets, enough = Number.POSITIVE_INFINITY, show = (piec
|
|
|
210
218
|
const space = run ? text.slice(from, from + ANSWER_PIECE).search(/\s/) : 0;
|
|
211
219
|
scanned.chars += space < 0 ? Math.min(ANSWER_PIECE, text.length - from) : space + 1;
|
|
212
220
|
const runTo = from + (space < 0 ? ANSWER_PIECE : space);
|
|
213
|
-
const ahead = peek(text, from, hold);
|
|
221
|
+
const ahead = peek(text, from, hold, fold);
|
|
214
222
|
if (ahead === undefined)
|
|
215
223
|
unread = true;
|
|
216
224
|
else {
|
|
@@ -236,28 +244,33 @@ function inPieces(text, secrets, enough = Number.POSITIVE_INFINITY, show = (piec
|
|
|
236
244
|
return { out: shows, seen: { raw, cuts, shapes: cutShapes, unread }, short: from < text.length && shown <= enough };
|
|
237
245
|
}
|
|
238
246
|
/** text from `from` on, as far as `count` characters the matcher sees (all of it, if it holds fewer), each run of
|
|
239
|
-
* whitespace in it one space. The matcher reads "+" as a space and decodes percent-encoded bytes
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
* whitespace in it one space. The matcher reads "+" as a space and decodes percent-encoded bytes, JSON's escapes (one
|
|
248
|
+
* level and two, as the JSON view reads them), Python's ("\'", "\x" and two hex digits, as the view that reads a
|
|
249
|
+
* single-quoted dict through them does) and HTML's character references (named and numeric), so a "+", an encoded
|
|
250
|
+
* byte, an escape and a reference that decode to whitespace count no more than whitespace does, and any other escape
|
|
251
|
+
* counts as what the view keeps of the character it decodes to. A character that renders as nothing (a zero-width
|
|
252
|
+
* space, a soft hyphen) or a combining mark counts as nothing too: the views drop it. So does a quote, an apostrophe
|
|
253
|
+
* or JSON's punctuation ("{", "}", "[", "]", ",", ":"), which the join views drop between a text's strings, and, with
|
|
254
|
+
* `fold` (a held value folds: learn/secrets.ts foldsHeld), a separator ("-", "_", ":", "."), which the fold view
|
|
255
|
+
* drops. Padding of any of them never hides the rest of a value split before it. Undefined, so the caller withholds
|
|
256
|
+
* the text, when that takes more than a piece of text (a run of whitespace counted as one): no redaction pass reads
|
|
257
|
+
* more than a piece. */
|
|
258
|
+
function peek(text, from, count, fold) {
|
|
259
|
+
const read = visible(text, from, count, text.length, fold);
|
|
248
260
|
return read.span > ANSWER_PIECE ? undefined : read.parts.join("");
|
|
249
261
|
}
|
|
250
262
|
/** The end of the run text[start, to) the pass reads for the head of a value whose rest comes after the run: as few of
|
|
251
263
|
* its last characters as hold `count` characters the matcher sees (at most a piece's worth), counted as peek counts
|
|
252
|
-
* them, so padding the views read as nothing (whitespace, a zero-width space, a soft hyphen,
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
|
|
264
|
+
* them (with `fold` as peek's), so padding the views read as nothing (whitespace, a zero-width space, a soft hyphen, a
|
|
265
|
+
* quote or JSON's punctuation, a separator a folded value drops, an escape, a character reference or encoded bytes
|
|
266
|
+
* that decode to any of them) between that head and the run's end never pushes the head out of it. Read forward from
|
|
267
|
+
* a start moved back from `to`, twice as far each time, so it reads at most two pieces in all. Undefined, so the
|
|
268
|
+
* caller withholds the text, when that takes more than a piece of text. */
|
|
269
|
+
function tailOf(text, start, to, count, fold) {
|
|
257
270
|
const want = Math.min(count, ANSWER_PIECE);
|
|
258
271
|
for (let width = Math.min(want, to - start);; width = Math.min(2 * width, ANSWER_PIECE, to - start)) {
|
|
259
272
|
const from = to - width;
|
|
260
|
-
if (from === start || visible(text, from, want, to).found >= want)
|
|
273
|
+
if (from === start || visible(text, from, want, to, fold).found >= want)
|
|
261
274
|
return text.slice(from, to);
|
|
262
275
|
if (width >= ANSWER_PIECE)
|
|
263
276
|
return undefined;
|
|
@@ -265,11 +278,10 @@ function tailOf(text, start, to, count) {
|
|
|
265
278
|
}
|
|
266
279
|
/** text[from, to) read as peek says, until `count` characters the matcher sees are found or the read passes a piece
|
|
267
280
|
* of text (`span`, a run of whitespace counted as one): what it read, as peek returns it, and how many it found. */
|
|
268
|
-
function visible(text, from, count, to) {
|
|
281
|
+
function visible(text, from, count, to, fold) {
|
|
269
282
|
const parts = [];
|
|
270
283
|
let span = 0;
|
|
271
284
|
let found = 0;
|
|
272
|
-
let escape;
|
|
273
285
|
for (let at = from; at < to && found < count && span <= ANSWER_PIECE;) {
|
|
274
286
|
SPACES.lastIndex = at;
|
|
275
287
|
let end = SPACES.test(text) ? SPACES.lastIndex : at;
|
|
@@ -281,15 +293,22 @@ function visible(text, from, count, to) {
|
|
|
281
293
|
while (end - at <= ANSWER_PIECE && end + 3 <= to && text[end] === "%" && HEX_PAIR.test(text.slice(end + 1, end + 3)))
|
|
282
294
|
end += 3;
|
|
283
295
|
if (end > at)
|
|
284
|
-
found +=
|
|
285
|
-
else if (text[at] === "\\" && (escape = jsonEscapeAt(text, at)) !== undefined) {
|
|
286
|
-
end = escape.end;
|
|
287
|
-
found += squeeze(escape.char).length;
|
|
288
|
-
}
|
|
296
|
+
found += kept(Buffer.from(text.slice(at, end).replaceAll("%", ""), "hex").toString("utf8"), fold);
|
|
289
297
|
else {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
298
|
+
// A character past U+FFFF is read whole, its two UTF-16 units as they are or as two escapes, as the views gather
|
|
299
|
+
// it before they squeeze it: a combining mark past U+FFFF is then dropped as the views drop it, where each of
|
|
300
|
+
// its halves alone would count as one.
|
|
301
|
+
let read = charAt(text, at);
|
|
302
|
+
end = read.end;
|
|
303
|
+
if (end < to && HIGH(read.char)) {
|
|
304
|
+
const low = charAt(text, end);
|
|
305
|
+
if (LOW(low.char)) {
|
|
306
|
+
read = { char: read.char + low.char, end: low.end, raw: false };
|
|
307
|
+
end = low.end;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (!(read.raw && read.char === "+"))
|
|
311
|
+
found += kept(read.char, fold);
|
|
293
312
|
}
|
|
294
313
|
parts.push(text.slice(at, end));
|
|
295
314
|
span += end - at;
|
|
@@ -300,8 +319,35 @@ function visible(text, from, count, to) {
|
|
|
300
319
|
}
|
|
301
320
|
return { parts, found, span };
|
|
302
321
|
}
|
|
322
|
+
/** The character text[at] starts, as the views read it: one of Python's escapes (pythonEscapeAt, at either level:
|
|
323
|
+
* "\x20" and "\\x20" are a space), else a JSON escape's (jsonEscapeAt), or a character reference's (entityAt), else
|
|
324
|
+
* the UTF-16 unit itself (`raw`), and where it ends. Python's first: where JSON's escapes read "\\x20" as a backslash
|
|
325
|
+
* and three characters, the view that reads Python's twice reads a space; counting less only reads further. */
|
|
326
|
+
function charAt(text, at) {
|
|
327
|
+
let escape;
|
|
328
|
+
if ((text[at] === "\\" && ((escape = pythonEscapeAt(text, at)) !== undefined || (escape = jsonEscapeAt(text, at)) !== undefined)) ||
|
|
329
|
+
(text[at] === "&" && (escape = entityAt(text, at)) !== undefined))
|
|
330
|
+
return { ...escape, raw: false };
|
|
331
|
+
return { char: text[at], end: at + 1, raw: true };
|
|
332
|
+
}
|
|
333
|
+
const HIGH = (char) => char.length === 1 && char.charCodeAt(0) >= 0xd800 && char.charCodeAt(0) <= 0xdbff;
|
|
334
|
+
const LOW = (char) => char.length === 1 && char.charCodeAt(0) >= 0xdc00 && char.charCodeAt(0) <= 0xdfff;
|
|
303
335
|
const SPACES = /\s+/y;
|
|
304
336
|
const HEX_PAIR = /^[0-9A-Fa-f]{2}$/;
|
|
337
|
+
/** What every view drops between a text's strings: a quote, an apostrophe (the join of single-quoted strings) and JSON's
|
|
338
|
+
* punctuation (the join view). */
|
|
339
|
+
const JOIN_DROPS = new Set(['"', "'", "{", "}", "[", "]", ",", ":"]);
|
|
340
|
+
/** What the fold view drops: the separators of a hex identifier. */
|
|
341
|
+
const FOLD_DROPS = new Set(["-", "_", ":", "."]);
|
|
342
|
+
/** How many characters the views keep of `chars` at the least (peek): squeezed, less each the join view drops, and,
|
|
343
|
+
* with `fold`, each the fold view drops. */
|
|
344
|
+
function kept(chars, fold) {
|
|
345
|
+
let count = 0;
|
|
346
|
+
for (const char of squeeze(chars))
|
|
347
|
+
if (!JOIN_DROPS.has(char) && !(fold && FOLD_DROPS.has(char)))
|
|
348
|
+
count += char.length;
|
|
349
|
+
return count;
|
|
350
|
+
}
|
|
305
351
|
/** Where the piece of `text` read from `from` ends: at its last whitespace before ANSWER_PIECE characters; with none, at
|
|
306
352
|
* runCut's place, else at the next whitespace (a run read as one, or unread past ANSWER_PIECE). Never inside a private
|
|
307
353
|
* key block whose END line is in reach (keyWhole). */
|
|
@@ -428,6 +474,24 @@ export function redactedOutput(value, secrets) {
|
|
|
428
474
|
}
|
|
429
475
|
return value;
|
|
430
476
|
}
|
|
477
|
+
/** `value` as redactedOutput cuts it, read whole first: an object or an array whose JSON holds a held value no cut in
|
|
478
|
+
* place takes (withheldWhole, whose join view reads its strings joined: one split across two of its fields, or across a
|
|
479
|
+
* property name and its value) is withheld whole, as "[redacted]", as a call's arguments are (timeline.ts argsOf). A
|
|
480
|
+
* bigint is read as its digits; a value JSON cannot write is withheld. */
|
|
481
|
+
export function redactedOutputWhole(value, secrets) {
|
|
482
|
+
if (value !== null && typeof value === "object") {
|
|
483
|
+
let json;
|
|
484
|
+
try {
|
|
485
|
+
json = JSON.stringify(value, (_key, item) => (typeof item === "bigint" ? item.toString() : item));
|
|
486
|
+
}
|
|
487
|
+
catch {
|
|
488
|
+
return "[redacted]";
|
|
489
|
+
}
|
|
490
|
+
if (withheldWhole(json, secrets))
|
|
491
|
+
return "[redacted]";
|
|
492
|
+
}
|
|
493
|
+
return redactedOutput(value, secrets);
|
|
494
|
+
}
|
|
431
495
|
/** What a thinking or text block may show while it streams: what has streamed so far,
|
|
432
496
|
* redacted by the same rule as redacted(), less a fixed tail held back until the block ends, when its settled row
|
|
433
497
|
* replaces this one whole. A key whose head has streamed but not its tail cannot be found by any redactor, and a key
|
package/dist/learn/audit.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Store } from "../store/store.js";
|
|
2
2
|
import type { AuditLoop } from "../learning-setting.js";
|
|
3
3
|
import type { RunLaunch } from "../run-launch.js";
|
|
4
|
-
import {
|
|
5
|
-
import { type CostStop, type PromotionRecord, type Refused, type ServingState } from "./promote.js";
|
|
6
|
-
export { AUDITS_FILE };
|
|
7
|
-
/** The newest rows the ledger keeps: twice the widest window a definition may set (AUDIT_MAX), and a file well under the
|
|
8
|
-
* folder's file cap (a line is a few hundred bytes); with them, the started lines of theirs, and every open one. */
|
|
9
|
-
export declare const AUDITS_KEPT = 2000;
|
|
4
|
+
import { type CostStop, type PromotionRecord, type ServingState } from "./promote.js";
|
|
10
5
|
/** What every shadow run's id starts with: its served run's id follows (shadowRunId). No server-minted id starts so. */
|
|
11
6
|
export declare const SHADOW_PREFIX = "audit.";
|
|
7
|
+
/** The newest rows the ledger keeps: twice the widest window a definition may set (AUDIT_MAX); with them, the started
|
|
8
|
+
* lines of theirs, and every open one (addAuditLines trims it in the write that adds). */
|
|
9
|
+
export declare const AUDITS_KEPT = 2000;
|
|
12
10
|
/** One finished audit. `run`: the served run; `shadow_run`: its shadow (null for a grade's row, or one never started);
|
|
13
11
|
* `workflow` at `digest` served it, under the promotion begun at `promoted_at` (learn/promote.ts promotionStartOf: the
|
|
14
|
-
* one serving when its shadow started, or at the grade; null: none); `agreed`: whether the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* one serving when its shadow started, or at the grade; null: none); `agreed`: whether the served answer is right
|
|
13
|
+
* against the known one (the shadow's, or a grade's: its `correct`, else its expected answer's verdict), null when
|
|
14
|
+
* either answer is missing (a shadow that failed, parked or never ran) or a grade contradicts itself: no evidence either
|
|
15
|
+
* way, never counted by the hold rule; the two runs' costs (null unknown). `turn`: the served run's answer the audit is
|
|
17
16
|
* of, the id of its answer row (its newest final answer when the audit began, or at the grade): a follow-up's later
|
|
18
17
|
* answer is never the one compared; absent when it had none. `skipped`: a drawn run whose cap left its shadow no
|
|
19
18
|
* allowance (less than a run's smallest cap): no shadow was started. `parked`: its shadow came to wait on a person (an
|
|
@@ -74,25 +73,27 @@ export declare const auditsOffWords: (tool: string) => string;
|
|
|
74
73
|
* uploaded files. A triggered run's context (a GitHub event's checkout, the thread it answers on) is never rebuilt for a
|
|
75
74
|
* shadow, which could answer there too: its served run is not auditable (its record's metrics.not_auditable). */
|
|
76
75
|
export declare const auditableLaunch: (launch: Pick<RunLaunch, "trigger" | "inputOrigin" | "files">) => boolean;
|
|
77
|
-
/** The
|
|
78
|
-
export
|
|
79
|
-
/** The
|
|
80
|
-
export declare
|
|
81
|
-
/** The ledger's
|
|
82
|
-
export declare
|
|
83
|
-
/** The ledger's rows on the folder's main: its finished audits, oldest first. */
|
|
84
|
-
export declare const readAudits: (ws: Workspace) => Promise<AuditRow[]>;
|
|
76
|
+
/** The store's learning records, as the ledger is read and written. */
|
|
77
|
+
export type AuditRecords = Pick<Store["learning"], "records" | "changeRecords">;
|
|
78
|
+
/** The agent's ledger, in the order written (none before the first line). */
|
|
79
|
+
export declare const ledgerOf: (rows: Pick<AuditRecords, "records">, agentId: string) => Promise<LedgerLine[]>;
|
|
80
|
+
/** The ledger's rows: its finished audits, oldest first. */
|
|
81
|
+
export declare const readAudits: (rows: Pick<AuditRecords, "records">, agentId: string) => Promise<AuditRow[]>;
|
|
85
82
|
/** A line's place in the ledger: one per served run and source (a started line's, its shadow's row, a grade's row). */
|
|
86
83
|
export declare const lineKey: (line: LedgerLine) => string;
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
|
|
84
|
+
/** Appends `lines` to the ledger, each not there yet (lineKey), in one transaction: `replace`, a line whose key is there
|
|
85
|
+
* takes the place of the one there (a grade's row of a run graded again). The ledger after (`all`) with the lines it
|
|
86
|
+
* appended. A line of a digest no version of its workflow holds (a run's purge took it since the line was read), or of a
|
|
87
|
+
* run that was purged, is never appended (Store.learning changeRecords refuses it): the others are. */
|
|
88
|
+
export declare function addAuditLines(rows: AuditRecords, agentId: string, lines: readonly LedgerLine[], replace?: boolean): Promise<{
|
|
89
|
+
all: LedgerLine[];
|
|
90
90
|
added: LedgerLine[];
|
|
91
|
-
|
|
92
|
-
};
|
|
91
|
+
}>;
|
|
93
92
|
/** The rows the hold rule counts for `workflow` at `digest` under the promotion begun at `promotedAt` (learn/promote.ts
|
|
94
|
-
* promotionStartOf; none counted for null): those with a verdict, the newest `hold_window` of them.
|
|
95
|
-
|
|
93
|
+
* promotionStartOf; none counted for null): those with a verdict, the newest `hold_window` of them. A served run an
|
|
94
|
+
* owner graded is counted by its grade's row alone: the grade is its known answer, as it is the check's, so its
|
|
95
|
+
* shadow (the agent's answer again) never says otherwise, and a grade that contradicts itself leaves it unjudged. */
|
|
96
|
+
export declare function windowOf(rows: readonly AuditRow[], workflow: string, digest: string, promotedAt: string | null, loop: Pick<AuditLoop, "hold_window">): AuditRow[];
|
|
96
97
|
/** The hold rule: the counted rows (windowOf) when at least `hold_disagree` of them disagree, else undefined. */
|
|
97
98
|
export declare function holdOf(rows: readonly AuditRow[], workflow: string, digest: string, promotedAt: string | null, loop: Pick<AuditLoop, "hold_window" | "hold_disagree">): {
|
|
98
99
|
rows: AuditRow[];
|
|
@@ -109,7 +110,7 @@ export declare function auditLineOf(rows: readonly AuditRow[], workflow: string,
|
|
|
109
110
|
/** What the promotions read says of each learned workflow beside what serves (learn/promote.ts servingOf, in its order):
|
|
110
111
|
* `state` (learn/promote.ts servingStateOf with the money rule's decision, `costStop`: the word the learning view's
|
|
111
112
|
* `status` says too), its newest decided check's numbers, and its audit line over the rows of the serving (else the
|
|
112
|
-
* newest) revision's newest promotion (the ones the hold rule counts).
|
|
113
|
+
* newest) revision's newest promotion (the ones the hold rule counts). */
|
|
113
114
|
export type ServingLine = {
|
|
114
115
|
readonly state: ServingState;
|
|
115
116
|
readonly check: {
|
|
@@ -120,4 +121,4 @@ export type ServingLine = {
|
|
|
120
121
|
} | null;
|
|
121
122
|
readonly audit: AuditLine | null;
|
|
122
123
|
};
|
|
123
|
-
export declare function servingLinesOf(records: readonly PromotionRecord[], rows: readonly AuditRow[], loop: Pick<AuditLoop, "hold_window" | "hold_disagree">, costStop: CostStop
|
|
124
|
+
export declare function servingLinesOf(records: readonly PromotionRecord[], rows: readonly AuditRow[], loop: Pick<AuditLoop, "hold_window" | "hold_disagree">, costStop: CostStop): ServingLine[];
|
package/dist/learn/audit.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
// The audit ledger:
|
|
2
|
-
// alone (runner/audit.ts, and the server for an owner's grade). A `started` line is a shadow audit begun (written before
|
|
1
|
+
// The audit ledger: the agent's audit records (Store.learning records of kind audit), one line each, appended by the
|
|
2
|
+
// host alone (runner/audit.ts, and the server for an owner's grade). A `started` line is a shadow audit begun (written before
|
|
3
3
|
// its shadow run is created); a row is one finished audit of a run a promoted learned workflow served first: its shadow
|
|
4
4
|
// run's answer (the same agent on the same input, learning off) against the served one (source `shadow`, the started
|
|
5
|
-
// line's result), or an owner's grade of the served run (source `grade
|
|
6
|
-
// started lines with no result row: settlement reads their
|
|
7
|
-
// Each line keeps the promotion it counts for (`promoted_at`),
|
|
8
|
-
// revision's current promotion (holdOf). The engine never reads a
|
|
9
|
-
// (
|
|
5
|
+
// line's result), or an owner's grade of the served run (source `grade`: the served answer against the grade's known
|
|
6
|
+
// answer, which outranks the shadow's). The open audits are the started lines with no result row: settlement reads their
|
|
7
|
+
// two runs by id, so none is ever lost to a window of runs. Each line keeps the promotion it counts for (`promoted_at`),
|
|
8
|
+
// and the hold rule reads the newest rows of the serving revision's current promotion (holdOf). The engine never reads a
|
|
9
|
+
// row's domain: only whether an answer is right against the known one (runner/promotion.ts answerJudged) and what each
|
|
10
|
+
// run cost.
|
|
10
11
|
import { createHash } from "node:crypto";
|
|
11
12
|
import { COMPUTER_TOOLS } from "@parcha/agentrun-kernel/kernel";
|
|
13
|
+
import { LearningRecordRefused } from "../store/store.js";
|
|
12
14
|
import { pinAnnotations, toolClassOf, toolWord } from "./replay-calls.js";
|
|
13
|
-
import { AUDITS_FILE, readLearning } from "./folder.js";
|
|
14
15
|
import { promotionStartOf, servingOf, servingStateOf } from "./promote.js";
|
|
15
|
-
export { AUDITS_FILE };
|
|
16
|
-
/** The newest rows the ledger keeps: twice the widest window a definition may set (AUDIT_MAX), and a file well under the
|
|
17
|
-
* folder's file cap (a line is a few hundred bytes); with them, the started lines of theirs, and every open one. */
|
|
18
|
-
export const AUDITS_KEPT = 2_000;
|
|
19
16
|
/** What every shadow run's id starts with: its served run's id follows (shadowRunId). No server-minted id starts so. */
|
|
20
17
|
export const SHADOW_PREFIX = "audit.";
|
|
18
|
+
/** The newest rows the ledger keeps: twice the widest window a definition may set (AUDIT_MAX); with them, the started
|
|
19
|
+
* lines of theirs, and every open one (addAuditLines trims it in the write that adds). */
|
|
20
|
+
export const AUDITS_KEPT = 2_000;
|
|
21
21
|
/** The rows of `lines` (the finished audits), oldest first. */
|
|
22
22
|
export const rowsOf = (lines) => lines.filter((line) => line.source !== "started");
|
|
23
23
|
/** The started lines of `lines` with no result row yet: the audits settlement still owes, oldest first. */
|
|
@@ -75,61 +75,86 @@ const isLine = (value) => {
|
|
|
75
75
|
const noVerdictOf = (line) => line.agreed !== null ? {} : line.skipped === "no allowance" ? { skipped: "no allowance" } : line.parked === true ? { parked: true } : {};
|
|
76
76
|
/** A line's turn (AuditRow.turn), as written: none when it has none. */
|
|
77
77
|
const turnOf = (line) => (line.turn === undefined ? {} : { turn: line.turn });
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
/** A ledger line as read back, or undefined for one out of shape. */
|
|
79
|
+
function lineOf(value) {
|
|
80
|
+
if (!isLine(value))
|
|
81
|
+
return undefined;
|
|
82
|
+
const { run, workflow, digest, promoted_at, at } = value;
|
|
83
|
+
return value.source === "started"
|
|
84
|
+
? { source: "started", run, shadow_run: value.shadow_run, workflow, digest, promoted_at, ...turnOf(value), at }
|
|
85
|
+
: { run, shadow_run: value.shadow_run, workflow, digest, promoted_at, source: value.source, agreed: value.agreed, served_cost: value.served_cost, shadow_cost: value.shadow_cost, ...turnOf(value), ...noVerdictOf(value), at };
|
|
86
|
+
}
|
|
87
|
+
const linesOf = (records) => records.flatMap((one) => { const line = lineOf(one.data); return line ? [line] : []; });
|
|
88
|
+
/** A line's record: its served run, so the run's purge deletes it. */
|
|
89
|
+
const lineWrite = (line) => ({ runId: line.run, workflow: line.workflow, digest: line.digest, data: line });
|
|
90
|
+
/** The agent's ledger, in the order written (none before the first line). */
|
|
91
|
+
export const ledgerOf = async (rows, agentId) => linesOf(await rows.records(agentId, "audit"));
|
|
92
|
+
/** The ledger's rows: its finished audits, oldest first. */
|
|
93
|
+
export const readAudits = async (rows, agentId) => rowsOf(await ledgerOf(rows, agentId));
|
|
94
|
+
/** A line's place in the ledger: one per served run and source (a started line's, its shadow's row, a grade's row). */
|
|
95
|
+
export const lineKey = (line) => `${line.source}:${line.run}`;
|
|
96
|
+
/** Appends `lines` to the ledger, each not there yet (lineKey), in one transaction: `replace`, a line whose key is there
|
|
97
|
+
* takes the place of the one there (a grade's row of a run graded again). The ledger after (`all`) with the lines it
|
|
98
|
+
* appended. A line of a digest no version of its workflow holds (a run's purge took it since the line was read), or of a
|
|
99
|
+
* run that was purged, is never appended (Store.learning changeRecords refuses it): the others are. */
|
|
100
|
+
export async function addAuditLines(rows, agentId, lines, replace = false) {
|
|
101
|
+
let left = lines;
|
|
102
|
+
for (let tries = 0;; tries++) {
|
|
84
103
|
try {
|
|
85
|
-
|
|
86
|
-
if (!isLine(value))
|
|
87
|
-
continue;
|
|
88
|
-
const { run, workflow, digest, promoted_at, at } = value;
|
|
89
|
-
out.push(value.source === "started"
|
|
90
|
-
? { source: "started", run, shadow_run: value.shadow_run, workflow, digest, promoted_at, ...turnOf(value), at }
|
|
91
|
-
: { run, shadow_run: value.shadow_run, workflow, digest, promoted_at, source: value.source, agreed: value.agreed, served_cost: value.served_cost, shadow_cost: value.shadow_cost, ...turnOf(value), ...noVerdictOf(value), at });
|
|
104
|
+
return await appendLines(rows, agentId, left, replace);
|
|
92
105
|
}
|
|
93
|
-
catch {
|
|
94
|
-
// A
|
|
106
|
+
catch (error) {
|
|
107
|
+
// A purged run's line, refused in the write's own transaction: the write again without it.
|
|
108
|
+
if (!(error instanceof LearningRecordRefused) || tries >= 2)
|
|
109
|
+
throw error;
|
|
110
|
+
const refused = new Set(error.records.map((one) => one.runId));
|
|
111
|
+
const kept = left.filter((line) => !refused.has(line.run));
|
|
112
|
+
if (kept.length === left.length)
|
|
113
|
+
throw error;
|
|
114
|
+
left = kept;
|
|
95
115
|
}
|
|
96
116
|
}
|
|
97
|
-
return out;
|
|
98
|
-
}
|
|
99
|
-
/** The ledger's text for `lines`: from the AUDITS_KEPT-th newest row on, and every open started line before it. */
|
|
100
|
-
export function auditsText(lines) {
|
|
101
|
-
const rows = lines.flatMap((line, i) => (line.source === "started" ? [] : [i]));
|
|
102
|
-
const from = rows.length > AUDITS_KEPT ? rows[rows.length - AUDITS_KEPT] : 0;
|
|
103
|
-
const open = new Set(openAudits(lines));
|
|
104
|
-
return lines.filter((line, i) => i >= from || open.has(line)).map((line) => JSON.stringify(line)).join("\n") + "\n";
|
|
105
117
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
function appendLines(rows, agentId, lines, replace) {
|
|
119
|
+
return rows.changeRecords(agentId, "audit", (records, held) => {
|
|
120
|
+
const keys = new Set(lines.map(lineKey));
|
|
121
|
+
const kept = records.filter((one) => { const line = lineOf(one.data); return !replace || !line || !keys.has(lineKey(line)); });
|
|
122
|
+
const before = linesOf(kept);
|
|
123
|
+
const known = new Set(before.map(lineKey));
|
|
124
|
+
const added = [];
|
|
125
|
+
for (const line of lines) {
|
|
126
|
+
if (known.has(lineKey(line)))
|
|
127
|
+
continue;
|
|
128
|
+
if (held !== undefined && !held(line.workflow, line.digest))
|
|
129
|
+
continue;
|
|
130
|
+
known.add(lineKey(line));
|
|
131
|
+
added.push(line);
|
|
132
|
+
}
|
|
133
|
+
if (!added.length && kept.length === records.length)
|
|
134
|
+
return { result: { all: before, added } };
|
|
135
|
+
const writes = trimmed([...kept.map((one) => ({ seq: one.seq, runId: one.runId, workflow: one.workflow, digest: one.digest, data: one.data })), ...added.map(lineWrite)]);
|
|
136
|
+
return { records: writes, result: { all: linesOf(writes), added } };
|
|
137
|
+
});
|
|
110
138
|
}
|
|
111
|
-
/** The ledger's
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const added = [];
|
|
120
|
-
for (const line of lines) {
|
|
121
|
-
if (known.has(lineKey(line)))
|
|
122
|
-
continue;
|
|
123
|
-
known.add(lineKey(line));
|
|
124
|
-
added.push(line);
|
|
125
|
-
}
|
|
126
|
-
const rows = rowsOf(added).length;
|
|
127
|
-
const said = rows ? `${rows} audit row${rows === 1 ? "" : "s"}` : `${added.length} audit${added.length === 1 ? "" : "s"} started`;
|
|
128
|
-
return added.length ? { added, change: { by: { host: said }, writes: [{ path: AUDITS_FILE, text: auditsText([...before, ...added]) }] } } : { added };
|
|
139
|
+
/** The ledger's records from the AUDITS_KEPT-th newest row on, and every open started line before it (main's folder
|
|
140
|
+
* ledger kept the same): so it never grows past its cap. */
|
|
141
|
+
function trimmed(writes) {
|
|
142
|
+
const lines = writes.map((one) => lineOf(one.data));
|
|
143
|
+
const rows = lines.flatMap((line, i) => (line && line.source !== "started" ? [i] : []));
|
|
144
|
+
const from = rows.length > AUDITS_KEPT ? rows[rows.length - AUDITS_KEPT] : 0;
|
|
145
|
+
const open = new Set(openAudits(lines.filter((line) => line !== undefined)));
|
|
146
|
+
return writes.filter((_, i) => i >= from || (lines[i] !== undefined && open.has(lines[i])));
|
|
129
147
|
}
|
|
130
148
|
/** The rows the hold rule counts for `workflow` at `digest` under the promotion begun at `promotedAt` (learn/promote.ts
|
|
131
|
-
* promotionStartOf; none counted for null): those with a verdict, the newest `hold_window` of them.
|
|
132
|
-
|
|
149
|
+
* promotionStartOf; none counted for null): those with a verdict, the newest `hold_window` of them. A served run an
|
|
150
|
+
* owner graded is counted by its grade's row alone: the grade is its known answer, as it is the check's, so its
|
|
151
|
+
* shadow (the agent's answer again) never says otherwise, and a grade that contradicts itself leaves it unjudged. */
|
|
152
|
+
export function windowOf(rows, workflow, digest, promotedAt, loop) {
|
|
153
|
+
if (promotedAt === null)
|
|
154
|
+
return [];
|
|
155
|
+
const graded = new Set(rows.filter((row) => row.source === "grade").map((row) => row.run));
|
|
156
|
+
return rows.filter((row) => row.workflow === workflow && row.digest === digest && row.promoted_at === promotedAt && row.agreed !== null && (row.source === "grade" || !graded.has(row.run))).slice(-loop.hold_window);
|
|
157
|
+
}
|
|
133
158
|
/** The hold rule: the counted rows (windowOf) when at least `hold_disagree` of them disagree, else undefined. */
|
|
134
159
|
export function holdOf(rows, workflow, digest, promotedAt, loop) {
|
|
135
160
|
const counted = windowOf(rows, workflow, digest, promotedAt, loop);
|
|
@@ -140,14 +165,14 @@ export function auditLineOf(rows, workflow, digest, promotedAt, loop) {
|
|
|
140
165
|
const counted = windowOf(rows, workflow, digest, promotedAt, loop);
|
|
141
166
|
return { window: loop.hold_window, disagree: loop.hold_disagree, rows: counted.length, disagreed: counted.filter((row) => row.agreed === false).length };
|
|
142
167
|
}
|
|
143
|
-
export function servingLinesOf(records, rows, loop, costStop
|
|
144
|
-
return servingOf(records
|
|
168
|
+
export function servingLinesOf(records, rows, loop, costStop) {
|
|
169
|
+
return servingOf(records).map(({ workflow, digest }) => {
|
|
145
170
|
const own = records.filter((one) => one.workflow === workflow);
|
|
146
171
|
const newest = own.at(-1);
|
|
147
172
|
const checked = own.findLast((one) => one.check?.n !== undefined)?.check;
|
|
148
173
|
const at = digest ?? newest?.digest;
|
|
149
174
|
return {
|
|
150
|
-
state: servingStateOf(records, workflow, costStop
|
|
175
|
+
state: servingStateOf(records, workflow, costStop),
|
|
151
176
|
check: checked ? { n: checked.n, agreed: checked.agreed ?? 0, alone: checked.alone ?? 0, attempt: checked.attempt } : null,
|
|
152
177
|
audit: at === undefined ? null : auditLineOf(rows, workflow, at, promotionStartOf(records, workflow, at)?.at ?? null, loop),
|
|
153
178
|
};
|
package/dist/learn/check.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The checker of a workflow draft a run's compile turn gives its agent's learning
|
|
1
|
+
// The checker of a workflow draft a run's compile turn gives its agent's learning (SPEC.md): its workflow.json and
|
|
2
2
|
// README.md, each a change against what the folder holds. Structure only, and what must never be stored; nothing the
|
|
3
3
|
// checker refuses is ever written to git. Every problem it reports is printable: its path and detail are cut of the
|
|
4
4
|
// host's secrets and of text shaped like one, and a field over PRINT_MAX is redacted whole.
|