@parcha/agentrun-serve 0.1.0-beta.57 → 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 +376 -0
- package/README.md +393 -118
- 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/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +7 -5
- package/dist/box-paths.js +12 -8
- 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 +121 -0
- package/dist/claude-login-token.js +797 -0
- package/dist/claude-login.d.ts +119 -34
- package/dist/claude-login.js +551 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +325 -328
- 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 +40 -19
- package/dist/computer-attach.js +326 -62
- 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 +12 -11
- package/dist/computers.js +11 -8
- 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.d.ts +25 -4
- package/dist/dial-relay.js +139 -5
- 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 +13 -5
- package/dist/env-switch.js +24 -6
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +12 -4
- package/dist/fal-price.js +110 -26
- 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 +173 -0
- package/dist/learn/ledger.js +225 -0
- package/dist/learn/promote.d.ts +82 -39
- package/dist/learn/promote.js +61 -66
- 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 +40 -21
- package/dist/learning-cost.js +30 -21
- 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 +9 -0
- package/dist/live-reach.js +9 -0
- package/dist/mcp-api-only-origins.d.ts +23 -3
- package/dist/mcp-api-only-origins.js +57 -17
- 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/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +234 -61
- 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 +59 -34
- package/dist/place-offers.js +100 -58
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +5 -4
- package/dist/provider.js +26 -13
- 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-learning-served.d.ts +2 -2
- 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/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +97 -63
- package/dist/runner/adapter-run-spec.d.ts +34 -14
- package/dist/runner/adapter-run-spec.js +120 -75
- 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.d.ts +9 -2
- package/dist/runner/beside.js +29 -13
- package/dist/runner/claim-secrets.d.ts +27 -18
- package/dist/runner/claim-secrets.js +61 -47
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +93 -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 +19 -4
- 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.d.ts +11 -6
- package/dist/runner/main.js +24 -18
- package/dist/runner/mcp-claim.js +24 -7
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- 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 +11 -4
- package/dist/runner/presence.js +11 -6
- 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/reflect-hook.js +1 -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 +38 -12
- package/dist/runner/run-child-host.js +231 -83
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +5 -3
- package/dist/runner/runner.js +14 -10
- package/dist/runner/save-slots.js +2 -1
- 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/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +138 -37
- package/dist/runner/workflow-first.js +230 -99
- package/dist/runner/workflow-spec.js +2 -2
- 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 +33 -10
- package/dist/server.js +454 -136
- 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/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- 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/0028_learning_ledger.sql +44 -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 +44 -4
- package/dist/store/schema.js +111 -11
- 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 +19 -2
- package/dist/store/sqlite/run-patch.js +67 -2
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +177 -32
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +74 -25
- 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 +102 -136
- package/dist/store-reads/learning.js +251 -302
- 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 +91 -9
- package/dist/template-eval.js +448 -105
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- 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 +14 -14
- package/dist/timeline/web-calls.js +18 -30
- 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.d.ts +4 -9
- package/dist/web-save.js +27 -55
- 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 +38 -11
- package/dist/workspace/attached-computers.js +81 -16
- package/dist/workspace/computer-deps.d.ts +29 -7
- package/dist/workspace/computer-deps.js +36 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +166 -57
- 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.d.ts +91 -0
- package/dist/workspace/paired-route.js +152 -0
- 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/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +25 -9
- package/dist/console/assets/backend-DVhHzJX2.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-okP-y8PK.js +0 -747
|
@@ -25,16 +25,6 @@ export declare function loadImported(deps: Pick<TemplateImportDeps, "registry" |
|
|
|
25
25
|
/** The uploads served here whose row the store no longer keeps (an agent's purge removed it: Agents.purge), no longer
|
|
26
26
|
* served. Only the package read before the store is removed, so an upload put in meanwhile stays served. */
|
|
27
27
|
export declare function dropRemovedUploads(deps: Pick<TemplateImportDeps, "registry" | "store">): Promise<void>;
|
|
28
|
-
/** An upload: its files checked as an import's are, its id `upload:<name>` (its manifest's name), its sha the package's
|
|
29
|
-
* sha256; a dry run answers it, storing nothing; else it is stored and served (201), in place of the one of its name. */
|
|
30
|
-
/** An upload's files ({files} of POST /v2/templates/import) checked as the import checks them, storing nothing: the
|
|
31
|
-
* package's bytes by path (each hidden path left out) and the package read from them; else the refusal the route answers
|
|
32
|
-
* (422). `agentrun deploy` runs this on the body it is about to send (agentrun-serve check-upload), so a package a target
|
|
33
|
-
* refuses is refused before anything is sent, by this one check. */
|
|
34
|
-
export declare function checkUpload(raw: unknown): {
|
|
35
|
-
files: Map<string, Buffer>;
|
|
36
|
-
pkg: Package;
|
|
37
|
-
};
|
|
38
28
|
/** POST /v2/templates/import: the package read at its source's commit and checked; a dry run answers it, storing nothing;
|
|
39
29
|
* else it is stored and served (201), in place of the one under its id. `signal` ends the read (the request's). An
|
|
40
30
|
* upload ({files}) is uploadTemplate's. */
|
package/dist/template-import.js
CHANGED
|
@@ -163,23 +163,18 @@ function bodyOf(body, apiOnly) {
|
|
|
163
163
|
}
|
|
164
164
|
/** An upload: its files checked as an import's are, its id `upload:<name>` (its manifest's name), its sha the package's
|
|
165
165
|
* sha256; a dry run answers it, storing nothing; else it is stored and served (201), in place of the one of its name. */
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
* refuses is refused before anything is sent, by this one check. */
|
|
170
|
-
export function checkUpload(raw) {
|
|
166
|
+
async function uploadTemplate(deps, raw, dryRun) {
|
|
167
|
+
let pkg;
|
|
168
|
+
let files;
|
|
171
169
|
try {
|
|
172
|
-
|
|
170
|
+
files = uploadFiles(raw);
|
|
173
171
|
const name = manifestOf(files.get(MANIFEST)?.toString("utf8") ?? "")?.name;
|
|
174
172
|
const id = `${UPLOAD_PREFIX}${typeof name === "string" ? name : ""}`;
|
|
175
|
-
|
|
173
|
+
pkg = importedPackage(id, { source: id, sha: uploadSha(files), publisher: "" }, files);
|
|
176
174
|
}
|
|
177
175
|
catch (error) {
|
|
178
176
|
refusalOf(error);
|
|
179
177
|
}
|
|
180
|
-
}
|
|
181
|
-
async function uploadTemplate(deps, raw, dryRun) {
|
|
182
|
-
const { files, pkg } = checkUpload(raw);
|
|
183
178
|
const replaced = deps.registry.get(pkg.id)?.origin?.sha ?? null;
|
|
184
179
|
if (dryRun)
|
|
185
180
|
return { status: 200, pkg, trusted: true, replaced };
|
|
@@ -71,7 +71,7 @@ export declare function foldLabel(tool: string, calls: readonly {
|
|
|
71
71
|
path?: (path: string) => string;
|
|
72
72
|
}): string;
|
|
73
73
|
/** The input worth showing: the base keys first, then the browser and file ones, and last the app a computer's look or act
|
|
74
|
-
* names (never what an act types: its steps; nor a codemode script, which can hold it). */
|
|
74
|
+
* names (never what an act types: its steps; nor a codemode script, which can hold it), then a search's objective. */
|
|
75
75
|
export declare function inputPreview(args: Obj, max: number): string | null;
|
|
76
76
|
/** Files a finished call put in the workspace. */
|
|
77
77
|
export declare function savedPaths(tool: string, args: Obj, result: ToolResultView): string[];
|
package/dist/timeline/labels.js
CHANGED
|
@@ -68,9 +68,9 @@ export function foldLabel(tool, calls, options = {}) {
|
|
|
68
68
|
return subjects.length ? `${head}: ${list(subjects)}` : head;
|
|
69
69
|
}
|
|
70
70
|
/** The input worth showing: the base keys first, then the browser and file ones, and last the app a computer's look or act
|
|
71
|
-
* names (never what an act types: its steps; nor a codemode script, which can hold it). */
|
|
71
|
+
* names (never what an act types: its steps; nor a codemode script, which can hold it), then a search's objective. */
|
|
72
72
|
export function inputPreview(args, max) {
|
|
73
|
-
for (const key of ["description", "command", "query", "file_path", "url", "path", "code", "app"]) {
|
|
73
|
+
for (const key of ["description", "command", "query", "file_path", "url", "path", "code", "app", "objective"]) {
|
|
74
74
|
const value = str(args[key]);
|
|
75
75
|
if (value)
|
|
76
76
|
return cut(scrubUrls(value), max);
|
|
@@ -150,7 +150,8 @@ const fromHost = (a) => {
|
|
|
150
150
|
registerLabel("web_save", (a, result) => `${unfetched(result) ? "Tried to save" : "Saved"} ${savedAt(a, result)}${fromHost(a)}`, { many: (n) => `Saved ${n} files from the web`, subject: (input) => input ?? undefined }, { name: "Save files from the web" });
|
|
151
151
|
registerOutcome("web_save", fetchOutcome);
|
|
152
152
|
registerLabel("web_search", (a) => {
|
|
153
|
-
|
|
153
|
+
// Its first keyword query, else its objective, else the deprecated query alone.
|
|
154
|
+
const query = (Array.isArray(a.queries) ? a.queries.map(str).find(Boolean) : undefined) ?? str(a.objective) ?? str(a.query);
|
|
154
155
|
return query ? `Searched the web for "${cut(scrubUrls(query), 60)}"` : "Searched the web";
|
|
155
156
|
}, { many: (n) => `Searched the web ${n} times`, subject: (input) => (input ? `"${cut(input, 40)}"` : undefined) }, { name: "Search the web" });
|
|
156
157
|
// web_search answers its results and a line asking for citations, or `{error}` when the search gave no answer: failed.
|
|
@@ -53,7 +53,8 @@ export type TimelineEvent = {
|
|
|
53
53
|
paused?: true;
|
|
54
54
|
/** `true` on the `tool_result` row of a call refused before it ran (its host's mark, CALL_REFUSED: a gate's deny, a
|
|
55
55
|
* person's, a call held for an approval the run ended or stopped without): it never ran, so it never failed, though
|
|
56
|
-
* `tool_status` stays `failed` (it did not do its work). A client shows it apart from a call that ran and failed.
|
|
56
|
+
* `tool_status` stays `failed` (it did not do its work). A client shows it apart from a call that ran and failed. Also
|
|
57
|
+
* on a script's (codemode) or a tools_call's row that stopped at such a call (its host tool answered `refused`). */
|
|
57
58
|
refused?: true;
|
|
58
59
|
/** On the usage row, the run's cost. On a paid tool's charge row (a `phase` naming the tool), that charge alone. On a
|
|
59
60
|
* browser call's `tool_use` row, every browser charge booked under that call (BROWSER_CHARGE): its session's time
|
|
@@ -92,8 +93,10 @@ export type TimelineEvent = {
|
|
|
92
93
|
* counts the calls past the record's bound. This projector writes none (store-reads/journal.ts withComputerCalls). */
|
|
93
94
|
computer_calls?: readonly ComputerCallRow[];
|
|
94
95
|
computer_calls_dropped?: number;
|
|
95
|
-
/** On a `tool_use` row of a timeline read with `calls` (TimelineOptions): the call's arguments, each string as
|
|
96
|
-
* makes it
|
|
96
|
+
/** On a `tool_use` row of a timeline read with `calls` (TimelineOptions): the call's arguments, each string as
|
|
97
|
+
* `calls.input` makes it of the arguments as the call came (else as the rows show them), its names and values
|
|
98
|
+
* together cut at `calls.result` characters (inputShown), the bound its output has (a grader reads a long write whole: an issue body, a note, a
|
|
99
|
+
* posted digest). Absent when `holds` withholds them whole. */
|
|
97
100
|
tool_input?: Obj;
|
|
98
101
|
/** On a `tool_result` row of a timeline read with `calls`: the call's output whole to `calls.result` characters (its
|
|
99
102
|
* head past that), as `calls.redact` makes it, its URLs' query values elided as the preview's are; a web call's every
|
|
@@ -133,7 +136,8 @@ export declare const CAPS: {
|
|
|
133
136
|
* web_search's every result keeps its url, title and published date, and a web_fetch its url and title, their snippets
|
|
134
137
|
* and page text cut to fit (web-calls.ts), past this only when its urls alone pass it. */
|
|
135
138
|
export declare const CALL_RESULT_CHARS = 120000;
|
|
136
|
-
/** The most rows a `calls=whole` timeline page holds, and its default: each row's result
|
|
139
|
+
/** The most rows a `calls=whole` timeline page holds, and its default: each row's result, or the names, values and
|
|
140
|
+
* brackets of its call's arguments together (tool_input, inputShown), may be CALL_RESULT_CHARS long. */
|
|
137
141
|
export declare const CALLS_PAGE_ROWS = 100;
|
|
138
142
|
/** A host's marks of a model request: as it leaves (written before it does), and as its stream ends aborted. A request
|
|
139
143
|
* that answered or failed has a `pi.assistant` entry; one aborted before its first content has none; a start with no
|
|
@@ -282,22 +286,30 @@ export type TimelineOptions = {
|
|
|
282
286
|
* this for the full protection: a key a stream wraps with only part of its tail streamed is covered by a held-back
|
|
283
287
|
* tail as long as a key, not by the word holdback. */
|
|
284
288
|
redactLive?: (text: string) => string;
|
|
289
|
+
/** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole, whose join view reads a
|
|
290
|
+
* JSON text's strings joined, property names among them). Read in every read, with `calls` or without, before any
|
|
291
|
+
* row shows what it reads: a call's arguments, each string of which `redact` reads on its own, are read with it as
|
|
292
|
+
* their JSON (argsOf), and a web call's output as it came (web-calls.ts webHeld). A value split across two of their
|
|
293
|
+
* strings, or across a property name and its value, which `redact` and `calls.redact` never read side by side,
|
|
294
|
+
* withholds them whole: the call's rows read it as one with no arguments, or its output's preview, summary and a
|
|
295
|
+
* `calls` read's text read "[redacted]". Default: none withheld. */
|
|
296
|
+
holds?: (text: string) => boolean;
|
|
285
297
|
/** For a reader that grades the run (a template eval): each `tool_use` row carries its call's arguments whole
|
|
286
298
|
* (`tool_input`), and each `tool_result` row the head of its output to `result` characters (`tool_result_text`; a
|
|
287
299
|
* web call's every url, each of its strings redacted on its own), made safe by `redact`, a redactor that reads that
|
|
288
300
|
* far (the rows' own `redact` stops at the head a row shows).
|
|
289
|
-
* Without `redact`, the rows' own. `
|
|
290
|
-
*
|
|
301
|
+
* Without `redact`, the rows' own. `input`: each string of a call's arguments as `tool_input` shows it, read from the
|
|
302
|
+
* arguments as the call came, its head of `shown` characters made safe (the caller cuts it there). The rows' own
|
|
303
|
+
* `redact` stops at the head a row shows, so without `input`, `tool_input` reads the arguments as the rows show them,
|
|
304
|
+
* each string no longer than that head. Arguments `holds` withholds whole have no `tool_input` either way: it reads
|
|
305
|
+
* them as the call came. `held`: whether a number in the arguments shows a held value (a key that is all digits);
|
|
306
|
+
* such a number is shown as "[redacted]". */
|
|
291
307
|
calls?: {
|
|
292
308
|
result: number;
|
|
293
309
|
redact?: (text: string) => string;
|
|
310
|
+
input?: (text: string, shown: number) => string;
|
|
294
311
|
held?: (value: number | bigint) => boolean;
|
|
295
312
|
};
|
|
296
|
-
/** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole). A web call's output is read
|
|
297
|
-
* through it joined, its JSON's strings as they came (web-calls.ts webHeld), before any of its rows shows any of it: a
|
|
298
|
-
* value split across two of its strings, which `redact` and `calls.redact` never read side by side, withholds the
|
|
299
|
-
* output, so its preview, its summary and a `calls` read's text read "[redacted]". Default: none withheld. */
|
|
300
|
-
holds?: (text: string) => boolean;
|
|
301
313
|
};
|
|
302
314
|
/** A tool's calls in a run, and how many failed. */
|
|
303
315
|
export type ToolMetrics = {
|
|
@@ -18,7 +18,8 @@ export const CAPS = { summary: 500, preview: 500, text: 2000, thinking: 100 };
|
|
|
18
18
|
* web_search's every result keeps its url, title and published date, and a web_fetch its url and title, their snippets
|
|
19
19
|
* and page text cut to fit (web-calls.ts), past this only when its urls alone pass it. */
|
|
20
20
|
export const CALL_RESULT_CHARS = 120_000;
|
|
21
|
-
/** The most rows a `calls=whole` timeline page holds, and its default: each row's result
|
|
21
|
+
/** The most rows a `calls=whole` timeline page holds, and its default: each row's result, or the names, values and
|
|
22
|
+
* brackets of its call's arguments together (tool_input, inputShown), may be CALL_RESULT_CHARS long. */
|
|
22
23
|
export const CALLS_PAGE_ROWS = 100;
|
|
23
24
|
/** A host's marks of a model request: as it leaves (written before it does), and as its stream ends aborted. A request
|
|
24
25
|
* that answered or failed has a `pi.assistant` entry; one aborted before its first content has none; a start with no
|
|
@@ -193,13 +194,14 @@ const tokenCount = (value) => (typeof value === "number" && Number.isSafeInteger
|
|
|
193
194
|
/** A usage's tokens: undefined unless it has an input and an output count (a cache count it omits is 0), and unless it
|
|
194
195
|
* has some input. A request that reached a model always sent some, so a usage with none is a writer's zeros for a
|
|
195
196
|
* request it did not measure (an imported transcript's, a harness answer's written with no booking): unknown, never 0.
|
|
196
|
-
* `failed`: a failed request's counts are taken as they are, as its cost is
|
|
197
|
+
* `failed`: a failed request's counts are taken as they are, as its cost is; so are a `folded` usage's (an imported
|
|
198
|
+
* request whose tokens its source counted in a later request of the session). */
|
|
197
199
|
function tokensOf(usage, failed = false) {
|
|
198
200
|
const u = obj(usage);
|
|
199
201
|
const [input, output, cacheRead, cacheWrite] = [tokenCount(u?.input), tokenCount(u?.output), u?.cacheRead === undefined ? 0 : tokenCount(u.cacheRead), u?.cacheWrite === undefined ? 0 : tokenCount(u.cacheWrite)];
|
|
200
202
|
if (input === undefined || output === undefined || cacheRead === undefined || cacheWrite === undefined)
|
|
201
203
|
return undefined;
|
|
202
|
-
return failed || input + cacheRead + cacheWrite > 0 ? { input, cacheRead, cacheWrite, output } : undefined;
|
|
204
|
+
return failed || u?.folded === true || input + cacheRead + cacheWrite > 0 ? { input, cacheRead, cacheWrite, output } : undefined;
|
|
203
205
|
}
|
|
204
206
|
/** A run's model requests as its entries mark them: how many, what they cost and the tokens they used. The usage row
|
|
205
207
|
* and runMetricsOf count through it. `push` says what an entry was: an answer (a `pi.assistant` that is a request), a
|
|
@@ -285,8 +287,9 @@ function createMeter() {
|
|
|
285
287
|
const message = entry.model?.[0];
|
|
286
288
|
const data = obj(entry.data);
|
|
287
289
|
const summaryAnswered = compactionAnswers(entry, sideSummaries);
|
|
288
|
-
if (entry.kind === "pi.assistant" && entry.recordedCall && message) {
|
|
290
|
+
if (entry.kind === "pi.assistant" && (entry.recordedCall || data?.mirrors !== undefined) && message) {
|
|
289
291
|
// A call the loop's record kept (a CLI's, or one a tool of pi's nested): shown as an answer's call, never a request.
|
|
292
|
+
// So is an imported answer whose request another run counts (`mirrors`: an OpenCode request Claude Code also wrote).
|
|
290
293
|
return "call";
|
|
291
294
|
}
|
|
292
295
|
else if (entry.kind === REQUEST_REFUSED) {
|
|
@@ -506,21 +509,70 @@ const blocksOf = (message) => {
|
|
|
506
509
|
const textOf = (message, type = "text", field = "text") => blocksOf(message).filter((block) => block.type === type).map((block) => str(block[field]) ?? "").join("\n").trim();
|
|
507
510
|
/** Every string a row shows goes through here: a URL keeps its origin, path and query keys, then the text is cut. */
|
|
508
511
|
const clean = (text, max) => cut(scrubUrls(text), max);
|
|
509
|
-
/** A call's arguments as `tool_input` carries them,
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
const
|
|
523
|
-
|
|
512
|
+
/** A call's arguments as `tool_input` carries them, at most `budget` characters a row, taken in order: each property
|
|
513
|
+
* name as `redact` makes it, as only this field shows them, each string as `read` makes it of the head it is given,
|
|
514
|
+
* each number, boolean or null as its text (a number `held` names as "[redacted]"), and each array or object its two
|
|
515
|
+
* brackets. Every name and value costs at least one character. The name or string that reaches the budget is cut
|
|
516
|
+
* there, and a number, boolean or null that would pass it shows as "..."; an array or object then ends with one "..."
|
|
517
|
+
* (an item, or a "..." name), and a value reached past it shows as "...", unread, however much it holds. So a row's
|
|
518
|
+
* names, values and brackets come to at most `budget` characters, past which only a "..." for the value it stopped in
|
|
519
|
+
* and one for each array or object still open, whatever its call holds. An object two of whose names come out the
|
|
520
|
+
* same is withheld whole, as "[redacted]", never one value merged over the other. */
|
|
521
|
+
const inputShown = (args, budget, read, redact = (text) => text, held = () => false) => {
|
|
522
|
+
let left = budget;
|
|
523
|
+
const spend = (size) => (left -= Math.max(1, size));
|
|
524
|
+
// A number, boolean or null shows whole or as "...": a cut one would read as another value.
|
|
525
|
+
const scalar = (out) => {
|
|
526
|
+
const text = String(out);
|
|
527
|
+
if (text.length > left) {
|
|
528
|
+
left = 0;
|
|
529
|
+
return "...";
|
|
530
|
+
}
|
|
531
|
+
spend(text.length);
|
|
532
|
+
return out;
|
|
533
|
+
};
|
|
534
|
+
const shown = (value) => {
|
|
535
|
+
if (left <= 3)
|
|
536
|
+
return "...";
|
|
537
|
+
if (typeof value === "string") {
|
|
538
|
+
const text = cut(read(value, left), left);
|
|
539
|
+
spend(text.length);
|
|
540
|
+
return text;
|
|
541
|
+
}
|
|
542
|
+
if (typeof value === "number" || typeof value === "bigint")
|
|
543
|
+
return scalar(held(value) ? "[redacted]" : value);
|
|
544
|
+
if (Array.isArray(value)) {
|
|
545
|
+
spend(2);
|
|
546
|
+
const out = [];
|
|
547
|
+
for (const item of value) {
|
|
548
|
+
if (left <= 3)
|
|
549
|
+
return [...out, "..."];
|
|
550
|
+
out.push(shown(item));
|
|
551
|
+
}
|
|
552
|
+
return out;
|
|
553
|
+
}
|
|
554
|
+
if (!value || typeof value !== "object")
|
|
555
|
+
return scalar(value);
|
|
556
|
+
spend(2);
|
|
557
|
+
const entries = [];
|
|
558
|
+
let ended = false;
|
|
559
|
+
for (const [key, item] of Object.entries(value)) {
|
|
560
|
+
if (left <= 3) {
|
|
561
|
+
ended = true;
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
const name = cut(redact(key), left);
|
|
565
|
+
spend(name.length);
|
|
566
|
+
entries.push([name, shown(item)]);
|
|
567
|
+
}
|
|
568
|
+
if (new Set(entries.map(([key]) => key)).size !== entries.length)
|
|
569
|
+
return "[redacted]";
|
|
570
|
+
const out = Object.fromEntries(entries);
|
|
571
|
+
if (ended && !Object.hasOwn(out, "..."))
|
|
572
|
+
out["..."] = "...";
|
|
573
|
+
return out;
|
|
574
|
+
};
|
|
575
|
+
return shown(args);
|
|
524
576
|
};
|
|
525
577
|
/** The rows that show words as a person or the agent wrote them: cut, never scrubbed. */
|
|
526
578
|
const WHOLE = new Set(["user_message", "text_block", "final_answer"]);
|
|
@@ -675,8 +727,32 @@ function createProjector(options) {
|
|
|
675
727
|
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactValue(item)]));
|
|
676
728
|
return value;
|
|
677
729
|
};
|
|
678
|
-
/**
|
|
679
|
-
const
|
|
730
|
+
/** The arguments of calls a read withholds whole (argsOf). */
|
|
731
|
+
const withheldArgs = new WeakSet();
|
|
732
|
+
/** A call's arguments as its rows may show them: redacted once, where the call is first seen (redactValue). Arguments
|
|
733
|
+
* whose JSON holds a held value no cut in place takes (`holds`: split across two of their
|
|
734
|
+
* strings, or across a property name and its value, which redactValue reads one at a time) are withheld whole, in a
|
|
735
|
+
* read with calls or without: the call's rows read it as one with no arguments, its preview is "[redacted]" and its
|
|
736
|
+
* `tool_input` is left out. */
|
|
737
|
+
const argsOf = (args) => {
|
|
738
|
+
if (argsHeld(args)) {
|
|
739
|
+
const none = {};
|
|
740
|
+
withheldArgs.add(none);
|
|
741
|
+
return none;
|
|
742
|
+
}
|
|
743
|
+
return options.redact ? redactValue(args) : args;
|
|
744
|
+
};
|
|
745
|
+
/** Whether the read withholds `args` whole (argsOf); arguments that cannot be read as JSON are. */
|
|
746
|
+
const argsHeld = (args) => {
|
|
747
|
+
if (!options.holds)
|
|
748
|
+
return false;
|
|
749
|
+
try {
|
|
750
|
+
return options.holds(JSON.stringify(args));
|
|
751
|
+
}
|
|
752
|
+
catch {
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
};
|
|
680
756
|
/** An outcome's words as the summary shows them: its verdict (`failed:`, `refused:`) as read, and only what follows it
|
|
681
757
|
* redacted, so a redaction that takes the whole detail still leaves the verdict, as the row's status says. */
|
|
682
758
|
const saidOf = (text) => {
|
|
@@ -687,8 +763,8 @@ function createProjector(options) {
|
|
|
687
763
|
* which its label, summary and preview are all taken from (resultRow); its details and error flag as they came. */
|
|
688
764
|
const shownOf = (tool, view) => withheld(tool, view.text) ? { ...view, text: "[redacted]", details: redactValue(view.details) }
|
|
689
765
|
: options.redact ? { ...view, text: view.text ? options.redact(view.text) : view.text, details: redactValue(view.details) } : view;
|
|
690
|
-
/** Whether a call of `tool`'s output is withheld whole before any row shows it: a web call's
|
|
691
|
-
* (TimelineOptions.holds). */
|
|
766
|
+
/** Whether a call of `tool`'s output is withheld whole before any row shows it: a web call's output, read as it came
|
|
767
|
+
* through `holds` (TimelineOptions.holds, web-calls.ts webHeld). */
|
|
692
768
|
const withheld = (tool, text) => (options.holds && text ? webHeld(tool, text, options.holds) : false);
|
|
693
769
|
const failure = (text) => scrubUrls(firstLine(str(json(text)?.message) ?? diagnosticOf(text) ?? text)) || "no detail";
|
|
694
770
|
/** Whether a result is a call's refusal before it ran: an error its host marked so in its details (CALL_REFUSED),
|
|
@@ -698,11 +774,18 @@ function createProjector(options) {
|
|
|
698
774
|
const endedWithRun = (view) => view.isError && obj(view.details)?.[CALL_ENDED_WITH_RUN] === true;
|
|
699
775
|
/** A call's name on its rows: a refused one's in plain words (refusedLabel), else its label. */
|
|
700
776
|
const nameFor = (tool, args, view, result) => (refused(view) ? refusedLabel(labelled(tool), shown(args)) : label(tool, args, result));
|
|
701
|
-
/** The `tool_use` row of a call
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
const
|
|
705
|
-
|
|
777
|
+
/** The `tool_use` row of a call: its summary and preview from `args`, as its rows show them (argsOf), and a `calls`
|
|
778
|
+
* read's `tool_input` from `raw`, the arguments as the call came; `fields` is what differs between a stored call and
|
|
779
|
+
* a nested one. Arguments argsOf withholds whole preview as "[redacted]". */
|
|
780
|
+
const useRow = (conv, rowId, callId, name, args, raw, fields) => make("tool_use", conv, rowId, { summary: label(name, args), tool_name: name, tool_use_id: callId, tool_input_preview: withheldArgs.has(args) ? "[redacted]" : inputPreview(args, caps.preview), ...inputOf(args, raw), ...fields });
|
|
781
|
+
/** A `calls` read's `tool_input` (inputShown), at most `calls.result` characters of names and values a row: the raw arguments
|
|
782
|
+
* through `calls.input`, else the arguments as the rows show them. None when the arguments themselves are withheld:
|
|
783
|
+
* argsOf reads `raw` whole through `holds`, so a value split across two of the raw strings withholds both. */
|
|
784
|
+
const inputOf = (args, raw) => {
|
|
785
|
+
if (!options.calls || withheldArgs.has(args))
|
|
786
|
+
return {};
|
|
787
|
+
const { result, input, held } = options.calls;
|
|
788
|
+
const shown = obj(input ? inputShown(raw, result, input, options.redact, held) : inputShown(args, result, (text) => text, options.redact, held));
|
|
706
789
|
return shown ? { tool_input: shown } : {};
|
|
707
790
|
};
|
|
708
791
|
/** A call's output as a `calls` read shows it (tool_result_text): redacted by its redactor, else the rows' own, then its
|
|
@@ -901,7 +984,8 @@ function createProjector(options) {
|
|
|
901
984
|
const [id, name] = [str(block.id), str(block.name)];
|
|
902
985
|
if (block.type !== "toolCall" || !id || !name)
|
|
903
986
|
return;
|
|
904
|
-
const
|
|
987
|
+
const raw = obj(block.arguments) ?? {};
|
|
988
|
+
const args = argsOf(raw);
|
|
905
989
|
if (BROWSER_OPENERS.has(name) && !browsers.has(conv)) {
|
|
906
990
|
browsers.add(conv);
|
|
907
991
|
add(make("phase", conv, `${base}:${index}:session`, { summary: "A live browser session started" }));
|
|
@@ -910,7 +994,7 @@ function createProjector(options) {
|
|
|
910
994
|
// made inside a call of the harness's own (Codex's `exec`) under that call, which its record names. SDK calls keep
|
|
911
995
|
// their validated explicit parent.
|
|
912
996
|
const nesting = (entry.recordedCall ? (entry.parentCall ?? nestingCallOf(id)) : undefined) ?? str(obj(entry.data)?.parentCallId);
|
|
913
|
-
const use = useRow(conv, `${base}:${index}`, id, name, args, { round, ...(nesting ? { parent_tool_use_id: nesting } : {}) });
|
|
997
|
+
const use = useRow(conv, `${base}:${index}`, id, name, args, raw, { round, ...(nesting ? { parent_tool_use_id: nesting } : {}) });
|
|
914
998
|
const before = early.get(`${conv}:${id}`);
|
|
915
999
|
const opened = { conv, name, args, round, use, done: before !== undefined };
|
|
916
1000
|
calls.set(`${conv}:${id}`, opened);
|
|
@@ -1070,7 +1154,7 @@ function createProjector(options) {
|
|
|
1070
1154
|
function nested(conv, id, parent, name, raw) {
|
|
1071
1155
|
const args = argsOf(raw);
|
|
1072
1156
|
const round = calls.get(`${conv}:${parent}`)?.round;
|
|
1073
|
-
const use = useRow(conv, `${conv}:n:${id}`, id, name, args, { round, parent_tool_use_id: parent });
|
|
1157
|
+
const use = useRow(conv, `${conv}:n:${id}`, id, name, args, raw, { round, parent_tool_use_id: parent });
|
|
1074
1158
|
calls.set(`${conv}:${id}`, { conv, name, args, round, use, done: false });
|
|
1075
1159
|
rows.push(use);
|
|
1076
1160
|
return use;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
/** The names eachString has tried for a property, counted so a test can bound the work, not time it. */
|
|
2
|
+
export declare const namesTried: {
|
|
3
|
+
count: number;
|
|
4
|
+
};
|
|
1
5
|
/** A web call's output with each text that gives way cut to `keep` characters (a cut one ending "…"), the rest whole. */
|
|
2
6
|
export type WebShown = (keep: number) => string;
|
|
3
7
|
/** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole): `joined` is `parts` joined
|
|
4
8
|
* by line breaks, for a reader that reads each part by itself too (adapter-run-spec.ts answersCut). */
|
|
5
9
|
export type WebHolds = (joined: string, parts: readonly string[]) => boolean;
|
|
6
|
-
/** Whether `text`, a web call's output, is withheld whole: `holds` (
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* preview shows of the text as it came). Every reader of a web call's output asks this first: the runner before it
|
|
15
|
-
* stores the answer (adapter-run-spec.ts answersCut), a timeline before its row shows any of it (timeline.ts shownOf,
|
|
16
|
-
* resultText). False for an output that is not a web call's JSON. */
|
|
10
|
+
/** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) reads the output as it
|
|
11
|
+
* came, through the matcher's join view (redact/match.ts joinOf: a JSON text's strings joined), then its JSON's strings
|
|
12
|
+
* joined by line breaks with the lines after the JSON, once its values alone and once with each property name before its
|
|
13
|
+
* value. They are read in the order the output is written back in (stringsOf) and, where that differs, in the order it
|
|
14
|
+
* was written (writtenStrings). Every reader asks this first: the runner before it stores the answer (answersCut), a
|
|
15
|
+
* timeline before its row shows. Each string is cut on its own wherever the output is shown, so a held value split across
|
|
16
|
+
* two of them, or across a property name and its value, is found only here. False for an output that is not a web
|
|
17
|
+
* call's JSON. */
|
|
17
18
|
export declare function webHeld(tool: string, text: string, holds: WebHolds): boolean;
|
|
18
19
|
/** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself, its
|
|
19
20
|
* property names too, and to the lines after it, never to its JSON line whole: the redactor reads a run of more than
|
|
@@ -26,9 +27,8 @@ export declare function webCut(tool: string, text: string, cut: (text: string) =
|
|
|
26
27
|
/** `text`, a call of `tool`'s output, as a grader reads it (WebShown), each of its strings through `each` first (the
|
|
27
28
|
* run's redaction, its URLs' query values elided), so a cut never falls inside what that takes out. Undefined for a
|
|
28
29
|
* tool other than web_search and web_fetch, or an output that is not its JSON. A page's links past a cut are counted
|
|
29
|
-
* in `links_cut`.
|
|
30
|
-
|
|
31
|
-
export declare function webShownOf(tool: string, text: string, each?: (text: string) => string, holds?: WebHolds): WebShown | undefined;
|
|
30
|
+
* in `links_cut`. */
|
|
31
|
+
export declare function webShownOf(tool: string, text: string, each?: (text: string) => string): WebShown | undefined;
|
|
32
32
|
/** `shown` in `room` characters: whole when it fits, else each text that gives way cut to the longest length that
|
|
33
33
|
* fits, the same for each; past `room` only when its url lists alone pass it, every such text then cut to nothing. */
|
|
34
34
|
export declare function webWithin(shown: WebShown, room: number): string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const WEB_SEARCH = "web_search";
|
|
2
2
|
const WEB_FETCH = "web_fetch";
|
|
3
|
+
/** The names eachString has tried for a property, counted so a test can bound the work, not time it. */
|
|
4
|
+
export const namesTried = { count: 0 };
|
|
3
5
|
const isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
6
|
/** `text` cut to `keep` characters and marked, never splitting a surrogate pair. */
|
|
5
7
|
function clip(text, keep) {
|
|
@@ -9,9 +11,7 @@ function clip(text, keep) {
|
|
|
9
11
|
return `${text.slice(0, code >= 0xd800 && code <= 0xdbff ? keep - 1 : keep)}…`;
|
|
10
12
|
}
|
|
11
13
|
/** Every string in `value` through `each`, property names too (a tool may write a value as one): two names `each` makes
|
|
12
|
-
* one are both kept, the later ones numbered, as the runner's cutDeep keeps them (runner/redact.ts).
|
|
13
|
-
* number is kept (`next`), so k names that cut to one cost k lookups, not k²/2: no name is ever taken back, so every
|
|
14
|
-
* number below it is still taken, and the one it finds is the lowest free one, as a count from 2 finds. */
|
|
14
|
+
* one are both kept, the later ones numbered, as the runner's cutDeep keeps them (runner/redact.ts). */
|
|
15
15
|
function eachString(value, each) {
|
|
16
16
|
if (typeof value === "string")
|
|
17
17
|
return each(value);
|
|
@@ -24,13 +24,10 @@ function eachString(value, each) {
|
|
|
24
24
|
for (const [key, item] of Object.entries(value)) {
|
|
25
25
|
const once = each(key);
|
|
26
26
|
let name = once;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let n = next.get(once) ?? 2;
|
|
30
|
-
while (Object.hasOwn(out, `${once} (${n})`))
|
|
31
|
-
n++;
|
|
27
|
+
// Each name's count goes on from its last free number: no name is taken back, so every number below it is still taken.
|
|
28
|
+
for (let n = next?.get(once) ?? 2; (namesTried.count++, Object.hasOwn(out, name)); n++) {
|
|
32
29
|
name = `${once} (${n})`;
|
|
33
|
-
next.set(once, n + 1);
|
|
30
|
+
(next ??= new Map()).set(once, n + 1);
|
|
34
31
|
}
|
|
35
32
|
Object.defineProperty(out, name, { value: eachString(item, each), enumerable: true, writable: true, configurable: true });
|
|
36
33
|
}
|
|
@@ -81,23 +78,22 @@ function webRead(tool, text) {
|
|
|
81
78
|
}
|
|
82
79
|
return isObj(read) ? { read, end } : undefined;
|
|
83
80
|
}
|
|
84
|
-
/** Whether `text`, a web call's output, is withheld whole: `holds` (
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* preview shows of the text as it came). Every reader of a web call's output asks this first: the runner before it
|
|
93
|
-
* stores the answer (adapter-run-spec.ts answersCut), a timeline before its row shows any of it (timeline.ts shownOf,
|
|
94
|
-
* resultText). False for an output that is not a web call's JSON. */
|
|
81
|
+
/** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) reads the output as it
|
|
82
|
+
* came, through the matcher's join view (redact/match.ts joinOf: a JSON text's strings joined), then its JSON's strings
|
|
83
|
+
* joined by line breaks with the lines after the JSON, once its values alone and once with each property name before its
|
|
84
|
+
* value. They are read in the order the output is written back in (stringsOf) and, where that differs, in the order it
|
|
85
|
+
* was written (writtenStrings). Every reader asks this first: the runner before it stores the answer (answersCut), a
|
|
86
|
+
* timeline before its row shows. Each string is cut on its own wherever the output is shown, so a held value split across
|
|
87
|
+
* two of them, or across a property name and its value, is found only here. False for an output that is not a web
|
|
88
|
+
* call's JSON. */
|
|
95
89
|
export function webHeld(tool, text, holds) {
|
|
96
90
|
const web = webRead(tool, text);
|
|
97
91
|
return web ? heldIn(web, text, holds) : false;
|
|
98
92
|
}
|
|
99
93
|
/** webHeld of an output already read (webRead). */
|
|
100
94
|
function heldIn(web, text, holds) {
|
|
95
|
+
if (holds(text, [text]))
|
|
96
|
+
return true;
|
|
101
97
|
const after = web.end < 0 ? [] : [text.slice(web.end + 1)];
|
|
102
98
|
const line = web.end < 0 ? text : text.slice(0, web.end);
|
|
103
99
|
const asked = (strings) => {
|
|
@@ -112,8 +108,6 @@ function heldIn(web, text, holds) {
|
|
|
112
108
|
}
|
|
113
109
|
/** Whether two lists hold the same strings in the same order. */
|
|
114
110
|
const sameStrings = (a, b) => a.length === b.length && a.every((one, i) => one === b[i]);
|
|
115
|
-
/** What a web call withheld whole shows. */
|
|
116
|
-
const WITHHELD = () => "[redacted]";
|
|
117
111
|
/** How many of `links`, in order, fit in `keep` characters of JSON. */
|
|
118
112
|
function linksWithin(links, keep) {
|
|
119
113
|
let used = 0;
|
|
@@ -142,21 +136,17 @@ export function webCut(tool, text, cut, holds) {
|
|
|
142
136
|
/** `text`, a call of `tool`'s output, as a grader reads it (WebShown), each of its strings through `each` first (the
|
|
143
137
|
* run's redaction, its URLs' query values elided), so a cut never falls inside what that takes out. Undefined for a
|
|
144
138
|
* tool other than web_search and web_fetch, or an output that is not its JSON. A page's links past a cut are counted
|
|
145
|
-
* in `links_cut`.
|
|
146
|
-
|
|
147
|
-
export function webShownOf(tool, text, each = (part) => part, holds) {
|
|
139
|
+
* in `links_cut`. */
|
|
140
|
+
export function webShownOf(tool, text, each = (part) => part) {
|
|
148
141
|
const web = webRead(tool, text);
|
|
149
142
|
if (!web)
|
|
150
143
|
return undefined;
|
|
151
144
|
const shown = eachString(web.read, each);
|
|
152
145
|
const after = web.end < 0 ? "" : each(text.slice(web.end));
|
|
153
|
-
const withheld = () => (holds ? heldIn(web, text, holds) : false);
|
|
154
146
|
if (tool === WEB_SEARCH) {
|
|
155
147
|
const results = shown.results;
|
|
156
148
|
if (!Array.isArray(results) || !results.every(isObj))
|
|
157
149
|
return undefined;
|
|
158
|
-
if (withheld())
|
|
159
|
-
return WITHHELD;
|
|
160
150
|
return (keep) => {
|
|
161
151
|
const hits = results.map((hit) => (typeof hit.snippet === "string" ? { ...hit, snippet: clip(hit.snippet, keep) } : hit));
|
|
162
152
|
return `${JSON.stringify({ ...shown, ...(typeof shown.text === "string" ? { text: clip(shown.text, keep) } : {}), results: hits })}${after}`;
|
|
@@ -166,8 +156,6 @@ export function webShownOf(tool, text, each = (part) => part, holds) {
|
|
|
166
156
|
return undefined;
|
|
167
157
|
const page = shown;
|
|
168
158
|
const links = Array.isArray(page.links) ? page.links : undefined;
|
|
169
|
-
if (withheld())
|
|
170
|
-
return WITHHELD;
|
|
171
159
|
return (keep) => {
|
|
172
160
|
const kept = links ? linksWithin(links, keep) : 0;
|
|
173
161
|
const cut = links ? links.length - kept : 0;
|
package/dist/tool-gate.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ export declare function heldAs(name: string, args: unknown): {
|
|
|
31
31
|
readonly tool: string;
|
|
32
32
|
readonly args: unknown;
|
|
33
33
|
} | undefined;
|
|
34
|
+
/** Why a run can't write a file (a screenshot's save_as, a script's op held as write), or undefined where it can: "not
|
|
35
|
+
* given", write is not among the agent's `tools` (none given, none: leaving write out is how its owner keeps it from
|
|
36
|
+
* writing, whatever write's setting says); "denied", write's `permission` is deny; "no approver", it asks and no one can
|
|
37
|
+
* approve (`approvers` false). The one answer the run's gate refuses by and its files note and bound tools offer by. */
|
|
38
|
+
export type WriteBar = "not given" | "denied" | "no approver";
|
|
39
|
+
export declare const writeBar: (tools: readonly string[] | undefined, permission: Permission, approvers: boolean) => WriteBar | undefined;
|
|
34
40
|
/** A session's `{name -> settings key}` map (nameMapOf). */
|
|
35
41
|
export type NameMap = ReadonlyMap<string, string>;
|
|
36
42
|
/** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
|
|
@@ -190,6 +196,7 @@ export declare function runGate(where: {
|
|
|
190
196
|
}, runId: string, revision: {
|
|
191
197
|
kind: string;
|
|
192
198
|
body: {
|
|
199
|
+
tools?: readonly string[];
|
|
193
200
|
toolSettings?: unknown;
|
|
194
201
|
harness?: string;
|
|
195
202
|
approvals?: Approvals;
|
|
@@ -241,7 +248,8 @@ export declare class RunGate {
|
|
|
241
248
|
runId: string;
|
|
242
249
|
harness?: string;
|
|
243
250
|
computer?: boolean; /** The run's computer kind (its revision's setting): the key a computer tool's refusal and ask name on a tie (kindSetting). */
|
|
244
|
-
kind?: string;
|
|
251
|
+
kind?: string; /** The tools the agent is given (its revision's `tools`): a screenshot's save_as and a script's op held as write are refused unless write is among them; none given, none (writeBar). */
|
|
252
|
+
tools?: readonly string[];
|
|
245
253
|
effectOf?: (name: string) => ToolEffect | undefined; /** The arguments each MCP tool's listing in the run's pin declares (ClaimMcp.argumentsOf), for a pinned tool's closure (pinRefusal). */
|
|
246
254
|
argumentsOf?: ArgumentsOf; /** The harness's adapter facts on the owner's table (its native tools' names, nameMapOf); undefined for one with none. */
|
|
247
255
|
facts: AdapterFacts | undefined;
|
|
@@ -250,6 +258,10 @@ export declare class RunGate {
|
|
|
250
258
|
/** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
|
|
251
259
|
* reaches a live run at its next call; under approvals "never", an ask is an allow. */
|
|
252
260
|
readonly policy: (tool: string) => Permission;
|
|
261
|
+
/** Why this run can't write a file now (writeBar over its agent's tools, write's permission and whether anyone can
|
|
262
|
+
* approve), or undefined where it can: what decide refuses a save_as or a script's write by, and what the run's files
|
|
263
|
+
* note and computer_screenshot's save_as are offered by. */
|
|
264
|
+
readonly writeBar: () => WriteBar | undefined;
|
|
253
265
|
/** The gate's answer for one call before its intent, for a loop that parks and answers asks itself (the runner's adapter
|
|
254
266
|
* loops, pi's and the CLI harnesses'): run it, ask a person, or refuse it with the words the model reads. The order:
|
|
255
267
|
* the deny (with where it was set, and that nothing was sent or charged), a pin, bash's policy (policyRefusal), then
|