@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45
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 +231 -0
- package/README.md +580 -320
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +92 -22
- package/dist/composio-preset.d.ts +4 -3
- package/dist/composio-preset.js +81 -11
- package/dist/composio-triggers.d.ts +34 -2
- package/dist/composio-triggers.js +261 -31
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computer-lost.d.ts +11 -0
- package/dist/computer-lost.js +19 -0
- package/dist/computer-record.d.ts +10 -2
- package/dist/computer-record.js +50 -18
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +2 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +10 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +59 -3
- package/dist/harness-table.js +119 -14
- package/dist/harness.d.ts +17 -1
- package/dist/harness.js +22 -11
- package/dist/host.d.ts +12 -10
- package/dist/host.js +19 -16
- package/dist/import-worker.d.ts +3 -0
- package/dist/import-worker.js +7 -5
- package/dist/import.d.ts +22 -1
- package/dist/import.js +141 -28
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +26 -89
- package/dist/learn/check.js +58 -336
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +88 -103
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +17 -0
- package/dist/learn/delete.js +42 -0
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +20 -2
- package/dist/learn/promote.js +17 -4
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
- package/dist/learn/{skills.js → workflow-draft.js} +65 -59
- package/dist/learn/workflow-nodes.d.ts +22 -1
- package/dist/learn/workflow-nodes.js +29 -10
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +127 -13
- package/dist/learning-cost.js +142 -10
- package/dist/learning-routes.d.ts +99 -170
- package/dist/learning-routes.js +199 -420
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +62 -393
- package/dist/learning.js +101 -651
- package/dist/listen-first.d.ts +30 -0
- package/dist/listen-first.js +115 -0
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +2 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +16 -16
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +12 -4
- package/dist/model.js +41 -16
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +375 -347
- package/dist/owner.d.ts +8 -0
- package/dist/owner.js +11 -0
- package/dist/paid-calls.d.ts +14 -0
- package/dist/paid-calls.js +31 -1
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/place.d.ts +8 -3
- package/dist/place.js +13 -9
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +30 -2
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +16 -90
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.d.ts +64 -0
- package/dist/run-model-key.js +147 -0
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +14 -6
- package/dist/runner/adapter-loop.js +25 -14
- package/dist/runner/adapter-run-spec.d.ts +22 -7
- package/dist/runner/adapter-run-spec.js +130 -77
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +35 -4
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +5 -1
- package/dist/runner/audit.js +31 -12
- package/dist/runner/beside.d.ts +7 -2
- package/dist/runner/beside.js +41 -9
- package/dist/runner/claim-secrets.d.ts +66 -1
- package/dist/runner/claim-secrets.js +136 -3
- package/dist/runner/cli-run-spec.d.ts +2 -1
- package/dist/runner/cli-run-spec.js +82 -59
- package/dist/runner/commands.d.ts +3 -6
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +5 -4
- package/dist/runner/feedback-round.js +14 -10
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +30 -56
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +7 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -66
- package/dist/runner/learning-end.js +250 -299
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +8 -3
- package/dist/runner/loop-contract.js +4 -0
- package/dist/runner/loop.js +6 -2
- package/dist/runner/main.d.ts +18 -9
- package/dist/runner/main.js +82 -22
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +14 -6
- package/dist/runner/memory-claim.js +18 -9
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +13 -6
- package/dist/runner/promotion.js +63 -17
- package/dist/runner/reflect-hook.d.ts +64 -91
- package/dist/runner/reflect-hook.js +112 -206
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +58 -9
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +14 -6
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +17 -4
- package/dist/runs-over-store.d.ts +21 -32
- package/dist/runs-over-store.js +44 -41
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +119 -83
- package/dist/server.js +1121 -419
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/seal.d.ts +20 -2
- package/dist/store/seal.js +24 -8
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-launch.d.ts +4 -1
- package/dist/store/sqlite/run-launch.js +12 -0
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.d.ts +3 -2
- package/dist/store/sqlite/store.js +360 -75
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +231 -39
- package/dist/store/store.js +25 -3
- package/dist/store-reads/analytics.js +11 -1
- package/dist/store-reads/learning.d.ts +131 -194
- package/dist/store-reads/learning.js +292 -301
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.js +13 -3
- package/dist/store-view.d.ts +34 -2
- package/dist/store-view.js +108 -41
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.js +153 -0
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +13 -13
- package/dist/tools.js +29 -9
- package/dist/trigger-adapter.d.ts +3 -0
- package/dist/trigger-adapters.d.ts +4 -0
- package/dist/trigger-adapters.js +13 -0
- package/dist/trigger-composio.d.ts +58 -1
- package/dist/trigger-composio.js +160 -6
- package/dist/triggers.d.ts +64 -5
- package/dist/triggers.js +141 -17
- package/dist/validate.d.ts +11 -7
- package/dist/validate.js +9 -8
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +22 -8
- package/dist/workspace/computer-for-claim.js +339 -46
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +41 -21
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -9
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BrcDSBD8.css +0 -1
- package/dist/console/assets/index-Bz6IWncl.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -33
- package/dist/learning-evals.js +0 -98
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
-
import { type BrowserFeatures, type BrowserFile, type BrowserSpec, type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type HelloResult, type KindCapabilities, type MountReadBack, type MountSpec, type ProviderEntry, type Result } from "@parcha/agentrun-computer";
|
|
2
|
+
import { type BrowserFeatures, type BrowserFile, type BrowserSpec, type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type HelloResult, type KindCapabilities, type MountKind, type MountReadBack, type MountSpec, type ProviderEntry, type Result } from "@parcha/agentrun-computer";
|
|
3
3
|
import { type DockerDaemon } from "../docker-daemon.js";
|
|
4
|
+
import type { Recording, RecordWatch } from "../computer-record.js";
|
|
4
5
|
import type { MountCheck } from "./attach.js";
|
|
5
6
|
import type { RunComputer } from "./run-tools.js";
|
|
6
7
|
import type { Workspace } from "./workspace.js";
|
|
@@ -10,8 +11,8 @@ export type { ComputerSettingKind, KindCapabilities, ProviderEntry, ShellPlace }
|
|
|
10
11
|
/** An agent's computer setting. `image`: the one of the provider's configurations it selects; absent, the default. A
|
|
11
12
|
* sandbox's may ask for GPUs. `persistent`: the agent keeps its own computer between runs (agent-computer.ts). A
|
|
12
13
|
* desktop's or a phone's `surface` and `exec` go to the run's tools on the RunComputer (run-tools.ts); `exec: false`
|
|
13
|
-
* also mounts no folder in it and gives the run no shell. A desktop's or a
|
|
14
|
-
* screen (computer-for-claim.ts, computer-record.ts). */
|
|
14
|
+
* also mounts no folder in it and gives the run no shell. A desktop's, a phone's or a browser's `record`: the claim
|
|
15
|
+
* records its screen (computer-for-claim.ts, computer-record.ts). */
|
|
15
16
|
export type ComputerSetting = {
|
|
16
17
|
readonly kind: string;
|
|
17
18
|
readonly provider?: string | null;
|
|
@@ -76,6 +77,10 @@ export type ClaimBrowser = {
|
|
|
76
77
|
url(id: string): Promise<string>;
|
|
77
78
|
/** Ends the session; one already gone is ended. */
|
|
78
79
|
close(id: string): Promise<void>;
|
|
80
|
+
/** Where the agent's setting asks for it (computer.record), records session `id`'s screen through `watch` (its live
|
|
81
|
+
* view's, computer-record.ts browserWatch) until the caller stops it at the session's release, or the claim's release
|
|
82
|
+
* stops it. Absent: nothing is recorded. */
|
|
83
|
+
readonly record?: (id: string, watch: RecordWatch) => Recording;
|
|
79
84
|
/** The files a session downloaded, kept by the provider: where its features declare downloads. */
|
|
80
85
|
readonly downloads?: {
|
|
81
86
|
list(id: string): Promise<BrowserFile[]>;
|
|
@@ -106,11 +111,15 @@ export type ClaimSide = {
|
|
|
106
111
|
}): Promise<LaunchedComputer>;
|
|
107
112
|
/** The computer an earlier claim of the run kept at its park (computer-kept.ts), attached again in place of a launch,
|
|
108
113
|
* or undefined to launch one. Asked first: a computer attached again mounts what it mounted, so no mount is made for
|
|
109
|
-
* it, and its mount reads back under `epoch`, the claim epoch its labels carry.
|
|
114
|
+
* it, and its mount reads back under `epoch`, the claim epoch its labels carry. `folder`: the kind of the run's folder
|
|
115
|
+
* in it, where it holds one: only a computer kept holding the folder so is taken back (computer-kept.ts Kept.folder),
|
|
116
|
+
* and a new one in place of it, once its provider loses it, holds the same. Never throws. Absent: always a launch. */
|
|
110
117
|
reattach?(entry: ProviderEntry, spec: {
|
|
111
118
|
readonly kind: ComputerSettingKind;
|
|
112
119
|
readonly keys: Readonly<Record<string, string>>;
|
|
113
120
|
readonly configuration: KindCapabilities;
|
|
121
|
+
readonly folder?: MountKind;
|
|
122
|
+
readonly gpu?: GpuSpec;
|
|
114
123
|
readonly persistent?: true;
|
|
115
124
|
readonly signal?: AbortSignal;
|
|
116
125
|
}): Promise<(LaunchedComputer & {
|
|
@@ -126,6 +135,9 @@ export declare const providerKeys: (registry: Pick<KindRegistry, "PROVIDERS">, k
|
|
|
126
135
|
/** What a provider is on this server beside its descriptor: the mounts the operator's keys turn on, and whether the
|
|
127
136
|
* operator names its image here. */
|
|
128
137
|
type HereFields = {
|
|
138
|
+
readonly label?: string;
|
|
139
|
+
/** Whether its machines dial this server: always, or as its connect option says (the computer package's connectOf). */
|
|
140
|
+
readonly connect?: "dial" | "either";
|
|
129
141
|
readonly mounts: readonly string[];
|
|
130
142
|
readonly unmounted?: Readonly<Partial<Record<string, string>>>;
|
|
131
143
|
readonly mountsWith?: Readonly<Partial<Record<string, string>>>;
|
|
@@ -139,17 +151,23 @@ type HereFields = {
|
|
|
139
151
|
* mount where DAYTONA_ARCHIL_EGRESS names a self-hosted target's Archil egress relay), and imageNamed where its
|
|
140
152
|
* descriptor's imageEnv names its image here (Daytona's AGENTRUN_DAYTONA_SNAPSHOT). Any other entry as it is. Every
|
|
141
153
|
* reader of an entry's mounts (Settings → Computers, the claim, a run's start, its shell) reads this, so the
|
|
142
|
-
* provider made with those keys and the server agree on what it mounts.
|
|
143
|
-
|
|
154
|
+
* provider made with those keys and the server agree on what it mounts. `options`: the create() options its server
|
|
155
|
+
* settings give (computer-keys.ts settingOptions): where its machines dial this server by them (dialsBy), it takes no
|
|
156
|
+
* Archil mount (withoutArchil), so its folder is synced where Archil's would be. */
|
|
157
|
+
export declare function entryHere<Entry extends HereFields>(entry: Entry, set: (name: string) => boolean, options?: Readonly<Record<string, unknown>>): Entry;
|
|
144
158
|
/** `registry` with each provider as this server has it (entryHere), reading only the names an entry's mountsWith or
|
|
145
|
-
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key)
|
|
146
|
-
* whitespace alone is none. */
|
|
159
|
+
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key), and the options
|
|
160
|
+
* its server settings give, by `optionsOf` (settingOptions; absent: none). A value of whitespace alone is none. */
|
|
147
161
|
export declare function registryHere<Registry extends {
|
|
148
162
|
readonly PROVIDERS: readonly ProviderEntry[];
|
|
149
|
-
}>(registry: Registry, valueOf: (name: string) => Promise<string | undefined
|
|
150
|
-
/**
|
|
151
|
-
*
|
|
152
|
-
|
|
163
|
+
}>(registry: Registry, valueOf: (name: string) => Promise<string | undefined>, optionsOf?: (provider: string) => Readonly<Record<string, unknown>>): Promise<Registry>;
|
|
164
|
+
/** The kind of the run's folder a sandbox or a desktop of `entry` with files and exec holds in `mode`, or undefined for
|
|
165
|
+
* none. Mode 1: a bind of this machine. Mode 2: an Archil mount where the provider takes one and Archil's image is here
|
|
166
|
+
* (archilImageHere), else a synced folder where it takes one (the runner keeps the folder on the disk: no Archil image
|
|
167
|
+
* or client is needed in the computer). `gpuMounts`: what its GPU computers take, where the setting asks for GPUs: a
|
|
168
|
+
* kind they leave out is not picked, unless they leave out every one, and then the kind with no GPU is (so the GPU's
|
|
169
|
+
* refusal says why). Settings (computers.ts) and the claim read this one rule. */
|
|
170
|
+
export declare function folderKindOf(entry: HereFields, mode: 1 | 2, gpuMounts?: readonly string[]): MountKind | undefined;
|
|
153
171
|
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
154
172
|
* descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
|
|
155
173
|
export declare const vendorNetworkOnly: (network: readonly string[] | undefined) => boolean;
|
|
@@ -159,13 +177,6 @@ export declare const needsNetwork: (network: readonly string[] | undefined) => b
|
|
|
159
177
|
/** A provider's label after its article, as it is said: "a Modal", "an E2B" (every label is said by its first letter's
|
|
160
178
|
* sound). `start`: at a sentence's start, "A"/"An". */
|
|
161
179
|
export declare const aLabel: (label: string, start?: boolean) => string;
|
|
162
|
-
/** Why a sandbox or a desktop that would mount the owner's Archil disk can't start in Mode 2: the mount needs Archil's
|
|
163
|
-
* image in the owner's own vendor account, and this server can't put it there yet. A provider that prepares its image
|
|
164
|
-
* (prepareImage: Agent37 registers the box image in the owner's workspace, Modal pulls it, E2B starts its public
|
|
165
|
-
* template) is never refused so, nor one whose image the operator names here (archilImageHere: Daytona's
|
|
166
|
-
* AGENTRUN_DAYTONA_SNAPSHOT). For such a one, `imageEnv` says where to name it. Settings (computers.ts modeRefusal)
|
|
167
|
-
* and a run's start (computerReadiness) say it. */
|
|
168
|
-
export declare const mode2ArchilWhy: (label: string, kind: "sandbox" | "desktop", imageEnv?: string) => string;
|
|
169
180
|
/** Why a computer that needs a network is refused where this server's AGENTRUN_BOX_ALLOW is none, in words that name the
|
|
170
181
|
* fix: the operator said no network at all, and the computer can't run without one. */
|
|
171
182
|
export declare const noNetworkRefusal: (label: string, kind: string) => string;
|
|
@@ -194,18 +205,27 @@ export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2,
|
|
|
194
205
|
export type StartedComputer = {
|
|
195
206
|
readonly computer: RunComputer | undefined;
|
|
196
207
|
release(): Promise<void>;
|
|
208
|
+
/** What the run's disk keeps of the folder beyond what the computer wrote, now (a park lands it before the computer is
|
|
209
|
+
* kept): a synced folder's delta, or an Archil mount's modes and links in sync.json (recordMeta). */
|
|
210
|
+
readonly sync?: () => Promise<Result<void>>;
|
|
197
211
|
};
|
|
198
212
|
/** A setting resolved: its kind and provider, whether the run's folder is mounted, the ports, and how to start it. */
|
|
199
213
|
export type ResolvedComputer = {
|
|
200
214
|
readonly kind: ComputerSettingKind;
|
|
201
215
|
readonly provider: string | null;
|
|
202
216
|
readonly mounts: boolean;
|
|
217
|
+
/** The kind of the run's folder in it, where it mounts: a bind, an Archil mount or a synced folder (folderKindOf). */
|
|
218
|
+
readonly folder?: MountKind;
|
|
203
219
|
readonly ports: readonly Port[];
|
|
204
|
-
/** Starts the computer, mounting `workspace`'s folder when it mounts
|
|
205
|
-
*
|
|
220
|
+
/** Starts the computer, mounting `workspace`'s folder when it mounts (a synced folder pushed in from the store
|
|
221
|
+
* `workspace` keeps it in before the computer is handed on); `check` is the mount check attach runs (the claim's
|
|
222
|
+
* epoch bound in); `holds`: whether the claim may still write the run's disk (synced-folder.ts claimHolds), asked
|
|
223
|
+
* before each write of the folder there (fencedStore). A computer that cannot be had throws with code
|
|
224
|
+
* computer_unavailable and the words. */
|
|
206
225
|
start(run: {
|
|
207
226
|
readonly workspace: Workspace;
|
|
208
227
|
readonly check: MountCheck;
|
|
228
|
+
readonly holds?: () => Promise<boolean>;
|
|
209
229
|
readonly signal?: AbortSignal;
|
|
210
230
|
}): Promise<StartedComputer>;
|
|
211
231
|
};
|
|
@@ -5,24 +5,26 @@
|
|
|
5
5
|
// runTools (run-tools.ts), which follows the mount decided here. Pure until start: the registry, the saved keys and the
|
|
6
6
|
// launch of a vendor's computer are passed in, so a new provider is one entry in the registry and changes nothing here.
|
|
7
7
|
//
|
|
8
|
-
// The run's folder is mounted only when the kind has files and exec AND the provider
|
|
9
|
-
// is a folder of this machine (a bind)
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
8
|
+
// The run's folder is mounted only when the kind has files and exec AND the provider takes the mode's folder (folderKindOf):
|
|
9
|
+
// Mode 1's is a folder of this machine (a bind); Mode 2's is on Archil, an archil mount where the provider takes one and
|
|
10
|
+
// Archil's image is here, else a synced folder, which the runner pushes in at the claim and keeps on the disk after each
|
|
11
|
+
// change (synced-folder.ts). A sandbox must hold it: Mode 1 refuses a sandbox that is not Docker's (only a bind reaches
|
|
12
|
+
// this machine), Mode 2 refuses Docker's (it takes neither). A desktop, a phone and a browser are allowed in both modes:
|
|
13
|
+
// a desktop mounts only where its provider takes the mode's folder and it offers files and exec; a phone and a browser
|
|
14
|
+
// never do. A provider whose required keys are not all saved is refused here, before anything starts; start hands the
|
|
15
|
+
// provider its declared keys alone. A sandbox's GPUs are held to what its provider declares, with the mode's folder as their mount (the kind its GPU computers take, where the
|
|
16
|
+
// provider takes more than one), in the computer package's checkGpu words, and go into the computer's spec.
|
|
16
17
|
//
|
|
17
18
|
// Where the run's shell is follows the mount (shellPlaceOf): in the computer that mounts the folder; with none, Archil's
|
|
18
19
|
// serverless exec in Mode 2 (bash only); in Mode 1 none at all, since the folder is one of this server's own and a
|
|
19
20
|
// command there would run on the server itself. runShellOf reads it off a setting before anything starts (the tool
|
|
20
21
|
// plane shows bash unavailable by it), and the claim's runTools takes the same rule over the computer it started.
|
|
21
22
|
import { hostToolDefs } from "@parcha/agentrun-kernel/kernel";
|
|
22
|
-
import { configurationOf, imagesOf, mountsOf } from "@parcha/agentrun-computer";
|
|
23
|
+
import { archilSync, configurationOf, connectOf, imagesOf, mountsOf, syncingClient } from "@parcha/agentrun-computer";
|
|
23
24
|
import { noDockerWords } from "../docker-daemon.js";
|
|
24
25
|
import { gpuRefused } from "../gpu-words.js";
|
|
25
26
|
import { recordedClient } from "../computer-calls.js";
|
|
27
|
+
import { fencedStore, finalSyncWords, pullFolder, pushFolder, recordMeta, recordWords, restoreMeta, storedFolder, syncOf } from "./synced-folder.js";
|
|
26
28
|
/** Whether a computer (or its setting) takes its agent's programs away: `exec: false`. Only a desktop or a phone takes
|
|
27
29
|
* `exec` (computer-setting.ts refuses it on any other kind at save), so a computer without programs is one of those. */
|
|
28
30
|
export const noPrograms = (computer) => computer?.exec === false;
|
|
@@ -42,29 +44,65 @@ export const providerKeys = (registry, keyOf) => async (provider) => {
|
|
|
42
44
|
* mount where DAYTONA_ARCHIL_EGRESS names a self-hosted target's Archil egress relay), and imageNamed where its
|
|
43
45
|
* descriptor's imageEnv names its image here (Daytona's AGENTRUN_DAYTONA_SNAPSHOT). Any other entry as it is. Every
|
|
44
46
|
* reader of an entry's mounts (Settings → Computers, the claim, a run's start, its shell) reads this, so the
|
|
45
|
-
* provider made with those keys and the server agree on what it mounts.
|
|
46
|
-
|
|
47
|
+
* provider made with those keys and the server agree on what it mounts. `options`: the create() options its server
|
|
48
|
+
* settings give (computer-keys.ts settingOptions): where its machines dial this server by them (dialsBy), it takes no
|
|
49
|
+
* Archil mount (withoutArchil), so its folder is synced where Archil's would be. */
|
|
50
|
+
export function entryHere(entry, set, options = {}) {
|
|
47
51
|
const keyed = entry.mountsWith === undefined ? undefined : mountsOf(entry, set);
|
|
48
52
|
const named = entry.imageEnv !== undefined && set(entry.imageEnv);
|
|
49
|
-
|
|
53
|
+
const here = keyed === undefined && !named ? entry : { ...entry, ...keyed, ...(named ? { imageNamed: true } : {}) };
|
|
54
|
+
return dialsBy(entry, options) ? withoutArchil(here) : here;
|
|
55
|
+
}
|
|
56
|
+
/** Whether a computer of `entry` made with `options` dials this server (the computer package's connectOf). A connect it
|
|
57
|
+
* doesn't know is the provider's to refuse, in its words, when it is made: here it is read as exec. */
|
|
58
|
+
function dialsBy(entry, options) {
|
|
59
|
+
if (entry.connect === undefined)
|
|
60
|
+
return false;
|
|
61
|
+
try {
|
|
62
|
+
return connectOf({ label: entry.label ?? "", connect: entry.connect }, options) === "dial";
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** `entry` with no Archil mount, saying why: a machine that dials this server takes none (the computer package's
|
|
69
|
+
* HostedProvider drops it from its capabilities on dial and refuses one in check()). */
|
|
70
|
+
function withoutArchil(entry) {
|
|
71
|
+
if (!entry.mounts.includes("archil"))
|
|
50
72
|
return entry;
|
|
51
|
-
|
|
73
|
+
const archil = `${entry.label ?? "its provider"}'s machines dial this server, and a machine that dials takes no Archil mount`;
|
|
74
|
+
return { ...entry, mounts: entry.mounts.filter((kind) => kind !== "archil"), unmounted: { ...entry.unmounted, archil } };
|
|
52
75
|
}
|
|
53
76
|
/** The names entryHere reads of `entry`: the keys of its mountsWith, and its imageEnv. */
|
|
54
77
|
const hereNames = (entry) => [...Object.values(entry.mountsWith ?? {}).filter((name) => typeof name === "string"), ...(entry.imageEnv === undefined ? [] : [entry.imageEnv])];
|
|
55
78
|
/** `registry` with each provider as this server has it (entryHere), reading only the names an entry's mountsWith or
|
|
56
|
-
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key)
|
|
57
|
-
* whitespace alone is none. */
|
|
58
|
-
export async function registryHere(registry, valueOf) {
|
|
79
|
+
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key), and the options
|
|
80
|
+
* its server settings give, by `optionsOf` (settingOptions; absent: none). A value of whitespace alone is none. */
|
|
81
|
+
export async function registryHere(registry, valueOf, optionsOf) {
|
|
59
82
|
const names = [...new Set(registry.PROVIDERS.flatMap(hereNames))];
|
|
60
|
-
if (names.length === 0)
|
|
61
|
-
return registry;
|
|
62
83
|
const set = new Set((await Promise.all(names.map(async (name) => ((await valueOf(name))?.trim() ? name : "")))).filter((name) => name !== ""));
|
|
63
|
-
return { ...registry, PROVIDERS: registry.PROVIDERS.map((entry) => entryHere(entry, (name) => set.has(name))) };
|
|
84
|
+
return { ...registry, PROVIDERS: registry.PROVIDERS.map((entry) => entryHere(entry, (name) => set.has(name), optionsOf?.(entry.id))) };
|
|
64
85
|
}
|
|
65
86
|
/** Whether a computer of `entry` that mounts the owner's Archil disk has Archil's image in the owner's vendor account:
|
|
66
87
|
* its provider prepares it (prepareImage), or the operator names it here (imageNamed, entryHere). */
|
|
67
|
-
|
|
88
|
+
const archilImageHere = (entry) => entry.prepareImage === true || entry.imageNamed === true;
|
|
89
|
+
/** The kind of the run's folder a sandbox or a desktop of `entry` with files and exec holds in `mode`, or undefined for
|
|
90
|
+
* none. Mode 1: a bind of this machine. Mode 2: an Archil mount where the provider takes one and Archil's image is here
|
|
91
|
+
* (archilImageHere), else a synced folder where it takes one (the runner keeps the folder on the disk: no Archil image
|
|
92
|
+
* or client is needed in the computer). `gpuMounts`: what its GPU computers take, where the setting asks for GPUs: a
|
|
93
|
+
* kind they leave out is not picked, unless they leave out every one, and then the kind with no GPU is (so the GPU's
|
|
94
|
+
* refusal says why). Settings (computers.ts) and the claim read this one rule. */
|
|
95
|
+
export function folderKindOf(entry, mode, gpuMounts) {
|
|
96
|
+
const pick = (takes) => {
|
|
97
|
+
if (mode === 1)
|
|
98
|
+
return takes("bind") ? "bind" : undefined;
|
|
99
|
+
if (takes("archil") && archilImageHere(entry))
|
|
100
|
+
return "archil";
|
|
101
|
+
return takes("sync") ? "sync" : undefined;
|
|
102
|
+
};
|
|
103
|
+
const taken = (kind) => entry.mounts.includes(kind);
|
|
104
|
+
return pick((kind) => taken(kind) && (gpuMounts?.includes(kind) ?? true)) ?? pick(taken);
|
|
105
|
+
}
|
|
68
106
|
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
69
107
|
* descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
|
|
70
108
|
export const vendorNetworkOnly = (network) => network !== undefined && network.length > 0 && network.every((one) => one === "open");
|
|
@@ -74,15 +112,6 @@ export const needsNetwork = (network) => network !== undefined && network.length
|
|
|
74
112
|
/** A provider's label after its article, as it is said: "a Modal", "an E2B" (every label is said by its first letter's
|
|
75
113
|
* sound). `start`: at a sentence's start, "A"/"An". */
|
|
76
114
|
export const aLabel = (label, start = false) => `${start ? "A" : "a"}${/^[AEIOU]/i.test(label) ? "n" : ""} ${label}`;
|
|
77
|
-
/** Why a sandbox or a desktop that would mount the owner's Archil disk can't start in Mode 2: the mount needs Archil's
|
|
78
|
-
* image in the owner's own vendor account, and this server can't put it there yet. A provider that prepares its image
|
|
79
|
-
* (prepareImage: Agent37 registers the box image in the owner's workspace, Modal pulls it, E2B starts its public
|
|
80
|
-
* template) is never refused so, nor one whose image the operator names here (archilImageHere: Daytona's
|
|
81
|
-
* AGENTRUN_DAYTONA_SNAPSHOT). For such a one, `imageEnv` says where to name it. Settings (computers.ts modeRefusal)
|
|
82
|
-
* and a run's start (computerReadiness) say it. */
|
|
83
|
-
export const mode2ArchilWhy = (label, kind, imageEnv) => imageEnv === undefined
|
|
84
|
-
? `${aLabel(label, true)} ${kind} can't start in Mode 2 yet: it needs Archil's image in your ${label} account, and this server can't put it there yet. Set this agent's computer to none (${SETTINGS})`
|
|
85
|
-
: `${aLabel(label, true)} ${kind} can't start in Mode 2 until this server names Archil's image in your ${label} account: build one from the computer package's box/Dockerfile and name it in ${imageEnv}, or set this agent's computer to none (${SETTINGS})`;
|
|
86
115
|
/** Why a computer that needs a network is refused where this server's AGENTRUN_BOX_ALLOW is none, in words that name the
|
|
87
116
|
* fix: the operator said no network at all, and the computer can't run without one. */
|
|
88
117
|
export const noNetworkRefusal = (label, kind) => `This agent's computer is ${aLabel(label)} ${kind}, which needs a network (the vendor's own, or public addresses from this machine), and this server's AGENTRUN_BOX_ALLOW is none (no network): pick a computer that runs with no network in ${SETTINGS}, or set AGENTRUN_BOX_ALLOW to a host list.`;
|
|
@@ -113,8 +142,6 @@ export async function computerReadiness(setting, mode, given, keyOf, answers, bo
|
|
|
113
142
|
if ("refused" in resolved)
|
|
114
143
|
return { refused: resolved.refused };
|
|
115
144
|
const entry = registry.PROVIDERS.find((one) => one.id === resolved.provider);
|
|
116
|
-
if (mode === 2 && (resolved.kind === "sandbox" || resolved.kind === "desktop") && resolved.mounts && entry && !archilImageHere(entry))
|
|
117
|
-
return { refused: `${mode2ArchilWhy(entry.label, resolved.kind, entry.imageEnv)}.` };
|
|
118
145
|
if (entry && entry.mounts.includes("bind") && answers) {
|
|
119
146
|
const said = await answers(entry.id);
|
|
120
147
|
// It names the box whose probe said no (a refusal's details.box), as the box check did.
|
|
@@ -148,13 +175,17 @@ export function shellPlaceOf(mounts, mode) {
|
|
|
148
175
|
return "computer";
|
|
149
176
|
return mode === 2 ? "local" : "none";
|
|
150
177
|
}
|
|
151
|
-
/**
|
|
152
|
-
* configuration of the provider that serves the kind offers both) and the provider
|
|
153
|
-
*
|
|
154
|
-
function
|
|
155
|
-
const folder = mode === 1 ? "bind" : "archil";
|
|
178
|
+
/** The kind of the run's folder a computer of `kind` on `entry` holds in `mode` (folderKindOf), or undefined for none:
|
|
179
|
+
* the kind has files and exec (a configuration of the provider that serves the kind offers both) and the provider takes
|
|
180
|
+
* the mode's folder. A phone and a browser never do. `gpuMounts`: folderKindOf's. */
|
|
181
|
+
function folderOf(kind, entry, serving, mode, gpuMounts) {
|
|
156
182
|
const shell = serving.some((one) => one.groups.includes("files") && one.groups.includes("exec"));
|
|
157
|
-
|
|
183
|
+
if (!((kind === "sandbox" || kind === "desktop") && shell))
|
|
184
|
+
return undefined;
|
|
185
|
+
// Configurations made on dial by their own options (the provider's are its settings' and theirs) take no Archil mount
|
|
186
|
+
// either, as entryHere's settings' dial.
|
|
187
|
+
const dialed = serving.every((one) => dialsBy(entry, one.options ?? {}));
|
|
188
|
+
return folderKindOf(dialed ? withoutArchil(entry) : entry, mode, gpuMounts);
|
|
158
189
|
}
|
|
159
190
|
/** The configurations of `entry` that serve `kind`. */
|
|
160
191
|
const servingOf = (registry, entry, kind) => entry.capabilities.filter((one) => registry.servingRefusals(one, kind).length === 0);
|
|
@@ -188,7 +219,7 @@ export function runShellOf(setting, mode, registry) {
|
|
|
188
219
|
// An agent whose computer runs no programs of its own has no shell anywhere: not its computer's, not Archil's exec.
|
|
189
220
|
if (noPrograms(setting))
|
|
190
221
|
return "none";
|
|
191
|
-
const mounts =
|
|
222
|
+
const mounts = folderOf(kind, entry, serving, mode) !== undefined;
|
|
192
223
|
if (kind === "sandbox" && !mounts)
|
|
193
224
|
return "none";
|
|
194
225
|
return shellPlaceOf(mounts, mode);
|
|
@@ -236,13 +267,11 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
236
267
|
return { refused: `No provider gives a ${kind} computer on this server: pick another kind for this agent's computer in ${SETTINGS}.` };
|
|
237
268
|
if (!setting.provider)
|
|
238
269
|
return { refused: `A ${kind} computer needs a provider: pick ${pick}` };
|
|
239
|
-
|
|
240
|
-
|
|
270
|
+
// `registry` is as this server has it (registryHere, by its caller): the mounts its keys turn on, and whether the
|
|
271
|
+
// operator names its image, so the folder it holds is the one the start and the readiness check said.
|
|
272
|
+
const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
|
|
273
|
+
if (!entry)
|
|
241
274
|
return { refused: `${JSON.stringify(setting.provider)} is no computer provider this server knows: pick ${pick}` };
|
|
242
|
-
// The mounts its keys turn on (entryHere: Daytona's Archil mount with an Archil egress), read from the keys the claim
|
|
243
|
-
// gives it, so the folder it mounts is the one its provider, made with those keys, declares.
|
|
244
|
-
const keyed = listed.mountsWith === undefined ? undefined : await side.keysOf(listed.id);
|
|
245
|
-
const entry = keyed === undefined ? listed : entryHere(listed, (name) => Boolean(keyed[name]?.trim()));
|
|
246
275
|
// The configurations of the provider that serve the kind; none, and the registry says why, by its closest one.
|
|
247
276
|
const serving = servingOf(registry, entry, kind);
|
|
248
277
|
if (serving.length === 0) {
|
|
@@ -264,23 +293,25 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
264
293
|
return { refused: `${parked.why}, so this agent's ${JSON.stringify(setting.image)} ${kind} is parked. It ${offers} for this agent's computer in ${SETTINGS}.` };
|
|
265
294
|
return { refused: `${entry.label} has no ${kind} image ${JSON.stringify(setting.image)}. It ${offers} for this agent's computer in ${SETTINGS}.` };
|
|
266
295
|
}
|
|
267
|
-
// The run's folder:
|
|
268
|
-
//
|
|
269
|
-
|
|
270
|
-
|
|
296
|
+
// The run's folder: held where the selected configuration has files and exec and the provider takes the mode's folder
|
|
297
|
+
// (of the kinds its GPU computers take, where the setting asks for GPUs), and the agent may run programs there (a
|
|
298
|
+
// folder is mounted for its shell).
|
|
299
|
+
const gpu = kind === "sandbox" && setting.gpu ? setting.gpu : undefined;
|
|
300
|
+
const folder = noPrograms(setting) ? undefined : folderOf(kind, entry, [configuration], mode, gpu ? configuration.gpu?.mounts : undefined);
|
|
301
|
+
const mounts = folder !== undefined;
|
|
302
|
+
if (kind === "sandbox" && folder === undefined) {
|
|
271
303
|
if (mode === 1)
|
|
272
304
|
return { refused: `Mode 1 runs a sandbox only on Docker: ${aLabel(entry.label)} sandbox can't reach the run's folder on this machine. Pick Docker for this agent's computer in ${SETTINGS}, or another kind of computer.` };
|
|
273
305
|
if (entry.mounts.includes("bind"))
|
|
274
306
|
return { refused: `Mode 2 keeps workspaces on Archil; a local Docker computer can't mount them. Pick a remote sandbox for this agent's computer in ${SETTINGS}, or no computer.` };
|
|
275
|
-
const why = entry.unmounted?.archil;
|
|
276
|
-
return { refused: `${aLabel(entry.label, true)} sandbox can't
|
|
307
|
+
const why = [entry.unmounted?.archil, entry.unmounted?.sync].filter((one) => one !== undefined).join("; ");
|
|
308
|
+
return { refused: `${aLabel(entry.label, true)} sandbox can't hold the run's folder from Archil${why ? ` (${why})` : ""}: pick another sandbox for this agent's computer in ${SETTINGS}.` };
|
|
277
309
|
}
|
|
278
310
|
// Its GPUs, a sandbox's alone: in gpuRefused's words, against what the configuration the setting selected declares,
|
|
279
|
-
// with the
|
|
311
|
+
// with the run's folder as the mount it takes (a sandbox here always holds it). A GPU computer that can't take the
|
|
280
312
|
// folder is told so, and what to use instead.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const refused = gpuRefused(gpu, configuration.gpu, { kind: mode === 1 ? "bind" : "archil" }, entry.label);
|
|
313
|
+
if (gpu && folder) {
|
|
314
|
+
const refused = gpuRefused(gpu, configuration.gpu, { kind: folder }, entry.label);
|
|
284
315
|
if (refused?.folder)
|
|
285
316
|
return { refused: refused.words };
|
|
286
317
|
if (refused)
|
|
@@ -294,7 +325,7 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
294
325
|
if (persistent && mounts)
|
|
295
326
|
return { refused: `${aLabel(entry.label, true)} ${kind} mounts each run's folder, so it can't be kept between runs: turn persistent off for this agent's computer in ${SETTINGS}.` };
|
|
296
327
|
// Its keys: every required one saved, before anything starts; only declared names go to the provider.
|
|
297
|
-
const saved =
|
|
328
|
+
const saved = await side.keysOf(entry.id);
|
|
298
329
|
const has = (name) => typeof saved[name] === "string" && saved[name] !== "";
|
|
299
330
|
const missing = entry.keys.filter((key) => key.required && !has(key.name)).map((key) => key.name);
|
|
300
331
|
if (missing.length > 0) {
|
|
@@ -308,11 +339,32 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
308
339
|
kind,
|
|
309
340
|
provider: entry.id,
|
|
310
341
|
mounts,
|
|
342
|
+
...(folder ? { folder } : {}),
|
|
311
343
|
ports,
|
|
312
|
-
async start({ workspace, check, signal }) {
|
|
344
|
+
async start({ workspace, check, holds, signal }) {
|
|
313
345
|
// A computer kept at the run's park, attached again: it mounts what it mounted, read back under its own epoch.
|
|
314
|
-
const again = await side.reattach?.(entry, { kind, keys, configuration, ...(persistent ? { persistent: true } : {}), ...(signal ? { signal } : {}) });
|
|
315
|
-
|
|
346
|
+
const again = await side.reattach?.(entry, { kind, keys, configuration, ...(folder ? { folder } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(persistent ? { persistent: true } : {}), ...(signal ? { signal } : {}) });
|
|
347
|
+
// The run's disk as the runner keeps the folder on it, each write fenced by the claim.
|
|
348
|
+
const diskOf = () => {
|
|
349
|
+
const disk = workspace.syncStore?.();
|
|
350
|
+
return disk && holds ? fencedStore(disk, holds) : disk;
|
|
351
|
+
};
|
|
352
|
+
// A synced folder's store: for a new computer, listed and held to the caps before it is rented.
|
|
353
|
+
const store = folder === "sync" ? diskOf() : undefined;
|
|
354
|
+
if (folder === "sync" && store === undefined) {
|
|
355
|
+
await again?.release().catch(() => undefined);
|
|
356
|
+
throw unavailable(`${entry.label} could not start a ${kind} computer: this run's folder can't be synced into a computer here`);
|
|
357
|
+
}
|
|
358
|
+
let stored;
|
|
359
|
+
if (store && !again) {
|
|
360
|
+
try {
|
|
361
|
+
stored = await storedFolder(store);
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
throw unavailable(`${aLabel(entry.label, true)} ${kind} can't hold this run's folder: ${error instanceof Error ? error.message : String(error)}.`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const mount = !mounts || again ? undefined : folder === "sync" ? { kind: "sync" } : await workspace.mountSpec();
|
|
316
368
|
let launched;
|
|
317
369
|
try {
|
|
318
370
|
launched = again ?? await side.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(persistent ? { persistent: true } : {}), ...(signal ? { signal } : {}) });
|
|
@@ -324,19 +376,75 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
324
376
|
throw unavailable(noDockerWords(kind, registry.PROVIDERS, mode));
|
|
325
377
|
throw unavailable(`${entry.label} could not start a ${kind} computer: ${error instanceof Error ? error.message : String(error)}`);
|
|
326
378
|
}
|
|
327
|
-
|
|
328
|
-
|
|
379
|
+
// A folder synced on an earlier claim, now under a new Archil mount: the modes and links its sync.json keeps, which
|
|
380
|
+
// the mount never reads, put back (and the mount synced) before any tool runs. One that can't be lets the computer go.
|
|
381
|
+
const synced = folder === "archil" ? diskOf() : undefined;
|
|
382
|
+
if (synced && launched.client && !again) {
|
|
383
|
+
try {
|
|
384
|
+
await restoreMeta(synced, syncingClient(launched.client, archilSync(launched.client)), signal);
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
await launched.release().catch(() => undefined);
|
|
388
|
+
throw unavailable(`${entry.label} could not start a ${kind} computer: ${error instanceof Error ? error.message : String(error)}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// A synced folder, before any tool runs there: pushed into a new computer, or pulled whole from a kept one (whose
|
|
392
|
+
// copy may be newer than the disk's). One that can't be had lets the computer go.
|
|
393
|
+
let sync;
|
|
394
|
+
if (store && launched.client) {
|
|
395
|
+
try {
|
|
396
|
+
sync = syncOf(again ? await pullFolder(store, launched.client, signal) : await pushFolder(store, launched.client, stored, signal));
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
await launched.release().catch(() => undefined);
|
|
400
|
+
throw unavailable(`${entry.label} could not start a ${kind} computer: ${error instanceof Error ? error.message : String(error)}`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
const checked = mounts ? { ...check, ...(again ? { epoch: again.epoch } : {}), ...(folder === "sync" ? { sync: true } : {}) } : undefined;
|
|
404
|
+
const computer = runComputerOf(kind, launched, checked, { ...(setting.surface ? { surface: setting.surface } : {}), ...(noPrograms(setting) ? { exec: false } : {}) }, sync);
|
|
329
405
|
if (typeof computer === "string") {
|
|
330
406
|
await launched.release();
|
|
331
407
|
throw unavailable(`${entry.label} could not start a ${kind} computer: ${computer}`);
|
|
332
408
|
}
|
|
333
|
-
|
|
409
|
+
const own = launched.client;
|
|
410
|
+
if (!sync && synced && own) {
|
|
411
|
+
// An Archil mount's park and release: its modes and links recorded in sync.json first (recordMeta), for a later
|
|
412
|
+
// claim that syncs the folder; the computer goes whatever that answered, and a failed one is said.
|
|
413
|
+
const record = () => recordMeta(synced, own);
|
|
414
|
+
return {
|
|
415
|
+
computer,
|
|
416
|
+
sync: record,
|
|
417
|
+
async release() {
|
|
418
|
+
const recorded = await record();
|
|
419
|
+
await launched.release();
|
|
420
|
+
if (!recorded.ok)
|
|
421
|
+
throw new Error(recordWords(recorded.error.message));
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
if (!sync)
|
|
426
|
+
return { computer, release: () => launched.release() };
|
|
427
|
+
const final = sync;
|
|
428
|
+
// A synced folder's release: a final delta (what a background program wrote since the last change), then the
|
|
429
|
+
// computer goes, whatever the delta answered; a failed one is said in archilRelease's words.
|
|
430
|
+
return {
|
|
431
|
+
computer,
|
|
432
|
+
sync: final,
|
|
433
|
+
async release() {
|
|
434
|
+
const synced = await final();
|
|
435
|
+
await launched.release();
|
|
436
|
+
if (!synced.ok)
|
|
437
|
+
throw new Error(finalSyncWords(synced.error.message));
|
|
438
|
+
},
|
|
439
|
+
};
|
|
334
440
|
},
|
|
335
441
|
};
|
|
336
442
|
}
|
|
337
443
|
/** The started computer as runTools takes it, or what it lacks, in words. `agent`: a desktop's or a phone's surface and
|
|
338
|
-
* exec, as its agent's setting says them.
|
|
339
|
-
|
|
444
|
+
* exec, as its agent's setting says them. `sync`: a synced folder's delta, which lands on the disk after every call
|
|
445
|
+
* that may change the folder, before it answers (syncingClient); the tools, the attached Workspace and the owner's door
|
|
446
|
+
* share the one client, and each call's recorded time holds its sync. */
|
|
447
|
+
function runComputerOf(kind, launched, check, agent, sync) {
|
|
340
448
|
// The run's browser tool opens a browser's sessions through its provider.
|
|
341
449
|
if (kind === "browser")
|
|
342
450
|
return launched.browser ? { kind, browser: launched.browser } : "it gave no CDP connection";
|
|
@@ -344,7 +452,7 @@ function runComputerOf(kind, launched, check, agent) {
|
|
|
344
452
|
if (!launched.client)
|
|
345
453
|
return "it gave no computer protocol client";
|
|
346
454
|
// Each call the agent's tools make is recorded on the tool call's row (computer-calls.ts): the run's one client.
|
|
347
|
-
const client = recordedClient(launched.client);
|
|
455
|
+
const client = recordedClient(sync ? syncingClient(launched.client, sync) : launched.client);
|
|
348
456
|
if (kind === "phone")
|
|
349
457
|
return hello ? { kind, computer: { client }, hello, ...agent } : "it gave no hello";
|
|
350
458
|
if (check && !launched.readBack)
|
|
@@ -2,8 +2,7 @@ import { type Workspace } from "./workspace.js";
|
|
|
2
2
|
/** Where a run's skills are, from its folder's root. */
|
|
3
3
|
export declare const RUN_SKILLS_DIR = ".agents/skills";
|
|
4
4
|
/** Lays the revision's own skills in the run's `.agents/skills/` at a claim, keeping what is there: each skill folder
|
|
5
|
-
* not there yet is written, one that is (laid at an earlier claim
|
|
6
|
-
* name no revision skill takes) is left as it is. Every path is checked first, by the Workspace's own rule: one that
|
|
5
|
+
* not there yet is written, one that is (laid at an earlier claim) is left as it is. Every path is checked first, by the Workspace's own rule: one that
|
|
7
6
|
* would leave `.agents/skills/` (absolute, "..", an empty segment, a backslash, or none) is ESCAPE, and nothing is
|
|
8
7
|
* written. A link on the way is ESCAPE too, and nothing is written through it.
|
|
9
8
|
*
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// A revision's skills laid in a run's folder, through the run's Workspace, at each claim: what a run's harness reads its
|
|
2
2
|
// skills from. A run whose computer is a desktop or a phone gets that kind's skill beside them (kind-skills.ts). This
|
|
3
|
-
// is the one writer of the run's .agents/skills/: it only adds what is missing, so
|
|
4
|
-
//
|
|
3
|
+
// is the one writer of the run's .agents/skills/: it only adds what is missing, so an earlier claim's folder and the
|
|
4
|
+
// run's own edits are never removed or written over.
|
|
5
5
|
import { kindSkillOf } from "./kind-skills.js";
|
|
6
6
|
import { relativeSegments } from "./paths.js";
|
|
7
7
|
import { WorkspaceError } from "./workspace.js";
|
|
8
8
|
/** Where a run's skills are, from its folder's root. */
|
|
9
9
|
export const RUN_SKILLS_DIR = ".agents/skills";
|
|
10
10
|
/** Lays the revision's own skills in the run's `.agents/skills/` at a claim, keeping what is there: each skill folder
|
|
11
|
-
* not there yet is written, one that is (laid at an earlier claim
|
|
12
|
-
* name no revision skill takes) is left as it is. Every path is checked first, by the Workspace's own rule: one that
|
|
11
|
+
* not there yet is written, one that is (laid at an earlier claim) is left as it is. Every path is checked first, by the Workspace's own rule: one that
|
|
13
12
|
* would leave `.agents/skills/` (absolute, "..", an empty segment, a backslash, or none) is ESCAPE, and nothing is
|
|
14
13
|
* written. A link on the way is ESCAPE too, and nothing is written through it.
|
|
15
14
|
*
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// log in words and never fails the run: the next sweep takes what is left.
|
|
9
9
|
// Mode 1: the run's local folder (runFolder). Its end does nothing here; the tools' end clears what they keep in it.
|
|
10
10
|
import { mkdir } from "node:fs/promises";
|
|
11
|
+
import { HELD_ARCHIL } from "./archil-claim.js";
|
|
11
12
|
import { archilWorkspace } from "./archil.js";
|
|
12
13
|
import { localWorkspace } from "./local.js";
|
|
13
14
|
import { runFolder, runKey } from "./paths.js";
|
|
@@ -25,6 +26,10 @@ export async function openRunWorkspace(options) {
|
|
|
25
26
|
const claim = options.archil;
|
|
26
27
|
if (claim === undefined)
|
|
27
28
|
throw new TypeError("a Mode 2 run's Workspace is opened with its claim's Archil claim (archilClaim)");
|
|
29
|
+
// A run's own process: the folder its runner opened on the disk (archil-claim.ts archilWhereHeld).
|
|
30
|
+
const heldThere = HELD_ARCHIL.get(claim);
|
|
31
|
+
if (heldThere)
|
|
32
|
+
return { workspace: heldThere, end: async () => { } };
|
|
28
33
|
const say = (message) => {
|
|
29
34
|
try {
|
|
30
35
|
log(message);
|