@parcha/agentrun-serve 0.1.0-beta.32 → 0.1.0-beta.34
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 +270 -0
- package/README.md +343 -246
- package/dist/adapters.d.ts +0 -7
- package/dist/adapters.js +11 -22
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +14 -0
- package/dist/api-only.js +33 -0
- package/dist/archil-routes.d.ts +1 -1
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-egress-vm.d.ts +0 -8
- package/dist/box-egress-vm.js +0 -10
- package/dist/box-egress.d.ts +0 -4
- package/dist/box-egress.js +1 -16
- package/dist/box-paths.d.ts +25 -2
- package/dist/box-paths.js +79 -11
- package/dist/box-relay.d.ts +0 -11
- package/dist/box-relay.js +0 -20
- package/dist/box-settings.d.ts +26 -0
- package/dist/box-settings.js +63 -0
- package/dist/boxes.d.ts +21 -1
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +94 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -53
- package/dist/browser-person.js +94 -279
- package/dist/budget.d.ts +0 -4
- package/dist/budget.js +0 -7
- package/dist/cap.d.ts +8 -12
- package/dist/cap.js +12 -27
- package/dist/cli.js +61 -20
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +31 -3
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -11
- package/dist/files.js +2 -21
- package/dist/github-connection.d.ts +2 -2
- package/dist/github-connection.js +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +22 -5
- package/dist/harness-install.js +98 -20
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/harness.d.ts +4 -3
- package/dist/harness.js +16 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +62 -24
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +8 -1
- package/dist/learn/secrets.js +95 -15
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +37 -5
- package/dist/learned-workflow.js +106 -12
- package/dist/learning-routes.d.ts +16 -49
- package/dist/learning-routes.js +46 -36
- package/dist/learning-run.d.ts +6 -250
- package/dist/learning-run.js +11 -665
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +13 -3
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -52
- package/dist/mcp-gateway.js +44 -148
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +6 -6
- package/dist/mcp-servers-store.js +13 -15
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +124 -50
- package/dist/page.d.ts +1 -3
- package/dist/page.js +9 -19
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +28 -62
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/place.d.ts +0 -5
- package/dist/place.js +0 -10
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- package/dist/propose.js +83 -39
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -13
- package/dist/run-db.js +2 -41
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +46 -2
- package/dist/run-learning-served.js +26 -7
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +19 -5
- package/dist/run-view.d.ts +12 -17
- package/dist/run-view.js +29 -28
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +14 -3
- package/dist/runner/adapter-loop.js +464 -62
- package/dist/runner/adapter-run-spec.d.ts +29 -8
- package/dist/runner/adapter-run-spec.js +96 -37
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +15 -1
- package/dist/runner/adapters/pi.js +19 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +54 -12
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +49 -15
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +60 -17
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.js +118 -8
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +30 -6
- package/dist/runner/journal-kinds.js +20 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/live-ticker.d.ts +1 -1
- package/dist/runner/live-ticker.js +28 -4
- package/dist/runner/loop-contract.d.ts +3 -2
- package/dist/runner/main.d.ts +64 -10
- package/dist/runner/main.js +165 -27
- package/dist/runner/mcp-claim.d.ts +1 -1
- package/dist/runner/mcp-claim.js +2 -3
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +154 -11
- package/dist/runner/redact.d.ts +8 -2
- package/dist/runner/redact.js +11 -2
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +56 -10
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +68 -26
- package/dist/runs-over-store.d.ts +8 -3
- package/dist/runs-over-store.js +76 -19
- package/dist/seal-key.d.ts +54 -15
- package/dist/seal-key.js +232 -82
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/secrets.d.ts +2 -10
- package/dist/secrets.js +21 -17
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +10 -32
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -33
- package/dist/server.d.ts +26 -44
- package/dist/server.js +229 -142
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +3 -3
- package/dist/store/open.d.ts +18 -5
- package/dist/store/open.js +23 -3
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +27 -3
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +49 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +64 -20
- package/dist/store/store.d.ts +38 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +25 -6
- package/dist/store-reads/journal.js +173 -21
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +91 -23
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +274 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +9 -104
- package/dist/tool-keys.js +15 -271
- package/dist/tool-plane.d.ts +14 -42
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +31 -19
- package/dist/tools.js +101 -108
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-schedule.js +2 -1
- package/dist/trigger-secrets-shown.js +5 -1
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +52 -5
- package/dist/workspace/computer-deps.js +154 -19
- package/dist/workspace/computer-for-claim.d.ts +19 -14
- package/dist/workspace/computer-for-claim.js +77 -16
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-providers.d.ts +6 -2
- package/dist/workspace/computer-providers.js +1 -1
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +4 -3
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +3 -99
- package/launcher/agentrun-serve +6 -33
- package/package.json +14 -14
- package/templates/README.md +9 -3
- package/templates/inbound-lead/agent.md +1 -1
- package/templates/kyb/agent.md +1 -1
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -514
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/bounds.d.ts +0 -26
- package/dist/bounds.js +0 -137
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-35-7aeIZ.js +0 -519
- package/dist/console/assets/index-Cejbov-Y.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/disk.d.ts +0 -33
- package/dist/disk.js +0 -85
- package/dist/door-line.d.ts +0 -23
- package/dist/door-line.js +0 -83
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/harness-app.d.ts +0 -69
- package/dist/harness-app.js +0 -1162
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/request-start.d.ts +0 -27
- package/dist/request-start.js +0 -381
- package/dist/run-box.d.ts +0 -205
- package/dist/run-box.js +0 -661
- package/dist/run-holder.d.ts +0 -52
- package/dist/run-holder.js +0 -139
- package/dist/runs.d.ts +0 -1200
- package/dist/runs.js +0 -4103
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -178
- package/dist/served-only.d.ts +0 -5
- package/dist/served-only.js +0 -12
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/page.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export declare const sendHostRefused: (req: IncomingMessage, res: ServerResponse
|
|
|
21
21
|
/** `publicUrl`: the address people open (AGENTRUN_PUBLIC_URL); an https one adds HSTS to every page answer (hstsHeaders). */
|
|
22
22
|
type PageServer = {
|
|
23
23
|
token: string;
|
|
24
|
-
dir: string;
|
|
25
24
|
authFailed?: (route: string, reason: string) => void;
|
|
26
25
|
owner?: Owner;
|
|
27
26
|
console?: string | undefined;
|
|
@@ -34,8 +33,7 @@ export declare const byOwnerSession: (req: IncomingMessage) => boolean;
|
|
|
34
33
|
/** Whether `req` came from the accounts-off console's page session (answerPage). */
|
|
35
34
|
export declare const byConsoleSession: (req: IncomingMessage) => boolean;
|
|
36
35
|
/**
|
|
37
|
-
* Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/") and the
|
|
38
|
-
* returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
|
|
36
|
+
* Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/"), and returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
|
|
39
37
|
* becomes the Bearer header for a GET or HEAD, and for any other method only when the request's Origin is this server's
|
|
40
38
|
* own origin and its body is application/json, or the request is a PUT or POST to a route that takes bytes, with any
|
|
41
39
|
* content type.
|
package/dist/page.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// hashed assets under /assets/, public, under one strict CSP. The console signs a person in itself. With accounts it
|
|
3
3
|
// takes the owner's session cookie (owner.ts); without, the server's token as a cookie that the printed link (`/?token=`)
|
|
4
4
|
// sets once. Either stands in for the Bearer header on /v2, and for a write only from this origin with a JSON body, or
|
|
5
|
-
// with any body on a route that takes bytes (a PUT or POST marked `raw` in server.ts).
|
|
6
|
-
// store's read-only JSON (/api/*, pi-durable-agent's store page's data) answers the Bearer token or either cookie.
|
|
5
|
+
// with any body on a route that takes bytes (a PUT or POST marked `raw` in server.ts).
|
|
7
6
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
8
7
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
9
8
|
import { extname, join, sep } from "node:path";
|
|
10
9
|
import { fileURLToPath } from "node:url";
|
|
11
|
-
import { storeApi } from "@parcha/pi-durable-agent/serve";
|
|
12
10
|
import { ApiError } from "./errors.js";
|
|
13
11
|
import { hostRefusedPage } from "./host-check.js";
|
|
14
|
-
|
|
12
|
+
// img-src names Google's favicon service and the four hosts it redirects to: the console's Keys page shows a provider's
|
|
13
|
+
// icon from it (apps/console/src/components/ProviderIcon.tsx), sent with no referrer. Everything else is this origin's.
|
|
14
|
+
const CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https://www.google.com https://t0.gstatic.com https://t1.gstatic.com https://t2.gstatic.com https://t3.gstatic.com; base-uri 'none'; form-action https://github.com; frame-ancestors 'none'";
|
|
15
15
|
const SECURITY = { "content-security-policy": CSP, "x-content-type-options": "nosniff", "referrer-policy": "no-referrer", "cache-control": "no-store" };
|
|
16
16
|
const HTML = "text/html; charset=utf-8";
|
|
17
17
|
/** Strict-Transport-Security for a server whose public address (AGENTRUN_PUBLIC_URL) is https: a browser that saw it
|
|
@@ -77,18 +77,9 @@ async function file(req, res, raw, dir, rel, status = 200) {
|
|
|
77
77
|
return missing();
|
|
78
78
|
send(req, res, status, type, await readFile(real), { "cache-control": rel.startsWith("assets/") ? "public, max-age=31536000, immutable" : "no-store" });
|
|
79
79
|
}
|
|
80
|
-
async function answer(req, res, raw, server
|
|
80
|
+
async function answer(req, res, raw, server) {
|
|
81
81
|
if (req.method !== "GET" && req.method !== "HEAD")
|
|
82
82
|
return refuse(req, res, new ApiError("method_not_allowed", `the console answers GET and HEAD; ${req.method} is not one`, {}, { allow: "GET, HEAD" }));
|
|
83
|
-
if (raw.startsWith("/api/")) {
|
|
84
|
-
if (!held && !same(String(req.headers.authorization ?? ""), `Bearer ${server.token}`)) {
|
|
85
|
-
server.authFailed?.(raw, req.headers.authorization === undefined ? "no_credential" : "wrong_token");
|
|
86
|
-
return refuse(req, res, new ApiError("unauthenticated", "the page's data needs the cookie the printed link sets, or Authorization: Bearer <the token>"));
|
|
87
|
-
}
|
|
88
|
-
const url = new URL(req.url ?? "/", "http://serve");
|
|
89
|
-
const { status, value } = await storeApi({ dir: server.dir })(url.pathname, url.searchParams);
|
|
90
|
-
return send(req, res, status, "application/json; charset=utf-8", JSON.stringify(value));
|
|
91
|
-
}
|
|
92
83
|
const dir = server.console ?? CONSOLE_DIR;
|
|
93
84
|
if (MOVED.has(raw))
|
|
94
85
|
return redirect(res, `/${(req.url ?? "").slice(raw.length)}`);
|
|
@@ -122,8 +113,7 @@ const consoleSessions = new WeakSet();
|
|
|
122
113
|
/** Whether `req` came from the accounts-off console's page session (answerPage). */
|
|
123
114
|
export const byConsoleSession = (req) => consoleSessions.has(req);
|
|
124
115
|
/**
|
|
125
|
-
* Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/") and the
|
|
126
|
-
* returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
|
|
116
|
+
* Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/"), and returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
|
|
127
117
|
* becomes the Bearer header for a GET or HEAD, and for any other method only when the request's Origin is this server's
|
|
128
118
|
* own origin and its body is application/json, or the request is a PUT or POST to a route that takes bytes, with any
|
|
129
119
|
* content type.
|
|
@@ -144,12 +134,12 @@ export function answerPage(req, res, raw, server) {
|
|
|
144
134
|
}
|
|
145
135
|
return false;
|
|
146
136
|
}
|
|
147
|
-
if (raw !== "/" && !raw.startsWith("/assets/") && !
|
|
137
|
+
if (raw !== "/" && !raw.startsWith("/assets/") && !MOVED.has(raw))
|
|
148
138
|
return false;
|
|
149
|
-
// Every page answer (the console, its assets, its redirects
|
|
139
|
+
// Every page answer (the console, its assets, its redirects) at an https public address: HSTS.
|
|
150
140
|
for (const [name, value] of Object.entries(hstsHeaders(server.publicUrl)))
|
|
151
141
|
res.setHeader(name, value);
|
|
152
|
-
answer(req, res, raw, server
|
|
142
|
+
answer(req, res, raw, server).catch(() => {
|
|
153
143
|
if (!res.headersSent)
|
|
154
144
|
refuse(req, res, new ApiError("internal", "the console could not be read"));
|
|
155
145
|
else
|
package/dist/paid-calls.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord";
|
|
2
2
|
import type { Refusal } from "@parcha/agentrun-kernel";
|
|
3
3
|
import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
|
-
import { type SyncTarget } from "@parcha/pi-durable-disk";
|
|
5
4
|
/** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
|
|
6
5
|
* $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
|
|
7
6
|
export declare const PARALLEL_SEARCH_USD = 0.001;
|
|
@@ -55,37 +54,25 @@ export type PaidBooking = {
|
|
|
55
54
|
basis: string;
|
|
56
55
|
call?: string;
|
|
57
56
|
chargedBy?: string;
|
|
57
|
+
tool?: string;
|
|
58
|
+
tag?: string;
|
|
59
|
+
owed?: true;
|
|
60
|
+
hold?: true;
|
|
61
|
+
ref?: string;
|
|
58
62
|
}): Promise<unknown>;
|
|
59
63
|
/** `givenBack`: the hold let go unused, nothing sent (RunTools.settle). */
|
|
60
64
|
settle(id: string, usd: number | null, options?: {
|
|
61
65
|
readonly givenBack?: true;
|
|
62
66
|
}): Promise<unknown>;
|
|
63
67
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
export declare const noStoreToSync: (store: SyncTarget | undefined) => boolean;
|
|
68
|
-
/** A hold that could not be made durable (writeHold): nothing was sent. Its message says why, after "was not sent: ". */
|
|
69
|
-
export declare class HoldNotDurable extends Error {
|
|
70
|
-
readonly name = "HoldNotDurable";
|
|
71
|
-
}
|
|
72
|
-
/** The run's journal a hold is synced in (settleIn), for another barrier before a paid effect: browser-cost.ts'. */
|
|
73
|
-
export declare const runJournal: () => SyncTarget | undefined;
|
|
74
|
-
/** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit), then the
|
|
75
|
-
* run journal's barrier (pi-durable-disk barriers.ts, paidToolHold): the hold is on disk before the call is sent, so a
|
|
76
|
-
* box loss never leaves a sent call the cap does not count. Every paid call writes its hold here: a paid request
|
|
77
|
-
* (paidRequest), monid.run (monid.ts) and a priced MCP call (mcp-gateway.ts), so a new paid tool gets the sync with it.
|
|
78
|
-
* Whatever throws, the caller sends nothing (holdRefusal says why): with no store to sync it writes no hold
|
|
79
|
-
* (HoldNotDurable); a write that fails throws its own error; a sync that fails after the write settles the hold at $0
|
|
80
|
-
* under its call (best effort), so no cap counts a call that never left, and throws HoldNotDurable. */
|
|
68
|
+
/** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
|
|
69
|
+
* call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
|
|
70
|
+
* monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
|
|
81
71
|
export declare function writeHold(write: (kind: string, data: Record<string, string | number | null>) => Promise<void>, data: Record<string, string | number | null>): Promise<void>;
|
|
82
|
-
/** What a paid call
|
|
72
|
+
/** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
|
|
83
73
|
export declare const holdRefusal: (name: string, error: unknown) => string;
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
export declare const settleOnRoot: (kind: string, data: Record<string, string | number | null>) => Promise<void> | undefined;
|
|
87
|
-
/** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) is the call's own
|
|
88
|
-
* commit, so a stopped turn sends nothing new; its settle goes to the run's root when that is set (settleIn). On the
|
|
74
|
+
/** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
|
|
75
|
+
* call's own commits, so a stopped turn sends nothing new. On the
|
|
89
76
|
* runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
|
|
90
77
|
* and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
|
|
91
78
|
* settled there, never booked beside it where the cap does not judge it. */
|
|
@@ -102,17 +89,24 @@ export declare function paidRequest(fee: Fee, send: () => Promise<Response>): Pr
|
|
|
102
89
|
/** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
|
|
103
90
|
export declare const paidLedger: () => PaidBooking | undefined;
|
|
104
91
|
/** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
|
|
105
|
-
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold).
|
|
106
|
-
|
|
92
|
+
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
|
|
93
|
+
* for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
|
|
94
|
+
* paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
|
|
95
|
+
export declare function paidStep<T>(paid: PaidBooking, call: string | undefined, fee: {
|
|
107
96
|
name: string;
|
|
108
97
|
holdUsd: number;
|
|
109
98
|
basis: string;
|
|
110
99
|
by: string;
|
|
100
|
+
tool?: string;
|
|
101
|
+
tag?: string;
|
|
102
|
+
owed?: true;
|
|
103
|
+
hold?: true;
|
|
104
|
+
ref?: string;
|
|
111
105
|
}, run: () => Promise<T>, chargeOf: (outcome: {
|
|
112
106
|
result: T;
|
|
113
107
|
} | {
|
|
114
108
|
thrown: unknown;
|
|
115
|
-
}) => number | null): Promise<{
|
|
109
|
+
}) => number | null, pause?: Ledger["pause"]): Promise<{
|
|
116
110
|
refused: string;
|
|
117
111
|
} | {
|
|
118
112
|
result: T;
|
package/dist/paid-calls.js
CHANGED
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
// tool books without the call passed down to it.
|
|
16
16
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
17
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
18
|
-
import { TOOL_COST, TOOL_STARTED } from "
|
|
19
|
-
import {
|
|
20
|
-
import { paidCall } from "./cap.js";
|
|
18
|
+
import { TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
|
|
19
|
+
import { paidCall, SPEND_CAP_REACHED } from "./cap.js";
|
|
21
20
|
/** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
|
|
22
21
|
* $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
|
|
23
22
|
export const PARALLEL_SEARCH_USD = 0.001;
|
|
@@ -55,67 +54,27 @@ const roomOf = (error) => {
|
|
|
55
54
|
const given = error;
|
|
56
55
|
if (given?.code !== "spend_cap_reached" || given.forGood !== false || !given.figures)
|
|
57
56
|
return undefined;
|
|
58
|
-
|
|
57
|
+
// Its code rides with it: the model request the pause refuses next is the cap's refusal (Refusal.code), never a failure.
|
|
58
|
+
return { refuse: String(given.message), code: SPEND_CAP_REACHED, forGood: false, figures: given.figures };
|
|
59
59
|
};
|
|
60
|
-
/** A paid step refused for room pauses the run, through the call's ledger
|
|
61
|
-
|
|
60
|
+
/** A paid step refused for room pauses the run, through `pause` (the call's ledger's, Ledger.pause, by default), before
|
|
61
|
+
* its refusal is told. */
|
|
62
|
+
const pauseOn = async (error, pause = ledgers.getStore()?.pause) => {
|
|
62
63
|
const room = roomOf(error);
|
|
63
|
-
const pause = ledgers.getStore()?.pause;
|
|
64
64
|
if (room && pause)
|
|
65
65
|
await pause(room);
|
|
66
66
|
};
|
|
67
67
|
const ledgers = new AsyncLocalStorage();
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* (
|
|
71
|
-
let rootRecord;
|
|
72
|
-
/** The run's store, for the barrier after each hold (writeHold): set with the root's commit, once the run is open. */
|
|
73
|
-
let holdStore;
|
|
74
|
-
/** The run journal's level: the store's own once one is open, this before (FULL syncs every commit, NORMAL only at a
|
|
75
|
-
* barrier). */
|
|
76
|
-
let journalLevel = JOURNAL_SYNCHRONOUS;
|
|
77
|
-
export const settleIn = (record, store, journal = JOURNAL_SYNCHRONOUS) => {
|
|
78
|
-
rootRecord = record;
|
|
79
|
-
holdStore = store;
|
|
80
|
-
// Only a test passes `journal`, to run the barriers at NORMAL before the run journal is NORMAL (pi-durable-disk 2b).
|
|
81
|
-
journalLevel = journal;
|
|
82
|
-
};
|
|
83
|
-
/** Whether a barrier on the run journal has nothing to sync: no store open, while the journal syncs only at barriers. A
|
|
84
|
-
* hold or a start mark written then would sit in the store with nothing to make it durable, so none is written. */
|
|
85
|
-
export const noStoreToSync = (store) => store === undefined && journalLevel !== "FULL";
|
|
86
|
-
/** A hold that could not be made durable (writeHold): nothing was sent. Its message says why, after "was not sent: ". */
|
|
87
|
-
export class HoldNotDurable extends Error {
|
|
88
|
-
name = "HoldNotDurable";
|
|
89
|
-
}
|
|
90
|
-
/** The run's journal a hold is synced in (settleIn), for another barrier before a paid effect: browser-cost.ts'. */
|
|
91
|
-
export const runJournal = () => holdStore;
|
|
92
|
-
/** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit), then the
|
|
93
|
-
* run journal's barrier (pi-durable-disk barriers.ts, paidToolHold): the hold is on disk before the call is sent, so a
|
|
94
|
-
* box loss never leaves a sent call the cap does not count. Every paid call writes its hold here: a paid request
|
|
95
|
-
* (paidRequest), monid.run (monid.ts) and a priced MCP call (mcp-gateway.ts), so a new paid tool gets the sync with it.
|
|
96
|
-
* Whatever throws, the caller sends nothing (holdRefusal says why): with no store to sync it writes no hold
|
|
97
|
-
* (HoldNotDurable); a write that fails throws its own error; a sync that fails after the write settles the hold at $0
|
|
98
|
-
* under its call (best effort), so no cap counts a call that never left, and throws HoldNotDurable. */
|
|
68
|
+
/** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
|
|
69
|
+
* call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
|
|
70
|
+
* monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
|
|
99
71
|
export async function writeHold(write, data) {
|
|
100
|
-
if (noStoreToSync(holdStore))
|
|
101
|
-
throw new HoldNotDurable("the run's store is not open, so its hold cannot be made durable");
|
|
102
72
|
await write(TOOL_STARTED, data);
|
|
103
|
-
try {
|
|
104
|
-
await syncNow(holdStore, BARRIER.paidToolHold);
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
const { heldUsd: _held, ...label } = data;
|
|
108
|
-
await write(TOOL_COST, { ...label, usd: 0 }).catch(() => undefined);
|
|
109
|
-
throw new HoldNotDurable(`its hold could not be made durable (${String(error?.message ?? error).slice(0, 200)})`);
|
|
110
|
-
}
|
|
111
73
|
}
|
|
112
|
-
/** What a paid call
|
|
113
|
-
export const holdRefusal = (name, error) =>
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
export const settleOnRoot = (kind, data) => rootRecord?.(kind, data);
|
|
117
|
-
/** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) is the call's own
|
|
118
|
-
* commit, so a stopped turn sends nothing new; its settle goes to the run's root when that is set (settleIn). On the
|
|
74
|
+
/** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
|
|
75
|
+
export const holdRefusal = (name, error) => `${name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})`;
|
|
76
|
+
/** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
|
|
77
|
+
* call's own commits, so a stopped turn sends nothing new. On the
|
|
119
78
|
* runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
|
|
120
79
|
* and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
|
|
121
80
|
* settled there, never booked beside it where the cap does not judge it. */
|
|
@@ -123,7 +82,7 @@ export const ledgerOf = (api, context) => {
|
|
|
123
82
|
const outer = ledgers.getStore();
|
|
124
83
|
return {
|
|
125
84
|
call: api.callId,
|
|
126
|
-
record: (kind, data) =>
|
|
85
|
+
record: (kind, data) => api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data })), context),
|
|
127
86
|
...(outer?.paid ? { paid: outer.paid } : {}),
|
|
128
87
|
...(outer?.pause ? { pause: outer.pause } : {}),
|
|
129
88
|
};
|
|
@@ -181,16 +140,22 @@ let paidSeq = 0;
|
|
|
181
140
|
/** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
|
|
182
141
|
export const paidLedger = () => ledgers.getStore()?.paid;
|
|
183
142
|
/** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
|
|
184
|
-
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold).
|
|
185
|
-
|
|
186
|
-
|
|
143
|
+
* or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
|
|
144
|
+
* for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
|
|
145
|
+
* paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
|
|
146
|
+
export async function paidStep(paid, call, fee, run, chargeOf, pause) {
|
|
147
|
+
const id = `${call ?? fee.ref ?? fee.name}#${(paidSeq += 1)}`;
|
|
148
|
+
let admitted;
|
|
187
149
|
try {
|
|
188
|
-
await paid.admit({ id, name: fee.name, holdUsd: fee.holdUsd, basis: fee.basis, call, chargedBy: fee.by });
|
|
150
|
+
admitted = await paid.admit({ id, name: fee.name, holdUsd: fee.holdUsd, basis: fee.basis, ...(call === undefined ? {} : { call }), chargedBy: fee.by, ...(fee.tool ? { tool: fee.tool } : {}), ...(fee.tag ? { tag: fee.tag } : {}), ...(fee.owed ? { owed: true } : {}), ...(fee.hold ? { hold: true } : {}), ...(fee.ref === undefined ? {} : { ref: fee.ref }) });
|
|
189
151
|
}
|
|
190
152
|
catch (error) {
|
|
191
|
-
await pauseOn(error);
|
|
153
|
+
await pauseOn(error, pause);
|
|
192
154
|
return { refused: error?.code === "spend_cap_reached" ? String(error.message) : holdRefusal(fee.name, error) };
|
|
193
155
|
}
|
|
156
|
+
// Its ref booked already (by this claim or an earlier one): no step was opened, so nothing is settled.
|
|
157
|
+
if (admitted?.booked === true)
|
|
158
|
+
return { result: await run() };
|
|
194
159
|
let outcome;
|
|
195
160
|
try {
|
|
196
161
|
outcome = { result: await run() };
|
|
@@ -198,7 +163,8 @@ export async function paidStep(paid, call, fee, run, chargeOf) {
|
|
|
198
163
|
catch (thrown) {
|
|
199
164
|
outcome = { thrown };
|
|
200
165
|
}
|
|
201
|
-
|
|
166
|
+
// A hold-only step (`hold`) is given back, never a charge: its money is booked by its own charges' steps.
|
|
167
|
+
await (fee.hold ? paid.settle(id, 0, { givenBack: true }) : paid.settle(id, chargeOf(outcome))).catch(() => undefined);
|
|
202
168
|
if ("thrown" in outcome)
|
|
203
169
|
throw outcome.thrown;
|
|
204
170
|
return outcome;
|
package/dist/pause.d.ts
CHANGED
|
@@ -34,8 +34,6 @@ export type NodeLine = {
|
|
|
34
34
|
error_truncated?: boolean;
|
|
35
35
|
at: string;
|
|
36
36
|
};
|
|
37
|
-
/** Appends to the run's node log; a write that fails is lost, never the run's. */
|
|
38
|
-
export declare const nodeLog: (root: string) => (line: NodeLine) => void;
|
|
39
37
|
/** The node log of the run at `root`, in order; a torn last line is left out. */
|
|
40
38
|
export declare function readNodeLog(root: string): Promise<NodeLine[]>;
|
|
41
39
|
/** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
|
package/dist/pause.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// Live view: `live.json`, the driver's frame and the run's decision receipts, rewritten whole by the run's process when
|
|
13
13
|
// they change. The run's process holds its store exclusively (pi-durable-disk's exclusive profile: no other connection
|
|
14
14
|
// reads it until the process exits), so this file is what GET /v2/runs/{id}/graph reads while the run goes.
|
|
15
|
-
import {
|
|
15
|
+
import { existsSync, renameSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { join } from "node:path";
|
|
17
17
|
import { RUN_CANCELLED } from "./files.js";
|
|
18
18
|
export const RUN_PAUSED = "paused";
|
|
@@ -31,13 +31,6 @@ export function gated(root, fn) {
|
|
|
31
31
|
return fn(params);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
/** Appends to the run's node log; a write that fails is lost, never the run's. */
|
|
35
|
-
export const nodeLog = (root) => (line) => {
|
|
36
|
-
try {
|
|
37
|
-
appendFileSync(join(root, NODE_LOG), `${JSON.stringify(line)}\n`, { mode: 0o600 });
|
|
38
|
-
}
|
|
39
|
-
catch { }
|
|
40
|
-
};
|
|
41
34
|
/** The node log of the run at `root`, in order; a torn last line is left out. */
|
|
42
35
|
export async function readNodeLog(root) {
|
|
43
36
|
const { readFile } = await import("node:fs/promises");
|
package/dist/place.d.ts
CHANGED
|
@@ -55,16 +55,11 @@ export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly
|
|
|
55
55
|
};
|
|
56
56
|
/** A run's place: its revision's, else the place a revision that names none resolves to here (`fallback`: defaultPlaceOf). */
|
|
57
57
|
export declare const resolvePlace: (revision: Place | undefined, fallback: Place) => Place;
|
|
58
|
-
/** The place a run kept (its serve.json), or runner for a run kept before runs had one. */
|
|
59
|
-
export declare function storedPlace(value: unknown): Place;
|
|
60
58
|
/** Where a box has the run's work/ (bound, or seeded), and where its tools start: the same in every box. */
|
|
61
59
|
export declare const BOX_WORK = "/workspace";
|
|
62
60
|
/** The boxes that cannot bind a run's work/, being on another machine: its work/ is seeded at the box's making and
|
|
63
61
|
* pulled back (run-box.ts). */
|
|
64
62
|
export declare const REMOTE_BOXES: readonly BoxId[];
|
|
65
|
-
export declare const remotePlace: (place: Place) => boolean;
|
|
66
|
-
/** The run's work/ as its agent's tools see it: on the runner, `<runDir>/work`; in any box, BOX_WORK. */
|
|
67
|
-
export declare const agentWorkDir: (runDir: string, place: Place) => string;
|
|
68
63
|
/** `place` as a definition writes it, to copy: `"place": {"mode": "sandbox", "box": "docker"}`. */
|
|
69
64
|
export declare const placeFix: (place: Place) => string;
|
|
70
65
|
/** What is wrong with `place` as a definition gives it, as issues at `field`. Each names its fix: the field to remove,
|
package/dist/place.js
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
// (newAgentPlace). A revision that names no place resolves the same way at each run (defaultPlaceOf): this server's
|
|
13
13
|
// default_place, so where docker is there now it runs in the Docker box, and the runner where it is not. A workflow, and a
|
|
14
14
|
// revision with a tool the box refuses, run on the runner.
|
|
15
|
-
import { join } from "node:path";
|
|
16
15
|
import { BOX_IDS, BOXES_ENV, VM_PROVIDER } from "./boxes.js";
|
|
17
16
|
import { sentence } from "./errors.js";
|
|
18
17
|
export const PLACE_MODES = ["runner", "sandbox"];
|
|
@@ -106,20 +105,11 @@ const stated = ({ state, network, network_reason, ...offer }) => ({
|
|
|
106
105
|
});
|
|
107
106
|
/** A run's place: its revision's, else the place a revision that names none resolves to here (`fallback`: defaultPlaceOf). */
|
|
108
107
|
export const resolvePlace = (revision, fallback) => revision ?? fallback;
|
|
109
|
-
/** The place a run kept (its serve.json), or runner for a run kept before runs had one. */
|
|
110
|
-
export function storedPlace(value) {
|
|
111
|
-
if (!isObject(value) || value.mode !== "sandbox" || !listed(BOX_IDS, value.box))
|
|
112
|
-
return { mode: "runner" };
|
|
113
|
-
return { mode: "sandbox", box: value.box };
|
|
114
|
-
}
|
|
115
108
|
/** Where a box has the run's work/ (bound, or seeded), and where its tools start: the same in every box. */
|
|
116
109
|
export const BOX_WORK = "/workspace";
|
|
117
110
|
/** The boxes that cannot bind a run's work/, being on another machine: its work/ is seeded at the box's making and
|
|
118
111
|
* pulled back (run-box.ts). */
|
|
119
112
|
export const REMOTE_BOXES = ["daytona", VM_PROVIDER.id];
|
|
120
|
-
export const remotePlace = (place) => place.mode === "sandbox" && REMOTE_BOXES.includes(place.box);
|
|
121
|
-
/** The run's work/ as its agent's tools see it: on the runner, `<runDir>/work`; in any box, BOX_WORK. */
|
|
122
|
-
export const agentWorkDir = (runDir, place) => (place.mode === "runner" ? join(runDir, "work") : BOX_WORK);
|
|
123
113
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
124
114
|
const listed = (options, value) => typeof value === "string" && options.includes(value);
|
|
125
115
|
/** `place` as a definition writes it, to copy: `"place": {"mode": "sandbox", "box": "docker"}`. */
|
package/dist/print.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function boxImageLine(state: ImageState, started: boolean): strin
|
|
|
9
9
|
export type TokenSource = "made" | "file" | "env";
|
|
10
10
|
/** The banner's lines. The token is printed only when this start made it; else where it is. `publicUrl` is the address
|
|
11
11
|
* people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
|
|
12
|
-
* password, so its link holds no token. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
12
|
+
* password, so its link holds no token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
13
13
|
export declare function banner(o: {
|
|
14
14
|
url: string;
|
|
15
15
|
baseUrl: string;
|
|
@@ -19,6 +19,7 @@ export declare function banner(o: {
|
|
|
19
19
|
listen?: string;
|
|
20
20
|
publicUrl?: string;
|
|
21
21
|
accounts?: boolean;
|
|
22
|
+
apiOnly?: boolean;
|
|
22
23
|
boxes?: string;
|
|
23
24
|
}): string[];
|
|
24
25
|
/** One log line. */
|
package/dist/print.js
CHANGED
|
@@ -16,7 +16,7 @@ export function boxImageLine(state, started) {
|
|
|
16
16
|
}
|
|
17
17
|
/** The banner's lines. The token is printed only when this start made it; else where it is. `publicUrl` is the address
|
|
18
18
|
* people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
|
|
19
|
-
* password, so its link holds no token. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
19
|
+
* password, so its link holds no token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
20
20
|
export function banner(o) {
|
|
21
21
|
const where = o.source === "env" ? "$AGENTRUN_TOKEN" : `<in ${join(o.data, ".token")}>`;
|
|
22
22
|
const key = o.source === "made" ? o.token : where;
|
|
@@ -25,7 +25,9 @@ export function banner(o) {
|
|
|
25
25
|
`AGENTRUN_BASE_URL=${o.publicUrl ? `${o.publicUrl}/v2` : o.baseUrl}`,
|
|
26
26
|
`AGENTRUN_API_KEY=${key}`,
|
|
27
27
|
// Encoded: a "+" in a token reads as a space in a query string.
|
|
28
|
-
o.
|
|
28
|
+
o.apiOnly
|
|
29
|
+
? "API only (AGENTRUN_API_ONLY=1): the run routes are served; the console, sign-in, setup, settings, MCP, triggers and hooks are refused."
|
|
30
|
+
: o.accounts ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?token=${o.source === "made" ? encodeURIComponent(o.token) : where}`,
|
|
29
31
|
...(o.boxes ? [o.boxes] : []),
|
|
30
32
|
];
|
|
31
33
|
}
|