@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/runs.d.ts
DELETED
|
@@ -1,1200 +0,0 @@
|
|
|
1
|
-
import { type ChildProcess } from "node:child_process";
|
|
2
|
-
import { type Revision, type RevisionKind, type RunOrigin, type RunRow } from "@parcha/pi-durable-agent";
|
|
3
|
-
import { type MessageOrigin, type RunMetrics, type TimelineEvent, timelineReducer } from "@parcha/pi-durable-agent/timeline";
|
|
4
|
-
import type { RUN_EVENTS, RunNotice } from "./webhooks.js";
|
|
5
|
-
import type { RunTrigger } from "./triggers.js";
|
|
6
|
-
import { type AgentEntry, type Agents } from "./agents.js";
|
|
7
|
-
import { type McpServerSource } from "./mcp-gateway.js";
|
|
8
|
-
import { type DaytonaApi } from "./daytona-api.js";
|
|
9
|
-
import { type Learning, type LearningMode, type LearningReason, type LearningState } from "./learning.js";
|
|
10
|
-
import { Hearing } from "./heard.js";
|
|
11
|
-
import { LearningRuns, type Reflect } from "./learning-run.js";
|
|
12
|
-
import { type BoxHost, type Quarantine } from "./box/sweep.js";
|
|
13
|
-
import { type CapMode, type RefusalFigures } from "./cap.js";
|
|
14
|
-
import { type Tier } from "./model.js";
|
|
15
|
-
import { type Plane, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
|
|
16
|
-
import { type Page, RowLog } from "./rows.js";
|
|
17
|
-
import { type Json } from "./validate.js";
|
|
18
|
-
import { RequestBounds } from "./bounds.js";
|
|
19
|
-
import { Turns } from "./turns.js";
|
|
20
|
-
import { type StoredKeys } from "./secrets.js";
|
|
21
|
-
import { type HandedSignIn, type SignIns } from "./sign-ins.js";
|
|
22
|
-
import { type Place } from "./place.js";
|
|
23
|
-
import { RUN_EPOCH_ENV, type RunHolder } from "./run-holder.js";
|
|
24
|
-
import { type Approval, type ApprovalAnswer, costOf, costView, type Handed, knownToolCostOf, type Pending, type SoFar, soFarOf, type State, type Status, stoppedAt, SUGGESTED_RAISE_FACTOR, suggestedCap, toolCostOf, WITHHELD_SIGN_IN, withOverCap, withPaused } from "./run-view.js";
|
|
25
|
-
export { costOf, costView, knownToolCostOf, soFarOf, type SoFar, toolCostOf, withOverCap, withPaused, stoppedAt, suggestedCap, SUGGESTED_RAISE_FACTOR, type State, type Status, WITHHELD_SIGN_IN };
|
|
26
|
-
import { type BoxPaths } from "./box-paths.js";
|
|
27
|
-
import type { BoxProvider } from "@parcha/pi-transport";
|
|
28
|
-
import type { RemoteLimits } from "./run-box.js";
|
|
29
|
-
import type { Emitted } from "./webhooks.js";
|
|
30
|
-
export declare const STATUSES: readonly Status[];
|
|
31
|
-
/** Why a run going when its server started was stopped: the browser sign-in it was handed can't be read here (the seal
|
|
32
|
-
* key changed or is missing, or the sign-ins file is damaged or can't be read). */
|
|
33
|
-
export declare const UNREADABLE_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged): the run was stopped, so nothing it says can show it.";
|
|
34
|
-
/** Why a run going when its server started was stopped: its serve.json is there but can't be read or parsed, and with it
|
|
35
|
-
* went which browser it ran on and whether it was handed its agent's sign-in, so its text can't be cut of the pointer. */
|
|
36
|
-
export declare const UNREADABLE_RUN_META = "This server can't read the run's record (its serve.json is damaged or can't be read), so it can't tell whether the run was handed its agent's browser sign-in: the run was stopped, so nothing it says can show it.";
|
|
37
|
-
/** The epoch of the claim a run's process holds, which the server gave it at its launch (run-holder.ts). */
|
|
38
|
-
export { RUN_EPOCH_ENV };
|
|
39
|
-
type RunMeta = {
|
|
40
|
-
title: string;
|
|
41
|
-
created_at: string;
|
|
42
|
-
/** The run's input: an agentic run's first message is its `content`, a workflow run's input is the whole of it. */
|
|
43
|
-
input?: Json;
|
|
44
|
-
effort?: string;
|
|
45
|
-
max_cost_usd?: number;
|
|
46
|
-
/** How its cap prices a request (cap.ts CapMode); absent, expected. */
|
|
47
|
-
cap_mode?: CapMode;
|
|
48
|
-
/** Each raise of its cap (PATCH /runs/{id}): from what, to what, when, and the pause it answers (pauseOf), if any. */
|
|
49
|
-
cap_raised?: {
|
|
50
|
-
from: number;
|
|
51
|
-
to: number;
|
|
52
|
-
at: string;
|
|
53
|
-
pause?: string;
|
|
54
|
-
}[];
|
|
55
|
-
/** The one follow-up that sends a run paused at its cap on once its cap is raised (resumeRaised): for which pause, by
|
|
56
|
-
* what id, whether it went, how many tries failed and why, and which process was being let go when it was asked for
|
|
57
|
-
* (its pid and start ticks): it goes once that process is gone, here or after a restart. */
|
|
58
|
-
cap_continue?: {
|
|
59
|
-
pause: string;
|
|
60
|
-
message_id: string;
|
|
61
|
-
sent: boolean;
|
|
62
|
-
tries: number;
|
|
63
|
-
error?: string;
|
|
64
|
-
paused?: string;
|
|
65
|
-
};
|
|
66
|
-
error?: {
|
|
67
|
-
code: string;
|
|
68
|
-
message: string;
|
|
69
|
-
details?: {
|
|
70
|
-
reason: string;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
/** A workflow run's output, once it completed. */
|
|
74
|
-
output?: unknown;
|
|
75
|
-
/** A workflow run that escalated: what a person is to look at. Its time is the run's saved end, read with it. */
|
|
76
|
-
review?: SavedReview;
|
|
77
|
-
/** Where the run stood when its turn was stopped: the person's last message, by its timeline row's id (its store
|
|
78
|
-
* entry's), or the root conversation's place 0 before any. It stays stopped until a message newer than that is shown. */
|
|
79
|
-
stopped_at?: string;
|
|
80
|
-
/** A run stopped by an older server: how many messages the person had sent then. Read only when `stopped_at` is not. */
|
|
81
|
-
stopped_after?: number;
|
|
82
|
-
/** What its newest process took its thinking level from (app.ts's thinkingOf), as its environment had them: `effort`,
|
|
83
|
-
* the run's effort, and `host`, the host's AGENT_THINKING. Absent for a process an older server started. */
|
|
84
|
-
launch_thinking?: {
|
|
85
|
-
effort?: string;
|
|
86
|
-
host?: string;
|
|
87
|
-
};
|
|
88
|
-
/** Its tools' providers, resolved at its first launch and kept for its life (tool-plane.ts). */
|
|
89
|
-
tool_plane?: Plane;
|
|
90
|
-
/** Set when a server found the run going with a browser sign-in it could not read (its seal key changed): the run was
|
|
91
|
-
* stopped, and its store is never read for rows, which could repeat the pointer uncut. */
|
|
92
|
-
unshown?: true;
|
|
93
|
-
/** Set once a launch handed the run its agent's browser sign-in: the SHA-256 of each pointer it was handed (never a
|
|
94
|
-
* pointer), one per pointer, in the order handed. Only such a run's text could repeat one, so only such a run is
|
|
95
|
-
* stopped and hidden, or withheld, while any of them can't be read back; and a hidden one is shown again once every one
|
|
96
|
-
* of them can, live or forgotten. MALFORMED for a value this server did not write (handedMark). */
|
|
97
|
-
sign_in_handed?: Handed;
|
|
98
|
-
/** Where it runs, as its start resolved it (place.ts): its process reads it. Absent for a run an older server started,
|
|
99
|
-
* which ran on the runner. */
|
|
100
|
-
place?: Place;
|
|
101
|
-
/** Where the run's learning stands (learning.ts); absent for a run that does not learn. */
|
|
102
|
-
learning?: Learning;
|
|
103
|
-
/** The run's end-of-run turn, saved before it is asked. */
|
|
104
|
-
reflect?: Reflect;
|
|
105
|
-
/** A run whose cost was unknown when it ended: the sum of its charges whose cost is known, and how many have none
|
|
106
|
-
* (costsofar/1), as its view said then, so a list row read from the store says it too. */
|
|
107
|
-
cost_so_far?: SoFar;
|
|
108
|
-
/** A person's answer to each tool call that waited for approval (tool-gate.ts), by its id: the first one wins, and
|
|
109
|
-
* the run's process reads it here. A cancel marks one still waiting canceled. */
|
|
110
|
-
approvals?: Record<string, ApprovalAnswer>;
|
|
111
|
-
/** A cancel that waits for the run's gate to cut the approved calls it overrode (Runs.cancel): their ids, kept so an
|
|
112
|
-
* operator (and a test) reads that it did, never how long it took. Absent on a cancel that waits on nothing. */
|
|
113
|
-
cancel_waits_for?: string[];
|
|
114
|
-
/** The trigger that started it, and its firing's key (triggers.ts); absent for a run a caller started. */
|
|
115
|
-
trigger?: RunTrigger;
|
|
116
|
-
/** Who its first message is from when its person did not write it (a trigger's firing, pi-durable-agent's
|
|
117
|
-
* MessageOrigin): sent with that message, and with it again by a relaunch. Absent: the person's. */
|
|
118
|
-
input_origin?: MessageOrigin;
|
|
119
|
-
};
|
|
120
|
-
type RunError = {
|
|
121
|
-
code: string;
|
|
122
|
-
message: string;
|
|
123
|
-
retryable: boolean;
|
|
124
|
-
details?: {
|
|
125
|
-
reason: string;
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
/** Why an escalated workflow run waits for a person: the escalation's kind, the escalate node's label, its summary,
|
|
129
|
-
* and when the run ended (`at`, the run's `ended_at`). */
|
|
130
|
-
export type RunReview = {
|
|
131
|
-
kind: string | null;
|
|
132
|
-
node: string | null;
|
|
133
|
-
reason: string;
|
|
134
|
-
at: string;
|
|
135
|
-
};
|
|
136
|
-
/** A review as serve.json keeps it: `at` is not kept, as it is the run's saved end, which the store stamps. */
|
|
137
|
-
type SavedReview = Omit<RunReview, "at">;
|
|
138
|
-
/** One run as this server holds it. */
|
|
139
|
-
/** A run's answer or output as a view served it: `out`, redacted from `input` over the held values whose digest is `keys`. */
|
|
140
|
-
type Served = {
|
|
141
|
-
keys: string;
|
|
142
|
-
input: unknown;
|
|
143
|
-
out: unknown;
|
|
144
|
-
};
|
|
145
|
-
export type Run = {
|
|
146
|
-
/** Set at load when its serve.json was there but could not be read or parsed (readMeta): what it was handed is not
|
|
147
|
-
* known, as forget reads of it from disk. */
|
|
148
|
-
damaged?: true;
|
|
149
|
-
id: string;
|
|
150
|
-
/** The values of the secrets each launch handed its process: what its errors never show, a key rotated since included. */
|
|
151
|
-
handed?: Set<string>;
|
|
152
|
-
/** What a view last served of its answer and its workflow output (runs.ts servedOnce), with what it was made from. */
|
|
153
|
-
served?: {
|
|
154
|
-
answer?: Served;
|
|
155
|
-
output?: Served;
|
|
156
|
-
};
|
|
157
|
-
agentId: string;
|
|
158
|
-
kind: RevisionKind;
|
|
159
|
-
revision: string;
|
|
160
|
-
/** The harness its revision names (pi when it names none, or its revision is gone). */
|
|
161
|
-
harness: string;
|
|
162
|
-
/** The newest store entry the run has shown. */
|
|
163
|
-
lastEntry?: number;
|
|
164
|
-
/** What the live path's rows keep served (keepCommitted), for a learning row shown between its snapshots. */
|
|
165
|
-
keep?: (id: string) => boolean;
|
|
166
|
-
/** The ids of the rows only the served view made for it (servedOnly), which the live path's keep never holds. */
|
|
167
|
-
madeHere?: Set<string>;
|
|
168
|
-
/** What its pinned revision's tools resolve from (tool-plane.ts), resolved again at each launch. */
|
|
169
|
-
tooling?: Tooling;
|
|
170
|
-
/** Imported history (`agentrun-serve import`): the source it was run in, and its id there. It takes no message, and a
|
|
171
|
-
* stop or a cancel moves nothing. */
|
|
172
|
-
imported?: {
|
|
173
|
-
source: string;
|
|
174
|
-
session: string;
|
|
175
|
-
};
|
|
176
|
-
/** The revision's number among its agent's. */
|
|
177
|
-
version: number;
|
|
178
|
-
dir: string;
|
|
179
|
-
meta: RunMeta;
|
|
180
|
-
log: RowLog;
|
|
181
|
-
/** The run's rows as they come in (before the log names them), with each `ask_person` answer's waiting row. */
|
|
182
|
-
rows: TimelineEvent[];
|
|
183
|
-
/** The reducer of its door's events that makes those rows (follow): the newest connection's once its snapshot is in,
|
|
184
|
-
* the one before it until then. */
|
|
185
|
-
timeline?: ReturnType<typeof timelineReducer>;
|
|
186
|
-
/** The person's messages the run took, and how each one's turn ended (turns.ts): its end is read from them. */
|
|
187
|
-
turns: Turns;
|
|
188
|
-
/** Its tool calls that waited for a person's approval, read from its store's entries, by id. */
|
|
189
|
-
approvals?: Map<string, Approval>;
|
|
190
|
-
/** Each resume row's approval, by the row's id (stable: rows upsert by id), noted the first time the row comes in with
|
|
191
|
-
* the gate's head (withApprovals). A row already rewritten no longer starts with that head, so an answer's restate
|
|
192
|
-
* reads the link from here, never from the row's text. Rebuilt from the store's rows, which keep the head, when a
|
|
193
|
-
* run is opened. */
|
|
194
|
-
resumeRows?: Map<string, string>;
|
|
195
|
-
/** The whole text of each assistant message of its end-of-run turn, by store entry: what the turn answered, whose
|
|
196
|
-
* notes learning reads (learning-run.ts). */
|
|
197
|
-
turnText?: Map<number, string>;
|
|
198
|
-
/** What was said to it, whole, by store entry, as its learning's grader reads it (heard.ts): the person's words, and a
|
|
199
|
-
* trigger's input apart by its source. */
|
|
200
|
-
hearing?: Hearing;
|
|
201
|
-
child?: ChildProcess;
|
|
202
|
-
/** The pid of a run process an earlier server started that still serves the run: supervised by the holder its row names. */
|
|
203
|
-
orphan?: number;
|
|
204
|
-
/** That process as its row names it (its pid, its start, this boot): what a signal to it is checked against. */
|
|
205
|
-
orphanHolder?: RunHolder;
|
|
206
|
-
/** A stop of that process kept pending while its identity cannot be checked (terminate): tried again every second. */
|
|
207
|
-
stopPending?: NodeJS.Timeout;
|
|
208
|
-
/** That pending stop has been said in the log: once for as long as it waits. */
|
|
209
|
-
stopWaits?: boolean;
|
|
210
|
-
/** Adopted with a saved stop: its first snapshot is checked once, and a turn still working is aborted. */
|
|
211
|
-
finishStop?: boolean;
|
|
212
|
-
/** A completed run opening again for a follow-up: every follow-up meanwhile waits for this one, never a second. */
|
|
213
|
-
reopening?: Promise<void>;
|
|
214
|
-
/** A follow-up to a run whose turn had ended is on its way: a launch it makes opens the run for it (FOLLOW_UP_OPEN_ENV). */
|
|
215
|
-
followUpOpen?: true;
|
|
216
|
-
feed?: AbortController;
|
|
217
|
-
/** An agentic run's turn is running; a workflow run's process serves. */
|
|
218
|
-
working: boolean;
|
|
219
|
-
/** Messages this server sent the run that its rows do not show yet. */
|
|
220
|
-
submitted: number;
|
|
221
|
-
/** The write of its end-of-run turn's origin (toLiveDoor), which a person's turn waits for before it removes it. */
|
|
222
|
-
originWrite?: Promise<unknown>;
|
|
223
|
-
/** The user_message rows the run has shown, by id: one shown for the first time is a submitted message arriving. */
|
|
224
|
-
users: Set<string>;
|
|
225
|
-
/** The rows the live path has shown as live, by id, over every connection to the run's door. */
|
|
226
|
-
live: Set<string>;
|
|
227
|
-
cancel: boolean;
|
|
228
|
-
/** Set when the run has answered or failed and is being let go; the outcome it gets. */
|
|
229
|
-
finishing?: Status;
|
|
230
|
-
/** A stop on its way: from its mark to its abort's answer, or a server's abort of a saved stop's turn that outlived the
|
|
231
|
-
* server before it (finishStop). The abort withdraws every input queued behind that turn, so a message meanwhile waits
|
|
232
|
-
* for it (message). */
|
|
233
|
-
stopping?: true;
|
|
234
|
-
endedAt?: string;
|
|
235
|
-
outcome?: Status;
|
|
236
|
-
error?: RunError;
|
|
237
|
-
/** The cost the store recorded when it carried the run back; null when it recorded none (unknown). */
|
|
238
|
-
costUsd?: number | null;
|
|
239
|
-
/** A workflow run's decisions' cost, from its receipts once its end is read: null when one is unknown. */
|
|
240
|
-
decisionCost?: number | null;
|
|
241
|
-
/** The same decisions, apart: the sum of the costs that are known, and how many are not. */
|
|
242
|
-
decisionsPriced?: {
|
|
243
|
-
known: number;
|
|
244
|
-
unpriced: number;
|
|
245
|
-
};
|
|
246
|
-
/** The saved sign-in its next launch hands its browser (pinSignIn), never kept on disk by the run. */
|
|
247
|
-
signIn?: HandedSignIn;
|
|
248
|
-
/** Whether its process, as last settled, let the run go (and its browser's sessions with it), or went without. */
|
|
249
|
-
letGo?: boolean;
|
|
250
|
-
/** A workflow run's decision rows, from its released store: its timeline shows one row each (decision-rows.ts). Null
|
|
251
|
-
* when they cannot be read: its timeline's usage row then reads unknown. */
|
|
252
|
-
decisions?: Record<string, unknown>[] | null;
|
|
253
|
-
/** How many of a workflow run's llm calls' answers its node log held when its rows were last read: their cost is in its
|
|
254
|
-
* rows (each a REQUEST_COST entry, committed before its answer is logged), so its graph counts only the later ones. */
|
|
255
|
-
llmRead?: number;
|
|
256
|
-
/** What every conversation of its store says it used, as the settle that ends it read them. */
|
|
257
|
-
metrics?: RunMetrics;
|
|
258
|
-
relaunches: number;
|
|
259
|
-
/** Its start's launch is next: the one a deny is told as under ask (relaunchPlane's `first`). */
|
|
260
|
-
firstLaunch?: true;
|
|
261
|
-
/** Its newest launch has not reported back: its mark (RUN_LAUNCHING) is on disk. */
|
|
262
|
-
launching?: boolean;
|
|
263
|
-
/** The store has it running and its serve.json holds no input: its server went down before it set the run up (whose
|
|
264
|
-
* first write is the input), so it never launched. A serve.json written since (its failure, a stop) never adds one. */
|
|
265
|
-
notSetUp?: boolean;
|
|
266
|
-
/** Its files being copied into its work/ before its first launch, until they are: nothing launches it meanwhile (a
|
|
267
|
-
* request that would waits for it), and nothing but a cancel settles it. */
|
|
268
|
-
preparing?: Promise<void>;
|
|
269
|
-
/** Its harness being installed before its first launch (claude-agent's Claude Code or codex's Codex, on first use:
|
|
270
|
-
* harness-install.ts): true
|
|
271
|
-
* once it is, false when the install failed and the run ended so. Nothing launches it meanwhile, and a request that
|
|
272
|
-
* would waits for it. */
|
|
273
|
-
installing?: Promise<boolean>;
|
|
274
|
-
/** It shows the install's row (its words, since `at`) while it waits for an install that runs. */
|
|
275
|
-
installRow?: {
|
|
276
|
-
at: string;
|
|
277
|
-
words: string;
|
|
278
|
-
};
|
|
279
|
-
/** A raised workflow run whose process the pause let go, waiting for a place under the server's limits before it opens
|
|
280
|
-
* again (finishRaise): its words, since `at`, shown as a row; queued meanwhile. Its pause's mark stays until it opens,
|
|
281
|
-
* so a restart finishes the raise the same way. */
|
|
282
|
-
placeWait?: {
|
|
283
|
-
at: string;
|
|
284
|
-
words: string;
|
|
285
|
-
};
|
|
286
|
-
/** The tries in a row whose launch failed after its place was taken (finishRaise): back of the queue after each, and
|
|
287
|
-
* off it after RAISE_TRIES, its mark kept, so a run whose launch keeps failing never holds a place reserved. */
|
|
288
|
-
raiseTries?: number;
|
|
289
|
-
/** A raise whose launch failed RAISE_TRIES times: why, since `at`, shown as a row while the run stays paused at its
|
|
290
|
-
* cap, so the owner reads that the raise was taken and the run could not start, not a call for another raise. */
|
|
291
|
-
raiseFailedRow?: {
|
|
292
|
-
at: string;
|
|
293
|
-
words: string;
|
|
294
|
-
};
|
|
295
|
-
/** The pause at its cap the watch last read (connect: its notice key), so a new one, or one written again, is told. */
|
|
296
|
-
pauseSeen?: string;
|
|
297
|
-
/** budget.json's time and size at the watch's last read, so an unchanged file is not read again. */
|
|
298
|
-
pauseStamp?: string;
|
|
299
|
-
/** It waits for its harness's install before a launch (harnessReady): takePlace counts it as holding a place until
|
|
300
|
-
* that launch, so nothing takes its place meanwhile. A cancel or an end lets the place go. */
|
|
301
|
-
waitsInstall?: boolean;
|
|
302
|
-
settled: boolean;
|
|
303
|
-
settling?: Promise<void>;
|
|
304
|
-
/** The newest write of its serve.json: one at a time, in order. */
|
|
305
|
-
saving?: Promise<void>;
|
|
306
|
-
/** Settles of this run not yet done: while any is, nothing starts its process again. */
|
|
307
|
-
settles: number;
|
|
308
|
-
updatedAt: string;
|
|
309
|
-
/** Its own door token (RUN_DOOR_TOKEN), once read or made; absent for a run an older server started, whose door takes
|
|
310
|
-
* the server-wide one. */
|
|
311
|
-
doorToken?: string;
|
|
312
|
-
/** A remote box's making and seed, asked by the run's process through the relay: one at a time. */
|
|
313
|
-
boxing?: Promise<{
|
|
314
|
-
id: string;
|
|
315
|
-
made: boolean;
|
|
316
|
-
replaced?: boolean;
|
|
317
|
-
}>;
|
|
318
|
-
/** Its remote box's newest pull: a read of its files waits for it. */
|
|
319
|
-
pulling?: Promise<void>;
|
|
320
|
-
/** Its launch waits on its claim, tried again later (launch): it keeps its place in the server's limits (takePlace). */
|
|
321
|
-
claimWait?: boolean;
|
|
322
|
-
/** Why that claim waits, in words, for a request's 503 (notUp). */
|
|
323
|
-
claimWaitWhy?: string;
|
|
324
|
-
/** Why its newest process was stopped unopened (the ready time passed, its door's last answer): the reason its run
|
|
325
|
-
* fails with when that was its last launch, since the process's own log does not say it. */
|
|
326
|
-
notOpened?: string;
|
|
327
|
-
/** The door the process this server started said it serves (its stdout line): this server's own record of it, so a
|
|
328
|
-
* row the agent store cannot take yet never keeps the door from it. */
|
|
329
|
-
door?: string;
|
|
330
|
-
/** The holder its row is still to name (nameHolder), while a store another writer holds keeps the write waiting. */
|
|
331
|
-
naming?: {
|
|
332
|
-
epoch: number;
|
|
333
|
-
holder: RunHolder;
|
|
334
|
-
tries: number;
|
|
335
|
-
};
|
|
336
|
-
/** How many launches in a row its claim was refused: the next try comes sooner while it is few. */
|
|
337
|
-
claimTries?: number;
|
|
338
|
-
/** The last of its database's reads and take-back checkpoint (runs.ts runDb): the next waits for it. */
|
|
339
|
-
dbQueue?: Promise<void>;
|
|
340
|
-
/** It stood waiting for the person when last marked: a turn's end is the change into that. */
|
|
341
|
-
waited?: boolean;
|
|
342
|
-
/** The pause at its cap (its mark) whose process was let go: once per pause. */
|
|
343
|
-
parked?: string;
|
|
344
|
-
/** A raise of its cap being taken (raiseCap): the next one waits for it, so two at once resume it once. */
|
|
345
|
-
raising?: Promise<unknown>;
|
|
346
|
-
/** Its raise's follow-up is being sent (resumeRaised), or waits to be tried again (its time): never two at once. */
|
|
347
|
-
resuming?: "sending" | number;
|
|
348
|
-
/** Its newest refusal for room's figures, from that refusal's own start mark (cap.ts RefusalFigures): all three, or
|
|
349
|
-
* none. */
|
|
350
|
-
capRefusal?: RefusalFigures;
|
|
351
|
-
/** That refusal's own start mark (its entry): the pause a raise answers is keyed to it (pauseOf). */
|
|
352
|
-
capMark?: number;
|
|
353
|
-
/** What it has spent paused at that refusal (its row), its process gone: the store's spend (spentNow), read once. */
|
|
354
|
-
capSpent?: {
|
|
355
|
-
mark: string;
|
|
356
|
-
usd: number | null;
|
|
357
|
-
at?: number;
|
|
358
|
-
};
|
|
359
|
-
/** Its model requests' bounds (cap.ts BOUND_FIELD: the most a cache miss can make one cost beyond its hold), as its
|
|
360
|
-
* entries say them (bounds.ts). */
|
|
361
|
-
bounds?: RequestBounds;
|
|
362
|
-
};
|
|
363
|
-
/** The row a run shows while its harness installs for it (harness-install.ts), since `at`. */
|
|
364
|
-
/** The row a raised workflow run shows once its launch failed RAISE_TRIES times (finishRaise), since `at`. */
|
|
365
|
-
export declare const raiseFailedRow: ({ at, words }: {
|
|
366
|
-
at: string;
|
|
367
|
-
words: string;
|
|
368
|
-
}) => TimelineEvent;
|
|
369
|
-
/** The row a raised workflow run shows while it waits for a place to open again in (finishRaise), since `at`. */
|
|
370
|
-
export declare const placeRow: ({ at, words }: {
|
|
371
|
-
at: string;
|
|
372
|
-
words: string;
|
|
373
|
-
}) => TimelineEvent;
|
|
374
|
-
export declare const installRow: ({ at, words }: {
|
|
375
|
-
at: string;
|
|
376
|
-
words: string;
|
|
377
|
-
}) => TimelineEvent;
|
|
378
|
-
/** What a stop keeps of where the run stands: the person's last message, by its id, or the place before any. */
|
|
379
|
-
export declare const stopMark: (rows: readonly TimelineEvent[]) => {
|
|
380
|
-
stopped_at: string;
|
|
381
|
-
};
|
|
382
|
-
/** The rows a snapshot that no longer holds them leaves served: those committed entries made. A row any connection
|
|
383
|
-
* showed live is not one (`live` holds them for the run), so a live row that ended while the door was away goes. */
|
|
384
|
-
/** The live path's keep: a row a committed entry made stays served though a later snapshot no longer holds it (the
|
|
385
|
-
* timeline only grows); a row the reducer showed live does not, nor one only the served view makes (`madeHere`, the ids
|
|
386
|
-
* show() tagged servedOnly, read as it grows), which goes once show() stops making it. */
|
|
387
|
-
export declare function keepCommitted(live: Set<string>, rows: readonly TimelineEvent[], isLive: (id: string) => boolean, madeHere?: ReadonlySet<string>): (id: string) => boolean;
|
|
388
|
-
/** A run's status and state, by the contract's table (run-view.ts statusOf). The table is read over the run's rows, its
|
|
389
|
-
* turns and its store entries; the file-backed facts (a workflow paused at its cap or in its process, the browser ask)
|
|
390
|
-
* this server reads from the run's directory and passes in. The store-backed view builds the same facts from the run's
|
|
391
|
-
* row and journal, so the status a person or a model sees is the same. The facts are thunks, read only where the table
|
|
392
|
-
* reaches them, so the hot path (an ended or stopped run) touches no file, as it did when the reads lived here. */
|
|
393
|
-
export declare function statusOf(run: Run): {
|
|
394
|
-
status: Status;
|
|
395
|
-
state: State;
|
|
396
|
-
};
|
|
397
|
-
/** The waits between carry backs that found the store busy, and a hook called at each such refusal. */
|
|
398
|
-
export type CarryBackRetry = {
|
|
399
|
-
delaysMs?: readonly number[];
|
|
400
|
-
onBusy?: (runId: string, attempt: number) => void;
|
|
401
|
-
};
|
|
402
|
-
/** How a run is asked to start: its input and title, its effort and cap, and what puts its files in its work/. `origin`:
|
|
403
|
-
* the store's key for what asked (an Idempotency-Key's, a trigger's firing): a key that already started a run gets that
|
|
404
|
-
* run. `trigger`: the trigger and firing that started it. */
|
|
405
|
-
export type StartOptions = {
|
|
406
|
-
input: Json;
|
|
407
|
-
title: string;
|
|
408
|
-
place: Place;
|
|
409
|
-
effort?: string;
|
|
410
|
-
maxCostUsd?: number;
|
|
411
|
-
capMode?: CapMode;
|
|
412
|
-
trigger?: RunTrigger;
|
|
413
|
-
inputs?: (work: string) => Promise<unknown>;
|
|
414
|
-
origin?: RunOrigin; /** Who the first message is from, when not the person (RunMeta.input_origin). */
|
|
415
|
-
from?: MessageOrigin;
|
|
416
|
-
};
|
|
417
|
-
/** `token` is the server's own: no run's process sees it. */
|
|
418
|
-
/** `maxRuns`: the most runs with a live process at once; `settleRetryMs`: how often a carry back the store refused is
|
|
419
|
-
* tried again; `readyTimeoutMs`: how long a request to a run waits for its door (a run's first message, sent by its
|
|
420
|
-
* start, always waits READY_TIMEOUT_MS); `openTimeoutMs`: how long a launched process has to open its run (READY_TIMEOUT_MS,
|
|
421
|
-
* the first message's wait, by default; never the request's wait); `log` takes a run's start and end (print.ts). */
|
|
422
|
-
export type RunsOptions = {
|
|
423
|
-
installs?: Readonly<Record<string, {
|
|
424
|
-
readonly installed: boolean;
|
|
425
|
-
readonly installingWords: string;
|
|
426
|
-
needed(): Promise<boolean>;
|
|
427
|
-
ensure(): Promise<void>;
|
|
428
|
-
}>>; /** What a run's Docker box reaches, as the server resolved it (run-box.ts boxNetworkOf): the list, or none. Absent, none. */
|
|
429
|
-
dockerAllow?: readonly string[] | "none"; /** On a Mac, the server's proxy container's volume a run's Docker box mounts (box-egress-vm.ts). */
|
|
430
|
-
dockerVolume?: string; /** A server in a container: where its Docker has the data directory (box-paths.ts), which a run's Docker box mounts from. Absent on a host. */
|
|
431
|
-
dockerPaths?: BoxPaths;
|
|
432
|
-
agents: Agents;
|
|
433
|
-
token: string; /** The server's saved tool keys, read by name for its runs alone (secrets.ts). */
|
|
434
|
-
storedKeys?: StoredKeys; /** The server's saved MCP servers (mcp-servers.ts): a run's pin and its credentials come from them at each launch. */
|
|
435
|
-
mcpServers?: McpServerSource;
|
|
436
|
-
documents?: string;
|
|
437
|
-
doorTokenFile: string;
|
|
438
|
-
doorToken: string; /** The test switches a run's process gets (server.ts fauxEnvOf): empty outside tests. */
|
|
439
|
-
fauxEnv?: NodeJS.ProcessEnv;
|
|
440
|
-
runBoxes?: BoxProvider; /** The server's Daytona provider, with its key: remote boxes are made, seeded, pulled and destroyed with it, here alone (box-relay.ts). */
|
|
441
|
-
remoteBoxes?: BoxProvider; /** Daytona's API and the same key, for what the provider does not do: a kept box's idle stop, and its wake at a start (daytona-api.ts). */
|
|
442
|
-
remoteApi?: DaytonaApi; /** The server's VM box provider, with its client: a VM run's box is made, seeded, pulled and ended with it, here alone, as a Daytona one is (box-relay-vm.ts); it has no network. */
|
|
443
|
-
vmBoxes?: BoxProvider; /** A VM box's limits (run-box.ts RemoteLimits), from the box settings. */
|
|
444
|
-
vmLimits?: RemoteLimits; /** The relay's VM half, which lets go of a run's programs at its end. */
|
|
445
|
-
vmRelay?: {
|
|
446
|
-
drop(runId: string): void;
|
|
447
|
-
}; /** The hosts a remote box may reach (run-box.ts boxAllowOf); `none`, or absent, for none. */
|
|
448
|
-
boxAllow?: readonly string[] | "none"; /** Called once, with the provider's refusal's code and words, when it cannot keep that list here: from then on each remote box is made with no network. */
|
|
449
|
-
onNoBoxList?: (code: string, message: string) => void;
|
|
450
|
-
toolSettings?: () => ToolSettingsMap; /** Whether anyone can answer a tool call's approval here (accounts on); false, the run's gate refuses each ask (tool-gate.ts). */
|
|
451
|
-
approvers?: boolean;
|
|
452
|
-
drainTimeout?: string;
|
|
453
|
-
carryBackRetry?: CarryBackRetry;
|
|
454
|
-
maxRuns?: number;
|
|
455
|
-
box?: {
|
|
456
|
-
host: BoxHost;
|
|
457
|
-
quarantine: Quarantine;
|
|
458
|
-
};
|
|
459
|
-
settleRetryMs?: number;
|
|
460
|
-
readyTimeoutMs?: number;
|
|
461
|
-
openTimeoutMs?: number; /** Under --faux only (server.ts): the nonce handed to each run's process in place of its launch's. */
|
|
462
|
-
fauxHandedNonce?: string;
|
|
463
|
-
reflectTimeoutMs?: number; /** How much of what a run learned its instructions hold, in bytes (`--learning-budget`, learning.ts learnedOf). */
|
|
464
|
-
learningBudget?: number;
|
|
465
|
-
log?: (event: string, fields: Record<string, string | number>) => void;
|
|
466
|
-
notify?: RunNotify;
|
|
467
|
-
learning?: LearningMode; /** Each agent's saved sign-ins (sign-ins.ts): absent, no run gets one. */
|
|
468
|
-
signIns?: SignIns; /** Every secret this server never shows (server.ts serverSecrets), read at each call, so one made or rotated is cut at once: the host's and the keys saved on it, read through `stored` when given (learning's view keeps the saved keys it read), its tokens, and each it holds (server-secrets.ts). What a run shows, its title among it, and what its learning keeps are cut of it. */
|
|
469
|
-
serverSecrets: (stored?: StoredKeys) => string[]; /** The current name of a trigger by its id, from the store (server.ts triggerNameOf): resolved once when a run is loaded (a run restored after a restart still names its trigger), and a firing's start and a rename push it in (triggerChanged), so servedTriggerRow reads it with no store read. */
|
|
470
|
-
triggerName?: (id: string) => Promise<string | undefined>;
|
|
471
|
-
};
|
|
472
|
-
/** Told of a run's moment each time it is seen (webhooks.ts' emit, which queues each one once): a wait it reached, and an
|
|
473
|
-
* end once the agent store has it. `marker` names the moment (the person's turn it waits at, the end's time), the same
|
|
474
|
-
* when another server sees it again. It says what came of it: `unsaved`, not in the outbox on disk yet. */
|
|
475
|
-
export type RunNotify = (event: (typeof RUN_EVENTS)[number], run: RunNotice & {
|
|
476
|
-
status: Status;
|
|
477
|
-
}, marker: string) => Emitted;
|
|
478
|
-
/** Why a message that may not answer a person's question is not sent. */
|
|
479
|
-
export declare const WAITS_ON_A_PERSON = "The run is waiting on a person.";
|
|
480
|
-
/** The secrets a run's process is handed over its pipe (secrets.ts): every one but the server's own and the decision
|
|
481
|
-
* keys, which go on their own descriptor. */
|
|
482
|
-
export declare const RUN_SECRETS: string[];
|
|
483
|
-
type KeyRow = {
|
|
484
|
-
kind: string;
|
|
485
|
-
fields: readonly string[];
|
|
486
|
-
unlocks: readonly string[];
|
|
487
|
-
};
|
|
488
|
-
/** What of a revision decides the secrets its runs are handed, none of it a key, read once per revision (a revision
|
|
489
|
-
* never changes): its harness, the model it names, the tools it binds (named as its process binds them, app.ts: an
|
|
490
|
-
* agentic revision's `tools`, a workflow's on its model nodes and its `call` nodes), a workflow's tiers (those its model
|
|
491
|
-
* nodes and `llm` calls run on), and its decision providers (decisions.ts' decisionKeysFor: a workflow's decision
|
|
492
|
-
* nodes', providersNamed, Jev for a node that names none; an agentic revision's, none). Names only: no instruction and
|
|
493
|
-
* no skill. */
|
|
494
|
-
export type RunNeeds = {
|
|
495
|
-
harness: string;
|
|
496
|
-
model?: string;
|
|
497
|
-
tools: readonly string[];
|
|
498
|
-
tiers?: readonly Tier[];
|
|
499
|
-
decisionProviders: readonly string[];
|
|
500
|
-
};
|
|
501
|
-
/** `revision`'s RunNeeds. */
|
|
502
|
-
export declare function needsOf(revision: Revision): Promise<RunNeeds>;
|
|
503
|
-
/** The secrets a run of `needs` is handed over its pipe, by the keys `env` holds now: RUN_SECRETS but each field of a
|
|
504
|
-
* `tool` row of `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does
|
|
505
|
-
* not need, from the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the
|
|
506
|
-
* gateway's (model.ts' modelKeys: its own model, or the host's of each tier it runs); a run on an adapter's, the
|
|
507
|
-
* one key its wire's route sends for the revision's model (adapters.ts' harnessModelKeys). Read at each launch, so a key
|
|
508
|
-
* saved with no restart counts at the next. */
|
|
509
|
-
export declare function keysFor(needs: RunNeeds, env: NodeJS.ProcessEnv, rows?: readonly KeyRow[]): string[];
|
|
510
|
-
/** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
|
|
511
|
-
export declare function secretsFor(revision: Revision, rows?: readonly KeyRow[], env?: NodeJS.ProcessEnv): Promise<string[]>;
|
|
512
|
-
/** The decision providers a run of `revision` needs keys for (needsOf). Its web tools' need, Parallel's where one
|
|
513
|
-
* resolves to Parallel, is its tool plane's (tool-plane.ts' handsParallel), read at each launch. */
|
|
514
|
-
export declare function decisionProvidersFor(revision: Revision): Promise<readonly string[]>;
|
|
515
|
-
/** A run's process's environment: no secret in it (they go over its pipe), nor the token by value; the AGENT_MODEL
|
|
516
|
-
* variables and the rest pass, and the door token goes by file. A test hook's name passes never (withoutFaux): the run
|
|
517
|
-
* gets one only from startServe's options. */
|
|
518
|
-
export declare const childEnv: (env: NodeJS.ProcessEnv, token: string) => NodeJS.ProcessEnv;
|
|
519
|
-
/** The line of the run process's log a failure's message is made of: its last, past any harness's own lines (a proxy's
|
|
520
|
-
* refusal just before a crash says nothing of why the process went). */
|
|
521
|
-
export declare function failureLine(log: string): string;
|
|
522
|
-
/** The last line of the run process's log, in words, for a failure's message. */
|
|
523
|
-
export declare function lastLogLine(run: Pick<Run, "dir">): Promise<string>;
|
|
524
|
-
/** Seams for tests, each unset in a server: `personsTurn` holds a person's turn just after its origin went;
|
|
525
|
-
* `beforeRestartCheck` holds a settle that found the run's process gone just before it decides whether to open it again. */
|
|
526
|
-
export declare const runsTestHooks: {
|
|
527
|
-
personsTurn?: (runDir: string) => Promise<void> | void;
|
|
528
|
-
beforeRestartCheck?: (runDir: string) => Promise<void> | void;
|
|
529
|
-
};
|
|
530
|
-
export declare class Runs {
|
|
531
|
-
#private;
|
|
532
|
-
private readonly options;
|
|
533
|
-
private readonly runs;
|
|
534
|
-
/** The current name of each trigger a held run names, by its id (servedTriggerRow): pushed in at a firing's start (the
|
|
535
|
-
* run's trigger), on a rename or delete (server.ts triggerChanged), and resolved once when a run is loaded, so a
|
|
536
|
-
* served row names its trigger with no store read. `undefined` for a trigger that is gone. */
|
|
537
|
-
private readonly triggerNames;
|
|
538
|
-
/** The last entry each run's database reads have seen (run-db.ts): a read behind it is never shown. */
|
|
539
|
-
private readonly reads;
|
|
540
|
-
/** The disk the runs' folders are on (disk.ts): on this machine, the data directory's own. */
|
|
541
|
-
private get disk();
|
|
542
|
-
/** What decides the secrets each revision's runs are handed (needsOf), by revision id: read once, from the revision the
|
|
543
|
-
* run is pinned to, never from a request. The keys themselves are read at each launch (keysFor). */
|
|
544
|
-
private readonly needs;
|
|
545
|
-
private readonly adopting;
|
|
546
|
-
/** The runs this process is starting, from the store's row until the run is held (start): its serve.json and its seed
|
|
547
|
-
* copy are written in between. A read of one waits for its start and never loads it from disk, where it would look
|
|
548
|
-
* like a run a stopped server left mid-copy. Null once a start failed. */
|
|
549
|
-
private readonly startingRuns;
|
|
550
|
-
/** The hosts this server's next remote box asks for: the setting's, until the provider cannot keep a list here, then none. */
|
|
551
|
-
private remoteAllow;
|
|
552
|
-
private readonly clock;
|
|
553
|
-
private readonly cli;
|
|
554
|
-
private readonly app;
|
|
555
|
-
private closing;
|
|
556
|
-
/** Raised workflow runs waiting for a place to open again in (finishRaise), tried again every PLACE_RETRY_MS. */
|
|
557
|
-
private placeWaiters;
|
|
558
|
-
private placeRetry;
|
|
559
|
-
private placeRetrying;
|
|
560
|
-
/** Set once `close` is done: the store is closed, so nothing settles after it. */
|
|
561
|
-
private closed;
|
|
562
|
-
/** Runs past the cap's check whose process is not started yet. */
|
|
563
|
-
private starting;
|
|
564
|
-
/** The memory the starts counted in `starting` reserve, in MiB. */
|
|
565
|
-
private startingMib;
|
|
566
|
-
/** This host's memory, out of which each live run reserves what its harness takes (host.ts), beside `maxRuns`. */
|
|
567
|
-
/** This host's memory for runs (host.ts); a test's seam sets it (startServe's `hostMemory`). */
|
|
568
|
-
memory: number;
|
|
569
|
-
/** The start sweep of the boxes runs left: once, before any run opens a box (sweepOnce). */
|
|
570
|
-
private swept?;
|
|
571
|
-
/** The runs' learning (learning-run.ts): a step this file calls as a run starts, ends, settles, opens again and is
|
|
572
|
-
* recovered, handed what it moves of a run. */
|
|
573
|
-
readonly learning: LearningRuns;
|
|
574
|
-
/** When this server took the data root (one server a root): a run started since is its own, never one to recover. */
|
|
575
|
-
private readonly bootedAt;
|
|
576
|
-
constructor(options: RunsOptions);
|
|
577
|
-
/** A test's seam (startServe's `beforeAbort`): awaited by a stop between its mark and its abort, so a test can hold a
|
|
578
|
-
* stop in flight there. */
|
|
579
|
-
beforeAbort?: (runId: string) => Promise<void> | void;
|
|
580
|
-
/** A test's seam (startServe's `beforeReopenLaunch`): awaited by a reopen after the run reads open again and before its
|
|
581
|
-
* launch, so a test can hold a reopen there. */
|
|
582
|
-
beforeReopenLaunch?: (runId: string) => Promise<void> | void;
|
|
583
|
-
/** A test's seam (startServe's `beforeRaiseLaunch`): awaited where a raise that opens a let-go workflow pins what its
|
|
584
|
-
* launch needs (finishRaise), after its place is taken; one that throws stands for a pin that fails there. */
|
|
585
|
-
beforeRaiseLaunch?: (runId: string) => Promise<void> | void;
|
|
586
|
-
/** A test's seam (startServe's `onPauseCheck`): told each stat and each read of a workflow run's pause by its watch. */
|
|
587
|
-
onPauseCheck?: (runId: string, what: "stat" | "read") => void;
|
|
588
|
-
/** A test's seam (startServe's `onRunLoad`): told each run read in from its store, its timeline with it. */
|
|
589
|
-
onRunLoad?: (runId: string) => void;
|
|
590
|
-
/** A test's seam (startServe's `beforeSubmit`): awaited by a message before it goes to the run's door. */
|
|
591
|
-
beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
|
|
592
|
-
/** A test's seam (startServe's `beforeMetaSave`): awaited before a run's serve.json is written; one that throws fails
|
|
593
|
-
* the write, as a full disk would. */
|
|
594
|
-
beforeMetaSave?: (runId: string, meta: Readonly<RunMeta>) => Promise<void> | void;
|
|
595
|
-
/** A test's seam (startServe's `messageOrigin`): the origin a message sent through the messages route carries. */
|
|
596
|
-
messageOrigin?: (runId: string, content: string) => MessageOrigin | undefined;
|
|
597
|
-
private get store();
|
|
598
|
-
/** Run `id` when this process holds it, never read from disk. */
|
|
599
|
-
held(id: string): Run | undefined;
|
|
600
|
-
/** Run `id`, read from the agent store the first time this process sees it. */
|
|
601
|
-
get(id: string): Promise<Run | null>;
|
|
602
|
-
/** One Run per run id, however many requests ask for it at once. */
|
|
603
|
-
private adopt;
|
|
604
|
-
private load;
|
|
605
|
-
private blank;
|
|
606
|
-
/** Writes the run's serve.json as it is when its turn comes; then tells learning what it now holds (the ledger's line
|
|
607
|
-
* once the run's learning ended). */
|
|
608
|
-
/** Writes the run's serve.json, after any write already under way: `meta`, a copy its caller publishes to run.meta
|
|
609
|
-
* only once this resolves (a raise, takeRaise), else run.meta, each as it stands when the write starts. */
|
|
610
|
-
private saveMeta;
|
|
611
|
-
/** The process that holds the run, as its row's claim names it (run-holder.ts); undefined for none, or the server. */
|
|
612
|
-
private holder;
|
|
613
|
-
/** Who holds the run, as its row says and the processes show: `unknown` when the row or the process listing cannot be
|
|
614
|
-
* read, which a caller never takes for a holder that is gone. */
|
|
615
|
-
private holderView;
|
|
616
|
-
/** The door a live run serves, from its row's holder: a process that lives (its pid, of the same start, on this boot)
|
|
617
|
-
* and a loopback address it named. */
|
|
618
|
-
private doorOf;
|
|
619
|
-
/** The record the run's process keeps in its own store (pi-durable-disk RUN_STATUS_TABLE: its status, `detail` and
|
|
620
|
-
* `wakeAt`), read lock-free; null when it has none or it cannot be read. */
|
|
621
|
-
private runRecord;
|
|
622
|
-
private storeFile;
|
|
623
|
-
/** The run's rows from its store, opened read-only; only once its claim is released. An agentic run's rows are its
|
|
624
|
-
* root conversation's; a workflow run's are its model nodes'. `atEnd`: a settle's read, which reads every
|
|
625
|
-
* conversation (a workflow's nodes, a harness's session) once and counts the run's metrics from all of them. */
|
|
626
|
-
private readStore;
|
|
627
|
-
/** `act` on run `run`'s database, after every earlier one on it: its reads and its take-back's checkpoint never meet. */
|
|
628
|
-
private runDb;
|
|
629
|
-
/** The server takes run `run` back once no process holds it: its claim's epoch is bumped, with the server as its
|
|
630
|
-
* holder (the disk's revoke, disk.ts), and only then its database checkpointed (run-db.ts), its WAL emptied into the
|
|
631
|
-
* database file. A run whose process still lives is not taken. A take-back that fails (the agent store held by another
|
|
632
|
-
* writer, or not writable) only warns: the run settles all the same, its database read with its WAL, and the next
|
|
633
|
-
* settle or start takes it back. */
|
|
634
|
-
private takeBack;
|
|
635
|
-
/** New rows in: into the log, then the run's status, then whatever the status asks for. */
|
|
636
|
-
/** `keep`: rows that stay served though `rows` no longer holds them (the live path's committed rows). */
|
|
637
|
-
private take;
|
|
638
|
-
/** The approval rows as the run's answers say them now (a stop or a cancel withdraws a call, an answer settles one),
|
|
639
|
-
* shown at once: an answer takes no new rows. */
|
|
640
|
-
private restate;
|
|
641
|
-
/** The run's rows into its log, as served: a workflow run's decisions and the run's learning row are the served view's
|
|
642
|
-
* only, never the run's own rows, which its cost and its answer are read from. */
|
|
643
|
-
private show;
|
|
644
|
-
/** A trigger's row as served: "<label> <its name>: <its first line>" for a trigger that has a name now; as the timeline
|
|
645
|
-
* wrote it, "<label> <its id>: …", for one that is gone. The name is put in after the run's rows were redacted, so it
|
|
646
|
-
* is redacted here with the run's redactor: a key pasted into a trigger's name never shows on its runs' rows. */
|
|
647
|
-
private servedTriggerRow;
|
|
648
|
-
/** Trigger `id` renamed or deleted, with its name now (`name`, undefined when it is gone): the name is pushed to the
|
|
649
|
-
* one the runs read (triggerNames), and each held run whose Timeline names it is shown again, its row naming the
|
|
650
|
-
* trigger as it is now. With no `id` (the triggers just read at a start): every run so named is shown again. */
|
|
651
|
-
triggerChanged(id?: string, name?: string | undefined): void;
|
|
652
|
-
/** A live process: the child this server started, or one an earlier server started that still serves the run. */
|
|
653
|
-
private live;
|
|
654
|
-
/** Run `id`'s status read again now: the owner answered its browser ask (browser-person.ts), so it is working again
|
|
655
|
-
* before its process has read the answer. */
|
|
656
|
-
remark(id: string): void;
|
|
657
|
-
/** Whether run `id` has a process serving it now: the child this server started, or an adopted one that is alive. A
|
|
658
|
-
* run's live browser view is that process's alone (browser-live.ts). */
|
|
659
|
-
hasProcess(id: string): boolean;
|
|
660
|
-
/** How an agentic run ends: over its cap, or as the turn of the person's newest message ended (turns.ts), once every
|
|
661
|
-
* message the run took has had its turn. Undefined while one is open, or when the run stopped, waits, or its turn
|
|
662
|
-
* ended interrupted (the run then waits for the person), or while its records name no message (a live process of an
|
|
663
|
-
* older server: the run's next process writes its turn's end as it opens). Never from the order of its rows, or from
|
|
664
|
-
* when its door said idle. A workflow run ends when its workflow does. */
|
|
665
|
-
private decide;
|
|
666
|
-
/** A run's error as a person reads it, in its error box and on its Timeline row alike: a refused key in plain words
|
|
667
|
-
* (plainKey), else the harness's text with no loopback address (withoutLoopback: Codex names serve's own proxy). */
|
|
668
|
-
private errorWords;
|
|
669
|
-
/** An error row as served: its summary and text in errorWords' terms, or the pause's phase row of a refusal for room the
|
|
670
|
-
* run paused at. The run's own rows, which its status reads, keep what the harness said. */
|
|
671
|
-
private servedError;
|
|
672
|
-
/** What serve shows of a run's error text, for every run kind (run-view.ts shownOf): no held secret and no loopback. */
|
|
673
|
-
private shown;
|
|
674
|
-
/** A run's error as its view and the run lists serve it (run-view.ts servedRunErrorWith): its message in shown()'s terms. */
|
|
675
|
-
private servedRunError;
|
|
676
|
-
/** A run's review as its view serves it (run-view.ts servedReviewWith): its reason in shown()'s terms, or withheld while
|
|
677
|
-
* the run is hidden (meta.unshown). */
|
|
678
|
-
private servedReview;
|
|
679
|
-
/** The pointers a run was handed, read back to cut them (sign-ins.ts peek and forgotten), by its serve.json's
|
|
680
|
-
* `sign_in_handed`: none for a run with no mark (it was never handed one); else, for each hash it names, the live or
|
|
681
|
-
* forgotten pointer whose SHA-256 it is. `unreadable` when what it was handed can't be read back here: a MALFORMED
|
|
682
|
-
* mark, no vendor browser kept beside the mark, the sign-ins file can't be read, or any of its hashes matches no
|
|
683
|
-
* pointer that opens (one under another seal key or none, one forgotten and dropped past MAX_FORGOTTEN, the sign-ins
|
|
684
|
-
* file gone). Fails closed: a marked run is cut of every pointer it was handed, or withheld, never served uncut. Read
|
|
685
|
-
* anew at each load: nothing caches this verdict, so a run withheld while its key was missing is shown once it opens. */
|
|
686
|
-
private handedPointers;
|
|
687
|
-
/** shown() for a run this server holds no Run for (an ended one a list reads from its row and serve.json alone, the
|
|
688
|
-
* summary choke point: run-view.ts rowShown): cut of every secret this server never shows (serverSecrets) and of what
|
|
689
|
-
* the run was handed of its agent's sign-in (handedPointers); `withheld` when that can't be read back here, as a load
|
|
690
|
-
* would hide the run. */
|
|
691
|
-
private rowShown;
|
|
692
|
-
/** A run's answer as serve serves it: no held secret, never cut (redactedAnswer). Loopback addresses stay: an answer is
|
|
693
|
-
* the model's own words, and a local address there can be what the person asked about. */
|
|
694
|
-
private servedAnswer;
|
|
695
|
-
/** A workflow run's output as serve serves it: each string in it as servedAnswer, its shape kept. */
|
|
696
|
-
private servedOutput;
|
|
697
|
-
/** `redact(values)` over the values `run` holds, read once per input and held value set: a console polls a run's
|
|
698
|
-
* view, and an answer a run was made to write can be large. The run keeps the one it served last, of each slot; a key
|
|
699
|
-
* saved or deleted changes the values' digest, and the next view redacts again. */
|
|
700
|
-
private servedOnce;
|
|
701
|
-
/** The timeline's redaction of `run`'s error rows and of what a tool's result shows (its summary and preview), applied
|
|
702
|
-
* before a row is cut (timelineOf's `redact`), so a cut never leaves the head of a key. Every such cut is within
|
|
703
|
-
* redacted()'s SHOWN, so its window holds. */
|
|
704
|
-
/** How a run's decision rows show a text (decision-rows.ts Shown): the run's redactor, and as many characters held back
|
|
705
|
-
* from a text stored cut as a held value takes in its widest form. */
|
|
706
|
-
private decisionShown;
|
|
707
|
-
private redactor;
|
|
708
|
-
/** The last line of the run process's log (lastLogLine) for a failure's message, with every value its errors never
|
|
709
|
-
* show cut out: its process may have written a secret or its sign-in's pointer there. */
|
|
710
|
-
private lastLine;
|
|
711
|
-
/** Every secret value `run`'s errors never show, as learning's checker holds them (learning-run.ts refused): every one
|
|
712
|
-
* this server never shows (serverSecrets, read now, so one rotated is cut at once) and what each launch handed the run. */
|
|
713
|
-
private refusedValues;
|
|
714
|
-
/** A run's model error in a person's words when its provider refused the run's key (key-refusal.ts): the key its
|
|
715
|
-
* harness's route sends, by this server's settings and keys, and no secret's value. */
|
|
716
|
-
private plainKey;
|
|
717
|
-
/** Records the run's status as a change when it moves, and lets go of a live run that answered, failed or is over its cap. */
|
|
718
|
-
/** What a run paused at its cap has spent once its process is gone: its store's spend as the cap reads it (spentIn),
|
|
719
|
-
* read once per pause (its refusal's row). None while its process lives, nor when the store says unknown or cannot
|
|
720
|
-
* be read: the refusal's own figure stands then. */
|
|
721
|
-
private spentNow;
|
|
722
|
-
/** The run's live process, by its pid and start ticks (processIdentity). */
|
|
723
|
-
private liveIdentity;
|
|
724
|
-
private refresh;
|
|
725
|
-
/** The test hooks startServe's options name, as a run's process and this server's own calls get them. */
|
|
726
|
-
private fauxEnv;
|
|
727
|
-
/** Let go of a live run with `outcome`: SIGTERM, after aborting its turn when it is still working. */
|
|
728
|
-
private finish;
|
|
729
|
-
/** SIGTERM to the run's process: it drains, releases the run and exits. */
|
|
730
|
-
private terminate;
|
|
731
|
-
/** Supervise a run process an earlier server started, its row's holder: follow its door, and settle the run once the
|
|
732
|
-
* process is gone, or once the record it keeps in its store has said for EXIT_AFTER_RELEASE_MS that it let go while
|
|
733
|
-
* the process lives on. `follow`: its rows are followed live from its door (never for a run whose rows are not
|
|
734
|
-
* shown, meta.unshown). */
|
|
735
|
-
private adoptProcess;
|
|
736
|
-
/** At start: every run the store says is running is read, supervised when its process lives, carried back when it
|
|
737
|
-
* already ended, and opened again when its process went before it ended. */
|
|
738
|
-
/** Every run's box let go that nothing owns, and every run cgroup no record names: once, before any run of this server
|
|
739
|
-
* starts, opens again or relaunches, so a box or cgroup being made is never swept away. */
|
|
740
|
-
private sweepOnce;
|
|
741
|
-
/** A sandbox run's box (run-box.ts), destroyed by its label: at every settle, a cancel included, and at archive. A
|
|
742
|
-
* remote box's work/ is pulled first, and its box goes only once that pull brought it back whole (or there is no box).
|
|
743
|
-
* A copy that stopped for good (an archive the extractor cannot read, a limit it cannot pass) keeps the box, said in
|
|
744
|
-
* the log, its lifetime bounding it, and the run ends. Any other failure at a run's end (`ending`) throws
|
|
745
|
-
* PullPending, and the end is tried again; at an archive it only warns, the box kept for the run's end or the next
|
|
746
|
-
* start's sweep. A destroy that fails only warns: the next start's sweep tries again, and the box's lifetime bounds it. */
|
|
747
|
-
private dropBox;
|
|
748
|
-
/** A remote box kept because its copy back is not whole: said in the log, and set to stop once idle, so it costs its
|
|
749
|
-
* disk alone until the next start's pull (which wakes it) or its lifetime. */
|
|
750
|
-
private keepBox;
|
|
751
|
-
/** What wakes run `runId`'s remote box when Daytona stopped or paused it (a class that pauses when idle, while the run
|
|
752
|
-
* waited for a person): how many it woke. */
|
|
753
|
-
private wakeOf;
|
|
754
|
-
/** Pulls run `run`'s remote box into its work/, after any pull already running: at a turn's end in the background (a
|
|
755
|
-
* failure warns, and the next pull brings it), or awaited (`strict`: a failure throws). */
|
|
756
|
-
private pullBox;
|
|
757
|
-
/** Waits for the pull run `id`'s turn's end began, if any, up to PULL_WAIT_MS: its files then show what its box wrote. */
|
|
758
|
-
pulled(id: string): Promise<void>;
|
|
759
|
-
/** Whether run `id` is one this server holds in a remote box and has not ended: the relay serves no other. */
|
|
760
|
-
servesBox(id: string): boolean;
|
|
761
|
-
/** The server's provider of a remote place's boxes: the VM box's, or Daytona's. */
|
|
762
|
-
private remoteOf;
|
|
763
|
-
/** Run `id`'s remote box, found or made and seeded: what its process asks the relay for at its first tool call. */
|
|
764
|
-
ensureBox(id: string): Promise<{
|
|
765
|
-
id: string;
|
|
766
|
-
made: boolean;
|
|
767
|
-
replaced?: boolean;
|
|
768
|
-
}>;
|
|
769
|
-
/** The run's box let go (archive, or its process gone after an archive): reaped by the box's own count. */
|
|
770
|
-
private teardown;
|
|
771
|
-
/** After an archive (a run's, or an agent's, which archives its runs): the box of every run now archived is let go,
|
|
772
|
-
* now when its process is gone, else when it exits. */
|
|
773
|
-
archived(): Promise<void>;
|
|
774
|
-
recover(): Promise<void>;
|
|
775
|
-
/** The run's status, state and whether its rows are all in, as one more change of its log when any of them moves. A wait
|
|
776
|
-
* is told each time it is seen: webhooks.ts queues each wait once, whichever server sees it first. */
|
|
777
|
-
private mark;
|
|
778
|
-
/** Tells webhooks.ts (`notify`) of a moment of the run under `marker`: a wait it reached (mark), or an end the agent store
|
|
779
|
-
* has (settle, persistLater, reopen). What it already queued it queues no more. */
|
|
780
|
-
private notice;
|
|
781
|
-
/** A call to run `run`'s door: with its own door token, or, for a process an older server started, the server-wide one. */
|
|
782
|
-
private headers;
|
|
783
|
-
/** Run `id`'s own door token, the one its calls to the box relay carry; none for a run it does not hold or that has none. */
|
|
784
|
-
relayToken(id: string): string | undefined;
|
|
785
|
-
/** Follow the door's events into an agentic run's rows, again after each drop while the process lives. A workflow
|
|
786
|
-
* run is only watched: the door's events are a root conversation's, and a workflow run has none. */
|
|
787
|
-
private connect;
|
|
788
|
-
/** One round of a live workflow run's watch of its pause at its cap: a stat of budget.json, and a read only when it
|
|
789
|
-
* changed (its time or size); a new pause, or one written again, refreshes the run (its status, its notice). */
|
|
790
|
-
private watchPause;
|
|
791
|
-
private follow;
|
|
792
|
-
/** The install `run`'s harness waits for before it launches (claude-agent's Claude Code, codex's Codex: harness-install.ts), or undefined
|
|
793
|
-
* when it waits for none. One per run at a time, every run's on the server's one install: while that runs the run
|
|
794
|
-
* shows it (installRow). A failed install ends the run failed, with the install's words, which name the command that
|
|
795
|
-
* installs it by hand. */
|
|
796
|
-
private harnessReady;
|
|
797
|
-
/** The door of a run that is not finished, starting or waking its process when it is not live. */
|
|
798
|
-
private ensureLive;
|
|
799
|
-
/** A request's 503 for a run that did not come up in time, naming why, as far as this server can tell: the process
|
|
800
|
-
* listing cannot be read (who holds it is unknown), the agent store is busy (its claim waits on it), or the run never
|
|
801
|
-
* opened (its process is up, its door not serving). */
|
|
802
|
-
private notUp;
|
|
803
|
-
/** The refusal of a message to an imported run: it was run elsewhere, and is kept as history. */
|
|
804
|
-
private importedRefusal;
|
|
805
|
-
private finished;
|
|
806
|
-
/** Abort an agentic run's turn running now through the door, when there is one; never wakes the run. A workflow run
|
|
807
|
-
* has no turn: the door's abort would give it a root conversation. */
|
|
808
|
-
private abortTurn;
|
|
809
|
-
/** One request to the door of a run whose process lives, never waking it (toDoor wakes no run that is finishing): again
|
|
810
|
-
* while it opens or parks. `turnOrigin`: who sent a turn this request sends (learning-run.ts's REFLECT_ORIGIN), kept in
|
|
811
|
-
* the run's directory before it goes, where the tool gate reads it (tool-gate.ts NOTE_ONLY_TEXT); a person's message
|
|
812
|
-
* removes it. */
|
|
813
|
-
private toLiveDoor;
|
|
814
|
-
private toDoor;
|
|
815
|
-
/** Reads what decides the secrets runs of `run`'s revision are handed (needsOf), once per revision: from `given` (a
|
|
816
|
-
* start's, read from the store), else from the agent store, waiting out a busy one as a run's end does. */
|
|
817
|
-
private pinNeeds;
|
|
818
|
-
/** Just before a launch that spawns the run's process (after pinNeeds): its MCP servers' OAuth tokens near expiry are
|
|
819
|
-
* refreshed in serve (mcp-servers.ts headersForRun), so the synchronous launch hands it a fresh access token, never a
|
|
820
|
-
* refresh token. Never on a path that only reaches a live process, nor on a stop's: an authorization server that is
|
|
821
|
-
* slow to answer never holds an abort. */
|
|
822
|
-
private mcpFresh;
|
|
823
|
-
/** `run`'s pinned MCP tools: read from its directory, or at its first launch made from the granted `tools` and the
|
|
824
|
-
* servers saved now, and written before its process starts. Undefined when it grants none. */
|
|
825
|
-
private mcpPin;
|
|
826
|
-
/** The saved sign-in the run's browser starts from (sign-ins.ts), resolved before each launch: made at the vendor when
|
|
827
|
-
* its agent has none, and leased to this run to save unless another run of the agent holds the lease. One that cannot
|
|
828
|
-
* be had (the vendor not answering, a seal key changed) leaves its browser signed out, said in its log. */
|
|
829
|
-
private pinSignIn;
|
|
830
|
-
/** That `run` is handed `signIn`, kept before it is (forRun's keep, under its agent's sign-ins lock, so no forget comes
|
|
831
|
-
* between): false when that can't be saved, and the run is handed none. */
|
|
832
|
-
private keepHanded;
|
|
833
|
-
/** The run of `agentId` still going (its row running) that was handed the sign-in whose pointer hashes to `hash`, or
|
|
834
|
-
* any sign-in when `hash` is undefined (a pointer that does not open here): forget waits for it (sign-ins.ts). From the
|
|
835
|
-
* run this server holds, else its serve.json: a run still going need not be held yet (a recovery under way, or one it
|
|
836
|
-
* could not recover). One whose mark is MALFORMED, or whose serve.json is damaged (run.damaged for a held run, the same
|
|
837
|
-
* answer the disk read gives), counts: what it was handed is not known. */
|
|
838
|
-
handedTo(agentId: string, hash: string | undefined): Promise<string | undefined>;
|
|
839
|
-
/** The pointer of the sign-in a run this server loads was handed, among the values its rows, errors and answers never
|
|
840
|
-
* show: read only, with no lease taken (pinSignIn takes one at its next launch). `unreadable` when its agent keeps
|
|
841
|
-
* one that does not open under this server's seal key. */
|
|
842
|
-
private peekSignIn;
|
|
843
|
-
/** Lets go of the save lease the run holds on its agent's sign-in, if any: at once when its process let its sessions go
|
|
844
|
-
* (`clean`), else by the gone rule (sign-ins.ts). */
|
|
845
|
-
private releaseSignIn;
|
|
846
|
-
private launch;
|
|
847
|
-
/** Names `holder` on the run's row under `epoch`, the claim its launch made: a claim that moved on since (a take-back,
|
|
848
|
-
* a later launch) is left as it is, and a store that is busy is tried again shortly, a few times. */
|
|
849
|
-
private nameHolder;
|
|
850
|
-
/** Writes the run's newest holder to name (`naming`); a store another writer holds is tried again, soon at first, then
|
|
851
|
-
* every settle retry, while the process lives and the server runs. */
|
|
852
|
-
private writeHolder;
|
|
853
|
-
/** Writes the run's launch mark before its process is spawned: a spawn that takes the server down leaves it, and the
|
|
854
|
-
* next start fails the run rather than launch it again and go down with it. The file exists once the call returns,
|
|
855
|
-
* which a server's death does not undo; no fsync, which would hold the event loop on the disk at every launch. */
|
|
856
|
-
private markLaunching;
|
|
857
|
-
/** The run's newest launch came through with the server up: its process serves, or exited while it was watched. Its
|
|
858
|
-
* callers are event handlers, so a mark that cannot be removed is logged, never thrown: a throw there stops the
|
|
859
|
-
* server and every run on it. The mark left behind fails the run at the next start, which never launches it again. */
|
|
860
|
-
private reportedBack;
|
|
861
|
-
/** Opens the run again on its directory after its process went before the run ended: it resumes from its store. An
|
|
862
|
-
* agentic run whose first message never landed gets it again, under the same request id. */
|
|
863
|
-
private relaunch;
|
|
864
|
-
/** After the run's process exited, or was found gone: its rows from its released store, then, when it is over, its
|
|
865
|
-
* carry back. One at a time per run, and none once the run has its outcome. */
|
|
866
|
-
private settle;
|
|
867
|
-
/** `exited`: the process this server supervised exited. Exiting on an error before it released fails the run; going
|
|
868
|
-
* any other way before the run ended (killed, or found gone at a start) opens it again. */
|
|
869
|
-
private settleOnce;
|
|
870
|
-
/** A workflow run's carry back, `workflowCarry` of @parcha/pi-durable-agent/workflow on its released store, and its
|
|
871
|
-
* output when it completed; undefined while its workflow has not ended. */
|
|
872
|
-
private workflowEnd;
|
|
873
|
-
/** A workflow run's decisions' cost, from their receipts in its released store: a receipt whose cost is unknown leaves
|
|
874
|
-
* the run's unknown, never $0. Read at its end and again when a restarted server adopts it as ended. */
|
|
875
|
-
private readDecisionCost;
|
|
876
|
-
/** Ends the run in the agent store, once: how it ended, its cost, a line for the list and its metrics. A store held by
|
|
877
|
-
* another writer is tried again with backoff; past the last try the run stays unsettled, and the next start carries it back. */
|
|
878
|
-
private carryBack;
|
|
879
|
-
/** The run's metrics as the store keeps them: what its entries say it used, the effort its newest process ran at (unknown
|
|
880
|
-
* for one an older server started), and on a harness other than pi the model its revision names (its entries name the
|
|
881
|
-
* harness). A busy store throws, for the write's retries; a revision that cannot be read otherwise adds nothing. */
|
|
882
|
-
private storedMetrics;
|
|
883
|
-
/** Tries `persist` again every settleRetryMs while the server lives, until it lands. */
|
|
884
|
-
private persistLater;
|
|
885
|
-
/** How long a run's end waits for a busy store, step by step. */
|
|
886
|
-
private busyDelays;
|
|
887
|
-
/** Hears that `what` was busy for run `runId`, and says so when another try follows. */
|
|
888
|
-
private onBusy;
|
|
889
|
-
/** The run's store, read again while another connection holds it, within the same retries. */
|
|
890
|
-
private storeWhenFree;
|
|
891
|
-
/** Start a run of `revision` (number `version`) of `entry`'s agent: `startRun` in the store, then its process, then an
|
|
892
|
-
* agentic run's first message, `input.content`. */
|
|
893
|
-
/** A place for one more live run of `harness`, taken for this start (counted in `starting` and `startingMib` from
|
|
894
|
-
* here, so two starts at once cannot both take the last place), or 429 rate_limited; the function returned gives it
|
|
895
|
-
* back once the run holds it as a live run, or did not start. A place is one under the cap on the count and the
|
|
896
|
-
* memory a run of its harness reserves (host.ts): both must be free. A run that has ended (failed, completed,
|
|
897
|
-
* cancelled) still holds its place until its process exits; a start that needs that place waits for it, up to that
|
|
898
|
-
* process's drain and kill, never refused for a place already being given back. A harness whose one run is more than
|
|
899
|
-
* the whole memory for runs is refused at once, never a 429 (capabilities say so too). From the read of what is held
|
|
900
|
-
* to the reservation nothing awaits, so two starts at once never both take the last of it. */
|
|
901
|
-
private takePlace;
|
|
902
|
-
/** `inputs` copies the run's files into its work/ (uploads.ts), after the store made it and before its process starts. */
|
|
903
|
-
create(entry: AgentEntry, revision: Revision, version: number, options: StartOptions): Promise<Run>;
|
|
904
|
-
/** Writes the serve.json of a run being set up. When it fails, the store has the run as running and no process will
|
|
905
|
-
* run it: it ends failed here, never left for a later start to open with half its files. */
|
|
906
|
-
private setUp;
|
|
907
|
-
private start;
|
|
908
|
-
/** Copies the run's files into its work/ under the launch mark: a server that goes down while it copies leaves the
|
|
909
|
-
* mark, and the next start fails the run rather than run it on part of its files. Copied whole, the mark goes, and the
|
|
910
|
-
* launch makes its own. False when the copy failed, and the run ended so (or was cancelled meanwhile). */
|
|
911
|
-
private prepare;
|
|
912
|
-
/** One message to the run's door. `origin`: who wrote it when the person did not (a raised cap's follow-up, an
|
|
913
|
-
* approval's resume), carried to its user entry so the Timeline shows it as the server's (pi-durable-agent's
|
|
914
|
-
* MessageOrigin); the model reads the same text either way. `answers: false`: the run's door refuses the message
|
|
915
|
-
* (WAITING) when the run's turn ended on ask_person or a tool call of it waits for its owner's approval (the gate's
|
|
916
|
-
* park, APPROVAL_ENTRY), and when the run is busy (BUSY), so it is never queued behind a
|
|
917
|
-
* turn that may end so; decided at the door's admission, past every wait here. */
|
|
918
|
-
private submit;
|
|
919
|
-
/** Whether the run's harness takes a message mid-turn. */
|
|
920
|
-
private steers;
|
|
921
|
-
/** Whether the run's store already took a message under `requestId`: a trigger's firing sent it, and the server went
|
|
922
|
-
* down before it wrote so. Read before sending it again, so a completed run is not opened again for a message it
|
|
923
|
-
* already has. Only for a run with no live process: a live one holds its store, and takes the message through its
|
|
924
|
-
* door, which takes one per id anyway. The store keeps the id as JSON text, as pi submits it, or as a harness's door
|
|
925
|
-
* keeps its journal (doorKey), where a busy refusal is not a message taken (doorTook). A store held past the retries
|
|
926
|
-
* throws as busy. */
|
|
927
|
-
tookMessage(run: Run, requestId: string): Promise<boolean>;
|
|
928
|
-
/** Raises the cap of an agentic run that names one, to `cap`: above its own (by more than CAP_TOLERANCE), or the same as
|
|
929
|
-
* its newest raise (a retry, which changes nothing). serve.json keeps it before any answer, and a raise it could not keep
|
|
930
|
-
* is undone, so the run's next process opens under it (CAP_ENV), as does a server started again. A run paused at its
|
|
931
|
-
* cap goes on: the raise names the pause it answers, and the pause gets one follow-up, "The cap was raised to $X;
|
|
932
|
-
* continue the task." under an id fixed now, which refresh sends once the paused process is gone (resumeRaised), here
|
|
933
|
-
* or after a restart; a second raise before it goes raises what it says. A run working keeps the cap its process was
|
|
934
|
-
* opened with until its next process. Raises of one run are taken one at a time. */
|
|
935
|
-
raiseCap(run: Run, cap: number): Promise<{
|
|
936
|
-
resumed: boolean;
|
|
937
|
-
messageId?: string;
|
|
938
|
-
note?: string;
|
|
939
|
-
}>;
|
|
940
|
-
private takeRaise;
|
|
941
|
-
/** A workflow run's raise (budget.ts): serve.json keeps it first, as an agentic run's does, then `cap.json` tells the
|
|
942
|
-
* run's process, whose step waiting at its cap is judged again under it, and a run whose process the pause let go is
|
|
943
|
-
* opened again (its pause's mark taken away first, so its settle does not hold it) under the raised cap (CAP_ENV),
|
|
944
|
-
* resuming from its journal. A raise while it works holds from its next check. The same raise again changes nothing. */
|
|
945
|
-
private raiseWorkflow;
|
|
946
|
-
/** Finishes the raise serve.json keeps (`max_cost_usd`), in its steps' order, each one done again harmlessly: `cap.json`
|
|
947
|
-
* takes it (a waiting process wakes on it), then a pause it answers (budget.json under a lower cap) is taken away and
|
|
948
|
-
* its run, with no process, opened again under it. A raise, its retry and a restart's settle all finish it here, so a
|
|
949
|
-
* crash between serve.json and the rest never leaves a raised run waiting for a raise. True when it took a pause away. */
|
|
950
|
-
private finishRaise;
|
|
951
|
-
/** A raised run that found no place: queued, saying it waits for one, and tried again every PLACE_RETRY_MS until it
|
|
952
|
-
* opens (finishRaise), ends or is cancelled. */
|
|
953
|
-
private waitForPlace;
|
|
954
|
-
/** Whether a raise that took a place has nothing to open now: the server is closing (the mark stays, for the next
|
|
955
|
-
* server), or the run ended, was cancelled, opened, or has no pause left. Off the queue then, unless closing. */
|
|
956
|
-
private raiseMoot;
|
|
957
|
-
/** `run` off the queue for a place: what it reserved is free, and it shows no wait for one. */
|
|
958
|
-
private leavePlaceQueue;
|
|
959
|
-
/** A raised run whose launch failed after its place was taken: to the back of the queue, its mark kept, and off it
|
|
960
|
-
* after RAISE_TRIES failures in a row (still paused at its cap; a raise retried, or the server's next start, finishes it
|
|
961
|
-
* then), so it never holds a place reserved for good. */
|
|
962
|
-
private raiseFailed;
|
|
963
|
-
private retryPlaces;
|
|
964
|
-
/** Sends a raised run its pause's follow-up, under its id (the door takes one id once), at the run's cap now: as a
|
|
965
|
-
* follow-up to a run whose process has gone (message()), so the process it starts resumes nothing and opens under the
|
|
966
|
-
* new cap, or to the process another launch started. Marked sent in serve.json. One that cannot be sent is tried
|
|
967
|
-
* again (CONTINUE_RETRY_MS), and after CONTINUE_TRIES the run fails, saying why: never a pause stuck in silence. */
|
|
968
|
-
private resumeRaised;
|
|
969
|
-
/** Ends a raised run whose follow-up could not be sent: failed, in words a person can act on. */
|
|
970
|
-
private failRaised;
|
|
971
|
-
/** One message to an agentic run, its mode chosen by the run's state (the contract's table). `requestId`: the message's
|
|
972
|
-
* id in the run's store, which takes one message per id (a trigger's firing key); default a new one. */
|
|
973
|
-
/** `origin`: who the message is from when its person did not write it (a trigger's firing). */
|
|
974
|
-
message(run: Run, content: string, requestId?: string, { answers, origin }?: {
|
|
975
|
-
answers?: boolean;
|
|
976
|
-
origin?: MessageOrigin;
|
|
977
|
-
}): Promise<{
|
|
978
|
-
mode: "steer" | "answer" | "follow_up";
|
|
979
|
-
messageId: string;
|
|
980
|
-
}>;
|
|
981
|
-
/** A person's turn is sent next: no turn from here on is the server's own end-of-run turn (tool-gate.ts NOTE_ONLY_TEXT),
|
|
982
|
-
* so its origin goes, right before the turn is sent. */
|
|
983
|
-
private personsTurn;
|
|
984
|
-
/** Waits, up to a request's deadline, while `holds` (checked every `everyMs`): else 503 `unavailable`, saying `why`. */
|
|
985
|
-
private waitWhile;
|
|
986
|
-
/** A completed agentic run that gets a follow-up opens again: the same run on its own store and session, under its
|
|
987
|
-
* cap, taking a place under the server's. Launched here, with no wait after the place is taken, so no start takes
|
|
988
|
-
* it meanwhile. An archived run, or a run of an archived agent, stays closed. */
|
|
989
|
-
private reopen;
|
|
990
|
-
/** Waits, up to a request's deadline, until a live run's rows show every message sent to it, and any rows at all: its
|
|
991
|
-
* record has caught up with its process. Its end, a cancel or its process going ends the wait. */
|
|
992
|
-
private caughtUp;
|
|
993
|
-
/** Abort the turn that is running; the run stays open, `input_required` and idle. A workflow run has no turn to stop. */
|
|
994
|
-
stop(run: Run): Promise<boolean>;
|
|
995
|
-
/** message()'s decline of the tool call that waits for approval: a deny with the message as its note, which the
|
|
996
|
-
* run's gate acts on as any deny, resuming the session with the refusal and the person's words in one message. */
|
|
997
|
-
private declineBy;
|
|
998
|
-
/** The answers given and not acted on yet (the run's process has not resolved them), overridden by a stop or a cancel:
|
|
999
|
-
* `withdrawn` or `canceled`, each keeping the answer it superseded, so nothing runs and nothing resumes, and the
|
|
1000
|
-
* history shows what was given. The run's gate reads the answer again just before it acts (tool-gate.ts). */
|
|
1001
|
-
private supersede;
|
|
1002
|
-
/** Until every tool call of the run that waited for approval is resolved in its store (its process acted on its answer,
|
|
1003
|
-
* or cut it), or `ms` pass. */
|
|
1004
|
-
private untilResolved;
|
|
1005
|
-
/** stop()'s withdrawal of the tool call that waits for approval: never run, and an answer after is 409. */
|
|
1006
|
-
private withdraw;
|
|
1007
|
-
/** stop() of a run with no turn to abort (parked on an approval it withdrew): the stop's mark, as a stop saves it. */
|
|
1008
|
-
private stopIdle;
|
|
1009
|
-
/** stop()'s mark and abort, once it took the stop. */
|
|
1010
|
-
private stopTurn;
|
|
1011
|
-
/** A person's answer to the tool call `id` that waits for approval (tool-gate.ts): kept in the run's serve.json before
|
|
1012
|
-
* it returns, the first answer winning (the same one again changes nothing; another is 409, `already_answered`). The
|
|
1013
|
-
* run's process reads it there, runs or refuses the call, and resumes; a run with no process gets one. */
|
|
1014
|
-
approve(run: Run, id: string, decision: "allow" | "deny", note?: string): Promise<void>;
|
|
1015
|
-
/** Record the cancel and signal the run. An agentic run reads `cancelled` from here on (the first end a run comes to is
|
|
1016
|
-
* its last: nothing its turn writes later moves it), and is carried back so once its process has exited; a workflow
|
|
1017
|
-
* run reads it once it is carried back, with how its workflow stopped. */
|
|
1018
|
-
cancel(run: Run): Promise<boolean>;
|
|
1019
|
-
/** Pause a workflow run (`paused` true) or resume it: the mark in its directory, which its process reads before each
|
|
1020
|
-
* node starts. A run that has ended is not continuable. */
|
|
1021
|
-
pause(run: Run, paused: boolean): Promise<{
|
|
1022
|
-
run_id: string;
|
|
1023
|
-
paused: boolean;
|
|
1024
|
-
status: Status;
|
|
1025
|
-
}>;
|
|
1026
|
-
/** How long a run's process gets after SIGTERM before SIGKILL: its drain and a second to exit. */
|
|
1027
|
-
private killAfterMs;
|
|
1028
|
-
/** What close() will wait on: the runs whose processes are left to finish their turn (those this server started, and
|
|
1029
|
-
* those it adopted), and the longest it can wait on them: a kill bound for the started ones, and one more for the
|
|
1030
|
-
* adopted ones, which it stops after them. */
|
|
1031
|
-
stopping(): {
|
|
1032
|
-
runs: number;
|
|
1033
|
-
boundMs: number;
|
|
1034
|
-
};
|
|
1035
|
-
close(): Promise<void>;
|
|
1036
|
-
/** A run's cost from its rows, else what the store recorded when it carried the run back. */
|
|
1037
|
-
cost(run: Run): {
|
|
1038
|
-
so_far_usd?: number | undefined;
|
|
1039
|
-
unpriced?: number | undefined;
|
|
1040
|
-
overshoot_bound_usd?: undefined;
|
|
1041
|
-
usd: number | null;
|
|
1042
|
-
basis: string;
|
|
1043
|
-
charge_state: null;
|
|
1044
|
-
cap_usd: number | null;
|
|
1045
|
-
} | {
|
|
1046
|
-
so_far_usd?: number | undefined;
|
|
1047
|
-
unpriced?: number | undefined;
|
|
1048
|
-
overshoot_bound_usd: number;
|
|
1049
|
-
usd: number | null;
|
|
1050
|
-
basis: string;
|
|
1051
|
-
charge_state: null;
|
|
1052
|
-
cap_usd: number | null;
|
|
1053
|
-
};
|
|
1054
|
-
/** `Run`, as the contract shows it, its console page at `origin` (server.ts linkOrigin). `known`: its stored row as the
|
|
1055
|
-
* caller already has it, so nothing is read; a run just written has none worth reading (`{ stored: null }`: it is
|
|
1056
|
-
* neither archived nor ended), and its start's answer must not read the store once the run exists, since a busy store
|
|
1057
|
-
* would then refuse a run that runs. */
|
|
1058
|
-
view(run: Run, origin: string, known?: {
|
|
1059
|
-
stored: RunRow | null;
|
|
1060
|
-
}): Promise<{
|
|
1061
|
-
created_at: string;
|
|
1062
|
-
updated_at: string;
|
|
1063
|
-
ended_at: string | null;
|
|
1064
|
-
result: {
|
|
1065
|
-
output: unknown;
|
|
1066
|
-
final_answer: string | null;
|
|
1067
|
-
} | null;
|
|
1068
|
-
error: RunError | null;
|
|
1069
|
-
review: RunReview | null;
|
|
1070
|
-
pending: Pending;
|
|
1071
|
-
cost: {
|
|
1072
|
-
so_far_usd?: number | undefined;
|
|
1073
|
-
unpriced?: number | undefined;
|
|
1074
|
-
overshoot_bound_usd?: undefined;
|
|
1075
|
-
usd: number | null;
|
|
1076
|
-
basis: string;
|
|
1077
|
-
charge_state: null;
|
|
1078
|
-
cap_usd: number | null;
|
|
1079
|
-
} | {
|
|
1080
|
-
so_far_usd?: number | undefined;
|
|
1081
|
-
unpriced?: number | undefined;
|
|
1082
|
-
overshoot_bound_usd: number;
|
|
1083
|
-
usd: number | null;
|
|
1084
|
-
basis: string;
|
|
1085
|
-
charge_state: null;
|
|
1086
|
-
cap_usd: number | null;
|
|
1087
|
-
};
|
|
1088
|
-
cap_mode: "expected" | "strict" | null;
|
|
1089
|
-
approvals: "ask" | "never";
|
|
1090
|
-
archived_at: string | null;
|
|
1091
|
-
imported_from: {
|
|
1092
|
-
source: string;
|
|
1093
|
-
session: string;
|
|
1094
|
-
} | null;
|
|
1095
|
-
trigger: RunTrigger | null;
|
|
1096
|
-
learning: {
|
|
1097
|
-
given?: import("./learning.js").NoteUsed[];
|
|
1098
|
-
read?: import("./learning.js").NoteUsed[];
|
|
1099
|
-
learned?: import("./learning.js").NoteLearned[];
|
|
1100
|
-
pending?: import("./learning.js").NoteUsed[];
|
|
1101
|
-
skills?: import("./learning.js").LearnedFile[];
|
|
1102
|
-
workflows?: import("./learning.js").LearnedFile[];
|
|
1103
|
-
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
1104
|
-
reason: "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "cancelled" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
1105
|
-
detail: string | null;
|
|
1106
|
-
at: string;
|
|
1107
|
-
} | null;
|
|
1108
|
-
poll_after_ms: number;
|
|
1109
|
-
last_progress_at: string | null;
|
|
1110
|
-
effort?: string | undefined;
|
|
1111
|
-
run_id: string;
|
|
1112
|
-
agent_id: string;
|
|
1113
|
-
agent_version: number;
|
|
1114
|
-
console_url: string;
|
|
1115
|
-
revision: string;
|
|
1116
|
-
kind: RevisionKind;
|
|
1117
|
-
sha: null;
|
|
1118
|
-
status: Status;
|
|
1119
|
-
state: State;
|
|
1120
|
-
title: string;
|
|
1121
|
-
place: Place;
|
|
1122
|
-
}>;
|
|
1123
|
-
summary(run: Run, origin: string): Promise<{
|
|
1124
|
-
created_at: string;
|
|
1125
|
-
ended_at: string | null;
|
|
1126
|
-
error: RunError | null;
|
|
1127
|
-
review: RunReview | null;
|
|
1128
|
-
pending: Pending;
|
|
1129
|
-
cost: {
|
|
1130
|
-
so_far_usd?: number | undefined;
|
|
1131
|
-
unpriced?: number | undefined;
|
|
1132
|
-
overshoot_bound_usd?: undefined;
|
|
1133
|
-
usd: number | null;
|
|
1134
|
-
basis: string;
|
|
1135
|
-
charge_state: null;
|
|
1136
|
-
cap_usd: number | null;
|
|
1137
|
-
} | {
|
|
1138
|
-
so_far_usd?: number | undefined;
|
|
1139
|
-
unpriced?: number | undefined;
|
|
1140
|
-
overshoot_bound_usd: number;
|
|
1141
|
-
usd: number | null;
|
|
1142
|
-
basis: string;
|
|
1143
|
-
charge_state: null;
|
|
1144
|
-
cap_usd: number | null;
|
|
1145
|
-
};
|
|
1146
|
-
archived_at: string | null;
|
|
1147
|
-
imported_from: {
|
|
1148
|
-
source: string;
|
|
1149
|
-
session: string;
|
|
1150
|
-
} | null;
|
|
1151
|
-
trigger: RunTrigger | null;
|
|
1152
|
-
learning: ({
|
|
1153
|
-
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
1154
|
-
reason: "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "cancelled" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
1155
|
-
detail: string | null;
|
|
1156
|
-
} & Omit<{
|
|
1157
|
-
given?: import("./learning.js").NoteUsed[];
|
|
1158
|
-
read?: import("./learning.js").NoteUsed[];
|
|
1159
|
-
learned?: import("./learning.js").NoteLearned[];
|
|
1160
|
-
pending?: import("./learning.js").NoteUsed[];
|
|
1161
|
-
skills?: import("./learning.js").LearnedFile[];
|
|
1162
|
-
workflows?: import("./learning.js").LearnedFile[];
|
|
1163
|
-
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
1164
|
-
reason: "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "cancelled" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
1165
|
-
detail: string | null;
|
|
1166
|
-
at: string;
|
|
1167
|
-
}, "at" | "reason" | "detail" | "state">) | null;
|
|
1168
|
-
effort?: string | undefined;
|
|
1169
|
-
run_id: string;
|
|
1170
|
-
agent_id: string;
|
|
1171
|
-
agent_version: number;
|
|
1172
|
-
console_url: string;
|
|
1173
|
-
revision: string;
|
|
1174
|
-
kind: RevisionKind;
|
|
1175
|
-
sha: null;
|
|
1176
|
-
status: Status;
|
|
1177
|
-
state: State;
|
|
1178
|
-
title: string;
|
|
1179
|
-
}>;
|
|
1180
|
-
/** A run's status for a list: an ended run's from its row, a running one's from the run itself. */
|
|
1181
|
-
statusOfRow(row: RunRow): Promise<Status>;
|
|
1182
|
-
/** A run's summary for a list. An ended run this server holds no Run for is read from its row and its serve.json alone,
|
|
1183
|
-
* not its store; `versions` numbers its agent's revisions. */
|
|
1184
|
-
summaryOfRow(row: RunRow, versions: Map<string, number>, origin: string): Promise<Awaited<ReturnType<Runs["summary"]>>>;
|
|
1185
|
-
/** A key was saved on this server or deleted from it: each held run's learning row and decision rows shown again, cut
|
|
1186
|
-
* of the keys as they are now (learning-run.ts shown, decision-rows.ts), as its view and its lists already are from
|
|
1187
|
-
* the next read on. */
|
|
1188
|
-
keysChanged(): void;
|
|
1189
|
-
/** A held run's learning, in short (learning-run.ts heldLearning). */
|
|
1190
|
-
heldLearning(runId: string): {
|
|
1191
|
-
state: LearningState;
|
|
1192
|
-
reason: LearningReason | null;
|
|
1193
|
-
} | null | undefined;
|
|
1194
|
-
/** The timeline from change `after`, held up to `waitMs` for a change when there is none. */
|
|
1195
|
-
page(run: Run, after: number, waitMs: number, limit: number): Promise<Page & {
|
|
1196
|
-
status: Status;
|
|
1197
|
-
state: State;
|
|
1198
|
-
final: boolean;
|
|
1199
|
-
}>;
|
|
1200
|
-
}
|