@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -5
- package/README.md +371 -300
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +52 -16
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +7 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +23 -89
- package/dist/learn/check.js +57 -335
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +87 -102
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +13 -1
- package/dist/learn/promote.js +9 -0
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +268 -316
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +15 -1
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +16 -8
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +63 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +8 -6
- package/dist/runner/promotion.js +19 -12
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1222 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +1 -5
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +55 -33
- package/dist/server.js +685 -320
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +60 -5
- package/dist/triggers.js +123 -18
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +33 -19
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -35
- package/dist/learning-evals.js +0 -99
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
package/dist/webhooks.js
CHANGED
|
@@ -36,6 +36,7 @@ export const WEBHOOK_CHANNEL = "webhook-out";
|
|
|
36
36
|
export const WEBHOOK_SETTING = "webhook-out";
|
|
37
37
|
/** The waits before each try again, after the first at once: the Standard Webhooks schedule, cut at about a day. */
|
|
38
38
|
export const RETRY_MS = [5_000, 300_000, 1_800_000, 7_200_000, 18_000_000, 36_000_000];
|
|
39
|
+
/** The bound on one try, its name's lookup included (WebhooksOptions.timeoutMs changes it). */
|
|
39
40
|
const TIMEOUT_MS = 15_000;
|
|
40
41
|
/** How far back an end's run.ended is still queued: past the retries (RETRY_MS, about a day), a notice would not be sent
|
|
41
42
|
* any more. */
|
|
@@ -47,7 +48,8 @@ const MAX_URL = 2048;
|
|
|
47
48
|
const SECRET_FIELD = "secret";
|
|
48
49
|
/** Where its secret is kept in trigger_settings (adapter WEBHOOK_CHANNEL): the server's one scope, one minted field. */
|
|
49
50
|
export const WEBHOOK_SECRET_SPEC = { scope: "server", fields: { [SECRET_FIELD]: { mint: true } } };
|
|
50
|
-
/** How long a try's claim on its message holds (Store.channels.claim): past the try's own TIMEOUT_MS
|
|
51
|
+
/** How long a try's claim on its message holds (Store.channels.claim): past the try's own bound (TIMEOUT_MS, or the
|
|
52
|
+
* option's, which the constructor holds under this). */
|
|
51
53
|
const CLAIM_MS = 60_000;
|
|
52
54
|
/** Names that are this machine or its own network, whatever they resolve to. */
|
|
53
55
|
const LOCAL_NAME = /^(localhost|.*\.localhost|.*\.local|.*\.internal)$/i;
|
|
@@ -148,10 +150,15 @@ export class Webhooks {
|
|
|
148
150
|
privateTargets;
|
|
149
151
|
lookup;
|
|
150
152
|
storeRetryMs;
|
|
153
|
+
timeoutMs;
|
|
151
154
|
/** `key` is the server's seal key; `say` takes a log line's fields. */
|
|
152
155
|
constructor(store, key, say, options = {}) {
|
|
153
156
|
this.store = store;
|
|
154
157
|
this.say = say;
|
|
158
|
+
this.timeoutMs = options.timeoutMs ?? TIMEOUT_MS;
|
|
159
|
+
// Whole milliseconds: AbortSignal.timeout takes no other, and would throw at every send, after its claim.
|
|
160
|
+
if (!(Number.isInteger(this.timeoutMs) && this.timeoutMs > 0 && this.timeoutMs < CLAIM_MS))
|
|
161
|
+
throw new RangeError(`a webhook try's bound is whole milliseconds between 0 and ${CLAIM_MS} (its claim), not ${this.timeoutMs}`);
|
|
155
162
|
this.secrets = sealedSettingsOverStore(store, WEBHOOK_CHANNEL, WEBHOOK_SECRET_SPEC, key, say);
|
|
156
163
|
this.retryMs = options.retryMs ?? RETRY_MS;
|
|
157
164
|
this.storeRetryMs = options.storeRetryMs ?? STORE_RETRY_MS;
|
|
@@ -480,7 +487,7 @@ export class Webhooks {
|
|
|
480
487
|
catch (error) {
|
|
481
488
|
// The try's own bound, cut or the server stopping: the lookup is given up on, never waited out.
|
|
482
489
|
if (signal.aborted)
|
|
483
|
-
return { refused: signal.reason?.name === "TimeoutError" ? `no answer in ${
|
|
490
|
+
return { refused: signal.reason?.name === "TimeoutError" ? `no answer in ${this.timeoutMs / 1000} s` : "not reached: the server is stopping" };
|
|
484
491
|
return { refused: `not reached: ${error.code ?? "its name does not resolve"}` };
|
|
485
492
|
}
|
|
486
493
|
if (!addresses.length || addresses.some(isPrivateAddress))
|
|
@@ -604,7 +611,7 @@ export class Webhooks {
|
|
|
604
611
|
const started = performance.now();
|
|
605
612
|
const target = new URL(config.url);
|
|
606
613
|
// One bound for the whole try, its name's lookup included, and the server's stop cuts it all (close()).
|
|
607
|
-
const signal = AbortSignal.any([AbortSignal.timeout(
|
|
614
|
+
const signal = AbortSignal.any([AbortSignal.timeout(this.timeoutMs), this.stop.signal]);
|
|
608
615
|
const dial = await this.dialled(target, signal);
|
|
609
616
|
if ("refused" in dial)
|
|
610
617
|
failure = dial.refused;
|
|
@@ -622,7 +629,7 @@ export class Webhooks {
|
|
|
622
629
|
failure = res.status >= 300 && res.status < 400 ? `answered ${res.status}: a redirect is not followed` : `answered ${res.status}`;
|
|
623
630
|
}
|
|
624
631
|
catch (error) {
|
|
625
|
-
failure = error.name === "TimeoutError" ? `no answer in ${
|
|
632
|
+
failure = error.name === "TimeoutError" ? `no answer in ${this.timeoutMs / 1000} s` : `not reached: ${error.cause?.code ?? error.message}`;
|
|
626
633
|
}
|
|
627
634
|
finally {
|
|
628
635
|
await dial.dispatcher?.close().catch(() => undefined);
|
|
@@ -51,6 +51,8 @@ export declare function forgetAgentComputer(store: {
|
|
|
51
51
|
type Holding = {
|
|
52
52
|
settings: Pick<Store["settings"], "get" | "putIfAbsent" | "replaceIf" | "removeIf">;
|
|
53
53
|
};
|
|
54
|
+
/** The settings key of the hold on an agent's own computer (gone with the agent's delete: agent-delete.ts). */
|
|
55
|
+
export declare const agentComputerHoldKey: (agentId: string) => string;
|
|
54
56
|
/** How long a hold that is letting go (its run detaching the computer at its end, or this server deleting it) keeps every
|
|
55
57
|
* other run off: the most a provider's detach or delete is waited on. A holder that died while letting go is taken over
|
|
56
58
|
* after it. */
|
|
@@ -55,6 +55,8 @@ export async function forgetAgentComputer(store, agentId, id) {
|
|
|
55
55
|
await store.settings.removeIf(recordKey(agentId), record);
|
|
56
56
|
}
|
|
57
57
|
const holdKey = (agentId) => `agent_computer_hold:${agentId}`;
|
|
58
|
+
/** The settings key of the hold on an agent's own computer (gone with the agent's delete: agent-delete.ts). */
|
|
59
|
+
export const agentComputerHoldKey = holdKey;
|
|
58
60
|
/** How long a hold that is letting go (its run detaching the computer at its end, or this server deleting it) keeps every
|
|
59
61
|
* other run off: the most a provider's detach or delete is waited on. A holder that died while letting go is taken over
|
|
60
62
|
* after it. */
|
|
@@ -3,6 +3,7 @@ import type { KeyEnv } from "../key-meta.js";
|
|
|
3
3
|
import type { SealedKeys } from "../store/store.js";
|
|
4
4
|
import { type ArchilDisk, type ArchilDiskOptions, type ArchilImage } from "./archil-disk.js";
|
|
5
5
|
import type { LaunchDisk } from "../run-launch.js";
|
|
6
|
+
import type { Workspace } from "./workspace.js";
|
|
6
7
|
import { type RunDisk, type RunDiskOptions } from "./run-disk.js";
|
|
7
8
|
export { ARCHIL_API_KEY_ROW, type ArchilSettings };
|
|
8
9
|
/** A claim this step refused, in words a person reads: no Archil call was made. */
|
|
@@ -68,4 +69,10 @@ export interface ArchilClaim {
|
|
|
68
69
|
release(): void;
|
|
69
70
|
}
|
|
70
71
|
/** The Archil step of a claim: its disk made, its API key opened; the run's mount credential minted when a mount asks. */
|
|
72
|
+
/** The run's folder on its disk where its runner opened it (held.ts archil), by the claim that stands for it in a run's own
|
|
73
|
+
* process: openRunWorkspace opens this Workspace for it. */
|
|
74
|
+
export declare const HELD_ARCHIL: WeakMap<object, Workspace>;
|
|
75
|
+
/** archilClaim where the run is: with the runner's seal key, its own; in a run's own process, its runner's (held.ts), as
|
|
76
|
+
* a claim that holds no key, whose revoke, inherit and release its runner makes. */
|
|
77
|
+
export declare function archilWhereHeld(options: ArchilClaimOptions): Promise<ArchilClaim>;
|
|
71
78
|
export declare function archilClaim(options: ArchilClaimOptions): Promise<ArchilClaim>;
|
|
@@ -21,6 +21,7 @@ import { archilApiKey } from "./archil-key.js";
|
|
|
21
21
|
import { archilDisk, pinnedImage } from "./archil-disk.js";
|
|
22
22
|
import { mintMountToken, nicknameOf, removeMountToken, removeOlderMountTokens, removeRunMountTokens } from "./archil-mount-credential.js";
|
|
23
23
|
import { COMPUTER_LIFETIME_MS } from "./computer-deps.js";
|
|
24
|
+
import { heldOrThrow } from "../runner/held.js";
|
|
24
25
|
import { runDiskOf } from "./run-disk.js";
|
|
25
26
|
export { ARCHIL_API_KEY_ROW };
|
|
26
27
|
/** A claim this step refused, in words a person reads: no Archil call was made. */
|
|
@@ -35,6 +36,34 @@ const RELEASED = "the run's Archil keys were released (its loop ended or its cla
|
|
|
35
36
|
/** How long a revoke waits to read the users list again for a mint it never heard of: past Archil's list lag (mint-4). */
|
|
36
37
|
const LOST_MINT_REREAD_MS = 2_000;
|
|
37
38
|
/** The Archil step of a claim: its disk made, its API key opened; the run's mount credential minted when a mount asks. */
|
|
39
|
+
/** The run's folder on its disk where its runner opened it (held.ts archil), by the claim that stands for it in a run's own
|
|
40
|
+
* process: openRunWorkspace opens this Workspace for it. */
|
|
41
|
+
export const HELD_ARCHIL = new WeakMap();
|
|
42
|
+
/** archilClaim where the run is: with the runner's seal key, its own; in a run's own process, its runner's (held.ts), as
|
|
43
|
+
* a claim that holds no key, whose revoke, inherit and release its runner makes. */
|
|
44
|
+
export async function archilWhereHeld(options) {
|
|
45
|
+
if (options.sealKey)
|
|
46
|
+
return archilClaim(options);
|
|
47
|
+
const given = await heldOrThrow("a Mode 2 run's disk").archil();
|
|
48
|
+
if (!given)
|
|
49
|
+
throw new Error("the runner opened no Archil disk for this Mode 2 run");
|
|
50
|
+
const none = (what) => {
|
|
51
|
+
throw new Error(`a Mode 2 run's ${what} is its runner's, not its own process's`);
|
|
52
|
+
};
|
|
53
|
+
const claim = {
|
|
54
|
+
get disk() { return none("disk"); },
|
|
55
|
+
get diskKind() { return none("disk"); },
|
|
56
|
+
get region() { return none("region"); },
|
|
57
|
+
get image() { return none("image"); },
|
|
58
|
+
token: async () => none("mount credential"),
|
|
59
|
+
revoke: () => given.revoke(),
|
|
60
|
+
inherit: () => void given.inherit().catch(() => undefined),
|
|
61
|
+
secrets: new Set(),
|
|
62
|
+
release: () => void given.release().catch(() => undefined),
|
|
63
|
+
};
|
|
64
|
+
HELD_ARCHIL.set(claim, given.workspace);
|
|
65
|
+
return claim;
|
|
66
|
+
}
|
|
38
67
|
export async function archilClaim(options) {
|
|
39
68
|
const { settings, sealKey } = options;
|
|
40
69
|
if (settings === undefined) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MountSpec } from "@parcha/agentrun-computer";
|
|
2
2
|
import { type ArchilDisk, type ArchilImage } from "./archil-disk.js";
|
|
3
3
|
import { type AttachableComputer, type MountCheck } from "./attach.js";
|
|
4
|
+
import type { FolderStore } from "./synced-folder.js";
|
|
4
5
|
import { type Entry, type ExecOptions, type ExecResult, type GrepOptions, type GrepResult, type Stat, type Workspace } from "./workspace.js";
|
|
5
6
|
/** The most bytes one append call takes. */
|
|
6
7
|
export declare const APPEND_MAX: number;
|
|
@@ -53,7 +54,14 @@ declare class ArchilWorkspace implements Workspace {
|
|
|
53
54
|
/** The Archil mount a computer makes of this folder: the disk, its region, the root as the folder, and the token. */
|
|
54
55
|
mountSpec(): Promise<MountSpec>;
|
|
55
56
|
attach(computer: AttachableComputer, check: MountCheck): Promise<Workspace>;
|
|
57
|
+
/** The folder as a synced folder's runner keeps it (synced-folder.ts): its files and directories through the file
|
|
58
|
+
* API, each write after this workspace's execs; its modes and links, which the file API keeps no record of, in
|
|
59
|
+
* sync.json beside it (syncMetaOf). A failed write answers in words, kind limit where the disk took too much. */
|
|
60
|
+
syncStore(): FolderStore;
|
|
56
61
|
}
|
|
62
|
+
/** Where a synced folder's modes and links are kept: beside its root, never inside it, as its spill folder is. A run's
|
|
63
|
+
* ".../runs/<run>/work" keeps them in ".../runs/<run>/sync.json"; any other root in "<root>.sync.json". */
|
|
64
|
+
export declare const syncMetaOf: (root: string) => string;
|
|
57
65
|
/** A Workspace on folder `root` of Archil disk `disk` (a relative key, e.g. agents/<agent>/runs/<run>/work). */
|
|
58
66
|
export declare const archilWorkspace: (disk: ArchilDisk, root: string, options?: ArchilWorkspaceOptions) => ArchilWorkspace;
|
|
59
67
|
export type { ArchilWorkspace };
|
package/dist/workspace/archil.js
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
// ArchilWorkspace: a Workspace on a folder of the owner's Archil disk, through the disk's file API and its serverless
|
|
2
|
+
// exec (archil-disk.ts, archil-exec.ts). Nothing is mounted on the server or a runner, and no program runs here.
|
|
3
|
+
//
|
|
4
|
+
// Keys. The workspace's root is a folder of the disk (paths.ts runKey or learningKey); every key, prefix, directory
|
|
5
|
+
// and exec mount it sends is the root or under it, or its exec spill folder beside it (spillFolderOf: a run's
|
|
6
|
+
// "exec-out"), built from paths paths.ts has checked. An exec mounts those two folders alone (each a mount's
|
|
7
|
+
// subdirectory): the rest of the owner's disk is not in its container. The spill folder holds an exec's stdin and its
|
|
8
|
+
// output while the exec runs (archil-exec.ts); the workspace's own calls are rooted at the root, so they never meet it,
|
|
9
|
+
// each exec's files are deleted on every path, and sweep() clears what a killed exec left.
|
|
10
|
+
//
|
|
11
|
+
// An exec asked to run with no network (ExecOptions.network "deny", a bash policy's shell: run-tools.ts) is sent with
|
|
12
|
+
// its egress denied (DENY_EGRESS): the container reaches the two mounted folders and nothing else. Archil refuses a
|
|
13
|
+
// network policy on a plan without one (its Free plan). Then the command runs with the network open, as the owner's
|
|
14
|
+
// plan allows, and its stderr starts with one line saying so and why, Archil's words included. The workspace remembers
|
|
15
|
+
// the refusal, so its later execs are sent without the policy and say the same.
|
|
16
|
+
//
|
|
17
|
+
// Durability. Archil commits a put, an append or a delete before it answers 200, so each call returns once the API
|
|
18
|
+
// has answered. A write is one put. The API has no rename, so there is no temporary key; that a reader sees the old
|
|
19
|
+
// file or the new one, never a mix, rests on Archil's S3 gateway publishing an object when its put completes (a
|
|
20
|
+
// multipart one, above 16 MiB, when it is assembled). It was observed live (no read during a put over an 8 MiB file
|
|
21
|
+
// saw a mix) but Archil's docs do not promise it: a known limit. An append is cut into calls of at most 1 MiB, made in
|
|
22
|
+
// order, each after any exec of this workspace; a reader during it can see part of it (the port allows that), and
|
|
23
|
+
// once it returns all of it is there. One that fails says only what is known: the bytes appended, read back from the
|
|
24
|
+
// file's size, or else the bytes acknowledged and that the failed chunk's outcome is unknown (a chunk can commit and
|
|
25
|
+
// lose its answer), so the file must be re-read before a retry.
|
|
26
|
+
//
|
|
27
|
+
// Modes, a known limit. The port says an existing file keeps its mode on a write. The file API shows no mode, so this
|
|
28
|
+
// backend cannot read one to keep it, and a put does not keep it: measured live, a 0755 file is 0644 after a put.
|
|
29
|
+
//
|
|
30
|
+
// Links, as a live run on a dev disk showed. The file API cannot make a symbolic link, but an exec can, and the API
|
|
31
|
+
// never follows one: it lists a link as a file (it cannot tell them apart, so this backend lists it as one, and the
|
|
32
|
+
// port says so), a read of it answers 501 (UNAVAILABLE here), a read through a linked folder 404, a write through one
|
|
33
|
+
// 409 "an existing object blocks the path" (EXISTS here), and nothing is listed under one. A remove takes the link
|
|
34
|
+
// itself, never what it points at, and a recursive remove never walks into one. exec refuses a link on the way to its
|
|
35
|
+
// cwd (ESCAPE).
|
|
36
|
+
//
|
|
37
|
+
// The queue. While an exec runs it holds the folder, and Archil refuses a write under it (409). So this workspace runs
|
|
38
|
+
// its execs one at a time and makes its writes wait for them; a 409 from another client's hold is tried again for up
|
|
39
|
+
// to queueMs. Reads do not wait.
|
|
40
|
+
//
|
|
41
|
+
// In a computer. mountSpec() is the Archil mount a computer makes of the root: the disk's id, its region and the root as
|
|
42
|
+
// the folder (runKey), with the disk token from the function it was made with (the claim's, archil-claim.ts). attach()
|
|
43
|
+
// goes through the shared attach path (attach.ts checkReadBack, then attachedWorkspace) with the check the claim builds:
|
|
44
|
+
// the computer module's read-back of that mount under the claim's epoch. The read-back holds no token, so attach asks
|
|
45
|
+
// for none. Once attached, the computer syncs the mount after each changing call (the attach contract), so attach adds no
|
|
46
|
+
// sync of its own. Without a region and a token function, both are refused in words. Background programs need a
|
|
47
|
+
// computer: here `process` refuses every call, cause no-computer, as with any workspace that has none.
|
|
48
|
+
//
|
|
49
|
+
// A computer that takes no Archil mount holds the root as a synced folder (synced-folder.ts): syncStore() is the root
|
|
50
|
+
// through the file API as the runner keeps it, its files and `dir/` markers, and its modes and links in sync.json beside
|
|
51
|
+
// the root (syncMetaOf), and attach() with check.sync reads back a synced folder under the claim's epoch instead.
|
|
52
|
+
import { folderPathProblem } from "@parcha/agentrun-computer";
|
|
1
53
|
import { DENY_EGRESS, pinnedImage } from "./archil-disk.js";
|
|
2
54
|
import { ArchilEgressRefused, archilExec, COMMAND_MAX_MS, DEFAULT_QUEUE_MS, MAX_EXEC_MS, spillKeys, spillName } from "./archil-exec.js";
|
|
3
55
|
import { attachedWorkspace, checkReadBack, noProcesses } from "./attach.js";
|
|
@@ -686,11 +738,121 @@ class ArchilWorkspace {
|
|
|
686
738
|
return this.#mount(await this.#mountToken());
|
|
687
739
|
}
|
|
688
740
|
async attach(computer, check) {
|
|
689
|
-
// The computer module's read-back never holds the token, so the mount is compared without one.
|
|
690
|
-
|
|
691
|
-
|
|
741
|
+
// The computer module's read-back never holds the token, so the mount is compared without one. A synced folder
|
|
742
|
+
// reads back with no source: the runner pushed this folder into it (synced-folder.ts).
|
|
743
|
+
await checkReadBack(computer, check.sync ? { kind: "sync" } : this.#mount(""), check);
|
|
744
|
+
// The computer syncs the mount after each changing call (the attach contract), and a synced folder's client lands
|
|
745
|
+
// the delta here before each answers: nothing more to make durable here.
|
|
692
746
|
return attachedWorkspace(this, computer, { synced: async () => true });
|
|
693
747
|
}
|
|
748
|
+
/** The folder as a synced folder's runner keeps it (synced-folder.ts): its files and directories through the file
|
|
749
|
+
* API, each write after this workspace's execs; its modes and links, which the file API keeps no record of, in
|
|
750
|
+
* sync.json beside it (syncMetaOf). A failed write answers in words, kind limit where the disk took too much. */
|
|
751
|
+
syncStore() {
|
|
752
|
+
const meta = syncMetaOf(this.#root);
|
|
753
|
+
const wrote = async (path, what, call) => {
|
|
754
|
+
try {
|
|
755
|
+
const rel = relativeSegments(path).join("/");
|
|
756
|
+
await this.#write(rel, () => call(this.#key(rel)));
|
|
757
|
+
return { ok: true, value: undefined };
|
|
758
|
+
}
|
|
759
|
+
catch (error) {
|
|
760
|
+
const why = failed(error, path, what);
|
|
761
|
+
return { ok: false, error: { code: why.code === "TOO_LARGE" ? "limit" : "refused", message: why.message } };
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
return {
|
|
765
|
+
put: (path, body) => wrote(path, "put", (key) => this.#disk.putObject(key, body)),
|
|
766
|
+
mkdir: (path) => wrote(path, "mkdir", (key) => this.#disk.putObject(`${key}/`, new Uint8Array(0))),
|
|
767
|
+
remove: (path, type) => wrote(path, "remove", (key) => this.#disk.deleteObject(type === "dir" ? `${key}/` : key)),
|
|
768
|
+
meta: async (folder) => {
|
|
769
|
+
try {
|
|
770
|
+
await this.#write("", () => this.#disk.putObject(meta, Buffer.from(JSON.stringify(folder))));
|
|
771
|
+
return { ok: true, value: undefined };
|
|
772
|
+
}
|
|
773
|
+
catch (error) {
|
|
774
|
+
return { ok: false, error: { code: "refused", message: `the folder's sync.json: ${describe(error)}` } };
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
entries: () => this.#syncEntries(),
|
|
778
|
+
read: async (path, size) => {
|
|
779
|
+
if (size === 0)
|
|
780
|
+
return new Uint8Array(0);
|
|
781
|
+
try {
|
|
782
|
+
const got = await this.#disk.getRange(this.#key(relativeSegments(path).join("/")), `bytes=0-${size - 1}`);
|
|
783
|
+
return got.status === 416 ? new Uint8Array(0) : got.body;
|
|
784
|
+
}
|
|
785
|
+
catch (error) {
|
|
786
|
+
throw failed(error, path, "read");
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
readMeta: async () => {
|
|
790
|
+
let got;
|
|
791
|
+
try {
|
|
792
|
+
got = await this.#disk.getRange(meta, `bytes=0-${SYNC_META_MAX - 1}`);
|
|
793
|
+
}
|
|
794
|
+
catch (error) {
|
|
795
|
+
if (statusOf(error) === 404)
|
|
796
|
+
return undefined;
|
|
797
|
+
throw failed(error, "", "the folder's sync.json: read");
|
|
798
|
+
}
|
|
799
|
+
return got.status === 416 ? undefined : folderMetaOf(got.body);
|
|
800
|
+
},
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
/** Every file and directory under the root, each once, a directory before what is in it: a key the relative-path
|
|
804
|
+
* rule refuses throws in words. */
|
|
805
|
+
async *#syncEntries() {
|
|
806
|
+
const prefix = `${this.#root}/`;
|
|
807
|
+
const seen = new Set();
|
|
808
|
+
for await (const page of this.#pages(prefix, true)) {
|
|
809
|
+
for (const [key, size] of [...page.objects.map((object) => [object.key, object.size]), ...page.commonPrefixes.map((common) => [common, 0])]) {
|
|
810
|
+
if (!key.startsWith(prefix))
|
|
811
|
+
continue;
|
|
812
|
+
const dir = key.endsWith("/");
|
|
813
|
+
const path = key.slice(prefix.length, dir ? -1 : undefined);
|
|
814
|
+
if (path === "")
|
|
815
|
+
continue;
|
|
816
|
+
const problem = folderPathProblem(path);
|
|
817
|
+
if (problem !== undefined)
|
|
818
|
+
throw new WorkspaceError("REFUSED", `the run's folder on the disk holds ${JSON.stringify(path)}, which ${problem}, so it can't be synced: rename or remove it`, { path });
|
|
819
|
+
const parts = path.split("/");
|
|
820
|
+
for (let cut = 1; cut < parts.length; cut++) {
|
|
821
|
+
const up = parts.slice(0, cut).join("/");
|
|
822
|
+
if (seen.has(up))
|
|
823
|
+
continue;
|
|
824
|
+
seen.add(up);
|
|
825
|
+
yield { path: up, type: "dir", size: 0 };
|
|
826
|
+
}
|
|
827
|
+
if (seen.has(path))
|
|
828
|
+
continue;
|
|
829
|
+
seen.add(path);
|
|
830
|
+
yield { path, type: dir ? "dir" : "file", size: dir ? 0 : size };
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
/** The most bytes a folder's sync.json is read of. */
|
|
836
|
+
const SYNC_META_MAX = 32 * 1024 * 1024;
|
|
837
|
+
/** Where a synced folder's modes and links are kept: beside its root, never inside it, as its spill folder is. A run's
|
|
838
|
+
* ".../runs/<run>/work" keeps them in ".../runs/<run>/sync.json"; any other root in "<root>.sync.json". */
|
|
839
|
+
export const syncMetaOf = (root) => (root.endsWith("/work") ? `${root.slice(0, -"/work".length)}/sync.json` : `${root}.sync.json`);
|
|
840
|
+
/** sync.json's bytes as a FolderMeta: each mode a whole permission number, each link's target text; anything else in it
|
|
841
|
+
* is left out. Bytes that are no JSON object throw in words. */
|
|
842
|
+
function folderMetaOf(bytes) {
|
|
843
|
+
let read;
|
|
844
|
+
try {
|
|
845
|
+
read = JSON.parse(Buffer.from(bytes).toString("utf8"));
|
|
846
|
+
}
|
|
847
|
+
catch (error) {
|
|
848
|
+
throw new WorkspaceError("UNAVAILABLE", `the folder's sync.json is not JSON: ${describe(error)}`);
|
|
849
|
+
}
|
|
850
|
+
const record = (value) => (typeof value === "object" && value !== null && !Array.isArray(value) ? value : {});
|
|
851
|
+
const { modes, links } = record(read);
|
|
852
|
+
return {
|
|
853
|
+
modes: Object.fromEntries(Object.entries(record(modes)).filter((pair) => Number.isInteger(pair[1]) && pair[1] >= 0 && pair[1] <= 0o7777)),
|
|
854
|
+
links: Object.fromEntries(Object.entries(record(links)).filter((pair) => typeof pair[1] === "string" && !pair[1].includes("\0"))),
|
|
855
|
+
};
|
|
694
856
|
}
|
|
695
857
|
/** A Workspace on folder `root` of Archil disk `disk` (a relative key, e.g. agents/<agent>/runs/<run>/work). */
|
|
696
858
|
export const archilWorkspace = (disk, root, options) => new ArchilWorkspace(disk, root, options);
|
|
@@ -2,10 +2,12 @@ import type { ComputerClient, Empty, MountReadBack, MountSpec, ProcessExit, Proc
|
|
|
2
2
|
import { type Workspace } from "./workspace.js";
|
|
3
3
|
/** What attach runs of D, passed in (the cutover passes D's own): the read-back a mount made as `spec` asks gives, and
|
|
4
4
|
* the claim's epoch it is read back under (D reads an Archil mount back with the computer's claim epoch; a bind takes
|
|
5
|
-
* none).
|
|
5
|
+
* none). `sync`: the claim made the computer a synced folder of the Workspace (resolve-computer.ts), so it reads back
|
|
6
|
+
* as one, under the epoch. */
|
|
6
7
|
export type MountCheck = {
|
|
7
8
|
readonly readBackOf: (spec: MountSpec, epoch?: number) => MountReadBack;
|
|
8
9
|
readonly epoch?: number;
|
|
10
|
+
readonly sync?: true;
|
|
9
11
|
};
|
|
10
12
|
/** A computer as attach takes it: its ref, its computerd client, and D's read-back of what it mounts at /workspace. */
|
|
11
13
|
export interface AttachableComputer {
|
package/dist/workspace/attach.js
CHANGED
|
@@ -422,6 +422,8 @@ const shown = (back) => {
|
|
|
422
422
|
return back.other;
|
|
423
423
|
if (back.kind === "bind")
|
|
424
424
|
return `a bind of ${back.path}`;
|
|
425
|
+
if (back.kind === "sync")
|
|
426
|
+
return `a synced folder under epoch ${back.epoch}`;
|
|
425
427
|
const { exclusive, epoch } = held(back);
|
|
426
428
|
const hold = exclusive === undefined ? "" : exclusive === true ? ", exclusive" : ", not exclusive";
|
|
427
429
|
return `${back.disk}:/${back.folder} in ${back.region}${hold}${epoch === undefined ? "" : ` under epoch ${String(epoch)}`}`;
|
|
@@ -6,8 +6,18 @@ import type { ComputerSettingKind, KindRegistry, ProviderEntry } from "./resolve
|
|
|
6
6
|
export declare const PAIRED_ID_PREFIX = "cmp-";
|
|
7
7
|
/** The image a paired computer's spec names: none is made, so this only says what it is. */
|
|
8
8
|
export declare const ATTACHED_IMAGE = "attached";
|
|
9
|
+
/** How to start a server so its runs can use a paired computer, in one line: the same words wherever it is said. */
|
|
10
|
+
export declare const ONE_PROCESS_FIX = "start the image with the server options alone, without server-and-runner (outside the image: agentrun-serve without --no-runner)";
|
|
9
11
|
/** The words a run gets when its agent's computer is a paired computer and its runner is not in the server's process. */
|
|
10
|
-
export declare const ONE_PROCESS_WORDS = "a paired computer's socket is held by the
|
|
12
|
+
export declare const ONE_PROCESS_WORDS = "a paired computer's socket is held by the server process it dialed, and this runner runs in a process of its own: start the image with the server options alone, without server-and-runner (outside the image: agentrun-serve without --no-runner)";
|
|
13
|
+
/** What a pairing code, the pair answer and each paired computer say on a server whose runner runs in a process of its
|
|
14
|
+
* own (--no-runner; the image's server-and-runner): the computer pairs, and no run here can use it. */
|
|
15
|
+
export declare const RUNNER_APART_WORDS = "no run on this server can use a paired computer: its runner runs in a process of its own, and the computer's socket is held by the server's: start the image with the server options alone, without server-and-runner (outside the image: agentrun-serve without --no-runner)";
|
|
16
|
+
/** What a provider whose machines dial this server (the computer package's connectOf "dial": Fly Machines, Cloudflare,
|
|
17
|
+
* and E2B, Daytona or Modal set to dial) says on such a server: its row in GET /v2/computers and its test. Its
|
|
18
|
+
* machines' sockets are taken by the server's attach hub, and a runner of its own process has none, so its create
|
|
19
|
+
* refuses (the computer package's hosted/provider.ts, naming the same fix). */
|
|
20
|
+
export declare const dialApartWords: (label: string) => string;
|
|
11
21
|
/** What the claim reads of the paired computers: the store's rows (removed ones left out), and the server's hub where
|
|
12
22
|
* the runner shares its process (absent: a runner of its own process). */
|
|
13
23
|
export interface AttachedComputers {
|
|
@@ -25,13 +35,14 @@ export declare function helloLacks(hello: Partial<HelloResult>, kind: ComputerSe
|
|
|
25
35
|
* words that say what it lacks and to update the driver. Undefined when it serves one. */
|
|
26
36
|
export declare function servesNoKind(name: string, hello: Partial<HelloResult>): string | undefined;
|
|
27
37
|
/** A paired computer as a provider of `registry`: named by its name and its os, as an agent's computer picker lists it;
|
|
28
|
-
* the setting kinds its paired hello serves, no keys,
|
|
29
|
-
*
|
|
38
|
+
* the setting kinds its paired hello serves, no keys, the machine's own network ("open": a run never narrows a person's
|
|
39
|
+
* own machine), never metered. A sandbox (a Linux box with files and exec) takes the run's folder as a synced folder
|
|
40
|
+
* (the computer package's attachedProvider checks its /workspace); a desktop or a phone takes no mount. */
|
|
30
41
|
export declare function pairedEntry(row: PairedComputerRow, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals">): ProviderEntry;
|
|
31
42
|
/** `registry` with each paired computer of `rows` as one more provider (pairedEntry), and the words for one that cannot
|
|
32
43
|
* serve a kind an agent asks of it: it is a computer of the person's own, and either the attach path carries no such
|
|
33
|
-
* kind (ATTACH_CANNOT: a
|
|
34
|
-
* kind it serves, or its driver lacks what the kind needs (helloLacks), so the driver is what to update. */
|
|
44
|
+
* kind (ATTACH_CANNOT: a browser), or it is a desktop or a phone asked to be a sandbox (PAIRED_SANDBOX), so the agent
|
|
45
|
+
* takes it as the kind it serves, or its driver lacks what the kind needs (helloLacks), so the driver is what to update. */
|
|
35
46
|
export declare function withPaired<R extends KindRegistry>(registry: R, rows: readonly PairedComputerRow[]): R;
|
|
36
47
|
/** The provider of the paired computer `row`: attachedProvider over the hub, or a refusal in ONE_PROCESS_WORDS where this
|
|
37
48
|
* process holds no hub. */
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// configuration is the kind and groups it paired as. An agent's computer setting names it as its provider, {kind:
|
|
4
4
|
// "desktop", provider: "cmp-..."}, so a run resolves, checks and claims it on the one path every computer takes
|
|
5
5
|
// (resolve-computer.ts, computer-for-claim.ts), and the computer package's attachedProvider stands in for a vendor's.
|
|
6
|
+
// A Linux box with no display (computerd's hello says linux, with files and exec) is a sandbox: in Mode 2 it holds the
|
|
7
|
+
// run's folder as a synced folder in its own /workspace, as a hosted computer that dials does.
|
|
6
8
|
//
|
|
7
9
|
// Its socket is held by the AttachHub of the server's process: a runner in that process (the CLI's start, its runner
|
|
8
10
|
// beside the server) takes it; a runner of its own process cannot reach it and refuses it in ONE_PROCESS_WORDS.
|
|
@@ -12,8 +14,18 @@ import { attachedProvider, SETTING_KIND_NAMES, SETTING_KINDS } from "@parcha/age
|
|
|
12
14
|
export const PAIRED_ID_PREFIX = "cmp-";
|
|
13
15
|
/** The image a paired computer's spec names: none is made, so this only says what it is. */
|
|
14
16
|
export const ATTACHED_IMAGE = "attached";
|
|
17
|
+
/** How to start a server so its runs can use a paired computer, in one line: the same words wherever it is said. */
|
|
18
|
+
export const ONE_PROCESS_FIX = "start the image with the server options alone, without server-and-runner (outside the image: agentrun-serve without --no-runner)";
|
|
15
19
|
/** The words a run gets when its agent's computer is a paired computer and its runner is not in the server's process. */
|
|
16
|
-
export const ONE_PROCESS_WORDS =
|
|
20
|
+
export const ONE_PROCESS_WORDS = `a paired computer's socket is held by the server process it dialed, and this runner runs in a process of its own: ${ONE_PROCESS_FIX}`;
|
|
21
|
+
/** What a pairing code, the pair answer and each paired computer say on a server whose runner runs in a process of its
|
|
22
|
+
* own (--no-runner; the image's server-and-runner): the computer pairs, and no run here can use it. */
|
|
23
|
+
export const RUNNER_APART_WORDS = `no run on this server can use a paired computer: its runner runs in a process of its own, and the computer's socket is held by the server's: ${ONE_PROCESS_FIX}`;
|
|
24
|
+
/** What a provider whose machines dial this server (the computer package's connectOf "dial": Fly Machines, Cloudflare,
|
|
25
|
+
* and E2B, Daytona or Modal set to dial) says on such a server: its row in GET /v2/computers and its test. Its
|
|
26
|
+
* machines' sockets are taken by the server's attach hub, and a runner of its own process has none, so its create
|
|
27
|
+
* refuses (the computer package's hosted/provider.ts, naming the same fix). */
|
|
28
|
+
export const dialApartWords = (label) => `no run on this server can use ${label}: its machines dial this server, and its runner runs in a process of its own, with no attach hub to take their socket: ${ONE_PROCESS_FIX}`;
|
|
17
29
|
/** The store's row as the hub and attachedProvider take it. */
|
|
18
30
|
export const pairedOf = (row) => ({
|
|
19
31
|
id: row.id,
|
|
@@ -22,13 +34,13 @@ export const pairedOf = (row) => ({
|
|
|
22
34
|
labels: { ...row.labels },
|
|
23
35
|
});
|
|
24
36
|
/** The setting kinds the attach path cannot serve, with why and what to pair instead: a browser session needs a CDP
|
|
25
|
-
* connection, which the attach socket does not carry,
|
|
26
|
-
* computer has no mount for (resolve-computer.ts refuses a sandbox without one). Kind-based, never by OS: a driver whose hello serves one of
|
|
37
|
+
* connection, which the attach socket does not carry. Kind-based, never by OS: a driver whose hello serves one of
|
|
27
38
|
* these and no other kind is refused at pairing, and a paired row of one serves nothing. */
|
|
28
39
|
const ATTACH_CANNOT = {
|
|
29
40
|
browser: "a paired computer can't serve browser sessions yet, so pair a desktop or phone driver",
|
|
30
|
-
sandbox: "a paired computer can't mount a run's folder yet, so no agent could run a sandbox on it: pair a desktop or phone driver",
|
|
31
41
|
};
|
|
42
|
+
/** Which paired computer is a sandbox: a Linux box's computerd, its hello kind linux (no display), with files and exec. */
|
|
43
|
+
const PAIRED_SANDBOX = "only a Linux box paired with computerd and no display can be a sandbox computer";
|
|
32
44
|
/** What a driver's hello lacks to serve `kind`, by the kind registry's rule (the computer package's SETTING_KINDS, which
|
|
33
45
|
* servingRefusals reads): "it says desktop but declares no input.pointer, input.keys", "it says android, which no
|
|
34
46
|
* desktop computer is"; undefined when the hello serves the kind. The one source of a paired computer's words for a
|
|
@@ -58,8 +70,9 @@ export function servesNoKind(name, hello) {
|
|
|
58
70
|
return `${name}'s driver serves no kind: ${lack}: update the driver on ${name}`;
|
|
59
71
|
}
|
|
60
72
|
/** A paired computer as a provider of `registry`: named by its name and its os, as an agent's computer picker lists it;
|
|
61
|
-
* the setting kinds its paired hello serves, no keys,
|
|
62
|
-
*
|
|
73
|
+
* the setting kinds its paired hello serves, no keys, the machine's own network ("open": a run never narrows a person's
|
|
74
|
+
* own machine), never metered. A sandbox (a Linux box with files and exec) takes the run's folder as a synced folder
|
|
75
|
+
* (the computer package's attachedProvider checks its /workspace); a desktop or a phone takes no mount. */
|
|
63
76
|
export function pairedEntry(row, registry) {
|
|
64
77
|
const hello = row.hello;
|
|
65
78
|
const configuration = { kind: String(hello.kind ?? ""), groups: Array.isArray(hello.groups) ? [...hello.groups] : [] };
|
|
@@ -69,7 +82,7 @@ export function pairedEntry(row, registry) {
|
|
|
69
82
|
label: typeof hello.os === "string" ? `${row.name} (${hello.os})` : row.name,
|
|
70
83
|
kinds,
|
|
71
84
|
keys: [],
|
|
72
|
-
mounts: [],
|
|
85
|
+
mounts: kinds.includes("sandbox") ? ["sync"] : [],
|
|
73
86
|
network: ["open"],
|
|
74
87
|
metered: false,
|
|
75
88
|
capabilities: [configuration],
|
|
@@ -78,8 +91,8 @@ export function pairedEntry(row, registry) {
|
|
|
78
91
|
}
|
|
79
92
|
/** `registry` with each paired computer of `rows` as one more provider (pairedEntry), and the words for one that cannot
|
|
80
93
|
* serve a kind an agent asks of it: it is a computer of the person's own, and either the attach path carries no such
|
|
81
|
-
* kind (ATTACH_CANNOT: a
|
|
82
|
-
* kind it serves, or its driver lacks what the kind needs (helloLacks), so the driver is what to update. */
|
|
94
|
+
* kind (ATTACH_CANNOT: a browser), or it is a desktop or a phone asked to be a sandbox (PAIRED_SANDBOX), so the agent
|
|
95
|
+
* takes it as the kind it serves, or its driver lacks what the kind needs (helloLacks), so the driver is what to update. */
|
|
83
96
|
export function withPaired(registry, rows) {
|
|
84
97
|
if (rows.length === 0)
|
|
85
98
|
return registry;
|
|
@@ -89,6 +102,9 @@ export function withPaired(registry, rows) {
|
|
|
89
102
|
if (row !== undefined && kind in ATTACH_CANNOT && entry.kinds.length > 0) {
|
|
90
103
|
return `${row.name} is a computer of your own, and a paired computer can't be a ${kind} computer yet: give this agent ${row.name} as a ${entry.kinds.join(" or ")} computer`;
|
|
91
104
|
}
|
|
105
|
+
if (row !== undefined && kind === "sandbox" && entry.kinds.length > 0) {
|
|
106
|
+
return `${row.name} is a computer of your own, and ${PAIRED_SANDBOX}: give this agent ${row.name} as a ${entry.kinds.join(" or ")} computer`;
|
|
107
|
+
}
|
|
92
108
|
const lack = row === undefined ? undefined : helloLacks(row.hello, kind);
|
|
93
109
|
if (row === undefined || lack === undefined)
|
|
94
110
|
return registry.unservedWhy?.(entry, kind);
|
|
@@ -314,7 +314,7 @@ export function computerDepsFrom(options) {
|
|
|
314
314
|
// made as without it.
|
|
315
315
|
...(faux ? {
|
|
316
316
|
keyTable: { keys: { ...KEY_TABLE.keys, ...faux.keyTable.keys }, labels: { ...KEY_TABLE.labels, ...faux.keyTable.labels } },
|
|
317
|
-
launch: (entry, spec) => faux.launch(entry, spec),
|
|
317
|
+
launch: (entry, spec) => faux.launch(entry, spec, options.dial ? { dial: options.dial } : {}),
|
|
318
318
|
launches: (provider) => faux.owns(provider),
|
|
319
319
|
} : {}),
|
|
320
320
|
...(options.answers ? { answers: options.answers } : {}),
|
|
@@ -104,8 +104,11 @@ export interface ComputerForClaimDeps {
|
|
|
104
104
|
/** Its daemon's answer (docker-daemon.ts), asked when a launch on such a provider fails (ClaimSide.daemon). */
|
|
105
105
|
readonly daemon?: ClaimSide["daemon"];
|
|
106
106
|
/** A launch of the server's own in place of the providers' (--faux's desktop), for the providers `launches` takes (by
|
|
107
|
-
* id; absent, every one): any other is made by its provider, as with no launch.
|
|
108
|
-
|
|
107
|
+
* id; absent, every one): any other is made by its provider, as with no launch. Given the claim's run (`run`), as a
|
|
108
|
+
* provider's create is given it in its labels. */
|
|
109
|
+
readonly launch?: (entry: ProviderEntry, spec: Parameters<ClaimSide["launch"]>[1] & {
|
|
110
|
+
readonly run?: string;
|
|
111
|
+
}) => ReturnType<ClaimSide["launch"]>;
|
|
109
112
|
readonly launches?: (provider: string) => boolean;
|
|
110
113
|
/** The run's folder (mounted only where the provider mounts it) and the mount check attach runs. */
|
|
111
114
|
readonly workspace: Workspace;
|
|
@@ -192,7 +195,8 @@ export interface ClaimComputer {
|
|
|
192
195
|
/** The claim's release at the run's park, for `cause`: a computer it `keeps` is kept for KEEP_MS (computer-kept.ts),
|
|
193
196
|
* its live view closed with the park's cause and the keep's time (ParkedEnd) and its hold ended, but the machine left
|
|
194
197
|
* running and its mount credential left in place, and true is answered; any other is released as `release` does, and
|
|
195
|
-
* false.
|
|
198
|
+
* false. A synced folder's delta lands first: one that does not keeps nothing, and the park throws as `release` does.
|
|
199
|
+
* Idempotent with `release`. */
|
|
196
200
|
park?(cause: ParkCause): Promise<boolean>;
|
|
197
201
|
}
|
|
198
202
|
/** The kinds of computer a claim makes the run fresh. */
|