@parcha/agentrun-serve 0.1.0-beta.44 → 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 +131 -5
- package/README.md +371 -300
- 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 +52 -16
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- 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/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 +3 -1
- package/dist/errors.js +7 -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 +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- 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 +23 -89
- package/dist/learn/check.js +57 -335
- 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 +87 -102
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- 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 +13 -1
- package/dist/learn/promote.js +9 -0
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- 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 +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- 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 +268 -316
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- 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 +15 -1
- 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 +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- 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 +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +16 -8
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- 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 +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -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 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +63 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- 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 +8 -6
- package/dist/runner/promotion.js +19 -12
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- 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 +1 -5
- 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 +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- 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 +55 -33
- package/dist/server.js +685 -320
- 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 +2 -2
- package/dist/store/index.js +1 -1
- 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/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- 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/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +60 -5
- package/dist/triggers.js +123 -18
- package/dist/validate.js +1 -1
- 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 +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- 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 +33 -19
- 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 -10
- 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-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.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 -35
- package/dist/learning-evals.js +0 -99
- 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
|
@@ -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, ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(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);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type ComputerClient, type FolderMeta, FolderSync, type Result, type SyncSink } from "@parcha/agentrun-computer";
|
|
2
|
+
/** A file or a directory of the folder as the store holds it, by its path relative to the folder. */
|
|
3
|
+
export type StoredEntry = {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly type: "file" | "dir";
|
|
6
|
+
readonly size: number;
|
|
7
|
+
};
|
|
8
|
+
/** Where the runner keeps a synced folder: what the delta writes (SyncSink), and what a push and a full pull read. */
|
|
9
|
+
export interface FolderStore extends SyncSink {
|
|
10
|
+
/** Every file and directory of the folder, each once, by path relative to it (one that is no relative path throws). */
|
|
11
|
+
entries(): AsyncIterable<StoredEntry>;
|
|
12
|
+
/** File `path`'s bytes, the `size` its listing gave. */
|
|
13
|
+
read(path: string, size: number): Promise<Uint8Array>;
|
|
14
|
+
/** The folder's modes and links as last written, or none where none were. */
|
|
15
|
+
readMeta(): Promise<FolderMeta | undefined>;
|
|
16
|
+
}
|
|
17
|
+
/** What the store holds, listed whole and within the caps, and its modes and links. `linkObjects`: links an exec made
|
|
18
|
+
* on the disk (an Archil mount's), which its file API lists as files: pushed as the links sync.json names, then removed
|
|
19
|
+
* from the disk, which keeps a synced folder's links in sync.json alone. */
|
|
20
|
+
export type StoredFolder = {
|
|
21
|
+
readonly entries: readonly StoredEntry[];
|
|
22
|
+
readonly meta: FolderMeta;
|
|
23
|
+
readonly linkObjects: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The store's folder listed and held to the caps (SYNC_MAX_ENTRIES, SYNC_MAX_BYTES), from the listing alone, before a
|
|
27
|
+
* byte is read: over one, it throws in words naming the folder's size and the cap. A file the listing has where
|
|
28
|
+
* sync.json records a link is that link, made by an exec on an Archil mount (the file API lists one as a file, and an
|
|
29
|
+
* Archil computer's release records it: recordMeta). A link sync.json records where the listing has a directory, or at a
|
|
30
|
+
* path no sink takes, is not the folder's.
|
|
31
|
+
*/
|
|
32
|
+
export declare function storedFolder(store: FolderStore): Promise<StoredFolder>;
|
|
33
|
+
/**
|
|
34
|
+
* The stored folder pushed into the computer's empty /workspace through `client` (the computer's own, under no sync),
|
|
35
|
+
* one streaming tar, then the computer's listing read as the manifest: the folder's sync. The links an exec made on the
|
|
36
|
+
* disk (linkObjects), now links in the computer, are then removed from the disk. Throws in words where the push, the
|
|
37
|
+
* listing or a remove fails.
|
|
38
|
+
*/
|
|
39
|
+
export declare function pushFolder(store: FolderStore, client: ComputerClient, stored: StoredFolder, signal?: AbortSignal): Promise<FolderSync>;
|
|
40
|
+
/**
|
|
41
|
+
* A folder synced on an earlier claim, now under a mount of the disk itself (Archil), which never reads sync.json: the
|
|
42
|
+
* modes and links it keeps put back in place through `client` (the files with a mode of their own pushed again, its
|
|
43
|
+
* links made), then sync.json emptied, as the mount holds them from here on. `client` syncs the mount before a push
|
|
44
|
+
* answers, so nothing is emptied that has not landed. A folder never synced, or whose sync.json holds nothing, is left
|
|
45
|
+
* as it is. Throws in words where it fails.
|
|
46
|
+
*/
|
|
47
|
+
export declare function restoreMeta(store: FolderStore, client: ComputerClient, signal?: AbortSignal): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* The folder of a kept computer attached again (no manifest), pulled whole through `client`: every file the computer
|
|
50
|
+
* holds put on the store, and what the store holds beyond them removed. Throws in words where it fails.
|
|
51
|
+
*/
|
|
52
|
+
export declare function pullFolder(store: FolderStore, client: ComputerClient, signal?: AbortSignal): Promise<FolderSync>;
|
|
53
|
+
/**
|
|
54
|
+
* An Archil computer's folder's modes and links, read through `client` (its computerd sees the mount), written to the
|
|
55
|
+
* store's sync.json (FolderSync.recordMeta), which the mount never reads: so a later claim that holds the folder as a
|
|
56
|
+
* synced folder has them (storedFolder). A folder over a cap records nothing and is no failure: no synced folder holds it.
|
|
57
|
+
*/
|
|
58
|
+
export declare function recordMeta(store: FolderStore, client: ComputerClient): Promise<Result<void>>;
|
|
59
|
+
/** A failed recordMeta at release, in words. */
|
|
60
|
+
export declare const recordWords: (why: string) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether `claim` may still write the run's folder, by the run's row as `run` reads it from the store (runs.get). A claim
|
|
63
|
+
* moves the run's epoch up by one, and so does an end, park or release, which also clears its runner. So the claim may
|
|
64
|
+
* write while the epoch is still its own (its lease may have run out, but nothing has claimed the run since), or one
|
|
65
|
+
* past it with no runner (its own end, park or release, before its final sync). A later claim, held, ended or run out,
|
|
66
|
+
* puts the epoch further, or one past with a runner, and every write of this claim's is refused from then on.
|
|
67
|
+
*/
|
|
68
|
+
export declare const claimHolds: (run: (runId: string) => Promise<{
|
|
69
|
+
readonly epoch: number;
|
|
70
|
+
readonly runner: string | null;
|
|
71
|
+
} | undefined>, claim: {
|
|
72
|
+
readonly runId: string;
|
|
73
|
+
readonly epoch: number;
|
|
74
|
+
}) => () => Promise<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* `store` fenced by the run's claim (Q1): each write asks `holds` (claimHolds) first, and once a later claim has taken the
|
|
77
|
+
* run it is refused in words and never sent; one whose check fails is not sent either. Reads are not fenced. What is left is
|
|
78
|
+
* a write sent before the other claim landed in the store: it lands, at most one write's flight per write in flight.
|
|
79
|
+
*/
|
|
80
|
+
export declare function fencedStore(store: FolderStore, holds: () => Promise<boolean>): FolderStore;
|
|
81
|
+
/** `folder`'s sync, one at a time (syncingClient's after each change, and the final one at release), as
|
|
82
|
+
* syncingClient takes it. */
|
|
83
|
+
export declare function syncOf(folder: FolderSync): () => Promise<Result<void>>;
|
|
84
|
+
/** A failed final sync at release, in archilRelease's words. */
|
|
85
|
+
export declare const finalSyncWords: (why: string) => string;
|