@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.59
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 +325 -1
- package/README.md +332 -88
- 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/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- 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 +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +15 -11
- package/dist/claude-login-token.js +167 -107
- package/dist/claude-login.d.ts +76 -31
- package/dist/claude-login.js +426 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -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-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.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/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/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.js +9 -6
- 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 +8 -0
- package/dist/harness-table.js +17 -6
- 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.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +32 -29
- package/dist/learn/ledger.js +26 -19
- package/dist/learn/promote.d.ts +79 -36
- package/dist/learn/promote.js +60 -65
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- 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-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- 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 +16 -2
- package/dist/mcp-gateway.js +41 -3
- 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-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/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +202 -51
- 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 +55 -34
- package/dist/place-offers.js +93 -54
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +3 -2
- package/dist/provider.js +17 -8
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- 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.js +16 -3
- 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.js +3 -1
- package/dist/runnable.js +2 -2
- 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 +64 -28
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- 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 +81 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +5 -2
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- 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 +12 -11
- package/dist/runner/mcp-claim.js +21 -5
- 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 +10 -8
- package/dist/runner/presence.d.ts +1 -4
- package/dist/runner/presence.js +6 -8
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- 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 +20 -5
- package/dist/runner/run-child-host.js +179 -77
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +2 -3
- package/dist/runner/runner.js +13 -9
- package/dist/runner/sdk-loop.js +8 -8
- 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/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- 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 +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +15 -3
- package/dist/server.js +312 -80
- 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/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/store.js +4 -0
- package/dist/store/schema.d.ts +33 -10
- package/dist/store/schema.js +70 -16
- package/dist/store/seal.d.ts +4 -1
- 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 +3 -0
- package/dist/store/sqlite/store.js +116 -34
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +67 -32
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +35 -26
- package/dist/store-reads/learning.js +120 -92
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- 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/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 +50 -11
- package/dist/tool-plane.js +94 -30
- 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 +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -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/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 +35 -17
- 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 +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- 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/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 +6 -0
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +22 -6
- 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/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;
|
|
@@ -57,15 +54,60 @@ export declare const withoutSecrets: (env: NodeJS.ProcessEnv) => NodeJS.ProcessE
|
|
|
57
54
|
/** What a run's process is handed: the secrets named `names` that this process holds, or its server saved (`stored`),
|
|
58
55
|
* as its pipe carries them. */
|
|
59
56
|
export declare function handover(names: readonly string[], stored?: StoredKeys): Buffer;
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
export declare function
|
|
57
|
+
/** A `key=value,key=value` list (OTEL_EXPORTER_OTLP_HEADERS, OTEL_RESOURCE_ATTRIBUTES), each part percent-decoded; a
|
|
58
|
+
* part that is not one is skipped. */
|
|
59
|
+
export declare function keyValues(text: string | undefined): Record<string, string>;
|
|
63
60
|
/** The MCP credentials this process was handed (MCP_AUTH), by server; none when it was handed none. */
|
|
64
61
|
export declare function mcpCredentials(): Record<string, {
|
|
65
62
|
url: string;
|
|
66
63
|
headers?: Record<string, string>;
|
|
67
64
|
unopened?: string;
|
|
68
65
|
}>;
|
|
66
|
+
/** The OTLP header names whose value is not held (otlpHeaderValues), matched in any case: the standard headers that say
|
|
67
|
+
* 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
|
|
68
|
+
* list never means its value is safe. */
|
|
69
|
+
export declare const OTLP_PLAIN_HEADERS: readonly string[];
|
|
70
|
+
/** The OTLP header names whose value is on no held list but is cut from the tracer's own lines (otlpHeaderCut), matched
|
|
71
|
+
* in any case: a backend's dataset or tenant, which says where spans go and carries no key. Such a value is often a
|
|
72
|
+
* word like `production`, which a held list would find in nearly every project a source capture reads and in served
|
|
73
|
+
* text. Only the names here: an unknown name's value is still held. */
|
|
74
|
+
export declare const OTLP_CUT_ONLY_HEADERS: readonly string[];
|
|
75
|
+
/** The OTLP exporter's header values `env` names (OTEL_EXPORTER_OTLP_HEADERS and OTEL_EXPORTER_OTLP_TRACES_HEADERS: a
|
|
76
|
+
* tracing backend's key is one), at any length (keptSecrets floors them for the held list; otlpHeaderCut does not),
|
|
77
|
+
* but those of a header OTLP_PLAIN_HEADERS names, and, for the held list (`held`), those OTLP_CUT_ONLY_HEADERS names.
|
|
78
|
+
* Each is held as written (percent-encoded) and as sent (decoded); and as the SDK reads the same variable, which it
|
|
79
|
+
* merges under ours (`headers`, tracer.ts exporterConfig) and which drops a `;` and what follows it, so a part ours
|
|
80
|
+
* can't decode still sends that much; and, under a credential-named header (credentialNamed) or after a known auth
|
|
81
|
+
* scheme (KNOWN_SCHEME), each of those without its first word (AUTH_SCHEME), the credential alone, as an error may
|
|
82
|
+
* quote it. For the held list, any other header's value is held whole, never its tail alone; for the cut (`held`
|
|
83
|
+
* false), every value is taken without any first word too, since cutting more of the tracer's own lines costs
|
|
84
|
+
* nothing. Under any header, each credential a value carries inside it (innerCredentials: a credential-named
|
|
85
|
+
* `name=value` pair's value, a URL's user, password and key parameters) is taken alone too. A part whose name can't
|
|
86
|
+
* be decoded is held. Commas split the variable, so a comma inside a value must be written `%2C`. */
|
|
87
|
+
export declare const otlpHeaderValues: (env: NodeJS.ProcessEnv, held: boolean) => string[];
|
|
88
|
+
/** The credentials the OTLP endpoints `env` names write into their URLs (OTEL_EXPORTER_OTLP_ENDPOINT and
|
|
89
|
+
* OTEL_EXPORTER_OTLP_TRACES_ENDPOINT; urlCredentials): a user and password, and the value of each query parameter
|
|
90
|
+
* whose name says it is one, each as written and decoded. An exporter's error may quote the URL it posted to. */
|
|
91
|
+
export declare const otlpEndpointValues: (env: NodeJS.ProcessEnv) => string[];
|
|
92
|
+
/** `values` and every OTLP credential `env` names (otlpValues: its header values but a cut-only header's, its
|
|
93
|
+
* endpoints' user, password and key parameters) as the held list keeps them: each MIN_SECRET long or more, whitespace
|
|
94
|
+
* aside. A shorter one matches too much text by chance to be held, and some readers of the list have no floor of their
|
|
95
|
+
* own (a number equal to a held value is withheld, key-refusal.ts heldNumber; a source capture refuses a path or file
|
|
96
|
+
* holding one), so a short header value is on no held list, nor is a dataset's or tenant's (OTLP_CUT_ONLY_HEADERS):
|
|
97
|
+
* otlpHeaderCut alone cuts it, from the tracer's own lines. */
|
|
98
|
+
export declare const keptSecrets: (values: readonly string[], env: NodeJS.ProcessEnv) => string[];
|
|
99
|
+
/** Text with every OTLP credential `env` names (otlpValues: its header values, a cut-only header's too, its endpoints'
|
|
100
|
+
* user, password and key parameters) put as "[redacted]", at any length: the one cut without the MIN_SECRET floor.
|
|
101
|
+
* The tracer's own lines take it, after the runner's redactor (otel/tracer.ts saidOf), since they are where one can
|
|
102
|
+
* 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.
|
|
103
|
+
* Every other cut keeps the floor on purpose: a needle of a few characters in every redactor would cut ordinary text
|
|
104
|
+
* everywhere. Each value is matched exactly as held, and the cut is the union of every place each one stands: at each
|
|
105
|
+
* character, the longest value (or a "[redacted]" already in the text) starting there is found without being taken,
|
|
106
|
+
* so a value starting inside another is found too, and the places, which come in order, are merged where they overlap
|
|
107
|
+
* or touch and each run cut as one "[redacted]". So no character of any held value is left, whichever of two
|
|
108
|
+
* overlapping values starts first or is longer (the SDK's reading `api_key=<key>` and a key `<key;rest>` quoted as
|
|
109
|
+
* `api_key=<key;rest>`), and a "[redacted]" already in the text is left whole. One pass over the text, one merge. */
|
|
110
|
+
export declare function otlpHeaderCut(env: NodeJS.ProcessEnv): (text: string) => string;
|
|
69
111
|
/** Every header value of `credentials`: what a secret scan refuses. */
|
|
70
112
|
export declare const mcpSecretValues: (credentials: Record<string, {
|
|
71
113
|
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
|
|
@@ -204,18 +198,24 @@ export function handover(names, stored) {
|
|
|
204
198
|
return value === undefined ? [] : [[name, value]];
|
|
205
199
|
}));
|
|
206
200
|
}
|
|
207
|
-
/**
|
|
208
|
-
*
|
|
209
|
-
export function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
/** A `key=value,key=value` list (OTEL_EXPORTER_OTLP_HEADERS, OTEL_RESOURCE_ATTRIBUTES), each part percent-decoded; a
|
|
202
|
+
* part that is not one is skipped. */
|
|
203
|
+
export function keyValues(text) {
|
|
204
|
+
const out = {};
|
|
205
|
+
for (const part of (text ?? "").split(",")) {
|
|
206
|
+
const at = part.indexOf("=");
|
|
207
|
+
if (at <= 0)
|
|
208
|
+
continue;
|
|
209
|
+
try {
|
|
210
|
+
const key = decodeURIComponent(part.slice(0, at).trim());
|
|
211
|
+
if (key)
|
|
212
|
+
out[key] = decodeURIComponent(part.slice(at + 1).trim());
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
218
217
|
}
|
|
218
|
+
return out;
|
|
219
219
|
}
|
|
220
220
|
/** The MCP credentials this process was handed (MCP_AUTH), by server; none when it was handed none. */
|
|
221
221
|
export function mcpCredentials() {
|
|
@@ -227,6 +227,296 @@ export function mcpCredentials() {
|
|
|
227
227
|
return {};
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
+
/** The OTLP header names whose value is not held (otlpHeaderValues), matched in any case: the standard headers that say
|
|
231
|
+
* 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
|
|
232
|
+
* list never means its value is safe. */
|
|
233
|
+
export const OTLP_PLAIN_HEADERS = ["content-type", "accept", "content-encoding", "user-agent"];
|
|
234
|
+
/** `text` percent-decoded, or undefined when it can't be. */
|
|
235
|
+
const decoded = (text) => {
|
|
236
|
+
try {
|
|
237
|
+
return decodeURIComponent(text);
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
/** The OTLP header names whose value is on no held list but is cut from the tracer's own lines (otlpHeaderCut), matched
|
|
244
|
+
* in any case: a backend's dataset or tenant, which says where spans go and carries no key. Such a value is often a
|
|
245
|
+
* word like `production`, which a held list would find in nearly every project a source capture reads and in served
|
|
246
|
+
* text. Only the names here: an unknown name's value is still held. */
|
|
247
|
+
export const OTLP_CUT_ONLY_HEADERS = ["x-honeycomb-dataset", "x-axiom-dataset", "x-scope-orgid"];
|
|
248
|
+
/** An auth scheme before its credential, as a header writes it (`Bearer <token>`, `Basic <base64>`, `Api-Key <key>`,
|
|
249
|
+
* `sentry sentry_key=<key>`): a token, then a space or its `%20`. */
|
|
250
|
+
const AUTH_SCHEME = /^[A-Za-z][\w.+-]*(?:\s+|%20)/;
|
|
251
|
+
/** The auth schemes a backend's header writes before its credential, in any case, under any header name. */
|
|
252
|
+
const KNOWN_SCHEME = /^(?:bearer|basic|api-?key|api-?token|token|sentry|splunk|geniekey)(?:\s+|%20)/i;
|
|
253
|
+
/** Whether a header's or an endpoint's query parameter's name says its value is a credential (`authorization`,
|
|
254
|
+
* `x-sentry-auth`, `x-api-key`, `access_token`, `apiKey2`, `X-Amz-Signature`, `sessionid`): a name is split at each
|
|
255
|
+
* non-alphanumeric and at each lower-to-upper case change, a word's trailing digits are dropped (`key2` is `key`), and
|
|
256
|
+
* a word counts when it is one of CREDENTIAL_WORDS, ends in one of CREDENTIAL_ENDINGS (`accesstoken`, `dbpasswd`,
|
|
257
|
+
* `writekey`, `hmackey`), or starts with one of CREDENTIAL_STARTS and is more than its plural (`tokenvalue`,
|
|
258
|
+
* `passwordhash`; never `tokens`). `auth`, `key`, `sig` and `session` start no compound, so a word that only starts like
|
|
259
|
+
* one says nothing (`authority`, `keyspace`, `sessions`). */
|
|
260
|
+
const CREDENTIAL_WORDS = new Set(["authorization", "auth", "key", "apikey", "token", "secret", "password", "passwd", "pwd", "sig", "signature", "credential", "credentials", "jwt", "session"]);
|
|
261
|
+
const CREDENTIAL_ENDINGS = ["key", "token", "secret", "password", "passwd", "pwd", "auth", "authorization", "sig", "signature", "credential", "credentials", "jwt", "sessionid"];
|
|
262
|
+
const CREDENTIAL_STARTS = ["token", "secret", "password", "passwd", "jwt"];
|
|
263
|
+
const credentialWord = (word) => {
|
|
264
|
+
const bare = word.replace(/\d+$/, "");
|
|
265
|
+
return CREDENTIAL_WORDS.has(bare)
|
|
266
|
+
|| CREDENTIAL_ENDINGS.some((ending) => bare.endsWith(ending))
|
|
267
|
+
|| CREDENTIAL_STARTS.some((start) => bare.startsWith(start) && bare.length > start.length + 1);
|
|
268
|
+
};
|
|
269
|
+
const credentialNamed = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(credentialWord);
|
|
270
|
+
/** Where a URL starts: a scheme, then `://`; or `//` alone (a scheme-relative URL, `//<key>@host`) at the start of the
|
|
271
|
+
* text or after a space, a quote, `=`, `(`, `,`, `;` or `&`, never inside a path (`/a//b`). A scheme is read at most 32
|
|
272
|
+
* characters long, so a long word with no `://` after it costs one short look from each of its letters. */
|
|
273
|
+
const URL_START = /[A-Za-z][\w+.-]{0,31}:\/\/|(?<=^|[\s"'=(,;&])\/\//;
|
|
274
|
+
const URL_HEAD = /(?:[A-Za-z][\w+.-]{0,31}:)?\/\//y;
|
|
275
|
+
/** How many readings of one URL's userinfo urlParts takes at most, and how many characters its shorter readings (all
|
|
276
|
+
* but the RFC's and the first `@`'s) take together at most: a value can hold thousands of `@`, and a reading at each
|
|
277
|
+
* would hold, and the [otel] cut compile into one pattern, their count times the value's length. */
|
|
278
|
+
const MAX_READINGS = 16;
|
|
279
|
+
const READINGS_BUDGET = 4096;
|
|
280
|
+
/** How many characters of URL queries one header value's read (innerCredentials) takes after the first query it reads:
|
|
281
|
+
* 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
|
|
282
|
+
* would hold their count times the value's length. The pair read (pairValues) still covers every query's text. */
|
|
283
|
+
const QUERY_BUDGET = 4096;
|
|
284
|
+
/** A URL as RFC 3986 reads it, `text` from `start` (its scheme, or the `//` of a scheme-relative one) to `end`: its
|
|
285
|
+
* authority, up to the first `/`, `?` or `#`; the readings of its userinfo, the RFC's first (everything before the
|
|
286
|
+
* authority's last `@`, so a password's `;`, `&`, `=`, `,`, `'` or raw `@` stays in it), then, when the authority holds
|
|
287
|
+
* more than one `@`, the one up to its first `@` and the next shorter ones, up to MAX_READINGS in all and
|
|
288
|
+
* READINGS_BUDGET characters for those after the first two (a URL with no closing mark, followed by a pair holding an
|
|
289
|
+
* `@`, `...@relay.invalid&contact=ops@team`, reads too long a userinfo, and a redactor holding an extra candidate is
|
|
290
|
+
* safe where missing one leaks); and where its query is, from the first `?` to a `#`. Read in place, never copied to
|
|
291
|
+
* `end`: a value of thousands of URLs one inside the next costs each only its authority. Undefined when no URL starts
|
|
292
|
+
* at `start`. */
|
|
293
|
+
const urlParts = (text, start, end) => {
|
|
294
|
+
URL_HEAD.lastIndex = start;
|
|
295
|
+
if (!URL_HEAD.test(text))
|
|
296
|
+
return undefined;
|
|
297
|
+
const from = URL_HEAD.lastIndex;
|
|
298
|
+
let stop = from;
|
|
299
|
+
while (stop < end && !"/?#".includes(text[stop]))
|
|
300
|
+
stop++;
|
|
301
|
+
const authority = text.slice(from, stop);
|
|
302
|
+
const ats = [...authority.matchAll(/@/g)].map((at) => at.index);
|
|
303
|
+
const kept = ats.length > 1 ? [ats[ats.length - 1], ats[0]] : ats;
|
|
304
|
+
let budget = READINGS_BUDGET;
|
|
305
|
+
for (let next = 1; next < ats.length - 1 && kept.length < MAX_READINGS && ats[next] <= budget; next++) {
|
|
306
|
+
budget -= ats[next];
|
|
307
|
+
kept.push(ats[next]);
|
|
308
|
+
}
|
|
309
|
+
const mark = text.indexOf("?", stop);
|
|
310
|
+
const hash = text.indexOf("#", stop);
|
|
311
|
+
const query = mark >= 0 && mark < end && (hash < 0 || hash > mark) ? [mark + 1, hash >= 0 && hash < end ? hash : end] : [0, 0];
|
|
312
|
+
return { readings: kept.map((at) => authority.slice(0, at)), query };
|
|
313
|
+
};
|
|
314
|
+
/** A user or password as a URL parser writes it back (a client's error may quote the URL it parsed): `;`, `=`, `@`, `:`
|
|
315
|
+
* and the like percent-encoded. */
|
|
316
|
+
const asParsed = (part) => {
|
|
317
|
+
const url = new URL("http://host.invalid");
|
|
318
|
+
url.password = part;
|
|
319
|
+
return url.password;
|
|
320
|
+
};
|
|
321
|
+
/** The credentials a URL writes into itself (`text` from `start` to `end`, urlParts): the user and password of its
|
|
322
|
+
* userinfo (before its first `:` and after it), each as written, decoded and as a parser writes it back, the RFC's
|
|
323
|
+
* reading at any length and each shorter reading's only at MIN_SECRET or more (so a short piece of a password, `pa` of
|
|
324
|
+
* `pa@ss...`, cuts no ordinary word), and the value of each query parameter whose name says it is one
|
|
325
|
+
* (credentialNamed), the query split at `&` alone and again at `&` and `;`, as written and decoded; none when no URL
|
|
326
|
+
* starts at `start`. A query already in `queriesRead` (several URLs nested in one share it) is not read again, and
|
|
327
|
+
* after the first one read, one is read only while QUERY_BUDGET has room for all of it. */
|
|
328
|
+
const urlCredentials = (text, start = 0, end = text.length, queriesRead = { spans: new Set(), left: QUERY_BUDGET }) => {
|
|
329
|
+
const url = urlParts(text, start, end);
|
|
330
|
+
if (!url)
|
|
331
|
+
return [];
|
|
332
|
+
const userinfo = url.readings.flatMap((reading, at) => {
|
|
333
|
+
const colon = reading.indexOf(":");
|
|
334
|
+
const parts = (colon < 0 ? [reading] : [reading.slice(0, colon), reading.slice(colon + 1)]).flatMap((part) => [part, decoded(part) ?? part, asParsed(part)]);
|
|
335
|
+
return at === 0 ? parts : parts.filter((part) => part.replace(/\s+/g, "").length >= MIN_SECRET);
|
|
336
|
+
});
|
|
337
|
+
const [from, to] = url.query;
|
|
338
|
+
const span = `${from} ${to}`;
|
|
339
|
+
if (from === to || queriesRead.spans.has(span))
|
|
340
|
+
return userinfo;
|
|
341
|
+
if (queriesRead.spans.size > 0) {
|
|
342
|
+
if (to - from > queriesRead.left)
|
|
343
|
+
return userinfo;
|
|
344
|
+
queriesRead.left -= to - from;
|
|
345
|
+
}
|
|
346
|
+
queriesRead.spans.add(span);
|
|
347
|
+
// Read split at `&` alone (a WHATWG parser's reading, a value's raw `;` kept), and each `&` piece holding a `;` split
|
|
348
|
+
// 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
|
|
349
|
+
// a `;` alone. A query writes a space as `+`; a user and password do not.
|
|
350
|
+
const pieces = text.slice(from, to).split("&");
|
|
351
|
+
const query = [...pieces, ...pieces.filter((piece) => piece.includes(";")).flatMap((piece) => piece.split(";"))].flatMap((pair) => {
|
|
352
|
+
const at = pair.indexOf("=");
|
|
353
|
+
const name = pair.slice(0, Math.max(at, 0)).replace(/\+/g, " ");
|
|
354
|
+
const value = pair.slice(at + 1);
|
|
355
|
+
return at > 0 && credentialNamed(decoded(name) ?? name) ? [value, decoded(value.replace(/\+/g, " ")) ?? value] : [];
|
|
356
|
+
});
|
|
357
|
+
return [...userinfo, ...query];
|
|
358
|
+
};
|
|
359
|
+
/** Each URL inside a header value (a DSN, a relay's address) as the spans of text it takes, one starting at every
|
|
360
|
+
* `scheme://` (URL_START), so a URL inside another's query or path is read too: from its scheme to the quote that
|
|
361
|
+
* closes it when a `'` or `"` opens it (comes right before its scheme and is closed later), else to the first space or
|
|
362
|
+
* quote, and, when that is a quote, also on to the first space (RFC 3986 allows a raw `'` in a userinfo, so both
|
|
363
|
+
* readings are taken). Read inside a span alone (urlParts), a quoted URL's userinfo never runs past its closing quote to
|
|
364
|
+
* a later `@`, and an unquoted one's runs past any `;`, `&`, `=` or `,`. */
|
|
365
|
+
const urlSpans = (value) => {
|
|
366
|
+
const spans = [];
|
|
367
|
+
const start = new RegExp(URL_START.source, "g");
|
|
368
|
+
// The first match of `mark` at or after an index, found once for every index from the last one asked up to it: URLs
|
|
369
|
+
// nested one in the next share their end, and a search from each would read the rest of the value again.
|
|
370
|
+
const nextOf = (mark) => {
|
|
371
|
+
let asked = -1;
|
|
372
|
+
let found = -1;
|
|
373
|
+
return (from) => {
|
|
374
|
+
if (from < asked || from > found) {
|
|
375
|
+
mark.lastIndex = from;
|
|
376
|
+
found = mark.exec(value)?.index ?? value.length;
|
|
377
|
+
}
|
|
378
|
+
asked = from;
|
|
379
|
+
return found;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
const nextStop = nextOf(/[\s'"]|$/g);
|
|
383
|
+
const nextSpace = nextOf(/\s|$/g);
|
|
384
|
+
for (let found = start.exec(value); found; found = start.exec(value)) {
|
|
385
|
+
const open = value[found.index - 1];
|
|
386
|
+
const from = found.index + found[0].length;
|
|
387
|
+
const closing = open === "'" || open === '"' ? value.indexOf(open, from) : -1;
|
|
388
|
+
if (closing >= 0) {
|
|
389
|
+
spans.push({ start: found.index, end: closing });
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const end = nextStop(from);
|
|
393
|
+
spans.push({ start: found.index, end });
|
|
394
|
+
if (value[end] === "'" || value[end] === '"')
|
|
395
|
+
spans.push({ start: found.index, end: nextSpace(end) });
|
|
396
|
+
}
|
|
397
|
+
return spans;
|
|
398
|
+
};
|
|
399
|
+
/** The breaks between a header value's `name=value` pairs: `;`, `&`, a comma (or its `%2C`) and spaces; and, for a
|
|
400
|
+
* second, finer read, also `?`, `#` and `/`, so a pair inside a URL that is itself a pair's value
|
|
401
|
+
* (`upstream=https://relay/v1#access_token=<token>`) or a path's segment stands alone; and, for a third, all but `;`,
|
|
402
|
+
* so a credential with a raw `;` in it (`api_key=<key;rest>®ion=us`) is held whole too. */
|
|
403
|
+
const PAIR_BREAK = /[;&,\s]+|%2C/i;
|
|
404
|
+
const PIECE_BREAK = /[;&,\s?#/]+|%2C/i;
|
|
405
|
+
const WHOLE_BREAK = /[&,\s]+|%2C/i;
|
|
406
|
+
/** The value of each `name=value` pair of `text` split at `breaks` whose name says it is a credential (credentialNamed),
|
|
407
|
+
* out of any quotes around it, as written and decoded. A name is what follows the last `/`, `?`, `#` or `:` before its
|
|
408
|
+
* `=` (a URL's query or fragment, `https://relay/v1?region=us`, names `region`). A value of only `=` (a base64
|
|
409
|
+
* credential's padding, read as a pair) is not taken. */
|
|
410
|
+
const pairValues = (text, breaks) => text.split(breaks).flatMap((pair) => {
|
|
411
|
+
const at = pair.indexOf("=");
|
|
412
|
+
if (at <= 0)
|
|
413
|
+
return [];
|
|
414
|
+
const name = pair.slice(0, at).split(/[/?#:]/).at(-1) ?? "";
|
|
415
|
+
const inner = pair.slice(at + 1).replace(/^(["'])(.*)\1$/, "$2");
|
|
416
|
+
return /[^=]/.test(inner) && credentialNamed(decoded(name) ?? name) ? [inner, decoded(inner) ?? inner] : [];
|
|
417
|
+
});
|
|
418
|
+
/** The credentials a header value carries inside it, the union of two reads over the whole value as written: the value
|
|
419
|
+
* of each `name=value` pair whose name says it is a credential (pairValues, at each of PAIR_BREAK, PIECE_BREAK and
|
|
420
|
+
* WHOLE_BREAK: a cookie's `session=<token>`, sentry's
|
|
421
|
+
* `sentry_key=<key>`, a path's `;jsessionid=<id>`, a URL query's or fragment's `session=` or `access_token=`), and the
|
|
422
|
+
* user, password and key parameters of each URL in it (urlSpans, urlCredentials: a DSN's `https://<key>@host/1`, a
|
|
423
|
+
* relay's whole `user:pa;ss`). A URL only adds readings: the pair read covers its text too. A value that escapes its
|
|
424
|
+
* slashes (JSON's `https:\/\/`) is read again with them plain, and what that finds is held both ways. A pair named like
|
|
425
|
+
* no credential (`theme=dark`) is not taken. */
|
|
426
|
+
const innerCredentials = (value) => {
|
|
427
|
+
const read = (text) => {
|
|
428
|
+
const queriesRead = { spans: new Set(), left: QUERY_BUDGET };
|
|
429
|
+
return [
|
|
430
|
+
...pairValues(text, PAIR_BREAK),
|
|
431
|
+
...pairValues(text, PIECE_BREAK),
|
|
432
|
+
...pairValues(text, WHOLE_BREAK),
|
|
433
|
+
...urlSpans(text).flatMap(({ start, end }) => urlCredentials(text, start, end, queriesRead)),
|
|
434
|
+
];
|
|
435
|
+
};
|
|
436
|
+
if (!value.includes("\\/"))
|
|
437
|
+
return read(value);
|
|
438
|
+
return [...read(value), ...read(value.replace(/\\\//g, "/")).flatMap((found) => [found, found.replace(/\//g, "\\/")])];
|
|
439
|
+
};
|
|
440
|
+
/** The OTLP exporter's header values `env` names (OTEL_EXPORTER_OTLP_HEADERS and OTEL_EXPORTER_OTLP_TRACES_HEADERS: a
|
|
441
|
+
* tracing backend's key is one), at any length (keptSecrets floors them for the held list; otlpHeaderCut does not),
|
|
442
|
+
* but those of a header OTLP_PLAIN_HEADERS names, and, for the held list (`held`), those OTLP_CUT_ONLY_HEADERS names.
|
|
443
|
+
* Each is held as written (percent-encoded) and as sent (decoded); and as the SDK reads the same variable, which it
|
|
444
|
+
* merges under ours (`headers`, tracer.ts exporterConfig) and which drops a `;` and what follows it, so a part ours
|
|
445
|
+
* can't decode still sends that much; and, under a credential-named header (credentialNamed) or after a known auth
|
|
446
|
+
* scheme (KNOWN_SCHEME), each of those without its first word (AUTH_SCHEME), the credential alone, as an error may
|
|
447
|
+
* quote it. For the held list, any other header's value is held whole, never its tail alone; for the cut (`held`
|
|
448
|
+
* false), every value is taken without any first word too, since cutting more of the tracer's own lines costs
|
|
449
|
+
* nothing. Under any header, each credential a value carries inside it (innerCredentials: a credential-named
|
|
450
|
+
* `name=value` pair's value, a URL's user, password and key parameters) is taken alone too. A part whose name can't
|
|
451
|
+
* be decoded is held. Commas split the variable, so a comma inside a value must be written `%2C`. */
|
|
452
|
+
export const otlpHeaderValues = (env, held) => [env.OTEL_EXPORTER_OTLP_HEADERS, env.OTEL_EXPORTER_OTLP_TRACES_HEADERS].flatMap((text) => (text ?? "").split(",").flatMap((part) => {
|
|
453
|
+
const at = part.indexOf("=");
|
|
454
|
+
if (at <= 0)
|
|
455
|
+
return [];
|
|
456
|
+
const rawName = part.slice(0, at).trim();
|
|
457
|
+
const name = decoded(rawName) ?? rawName;
|
|
458
|
+
if (OTLP_PLAIN_HEADERS.includes(name.toLowerCase()))
|
|
459
|
+
return [];
|
|
460
|
+
if (held && OTLP_CUT_ONLY_HEADERS.includes(name.toLowerCase()))
|
|
461
|
+
return [];
|
|
462
|
+
const written = part.slice(at + 1).trim();
|
|
463
|
+
const property = written.indexOf(";");
|
|
464
|
+
const forms = [written, ...(property >= 0 ? [written.slice(0, property).trim()] : [])].flatMap((value) => [value, decoded(value) ?? value]);
|
|
465
|
+
const named = credentialNamed(name);
|
|
466
|
+
return forms.flatMap((value) => [value, ...(!held || named || KNOWN_SCHEME.test(value) ? [value.replace(AUTH_SCHEME, "")] : []), ...innerCredentials(value)]);
|
|
467
|
+
})).filter((value) => value.trim() !== "");
|
|
468
|
+
/** The credentials the OTLP endpoints `env` names write into their URLs (OTEL_EXPORTER_OTLP_ENDPOINT and
|
|
469
|
+
* OTEL_EXPORTER_OTLP_TRACES_ENDPOINT; urlCredentials): a user and password, and the value of each query parameter
|
|
470
|
+
* whose name says it is one, each as written and decoded. An exporter's error may quote the URL it posted to. */
|
|
471
|
+
export const otlpEndpointValues = (env) => [env.OTEL_EXPORTER_OTLP_ENDPOINT, env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT].flatMap((text) => urlCredentials((text ?? "").trim())).filter((value) => value.trim() !== "");
|
|
472
|
+
/** Every OTLP credential `env` names: its header values (otlpHeaderValues, a cut-only header's only when not `held`) and
|
|
473
|
+
* its endpoints' (otlpEndpointValues). */
|
|
474
|
+
const otlpValues = (env, held) => [...otlpHeaderValues(env, held), ...otlpEndpointValues(env)];
|
|
475
|
+
/** `values` and every OTLP credential `env` names (otlpValues: its header values but a cut-only header's, its
|
|
476
|
+
* endpoints' user, password and key parameters) as the held list keeps them: each MIN_SECRET long or more, whitespace
|
|
477
|
+
* aside. A shorter one matches too much text by chance to be held, and some readers of the list have no floor of their
|
|
478
|
+
* own (a number equal to a held value is withheld, key-refusal.ts heldNumber; a source capture refuses a path or file
|
|
479
|
+
* holding one), so a short header value is on no held list, nor is a dataset's or tenant's (OTLP_CUT_ONLY_HEADERS):
|
|
480
|
+
* otlpHeaderCut alone cuts it, from the tracer's own lines. */
|
|
481
|
+
export const keptSecrets = (values, env) => [...new Set([...values, ...otlpValues(env, true)])].filter((value) => value.replace(/\s+/g, "").length >= MIN_SECRET);
|
|
482
|
+
const CUT = "[redacted]";
|
|
483
|
+
/** Text with every OTLP credential `env` names (otlpValues: its header values, a cut-only header's too, its endpoints'
|
|
484
|
+
* user, password and key parameters) put as "[redacted]", at any length: the one cut without the MIN_SECRET floor.
|
|
485
|
+
* The tracer's own lines take it, after the runner's redactor (otel/tracer.ts saidOf), since they are where one can
|
|
486
|
+
* 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.
|
|
487
|
+
* Every other cut keeps the floor on purpose: a needle of a few characters in every redactor would cut ordinary text
|
|
488
|
+
* everywhere. Each value is matched exactly as held, and the cut is the union of every place each one stands: at each
|
|
489
|
+
* character, the longest value (or a "[redacted]" already in the text) starting there is found without being taken,
|
|
490
|
+
* so a value starting inside another is found too, and the places, which come in order, are merged where they overlap
|
|
491
|
+
* or touch and each run cut as one "[redacted]". So no character of any held value is left, whichever of two
|
|
492
|
+
* overlapping values starts first or is longer (the SDK's reading `api_key=<key>` and a key `<key;rest>` quoted as
|
|
493
|
+
* `api_key=<key;rest>`), and a "[redacted]" already in the text is left whole. One pass over the text, one merge. */
|
|
494
|
+
export function otlpHeaderCut(env) {
|
|
495
|
+
const values = [...new Set([CUT, ...otlpValues(env, false)])].sort((a, b) => b.length - a.length);
|
|
496
|
+
if (values.length === 1)
|
|
497
|
+
return (text) => text;
|
|
498
|
+
const needle = new RegExp(`(?=(${values.map((value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")}))`, "g");
|
|
499
|
+
return (text) => {
|
|
500
|
+
if (!text)
|
|
501
|
+
return text;
|
|
502
|
+
const spans = [];
|
|
503
|
+
for (const found of text.matchAll(needle)) {
|
|
504
|
+
const [start, end] = [found.index, found.index + found[1].length];
|
|
505
|
+
const last = spans.at(-1);
|
|
506
|
+
if (last && start <= last[1])
|
|
507
|
+
last[1] = Math.max(last[1], end);
|
|
508
|
+
else
|
|
509
|
+
spans.push([start, end]);
|
|
510
|
+
}
|
|
511
|
+
let out = "";
|
|
512
|
+
let from = 0;
|
|
513
|
+
for (const [start, end] of spans) {
|
|
514
|
+
out += `${text.slice(from, start)}${CUT}`;
|
|
515
|
+
from = end;
|
|
516
|
+
}
|
|
517
|
+
return out + text.slice(from);
|
|
518
|
+
};
|
|
519
|
+
}
|
|
230
520
|
/** Every header value of `credentials`: what a secret scan refuses. */
|
|
231
521
|
export const mcpSecretValues = (credentials) => Object.values(credentials).flatMap((server) => Object.values(server.headers ?? {})).flatMap((value) => [value, value.replace(/^Bearer\s+/i, "")]);
|
|
232
522
|
/** The saved sign-in this run's process was handed over its pipe, if any: read by the browser tool alone. */
|
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. */
|
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. */
|
|
@@ -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.
|
package/dist/server.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { DEFAULT_PORT } from "./host.js";
|
|
|
7
7
|
import { type LearningMode } from "./learning.js";
|
|
8
8
|
import { type Place } from "./place.js";
|
|
9
9
|
import { type ApiToken } from "./api-token.js";
|
|
10
|
+
import { type CutScrub } from "./run-export.js";
|
|
10
11
|
import { type Store } from "./store/index.js";
|
|
11
12
|
import { type BoxOffer, type ContainerFacts } from "./place-offers.js";
|
|
12
13
|
import { type Wait } from "./docker-host-addresses.js";
|
|
@@ -40,7 +41,7 @@ export type ServeOptions = {
|
|
|
40
41
|
openSetup?: boolean;
|
|
41
42
|
/** With accounts: the address people open (AGENTRUN_PUBLIC_URL), which the printed setup link uses. */
|
|
42
43
|
publicUrl?: string;
|
|
43
|
-
/** The home whose Claude Code, Codex and
|
|
44
|
+
/** The home whose Claude Code, Codex, pi, OpenCode and Copilot CLI sessions setup offers to import and GET /v2/wrapped reads (default this
|
|
44
45
|
* user's), and the temp directory whose projects setup leaves out (default the OS's). */
|
|
45
46
|
sessionsHome?: {
|
|
46
47
|
home: string;
|
|
@@ -182,8 +183,8 @@ export type ServeOptions = {
|
|
|
182
183
|
/** Under `faux`: the directory a Docker computer's computerd build is looked for in at the start (the computer
|
|
183
184
|
* package's dockerDaemonOf), in place of that package's own build; absent, a faux server doesn't check for one. */
|
|
184
185
|
fauxDaemonDir?: string;
|
|
185
|
-
/** For tests:
|
|
186
|
-
*
|
|
186
|
+
/** For tests: where Docker's start probe takes this server to be (place-offers.ts containerOf), in place of its own
|
|
187
|
+
* marks. The test support's serve() pins a host, so the suite reads the same words in a container. */
|
|
187
188
|
probeContainer?: ContainerFacts;
|
|
188
189
|
/** For tests: the wait before each read again of the Docker host's addresses after the start's failed
|
|
189
190
|
* (docker-host-addresses.ts retryHostAddresses), in place of the backoff's timer. */
|
|
@@ -198,6 +199,9 @@ export type ServeOptions = {
|
|
|
198
199
|
/** How often the runs' listings' builder looks again when it found nothing to build (run-listing.ts; default
|
|
199
200
|
* LISTER_IDLE_MS). `Infinity`: it builds only when Serve.listingSettled asks, so a test reads what a list builds alone. */
|
|
200
201
|
listerIdleMs?: number;
|
|
202
|
+
/** How often a timeline page that waits (`wait_ms`) reads the store again while nothing changed (default 1000 ms,
|
|
203
|
+
* run-reads-over-store.ts). A test's server reads sooner, so a change is served without the rest of a second's wait. */
|
|
204
|
+
timelinePollMs?: number;
|
|
201
205
|
/** No runner beside this server in its process (the CLI's --no-runner, the image's server-and-runner): a paired
|
|
202
206
|
* computer's socket is held here while no run holds it, and relayed to the runner that holds a run of it
|
|
203
207
|
* (workspace/paired-route.ts); while no runner relays, a pairing code, the pair answer and each paired computer say no
|
|
@@ -206,6 +210,8 @@ export type ServeOptions = {
|
|
|
206
210
|
/** For tests: the attach socket's liveness timing (computer-attach.ts AttachTiming), a relayed dial's included; the
|
|
207
211
|
* protocol's by default. */
|
|
208
212
|
attachTiming?: AttachTiming;
|
|
213
|
+
/** For tests: how long the stop waits for a ChatGPT sign-in it cancelled to end (PLAN_CLOSE_MS by default). */
|
|
214
|
+
planCloseMs?: number;
|
|
209
215
|
/** The most runs at once (default: AGENTRUN_MAX_RUNS, else as many pi runs as this host's memory holds: host.ts),
|
|
210
216
|
* beside the memory each run's harness reserves; over either, 429. */
|
|
211
217
|
maxRuns?: number;
|
|
@@ -248,6 +254,8 @@ export type ServeOptions = {
|
|
|
248
254
|
* command row is written, with the run's id and the message's text, so a test can hold a message at the run's door while
|
|
249
255
|
* the run's state changes under it (runs-over-store.ts message). */
|
|
250
256
|
beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
|
|
257
|
+
/** A test's seam: the scrubber GET /runs/{id}/export cuts with (run-export.ts), in place of secret-cut.ts scrub. */
|
|
258
|
+
shareScrub?: CutScrub;
|
|
251
259
|
/** A test's seam: step 2 of DELETE /agents/{id} (agent-delete.ts) in place of the learning module's deleteLearning over
|
|
252
260
|
* the agent's learning folder (learn/delete.ts), the server's own. */
|
|
253
261
|
deleteLearning?: DeleteLearning;
|
|
@@ -477,6 +485,7 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
|
|
|
477
485
|
missing?: string[] | undefined;
|
|
478
486
|
reason?: string | undefined;
|
|
479
487
|
available: boolean;
|
|
488
|
+
runner_only?: boolean | undefined;
|
|
480
489
|
sandbox_only?: boolean | undefined;
|
|
481
490
|
call_only?: boolean | undefined;
|
|
482
491
|
nodes: boolean;
|
|
@@ -514,6 +523,7 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
|
|
|
514
523
|
missing?: string[] | undefined;
|
|
515
524
|
reason?: string | undefined;
|
|
516
525
|
available: boolean;
|
|
526
|
+
runner_only?: boolean | undefined;
|
|
517
527
|
sandbox_only?: boolean | undefined;
|
|
518
528
|
call_only?: boolean | undefined;
|
|
519
529
|
nodes: boolean;
|
|
@@ -826,6 +836,7 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
|
|
|
826
836
|
missing?: string[] | undefined;
|
|
827
837
|
reason?: string | undefined;
|
|
828
838
|
available: boolean;
|
|
839
|
+
runner_only?: boolean | undefined;
|
|
829
840
|
sandbox_only?: boolean | undefined;
|
|
830
841
|
call_only?: boolean | undefined;
|
|
831
842
|
nodes: boolean;
|
|
@@ -863,6 +874,7 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
|
|
|
863
874
|
missing?: string[] | undefined;
|
|
864
875
|
reason?: string | undefined;
|
|
865
876
|
available: boolean;
|
|
877
|
+
runner_only?: boolean | undefined;
|
|
866
878
|
sandbox_only?: boolean | undefined;
|
|
867
879
|
call_only?: boolean | undefined;
|
|
868
880
|
nodes: boolean;
|