@parcha/agentrun-serve 0.1.0-beta.45 → 0.1.0-beta.47
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 +180 -0
- package/NOTICE +4 -0
- package/README.md +283 -47
- package/dist/acp-package.d.ts +35 -6
- package/dist/acp-package.js +3 -3
- package/dist/adapter-facts.d.ts +5 -2
- package/dist/adapter-facts.js +6 -3
- package/dist/adapters.d.ts +7 -0
- package/dist/adapters.js +39 -0
- package/dist/agents-store.d.ts +5 -3
- package/dist/agents-store.js +13 -8
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +7 -10
- package/dist/archil-routes.js +2 -1
- package/dist/cap.js +12 -2
- package/dist/chatgpt-plan.js +2 -1
- package/dist/cli.js +119 -44
- package/dist/composio-made.d.ts +19 -2
- package/dist/composio-made.js +17 -5
- package/dist/composio-preset.d.ts +42 -7
- package/dist/composio-preset.js +106 -70
- package/dist/composio-triggers.d.ts +9 -4
- package/dist/composio-triggers.js +20 -13
- package/dist/computer-attach.d.ts +11 -10
- package/dist/computer-attach.js +13 -14
- package/dist/computer-commands.d.ts +3 -0
- package/dist/computer-commands.js +3 -2
- package/dist/computer-lost.d.ts +4 -0
- package/dist/computer-lost.js +8 -3
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +2 -0
- package/dist/computers.d.ts +9 -75
- package/dist/computers.js +20 -66
- package/dist/console/assets/index-BBFzAxLB.js +715 -0
- package/dist/console/assets/index-BRi-Rgq6.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/cost-heal.d.ts +13 -0
- package/dist/cost-heal.js +27 -0
- package/dist/dial-relay.d.ts +6 -2
- package/dist/dial-relay.js +9 -12
- package/dist/email/routes.js +2 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -0
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/faux-computers.d.ts +2 -3
- package/dist/faux-computers.js +9 -31
- package/dist/github-connection.js +2 -1
- package/dist/harness-archive.d.ts +19 -2
- package/dist/harness-archive.js +49 -15
- package/dist/harness-check.d.ts +73 -0
- package/dist/harness-check.js +489 -0
- package/dist/harness-cursor.d.ts +45 -0
- package/dist/harness-cursor.js +121 -0
- package/dist/harness-recipe.d.ts +127 -0
- package/dist/harness-recipe.js +357 -0
- package/dist/harness-table.d.ts +12 -0
- package/dist/harness-table.js +62 -2
- package/dist/harness.d.ts +2 -0
- package/dist/harness.js +3 -2
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +14 -0
- package/dist/host.d.ts +10 -3
- package/dist/host.js +17 -3
- package/dist/import-sources.d.ts +2 -0
- package/dist/import-sources.js +2 -0
- package/dist/import-summary.d.ts +15 -5
- package/dist/import-summary.js +24 -8
- package/dist/import.d.ts +34 -4
- package/dist/import.js +134 -32
- package/dist/key-refusal.d.ts +1 -0
- package/dist/key-refusal.js +8 -3
- package/dist/key-words.d.ts +1 -1
- package/dist/key-words.js +4 -4
- package/dist/learn/check.d.ts +3 -0
- package/dist/learn/check.js +31 -20
- package/dist/learn/compile.js +11 -4
- package/dist/learn/promote.d.ts +77 -4
- package/dist/learn/promote.js +123 -2
- package/dist/learned-nodes.d.ts +4 -3
- package/dist/learned-workflow.js +4 -1
- package/dist/learning-cost.d.ts +6 -16
- package/dist/learning-cost.js +6 -12
- package/dist/learning-setting.d.ts +17 -6
- package/dist/learning-setting.js +41 -5
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +1 -1
- package/dist/listen-first.d.ts +10 -0
- package/dist/listen-first.js +25 -1
- package/dist/llms.txt +1 -1
- package/dist/mcp-gateway.d.ts +2 -1
- package/dist/mcp-gateway.js +31 -15
- package/dist/mcp-probe.d.ts +18 -6
- package/dist/mcp-probe.js +41 -8
- package/dist/mcp-secret-writes.d.ts +8 -0
- package/dist/mcp-secret-writes.js +104 -4
- package/dist/mcp-servers-store.d.ts +11 -5
- package/dist/mcp-servers-store.js +46 -20
- package/dist/model-form.d.ts +2 -1
- package/dist/model-form.js +22 -8
- package/dist/model-gateway.d.ts +113 -0
- package/dist/model-gateway.js +433 -0
- package/dist/model.d.ts +2 -1
- package/dist/model.js +9 -7
- package/dist/monid.js +1 -1
- package/dist/native/binding.d.ts +4 -0
- package/dist/native/binding.js +9 -0
- package/dist/native/cli.d.ts +3 -2
- package/dist/native/cli.js +6 -5
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +326 -41
- package/dist/owner.d.ts +4 -2
- package/dist/owner.js +10 -4
- package/dist/page.d.ts +8 -0
- package/dist/page.js +9 -1
- package/dist/port-models.js +17 -10
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +12 -3
- package/dist/public-address.d.ts +28 -0
- package/dist/public-address.js +62 -0
- package/dist/run-launch.d.ts +1 -1
- package/dist/run-launch.js +1 -1
- package/dist/run-secrets.d.ts +3 -2
- package/dist/run-secrets.js +6 -4
- package/dist/runner/adapter-loop.d.ts +10 -7
- package/dist/runner/adapter-loop.js +57 -22
- package/dist/runner/adapter-run-spec.d.ts +12 -0
- package/dist/runner/adapter-run-spec.js +40 -6
- package/dist/runner/adapters/index.js +16 -0
- package/dist/runner/adapters/pi.d.ts +5 -2
- package/dist/runner/adapters/pi.js +7 -4
- package/dist/runner/audit.d.ts +7 -0
- package/dist/runner/audit.js +24 -6
- package/dist/runner/claim-secrets.js +5 -1
- package/dist/runner/cli-run-spec.js +15 -7
- package/dist/runner/compare-end.d.ts +43 -0
- package/dist/runner/compare-end.js +95 -0
- package/dist/runner/computer-journal.d.ts +3 -0
- package/dist/runner/computer-journal.js +22 -2
- package/dist/runner/conformance/harness.js +19 -8
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +94 -54
- package/dist/runner/held.d.ts +5 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +3 -0
- package/dist/runner/loop-contract.d.ts +10 -0
- package/dist/runner/main.d.ts +5 -5
- package/dist/runner/main.js +81 -11
- package/dist/runner/mcp-claim.js +40 -12
- package/dist/runner/metrics.d.ts +26 -0
- package/dist/runner/metrics.js +44 -1
- package/dist/runner/presence.d.ts +41 -0
- package/dist/runner/presence.js +89 -0
- package/dist/runner/promotion.d.ts +10 -3
- package/dist/runner/promotion.js +42 -21
- package/dist/runner/run-child-host.js +52 -14
- package/dist/runner/runner.d.ts +5 -0
- package/dist/runner/runner.js +8 -0
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +19 -7
- package/dist/runner/workflow-first.d.ts +5 -2
- package/dist/runner/workflow-first.js +6 -3
- package/dist/runs-over-store.d.ts +6 -2
- package/dist/runs-over-store.js +14 -4
- package/dist/sdk/runs.d.ts +1 -1
- package/dist/sdk/runs.js +6 -1
- package/dist/sdk/schema.js +1 -1
- package/dist/secret-writes.d.ts +16 -3
- package/dist/secret-writes.js +28 -3
- package/dist/server-secrets-store.js +5 -0
- package/dist/server.d.ts +31 -2
- package/dist/server.js +326 -53
- package/dist/sign-ins-secrets.js +4 -1
- package/dist/skills/agentrun-serve/SKILL.md +11 -0
- package/dist/slack-url.d.ts +5 -0
- package/dist/slack-url.js +11 -0
- package/dist/slack.d.ts +107 -0
- package/dist/slack.js +292 -0
- package/dist/start-switches.d.ts +28 -0
- package/dist/start-switches.js +37 -0
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +2 -1
- package/dist/stop-signals.d.ts +11 -0
- package/dist/stop-signals.js +22 -0
- package/dist/store/agent-body.d.ts +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrations/0020_runners.sql +18 -0
- package/dist/store/postgres/store.d.ts +1 -1
- package/dist/store/postgres/store.js +4 -2
- package/dist/store/schema.d.ts +13 -5
- package/dist/store/schema.js +20 -11
- package/dist/store/seal.d.ts +16 -4
- package/dist/store/sqlite/store.d.ts +1 -1
- package/dist/store/sqlite/store.js +106 -27
- package/dist/store/store.d.ts +75 -23
- package/dist/store/store.js +11 -0
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +7 -0
- package/dist/store-reads/cap.js +11 -1
- package/dist/store-reads/journal.js +27 -1
- package/dist/store-reads/learning.d.ts +23 -2
- package/dist/store-reads/learning.js +29 -8
- package/dist/store-reads/runs.d.ts +9 -0
- package/dist/store-reads/runs.js +19 -6
- package/dist/store-reads/stats.d.ts +4 -1
- package/dist/store-reads/stats.js +15 -6
- package/dist/store-view.d.ts +123 -14
- package/dist/store-view.js +154 -21
- package/dist/telemetry.d.ts +7 -7
- package/dist/telemetry.js +38 -15
- package/dist/templates.d.ts +6 -3
- package/dist/templates.js +38 -3
- package/dist/timeline/timeline.js +18 -0
- package/dist/tool-keys-store.js +2 -2
- package/dist/tool-keys.js +2 -1
- package/dist/tool-plane.js +2 -2
- package/dist/trigger-adapter.d.ts +3 -4
- package/dist/trigger-adapter.js +2 -2
- package/dist/trigger-composio.js +3 -3
- package/dist/trigger-email.js +0 -2
- package/dist/trigger-feed.js +0 -2
- package/dist/trigger-schedule.js +3 -0
- package/dist/trigger-secrets-shown.d.ts +6 -3
- package/dist/trigger-secrets-shown.js +22 -13
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +19 -8
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +2 -1
- package/dist/webhooks.d.ts +85 -9
- package/dist/webhooks.js +129 -46
- package/dist/wires.d.ts +6 -1
- package/dist/wires.js +5 -0
- package/dist/workspace/attach.d.ts +3 -2
- package/dist/workspace/attach.js +2 -1
- package/dist/workspace/attached-computers.d.ts +6 -8
- package/dist/workspace/attached-computers.js +27 -24
- package/dist/workspace/computer-deps.d.ts +2 -3
- package/dist/workspace/computer-deps.js +3 -6
- package/dist/workspace/computer-for-claim.js +72 -96
- package/dist/workspace/computer-kept.d.ts +0 -7
- package/dist/workspace/computer-kept.js +0 -17
- package/dist/workspace/resolve-computer.d.ts +18 -14
- package/dist/workspace/resolve-computer.js +47 -60
- package/dist/workspace/synced-folder.d.ts +20 -15
- package/dist/workspace/synced-folder.js +33 -43
- package/launcher/agentrun-serve +4 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +11 -0
- package/templates/README.md +1 -1
- package/templates/inbound-lead/agent.md +2 -1
- package/templates/kyb/agent.md +2 -1
- package/dist/console/assets/index-3O2Yl6hZ.js +0 -701
- package/dist/console/assets/index-DaFsZuzQ.css +0 -1
package/dist/computers.d.ts
CHANGED
|
@@ -1,72 +1,11 @@
|
|
|
1
|
-
import { type ComputerProvider, type GpuCapability } from "@parcha/agentrun-computer";
|
|
2
|
-
import { type KeyChoice, type KeyTable, type
|
|
3
|
-
import { type ComputerKind
|
|
1
|
+
import { type ComputerProvider, type GpuCapability, type HostCommand, type ProviderEntry } from "@parcha/agentrun-computer";
|
|
2
|
+
import { type KeyChoice, type KeyTable, type ProviderFactories, type ProviderSettings } from "./computer-keys.js";
|
|
3
|
+
import { type ComputerKind } from "./computer-setting.js";
|
|
4
4
|
import { type DockerDaemon } from "./docker-daemon.js";
|
|
5
5
|
import { type KeyEnv, type KeyMeta } from "./key-meta.js";
|
|
6
6
|
import type { PairedComputerRow, Store } from "./store/index.js";
|
|
7
7
|
import type { PairedView } from "./computer-attach.js";
|
|
8
|
-
import { type ComputerSettingKind, type ShellPlace } from "./workspace/resolve-computer.js";
|
|
9
|
-
/** A setting kind as the kind registry's SETTING_KINDS gives it. */
|
|
10
|
-
export interface SettingKindSpec {
|
|
11
|
-
readonly machineKinds: readonly string[];
|
|
12
|
-
readonly required: readonly string[];
|
|
13
|
-
readonly optional: readonly string[];
|
|
14
|
-
}
|
|
15
|
-
/** A provider configuration's machine kind and groups, the GPUs it gives where it declares them, whether it keeps an
|
|
16
|
-
* agent's own computer between runs (persistence), and the image a setting selects it by, where it names one, as the
|
|
17
|
-
* kind registry gives them. */
|
|
18
|
-
export type KindCapabilities = {
|
|
19
|
-
readonly kind: string;
|
|
20
|
-
readonly groups: readonly string[];
|
|
21
|
-
readonly gpu?: GpuCapability;
|
|
22
|
-
readonly persistence?: unknown;
|
|
23
|
-
readonly image?: string;
|
|
24
|
-
readonly options?: Readonly<Record<string, unknown>>;
|
|
25
|
-
};
|
|
26
|
-
/** A provider as the kind registry's PROVIDERS gives it. */
|
|
27
|
-
export interface ProviderEntry {
|
|
28
|
-
readonly id: string;
|
|
29
|
-
readonly label: string;
|
|
30
|
-
/** Whether its machines dial this server, as its descriptor declares it (the computer package's connectOf reads it
|
|
31
|
-
* with its settings' connect). Absent: they never do. */
|
|
32
|
-
readonly connect?: "dial" | "either";
|
|
33
|
-
readonly kinds: readonly ComputerKind[];
|
|
34
|
-
readonly keys: readonly {
|
|
35
|
-
readonly name: string;
|
|
36
|
-
readonly required: boolean;
|
|
37
|
-
readonly picked?: boolean;
|
|
38
|
-
}[];
|
|
39
|
-
/** The mounts its computers take; none means it cannot mount the run's folder. */
|
|
40
|
-
readonly mounts: readonly string[];
|
|
41
|
-
/** Why its computers take none of these mounts, each in one sentence (Daytona's archil), as its descriptor says. */
|
|
42
|
-
readonly unmounted?: Readonly<Partial<Record<string, string>>>;
|
|
43
|
-
/** Mounts its computers take only where the operator sets the key named, by mount (Daytona's archil, with
|
|
44
|
-
* DAYTONA_ARCHIL_EGRESS), as its descriptor says: resolve-computer.ts entryHere reads it with the keys set here. */
|
|
45
|
-
readonly mountsWith?: Readonly<Partial<Record<string, string>>>;
|
|
46
|
-
/** The server's environment variable that names the image every computer of it starts from (Daytona's
|
|
47
|
-
* AGENTRUN_DAYTONA_SNAPSHOT), as its descriptor says: set, the operator names its image here (entryHere). */
|
|
48
|
-
readonly imageEnv?: string;
|
|
49
|
-
/** Set by entryHere alone: its imageEnv has a value here. */
|
|
50
|
-
readonly imageNamed?: true;
|
|
51
|
-
/** The network forms its computers make ("none", "open", "allow"), as its descriptor declares them. Absent (a
|
|
52
|
-
* test's fixture): nothing is said of its network. */
|
|
53
|
-
readonly network?: readonly string[];
|
|
54
|
-
readonly metered: boolean;
|
|
55
|
-
readonly capabilities: readonly KindCapabilities[];
|
|
56
|
-
/** The image a computer of each kind starts from when its setting names none. */
|
|
57
|
-
readonly defaultImage?: Partial<Record<ComputerKind, string>>;
|
|
58
|
-
/** Its provider makes its image ready before the first create (its descriptor's prepareImage). */
|
|
59
|
-
readonly prepareImage?: boolean;
|
|
60
|
-
/** A program its computers need on this machine's PATH, what installs it, and the machines it is built for
|
|
61
|
-
* (`${platform}-${arch}`; absent, every one), as its descriptor declares it: the phone's adb. Absent: none. */
|
|
62
|
-
readonly hostCommand?: HostCommand;
|
|
63
|
-
}
|
|
64
|
-
/** A provider's host command, as the kind registry's entry names it. */
|
|
65
|
-
export type HostCommand = {
|
|
66
|
-
readonly command: string;
|
|
67
|
-
readonly from: string;
|
|
68
|
-
readonly builds?: readonly string[];
|
|
69
|
-
};
|
|
8
|
+
import { type ComputerSettingKind, type KindRegistry, type ShellPlace } from "./workspace/resolve-computer.js";
|
|
70
9
|
/** Why a provider whose host command is not on this machine's PATH cannot run here, in words that say how to fix it,
|
|
71
10
|
* as the server says Docker's (docker-daemon.ts). On a machine the command has no build for (adb on arm64 Linux: AgentRun's
|
|
72
11
|
* arm64 image has none either), they say which machine it needs, not how to install it. */
|
|
@@ -75,12 +14,6 @@ export declare function hostCommandWhy(label: string, { command, from, builds }:
|
|
|
75
14
|
* words: what Settings → Computers, a run's start and the claim say for it. A command is there when a folder of `path`
|
|
76
15
|
* holds an executable file of its name. */
|
|
77
16
|
export declare function hostCommandRefusals(providers: readonly Pick<ProviderEntry, "id" | "label" | "hostCommand">[], path: string | undefined, platform?: string, arch?: string): Readonly<Record<string, string>>;
|
|
78
|
-
/** The kind registry, by its own names: the computer package's module (SETTING_KINDS, PROVIDERS, servingRefusals). */
|
|
79
|
-
export interface KindRegistry {
|
|
80
|
-
readonly SETTING_KINDS: Readonly<Record<ComputerKind, SettingKindSpec>>;
|
|
81
|
-
readonly PROVIDERS: readonly ProviderEntry[];
|
|
82
|
-
servingRefusals(capabilities: KindCapabilities, kind: ComputerKind): string[];
|
|
83
|
-
}
|
|
84
17
|
/** Where the run's folder lives: on this machine (Mode 1), or on the owner's disk (Mode 2). */
|
|
85
18
|
export type FolderMode = "local" | "disk";
|
|
86
19
|
export interface ComputerRoutesOptions {
|
|
@@ -176,13 +109,15 @@ export declare const NETWORK_REFUSED_WORDS = "needs a network, which this server
|
|
|
176
109
|
* makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
|
|
177
110
|
* the allow-list applies as it is (Docker), or nothing is declared. */
|
|
178
111
|
export declare function networkWords(network: readonly string[] | undefined, kind?: ComputerKind): string | undefined;
|
|
179
|
-
/** A kind; kind none, the one "no computer" choice, carries its ShellChoice itself (it has no providers).
|
|
112
|
+
/** A kind; kind none, the one "no computer" choice, carries its ShellChoice itself (it has no providers). `settings`: the
|
|
113
|
+
* fields its computer may set beside kind and provider (computer-setting.ts kindSettings). */
|
|
180
114
|
export type KindView = {
|
|
181
115
|
kind: ComputerKind;
|
|
182
116
|
offered: boolean;
|
|
183
117
|
why?: string;
|
|
184
118
|
groups: string[];
|
|
185
119
|
tools: string[];
|
|
120
|
+
settings: string[];
|
|
186
121
|
providers: ProviderView[];
|
|
187
122
|
} & Partial<ShellChoice>;
|
|
188
123
|
export type TestView = {
|
|
@@ -226,7 +161,8 @@ export declare const COMPUTER_UNAVAILABLE = "computer_unavailable";
|
|
|
226
161
|
* mode takes it. `provider` is as this server has it (resolve-computer.ts entryHere). */
|
|
227
162
|
export declare function modeRefusal(kind: ComputerKind, provider: ProviderEntry, mode: FolderMode): string | undefined;
|
|
228
163
|
/** The routes' work over the server's store: GET /v2/computers (view), PUT /v2/computers/{provider}/keys (saveKeys), POST
|
|
229
|
-
* /v2/computers/{provider}/test (test), and the
|
|
164
|
+
* /v2/computers/{provider}/test (test), GET /v2/computers/{provider}/choices (choices), and the provider of an agent's
|
|
165
|
+
* own computer (providerFor). */
|
|
230
166
|
export declare function createComputerRoutes(options: ComputerRoutesOptions): {
|
|
231
167
|
view: () => Promise<{
|
|
232
168
|
kinds: KindView[];
|
|
@@ -237,8 +173,6 @@ export declare function createComputerRoutes(options: ComputerRoutesOptions): {
|
|
|
237
173
|
choices: (providerId: string, signal?: AbortSignal) => Promise<{
|
|
238
174
|
choices: KeyChoicesView[];
|
|
239
175
|
} | undefined>;
|
|
240
|
-
claimRefusal: (computer: ComputerSetting) => Promise<string | undefined>;
|
|
241
|
-
claimOptions: (computer: ComputerSetting) => Promise<OptionsAnswer | undefined>;
|
|
242
176
|
providerFor: (providerId: string, image: string | undefined) => Promise<Pick<ComputerProvider, "release">>;
|
|
243
177
|
};
|
|
244
178
|
export type ComputerRoutes = ReturnType<typeof createComputerRoutes>;
|
package/dist/computers.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// Settings → Computers, the serve side: which computers this server offers, each provider's keys (saved or not, never a
|
|
2
|
-
// value), saving a provider's keys sealed in the store, testing a provider's account
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
2
|
+
// value), saving a provider's keys sealed in the store, and testing a provider's account. createComputerRoutes takes the
|
|
3
|
+
// server's Store and the computer package's kind registry by its own names (SETTING_KINDS, PROVIDERS, servingRefusals);
|
|
4
|
+
// the tools each kind brings are the server's to say (server.ts kindTools: a sandbox's shell tools from the kernel's
|
|
5
|
+
// hostToolDefs, a browser's from pi-browser, a desktop's or a phone's the kernel's COMPUTER_TOOLS). Keys go by their
|
|
6
|
+
// names only: a provider declares them, Settings takes only those, and the store keeps each sealed under the server's
|
|
7
|
+
// seal key (server-keys.ts); a provider is handed its keys only for its test, or for the agent's own computer
|
|
8
|
+
// (providerFor), through computer-keys.ts (providerOptions, testConnection), which maps a key's name onto the option it
|
|
9
|
+
// fills. A run's claim is refused by the workspace's resolver (workspace/resolve-computer.ts resolveComputer).
|
|
10
10
|
import { connectOf, imagesOf } from "@parcha/agentrun-computer";
|
|
11
11
|
import { BOX_ALLOW_ENV, boxAllowOf } from "./box-settings.js";
|
|
12
12
|
import { KEY_TABLE, keyChoices, providerOptions, settingOptions, testConnection } from "./computer-keys.js";
|
|
13
|
-
import { COMPUTER_KINDS,
|
|
13
|
+
import { COMPUTER_KINDS, kindSettings } from "./computer-setting.js";
|
|
14
14
|
import { inArchilMode } from "./archil-settings.js";
|
|
15
15
|
import { daemonUp, noDockerWords } from "./docker-daemon.js";
|
|
16
16
|
import { ApiError, invalid } from "./errors.js";
|
|
@@ -18,14 +18,16 @@ import { commandOnPath } from "./host-command.js";
|
|
|
18
18
|
import { gpuRefused } from "./gpu-words.js";
|
|
19
19
|
import { redacted } from "./key-refusal.js";
|
|
20
20
|
import { keyMetaOf, envValue } from "./key-meta.js";
|
|
21
|
-
import { registerNotSecretWrite, registerSecretWrite, secretName } from "./secret-writes.js";
|
|
22
|
-
import { getSealedKey, putSealedKey, removeSealedKey
|
|
21
|
+
import { registerNotSecretWrite, registerSecretPage, registerSecretWrite, secretName } from "./secret-writes.js";
|
|
22
|
+
import { getSealedKey, putSealedKey, removeSealedKey } from "./server-keys.js";
|
|
23
23
|
import { dialApartWords, RUNNER_APART_WORDS, withPaired } from "./workspace/attached-computers.js";
|
|
24
24
|
import { aLabel, entryHere, folderKindOf, needsNetwork, shellChoiceOf } from "./workspace/resolve-computer.js";
|
|
25
|
+
import { restartWith } from "./start-switches.js";
|
|
25
26
|
// Every request to a computer's keys is a secret write (secret-writes.ts), whatever its body (a value, a null, an empty
|
|
26
27
|
// body or none), as saveToolKey's is: the server's one dispatch check keeps it to the owner's session before any provider
|
|
27
28
|
// is looked up, so a token learns nothing of which providers exist. The view and the connection test write none.
|
|
28
29
|
registerSecretWrite("saveComputerKeys", () => true);
|
|
30
|
+
registerSecretPage("saveComputerKeys", "/#/settings/computers");
|
|
29
31
|
registerNotSecretWrite("testComputer", "A connection test reads the saved keys and writes none.");
|
|
30
32
|
const ARCH_NAMES = { x64: "x86-64", arm64: "arm64" };
|
|
31
33
|
const PLATFORM_NAMES = { linux: "Linux", darwin: "macOS", win32: "Windows" };
|
|
@@ -56,7 +58,7 @@ export const OPERATOR_LIST_WORDS = "open unless this server sets AGENTRUN_BOX_AL
|
|
|
56
58
|
* and at its claim (resolve-computer.ts noNetworkRefusal), so Settings says so and never offers it. */
|
|
57
59
|
export const NETWORK_REFUSED_WORDS = `needs a network, which this server refuses: its ${BOX_ALLOW_ENV} is none`;
|
|
58
60
|
/** Why a provider whose computers can't run with no network is not ready where this server has none. */
|
|
59
|
-
const noNetworkWhy = (provider) => `${provider.label} needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network): pick a computer that runs with no network, or
|
|
61
|
+
const noNetworkWhy = (provider) => `${provider.label} needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network): pick a computer that runs with no network, or ${restartWith(`${BOX_ALLOW_ENV} set to a host list`)}`;
|
|
60
62
|
/** What this server's allow-list means for a provider's computers, by the network forms it declares: words for one that
|
|
61
63
|
* makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
|
|
62
64
|
* the allow-list applies as it is (Docker), or nothing is declared. */
|
|
@@ -115,27 +117,15 @@ function gpuView(gpu, provider, mode) {
|
|
|
115
117
|
delete shown.unmounted;
|
|
116
118
|
return { ...shown, ...(refused ? { why: refused.words } : {}) };
|
|
117
119
|
}
|
|
118
|
-
/** Why `computer`'s GPUs cannot be had on `provider` in `mode`, in gpuRefused's words; undefined when they can, or it
|
|
119
|
-
* asks for none (only a sandbox does). */
|
|
120
|
-
function gpuRefusal(kinds, computer, provider, mode) {
|
|
121
|
-
const asked = gpuOf(computer);
|
|
122
|
-
if (!asked)
|
|
123
|
-
return undefined;
|
|
124
|
-
const gpu = sandboxGpu(kinds, provider);
|
|
125
|
-
const refused = gpuRefused(asked, gpu, folderMount(provider, gpu, mode), provider.label);
|
|
126
|
-
if (!refused)
|
|
127
|
-
return undefined;
|
|
128
|
-
return refused.folder ? `${refused.words} (Settings → Computers)` : `${provider.label} can't give this agent's computer its GPUs: ${refused.words} (Settings → Computers)`;
|
|
129
|
-
}
|
|
130
120
|
/** The required keys `provider` has no saved value for, by name. */
|
|
131
121
|
const missingKeys = (provider, saved) => provider.keys.filter((key) => key.required && !saved.has(key.name)).map((key) => key.name);
|
|
132
|
-
/** Why a provider with keys missing is not ready, naming the setting to fill: a person reads it (the view, the test)
|
|
133
|
-
|
|
134
|
-
const keysWhy = (provider, missing, route = false) => `${provider.label} needs ${missing.join(" and ")} saved: save ${missing.length > 1 ? "them" : "it"} in Settings → Computers${route ? ` (PUT /v2/computers/${provider.id}/keys)` : ""}`;
|
|
122
|
+
/** Why a provider with keys missing is not ready, naming the setting to fill: a person reads it (the view, the test). */
|
|
123
|
+
const keysWhy = (provider, missing) => `${provider.label} needs ${missing.join(" and ")} saved: save ${missing.length > 1 ? "them" : "it"} in Settings → Computers`;
|
|
135
124
|
/** Whether `provider` binds a folder of this machine, so its computers need this machine's Docker daemon. */
|
|
136
125
|
const local = (provider) => provider.mounts.includes("bind");
|
|
137
126
|
/** The routes' work over the server's store: GET /v2/computers (view), PUT /v2/computers/{provider}/keys (saveKeys), POST
|
|
138
|
-
* /v2/computers/{provider}/test (test), and the
|
|
127
|
+
* /v2/computers/{provider}/test (test), GET /v2/computers/{provider}/choices (choices), and the provider of an agent's
|
|
128
|
+
* own computer (providerFor). */
|
|
139
129
|
export function createComputerRoutes(options) {
|
|
140
130
|
const { store, sealKey, kinds, factories, settings = {}, keyTable = KEY_TABLE, tools, env = {}, answers = daemonUp, hostWhy = {} } = options;
|
|
141
131
|
const providerOf = (id) => kinds.PROVIDERS.find((one) => one.id === id);
|
|
@@ -202,7 +192,7 @@ export function createComputerRoutes(options) {
|
|
|
202
192
|
const why = offered ? undefined
|
|
203
193
|
: serving.length && serving.every(refusedOpen) ? `every provider of a ${kind} computer needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network)`
|
|
204
194
|
: serving.length ? `no provider of a ${kind} computer can reach this server's run folders` : `no provider serves a ${kind} computer`;
|
|
205
|
-
return { kind, offered, ...(why ? { why } : {}), groups: [...spec.required, ...spec.optional], tools: [...tools(kind)], providers, ...(kind === "none" ? choice({ kind: "none" }) : {}) };
|
|
195
|
+
return { kind, offered, ...(why ? { why } : {}), groups: [...spec.required, ...spec.optional], tools: [...tools(kind)], settings: kindSettings(kind), providers, ...(kind === "none" ? choice({ kind: "none" }) : {}) };
|
|
206
196
|
}),
|
|
207
197
|
paired,
|
|
208
198
|
};
|
|
@@ -288,42 +278,6 @@ export function createComputerRoutes(options) {
|
|
|
288
278
|
}
|
|
289
279
|
return { choices: views };
|
|
290
280
|
}
|
|
291
|
-
/** Why a run of an agent whose computer is `computer` cannot have it here, in words naming the setting to fill;
|
|
292
|
-
* undefined when it can. Checked at the claim: the provider must serve the kind (servingRefusals' words), fit this
|
|
293
|
-
* server's folder mode, give a sandbox the GPUs it asks for (checkGpu's words), have its daemon answer where it binds
|
|
294
|
-
* a folder of this machine (Docker), find what it runs on this machine (hostWhy's words), and have every required key
|
|
295
|
-
* saved; a key refusal names the route that saves them. */
|
|
296
|
-
async function claimRefusal(computer) {
|
|
297
|
-
if (computer.kind === "none")
|
|
298
|
-
return undefined;
|
|
299
|
-
const listed = providerOf(computer.provider);
|
|
300
|
-
if (!listed)
|
|
301
|
-
return `this agent's computer names the provider ${computer.provider}, which this server does not have: set its computer in Settings → Computers`;
|
|
302
|
-
// The keys set here, saved or the environment's: what the provider is made with, and what turns its mounts on.
|
|
303
|
-
const set = new Set([...(await sealedKeyNames(store)), ...listed.keys.filter((key) => envValue(env, key.name) !== undefined).map((key) => key.name)]);
|
|
304
|
-
const provider = entryHere(listed, (name) => set.has(name) || envValue(env, name) !== undefined, settingOptions(listed.id, settings, keyTable));
|
|
305
|
-
if (!provider.kinds.includes(computer.kind)) {
|
|
306
|
-
const words = [...new Set(provider.capabilities.flatMap((capabilities) => kinds.servingRefusals(capabilities, computer.kind)))];
|
|
307
|
-
return `${provider.label} does not serve a ${computer.kind} computer${words.length ? ` (${words.join("; ")})` : ""}: set this agent's computer to one it serves (Settings → Computers)`;
|
|
308
|
-
}
|
|
309
|
-
const mode = await modeNow();
|
|
310
|
-
const refused = modeRefusal(computer.kind, provider, mode) ?? gpuRefusal(kinds, computer, provider, mode) ?? (local(provider) ? daemonWhy(computer.kind, await answers(provider.id), mode) : undefined) ?? hostOf(provider);
|
|
311
|
-
if (refused)
|
|
312
|
-
return refused;
|
|
313
|
-
const missing = missingKeys(provider, set);
|
|
314
|
-
return missing.length ? keysWhy(provider, missing, true) : undefined;
|
|
315
|
-
}
|
|
316
|
-
/** What the claim makes a run's computer with: the options its provider's create() takes, from its saved keys and the
|
|
317
|
-
* server's settings (computer-keys.ts providerOptions); refused with computer_unavailable and claimRefusal's words when
|
|
318
|
-
* the computer cannot be had here. Undefined for a run with no computer. */
|
|
319
|
-
async function claimOptions(computer) {
|
|
320
|
-
if (computer.kind === "none")
|
|
321
|
-
return undefined;
|
|
322
|
-
const why = await claimRefusal(computer);
|
|
323
|
-
if (why)
|
|
324
|
-
return { ok: false, error: { code: COMPUTER_UNAVAILABLE, message: why } };
|
|
325
|
-
return providerOptions(computer.provider, await keysOf(providerOf(computer.provider)), settings, keyTable);
|
|
326
|
-
}
|
|
327
281
|
/** The provider an agent's own computer lives on (workspace/agent-computer.ts reconcileAgentComputer deletes it
|
|
328
282
|
* through it): made from its saved keys and the server's settings, with the create() options of the configuration
|
|
329
283
|
* `image` selects, and the store's ledger (the factories'). Throws, in words, when it cannot be made here. */
|
|
@@ -343,7 +297,7 @@ export function createComputerRoutes(options) {
|
|
|
343
297
|
throw new Error(`this server's ${entry.label} provider cannot release a computer`);
|
|
344
298
|
return made;
|
|
345
299
|
}
|
|
346
|
-
return { view, saveKeys, test, choices,
|
|
300
|
+
return { view, saveKeys, test, choices, providerFor };
|
|
347
301
|
}
|
|
348
302
|
/** This server's folder mode, read from the store at each call: "disk" (Mode 2) while the Archil settings row is saved
|
|
349
303
|
* (PUT /v2/workspace/archil), else "local" (Mode 1). createComputerRoutes' `mode`. */
|