@parcha/agentrun-serve 0.1.0-beta.46 → 0.1.0-beta.48
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 +211 -1
- package/NOTICE +4 -0
- package/README.md +350 -53
- package/dist/acp-package.d.ts +53 -6
- package/dist/acp-package.js +3 -3
- package/dist/adapter-facts.d.ts +3 -4
- package/dist/adapter-facts.js +4 -4
- package/dist/adapters.d.ts +3 -5
- package/dist/adapters.js +1 -31
- package/dist/agents-store.d.ts +5 -3
- package/dist/agents-store.js +13 -8
- package/dist/answer-json.d.ts +10 -0
- package/dist/answer-json.js +24 -0
- package/dist/api-only.d.ts +11 -11
- package/dist/api-only.js +16 -11
- package/dist/archil-routes.js +2 -1
- package/dist/browser-live.d.ts +9 -4
- package/dist/browser-live.js +18 -5
- package/dist/cap.js +10 -2
- package/dist/chatgpt-plan.js +2 -1
- package/dist/cli.js +109 -41
- package/dist/composio-made.d.ts +19 -2
- package/dist/composio-made.js +17 -5
- package/dist/composio-preset.d.ts +42 -7
- package/dist/composio-preset.js +106 -70
- package/dist/composio-triggers.d.ts +9 -4
- package/dist/composio-triggers.js +20 -13
- package/dist/computer-attach.d.ts +11 -10
- package/dist/computer-attach.js +13 -14
- package/dist/computer-commands.d.ts +3 -0
- package/dist/computer-commands.js +3 -2
- package/dist/computer-lost.d.ts +4 -0
- package/dist/computer-lost.js +8 -3
- package/dist/computer-routes.d.ts +8 -5
- package/dist/computer-routes.js +7 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +2 -0
- package/dist/computers.d.ts +14 -76
- package/dist/computers.js +24 -68
- package/dist/conformance.d.ts +4 -0
- package/dist/conformance.js +6 -0
- package/dist/console/assets/index-CTGegcKt.css +1 -0
- package/dist/console/assets/index-D1Se6mgG.js +715 -0
- package/dist/console/index.html +2 -2
- package/dist/cost-heal.d.ts +13 -0
- package/dist/cost-heal.js +27 -0
- package/dist/dial-relay.d.ts +6 -2
- package/dist/dial-relay.js +9 -12
- package/dist/email/routes.js +2 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -0
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/faux-computers.d.ts +2 -3
- package/dist/faux-computers.js +9 -31
- package/dist/github-connection.js +2 -1
- package/dist/harness-archive.d.ts +19 -2
- package/dist/harness-archive.js +49 -15
- package/dist/harness-check.d.ts +75 -0
- package/dist/harness-check.js +518 -0
- package/dist/harness-cursor.d.ts +28 -0
- package/dist/harness-cursor.js +42 -0
- package/dist/harness-goose.d.ts +4 -29
- package/dist/harness-goose.js +6 -86
- package/dist/harness-module.d.ts +4 -0
- package/dist/harness-module.js +1 -0
- package/dist/harness-owned.d.ts +52 -0
- package/dist/harness-owned.js +92 -0
- package/dist/harness-recipe.d.ts +127 -0
- package/dist/harness-recipe.js +335 -0
- package/dist/harness-table.d.ts +120 -5
- package/dist/harness-table.js +280 -6
- package/dist/harness.d.ts +2 -0
- package/dist/harness.js +5 -4
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +14 -0
- package/dist/host.d.ts +10 -3
- package/dist/host.js +17 -3
- package/dist/import-sources.d.ts +2 -0
- package/dist/import-sources.js +2 -0
- package/dist/import-summary.d.ts +15 -5
- package/dist/import-summary.js +24 -8
- package/dist/import.d.ts +24 -4
- package/dist/import.js +108 -26
- package/dist/key-refusal.d.ts +3 -1
- package/dist/key-refusal.js +26 -5
- package/dist/key-words.d.ts +1 -1
- package/dist/key-words.js +4 -4
- package/dist/learn/check.d.ts +3 -0
- package/dist/learn/check.js +31 -20
- package/dist/learn/compile.js +12 -5
- package/dist/learn/promote.d.ts +80 -2
- package/dist/learn/promote.js +95 -3
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +23 -0
- package/dist/learned-nodes.d.ts +4 -3
- package/dist/learned-workflow.js +4 -1
- package/dist/learning-cost.d.ts +6 -16
- package/dist/learning-cost.js +6 -12
- package/dist/learning-model.d.ts +18 -0
- package/dist/learning-model.js +77 -0
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +1 -1
- package/dist/listen-first.d.ts +10 -0
- package/dist/listen-first.js +25 -1
- package/dist/llms.txt +2 -1
- package/dist/mcp-gateway.d.ts +2 -1
- package/dist/mcp-gateway.js +31 -15
- package/dist/mcp-probe.d.ts +18 -6
- package/dist/mcp-probe.js +41 -8
- package/dist/mcp-secret-writes.d.ts +8 -0
- package/dist/mcp-secret-writes.js +104 -4
- package/dist/mcp-servers-store.d.ts +11 -5
- package/dist/mcp-servers-store.js +46 -20
- package/dist/model-form.d.ts +2 -1
- package/dist/model-form.js +30 -16
- package/dist/model-gateway.d.ts +113 -0
- package/dist/model-gateway.js +433 -0
- package/dist/model.d.ts +5 -3
- package/dist/model.js +26 -18
- package/dist/monid.js +1 -1
- package/dist/native/binding.d.ts +4 -0
- package/dist/native/binding.js +9 -0
- package/dist/native/cli.d.ts +3 -2
- package/dist/native/cli.js +6 -5
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +356 -43
- package/dist/owner.d.ts +4 -2
- package/dist/owner.js +10 -4
- package/dist/page.d.ts +9 -0
- package/dist/page.js +10 -2
- package/dist/port-models.js +17 -10
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +12 -3
- package/dist/public-address.d.ts +28 -0
- package/dist/public-address.js +62 -0
- package/dist/run-launch.d.ts +1 -1
- package/dist/run-launch.js +1 -1
- package/dist/run-secrets.d.ts +3 -2
- package/dist/run-secrets.js +7 -4
- package/dist/run-trace.js +6 -3
- package/dist/runner/adapter-loop.d.ts +14 -8
- package/dist/runner/adapter-loop.js +58 -24
- package/dist/runner/adapter-run-spec.d.ts +15 -2
- package/dist/runner/adapter-run-spec.js +48 -10
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +6 -26
- package/dist/runner/adapters/pi.d.ts +5 -2
- package/dist/runner/adapters/pi.js +7 -4
- package/dist/runner/audit.d.ts +7 -0
- package/dist/runner/audit.js +15 -6
- package/dist/runner/claim-secrets.js +5 -1
- package/dist/runner/cli-run-spec.js +22 -10
- package/dist/runner/compare-end.d.ts +43 -0
- package/dist/runner/compare-end.js +95 -0
- package/dist/runner/computer-journal.d.ts +3 -0
- package/dist/runner/computer-journal.js +22 -2
- package/dist/runner/conformance/host-tools.d.ts +4 -0
- package/dist/runner/conformance/host-tools.js +14 -0
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +94 -54
- package/dist/runner/held.d.ts +5 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +3 -0
- package/dist/runner/loop-contract.d.ts +10 -0
- package/dist/runner/main.d.ts +5 -5
- package/dist/runner/main.js +62 -11
- package/dist/runner/mcp-claim.js +40 -12
- package/dist/runner/meta-tools.js +4 -2
- package/dist/runner/metrics.d.ts +26 -0
- package/dist/runner/metrics.js +44 -1
- package/dist/runner/presence.d.ts +44 -0
- package/dist/runner/presence.js +96 -0
- package/dist/runner/promotion.d.ts +70 -7
- package/dist/runner/promotion.js +178 -28
- package/dist/runner/run-child-host.js +40 -10
- package/dist/runner/runner.d.ts +5 -0
- package/dist/runner/runner.js +8 -0
- package/dist/runner/sdk-loop.js +25 -1
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +19 -7
- package/dist/runner/workflow-first.d.ts +5 -2
- package/dist/runner/workflow-first.js +6 -3
- package/dist/runner/workflow-spec.js +3 -2
- package/dist/runs-over-store.d.ts +7 -2
- package/dist/runs-over-store.js +12 -4
- package/dist/sdk/check.d.ts +31 -0
- package/dist/sdk/check.js +58 -0
- package/dist/sdk/runs.d.ts +11 -3
- package/dist/sdk/runs.js +90 -15
- package/dist/sdk/schema.js +12 -4
- package/dist/secret-writes.d.ts +16 -3
- package/dist/secret-writes.js +28 -3
- package/dist/server-secrets-store.js +5 -0
- package/dist/server.d.ts +34 -2
- package/dist/server.js +437 -90
- package/dist/sign-ins-secrets.js +4 -1
- package/dist/skills/agentrun-serve/SKILL.md +11 -0
- package/dist/slack-url.d.ts +5 -0
- package/dist/slack-url.js +11 -0
- package/dist/slack.d.ts +107 -0
- package/dist/slack.js +292 -0
- package/dist/start-switches.d.ts +28 -0
- package/dist/start-switches.js +37 -0
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +2 -1
- package/dist/stop-signals.d.ts +11 -0
- package/dist/stop-signals.js +22 -0
- package/dist/store/agent-body.d.ts +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrations/0020_runners.sql +18 -0
- package/dist/store/postgres/store.d.ts +1 -1
- package/dist/store/postgres/store.js +4 -2
- package/dist/store/schema.d.ts +13 -5
- package/dist/store/schema.js +20 -11
- package/dist/store/seal.d.ts +16 -4
- package/dist/store/sqlite/store.d.ts +1 -1
- package/dist/store/sqlite/store.js +112 -28
- package/dist/store/store.d.ts +78 -24
- package/dist/store/store.js +11 -0
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +7 -0
- package/dist/store-reads/cap.js +11 -1
- package/dist/store-reads/journal.js +27 -1
- package/dist/store-reads/learning.d.ts +23 -2
- package/dist/store-reads/learning.js +29 -8
- package/dist/store-reads/runs.d.ts +9 -0
- package/dist/store-reads/runs.js +19 -6
- package/dist/store-reads/stats.d.ts +4 -1
- package/dist/store-reads/stats.js +15 -6
- package/dist/store-view.d.ts +125 -14
- package/dist/store-view.js +156 -21
- package/dist/telemetry.d.ts +7 -7
- package/dist/telemetry.js +38 -15
- package/dist/template-eval.js +5 -2
- package/dist/template-github-permissions.d.ts +5 -1
- package/dist/template-github-permissions.js +7 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +8 -0
- package/dist/timeline/timeline.js +30 -0
- package/dist/tool-gate.d.ts +8 -4
- package/dist/tool-gate.js +6 -7
- package/dist/tool-keys-store.js +2 -2
- package/dist/tool-keys.js +2 -1
- package/dist/tool-plane.d.ts +4 -0
- package/dist/tool-plane.js +12 -12
- package/dist/trigger-adapter.d.ts +3 -4
- package/dist/trigger-adapter.js +2 -2
- package/dist/trigger-composio.js +3 -3
- package/dist/trigger-email.js +0 -2
- package/dist/trigger-feed.js +0 -2
- package/dist/trigger-schedule.js +3 -0
- package/dist/trigger-secrets-shown.d.ts +6 -3
- package/dist/trigger-secrets-shown.js +22 -13
- package/dist/trigger-targets.d.ts +12 -3
- package/dist/trigger-targets.js +90 -10
- package/dist/triggers.d.ts +2 -2
- package/dist/validate.js +5 -1
- package/dist/viewer-credential.d.ts +25 -0
- package/dist/viewer-credential.js +51 -0
- package/dist/webhooks.d.ts +82 -8
- package/dist/webhooks.js +128 -45
- package/dist/wires.d.ts +6 -1
- package/dist/wires.js +5 -0
- package/dist/workspace/attach.d.ts +3 -2
- package/dist/workspace/attach.js +2 -1
- package/dist/workspace/attached-computers.d.ts +6 -8
- package/dist/workspace/attached-computers.js +27 -24
- package/dist/workspace/computer-deps.d.ts +2 -3
- package/dist/workspace/computer-deps.js +3 -6
- package/dist/workspace/computer-for-claim.js +72 -96
- package/dist/workspace/computer-kept.d.ts +0 -7
- package/dist/workspace/computer-kept.js +0 -17
- package/dist/workspace/resolve-computer.d.ts +23 -14
- package/dist/workspace/resolve-computer.js +66 -61
- package/dist/workspace/synced-folder.d.ts +20 -15
- package/dist/workspace/synced-folder.js +33 -43
- package/launcher/agentrun-serve +4 -1
- package/package.json +18 -10
- package/skills/agentrun-serve/SKILL.md +11 -0
- package/templates/README.md +1 -1
- package/templates/code-review/agent.md +2 -3
- package/templates/code-review/evals/mentions-defused/case.yaml +0 -1
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -27
- package/templates/code-review/evals/other-repo/case.yaml +0 -1
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +0 -18
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +1 -1
- package/dist/console/assets/index-C2MYaUBa.css +0 -1
- package/dist/console/assets/index-CZZeCReB.js +0 -701
|
@@ -25,6 +25,7 @@ import { unionOf } from "../docker-host-addresses.js";
|
|
|
25
25
|
import { KEY_TABLE } from "../computer-keys.js";
|
|
26
26
|
import { envValue, keyReader } from "../key-meta.js";
|
|
27
27
|
import { boxAllowOf, boxAllowSetIn } from "../box-settings.js";
|
|
28
|
+
import { BOX_CPUS_ENV, BOX_MEMORY_ENV, BOX_PIDS_ENV } from "../start-switches.js";
|
|
28
29
|
import { readLaunchBody } from "../run-launch.js";
|
|
29
30
|
import { SERVER_NOTE_LABEL } from "@parcha/agentrun-kernel/kernel/cap";
|
|
30
31
|
import { computerForClaim } from "./computer-for-claim.js";
|
|
@@ -40,9 +41,7 @@ const refused = (words) => Object.assign(new Error(words), { code: "computer_una
|
|
|
40
41
|
/** The settings that size a Docker computer (a sandbox or a desktop): its CPUs, its memory (swap included) and how many
|
|
41
42
|
* processes and threads it may hold at once. Unset, the Docker provider's own defaults hold. A vendor's computer sizes
|
|
42
43
|
* itself and is never given them. */
|
|
43
|
-
export
|
|
44
|
-
export const BOX_MEMORY_ENV = "AGENTRUN_BOX_MEMORY";
|
|
45
|
-
export const BOX_PIDS_ENV = "AGENTRUN_BOX_PIDS";
|
|
44
|
+
export { BOX_CPUS_ENV, BOX_MEMORY_ENV, BOX_PIDS_ENV };
|
|
46
45
|
/** Each setting's spec field and what it takes, in an operator's words. */
|
|
47
46
|
const LIMIT_SETTINGS = [
|
|
48
47
|
{ name: BOX_CPUS_ENV, field: "cpus", form: "a number of CPUs, such as 2 or 1.5" },
|
|
@@ -246,9 +245,7 @@ export function claimKinds(options) {
|
|
|
246
245
|
const base = options.kinds ?? { SETTING_KINDS, PROVIDERS, servingRefusals };
|
|
247
246
|
if (!options.faux)
|
|
248
247
|
return base;
|
|
249
|
-
|
|
250
|
-
const faux = options.faux.kinds;
|
|
251
|
-
return { ...base, PROVIDERS: [...base.PROVIDERS, ...faux.PROVIDERS] };
|
|
248
|
+
return { ...base, PROVIDERS: [...base.PROVIDERS, ...options.faux.kinds.PROVIDERS] };
|
|
252
249
|
}
|
|
253
250
|
/** This machine's Docker daemon as the claim asks it once a Docker launch fails: one check per process (its answer
|
|
254
251
|
* kept a while, docker-daemon.ts), in `env`. */
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
// `lapsed`), and the run's tools and model are told (run-tools.ts, the adapter loop's computer note).
|
|
19
19
|
//
|
|
20
20
|
// A sandbox the claim made can be lost mid-run (its vendor deleted it, or no longer has it): the call that finds it lost
|
|
21
|
-
// fails, and
|
|
21
|
+
// fails, saying so and that it was not run again (code gone, computer-lost.ts lostInCallWords), and is never sent to the
|
|
22
|
+
// new one; the next call of the run's tools starts a new one in its place under this claim (lostAware), its folder
|
|
22
23
|
// mounted again (Mode 2: a new mount credential, the lost one's removed), said on the run's timeline, up to `recreates`
|
|
23
24
|
// times a claim; the loss after that ends the run, code computer_unavailable. A provider error that is not a loss (a 5xx,
|
|
24
25
|
// a timeout) starts nothing. A desktop, a phone, a paired computer and the agent's own are never started again so.
|
|
@@ -41,16 +42,16 @@ import { isBrowserProvider, ownerFilter, releaseOlder, RUN_LABEL, runLabels } fr
|
|
|
41
42
|
import { startRecording } from "../computer-record.js";
|
|
42
43
|
import { computerOfPlace } from "../computer-setting.js";
|
|
43
44
|
import { KEY_TABLE, providerOptions, settingOptions } from "../computer-keys.js";
|
|
44
|
-
import { LOST_RECREATES, lostEnd, lostRecreatedWords } from "../computer-lost.js";
|
|
45
|
+
import { LOST_RECREATES, lostEnd, lostInCallWords, lostRecreatedWords } from "../computer-lost.js";
|
|
45
46
|
import { inToolCall, stopRun } from "../paid-calls.js";
|
|
46
47
|
import { getSealedKey } from "../server-keys.js";
|
|
47
48
|
import { agentComputerOf, forgetAgentComputer, holdAgentComputer, keepAgentComputer, liveHolderOf, reconcileAgentComputer, serverIdOf } from "./agent-computer.js";
|
|
48
49
|
import { pairedProvider, withPaired } from "./attached-computers.js";
|
|
49
50
|
import { computerHold, heldHands } from "./computer-hold.js";
|
|
50
|
-
import { deleteKept, endKept, KEEP_MS,
|
|
51
|
+
import { deleteKept, endKept, KEEP_MS, readKept, takeKept, writeKept } from "./computer-kept.js";
|
|
51
52
|
import { storeLedger } from "./computer-ledger.js";
|
|
52
53
|
import { providerKeys, registryHere, resolveComputer } from "./resolve-computer.js";
|
|
53
|
-
import { claimHolds, fencedStore,
|
|
54
|
+
import { claimHolds, fencedStore, holdSynced, storedFolder } from "./synced-folder.js";
|
|
54
55
|
/** A computer that cannot be had, with the code the run fails with and the server's words. */
|
|
55
56
|
const unavailable = (words) => Object.assign(new Error(words), { code: "computer_unavailable" });
|
|
56
57
|
/** The claim was lost (its live view's registration was fenced): the run's process holds it no more. */
|
|
@@ -257,17 +258,23 @@ async function providerLaunch(provider, claim, spec, signal) {
|
|
|
257
258
|
/** The words a hosted provider's connection answers every call in once its vendor deleted the machine (the computer
|
|
258
259
|
* package's hosted deletedSaid: "the computer <name> (<id>) was deleted: <vendor> no longer has it"). */
|
|
259
260
|
const DELETED_SAID = /^the computer \S+ \(\S+\) was deleted: /;
|
|
261
|
+
/** Whether `error` says the computer that answered it is gone (its connection ended, or its vendor deleted it), as a call
|
|
262
|
+
* in flight on one another call found lost answers. */
|
|
263
|
+
const lossSaid = (error) => error.code === "gone" || (error.code === "not_found" && DELETED_SAID.test(error.message));
|
|
260
264
|
/**
|
|
261
265
|
* `first`, a sandbox the claim made through its provider (or took back from the run's park), held so its loss is not the
|
|
262
266
|
* run's: a call it answers deleted (the hosted connection's own words, DELETED_SAID), or gone with its provider
|
|
263
|
-
* confirming it no longer has it (attach answers not_found or gone), marks it lost, and that call
|
|
267
|
+
* confirming it no longer has it (attach answers not_found or gone), marks it lost, and that call fails code gone in
|
|
268
|
+
* lostInCallWords (the computer was lost while it ran, and it was not run again), never not_found: a caller that reads
|
|
269
|
+
* not_found as a program or file not there (the shell's fallback from bash to sh) would send it again, to the new one. The
|
|
264
270
|
* next call made inside one of the run's tool calls starts a new one in its place (`renewal.remake`, one at a time
|
|
265
271
|
* however many calls ask) and goes to it: the lost one let go, the run's Timeline told (`started`). Each new one is the
|
|
266
272
|
* claim's, under its epoch: a later claim lets it go as it lets any of the run's older computers go. A start that fails
|
|
267
273
|
* answers its words and counts for nothing: the next call tries again under the same request, so a retry finds what an
|
|
268
274
|
* earlier try made. Gone with the provider still reporting the machine, or its read failing (a 5xx, a timeout), is not
|
|
269
|
-
* lost: the call's own answer stands
|
|
270
|
-
*
|
|
275
|
+
* lost: the call's own answer stands. A call in flight on one another call found lost (or already replaced) is cut by the
|
|
276
|
+
* same loss: an answer that says gone fails in lostInCallWords too, and any other answer stands; neither marks the new
|
|
277
|
+
* one lost. A loss once `renewal.max` new ones were started ends the run at once (`renewal.stop`, computer-lost.ts
|
|
271
278
|
* lostEnd's words, code computer_unavailable), the call that found it answering those words, as every later call does.
|
|
272
279
|
* A call outside a tool call (the run's end sweeping its scratch, the owner's computer channel) gets the loss's own
|
|
273
280
|
* answer and starts nothing.
|
|
@@ -293,17 +300,37 @@ function lostAware(first, renewal) {
|
|
|
293
300
|
const found = await renewal.provider.attach({ id: held.ref.id }).catch(() => undefined);
|
|
294
301
|
return found !== undefined && !found.ok && (found.error.code === "not_found" || found.error.code === "gone");
|
|
295
302
|
};
|
|
296
|
-
/** `
|
|
297
|
-
|
|
303
|
+
/** The answer of a call in flight on `held` when it was lost, `why` its own: inside one of the run's tool calls, gone in
|
|
304
|
+
* lostInCallWords; outside one (the run's end, the owner's computer channel), `why` itself, as every later call
|
|
305
|
+
* outside one answers the loss. */
|
|
306
|
+
const cutBy = (held, why) => (renewal.may() ? { code: "gone", message: lostInCallWords(held.ref.name, why.message) } : why);
|
|
307
|
+
/** `why`, the current one's (`held`'s) loss, as the call that found it answers: past the bound, the run's end, at once. */
|
|
308
|
+
const lose = async (held, why) => {
|
|
298
309
|
if (made < renewal.max) {
|
|
299
310
|
lost = why;
|
|
300
311
|
letGo = false;
|
|
301
|
-
return why;
|
|
312
|
+
return cutBy(held, why);
|
|
302
313
|
}
|
|
303
314
|
spent = { code: "not_found", message: lostEnd(renewal.max, why.message) };
|
|
304
315
|
await renewal.stop(spent.message);
|
|
305
316
|
return spent;
|
|
306
317
|
};
|
|
318
|
+
/** `held`'s own client, for a synced folder's sync, which stays on the machine it holds and starts nothing: a loss it
|
|
319
|
+
* finds while `held` is the current one marks it lost as any call's does (lose), so the run's next call starts the new
|
|
320
|
+
* one before it runs. Its answers on a machine already lost or replaced stand. */
|
|
321
|
+
const ownOf = (held) => ({
|
|
322
|
+
async call(method, params, options) {
|
|
323
|
+
const answered = await held.client.call(method, params, options);
|
|
324
|
+
if (answered.ok || spent || held !== current || lost)
|
|
325
|
+
return answered;
|
|
326
|
+
if (!(await goneFrom(held, answered.error)) || spent || held !== current || lost)
|
|
327
|
+
return answered;
|
|
328
|
+
return { ok: false, error: await lose(held, answered.error) };
|
|
329
|
+
},
|
|
330
|
+
close() {
|
|
331
|
+
held.client.close();
|
|
332
|
+
},
|
|
333
|
+
});
|
|
307
334
|
/** A new one in place of the lost one, or why the run has none now. */
|
|
308
335
|
const renew = async (why) => {
|
|
309
336
|
// The lost one's resources go first: a vendor's delete of one it no longer has is done already.
|
|
@@ -313,7 +340,7 @@ function lostAware(first, renewal) {
|
|
|
313
340
|
}
|
|
314
341
|
let fresh;
|
|
315
342
|
try {
|
|
316
|
-
fresh = await renewal.remake(made + 1);
|
|
343
|
+
fresh = await renewal.remake(made + 1, ownOf);
|
|
317
344
|
}
|
|
318
345
|
catch (error) {
|
|
319
346
|
return { code: "gone", message: `${why.message}; a new sandbox could not be started: ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -342,13 +369,22 @@ function lostAware(first, renewal) {
|
|
|
342
369
|
}
|
|
343
370
|
const held = current;
|
|
344
371
|
const answered = await held.client.call(method, params, options);
|
|
345
|
-
if (answered.ok ||
|
|
372
|
+
if (answered.ok || spent)
|
|
346
373
|
return answered;
|
|
374
|
+
// Another call found `held` lost, or replaced it, while this one was in flight on it (a command's stdout and stderr
|
|
375
|
+
// read side by side): an answer that says gone is this call's cut by the same loss, never sent again either. Any
|
|
376
|
+
// other answer stands, and starts nothing.
|
|
377
|
+
if (held !== current || lost)
|
|
378
|
+
return lossSaid(answered.error) ? { ok: false, error: cutBy(held, answered.error) } : answered;
|
|
347
379
|
const gone = await goneFrom(held, answered.error);
|
|
348
|
-
|
|
349
|
-
|
|
380
|
+
if (!gone)
|
|
381
|
+
return answered;
|
|
382
|
+
// Read back after another call replaced it, or found it lost, or the run ended: cut by that loss, nothing more.
|
|
383
|
+
if (spent)
|
|
350
384
|
return answered;
|
|
351
|
-
|
|
385
|
+
if (held !== current || lost)
|
|
386
|
+
return { ok: false, error: cutBy(held, answered.error) };
|
|
387
|
+
return { ok: false, error: await lose(held, answered.error) };
|
|
352
388
|
},
|
|
353
389
|
close() {
|
|
354
390
|
current.client.close();
|
|
@@ -365,6 +401,10 @@ function lostAware(first, renewal) {
|
|
|
365
401
|
machine: first.machine,
|
|
366
402
|
hello: first.hello,
|
|
367
403
|
client,
|
|
404
|
+
// The current one's own (ownOf): a synced folder's sync through it marks a loss it finds and starts nothing.
|
|
405
|
+
get own() {
|
|
406
|
+
return ownOf(current);
|
|
407
|
+
},
|
|
368
408
|
readBack: () => current.readBack(),
|
|
369
409
|
close: () => current.close(),
|
|
370
410
|
async release() {
|
|
@@ -373,19 +413,6 @@ function lostAware(first, renewal) {
|
|
|
373
413
|
},
|
|
374
414
|
};
|
|
375
415
|
}
|
|
376
|
-
/** A kept computer's synced folder read back whole onto `store` (the run's disk) through a connection of its own, within
|
|
377
|
-
* KEPT_PULL_MS, before its end deletes it. Throws in words where it can't be. */
|
|
378
|
-
async function pullKept(provider, ref, store) {
|
|
379
|
-
const connected = await provider.connect(ref);
|
|
380
|
-
if (!connected.ok)
|
|
381
|
-
throw new Error(connected.error.message);
|
|
382
|
-
try {
|
|
383
|
-
await pullFolder(store, connected.value.client, AbortSignal.timeout(KEPT_PULL_MS));
|
|
384
|
-
}
|
|
385
|
-
finally {
|
|
386
|
-
await connected.value.close();
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
416
|
/** The computer an earlier claim of the run kept at its park (`kept`), attached again through `provider` and connected,
|
|
390
417
|
* or undefined when its provider no longer has it or it does not connect (one that does not is deleted). */
|
|
391
418
|
async function keptLaunch(provider, kept, signal) {
|
|
@@ -551,6 +578,8 @@ store, deps) {
|
|
|
551
578
|
const disk = deps.workspace.syncStore?.();
|
|
552
579
|
return disk && holds ? fencedStore(disk, holds) : disk;
|
|
553
580
|
};
|
|
581
|
+
/** The claim's synced folder, held at the start and again by each new sandbox in place of a lost one. */
|
|
582
|
+
const folderHeld = {};
|
|
554
583
|
const table = deps.keyTable ?? KEY_TABLE;
|
|
555
584
|
// The paired computers, each one more provider of the registry (attached-computers.ts): a setting names one by its id.
|
|
556
585
|
const paired = deps.attached ? await deps.attached.rows() : [];
|
|
@@ -616,11 +645,11 @@ store, deps) {
|
|
|
616
645
|
* this claim's labels and its own request (the claim's, then which new one), so a retry of it under this epoch finds
|
|
617
646
|
* the one it made. Where it holds the run's folder (`folder`), the new one holds it too, read back before it serves a
|
|
618
647
|
* call: a mount's credential of the lost one removed (Mode 2) and a new one asked for; a synced folder pushed in again
|
|
619
|
-
* from the disk (synced-folder.ts),
|
|
648
|
+
* from the disk and held (synced-folder.ts holdSynced), so the claim's sync goes on from the new one's manifest. */
|
|
620
649
|
const renewalOf = (provider, entry, specNow, folder) => ({
|
|
621
650
|
provider,
|
|
622
651
|
max: deps.recreates ?? LOST_RECREATES,
|
|
623
|
-
async remake(times) {
|
|
652
|
+
async remake(times, own) {
|
|
624
653
|
deps.onStarting?.({ provider: entry.label, kind: "sandbox" });
|
|
625
654
|
const spec = await specNow();
|
|
626
655
|
let mount;
|
|
@@ -649,7 +678,7 @@ store, deps) {
|
|
|
649
678
|
if (mount) {
|
|
650
679
|
try {
|
|
651
680
|
if (store && stored)
|
|
652
|
-
await
|
|
681
|
+
folderHeld.folder = await holdSynced(store, own(again), stored, deps.signal);
|
|
653
682
|
await deps.workspace.attach({ id: ref.id, client: again.client, readBack: () => again.readBack() }, { ...deps.check, epoch: deps.check.epoch ?? launch.epoch, ...(store ? { sync: true } : {}) });
|
|
654
683
|
}
|
|
655
684
|
catch (error) {
|
|
@@ -669,71 +698,29 @@ store, deps) {
|
|
|
669
698
|
stop: (words) => (deps.stopRun ?? stopRun)(words),
|
|
670
699
|
may: () => inToolCall() && deps.signal?.aborted !== true,
|
|
671
700
|
});
|
|
672
|
-
/** A kept synced computer this claim does not take back, ended before anything of this claim reads the run's folder off
|
|
673
|
-
* the disk, so no write of the old one lands after: one whose end is under way (the parking runner's timer, reading
|
|
674
|
-
* it back) is waited for (keptEnded); one this claim reaches (`providerOf`, its own provider's) it ends, reading it
|
|
675
|
-
* back first; one it doesn't is left ending, read back by no one, for the janitor's next pass to delete. */
|
|
676
|
-
const settleSynced = async (record, providerOf) => {
|
|
677
|
-
const settings = store.settings;
|
|
678
|
-
if (record.folder !== "sync" || !settings)
|
|
679
|
-
return;
|
|
680
|
-
const row = await readKept(settings, launch.runId).catch(() => undefined);
|
|
681
|
-
if (!row || row.ended || row.id !== record.id)
|
|
682
|
-
return;
|
|
683
|
-
const wait = () => keptEnded(settings, launch.runId, KEPT_PULL_MS + KEPT_DELETE_MS, deps.signal);
|
|
684
|
-
if (row.ending)
|
|
685
|
-
return wait();
|
|
686
|
-
const disk = diskOf();
|
|
687
|
-
const ended = await endKept(settings, launch.runId, row, async () => {
|
|
688
|
-
const provider = providerOf ? await providerOf() : undefined;
|
|
689
|
-
if (!provider)
|
|
690
|
-
throw new Error("left to the janitor");
|
|
691
|
-
if (disk)
|
|
692
|
-
await pullKept(provider, row, disk).catch(() => undefined);
|
|
693
|
-
await deleteKept(provider, row);
|
|
694
|
-
}).catch(() => true);
|
|
695
|
-
if (!ended)
|
|
696
|
-
await wait();
|
|
697
|
-
};
|
|
698
701
|
const side = {
|
|
699
702
|
keysOf: providerKeys(kinds, keyOf),
|
|
700
703
|
answers: deps.answers ?? (async () => false),
|
|
701
704
|
...(deps.daemon ? { daemon: deps.daemon } : {}),
|
|
702
|
-
// The computer an earlier claim kept at the run's park, when it is this setting's (its provider and kind
|
|
703
|
-
// time is not over: taken off its row first (computer-kept.ts takeKept), so its
|
|
704
|
-
// then attached and connected again. Its mount, where it has one, stays the
|
|
705
|
-
// this claim's from here (inheritMount). Never the agent's own computer, a
|
|
705
|
+
// The computer an earlier claim kept at the run's park, when it is this setting's (its provider and kind, holding the
|
|
706
|
+
// run's folder the same way) and its time is not over: taken off its row first (computer-kept.ts takeKept), so its
|
|
707
|
+
// end and this claim never both have it, then attached and connected again. Its mount, where it has one, stays the
|
|
708
|
+
// one it was made with: its credential is this claim's from here (inheritMount). Never the agent's own computer, a
|
|
709
|
+
// paired one or --faux's. One that isn't this setting's is left to the launch's releaseOlderClaims and its keep's end.
|
|
706
710
|
async reattach(entry, { kind, keys, configuration, folder, gpu, persistent, signal }) {
|
|
707
711
|
const record = kept;
|
|
708
712
|
kept = undefined;
|
|
709
713
|
if (!record || !store.settings)
|
|
710
714
|
return undefined;
|
|
711
|
-
if (persistent || paired.some((row) => row.id === entry.id) || (deps.launch && (deps.launches?.(entry.id) ?? true)) || record.provider !== entry.id || record.kind !== kind)
|
|
712
|
-
await settleSynced(record);
|
|
715
|
+
if (persistent || paired.some((row) => row.id === entry.id) || (deps.launch && (deps.launches?.(entry.id) ?? true)) || record.provider !== entry.id || record.kind !== kind || record.folder !== folder)
|
|
713
716
|
return undefined;
|
|
714
|
-
}
|
|
715
717
|
try {
|
|
716
718
|
// Its time over, or its end took it first (ending or ended): a new one, said so.
|
|
717
719
|
if (record.ending || record.ended || now() >= record.until || !(await takeKept(store.settings, launch.runId, record))) {
|
|
718
720
|
lapsed = true;
|
|
719
|
-
await settleSynced(record, () => vendorProvider(entry, keys, configuration));
|
|
720
721
|
return undefined;
|
|
721
722
|
}
|
|
722
723
|
const provider = await vendorProvider(entry, keys, configuration);
|
|
723
|
-
// One kept holding the run's folder another way than this claim holds it (its provider's keys changed since the
|
|
724
|
-
// park: an Archil mount where the run now takes a synced folder) is not taken back: it goes now (a synced folder
|
|
725
|
-
// read back first), its mount's token with it, so nothing holds the folder but the new one.
|
|
726
|
-
if (record.folder !== folder) {
|
|
727
|
-
const disk = record.folder === "sync" ? diskOf() : undefined;
|
|
728
|
-
if (disk)
|
|
729
|
-
await pullKept(provider, record, disk).catch(() => undefined);
|
|
730
|
-
await deleteKept(provider, record).catch(() => undefined);
|
|
731
|
-
if (record.folder === "archil") {
|
|
732
|
-
deps.inheritMount?.();
|
|
733
|
-
await deps.revokeMount?.().catch(() => undefined);
|
|
734
|
-
}
|
|
735
|
-
return undefined;
|
|
736
|
-
}
|
|
737
724
|
const taken = await keptLaunch(provider, record, signal);
|
|
738
725
|
if (!taken)
|
|
739
726
|
return undefined;
|
|
@@ -828,13 +815,6 @@ store, deps) {
|
|
|
828
815
|
const resolved = await resolveComputer(setting, deps.mode, kinds, side);
|
|
829
816
|
if ("refused" in resolved)
|
|
830
817
|
throw unavailable(resolved.refused);
|
|
831
|
-
// A kept computer this setting can't take back (no computer now, or another kind or provider: reattach sees only its
|
|
832
|
-
// own) is settled before anything reads the run's folder off the disk (settleSynced: a synced one's alone).
|
|
833
|
-
if (kept && (resolved.kind !== kept.kind || resolved.provider !== kept.provider)) {
|
|
834
|
-
const record = kept;
|
|
835
|
-
kept = undefined;
|
|
836
|
-
await settleSynced(record);
|
|
837
|
-
}
|
|
838
818
|
if (resolved.kind === "none")
|
|
839
819
|
return { computer: undefined, release: noop };
|
|
840
820
|
const refusedKind = deps.refuseKind?.(resolved.kind);
|
|
@@ -850,7 +830,8 @@ store, deps) {
|
|
|
850
830
|
let started;
|
|
851
831
|
try {
|
|
852
832
|
// The mount check carries the claim's epoch (a disk read-back under another epoch is refused) unless it names one.
|
|
853
|
-
|
|
833
|
+
const disk = diskOf();
|
|
834
|
+
started = await resolved.start({ workspace: deps.workspace, check: { ...deps.check, epoch: deps.check.epoch ?? launch.epoch }, ...(disk ? { store: disk } : {}), held: folderHeld, ...(deps.signal ? { signal: deps.signal } : {}) });
|
|
854
835
|
}
|
|
855
836
|
catch (error) {
|
|
856
837
|
await revoke().catch(() => undefined);
|
|
@@ -928,10 +909,8 @@ store, deps) {
|
|
|
928
909
|
}
|
|
929
910
|
const ref = keeps.computer.ref;
|
|
930
911
|
// A synced folder's delta lands on the disk before the computer is kept (an Archil mount's modes and links are
|
|
931
|
-
// recorded); one that does not land lets it go as the run's end does, and the park throws the release's words.
|
|
932
|
-
//
|
|
933
|
-
// takes first, is its fence, not the claim's.
|
|
934
|
-
const synced = resolved.folder === "sync" ? deps.workspace.syncStore?.() : undefined;
|
|
912
|
+
// recorded); one that does not land lets it go as the run's end does, and the park throws the release's words.
|
|
913
|
+
// What is written in it after this is the disk's only if a claim takes it back (pullFolder).
|
|
935
914
|
if (started.sync && !(await started.sync()).ok) {
|
|
936
915
|
await release();
|
|
937
916
|
return false;
|
|
@@ -955,13 +934,10 @@ store, deps) {
|
|
|
955
934
|
await keeps.computer.close();
|
|
956
935
|
})();
|
|
957
936
|
await released;
|
|
958
|
-
// Its end at its time, by this process; the janitor's (computer-kept.ts sweepKept) whatever becomes of it.
|
|
959
|
-
//
|
|
960
|
-
// row reads ending meanwhile, so a claim that comes then waits for it (keptEnded) before it reads the disk.
|
|
937
|
+
// Its end at its time, by this process; the janitor's (computer-kept.ts sweepKept) whatever becomes of it. Either
|
|
938
|
+
// deletes it, a synced folder with no read-back.
|
|
961
939
|
const timer = setTimeout(() => {
|
|
962
940
|
void endKept(settings, launch.runId, row, async () => {
|
|
963
|
-
if (synced)
|
|
964
|
-
await pullKept(keeps.provider, ref, synced).catch(() => undefined);
|
|
965
941
|
await deleteKept(keeps.provider, ref);
|
|
966
942
|
await revoke().catch(() => undefined);
|
|
967
943
|
}).catch(() => undefined);
|
|
@@ -42,13 +42,6 @@ export type Kept = {
|
|
|
42
42
|
/** How long one delete of a kept computer may take at the janitor's pass: past it the pass goes on, the row is left
|
|
43
43
|
* ending, and the next pass deletes it again (a Docker command has no timeout of its own). */
|
|
44
44
|
export declare const KEPT_DELETE_MS = 60000;
|
|
45
|
-
/** How long an end's read-back of a kept synced folder may take: past it the read stops, the delete goes on, and a
|
|
46
|
-
* claim that waits on the end (keptEnded) goes on too. */
|
|
47
|
-
export declare const KEPT_PULL_MS = 120000;
|
|
48
|
-
/** Waits while `runId`'s kept row reads ending (its end under way: a synced folder read back onto the disk, then the
|
|
49
|
-
* delete), at most `ms` of real time or until `signal` aborts. A claim does so before its computer reads the run's
|
|
50
|
-
* folder off the disk, so no write of the old one lands after. A row that can't be read is not waited on. */
|
|
51
|
-
export declare function keptEnded(settings: Pick<KeptSettings, "get">, runId: string, ms: number, signal?: AbortSignal): Promise<void>;
|
|
52
45
|
/** The settings the kept rows live in. */
|
|
53
46
|
export type KeptSettings = Pick<Settings, "get" | "put" | "replaceIf" | "removeIf" | "remove" | "all">;
|
|
54
47
|
/** A row's value as a Kept, or undefined for anything else. */
|
|
@@ -25,23 +25,6 @@ export const keptKeyOf = (runId) => `${KEPT_PREFIX}${runId}`;
|
|
|
25
25
|
/** How long one delete of a kept computer may take at the janitor's pass: past it the pass goes on, the row is left
|
|
26
26
|
* ending, and the next pass deletes it again (a Docker command has no timeout of its own). */
|
|
27
27
|
export const KEPT_DELETE_MS = 60_000;
|
|
28
|
-
/** How long an end's read-back of a kept synced folder may take: past it the read stops, the delete goes on, and a
|
|
29
|
-
* claim that waits on the end (keptEnded) goes on too. */
|
|
30
|
-
export const KEPT_PULL_MS = 120_000;
|
|
31
|
-
/** How often a claim waiting on a kept computer's end reads its row again. */
|
|
32
|
-
const KEPT_POLL_MS = 250;
|
|
33
|
-
/** Waits while `runId`'s kept row reads ending (its end under way: a synced folder read back onto the disk, then the
|
|
34
|
-
* delete), at most `ms` of real time or until `signal` aborts. A claim does so before its computer reads the run's
|
|
35
|
-
* folder off the disk, so no write of the old one lands after. A row that can't be read is not waited on. */
|
|
36
|
-
export async function keptEnded(settings, runId, ms, signal) {
|
|
37
|
-
const until = Date.now() + ms;
|
|
38
|
-
while (Date.now() < until && signal?.aborted !== true) {
|
|
39
|
-
const row = await readKept(settings, runId).catch(() => undefined);
|
|
40
|
-
if (!row?.ending)
|
|
41
|
-
return;
|
|
42
|
-
await new Promise((resolve) => setTimeout(resolve, KEPT_POLL_MS));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
28
|
/** A row's value as a Kept, or undefined for anything else. */
|
|
46
29
|
export function keptOf(value) {
|
|
47
30
|
if (!value || typeof value !== "object")
|
|
@@ -1,9 +1,10 @@
|
|
|
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 MountKind, 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, type SettingKindSpec } from "@parcha/agentrun-computer";
|
|
3
3
|
import { type DockerDaemon } from "../docker-daemon.js";
|
|
4
4
|
import type { Recording, RecordWatch } from "../computer-record.js";
|
|
5
5
|
import type { MountCheck } from "./attach.js";
|
|
6
6
|
import type { RunComputer } from "./run-tools.js";
|
|
7
|
+
import { type FolderStore, type HeldFolder } from "./synced-folder.js";
|
|
7
8
|
import type { Workspace } from "./workspace.js";
|
|
8
9
|
/** The setting kind (what an agent is given, not a computer's capabilities().kind), a machine's kind and groups, and one
|
|
9
10
|
* provider of the kind registry: the computer module's own types. Where a run's shell is: the kernel registry's. */
|
|
@@ -34,12 +35,9 @@ export declare const noPrograms: <C extends {
|
|
|
34
35
|
/** The computer module's kind registry (src/kinds.ts), by its own names: the setting kinds, why a machine does not serve
|
|
35
36
|
* one (servingRefusals, whose words a refusal here carries), and the providers. */
|
|
36
37
|
export type KindRegistry = {
|
|
37
|
-
readonly SETTING_KINDS: Readonly<Record<ComputerSettingKind,
|
|
38
|
+
readonly SETTING_KINDS: Readonly<Record<ComputerSettingKind, SettingKindSpec>>;
|
|
38
39
|
servingRefusals(capabilities: KindCapabilities, kind: ComputerSettingKind): string[];
|
|
39
40
|
readonly PROVIDERS: readonly ProviderEntry[];
|
|
40
|
-
/** A provider's own words for why it gives no computer of `kind`, where they say more than servingRefusals' (a paired
|
|
41
|
-
* computer: its driver is what to update, attached-computers.ts withPaired); undefined, servingRefusals' words. */
|
|
42
|
-
readonly unservedWhy?: (entry: ProviderEntry, kind: ComputerSettingKind) => string | undefined;
|
|
43
41
|
};
|
|
44
42
|
/** A computer a provider started for the run: its ref, its computerd client and what it offers (sandbox, desktop,
|
|
45
43
|
* phone), the hello it answered when the claim connected it (a desktop's or a phone's ports read its groups), the
|
|
@@ -50,6 +48,11 @@ export type LaunchedComputer = {
|
|
|
50
48
|
readonly id: string;
|
|
51
49
|
readonly groups: readonly (Group | string)[];
|
|
52
50
|
readonly client?: ComputerClient;
|
|
51
|
+
/** The client of the machine `client` reaches now, where `client` may go on to a new one in its place (a sandbox
|
|
52
|
+
* started again once its provider lost it: computer-for-claim.ts lostAware). A synced folder's sync lists through it,
|
|
53
|
+
* so a sync never starts the new one and reads it against the lost one's manifest; a loss it finds is marked, so the
|
|
54
|
+
* run's next call starts the new one. Absent where `client` is it. */
|
|
55
|
+
readonly own?: ComputerClient;
|
|
53
56
|
readonly hello?: HelloResult;
|
|
54
57
|
readBack?(): Promise<Result<MountReadBack>>;
|
|
55
58
|
readonly browser?: ClaimBrowser;
|
|
@@ -152,8 +155,8 @@ type HereFields = {
|
|
|
152
155
|
* descriptor's imageEnv names its image here (Daytona's AGENTRUN_DAYTONA_SNAPSHOT). Any other entry as it is. Every
|
|
153
156
|
* reader of an entry's mounts (Settings → Computers, the claim, a run's start, its shell) reads this, so the
|
|
154
157
|
* 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
|
|
156
|
-
* Archil mount
|
|
158
|
+
* settings give (computer-keys.ts settingOptions): where its machines dial this server by them, mountsOf leaves out
|
|
159
|
+
* the Archil mount, so its folder is synced where Archil's would be. */
|
|
157
160
|
export declare function entryHere<Entry extends HereFields>(entry: Entry, set: (name: string) => boolean, options?: Readonly<Record<string, unknown>>): Entry;
|
|
158
161
|
/** `registry` with each provider as this server has it (entryHere), reading only the names an entry's mountsWith or
|
|
159
162
|
* imageEnv names, by `valueOf` (key-meta.ts keyReader: the environment's value, else the saved key), and the options
|
|
@@ -209,23 +212,24 @@ export type StartedComputer = {
|
|
|
209
212
|
* kept): a synced folder's delta, or an Archil mount's modes and links in sync.json (recordMeta). */
|
|
210
213
|
readonly sync?: () => Promise<Result<void>>;
|
|
211
214
|
};
|
|
212
|
-
/** A setting resolved: its kind and provider,
|
|
215
|
+
/** A setting resolved: its kind and provider, the run's folder in it where it mounts one, the ports, and how to start it. */
|
|
213
216
|
export type ResolvedComputer = {
|
|
214
217
|
readonly kind: ComputerSettingKind;
|
|
215
218
|
readonly provider: string | null;
|
|
216
|
-
readonly mounts: boolean;
|
|
217
219
|
/** The kind of the run's folder in it, where it mounts: a bind, an Archil mount or a synced folder (folderKindOf). */
|
|
218
220
|
readonly folder?: MountKind;
|
|
219
221
|
readonly ports: readonly Port[];
|
|
220
|
-
/** Starts the computer, mounting `workspace`'s folder when it mounts (a synced folder pushed in from
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
222
|
+
/** Starts the computer, mounting `workspace`'s folder when it mounts (a synced folder pushed in from `store` before
|
|
223
|
+
* the computer is handed on); `check` is the mount check attach runs (the claim's epoch bound in); `store`: the run's
|
|
224
|
+
* disk as the claim writes the folder on it, each write fenced by the claim (computer-for-claim.ts, fencedStore),
|
|
225
|
+
* absent where this runner keeps none; `held`: the claim's synced folder, set here and again by a new sandbox in place
|
|
226
|
+
* of a lost one (computer-for-claim.ts renewalOf). A computer that cannot be had throws with code
|
|
224
227
|
* computer_unavailable and the words. */
|
|
225
228
|
start(run: {
|
|
226
229
|
readonly workspace: Workspace;
|
|
227
230
|
readonly check: MountCheck;
|
|
228
|
-
readonly
|
|
231
|
+
readonly store?: FolderStore;
|
|
232
|
+
readonly held: HeldFolder;
|
|
229
233
|
readonly signal?: AbortSignal;
|
|
230
234
|
}): Promise<StartedComputer>;
|
|
231
235
|
};
|
|
@@ -239,6 +243,11 @@ export type ResolvedComputer = {
|
|
|
239
243
|
* itself, able to read its data and its keys; no bash family at all, the file tools alone (confined to the folder).
|
|
240
244
|
*/
|
|
241
245
|
export declare function shellPlaceOf(mounts: boolean, mode: 1 | 2): ShellPlace;
|
|
246
|
+
/** The kind of the run's folder a run of an agent with computer `setting` holds in `mode`, read off the setting and the
|
|
247
|
+
* kind registry before anything starts, as the claim picks it (resolveComputer: the configuration the setting selects,
|
|
248
|
+
* settingFolderOf): a bind, an Archil mount or a synced folder, or undefined for none (kind none, a computer that holds
|
|
249
|
+
* no folder, or a setting the claim refuses). `registry` is as this server has it (registryHere, entryHere). */
|
|
250
|
+
export declare function runFolderOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">): MountKind | undefined;
|
|
242
251
|
/**
|
|
243
252
|
* Where a run of an agent with computer `setting` has its shell in `mode` (shellPlaceOf), read off the setting and the
|
|
244
253
|
* kind registry before anything starts: what the claim's runTools gives the run once its computer is started. "computer"
|