@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/secrets.d.ts
CHANGED
|
@@ -12,10 +12,6 @@ export declare const MCP_AUTH = "AGENTRUN_MCP_AUTH";
|
|
|
12
12
|
/** The decision keys among them: a run's process gets them only on its decision descriptor (decisions.ts), never with
|
|
13
13
|
* the secrets on its pipe, which are its tools' environment. */
|
|
14
14
|
export declare const DECISION_KEYS: readonly string[];
|
|
15
|
-
/** The runner's OpenTelemetry settings (its OTEL_* variables, JSON), handed to a run's process on the same pipe so the
|
|
16
|
-
* run's trace is exported as the runner's would be: never in any environment (an OTLP header is a backend's key), held
|
|
17
|
-
* apart from the secrets, so no tool's environment has them. Read by otel/tracer.ts (handedOtel). */
|
|
18
|
-
export declare const OTEL_PAIR = "AGENTRUN_OTEL";
|
|
19
15
|
/** NAME=VALUE pairs, each ended by a NUL: what a pipe of secrets carries. A runner writes a run's own process its pairs
|
|
20
16
|
* with it (run-child-host.ts), as a launcher writes its server's. */
|
|
21
17
|
export declare const encode: (pairs: Iterable<readonly [string, string]>) => Buffer;
|
|
@@ -27,8 +23,9 @@ export type StoredKeys = (name: string) => string | undefined;
|
|
|
27
23
|
/** This host's secrets, for a scan of what a run wrote: each one the launcher lists, as this process holds it (never in
|
|
28
24
|
* the environment once handed over, so a scan of process.env alone sees none of them), and beside it the key a person
|
|
29
25
|
* saved under that name on the server `stored` reads for (a run that names its tool is handed it), and the value of
|
|
30
|
-
* every other key, token, secret or password `env` names
|
|
31
|
-
* whitespace aside, matches too much text by chance to be
|
|
26
|
+
* every other key, token, secret or password `env` names, and each OTLP header value and endpoint credential
|
|
27
|
+
* (keptSecrets). One shorter than the checker's MIN_SECRET, whitespace aside, matches too much text by chance to be
|
|
28
|
+
* refused, and is left out, an OTLP header value's too. */
|
|
32
29
|
export declare const hostSecrets: (env: NodeJS.ProcessEnv, stored?: StoredKeys) => string[];
|
|
33
30
|
/** Lists `text` among this process's seal keys, for redaction alone, until the returned release is called. */
|
|
34
31
|
export declare function holdSealKey(text: string): () => void;
|
|
@@ -46,6 +43,10 @@ export declare const secret: (name: string, stored?: StoredKeys) => string | und
|
|
|
46
43
|
* the object, or a spawn given it (Node builds a child's environment from its enumerable keys), leaves it out. Which
|
|
47
44
|
* came from a saved key is said too (savedIn), never a value. */
|
|
48
45
|
export declare const withSecrets: (env: NodeJS.ProcessEnv, which?: "all" | "own", stored?: StoredKeys) => NodeJS.ProcessEnv;
|
|
46
|
+
/** A copy of `env` (one withSecrets made) with every own property as it is: each secret still read by name and never
|
|
47
|
+
* enumerated, savedIn still saying which were saved, and its symbols. A spread keeps none of the secrets, so a copy
|
|
48
|
+
* that is read for a key is made with this (env-copy.test.mjs scans for spreads). */
|
|
49
|
+
export declare const copyEnv: <T extends object>(env: T) => T;
|
|
49
50
|
/** The secrets of `env` (one withSecrets made) that were saved on the server, not its own, by name. */
|
|
50
51
|
export declare const savedIn: (env: NodeJS.ProcessEnv) => ReadonlySet<string>;
|
|
51
52
|
/** The environment a child gets: `env` with every secret name taken out, and every other name shaped like a key
|
|
@@ -57,15 +58,60 @@ export declare const withoutSecrets: (env: NodeJS.ProcessEnv) => NodeJS.ProcessE
|
|
|
57
58
|
/** What a run's process is handed: the secrets named `names` that this process holds, or its server saved (`stored`),
|
|
58
59
|
* as its pipe carries them. */
|
|
59
60
|
export declare function handover(names: readonly string[], stored?: StoredKeys): Buffer;
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
export declare function
|
|
61
|
+
/** A `key=value,key=value` list (OTEL_EXPORTER_OTLP_HEADERS, OTEL_RESOURCE_ATTRIBUTES), each part percent-decoded; a
|
|
62
|
+
* part that is not one is skipped. */
|
|
63
|
+
export declare function keyValues(text: string | undefined): Record<string, string>;
|
|
63
64
|
/** The MCP credentials this process was handed (MCP_AUTH), by server; none when it was handed none. */
|
|
64
65
|
export declare function mcpCredentials(): Record<string, {
|
|
65
66
|
url: string;
|
|
66
67
|
headers?: Record<string, string>;
|
|
67
68
|
unopened?: string;
|
|
68
69
|
}>;
|
|
70
|
+
/** The OTLP header names whose value is not held (otlpHeaderValues), matched in any case: the standard headers that say
|
|
71
|
+
* how a body is sent, which carry no key. Every other header's value is held, an unknown name's too: a name not on this
|
|
72
|
+
* list never means its value is safe. */
|
|
73
|
+
export declare const OTLP_PLAIN_HEADERS: readonly string[];
|
|
74
|
+
/** The OTLP header names whose value is on no held list but is cut from the tracer's own lines (otlpHeaderCut), matched
|
|
75
|
+
* in any case: a backend's dataset or tenant, which says where spans go and carries no key. Such a value is often a
|
|
76
|
+
* word like `production`, which a held list would find in nearly every project a source capture reads and in served
|
|
77
|
+
* text. Only the names here: an unknown name's value is still held. */
|
|
78
|
+
export declare const OTLP_CUT_ONLY_HEADERS: readonly string[];
|
|
79
|
+
/** The OTLP exporter's header values `env` names (OTEL_EXPORTER_OTLP_HEADERS and OTEL_EXPORTER_OTLP_TRACES_HEADERS: a
|
|
80
|
+
* tracing backend's key is one), at any length (keptSecrets floors them for the held list; otlpHeaderCut does not),
|
|
81
|
+
* but those of a header OTLP_PLAIN_HEADERS names, and, for the held list (`held`), those OTLP_CUT_ONLY_HEADERS names.
|
|
82
|
+
* Each is held as written (percent-encoded) and as sent (decoded); and as the SDK reads the same variable, which it
|
|
83
|
+
* merges under ours (`headers`, tracer.ts exporterConfig) and which drops a `;` and what follows it, so a part ours
|
|
84
|
+
* can't decode still sends that much; and, under a credential-named header (credentialNamed) or after a known auth
|
|
85
|
+
* scheme (KNOWN_SCHEME), each of those without its first word (AUTH_SCHEME), the credential alone, as an error may
|
|
86
|
+
* quote it. For the held list, any other header's value is held whole, never its tail alone; for the cut (`held`
|
|
87
|
+
* false), every value is taken without any first word too, since cutting more of the tracer's own lines costs
|
|
88
|
+
* nothing. Under any header, each credential a value carries inside it (innerCredentials: a credential-named
|
|
89
|
+
* `name=value` pair's value, a URL's user, password and key parameters) is taken alone too. A part whose name can't
|
|
90
|
+
* be decoded is held. Commas split the variable, so a comma inside a value must be written `%2C`. */
|
|
91
|
+
export declare const otlpHeaderValues: (env: NodeJS.ProcessEnv, held: boolean) => string[];
|
|
92
|
+
/** The credentials the OTLP endpoints `env` names write into their URLs (OTEL_EXPORTER_OTLP_ENDPOINT and
|
|
93
|
+
* OTEL_EXPORTER_OTLP_TRACES_ENDPOINT; urlCredentials): a user and password, and the value of each query parameter
|
|
94
|
+
* whose name says it is one, each as written and decoded. An exporter's error may quote the URL it posted to. */
|
|
95
|
+
export declare const otlpEndpointValues: (env: NodeJS.ProcessEnv) => string[];
|
|
96
|
+
/** `values` and every OTLP credential `env` names (otlpValues: its header values but a cut-only header's, its
|
|
97
|
+
* endpoints' user, password and key parameters) as the held list keeps them: each MIN_SECRET long or more, whitespace
|
|
98
|
+
* aside. A shorter one matches too much text by chance to be held, and some readers of the list have no floor of their
|
|
99
|
+
* own (a number equal to a held value is withheld, key-refusal.ts heldNumber; a source capture refuses a path or file
|
|
100
|
+
* holding one), so a short header value is on no held list, nor is a dataset's or tenant's (OTLP_CUT_ONLY_HEADERS):
|
|
101
|
+
* otlpHeaderCut alone cuts it, from the tracer's own lines. */
|
|
102
|
+
export declare const keptSecrets: (values: readonly string[], env: NodeJS.ProcessEnv) => string[];
|
|
103
|
+
/** Text with every OTLP credential `env` names (otlpValues: its header values, a cut-only header's too, its endpoints'
|
|
104
|
+
* user, password and key parameters) put as "[redacted]", at any length: the one cut without the MIN_SECRET floor.
|
|
105
|
+
* The tracer's own lines take it, after the runner's redactor (otel/tracer.ts saidOf), since they are where one can
|
|
106
|
+
* show: an exporter's error may quote a header it sent or the URL it posted to, and a run's process never holds one.
|
|
107
|
+
* Every other cut keeps the floor on purpose: a needle of a few characters in every redactor would cut ordinary text
|
|
108
|
+
* everywhere. Each value is matched exactly as held, and the cut is the union of every place each one stands: at each
|
|
109
|
+
* character, the longest value (or a "[redacted]" already in the text) starting there is found without being taken,
|
|
110
|
+
* so a value starting inside another is found too, and the places, which come in order, are merged where they overlap
|
|
111
|
+
* or touch and each run cut as one "[redacted]". So no character of any held value is left, whichever of two
|
|
112
|
+
* overlapping values starts first or is longer (the SDK's reading `api_key=<key>` and a key `<key;rest>` quoted as
|
|
113
|
+
* `api_key=<key;rest>`), and a "[redacted]" already in the text is left whole. One pass over the text, one merge. */
|
|
114
|
+
export declare function otlpHeaderCut(env: NodeJS.ProcessEnv): (text: string) => string;
|
|
69
115
|
/** Every header value of `credentials`: what a secret scan refuses. */
|
|
70
116
|
export declare const mcpSecretValues: (credentials: Record<string, {
|
|
71
117
|
headers?: Record<string, string>;
|
package/dist/secrets.js
CHANGED
|
@@ -39,11 +39,6 @@ let handed;
|
|
|
39
39
|
* the secrets, so it is no tool's environment and no key a scan looks for by name. */
|
|
40
40
|
const SIGN_IN_PAIR = "AGENTRUN_SIGN_IN";
|
|
41
41
|
let signIn;
|
|
42
|
-
/** The runner's OpenTelemetry settings (its OTEL_* variables, JSON), handed to a run's process on the same pipe so the
|
|
43
|
-
* run's trace is exported as the runner's would be: never in any environment (an OTLP header is a backend's key), held
|
|
44
|
-
* apart from the secrets, so no tool's environment has them. Read by otel/tracer.ts (handedOtel). */
|
|
45
|
-
export const OTEL_PAIR = "AGENTRUN_OTEL";
|
|
46
|
-
let otel;
|
|
47
42
|
/** NAME=VALUE pairs, each ended by a NUL: what a pipe of secrets carries. A runner writes a run's own process its pairs
|
|
48
43
|
* with it (run-child-host.ts), as a launcher writes its server's. */
|
|
49
44
|
export const encode = (pairs) => Buffer.concat([...pairs].map(([name, value]) => Buffer.from(`${name}=${value}\0`)));
|
|
@@ -54,8 +49,6 @@ function decode(bytes) {
|
|
|
54
49
|
held.set(pair.slice(0, at), pair.slice(at + 1));
|
|
55
50
|
else if (pair.slice(0, at) === SIGN_IN_PAIR)
|
|
56
51
|
signIn = pair.slice(at + 1);
|
|
57
|
-
else if (pair.slice(0, at) === OTEL_PAIR)
|
|
58
|
-
otel = pair.slice(at + 1);
|
|
59
52
|
}
|
|
60
53
|
}
|
|
61
54
|
/** Exactly `length` bytes of `fd`, read as the launcher's writer writes them: the end of file before then is a writer
|
|
@@ -112,13 +105,14 @@ const SECRET_NAME = /(?:^|_)(?:KEY|TOKEN|SECRET|PASSWORD)$/i;
|
|
|
112
105
|
/** This host's secrets, for a scan of what a run wrote: each one the launcher lists, as this process holds it (never in
|
|
113
106
|
* the environment once handed over, so a scan of process.env alone sees none of them), and beside it the key a person
|
|
114
107
|
* saved under that name on the server `stored` reads for (a run that names its tool is handed it), and the value of
|
|
115
|
-
* every other key, token, secret or password `env` names
|
|
116
|
-
* whitespace aside, matches too much text by chance to be
|
|
108
|
+
* every other key, token, secret or password `env` names, and each OTLP header value and endpoint credential
|
|
109
|
+
* (keptSecrets). One shorter than the checker's MIN_SECRET, whitespace aside, matches too much text by chance to be
|
|
110
|
+
* refused, and is left out, an OTLP header value's too. */
|
|
117
111
|
export const hostSecrets = (env, stored) => {
|
|
118
112
|
// AGENTRUN_TOKENS's each secret too, not only the list whole (api-token.ts secretValues).
|
|
119
113
|
const held = [...SECRET_NAMES.flatMap((name) => [...secretValues(name, secret(name) ?? ""), stored?.(name) ?? ""]), ...mcpSecretValues(mcpCredentials()), ...sealKeys.keys(), ...heldTokens];
|
|
120
114
|
const named = Object.entries(env).filter(([name]) => SECRET_NAME.test(name) && !SECRET_NAMES.includes(name)).map(([, value]) => value ?? "");
|
|
121
|
-
return
|
|
115
|
+
return keptSecrets([...held, ...named], env);
|
|
122
116
|
};
|
|
123
117
|
/** The seal keys this process's open stores were booted with (seal-key.ts bootSealKey), by how many hold each: several
|
|
124
118
|
* data directories in one process each keep their own. Never read as a secret by name (each holder passes its own key
|
|
@@ -188,6 +182,10 @@ export const withSecrets = (env, which = "all", stored) => {
|
|
|
188
182
|
Object.defineProperty(out, SAVED, { value: saved, enumerable: false });
|
|
189
183
|
return out;
|
|
190
184
|
};
|
|
185
|
+
/** A copy of `env` (one withSecrets made) with every own property as it is: each secret still read by name and never
|
|
186
|
+
* enumerated, savedIn still saying which were saved, and its symbols. A spread keeps none of the secrets, so a copy
|
|
187
|
+
* that is read for a key is made with this (env-copy.test.mjs scans for spreads). */
|
|
188
|
+
export const copyEnv = (env) => Object.create(Object.getPrototypeOf(env), Object.getOwnPropertyDescriptors(env));
|
|
191
189
|
/** The secrets of `env` (one withSecrets made) that were saved on the server, not its own, by name. */
|
|
192
190
|
export const savedIn = (env) => env[SAVED] ?? new Set();
|
|
193
191
|
/** The environment a child gets: `env` with every secret name taken out, and every other name shaped like a key
|
|
@@ -204,18 +202,24 @@ export function handover(names, stored) {
|
|
|
204
202
|
return value === undefined ? [] : [[name, value]];
|
|
205
203
|
}));
|
|
206
204
|
}
|
|
207
|
-
/**
|
|
208
|
-
*
|
|
209
|
-
export function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
205
|
+
/** A `key=value,key=value` list (OTEL_EXPORTER_OTLP_HEADERS, OTEL_RESOURCE_ATTRIBUTES), each part percent-decoded; a
|
|
206
|
+
* part that is not one is skipped. */
|
|
207
|
+
export function keyValues(text) {
|
|
208
|
+
const out = {};
|
|
209
|
+
for (const part of (text ?? "").split(",")) {
|
|
210
|
+
const at = part.indexOf("=");
|
|
211
|
+
if (at <= 0)
|
|
212
|
+
continue;
|
|
213
|
+
try {
|
|
214
|
+
const key = decodeURIComponent(part.slice(0, at).trim());
|
|
215
|
+
if (key)
|
|
216
|
+
out[key] = decodeURIComponent(part.slice(at + 1).trim());
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
218
221
|
}
|
|
222
|
+
return out;
|
|
219
223
|
}
|
|
220
224
|
/** The MCP credentials this process was handed (MCP_AUTH), by server; none when it was handed none. */
|
|
221
225
|
export function mcpCredentials() {
|
|
@@ -227,6 +231,326 @@ export function mcpCredentials() {
|
|
|
227
231
|
return {};
|
|
228
232
|
}
|
|
229
233
|
}
|
|
234
|
+
/** The OTLP header names whose value is not held (otlpHeaderValues), matched in any case: the standard headers that say
|
|
235
|
+
* how a body is sent, which carry no key. Every other header's value is held, an unknown name's too: a name not on this
|
|
236
|
+
* list never means its value is safe. */
|
|
237
|
+
export const OTLP_PLAIN_HEADERS = ["content-type", "accept", "content-encoding", "user-agent"];
|
|
238
|
+
/** `text` percent-decoded, or undefined when it can't be. */
|
|
239
|
+
const decoded = (text) => {
|
|
240
|
+
try {
|
|
241
|
+
return decodeURIComponent(text);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
/** The OTLP header names whose value is on no held list but is cut from the tracer's own lines (otlpHeaderCut), matched
|
|
248
|
+
* in any case: a backend's dataset or tenant, which says where spans go and carries no key. Such a value is often a
|
|
249
|
+
* word like `production`, which a held list would find in nearly every project a source capture reads and in served
|
|
250
|
+
* text. Only the names here: an unknown name's value is still held. */
|
|
251
|
+
export const OTLP_CUT_ONLY_HEADERS = ["x-honeycomb-dataset", "x-axiom-dataset", "x-scope-orgid"];
|
|
252
|
+
/** An auth scheme before its credential, as a header writes it (`Bearer <token>`, `Basic <base64>`, `Api-Key <key>`,
|
|
253
|
+
* `sentry sentry_key=<key>`): a token, then a space or its `%20`. */
|
|
254
|
+
const AUTH_SCHEME = /^[A-Za-z][\w.+-]*(?:\s+|%20)/;
|
|
255
|
+
/** The auth schemes a backend's header writes before its credential, in any case, under any header name. */
|
|
256
|
+
const KNOWN_SCHEME = /^(?:bearer|basic|api-?key|api-?token|token|sentry|splunk|geniekey)(?:\s+|%20)/i;
|
|
257
|
+
/** Whether a header's or an endpoint's query parameter's name says its value is a credential (`authorization`,
|
|
258
|
+
* `x-sentry-auth`, `x-api-key`, `access_token`, `apiKey2`, `X-Amz-Signature`, `sessionid`): a name is split at each
|
|
259
|
+
* non-alphanumeric and at each lower-to-upper case change, a word's trailing digits are dropped (`key2` is `key`), and
|
|
260
|
+
* a word counts when it is one of CREDENTIAL_WORDS, ends in one of CREDENTIAL_ENDINGS (`accesstoken`, `dbpasswd`,
|
|
261
|
+
* `writekey`, `hmackey`), or starts with one of CREDENTIAL_STARTS and is more than its plural (`tokenvalue`,
|
|
262
|
+
* `passwordhash`; never `tokens`). `auth`, `key`, `sig` and `session` start no compound, so a word that only starts like
|
|
263
|
+
* one says nothing (`authority`, `keyspace`, `sessions`). */
|
|
264
|
+
const CREDENTIAL_WORDS = new Set(["authorization", "auth", "key", "apikey", "token", "secret", "password", "passwd", "pwd", "sig", "signature", "credential", "credentials", "jwt", "session"]);
|
|
265
|
+
const CREDENTIAL_ENDINGS = ["key", "token", "secret", "password", "passwd", "pwd", "auth", "authorization", "sig", "signature", "credential", "credentials", "jwt", "sessionid"];
|
|
266
|
+
const CREDENTIAL_STARTS = ["token", "secret", "password", "passwd", "jwt"];
|
|
267
|
+
const credentialWord = (word) => {
|
|
268
|
+
const bare = word.replace(/\d+$/, "");
|
|
269
|
+
return CREDENTIAL_WORDS.has(bare)
|
|
270
|
+
|| CREDENTIAL_ENDINGS.some((ending) => bare.endsWith(ending))
|
|
271
|
+
|| CREDENTIAL_STARTS.some((start) => bare.startsWith(start) && bare.length > start.length + 1);
|
|
272
|
+
};
|
|
273
|
+
const credentialNamed = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(credentialWord);
|
|
274
|
+
/** Where a URL starts: a scheme, then `://`; or `//` alone (a scheme-relative URL, `//<key>@host`) at the start of the
|
|
275
|
+
* text or after a space, a quote, `=`, `(`, `,`, `;` or `&`, never inside a path (`/a//b`). A scheme is read at most 32
|
|
276
|
+
* characters long, so a long word with no `://` after it costs one short look from each of its letters. */
|
|
277
|
+
const URL_START = /[A-Za-z][\w+.-]{0,31}:\/\/|(?<=^|[\s"'=(,;&])\/\//;
|
|
278
|
+
const URL_HEAD = /(?:[A-Za-z][\w+.-]{0,31}:)?\/\//y;
|
|
279
|
+
/** How many readings of one URL's userinfo urlParts takes at most, and how many characters its shorter readings (all
|
|
280
|
+
* but the RFC's and the first `@`'s) take together at most: a value can hold thousands of `@`, and a reading at each
|
|
281
|
+
* would hold, and the [otel] cut compile into one pattern, their count times the value's length. */
|
|
282
|
+
const MAX_READINGS = 16;
|
|
283
|
+
const READINGS_BUDGET = 4096;
|
|
284
|
+
/** How many characters of URL queries one header value's read (innerCredentials) takes after the first query it reads:
|
|
285
|
+
* a value of URLs nested each in the last's query gives each a query running to the value's end, and reading every one
|
|
286
|
+
* would hold their count times the value's length. The pair read (pairValues) still covers every query's text. */
|
|
287
|
+
const QUERY_BUDGET = 4096;
|
|
288
|
+
/** A URL as RFC 3986 reads it, `text` from `start` (its scheme, or the `//` of a scheme-relative one) to `end`: its
|
|
289
|
+
* authority, up to the first `/`, `?` or `#`; the readings of its userinfo, the RFC's first (everything before the
|
|
290
|
+
* authority's last `@`, so a password's `;`, `&`, `=`, `,`, `'` or raw `@` stays in it), then, when the authority holds
|
|
291
|
+
* more than one `@`, the one up to its first `@` and the next shorter ones, up to MAX_READINGS in all and
|
|
292
|
+
* READINGS_BUDGET characters for those after the first two (a URL with no closing mark, followed by a pair holding an
|
|
293
|
+
* `@`, `...@relay.invalid&contact=ops@team`, reads too long a userinfo, and a redactor holding an extra candidate is
|
|
294
|
+
* safe where missing one leaks); and where its query is, from the first `?` to a `#`. Read in place, never copied to
|
|
295
|
+
* `end`: a value of thousands of URLs one inside the next costs each only its authority. Undefined when no URL starts
|
|
296
|
+
* at `start`. */
|
|
297
|
+
const urlParts = (text, start, end) => {
|
|
298
|
+
URL_HEAD.lastIndex = start;
|
|
299
|
+
if (!URL_HEAD.test(text))
|
|
300
|
+
return undefined;
|
|
301
|
+
const from = URL_HEAD.lastIndex;
|
|
302
|
+
let stop = from;
|
|
303
|
+
while (stop < end && !"/?#".includes(text[stop]))
|
|
304
|
+
stop++;
|
|
305
|
+
const authority = text.slice(from, stop);
|
|
306
|
+
const ats = [...authority.matchAll(/@/g)].map((at) => at.index);
|
|
307
|
+
const kept = ats.length > 1 ? [ats[ats.length - 1], ats[0]] : ats;
|
|
308
|
+
let budget = READINGS_BUDGET;
|
|
309
|
+
for (let next = 1; next < ats.length - 1 && kept.length < MAX_READINGS && ats[next] <= budget; next++) {
|
|
310
|
+
budget -= ats[next];
|
|
311
|
+
kept.push(ats[next]);
|
|
312
|
+
}
|
|
313
|
+
const mark = text.indexOf("?", stop);
|
|
314
|
+
const hash = text.indexOf("#", stop);
|
|
315
|
+
const query = mark >= 0 && mark < end && (hash < 0 || hash > mark) ? [mark + 1, hash >= 0 && hash < end ? hash : end] : [0, 0];
|
|
316
|
+
return { readings: kept.map((at) => authority.slice(0, at)), query };
|
|
317
|
+
};
|
|
318
|
+
/** A user or password as a URL parser writes it back (a client's error may quote the URL it parsed): `;`, `=`, `@`, `:`
|
|
319
|
+
* and the like percent-encoded. */
|
|
320
|
+
const asParsed = (part) => {
|
|
321
|
+
const url = new URL("http://host.invalid");
|
|
322
|
+
url.password = part;
|
|
323
|
+
return url.password;
|
|
324
|
+
};
|
|
325
|
+
/** The credentials a URL writes into itself (`text` from `start` to `end`, urlParts): the user and password of its
|
|
326
|
+
* userinfo (before its first `:` and after it), each as written, decoded and as a parser writes it back, the RFC's
|
|
327
|
+
* reading at any length and each shorter reading's only at MIN_SECRET or more (so a short piece of a password, `pa` of
|
|
328
|
+
* `pa@ss...`, cuts no ordinary word), and the value of each query parameter whose name says it is one
|
|
329
|
+
* (credentialNamed), the query split at `&` alone and again at `&` and `;`, as written and decoded; none when no URL
|
|
330
|
+
* starts at `start`. A query already in `queriesRead` (several URLs nested in one share it) is not read again, and
|
|
331
|
+
* after the first one read, one is read only while QUERY_BUDGET has room for all of it. */
|
|
332
|
+
const urlCredentials = (text, start = 0, end = text.length, queriesRead = { spans: new Set(), left: QUERY_BUDGET }) => {
|
|
333
|
+
const url = urlParts(text, start, end);
|
|
334
|
+
if (!url)
|
|
335
|
+
return [];
|
|
336
|
+
const userinfo = url.readings.flatMap((reading, at) => {
|
|
337
|
+
const colon = reading.indexOf(":");
|
|
338
|
+
const parts = (colon < 0 ? [reading] : [reading.slice(0, colon), reading.slice(colon + 1)]).flatMap((part) => [part, decoded(part) ?? part, asParsed(part)]);
|
|
339
|
+
return at === 0 ? parts : parts.filter((part) => part.replace(/\s+/g, "").length >= MIN_SECRET);
|
|
340
|
+
});
|
|
341
|
+
const [from, to] = url.query;
|
|
342
|
+
const span = `${from} ${to}`;
|
|
343
|
+
if (from === to || queriesRead.spans.has(span))
|
|
344
|
+
return userinfo;
|
|
345
|
+
if (queriesRead.spans.size > 0) {
|
|
346
|
+
if (to - from > queriesRead.left)
|
|
347
|
+
return userinfo;
|
|
348
|
+
queriesRead.left -= to - from;
|
|
349
|
+
}
|
|
350
|
+
queriesRead.spans.add(span);
|
|
351
|
+
// Read split at `&` alone (a WHATWG parser's reading, a value's raw `;` kept), and each `&` piece holding a `;` split
|
|
352
|
+
// at it too (a path parameter's or a cookie's reading): both, so a key with a `;` in it is held whole and a pair after
|
|
353
|
+
// a `;` alone. A query writes a space as `+`; a user and password do not.
|
|
354
|
+
const pieces = text.slice(from, to).split("&");
|
|
355
|
+
const query = [...pieces, ...pieces.filter((piece) => piece.includes(";")).flatMap((piece) => piece.split(";"))].flatMap((pair) => {
|
|
356
|
+
const at = pair.indexOf("=");
|
|
357
|
+
const name = pair.slice(0, Math.max(at, 0)).replace(/\+/g, " ");
|
|
358
|
+
const value = pair.slice(at + 1);
|
|
359
|
+
return at > 0 && credentialNamed(decoded(name) ?? name) ? [value, decoded(value.replace(/\+/g, " ")) ?? value] : [];
|
|
360
|
+
});
|
|
361
|
+
return [...userinfo, ...query];
|
|
362
|
+
};
|
|
363
|
+
/** Each URL inside a header value (a DSN, a relay's address) as the spans of text it takes, one starting at every
|
|
364
|
+
* `scheme://` (URL_START), so a URL inside another's query or path is read too: from its scheme to the quote that
|
|
365
|
+
* closes it when a `'` or `"` opens it (comes right before its scheme and is closed later), else to the first space or
|
|
366
|
+
* quote, and, when that is a quote, also on to the first space (RFC 3986 allows a raw `'` in a userinfo, so both
|
|
367
|
+
* readings are taken). Read inside a span alone (urlParts), a quoted URL's userinfo never runs past its closing quote to
|
|
368
|
+
* a later `@`, and an unquoted one's runs past any `;`, `&`, `=` or `,`. */
|
|
369
|
+
const urlSpans = (value) => {
|
|
370
|
+
const spans = [];
|
|
371
|
+
const start = new RegExp(URL_START.source, "g");
|
|
372
|
+
// The first match of `mark` at or after an index, found once for every index from the last one asked up to it: URLs
|
|
373
|
+
// nested one in the next share their end, and a search from each would read the rest of the value again.
|
|
374
|
+
const nextOf = (mark) => {
|
|
375
|
+
let asked = -1;
|
|
376
|
+
let found = -1;
|
|
377
|
+
return (from) => {
|
|
378
|
+
if (from < asked || from > found) {
|
|
379
|
+
mark.lastIndex = from;
|
|
380
|
+
found = mark.exec(value)?.index ?? value.length;
|
|
381
|
+
}
|
|
382
|
+
asked = from;
|
|
383
|
+
return found;
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
const nextStop = nextOf(/[\s'"]|$/g);
|
|
387
|
+
const nextSpace = nextOf(/\s|$/g);
|
|
388
|
+
for (let found = start.exec(value); found; found = start.exec(value)) {
|
|
389
|
+
const open = value[found.index - 1];
|
|
390
|
+
const from = found.index + found[0].length;
|
|
391
|
+
const closing = open === "'" || open === '"' ? value.indexOf(open, from) : -1;
|
|
392
|
+
if (closing >= 0) {
|
|
393
|
+
spans.push({ start: found.index, end: closing });
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const end = nextStop(from);
|
|
397
|
+
spans.push({ start: found.index, end });
|
|
398
|
+
if (value[end] === "'" || value[end] === '"')
|
|
399
|
+
spans.push({ start: found.index, end: nextSpace(end) });
|
|
400
|
+
}
|
|
401
|
+
return spans;
|
|
402
|
+
};
|
|
403
|
+
/** The breaks between a header value's `name=value` pairs: `;`, `&`, a comma (or its `%2C`) and spaces; and, for a
|
|
404
|
+
* second, finer read, also `?`, `#` and `/`, so a pair inside a URL that is itself a pair's value
|
|
405
|
+
* (`upstream=https://relay/v1#access_token=<token>`) or a path's segment stands alone; and three whole reads, which keep
|
|
406
|
+
* a raw `;` in a value: all but `;` (LIST_BREAK), so a credential with a `;` in a list joined by `%2C`, the usual way to
|
|
407
|
+
* write one (`api_key=<key;rest>%2Cregion=us`), is held as itself, and `&` and spaces alone (WHOLE_BREAK), so one with
|
|
408
|
+
* a comma in it too (`api_key=<key;rest%2Cmore>®ion=us`) is held whole, and again at their `%26` and `%20`
|
|
409
|
+
* (ENCODED_BREAK), so that key before an encoded `&` or space is held as written too, not only decoded, and again at
|
|
410
|
+
* `%26` alone (ENCODED_AMP_BREAK), so a key with a `%20` in it before a `%26` is held, as written and decoded; a text
|
|
411
|
+
* with neither (ENCODED_SEEN) splits at both as at WHOLE_BREAK, so those reads are skipped for it. All are held:
|
|
412
|
+
* every redactor matches a held value exactly, so the longer reading of any never covers a line quoting the key alone.
|
|
413
|
+
* WHOLE_BREAK also holds a value with the comma that ends it (sentry's `sentry_key=<key>%2C`); the others hold the value
|
|
414
|
+
* alone. */
|
|
415
|
+
const PAIR_BREAK = /[;&,\s]+|%2C/i;
|
|
416
|
+
const PIECE_BREAK = /[;&,\s?#/]+|%2C/i;
|
|
417
|
+
const LIST_BREAK = /[&,\s]+|%2C/i;
|
|
418
|
+
const WHOLE_BREAK = /[&\s]+/;
|
|
419
|
+
const ENCODED_BREAK = /[&\s]+|%26|%20/i;
|
|
420
|
+
const ENCODED_AMP_BREAK = /[&\s]+|%26/i;
|
|
421
|
+
const ENCODED_SEEN = /%26|%20/i;
|
|
422
|
+
/** What a credential's value whose part before its first `;` is empty (`;<key>`) holds after that `;`, whole and up to
|
|
423
|
+
* its next `;`, as a reader that skips an empty part reads it; nothing for any other value. */
|
|
424
|
+
const afterEmpty = (value) => {
|
|
425
|
+
if (!value.startsWith(";"))
|
|
426
|
+
return [];
|
|
427
|
+
const after = value.replace(/^;+/, "");
|
|
428
|
+
return [after, after.split(";")[0]];
|
|
429
|
+
};
|
|
430
|
+
/** The value of each `name=value` pair of `text` split at `breaks` whose name says it is a credential (credentialNamed),
|
|
431
|
+
* out of any quotes around it, raw or written `%22` or `%27`, as written and decoded. A name is what follows the last
|
|
432
|
+
* `/`, `?`, `#` or `:` before its `=` (a URL's query or fragment, `https://relay/v1?region=us`, names `region`). A
|
|
433
|
+
* value whose part before its first `;` is empty, as written or decoded (`token=;<key>` read whole, `token=%3B<key>`),
|
|
434
|
+
* is taken after that `;` too (afterEmpty). A value of only `=`, `;` and quotes, as written or decoded (a base64 credential's padding read as a
|
|
435
|
+
* pair, `token=;` before a space, a lone `'` or its `%27`), is not taken: otlpHeaderCut has no length floor, and it
|
|
436
|
+
* would cut that character everywhere in the tracer's lines. */
|
|
437
|
+
const pairValues = (text, breaks) => text.split(breaks).flatMap((pair) => {
|
|
438
|
+
const at = pair.indexOf("=");
|
|
439
|
+
if (at <= 0)
|
|
440
|
+
return [];
|
|
441
|
+
const name = pair.slice(0, at).split(/[/?#:]/).at(-1) ?? "";
|
|
442
|
+
if (!credentialNamed(decoded(name) ?? name))
|
|
443
|
+
return [];
|
|
444
|
+
const inner = pair.slice(at + 1).replace(/^(["']|%22|%27)(.*)\1$/, "$2");
|
|
445
|
+
return [inner, ...afterEmpty(inner)]
|
|
446
|
+
.flatMap((value) => [value, decoded(value) ?? value])
|
|
447
|
+
.concat(afterEmpty(decoded(inner) ?? inner))
|
|
448
|
+
.filter((value) => /[^=;"']/.test(value));
|
|
449
|
+
});
|
|
450
|
+
/** The credentials a header value carries inside it, the union of two reads over the whole value as written: the value
|
|
451
|
+
* of each `name=value` pair whose name says it is a credential (pairValues, at each of PAIR_BREAK, PIECE_BREAK,
|
|
452
|
+
* LIST_BREAK, WHOLE_BREAK, ENCODED_BREAK and ENCODED_AMP_BREAK: a cookie's `session=<token>`, sentry's
|
|
453
|
+
* `sentry_key=<key>`, a path's `;jsessionid=<id>`, a URL query's or fragment's `session=` or `access_token=`), and the
|
|
454
|
+
* user, password and key parameters of each URL in it (urlSpans, urlCredentials: a DSN's `https://<key>@host/1`, a
|
|
455
|
+
* relay's whole `user:pa;ss`). A URL only adds readings: the pair read covers its text too. A value that escapes its
|
|
456
|
+
* slashes (JSON's `https:\/\/`) is read again with them plain, and what that finds is held both ways. A pair named like
|
|
457
|
+
* no credential (`theme=dark`) is not taken. */
|
|
458
|
+
const innerCredentials = (value) => {
|
|
459
|
+
const read = (text) => {
|
|
460
|
+
const queriesRead = { spans: new Set(), left: QUERY_BUDGET };
|
|
461
|
+
return [
|
|
462
|
+
...pairValues(text, PAIR_BREAK),
|
|
463
|
+
...pairValues(text, PIECE_BREAK),
|
|
464
|
+
...pairValues(text, LIST_BREAK),
|
|
465
|
+
...pairValues(text, WHOLE_BREAK),
|
|
466
|
+
...(ENCODED_SEEN.test(text) ? [...pairValues(text, ENCODED_BREAK), ...pairValues(text, ENCODED_AMP_BREAK)] : []),
|
|
467
|
+
...urlSpans(text).flatMap(({ start, end }) => urlCredentials(text, start, end, queriesRead)),
|
|
468
|
+
];
|
|
469
|
+
};
|
|
470
|
+
if (!value.includes("\\/"))
|
|
471
|
+
return read(value);
|
|
472
|
+
return [...read(value), ...read(value.replace(/\\\//g, "/")).flatMap((found) => [found, found.replace(/\//g, "\\/")])];
|
|
473
|
+
};
|
|
474
|
+
/** The OTLP exporter's header values `env` names (OTEL_EXPORTER_OTLP_HEADERS and OTEL_EXPORTER_OTLP_TRACES_HEADERS: a
|
|
475
|
+
* tracing backend's key is one), at any length (keptSecrets floors them for the held list; otlpHeaderCut does not),
|
|
476
|
+
* but those of a header OTLP_PLAIN_HEADERS names, and, for the held list (`held`), those OTLP_CUT_ONLY_HEADERS names.
|
|
477
|
+
* Each is held as written (percent-encoded) and as sent (decoded); and as the SDK reads the same variable, which it
|
|
478
|
+
* merges under ours (`headers`, tracer.ts exporterConfig) and which drops a `;` and what follows it, so a part ours
|
|
479
|
+
* can't decode still sends that much; and, under a credential-named header (credentialNamed) or after a known auth
|
|
480
|
+
* scheme (KNOWN_SCHEME), each of those without its first word (AUTH_SCHEME), the credential alone, as an error may
|
|
481
|
+
* quote it. For the held list, any other header's value is held whole, never its tail alone; for the cut (`held`
|
|
482
|
+
* false), every value is taken without any first word too, since cutting more of the tracer's own lines costs
|
|
483
|
+
* nothing. Under any header, each credential a value carries inside it (innerCredentials: a credential-named
|
|
484
|
+
* `name=value` pair's value, a URL's user, password and key parameters) is taken alone too. A part whose name can't
|
|
485
|
+
* be decoded is held. Commas split the variable, so a comma inside a value must be written `%2C`. */
|
|
486
|
+
export const otlpHeaderValues = (env, held) => [env.OTEL_EXPORTER_OTLP_HEADERS, env.OTEL_EXPORTER_OTLP_TRACES_HEADERS].flatMap((text) => (text ?? "").split(",").flatMap((part) => {
|
|
487
|
+
const at = part.indexOf("=");
|
|
488
|
+
if (at <= 0)
|
|
489
|
+
return [];
|
|
490
|
+
const rawName = part.slice(0, at).trim();
|
|
491
|
+
const name = decoded(rawName) ?? rawName;
|
|
492
|
+
if (OTLP_PLAIN_HEADERS.includes(name.toLowerCase()))
|
|
493
|
+
return [];
|
|
494
|
+
if (held && OTLP_CUT_ONLY_HEADERS.includes(name.toLowerCase()))
|
|
495
|
+
return [];
|
|
496
|
+
const written = part.slice(at + 1).trim();
|
|
497
|
+
const property = written.indexOf(";");
|
|
498
|
+
const forms = [written, ...(property >= 0 ? [written.slice(0, property).trim()] : [])].flatMap((value) => [value, decoded(value) ?? value]);
|
|
499
|
+
const named = credentialNamed(name);
|
|
500
|
+
return forms.flatMap((value) => [value, ...(!held || named || KNOWN_SCHEME.test(value) ? [value.replace(AUTH_SCHEME, "")] : []), ...innerCredentials(value)]);
|
|
501
|
+
})).filter((value) => value.trim() !== "");
|
|
502
|
+
/** The credentials the OTLP endpoints `env` names write into their URLs (OTEL_EXPORTER_OTLP_ENDPOINT and
|
|
503
|
+
* OTEL_EXPORTER_OTLP_TRACES_ENDPOINT; urlCredentials): a user and password, and the value of each query parameter
|
|
504
|
+
* whose name says it is one, each as written and decoded. An exporter's error may quote the URL it posted to. */
|
|
505
|
+
export const otlpEndpointValues = (env) => [env.OTEL_EXPORTER_OTLP_ENDPOINT, env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT].flatMap((text) => urlCredentials((text ?? "").trim())).filter((value) => value.trim() !== "");
|
|
506
|
+
/** Every OTLP credential `env` names: its header values (otlpHeaderValues, a cut-only header's only when not `held`) and
|
|
507
|
+
* its endpoints' (otlpEndpointValues). */
|
|
508
|
+
const otlpValues = (env, held) => [...otlpHeaderValues(env, held), ...otlpEndpointValues(env)];
|
|
509
|
+
/** `values` and every OTLP credential `env` names (otlpValues: its header values but a cut-only header's, its
|
|
510
|
+
* endpoints' user, password and key parameters) as the held list keeps them: each MIN_SECRET long or more, whitespace
|
|
511
|
+
* aside. A shorter one matches too much text by chance to be held, and some readers of the list have no floor of their
|
|
512
|
+
* own (a number equal to a held value is withheld, key-refusal.ts heldNumber; a source capture refuses a path or file
|
|
513
|
+
* holding one), so a short header value is on no held list, nor is a dataset's or tenant's (OTLP_CUT_ONLY_HEADERS):
|
|
514
|
+
* otlpHeaderCut alone cuts it, from the tracer's own lines. */
|
|
515
|
+
export const keptSecrets = (values, env) => [...new Set([...values, ...otlpValues(env, true)])].filter((value) => value.replace(/\s+/g, "").length >= MIN_SECRET);
|
|
516
|
+
const CUT = "[redacted]";
|
|
517
|
+
/** Text with every OTLP credential `env` names (otlpValues: its header values, a cut-only header's too, its endpoints'
|
|
518
|
+
* user, password and key parameters) put as "[redacted]", at any length: the one cut without the MIN_SECRET floor.
|
|
519
|
+
* The tracer's own lines take it, after the runner's redactor (otel/tracer.ts saidOf), since they are where one can
|
|
520
|
+
* show: an exporter's error may quote a header it sent or the URL it posted to, and a run's process never holds one.
|
|
521
|
+
* Every other cut keeps the floor on purpose: a needle of a few characters in every redactor would cut ordinary text
|
|
522
|
+
* everywhere. Each value is matched exactly as held, and the cut is the union of every place each one stands: at each
|
|
523
|
+
* character, the longest value (or a "[redacted]" already in the text) starting there is found without being taken,
|
|
524
|
+
* so a value starting inside another is found too, and the places, which come in order, are merged where they overlap
|
|
525
|
+
* or touch and each run cut as one "[redacted]". So no character of any held value is left, whichever of two
|
|
526
|
+
* overlapping values starts first or is longer (the SDK's reading `api_key=<key>` and a key `<key;rest>` quoted as
|
|
527
|
+
* `api_key=<key;rest>`), and a "[redacted]" already in the text is left whole. One pass over the text, one merge. */
|
|
528
|
+
export function otlpHeaderCut(env) {
|
|
529
|
+
const values = [...new Set([CUT, ...otlpValues(env, false)])].sort((a, b) => b.length - a.length);
|
|
530
|
+
if (values.length === 1)
|
|
531
|
+
return (text) => text;
|
|
532
|
+
const needle = new RegExp(`(?=(${values.map((value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")}))`, "g");
|
|
533
|
+
return (text) => {
|
|
534
|
+
if (!text)
|
|
535
|
+
return text;
|
|
536
|
+
const spans = [];
|
|
537
|
+
for (const found of text.matchAll(needle)) {
|
|
538
|
+
const [start, end] = [found.index, found.index + found[1].length];
|
|
539
|
+
const last = spans.at(-1);
|
|
540
|
+
if (last && start <= last[1])
|
|
541
|
+
last[1] = Math.max(last[1], end);
|
|
542
|
+
else
|
|
543
|
+
spans.push([start, end]);
|
|
544
|
+
}
|
|
545
|
+
let out = "";
|
|
546
|
+
let from = 0;
|
|
547
|
+
for (const [start, end] of spans) {
|
|
548
|
+
out += `${text.slice(from, start)}${CUT}`;
|
|
549
|
+
from = end;
|
|
550
|
+
}
|
|
551
|
+
return out + text.slice(from);
|
|
552
|
+
};
|
|
553
|
+
}
|
|
230
554
|
/** Every header value of `credentials`: what a secret scan refuses. */
|
|
231
555
|
export const mcpSecretValues = (credentials) => Object.values(credentials).flatMap((server) => Object.values(server.headers ?? {})).flatMap((value) => [value, value.replace(/^Bearer\s+/i, "")]);
|
|
232
556
|
/** The saved sign-in this run's process was handed over its pipe, if any: read by the browser tool alone. */
|
package/dist/server-fs.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const defaultData: (env?: NodeJS.ProcessEnv) => string;
|
|
|
15
15
|
/** The server's own data directory, on its reading of the environment (startServe): an npx hint names it (adapters.ts
|
|
16
16
|
* npxLine). */
|
|
17
17
|
export declare const DATA_ENV = "AGENTRUN_SERVE_DATA";
|
|
18
|
-
/** Agent `agentId`'s folder on the disk, which holds its
|
|
18
|
+
/** Agent `agentId`'s folder on the disk, which holds its runs: `<data>/disk/agents/<agent>`. */
|
|
19
19
|
/** The folder of a data directory that holds each agent's disk: its runs and its learning. */
|
|
20
20
|
export declare const DISK_DIR = "disk";
|
|
21
21
|
/** Agent `agentId`'s folder on the disk of data directory `data`: `<data>/disk/agents/<name>`. */
|
package/dist/server-fs.js
CHANGED
|
@@ -31,7 +31,7 @@ export const defaultData = (env = process.env) => join(env.XDG_DATA_HOME || join
|
|
|
31
31
|
/** The server's own data directory, on its reading of the environment (startServe): an npx hint names it (adapters.ts
|
|
32
32
|
* npxLine). */
|
|
33
33
|
export const DATA_ENV = "AGENTRUN_SERVE_DATA";
|
|
34
|
-
/** Agent `agentId`'s folder on the disk, which holds its
|
|
34
|
+
/** Agent `agentId`'s folder on the disk, which holds its runs: `<data>/disk/agents/<agent>`. */
|
|
35
35
|
/** The folder of a data directory that holds each agent's disk: its runs and its learning. */
|
|
36
36
|
export const DISK_DIR = "disk";
|
|
37
37
|
/** An agent's folder's name on the disk: its id in lower case, then 16 hex digits of the id's SHA-256, so ids that differ
|
package/dist/server-keys.d.ts
CHANGED
|
@@ -9,9 +9,10 @@ export type Opened = {
|
|
|
9
9
|
unreadable: Unreadable;
|
|
10
10
|
};
|
|
11
11
|
/** Why a saved harness key (harness-keys.ts) is not one its recipe's runs get, so it is entered again: saved for another
|
|
12
|
-
* recipe file of its id (`recipe_changed
|
|
13
|
-
* document reads it without loading the
|
|
14
|
-
|
|
12
|
+
* recipe file of its id (`recipe_changed`), bound to none (`not_bound`: saved before keys were bound, or its binding
|
|
13
|
+
* write was cut off), or one of UNREADABLE. Here, beside UNREADABLE, so the API document reads it without loading the
|
|
14
|
+
* keys layer. */
|
|
15
|
+
export declare const HARNESS_KEY_REENTER: readonly ["recipe_changed", "not_bound", "seal_key_changed", "file_unreadable"];
|
|
15
16
|
/** The fingerprint of a seal key: an HMAC of a fixed label under it, stable across restarts, so a value whose fingerprint
|
|
16
17
|
* no longer matches was sealed under another key (seal_key_changed), told apart from one that is simply damaged. No
|
|
17
18
|
* secret: neither the key nor a hash of it. Kept beside the sealed rows, in a settings row of the layer that writes them. */
|
|
@@ -23,6 +24,12 @@ export declare function openSealed(sealKey: Buffer, name: string, sealed: Uint8A
|
|
|
23
24
|
export declare function putSealedKey(store: {
|
|
24
25
|
sealedKeys: Pick<SealedKeys, "put">;
|
|
25
26
|
}, sealKey: Buffer, name: string, value: string): Promise<void>;
|
|
27
|
+
/** The value kept under `name`, opened now: the one saved there that opens under `sealKey`, else `value`, saved so that of
|
|
28
|
+
* writers racing on the row one's is kept and every one reads it back. A row that does not open (sealed under another
|
|
29
|
+
* key, or damaged) is replaced only while it holds the bytes read. Undefined only when the row still does not open. */
|
|
30
|
+
export declare function keepSealedKey(store: {
|
|
31
|
+
sealedKeys: Pick<SealedKeys, "get" | "putIfAbsent" | "replaceIf">;
|
|
32
|
+
}, sealKey: Buffer, name: string, value: string): Promise<string | undefined>;
|
|
26
33
|
/** The value saved under `name`, opened now; undefined with none saved, or one that does not open under this seal key
|
|
27
34
|
* (sealed under another key, or damaged). Never a value the store could read in the clear. */
|
|
28
35
|
export declare function getSealedKey(store: {
|
package/dist/server-keys.js
CHANGED
|
@@ -8,9 +8,10 @@ import { sealColumn, sealedAt, unsealColumn } from "./store/index.js";
|
|
|
8
8
|
/** Why a saved value does not open: sealed under another seal key (its fingerprint no longer matches), or damaged. */
|
|
9
9
|
export const UNREADABLE = ["seal_key_changed", "file_unreadable"];
|
|
10
10
|
/** Why a saved harness key (harness-keys.ts) is not one its recipe's runs get, so it is entered again: saved for another
|
|
11
|
-
* recipe file of its id (`recipe_changed
|
|
12
|
-
* document reads it without loading the
|
|
13
|
-
|
|
11
|
+
* recipe file of its id (`recipe_changed`), bound to none (`not_bound`: saved before keys were bound, or its binding
|
|
12
|
+
* write was cut off), or one of UNREADABLE. Here, beside UNREADABLE, so the API document reads it without loading the
|
|
13
|
+
* keys layer. */
|
|
14
|
+
export const HARNESS_KEY_REENTER = ["recipe_changed", "not_bound", ...UNREADABLE];
|
|
14
15
|
/** The fingerprint of a seal key: an HMAC of a fixed label under it, stable across restarts, so a value whose fingerprint
|
|
15
16
|
* no longer matches was sealed under another key (seal_key_changed), told apart from one that is simply damaged. No
|
|
16
17
|
* secret: neither the key nor a hash of it. Kept beside the sealed rows, in a settings row of the layer that writes them. */
|
|
@@ -31,6 +32,18 @@ export function openSealed(sealKey, name, sealed, fp) {
|
|
|
31
32
|
export async function putSealedKey(store, sealKey, name, value) {
|
|
32
33
|
await store.sealedKeys.put(name, sealColumn(sealKey, sealedAt.sealedKey(name), value));
|
|
33
34
|
}
|
|
35
|
+
/** The value kept under `name`, opened now: the one saved there that opens under `sealKey`, else `value`, saved so that of
|
|
36
|
+
* writers racing on the row one's is kept and every one reads it back. A row that does not open (sealed under another
|
|
37
|
+
* key, or damaged) is replaced only while it holds the bytes read. Undefined only when the row still does not open. */
|
|
38
|
+
export async function keepSealedKey(store, sealKey, name, value) {
|
|
39
|
+
const was = await store.sealedKeys.get(name);
|
|
40
|
+
const sealed = sealColumn(sealKey, sealedAt.sealedKey(name), value);
|
|
41
|
+
if (was === undefined)
|
|
42
|
+
await store.sealedKeys.putIfAbsent(name, sealed);
|
|
43
|
+
else if (!("value" in openSealed(sealKey, name, was, undefined)))
|
|
44
|
+
await store.sealedKeys.replaceIf(name, was, sealed);
|
|
45
|
+
return getSealedKey(store, sealKey, name);
|
|
46
|
+
}
|
|
34
47
|
/** The value saved under `name`, opened now; undefined with none saved, or one that does not open under this seal key
|
|
35
48
|
* (sealed under another key, or damaged). Never a value the store could read in the clear. */
|
|
36
49
|
export async function getSealedKey(store, sealKey, name) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// serverSecrets): what a run shows, what learning keeps and what the server answers are cut of it.
|
|
6
6
|
import { sealedSettingsOverStore } from "./sealed-settings-store.js";
|
|
7
7
|
import { besideTheStore } from "./server-secrets.js";
|
|
8
|
-
import { SEAL_KEY_ENV,
|
|
8
|
+
import { SEAL_KEY_ENV, sealKeyIn } from "./tool-keys.js";
|
|
9
9
|
import { SLACK_CHANNEL, SLACK_URL_SPEC, slackUrlForms } from "./slack.js";
|
|
10
10
|
import { WEBHOOK_CHANNEL, WEBHOOK_SECRET_SPEC } from "./webhooks.js";
|
|
11
11
|
/** The server's own secrets over the store: what it keeps beside the store (besideTheStore), the outbound webhook's
|
|
@@ -15,9 +15,7 @@ import { WEBHOOK_CHANNEL, WEBHOOK_SECRET_SPEC } from "./webhooks.js";
|
|
|
15
15
|
* list is whole from the first use. A value that does not open is said to `say`. */
|
|
16
16
|
export async function openServerSecretsOverStore(store, data, env, adapters, say = () => { }) {
|
|
17
17
|
// The server always has its seal key (seal-key.ts bootSealKey, at its start): no setting is ever kept in the clear.
|
|
18
|
-
const key =
|
|
19
|
-
if (!key)
|
|
20
|
-
throw new Error(`the server starts with its seal key (${SEAL_KEY_ENV}), made at the first start when none is handed over`);
|
|
18
|
+
const key = sealKeyIn(env[SEAL_KEY_ENV], "the server's own secrets");
|
|
21
19
|
const secrets = besideTheStore(data);
|
|
22
20
|
// The outbound webhook's secret, and each it held before, kept in the store (webhooks.ts). Its secret not opening under
|
|
23
21
|
// this seal key is said in the webhook's own words, naming the data directory.
|