@parcha/agentrun-serve 0.1.0-beta.61 → 0.1.0-beta.62
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 +66 -0
- package/README.md +102 -13
- package/dist/api-only.d.ts +4 -0
- package/dist/api-only.js +5 -1
- package/dist/archil-settings.d.ts +9 -0
- package/dist/archil-settings.js +8 -1
- package/dist/bash-read-only.d.ts +3 -0
- package/dist/bash-read-only.js +6 -3
- package/dist/chatgpt-plan.d.ts +26 -8
- package/dist/chatgpt-plan.js +89 -21
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +19 -8
- package/dist/composio-triggers.d.ts +9 -3
- package/dist/computers.d.ts +3 -0
- package/dist/computers.js +2 -1
- package/dist/console/assets/{backend-C9ffXUR5.js → backend-DEgVn5lC.js} +1 -1
- package/dist/console/assets/index-CG5tELph.js +639 -0
- package/dist/console/assets/share-CIeFK2Oe.js +6 -0
- package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/cut-pool.d.ts +14 -0
- package/dist/cut-pool.js +98 -0
- package/dist/cut-worker.d.ts +14 -0
- package/dist/cut-worker.js +16 -0
- package/dist/decisions.d.ts +4 -0
- package/dist/decisions.js +9 -1
- package/dist/env-switch.d.ts +3 -0
- package/dist/env-switch.js +3 -0
- package/dist/harness-table.d.ts +7 -0
- package/dist/harness-table.js +6 -3
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/learned-nodes.d.ts +2 -1
- package/dist/learned-nodes.js +2 -1
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- package/dist/mcp-servers-store.d.ts +7 -10
- package/dist/mcp-servers-store.js +15 -9
- package/dist/native/cli.js +5 -1
- package/dist/ollama-provider.d.ts +10 -3
- package/dist/ollama-provider.js +17 -7
- package/dist/openapi.js +29 -12
- package/dist/otel/tracer.d.ts +6 -3
- package/dist/otel/tracer.js +24 -6
- package/dist/page.d.ts +7 -0
- package/dist/page.js +17 -4
- package/dist/place.d.ts +25 -9
- package/dist/place.js +37 -11
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +2 -1
- package/dist/run-model-key.js +2 -1
- package/dist/run-reads-over-store.d.ts +7 -0
- package/dist/run-reads-over-store.js +32 -4
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +16 -6
- package/dist/runner/adapter-loop.js +64 -25
- package/dist/runner/adapter-run-spec.d.ts +6 -1
- package/dist/runner/adapter-run-spec.js +14 -11
- package/dist/runner/adapters/index.d.ts +4 -0
- package/dist/runner/adapters/index.js +2 -1
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +18 -7
- package/dist/runner/cli-run-spec.js +12 -8
- package/dist/runner/dispatch.js +2 -0
- package/dist/runner/harness-loops.d.ts +5 -0
- package/dist/runner/harness-loops.js +4 -1
- package/dist/runner/live-ticker.js +3 -1
- package/dist/runner/loop-contract.d.ts +4 -1
- package/dist/runner/mcp-run.d.ts +5 -0
- package/dist/runner/mcp-run.js +18 -0
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +5 -3
- package/dist/runner/native-loop.js +2 -2
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +44 -29
- package/dist/runner/run-child.js +1 -0
- package/dist/runner/runner.js +2 -0
- package/dist/runner/workflow-calls.d.ts +4 -3
- package/dist/runner/workflow-calls.js +41 -12
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/secret-rules.d.ts +0 -1
- package/dist/secret-rules.js +25 -5
- package/dist/server.d.ts +10 -1
- package/dist/server.js +114 -38
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +666 -0
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/suggestions.js +32 -3
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +7 -3
- package/dist/tool-gate.d.ts +25 -9
- package/dist/tool-gate.js +58 -19
- package/dist/tool-plane.d.ts +1 -0
- package/dist/tool-plane.js +6 -2
- package/dist/trigger-composio.js +1 -1
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.js +5 -0
- package/dist/workspace/archil-claim.d.ts +7 -3
- package/dist/workspace/archil-claim.js +13 -5
- package/dist/workspace/archil-mount-credential.d.ts +6 -0
- package/dist/workspace/archil-mount-credential.js +11 -0
- package/dist/workspace/computer-deps.d.ts +5 -3
- package/dist/workspace/computer-deps.js +11 -9
- package/dist/workspace/computer-for-claim.d.ts +6 -2
- package/dist/workspace/computer-for-claim.js +43 -12
- package/dist/workspace/computer-janitor.d.ts +7 -4
- package/dist/workspace/computer-janitor.js +7 -4
- package/dist/workspace/computer-kept.d.ts +7 -1
- package/dist/workspace/computer-kept.js +7 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
- package/dist/workspace/mount-revoke-left.d.ts +16 -4
- package/dist/workspace/mount-revoke-left.js +42 -22
- package/dist/workspace/resolve-computer.d.ts +11 -5
- package/dist/workspace/resolve-computer.js +22 -13
- package/dist/workspace/run-end-computers.js +1 -1
- package/dist/workspace/run-tools.d.ts +10 -3
- package/dist/workspace/run-tools.js +5 -4
- package/dist/wrapped.d.ts +29 -2
- package/dist/wrapped.js +20 -3
- package/launcher/agentrun-serve +1 -1
- package/package.json +12 -12
- package/dist/console/assets/index-BnZV3lvW.js +0 -639
- package/dist/console/assets/share-B1o5mJ56.js +0 -6
- /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
|
@@ -29,7 +29,7 @@ import { BOX_CPUS_ENV, BOX_MEMORY_ENV, BOX_PIDS_ENV } from "../start-switches.js
|
|
|
29
29
|
import { readLaunchBody } from "../run-launch.js";
|
|
30
30
|
import { SERVER_NOTE_LABEL } from "@parcha/agentrun-kernel/kernel/cap";
|
|
31
31
|
import { computerForClaim } from "./computer-for-claim.js";
|
|
32
|
-
import { computerHeldWords, computerLapsedWords, computerLostWords, KEEP_WORDS } from "./computer-kept.js";
|
|
32
|
+
import { computerHeldWords, computerLapsedWords, computerLostWords, computerRefusedWords, KEEP_WORDS } from "./computer-kept.js";
|
|
33
33
|
import { storeLedger } from "./computer-ledger.js";
|
|
34
34
|
import { computerProviderFactories, computerProviderMakers, providerSecretsOf } from "./computer-providers.js";
|
|
35
35
|
import { aLabel, needsNetwork, noNetworkRefusal, vendorNetworkOnly } from "./resolve-computer.js";
|
|
@@ -208,20 +208,22 @@ export const computerStartingWords = ({ provider, kind }) => `Starting a ${kind}
|
|
|
208
208
|
* (`kept`) says it is the same; a new one after a kept one's time passed (`replaced.lapsed`) says why first, as does
|
|
209
209
|
* one after a kept one pinned to a runner that was gone by the resume (`replaced.lost`, computerLostWords), or still
|
|
210
210
|
* there and ending it itself (`replaced.elsewhere`, computerHeldWords), and one after the kept one's provider refused
|
|
211
|
-
* to attach it again (`replaced.refused`,
|
|
212
|
-
*
|
|
211
|
+
* to attach it again (`replaced.refused`, computerRefusedWords: serve's words, never the provider's, which name host
|
|
212
|
+
* paths). A runner gone or still there says why first, though its provider refused too: that is why no runner that
|
|
213
|
+
* could reach the machine took the run. Where that runner is still there, the one before runs until its end, so the
|
|
214
|
+
* words say only that nothing on it comes with the new one, never that it is gone. */
|
|
213
215
|
export const computerReadyWords = ({ provider, kind, hello, replaced, kept }) => {
|
|
214
216
|
const ready = `The ${kind} is ready: ${[OS_NAMES[hello.os] ?? hello.os, hello.osVersion].filter(Boolean).join(" ")} (${hello.arch}), from ${provider}.`;
|
|
215
217
|
if (kept)
|
|
216
218
|
return `${ready} It's the same ${kind}, as the wait left it.`;
|
|
217
219
|
if (!replaced)
|
|
218
220
|
return ready;
|
|
219
|
-
const why = replaced.
|
|
220
|
-
? `
|
|
221
|
-
: replaced.
|
|
222
|
-
? ` ${
|
|
223
|
-
: replaced.
|
|
224
|
-
? ` ${
|
|
221
|
+
const why = replaced.lost
|
|
222
|
+
? ` ${computerLostWords(kind)}`
|
|
223
|
+
: replaced.elsewhere
|
|
224
|
+
? ` ${computerHeldWords(kind)}`
|
|
225
|
+
: replaced.refused
|
|
226
|
+
? ` ${computerRefusedWords(kind)}`
|
|
225
227
|
: replaced.lapsed
|
|
226
228
|
? ` ${computerLapsedWords(kind)}`
|
|
227
229
|
: "";
|
|
@@ -87,6 +87,9 @@ export type OpenComputerView = (args: {
|
|
|
87
87
|
export interface ComputerForClaimDeps {
|
|
88
88
|
/** The server's folder mode: 1, a folder of this machine; 2, Archil. */
|
|
89
89
|
readonly mode: 1 | 2;
|
|
90
|
+
/** In Mode 2, the server's Archil region where it has no serverless exec (archil-settings.ts noExecRegionOf): a run
|
|
91
|
+
* with no computer that mounts its folder has no shell there (resolve-computer.ts shellPlaceOf). */
|
|
92
|
+
readonly noExec: string | undefined;
|
|
90
93
|
/** The computer module's kind registry (or --faux's). */
|
|
91
94
|
readonly kinds: KindRegistry;
|
|
92
95
|
/** The server's seal key: absent, no key is opened, so a provider that needs one is refused in words. */
|
|
@@ -254,14 +257,15 @@ export type KeptKind = Kept["kind"];
|
|
|
254
257
|
* process of this runner's name), that runner was gone by this claim, and this claim could not reach it. `elsewhere`:
|
|
255
258
|
* the same, but that runner was still there (refusing claims, or its word late), so this claim gave the row back for
|
|
256
259
|
* that runner to end the machine (restoreKept). `refused`: the earlier one was kept at a park, and its provider refused
|
|
257
|
-
* to attach it again
|
|
260
|
+
* to attach it again (a Docker computer made before its egress bridge, or bound from another runner's home); the
|
|
261
|
+
* provider's words went to the runner's log alone. */
|
|
258
262
|
export type Replaced = {
|
|
259
263
|
readonly kind: MadeKind;
|
|
260
264
|
readonly folderKept: boolean;
|
|
261
265
|
readonly lapsed?: true;
|
|
262
266
|
readonly lost?: true;
|
|
263
267
|
readonly elsewhere?: true;
|
|
264
|
-
readonly refused?:
|
|
268
|
+
readonly refused?: true;
|
|
265
269
|
};
|
|
266
270
|
/** The agent's computer setting: the launch's, else its revision's (computer, else place), else the launch's place. The
|
|
267
271
|
* run's end reads it the same way (run-end-computers.ts). */
|
|
@@ -57,7 +57,7 @@ import { pairedProvider, withPaired } from "./attached-computers.js";
|
|
|
57
57
|
import { computerHold, heldHands } from "./computer-hold.js";
|
|
58
58
|
import { endingDeletes, figuresOf, intervalWrites, stderrLog } from "./computer-intervals.js";
|
|
59
59
|
import { computeMeter } from "../compute-cost.js";
|
|
60
|
-
import { bounded, deleteKept, dropKept, endKept, heldElsewhere, keepKept, KEEP_MS, KEPT_DELETE_MS, keptBy, keptTaken, pinnedOf, readKept, restoreKept, takeKept } from "./computer-kept.js";
|
|
60
|
+
import { bounded, deleteKept, dropKept, endKept, finishedKept, heldElsewhere, keepKept, KEEP_MS, KEPT_DELETE_MS, keptBy, keptTaken, pinnedOf, readKept, restoreKept, takeKept } from "./computer-kept.js";
|
|
61
61
|
import { storeLedger } from "./computer-ledger.js";
|
|
62
62
|
import { providerKeys, registryHere, resolveComputer, runShellOf } from "./resolve-computer.js";
|
|
63
63
|
import { computerDenied } from "../tool-gate.js";
|
|
@@ -71,6 +71,24 @@ const claimLost = (words) => Object.assign(new Error(words), { code: "claim_lost
|
|
|
71
71
|
const noop = async () => { };
|
|
72
72
|
/** A claim's create request: the run and its claim epoch, so a retry of the claim's create finds the computer it made. */
|
|
73
73
|
const claimRequestId = (claim) => `${claim.runId}#${claim.epoch}`;
|
|
74
|
+
/** `provider` that calls `kept.gone` once its delete of the kept machine answers it gone: ok, or not_found or gone (its
|
|
75
|
+
* vendor ended it already). A gone that throws is the store's: the row stays ending, for the janitor. */
|
|
76
|
+
function keptDeletes(provider, kept) {
|
|
77
|
+
return new Proxy(provider, {
|
|
78
|
+
get(target, key) {
|
|
79
|
+
const value = Reflect.get(target, key, target);
|
|
80
|
+
if (key !== "release")
|
|
81
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
82
|
+
return async (...args) => {
|
|
83
|
+
const released = await target.release(...args);
|
|
84
|
+
const [ref, how] = args;
|
|
85
|
+
if (ref.id === kept.id && how === "delete" && (released.ok || released.error.code === "not_found" || released.error.code === "gone"))
|
|
86
|
+
await kept.gone().catch(() => undefined);
|
|
87
|
+
return released;
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
74
92
|
/** The run's computers of a lower claim epoch released (the janitor's releaseOlder: one claim's computer at a time), its
|
|
75
93
|
* failure thrown in its words; true when it deleted one, an earlier claim's computer its runner never let go (a runner
|
|
76
94
|
* lost, a crash). A run's first claim is epoch 1 (a queued run is epoch 0; each claim and release moves it up one): no
|
|
@@ -82,7 +100,7 @@ async function releaseOlderClaims(provider, claim, signal, ending) {
|
|
|
82
100
|
// Each delete that answers ok ends its interval as it answers (computer-intervals.ts endingDeletes), so one deleted
|
|
83
101
|
// before another failed, or before the call was cut, keeps its end; one detached or not let go is left open.
|
|
84
102
|
const releasing = ending ? endingDeletes(provider, ending.entry, ending.writes) : provider;
|
|
85
|
-
const older = await releaseOlder(releasing, claim.runId, claim.epoch, signal ? { signal } : {});
|
|
103
|
+
const older = await releaseOlder(ending?.keptGone ? keptDeletes(releasing, ending.keptGone) : releasing, claim.runId, claim.epoch, signal ? { signal } : {});
|
|
86
104
|
if (!older.ok)
|
|
87
105
|
throw new Error(older.error.message);
|
|
88
106
|
return older.value.released.length > 0;
|
|
@@ -278,8 +296,8 @@ function providerComputer(provider, ref, connection, ended) {
|
|
|
278
296
|
* (computer-intervals.ts) is opened under `entry` (the provider's registry id) once the create answers, of `kind`, and
|
|
279
297
|
* ended by each delete that answers ok. */
|
|
280
298
|
async function providerLaunch(provider, claim, spec, signal, interval) {
|
|
281
|
-
const { writes, entry } = interval;
|
|
282
|
-
const releasedOlder = await releaseOlderClaims(provider, claim, signal, { entry, writes });
|
|
299
|
+
const { writes, entry, keptGone } = interval;
|
|
300
|
+
const releasedOlder = await releaseOlderClaims(provider, claim, signal, { entry, writes, ...(keptGone ? { keptGone } : {}) });
|
|
283
301
|
// Its first stretch held under the run's cap at what the create asks for, before anything is made: refused, nothing is.
|
|
284
302
|
const ahead = await interval.meter?.before(entry, figuresOf(spec));
|
|
285
303
|
// The claim is the request: a retry of this launch under the same epoch gets the computer it made, never a second.
|
|
@@ -685,8 +703,11 @@ store, deps) {
|
|
|
685
703
|
let lost = false;
|
|
686
704
|
/** The same, but that runner was still there, and this claim gave its row back for it to end (Replaced.elsewhere). */
|
|
687
705
|
let heldThere = false;
|
|
688
|
-
/** The kept computer's provider refused to attach it again
|
|
689
|
-
let refused;
|
|
706
|
+
/** The kept computer's provider refused to attach it again: the new one says so (Replaced.refused), in serve's words. */
|
|
707
|
+
let refused = false;
|
|
708
|
+
/** The kept row as this claim gave it back marked ending (restoreKept), where it did: the launch's release of the
|
|
709
|
+
* older claims' computers that deletes its machine marks it ended (finishedKept), so the run's end removes it. */
|
|
710
|
+
let givenBack;
|
|
690
711
|
/** What a park of this claim keeps (ClaimComputer.park): a desktop, a phone or a sandbox it made through its provider, or took
|
|
691
712
|
* back, with its provider, its connection's close and the claim epoch its labels carry; `pinned`: only this runner can
|
|
692
713
|
* reach it again (computer-kept.ts pinnedOf), so the park names this claim's holder on its row. `disk`: the Archil disk
|
|
@@ -840,6 +861,8 @@ store, deps) {
|
|
|
840
861
|
taking = undefined;
|
|
841
862
|
await reached?.close().catch(() => undefined);
|
|
842
863
|
const restored = await restoreKept(settings, launch.runId, row);
|
|
864
|
+
if (restored)
|
|
865
|
+
givenBack = row;
|
|
843
866
|
if (!restored)
|
|
844
867
|
deps.log?.(`run ${launch.runId}'s kept ${record.kind} ${record.name} could not be marked ending: the store did not take the write, so its row stays marked taking and it ends at its time`);
|
|
845
868
|
if (!elsewhere)
|
|
@@ -873,7 +896,11 @@ store, deps) {
|
|
|
873
896
|
const provider = await vendorProvider(entry, keys, configuration);
|
|
874
897
|
const taken = await keptLaunch(provider, record, signal, () => writes.ended(entry.id, record.id));
|
|
875
898
|
if (!taken || "refused" in taken) {
|
|
876
|
-
|
|
899
|
+
// The provider's words name host paths and its settings: the runner's log alone hears them.
|
|
900
|
+
if (taken) {
|
|
901
|
+
refused = true;
|
|
902
|
+
(deps.log ?? stderrLog)(`run ${launch.runId}'s kept ${record.kind} ${record.name} could not be taken back, so the claim goes on on a new one: ${taken.refused}`);
|
|
903
|
+
}
|
|
877
904
|
const there = await giveBack();
|
|
878
905
|
heldThere = there === true;
|
|
879
906
|
lost = there === false;
|
|
@@ -968,8 +995,12 @@ store, deps) {
|
|
|
968
995
|
// end: a server's stop). The journal is read before anything is rented, so a read that fails leaves nothing to let
|
|
969
996
|
// go. A paired computer is the same one at every claim, and is no computer of the run's own.
|
|
970
997
|
const journalSays = !pairedRow && launch.epoch > 1 && (await deps.hadComputer?.()) === true;
|
|
971
|
-
// A paired computer is no computer of the run's own: it has no interval.
|
|
972
|
-
|
|
998
|
+
// A paired computer is no computer of the run's own: it has no interval. A kept machine this claim gave back (it
|
|
999
|
+
// could not take it) that the release of the older claims' computers deletes has its row marked ended there: no
|
|
1000
|
+
// janitor's pass is left to wait for, and the run's end removes the row (forgetEnded).
|
|
1001
|
+
const ended = givenBack;
|
|
1002
|
+
const keptGone = !pairedRow && ended && store.settings ? { id: ended.id, gone: async () => void (await finishedKept(store.settings, launch.runId, ended)) } : undefined;
|
|
1003
|
+
const fresh = await providerLaunch(provider, launch, spec, signal, pairedRow ? { writes: intervalWrites(undefined), entry: entry.id, kind } : { writes, entry: entry.id, kind, ...(meter ? { meter } : {}), ...(keptGone ? { keptGone } : {}) });
|
|
973
1004
|
// A sandbox the claim made is started again when its provider loses it mid-run (lostAware): never a paired
|
|
974
1005
|
// computer, nor a desktop or a phone (a person may hold or watch it), nor the agent's own (persistent, above).
|
|
975
1006
|
const { releasedOlder } = fresh;
|
|
@@ -979,8 +1010,8 @@ store, deps) {
|
|
|
979
1010
|
ownKind = kind;
|
|
980
1011
|
if (!pairedRow && (kind === "desktop" || kind === "phone" || kind === "sandbox"))
|
|
981
1012
|
keepable = { provider, entry: entry.id, kind, computer: held, pinned: pinnedHere(entry, configuration), epoch: launch.epoch, disk: undefined };
|
|
982
|
-
if (!pairedRow && (releasedOlder || journalSays || lost || heldThere || refused
|
|
983
|
-
replaced = { kind: kind, folderKept: deps.mode === 2 && mount !== undefined, ...(lost ? { lost: true } : heldThere ? { elsewhere: true } : lapsed ? { lapsed: true } : {}), ...(refused
|
|
1013
|
+
if (!pairedRow && (releasedOlder || journalSays || lost || heldThere || refused))
|
|
1014
|
+
replaced = { kind: kind, folderKept: deps.mode === 2 && mount !== undefined, ...(lost ? { lost: true } : heldThere ? { elsewhere: true } : lapsed ? { lapsed: true } : {}), ...(refused ? { refused: true } : {}) };
|
|
984
1015
|
}
|
|
985
1016
|
made = { id: launched.id, machine: launched.machine, ...(launched.watch ? { watch: launched.watch, ...(kind === "desktop" || kind === "phone" ? { gone: goneOf(provider, launched.id, listedUnder, kind) } : {}) } : {}) };
|
|
986
1017
|
madeBy = entry;
|
|
@@ -1038,7 +1069,7 @@ store, deps) {
|
|
|
1038
1069
|
}
|
|
1039
1070
|
// A computer every tool of which is set to deny (tool-gate.ts computerDenied) serves the run nothing: none is started,
|
|
1040
1071
|
// nothing is rented or checked, and the run goes on without it, its timeline saying why.
|
|
1041
|
-
const denied = setting && (await deniedKind(launch, setting, store, runShellOf(setting, deps.mode, kinds)));
|
|
1072
|
+
const denied = setting && (await deniedKind(launch, setting, store, runShellOf(setting, deps.mode, kinds, deps.noExec)));
|
|
1042
1073
|
if (denied) {
|
|
1043
1074
|
deps.onComputerNote?.(computerDeniedWords(denied));
|
|
1044
1075
|
await endKeptNow();
|
|
@@ -3,6 +3,7 @@ import { type KeyTable, type ProviderSettings } from "../computer-keys.js";
|
|
|
3
3
|
import { type Store } from "../store/index.js";
|
|
4
4
|
import type { ComputerDeps } from "./computer-deps.js";
|
|
5
5
|
import { type Kept, type KeptHolder, type KeptSweep } from "./computer-kept.js";
|
|
6
|
+
import { type MountRevokeStart } from "./mount-revoke-left.js";
|
|
6
7
|
/** How often the janitor sweeps after its first sweep at the runner's start. */
|
|
7
8
|
export declare const JANITOR_EVERY_MS: number;
|
|
8
9
|
/** The longest close() waits for a sweep it cut: a vendor call that ignores the cut is left to finish on its own. */
|
|
@@ -46,8 +47,8 @@ export interface JanitorDeps {
|
|
|
46
47
|
readonly closeMs?: number;
|
|
47
48
|
/** The longest one provider's sweep may take. Default JANITOR_PROVIDER_MS. */
|
|
48
49
|
readonly providerMs?: number;
|
|
49
|
-
/** The longest the kept pass waits on one kept computer's delete, or
|
|
50
|
-
* cuts
|
|
50
|
+
/** The longest the kept pass waits on one kept computer's delete, or on its pass over the left credential removes as a
|
|
51
|
+
* whole, before it goes on and cuts their calls. Default KEPT_DELETE_MS. */
|
|
51
52
|
readonly deleteMs?: number;
|
|
52
53
|
/** The clock a computer's deadline label is read by. Default Date.now. A kept row's `until` is the store's clock's
|
|
53
54
|
* (store.sealedKeys), never this one's. */
|
|
@@ -86,10 +87,12 @@ export declare function keptMountRevoke(deps: {
|
|
|
86
87
|
* run's folder on Archil has the run's mount credentials up to its epoch removed (keptMountRevoke). Past its keep's time
|
|
87
88
|
* plus MOUNT_TTL_MS no remove is asked, so a remove that can never succeed (Archil turned off, its key gone, a refusal
|
|
88
89
|
* for good) no longer keeps the row ending and said at every pass. The removes a claim that kept nothing left at its
|
|
89
|
-
* end (mount-revoke-left.ts) are asked the same way, each
|
|
90
|
-
*
|
|
90
|
+
* end (mount-revoke-left.ts) are asked the same way, each row removed once its remove answers, the pass over them
|
|
91
|
+
* bounded as a whole by `deleteMs` and started where `leftStart` (the janitor's, kept across its passes) says.
|
|
92
|
+
* Undefined without the store's settings, where none is kept. Never throws. */
|
|
91
93
|
export declare function sweepKeptComputers(deps: Pick<JanitorDeps, "store" | "computers" | "env" | "sealKey" | "mountControl" | "now" | "self" | "deleteMs"> & {
|
|
92
94
|
readonly log?: (line: string) => void;
|
|
95
|
+
readonly leftStart: MountRevokeStart;
|
|
93
96
|
}): Promise<KeptSweep | undefined>;
|
|
94
97
|
/** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
|
|
95
98
|
* computer is due (sweepKeptComputers; each delete bounded, KEPT_DELETE_MS), so a park's keep ends on time though the
|
|
@@ -293,8 +293,9 @@ export function keptMountRevoke(deps, now) {
|
|
|
293
293
|
* run's folder on Archil has the run's mount credentials up to its epoch removed (keptMountRevoke). Past its keep's time
|
|
294
294
|
* plus MOUNT_TTL_MS no remove is asked, so a remove that can never succeed (Archil turned off, its key gone, a refusal
|
|
295
295
|
* for good) no longer keeps the row ending and said at every pass. The removes a claim that kept nothing left at its
|
|
296
|
-
* end (mount-revoke-left.ts) are asked the same way, each
|
|
297
|
-
*
|
|
296
|
+
* end (mount-revoke-left.ts) are asked the same way, each row removed once its remove answers, the pass over them
|
|
297
|
+
* bounded as a whole by `deleteMs` and started where `leftStart` (the janitor's, kept across its passes) says.
|
|
298
|
+
* Undefined without the store's settings, where none is kept. Never throws. */
|
|
298
299
|
export async function sweepKeptComputers(deps) {
|
|
299
300
|
const { store, computers } = deps;
|
|
300
301
|
const writes = intervalWrites(store, deps.log, deps.now);
|
|
@@ -323,7 +324,7 @@ export async function sweepKeptComputers(deps) {
|
|
|
323
324
|
const kept = await sweepKept({ settings, runs: store.runs, now, providerOf, deleted: (provider, id) => writes.ended(provider, id), revokeMount, ...bound, ...(store.runners ? { runners: store.runners } : {}), ...(deps.self ? { self: deps.self } : {}) });
|
|
324
325
|
// The removes a claim that kept nothing left at its end (mount-revoke-left.ts), by the same remove, its give-up and its
|
|
325
326
|
// bound, so one Archil does not answer never holds the pass from its provider sweep and its next wake.
|
|
326
|
-
const left = await sweepMountRevokes({ settings, revoke: revokeMount, ...bound });
|
|
327
|
+
const left = await sweepMountRevokes({ settings, revoke: revokeMount, start: deps.leftStart, ...bound });
|
|
327
328
|
return left.failed.length === 0 ? kept : { ...kept, failed: [...kept.failed, ...left.failed] };
|
|
328
329
|
}
|
|
329
330
|
/** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
|
|
@@ -341,8 +342,10 @@ export function startJanitor(deps) {
|
|
|
341
342
|
let wake;
|
|
342
343
|
/** A wake that came while a sweep ran: the kept pass runs again once that sweep is done. */
|
|
343
344
|
let missed = false;
|
|
345
|
+
/** Where the kept pass's next pass over the left removes starts (mount-revoke-left.ts MountRevokeStart). */
|
|
346
|
+
const leftStart = {};
|
|
344
347
|
const keptPass = async () => {
|
|
345
|
-
const kept = await sweepKeptComputers(deps);
|
|
348
|
+
const kept = await sweepKeptComputers({ ...deps, leftStart });
|
|
346
349
|
if (!kept || cut.signal.aborted)
|
|
347
350
|
return;
|
|
348
351
|
if (kept.ended.length > 0)
|
|
@@ -27,6 +27,10 @@ export declare const computerLostWords: (kind: string) => string;
|
|
|
27
27
|
* runner could not reach the machine, so it went on on a new one and that runner ends the kept one (restoreKept). Never
|
|
28
28
|
* names the runner. */
|
|
29
29
|
export declare const computerHeldWords: (kind: string) => string;
|
|
30
|
+
/** Why the run's computer at its resume is a new one: the one kept at its park was found, but its provider refused to
|
|
31
|
+
* attach it again (it no longer matches how the provider makes one here). The provider's own words name host paths and
|
|
32
|
+
* its settings, so they go to the runner's log alone (computer-for-claim.ts reattach), never to the person. */
|
|
33
|
+
export declare const computerRefusedWords: (kind: string) => string;
|
|
30
34
|
/** The live view's words once the kept computer's time passed, the run still parked. */
|
|
31
35
|
export declare const lapsedWords: (kind: string) => string;
|
|
32
36
|
/** The live view's words, the run still parked, for a kept computer whose end began before its time: a claim that could
|
|
@@ -180,7 +184,9 @@ export declare function keptTaken(settings: Pick<KeptSettings, "removeIf">, runI
|
|
|
180
184
|
* holds it): the row turned ending, whoever kept it and whether that runner is there or not, so no claim takes that
|
|
181
185
|
* machine back as the run's (nor does the claim rule pin the run to it). Its runner's end at its time (endKept, which
|
|
182
186
|
* finishes a row its park wrote that reads ending) or its janitor's next pass deletes it; once it is gone, or where any
|
|
183
|
-
* runner reaches it, any janitor's pass does.
|
|
187
|
+
* runner reaches it, any janitor's pass does. Where the claim's own launch deletes it (its provider lists it: an
|
|
188
|
+
* attach it refused, a Docker engine both runners share), that delete marks the row ended (finishedKept,
|
|
189
|
+
* computer-for-claim.ts keptDeletes), and the run's end removes it. A row this claim took the mark off (it reached the machine, then failed
|
|
184
190
|
* before it could use it) is put back so, only while the key has none. A write the store fails is tried again. True when
|
|
185
191
|
* the row reads ending (or ended) after; false when it does not (the store failed every try, and the row is left marked
|
|
186
192
|
* taking, which is ended at its time all the same). */
|
|
@@ -78,6 +78,10 @@ export const computerLostWords = (kind) => `The ${kind} wasn't kept: the runner
|
|
|
78
78
|
* runner could not reach the machine, so it went on on a new one and that runner ends the kept one (restoreKept). Never
|
|
79
79
|
* names the runner. */
|
|
80
80
|
export const computerHeldWords = (kind) => `The ${kind} wasn't kept: another runner kept it and couldn't take the run, so that runner ends it.`;
|
|
81
|
+
/** Why the run's computer at its resume is a new one: the one kept at its park was found, but its provider refused to
|
|
82
|
+
* attach it again (it no longer matches how the provider makes one here). The provider's own words name host paths and
|
|
83
|
+
* its settings, so they go to the runner's log alone (computer-for-claim.ts reattach), never to the person. */
|
|
84
|
+
export const computerRefusedWords = (kind) => `The ${kind} wasn't kept: it couldn't be taken back.`;
|
|
81
85
|
/** The live view's words once the kept computer's time passed, the run still parked. */
|
|
82
86
|
export const lapsedWords = (kind) => `${computerLapsedWords(kind)} A new one starts when the run goes on.`;
|
|
83
87
|
/** The live view's words, the run still parked, for a kept computer whose end began before its time: a claim that could
|
|
@@ -314,7 +318,9 @@ export async function keptTaken(settings, runId, taking) {
|
|
|
314
318
|
* holds it): the row turned ending, whoever kept it and whether that runner is there or not, so no claim takes that
|
|
315
319
|
* machine back as the run's (nor does the claim rule pin the run to it). Its runner's end at its time (endKept, which
|
|
316
320
|
* finishes a row its park wrote that reads ending) or its janitor's next pass deletes it; once it is gone, or where any
|
|
317
|
-
* runner reaches it, any janitor's pass does.
|
|
321
|
+
* runner reaches it, any janitor's pass does. Where the claim's own launch deletes it (its provider lists it: an
|
|
322
|
+
* attach it refused, a Docker engine both runners share), that delete marks the row ended (finishedKept,
|
|
323
|
+
* computer-for-claim.ts keptDeletes), and the run's end removes it. A row this claim took the mark off (it reached the machine, then failed
|
|
318
324
|
* before it could use it) is put back so, only while the key has none. A write the store fails is tried again. True when
|
|
319
325
|
* the row reads ending (or ended) after; false when it does not (the store failed every try, and the row is left marked
|
|
320
326
|
* taking, which is ended at its time all the same). */
|
|
@@ -56,8 +56,8 @@ the new state.
|
|
|
56
56
|
types for this desktop: its apps, its windows, its screen and input, and, where the desktop has them, its shell
|
|
57
57
|
(`computer.shell.run`) and its files (`computer.files`). The body is an async function: `await` the calls and `return`
|
|
58
58
|
what you need. Each call is a call of its own, asked about and recorded like the tools': a command is held to your
|
|
59
|
-
bash setting
|
|
60
|
-
stops the script until they answer.
|
|
59
|
+
bash setting; a file written needs write among your tools, and a file read, listed or looked up needs read, each then
|
|
60
|
+
held to that tool's setting. A call that needs a person's OK stops the script until they answer.
|
|
61
61
|
|
|
62
62
|
```js
|
|
63
63
|
const notes = computer.app("com.apple.Notes");
|
|
@@ -87,10 +87,19 @@ file from Finder into a Mail message), or anything outside every window.
|
|
|
87
87
|
|
|
88
88
|
**Only what you were given.** An agent's computer setting may leave some out: a code-only agent drives the desktop from
|
|
89
89
|
`codemode` alone, with no `computer_observe`, `computer_act` or `computer_screenshot` in its tool list; an agent whose
|
|
90
|
-
exec is off has no `computer.shell`, no `computer.processes` and no bash
|
|
90
|
+
exec is off has no `computer.shell`, no `computer.processes` and no bash; one not given read has no `computer.files`
|
|
91
|
+
read, list or stat, and one not given write no `computer.files.write`; an op whose setting is deny, or an ask no one
|
|
92
|
+
can answer here, is left out the same way. Where the desktop has the `apps` group a
|
|
91
93
|
script opens apps with `computer.apps`, and on a desktop with no ui group the tools open the app they name (below);
|
|
92
94
|
otherwise it uses the desktop's own launcher through the screen. Use what your tool list and codemode's types show.
|
|
93
95
|
|
|
96
|
+
## The run's folder
|
|
97
|
+
|
|
98
|
+
Where the run's folder is mounted on the desktop, it is `/workspace`: save there what the run should keep, from a
|
|
99
|
+
script, the terminal or an app's Save dialog. The desktop's terminal opens in the desktop user's home, not in
|
|
100
|
+
`/workspace`, so `cd /workspace` first or give the full path. Where the folder is not mounted, the server says so, and
|
|
101
|
+
what you save on the desktop stays there.
|
|
102
|
+
|
|
94
103
|
## How to work: observe, then act by ref, then check
|
|
95
104
|
|
|
96
105
|
1. **Observe** the app first. Find your target by its name and role, and note its ref.
|
|
@@ -15,16 +15,28 @@ export declare function leftRevokeOf(value: unknown): LeftRevoke | undefined;
|
|
|
15
15
|
/** Leaves run `runId`'s remove for the janitor. A row already there for a later or the same epoch is kept: its remove
|
|
16
16
|
* reaches this one's credentials too. One for an earlier epoch is replaced, by compare-and-set. */
|
|
17
17
|
export declare function leaveMountRevoke(settings: Pick<Settings, "get" | "putIfAbsent" | "replaceIf">, runId: string, left: LeftRevoke): Promise<void>;
|
|
18
|
+
/** Where the janitor's next pass over the left removes starts: at the first row, by key, after `after` (the last row a
|
|
19
|
+
* pass asked), coming back round to the first. The janitor keeps one across its passes (startJanitor), so a row whose
|
|
20
|
+
* remove hangs to the pass's bound is asked last on the next pass, after every row the bound kept from being asked. In
|
|
21
|
+
* memory: the janitor is the one sweeper of its process, and one that starts again starts at the first row. */
|
|
22
|
+
export type MountRevokeStart = {
|
|
23
|
+
after?: string;
|
|
24
|
+
};
|
|
18
25
|
/**
|
|
19
26
|
* The janitor's pass over the left removes: each asked of `revoke` (the kept pass's revokeMount, which asks nothing past
|
|
20
|
-
* the row's time plus MOUNT_TTL_MS),
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
27
|
+
* the row's time plus MOUNT_TTL_MS), and its row removed once that answers, only while it still reads as read (a later
|
|
28
|
+
* claim's left since stays). One that throws is left for the next pass, said in `failed`, and the pass goes on. The pass
|
|
29
|
+
* as a whole is bounded by `deleteMs` (KEPT_DELETE_MS): left rows pile up while Archil fails, which is when it hangs, so
|
|
30
|
+
* one bound per row would hold the janitor's provider sweep and next wake for as many bounds as there are rows. Once it
|
|
31
|
+
* passes, the remove asked is cut (the signal every remove is handed), and it and the rows not yet asked are left for
|
|
32
|
+
* the next pass, said in `failed`. The pass starts where `start` says and moves it on to each row it asks, so every pass
|
|
33
|
+
* asks at least one row past the last pass's last, and each row is asked within as many passes as there are rows.
|
|
34
|
+
* Never throws.
|
|
24
35
|
*/
|
|
25
36
|
export declare function sweepMountRevokes(deps: {
|
|
26
37
|
readonly settings: Pick<Settings, "all" | "removeIf">;
|
|
27
38
|
readonly revoke: (runId: string, left: LeftRevoke, signal: AbortSignal) => Promise<void>;
|
|
39
|
+
readonly start: MountRevokeStart;
|
|
28
40
|
readonly deleteMs?: number;
|
|
29
41
|
}): Promise<{
|
|
30
42
|
readonly failed: readonly string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KEPT_DELETE_MS } from "./computer-kept.js";
|
|
2
2
|
/** The settings prefix of the left removes. */
|
|
3
3
|
export const MOUNT_REVOKE_PREFIX = "archil_revoke:";
|
|
4
4
|
/** The settings key of run `runId`'s left remove. */
|
|
@@ -37,36 +37,56 @@ export async function leaveMountRevoke(settings, runId, left) {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* The janitor's pass over the left removes: each asked of `revoke` (the kept pass's revokeMount, which asks nothing past
|
|
40
|
-
* the row's time plus MOUNT_TTL_MS),
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* the row's time plus MOUNT_TTL_MS), and its row removed once that answers, only while it still reads as read (a later
|
|
41
|
+
* claim's left since stays). One that throws is left for the next pass, said in `failed`, and the pass goes on. The pass
|
|
42
|
+
* as a whole is bounded by `deleteMs` (KEPT_DELETE_MS): left rows pile up while Archil fails, which is when it hangs, so
|
|
43
|
+
* one bound per row would hold the janitor's provider sweep and next wake for as many bounds as there are rows. Once it
|
|
44
|
+
* passes, the remove asked is cut (the signal every remove is handed), and it and the rows not yet asked are left for
|
|
45
|
+
* the next pass, said in `failed`. The pass starts where `start` says and moves it on to each row it asks, so every pass
|
|
46
|
+
* asks at least one row past the last pass's last, and each row is asked within as many passes as there are rows.
|
|
47
|
+
* Never throws.
|
|
44
48
|
*/
|
|
45
49
|
export async function sweepMountRevokes(deps) {
|
|
46
50
|
const failed = [];
|
|
47
|
-
let
|
|
51
|
+
let read;
|
|
48
52
|
try {
|
|
49
|
-
|
|
53
|
+
read = await deps.settings.all({ prefix: MOUNT_REVOKE_PREFIX });
|
|
50
54
|
}
|
|
51
55
|
catch (error) {
|
|
52
56
|
return { failed: [`the left Archil mount credential removes could not be read: ${error?.message ?? String(error)}`] };
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
const byKey = [...read].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
59
|
+
const { after } = deps.start;
|
|
60
|
+
const from = after === undefined ? 0 : Math.max(0, byKey.findIndex((row) => row.key > after));
|
|
61
|
+
const rows = [...byKey.slice(from), ...byKey.slice(0, from)];
|
|
62
|
+
const ms = deps.deleteMs ?? KEPT_DELETE_MS;
|
|
63
|
+
const cut = new AbortController();
|
|
64
|
+
const timer = setTimeout(() => cut.abort(new Error(`its remove did not answer within ${ms / 1000} s, the pass's bound; the next pass tries again`)), ms);
|
|
65
|
+
const late = new Promise((_, reject) => cut.signal.addEventListener("abort", () => reject(cut.signal.reason), { once: true }));
|
|
66
|
+
late.catch(() => undefined);
|
|
67
|
+
try {
|
|
68
|
+
for (const [index, row] of rows.entries()) {
|
|
69
|
+
if (cut.signal.aborted) {
|
|
70
|
+
failed.push(`${rows.length - index} more left Archil mount credential removes were not asked: the pass's bound of ${ms / 1000} s passed; the next pass asks them`);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
const runId = row.key.slice(MOUNT_REVOKE_PREFIX.length);
|
|
74
|
+
deps.start.after = row.key;
|
|
75
|
+
try {
|
|
76
|
+
const left = leftRevokeOf(row.value);
|
|
77
|
+
if (left)
|
|
78
|
+
await Promise.race([deps.revoke(runId, left, cut.signal), late]);
|
|
79
|
+
await deps.settings.removeIf(row.key, row.value);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
failed.push(`the Archil mount credential of run ${runId}: ${error?.message ?? String(error)}`);
|
|
83
|
+
}
|
|
69
84
|
}
|
|
70
85
|
}
|
|
86
|
+
finally {
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
// The remove asked when the bound passed has its Archil calls cut; none is asked after the pass.
|
|
89
|
+
cut.abort(new Error("the janitor's pass over the left removes ended"));
|
|
90
|
+
}
|
|
71
91
|
return { failed };
|
|
72
92
|
}
|
|
@@ -246,8 +246,10 @@ export type ResolvedComputer = {
|
|
|
246
246
|
* container holding the run's folder alone, never a process of this server; bash only;
|
|
247
247
|
* - "none": none does, in Mode 1: the folder is one of this server's own, and a command there would run on the server
|
|
248
248
|
* itself, able to read its data and its keys; no bash family at all, the file tools alone (confined to the folder).
|
|
249
|
+
* Nor in Mode 2 where the server's Archil region has no serverless exec (`noExec`, that region: archil-settings.ts
|
|
250
|
+
* noExecRegionOf), whose every exec answers "Exec is not enabled".
|
|
249
251
|
*/
|
|
250
|
-
export declare function shellPlaceOf(mounts: boolean, mode: 1 | 2): ShellPlace;
|
|
252
|
+
export declare function shellPlaceOf(mounts: boolean, mode: 1 | 2, noExec: string | undefined): ShellPlace;
|
|
251
253
|
/** The kind of the run's folder a run of an agent with computer `setting` holds in `mode`, read off the setting and the
|
|
252
254
|
* kind registry before anything starts (selectedFor, settingFolderOf): a bind, an Archil mount or a synced folder, or
|
|
253
255
|
* undefined for none (kind none, a computer that holds no folder, or a setting the claim refuses). */
|
|
@@ -257,10 +259,11 @@ export declare function runFolderOf(setting: ComputerSetting, mode: 1 | 2, regis
|
|
|
257
259
|
* kind registry before anything starts: what the claim's runTools gives the run once its computer is started. "computer"
|
|
258
260
|
* for a sandbox, or a desktop whose provider mounts the folder and offers files and exec; for kind none, a phone, a
|
|
259
261
|
* browser or a desktop that does not mount, Archil's exec in Mode 2 ("local", bash only) and no shell at all in Mode 1
|
|
260
|
-
* ("none"). A setting this server refuses (an unknown kind
|
|
261
|
-
*
|
|
262
|
+
* or on a Mode 2 region with no exec (`noExec`, shellPlaceOf) ("none"). A setting this server refuses (an unknown kind
|
|
263
|
+
* or provider, a sandbox that cannot mount the mode's folder) runs nothing: "none". The setting is the agent's as
|
|
264
|
+
* saved; where it has none, the caller gives the server's default.
|
|
262
265
|
*/
|
|
263
|
-
export declare function runShellOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS"
|
|
266
|
+
export declare function runShellOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">, noExec: string | undefined): ShellPlace;
|
|
264
267
|
/** What a choice of no computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note).
|
|
265
268
|
* A computer that mounts the folder leaves nothing out; one that doesn't says so in its own words (APART_SHELL_NOTES). */
|
|
266
269
|
export declare const SHELL_NOTES: Readonly<Record<Exclude<ShellPlace, "computer">, string>>;
|
|
@@ -270,9 +273,12 @@ export declare const APART_SHELL_NOTES: Readonly<Record<Exclude<ShellPlace, "com
|
|
|
270
273
|
/** The host tools a run with its shell at `shell` gets, by name: the kernel registry's own list (hostToolDefs), never a
|
|
271
274
|
* second one: the file tools always, bash with a shell, the five background tools on a computer. */
|
|
272
275
|
export declare const hostToolsOf: (shell: ShellPlace) => string[];
|
|
276
|
+
/** The choice of no computer on a Mode 2 server whose Archil region `region` has no serverless exec (shellPlaceOf's
|
|
277
|
+
* `noExec`): no shell, why, and the fix, in place of SHELL_NOTES.none. */
|
|
278
|
+
export declare const noExecShellNote: (region: string) => string;
|
|
273
279
|
/** A computer choice as an agent's settings show it: where its runs have their shell (runShellOf), the host tools that
|
|
274
280
|
* gives, and what it leaves out, in words (none for a computer that mounts the folder). */
|
|
275
|
-
export declare function shellChoiceOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS"
|
|
281
|
+
export declare function shellChoiceOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">, noExec: string | undefined): {
|
|
276
282
|
shell: ShellPlace;
|
|
277
283
|
host_tools: string[];
|
|
278
284
|
shell_note?: string;
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
// provider takes more than one), in the computer package's checkGpu words, and go into the computer's spec.
|
|
17
17
|
//
|
|
18
18
|
// Where the run's shell is follows the mount (shellPlaceOf): in the computer that mounts the folder; with none, Archil's
|
|
19
|
-
// serverless exec in Mode 2 (bash only); in Mode 1 none at all, since the folder
|
|
20
|
-
// command there would run on the server itself
|
|
21
|
-
//
|
|
19
|
+
// serverless exec in Mode 2 (bash only), where the server's Archil region has it; in Mode 1 none at all, since the folder
|
|
20
|
+
// is one of this server's own and a command there would run on the server itself, and none in Mode 2 on a region with no
|
|
21
|
+
// serverless exec. runShellOf reads it off a setting before anything starts (the tool plane shows bash unavailable by
|
|
22
|
+
// it), and the claim's runTools takes the same rule over the computer it started.
|
|
23
|
+
import { noExecWords } from "../archil-settings.js";
|
|
22
24
|
import { hostToolDefs } from "@parcha/agentrun-kernel/kernel";
|
|
23
25
|
import { configurationOf, connectOf, imagesOf, mountsOf, syncingClient } from "@parcha/agentrun-computer";
|
|
24
26
|
import { noDockerWords } from "../docker-daemon.js";
|
|
@@ -162,11 +164,13 @@ const nothing = async () => { };
|
|
|
162
164
|
* container holding the run's folder alone, never a process of this server; bash only;
|
|
163
165
|
* - "none": none does, in Mode 1: the folder is one of this server's own, and a command there would run on the server
|
|
164
166
|
* itself, able to read its data and its keys; no bash family at all, the file tools alone (confined to the folder).
|
|
167
|
+
* Nor in Mode 2 where the server's Archil region has no serverless exec (`noExec`, that region: archil-settings.ts
|
|
168
|
+
* noExecRegionOf), whose every exec answers "Exec is not enabled".
|
|
165
169
|
*/
|
|
166
|
-
export function shellPlaceOf(mounts, mode) {
|
|
170
|
+
export function shellPlaceOf(mounts, mode, noExec) {
|
|
167
171
|
if (mounts)
|
|
168
172
|
return "computer";
|
|
169
|
-
return mode === 2 ? "local" : "none";
|
|
173
|
+
return mode === 2 && noExec === undefined ? "local" : "none";
|
|
170
174
|
}
|
|
171
175
|
/** The kind of the run's folder a computer of `kind` on `entry` holds in `mode` (folderKindOf), or undefined for none:
|
|
172
176
|
* the kind has files and exec (a configuration of the provider that serves the kind offers both) and the provider takes
|
|
@@ -209,12 +213,13 @@ export function runFolderOf(setting, mode, registry) {
|
|
|
209
213
|
* kind registry before anything starts: what the claim's runTools gives the run once its computer is started. "computer"
|
|
210
214
|
* for a sandbox, or a desktop whose provider mounts the folder and offers files and exec; for kind none, a phone, a
|
|
211
215
|
* browser or a desktop that does not mount, Archil's exec in Mode 2 ("local", bash only) and no shell at all in Mode 1
|
|
212
|
-
* ("none"). A setting this server refuses (an unknown kind
|
|
213
|
-
*
|
|
216
|
+
* or on a Mode 2 region with no exec (`noExec`, shellPlaceOf) ("none"). A setting this server refuses (an unknown kind
|
|
217
|
+
* or provider, a sandbox that cannot mount the mode's folder) runs nothing: "none". The setting is the agent's as
|
|
218
|
+
* saved; where it has none, the caller gives the server's default.
|
|
214
219
|
*/
|
|
215
|
-
export function runShellOf(setting, mode, registry) {
|
|
220
|
+
export function runShellOf(setting, mode, registry, noExec) {
|
|
216
221
|
if (setting.kind === "none")
|
|
217
|
-
return shellPlaceOf(false, mode);
|
|
222
|
+
return shellPlaceOf(false, mode, noExec);
|
|
218
223
|
const selected = selectedFor(setting, registry);
|
|
219
224
|
// An agent whose computer runs no programs of its own has no shell anywhere: not its computer's, not Archil's exec.
|
|
220
225
|
if (!selected || noPrograms(setting))
|
|
@@ -222,7 +227,7 @@ export function runShellOf(setting, mode, registry) {
|
|
|
222
227
|
const mounts = folderOf(selected.kind, selected.entry, [selected.configuration], mode) !== undefined;
|
|
223
228
|
if (selected.kind === "sandbox" && !mounts)
|
|
224
229
|
return "none";
|
|
225
|
-
return shellPlaceOf(mounts, mode);
|
|
230
|
+
return shellPlaceOf(mounts, mode, noExec);
|
|
226
231
|
}
|
|
227
232
|
/** What a choice of no computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note).
|
|
228
233
|
* A computer that mounts the folder leaves nothing out; one that doesn't says so in its own words (APART_SHELL_NOTES). */
|
|
@@ -239,11 +244,15 @@ export const APART_SHELL_NOTES = Object.freeze({
|
|
|
239
244
|
/** The host tools a run with its shell at `shell` gets, by name: the kernel registry's own list (hostToolDefs), never a
|
|
240
245
|
* second one: the file tools always, bash with a shell, the five background tools on a computer. */
|
|
241
246
|
export const hostToolsOf = (shell) => hostToolDefs({ maxExecS: 600, shell }).map((def) => def.name);
|
|
247
|
+
/** The choice of no computer on a Mode 2 server whose Archil region `region` has no serverless exec (shellPlaceOf's
|
|
248
|
+
* `noExec`): no shell, why, and the fix, in place of SHELL_NOTES.none. */
|
|
249
|
+
export const noExecShellNote = (region) => `No computer on this server: the agent gets the file tools only, no shell, since ${noExecWords(region)}. Give it a sandbox computer (a box) to run bash, or leave bash out of its tools.`;
|
|
242
250
|
/** A computer choice as an agent's settings show it: where its runs have their shell (runShellOf), the host tools that
|
|
243
251
|
* gives, and what it leaves out, in words (none for a computer that mounts the folder). */
|
|
244
|
-
export function shellChoiceOf(setting, mode, registry) {
|
|
245
|
-
const shell = runShellOf(setting, mode, registry);
|
|
246
|
-
|
|
252
|
+
export function shellChoiceOf(setting, mode, registry, noExec) {
|
|
253
|
+
const shell = runShellOf(setting, mode, registry, noExec);
|
|
254
|
+
const note = () => (setting.kind !== "none" ? APART_SHELL_NOTES[shell] : shell === "none" && mode === 2 && noExec !== undefined ? noExecShellNote(noExec) : SHELL_NOTES[shell]);
|
|
255
|
+
return { shell, host_tools: hostToolsOf(shell), ...(shell === "computer" ? {} : { shell_note: note() }) };
|
|
247
256
|
}
|
|
248
257
|
/** The server's default where an agent has no computer setting: in Mode 1 a sandbox on the first provider that binds a
|
|
249
258
|
* folder of this machine and answers here (Docker), else none; in Mode 2 none. */
|
|
@@ -63,7 +63,7 @@ export const RUN_END_RETRY_MS = 5_000;
|
|
|
63
63
|
* their labels: the janitor's provider sweep skips them (computer-janitor.ts sweepServerComputers), so there it ends
|
|
64
64
|
* only a machine a park kept (its kept pass, on any provider). Kept by hand, and held to the registry by
|
|
65
65
|
* run-end-computers-vendor-list.test.mjs: a provider added with lifetime "vendor" must be named here too. */
|
|
66
|
-
const VENDOR_ENDS_ITS_OWN = "E2B, Daytona, Modal, Morph, Browserbase, Kernel or the phone harness";
|
|
66
|
+
const VENDOR_ENDS_ITS_OWN = "E2B, Daytona, Modal, Morph, Render, Browserbase, Kernel or the phone harness";
|
|
67
67
|
/** Why a run's end can't have its provider here, which no later try changes: its keys or options. */
|
|
68
68
|
class NoProviderHere extends Error {
|
|
69
69
|
}
|