@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.35
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 +135 -0
- package/README.md +84 -16
- package/dist/adapters.d.ts +3 -0
- package/dist/adapters.js +7 -0
- package/dist/agent-rows.d.ts +1 -0
- package/dist/agents-store.js +17 -2
- package/dist/archil-settings.d.ts +11 -1
- package/dist/archil-settings.js +10 -0
- package/dist/bash-read-only.d.ts +13 -0
- package/dist/bash-read-only.js +77 -0
- package/dist/browser-cost.d.ts +2 -2
- package/dist/browser-cost.js +6 -4
- package/dist/budget.d.ts +0 -5
- package/dist/budget.js +0 -5
- package/dist/cap.d.ts +6 -3
- package/dist/cap.js +7 -4
- package/dist/cli.js +32 -5
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -57
- package/dist/computer-setting.d.ts +6 -5
- package/dist/computer-setting.js +54 -26
- package/dist/computers.d.ts +9 -4
- package/dist/computers.js +4 -2
- package/dist/console/assets/index-B7NKTU8E.css +1 -0
- package/dist/console/assets/index-CXZMgJE7.js +550 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +3 -0
- package/dist/explain.js +3 -1
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +6 -2
- package/dist/github.js +5 -3
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.js +5 -2
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +3 -3
- package/dist/learn/folder.d.ts +6 -3
- package/dist/learn/folder.js +7 -16
- package/dist/learn/grade.d.ts +4 -1
- package/dist/learn/grade.js +43 -5
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +1 -14
- package/dist/learn/notes.d.ts +14 -3
- package/dist/learn/notes.js +16 -6
- package/dist/learn/reflect.js +5 -3
- package/dist/learn/skills.d.ts +48 -5
- package/dist/learn/skills.js +97 -21
- package/dist/learned-nodes.d.ts +14 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +9 -5
- package/dist/learned-workflow.js +53 -9
- package/dist/learning-routes.d.ts +41 -0
- package/dist/learning-routes.js +94 -26
- package/dist/learning-run.d.ts +7 -5
- package/dist/learning-run.js +9 -6
- package/dist/learning.d.ts +0 -22
- package/dist/learning.js +0 -16
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +11 -1
- package/dist/mcp-servers-store.d.ts +12 -12
- package/dist/model.d.ts +3 -0
- package/dist/model.js +8 -0
- package/dist/openapi.js +37 -13
- package/dist/paid-calls.js +1 -1
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/port-models.d.ts +10 -3
- package/dist/port-models.js +26 -6
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +1 -10
- package/dist/run-launch.d.ts +5 -3
- package/dist/run-launch.js +6 -5
- package/dist/run-learning-served.d.ts +11 -0
- package/dist/run-reads-over-store.d.ts +4 -2
- package/dist/run-reads-over-store.js +10 -8
- package/dist/run-timeline-served.js +12 -2
- package/dist/run-view.d.ts +30 -14
- package/dist/run-view.js +60 -32
- package/dist/runnable.d.ts +4 -1
- package/dist/runnable.js +14 -2
- package/dist/runner/adapter-loop.d.ts +30 -4
- package/dist/runner/adapter-loop.js +253 -29
- package/dist/runner/adapter-run-spec.d.ts +21 -0
- package/dist/runner/adapter-run-spec.js +104 -28
- package/dist/runner/adapters/pi.d.ts +29 -1
- package/dist/runner/adapters/pi.js +95 -23
- package/dist/runner/beside.d.ts +8 -0
- package/dist/runner/beside.js +18 -0
- package/dist/runner/claim-secrets.d.ts +6 -0
- package/dist/runner/claim-secrets.js +15 -1
- package/dist/runner/cli-run-spec.d.ts +3 -0
- package/dist/runner/cli-run-spec.js +123 -34
- package/dist/runner/conformance/harness.d.ts +1 -0
- package/dist/runner/conformance/harness.js +5 -5
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +46 -15
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +23 -0
- package/dist/runner/journal-kinds.d.ts +38 -2
- package/dist/runner/journal-kinds.js +23 -0
- package/dist/runner/learning-end.js +88 -16
- package/dist/runner/learning-loop.d.ts +2 -0
- package/dist/runner/learning-loop.js +13 -5
- package/dist/runner/learning-seed.d.ts +6 -0
- package/dist/runner/learning-seed.js +6 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.d.ts +9 -4
- package/dist/runner/main.js +26 -11
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +6 -1
- package/dist/runner/mcp-github.d.ts +11 -2
- package/dist/runner/mcp-github.js +55 -4
- package/dist/runner/mcp-run.js +1 -0
- package/dist/runner/metrics.d.ts +14 -1
- package/dist/runner/metrics.js +72 -1
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +1 -1
- package/dist/runner/runner.js +90 -8
- package/dist/runner/spec-holds.d.ts +7 -2
- package/dist/runner/spec-holds.js +4 -3
- package/dist/runner/workflow-host.d.ts +7 -2
- package/dist/runner/workflow-host.js +3 -1
- package/dist/runner/workflow-loop.d.ts +4 -1
- package/dist/runner/workflow-loop.js +8 -2
- package/dist/runner/workflow-spec.d.ts +3 -0
- package/dist/runner/workflow-spec.js +156 -78
- package/dist/runs-over-store.d.ts +7 -1
- package/dist/runs-over-store.js +42 -11
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +0 -2
- package/dist/server-lock.js +4 -5
- package/dist/server.d.ts +21 -18
- package/dist/server.js +183 -34
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +5 -1
- package/dist/store/agent-body.js +11 -5
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +45 -0
- package/dist/store/postgres/connection.d.ts +4 -0
- package/dist/store/postgres/connection.js +55 -9
- package/dist/store/sqlite/connection.js +3 -38
- package/dist/store-reads/journal.js +39 -4
- package/dist/store-reads/learning.d.ts +58 -2
- package/dist/store-reads/learning.js +172 -7
- package/dist/store-view.d.ts +15 -1
- package/dist/store-view.js +45 -12
- package/dist/templates.d.ts +9 -4
- package/dist/templates.js +14 -9
- package/dist/timeline/timeline.d.ts +8 -0
- package/dist/tool-budget.d.ts +18 -0
- package/dist/tool-budget.js +50 -0
- package/dist/tool-gate.d.ts +6 -2
- package/dist/tool-gate.js +8 -5
- package/dist/tool-plane.d.ts +9 -10
- package/dist/tools.d.ts +37 -7
- package/dist/tools.js +73 -12
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +82 -9
- package/dist/usage.d.ts +1 -47
- package/dist/usage.js +3 -82
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +11 -1
- package/dist/workspace/archil-claim.d.ts +2 -2
- package/dist/workspace/archil-claim.js +4 -3
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +16 -0
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/computer-deps.d.ts +9 -10
- package/dist/workspace/computer-deps.js +53 -40
- package/dist/workspace/computer-for-claim.d.ts +5 -3
- package/dist/workspace/computer-for-claim.js +28 -16
- package/dist/workspace/computer-ledger.d.ts +1 -8
- package/dist/workspace/computer-ledger.js +0 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +3 -3
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/local.d.ts +3 -0
- package/dist/workspace/local.js +9 -0
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +8 -3
- package/dist/workspace/resolve-computer.js +28 -11
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +9 -3
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +1 -14
- package/package.json +14 -14
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +2 -2
- package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/release-notes/agent.md +11 -0
- package/dist/console/assets/index-RPHGlXmM.js +0 -540
- package/dist/console/assets/index-opTN5Naq.css +0 -1
|
@@ -27,13 +27,17 @@ function phonePlatform(machine, entry) {
|
|
|
27
27
|
const said = machine ?? entry?.capabilities.find((one) => one.kind === "android" || one.kind === "ios")?.kind;
|
|
28
28
|
return said === "ios" ? "ios" : "android";
|
|
29
29
|
}
|
|
30
|
-
/** The image `provider` made ready, when
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
/** The image `provider` made ready, when its descriptor declares it prepares its image (`entry.prepareImage`): its
|
|
31
|
+
* prepareImage(), its recipe built when the engine lacks it or its image by name pulled, answering the tag to start
|
|
32
|
+
* from; undefined for any other provider, which starts from its spec's image. A provider whose descriptor declares it
|
|
33
|
+
* and that has none breaks the contract, in words. A failure is the provider's words. `onWait`: told once if the claim
|
|
34
|
+
* waits on a build or a pull. */
|
|
35
|
+
async function readyImage(entry, provider, signal, onWait) {
|
|
36
|
+
if (!entry.prepareImage)
|
|
35
37
|
return undefined;
|
|
36
|
-
|
|
38
|
+
if (provider.prepareImage === undefined)
|
|
39
|
+
throw new Error(`${entry.label}'s descriptor says it prepares its image, but its provider has no prepareImage()`);
|
|
40
|
+
const ready = await provider.prepareImage({ ...(signal ? { signal } : {}), ...(onWait ? { onWait } : {}) });
|
|
37
41
|
if (!ready.ok)
|
|
38
42
|
throw new Error(ready.error.message);
|
|
39
43
|
return ready.value;
|
|
@@ -61,6 +65,10 @@ const failed = (error) => Object.assign(new Error(error.message), { code: error.
|
|
|
61
65
|
* at the claim. A session's computer is made at the tool's call, under the run's labels (`spec`'s) and the tool's tag;
|
|
62
66
|
* its release lets go of every one the tool left open. */
|
|
63
67
|
function claimBrowser(provider, spec) {
|
|
68
|
+
// A run's browser: the claim's spec always carries its lifetime (computerSpecOf); an agent's computer (owner) has none.
|
|
69
|
+
const lifetime = spec.lifetimeMs;
|
|
70
|
+
if (lifetime === undefined)
|
|
71
|
+
throw new TypeError("a run's browser needs lifetimeMs: the claim's spec carries none");
|
|
64
72
|
const open = new Set();
|
|
65
73
|
const release = async (id) => {
|
|
66
74
|
const released = await provider.release({ id, name: id }, "delete");
|
|
@@ -71,9 +79,9 @@ function claimBrowser(provider, spec) {
|
|
|
71
79
|
return {
|
|
72
80
|
browser: {
|
|
73
81
|
provider: provider.id,
|
|
74
|
-
maxLifetimeS: Math.floor(
|
|
82
|
+
maxLifetimeS: Math.floor(lifetime / 1000),
|
|
75
83
|
async open(tag, lifetimeS, signal) {
|
|
76
|
-
const lifetimeMs = Math.min(
|
|
84
|
+
const lifetimeMs = Math.min(lifetime, Math.max(1, Math.round(lifetimeS)) * 1000);
|
|
77
85
|
const created = await provider.create({ ...spec, lifetimeMs, labels: { ...spec.labels, [SESSION_TAG]: labelValue(tag) } }, signal ? { signal } : {});
|
|
78
86
|
if (!created.ok)
|
|
79
87
|
throw failed(created.error);
|
|
@@ -149,9 +157,9 @@ export async function computerForClaim(launch, store, deps) {
|
|
|
149
157
|
keysOf: providerKeys(deps.kinds, deps.keyOf ?? (async (name) => (deps.sealKey ? await getSealedKey(store, deps.sealKey, name) : undefined))),
|
|
150
158
|
answers: deps.answers ?? (async () => false),
|
|
151
159
|
...(deps.daemon ? { daemon: deps.daemon } : {}),
|
|
152
|
-
async launch(entry, { kind, keys, mount, gpu, signal }) {
|
|
160
|
+
async launch(entry, { kind, keys, configuration, mount, gpu, signal }) {
|
|
153
161
|
if (deps.launch) {
|
|
154
|
-
const own = await deps.launch(entry, { kind, keys, ...(mount ? { mount } : {}), ...(gpu ? { gpu } : {}), ...(signal ? { signal } : {}) });
|
|
162
|
+
const own = await deps.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu } : {}), ...(signal ? { signal } : {}) });
|
|
155
163
|
const ownWatch = own.watch;
|
|
156
164
|
made = { id: own.id, ...(ownWatch ? { watch: ownWatch } : {}) };
|
|
157
165
|
madeBy = entry;
|
|
@@ -163,7 +171,9 @@ export async function computerForClaim(launch, store, deps) {
|
|
|
163
171
|
const options = providerOptions(entry.id, keys, deps.settings ?? {}, table);
|
|
164
172
|
if (!options.ok)
|
|
165
173
|
throw new Error(options.error.message);
|
|
166
|
-
|
|
174
|
+
// The configuration the setting selected is built by its own create() options (Orgo's Windows: { os: "windows" }),
|
|
175
|
+
// beside the keys'.
|
|
176
|
+
const provider = await make({ ...options.options, ...configuration.options }, { ledger: storeLedger(store.computerLedger, entry.id), ...(launch.boxAllow === undefined ? {} : { boxAllow: launch.boxAllow }) });
|
|
167
177
|
// What this provider makes, as it declares it: the spec asks for one of its networks, within its lifetime
|
|
168
178
|
// (computer-deps.ts computerSpecOf).
|
|
169
179
|
const { network: networks, maxLifetimeMs } = provider.capabilities();
|
|
@@ -173,11 +183,13 @@ export async function computerForClaim(launch, store, deps) {
|
|
|
173
183
|
...(networks ? { networks } : {}),
|
|
174
184
|
...(typeof maxLifetimeMs === "number" ? { maxLifetimeMs } : {}),
|
|
175
185
|
};
|
|
176
|
-
// A provider that
|
|
177
|
-
// pulled) does so first, and the computer starts from the tag it answers: the recipe's tag is in no
|
|
178
|
-
// run of it unbuilt would be refused.
|
|
179
|
-
|
|
180
|
-
const
|
|
186
|
+
// A provider that declares it prepares its own image (its prepareImage(): its recipe built when the engine lacks it,
|
|
187
|
+
// an image by name pulled) does so first, and the computer starts from the tag it answers: the recipe's tag is in no
|
|
188
|
+
// registry, so a run of it unbuilt would be refused. The spec comes first, so a setting it refuses builds nothing. A
|
|
189
|
+
// configuration that names its image starts from it, else the kind's default.
|
|
190
|
+
const asked = deps.spec(entry, kind, run, configuration.image);
|
|
191
|
+
const ready = await readyImage(entry, provider, signal, deps.onImageWait);
|
|
192
|
+
const spec = { ...asked, ...(ready ? { image: ready } : {}), labels: runLabels(launch.runId, launch.epoch), ...(mount ? { mount } : {}), ...(gpu ? { gpu } : {}) };
|
|
181
193
|
// A browser makes nothing here: the run's browser tool opens each session through it, so a session lives (and is
|
|
182
194
|
// booked) only while the tool holds it.
|
|
183
195
|
if (kind === "browser") {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { ProviderOptions } from "@parcha/agentrun-computer";
|
|
2
1
|
import type { ComputerLedger } from "../store/store.js";
|
|
3
|
-
/** The phone provider's `ledger` option, and one entry of it, as the computer package's provider registry types them. */
|
|
4
|
-
export type PhoneLedger = NonNullable<ProviderOptions<"phone-harness">["ledger"]>;
|
|
5
|
-
export type PhoneLedgerEntry = Awaited<ReturnType<PhoneLedger["list"]>>[number];
|
|
6
2
|
/** A session's entry as a provider keeps it: its id, our labels, and the provider's own fields. */
|
|
7
3
|
export interface LedgerEntry {
|
|
8
4
|
id: string;
|
|
9
5
|
labels: Record<string, string>;
|
|
10
6
|
}
|
|
11
|
-
/** One provider's ledger, in the shape
|
|
7
|
+
/** One provider's ledger, in the shape a descriptor's `ledger` option takes: put, get, list and remove of its entries. */
|
|
12
8
|
export interface ProviderLedger<E extends LedgerEntry = LedgerEntry> {
|
|
13
9
|
put(entry: E): Promise<void>;
|
|
14
10
|
get(id: string): Promise<E | undefined>;
|
|
@@ -17,6 +13,3 @@ export interface ProviderLedger<E extends LedgerEntry = LedgerEntry> {
|
|
|
17
13
|
}
|
|
18
14
|
/** `provider`'s ledger over the store's computer ledger. */
|
|
19
15
|
export declare function storeLedger<E extends LedgerEntry = LedgerEntry>(ledger: ComputerLedger, provider: string): ProviderLedger<E>;
|
|
20
|
-
/** The phone provider's ledger over the store's computer ledger: what its create() takes as `ledger`. Typed by the
|
|
21
|
-
* provider's own option, so a change to its ledger interface fails this build. */
|
|
22
|
-
export declare const phoneLedger: (ledger: ComputerLedger) => PhoneLedger;
|
|
@@ -14,6 +14,3 @@ export function storeLedger(ledger, provider) {
|
|
|
14
14
|
remove: (id) => ledger.remove(provider, id),
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
/** The phone provider's ledger over the store's computer ledger: what its create() takes as `ledger`. Typed by the
|
|
18
|
-
* provider's own option, so a change to its ledger interface fails this build. */
|
|
19
|
-
export const phoneLedger = (ledger) => storeLedger(ledger, "phone-harness");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComputerProvider } from "@parcha/agentrun-computer";
|
|
1
|
+
import { type ComputerProvider, type ProviderEntry } from "@parcha/agentrun-computer";
|
|
2
2
|
import type { ProviderFactories } from "../computer-keys.js";
|
|
3
3
|
import type { ProviderMakers } from "./computer-for-claim.js";
|
|
4
4
|
/** How a provider is built from its id and options: the computer package's providerFor, or a test's stand-in. `claim`:
|
|
@@ -10,7 +10,9 @@ export type ProviderLoad = (id: string, options: Record<string, unknown>, claim?
|
|
|
10
10
|
/** Settings → Computers' factories (createComputerRoutes' `factories`, its account test) from the same makers, so serve
|
|
11
11
|
* builds a provider in one place: each made with its options and `ledgerOf` its id's ledger. */
|
|
12
12
|
export declare function computerProviderFactories(makers: ProviderMakers, ledgerOf: (id: string) => unknown): ProviderFactories;
|
|
13
|
-
/** Every provider the computer package
|
|
14
|
-
|
|
13
|
+
/** Every provider in `entries` (the computer package's PROVIDERS, each from its descriptor), made through `load`
|
|
14
|
+
* (providerFor) from its options, plus the server's ledger as the option its descriptor names, when it declares one. */
|
|
15
|
+
export declare function computerProviderMakers({ load, entries }?: {
|
|
15
16
|
readonly load?: ProviderLoad;
|
|
17
|
+
readonly entries?: readonly Pick<ProviderEntry, "id" | "ledger">[];
|
|
16
18
|
}): ProviderMakers;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
// The provider makers computerForClaim is handed at the claim (its `providers`): each
|
|
2
|
-
//
|
|
3
|
-
// names), and nothing else.
|
|
4
|
-
//
|
|
5
|
-
|
|
1
|
+
// The provider makers computerForClaim is handed at the claim (its `providers`): each provider the computer package
|
|
2
|
+
// declares, built by its providerFor from the options its saved keys fill (computer-keys.ts providerOptions, by its
|
|
3
|
+
// descriptor's key names), and nothing else. A provider whose descriptor declares a ledger (its sessions carry no labels
|
|
4
|
+
// of their own) is given the store's computer ledger, as the option its descriptor names. No key reaches a provider any
|
|
5
|
+
// other way, and nothing here reads the environment or names a vendor.
|
|
6
|
+
import { PROVIDERS, providerFor } from "@parcha/agentrun-computer";
|
|
6
7
|
/** Settings → Computers' factories (createComputerRoutes' `factories`, its account test) from the same makers, so serve
|
|
7
8
|
* builds a provider in one place: each made with its options and `ledgerOf` its id's ledger. */
|
|
8
9
|
export function computerProviderFactories(makers, ledgerOf) {
|
|
9
10
|
return Object.fromEntries(Object.entries(makers).map(([id, make]) => [id, (options) => make(options, { ledger: ledgerOf(id) })]));
|
|
10
11
|
}
|
|
11
|
-
/** Every provider the computer package
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** Every provider in `entries` (the computer package's PROVIDERS, each from its descriptor), made through `load`
|
|
13
|
+
* (providerFor) from its options, plus the server's ledger as the option its descriptor names, when it declares one. */
|
|
14
|
+
export function computerProviderMakers({ load = providerFor, entries = PROVIDERS } = {}) {
|
|
15
|
+
return Object.fromEntries(entries.map(({ id, ledger }) => [
|
|
14
16
|
id,
|
|
15
|
-
(options, extras) => load(id, { ...options, ...(
|
|
17
|
+
(options, extras) => load(id, { ...options, ...(ledger === undefined ? {} : { [ledger.option]: extras.ledger }) }, extras.boxAllow === undefined ? {} : { boxAllow: extras.boxAllow }),
|
|
16
18
|
]));
|
|
17
19
|
}
|
|
@@ -17,9 +17,12 @@ export declare function shellEnv(options?: {
|
|
|
17
17
|
* output goes to its log (the "log" stream is what a read reads); a listing is read to its last page. */
|
|
18
18
|
export declare function processesOf(processes: Processes): KernelProcesses;
|
|
19
19
|
/** The run's hands over `workspace`: its files, its shell with `env` for at most `maxExecS` a command, and the
|
|
20
|
-
* computer's processes when it has one (`processes`, the attached Workspace's)
|
|
20
|
+
* computer's processes when it has one (`processes`, the attached Workspace's); `prelude`, shell text each command runs
|
|
21
|
+
* after (a bash policy's). */
|
|
21
22
|
export declare function handsOf(workspace: Workspace, options: {
|
|
22
23
|
readonly maxExecS: number;
|
|
23
24
|
readonly env: Readonly<Record<string, string>>;
|
|
24
|
-
readonly processes?: Processes;
|
|
25
|
+
readonly processes?: Processes; /** Shell text run before each command (a bash policy's, bash-read-only.ts policyPrelude). */
|
|
26
|
+
readonly prelude?: string; /** Each command's network (a bash policy's on Archil's exec: run-tools.ts). */
|
|
27
|
+
readonly network?: "deny";
|
|
25
28
|
}): Hands;
|
package/dist/workspace/hands.js
CHANGED
|
@@ -71,7 +71,8 @@ export function processesOf(processes) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
/** The run's hands over `workspace`: its files, its shell with `env` for at most `maxExecS` a command, and the
|
|
74
|
-
* computer's processes when it has one (`processes`, the attached Workspace's)
|
|
74
|
+
* computer's processes when it has one (`processes`, the attached Workspace's); `prelude`, shell text each command runs
|
|
75
|
+
* after (a bash policy's). */
|
|
75
76
|
export function handsOf(workspace, options) {
|
|
76
77
|
return {
|
|
77
78
|
maxExecS: options.maxExecS,
|
|
@@ -100,8 +101,8 @@ export function handsOf(workspace, options) {
|
|
|
100
101
|
if (data !== "" && onOutput)
|
|
101
102
|
onOutput({ stream, data });
|
|
102
103
|
};
|
|
103
|
-
const run = (shell) => workspace.exec([shell, "-c", command], {
|
|
104
|
-
env: options.env, timeoutMs, maxOutput: 0, ...(signal ? { signal } : {}),
|
|
104
|
+
const run = (shell) => workspace.exec([shell, "-c", `${options.prelude ?? ""}${command}`], {
|
|
105
|
+
env: options.env, timeoutMs, maxOutput: 0, ...(signal ? { signal } : {}), ...(options.network ? { network: options.network } : {}),
|
|
105
106
|
onOutput: ({ stream, data }) => emit(stream, decoders[stream].write(Buffer.from(data.buffer, data.byteOffset, data.byteLength))),
|
|
106
107
|
});
|
|
107
108
|
let ran;
|
|
@@ -10,12 +10,12 @@ export { ARCHIL_CONTROL_URLS, type ArchilMountCredentialOptions, ArchilMountCred
|
|
|
10
10
|
export { ARCHIL_API_KEY_ENV, archilApiKey, type ArchilKeyOptions } from "./archil-key.js";
|
|
11
11
|
export { openRunWorkspace, type RunWorkspace, type RunWorkspaceOptions } from "./run-workspace.js";
|
|
12
12
|
export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace, type ServerRunWorkspaceOptions } from "./server-run-workspace.js";
|
|
13
|
-
export { type LedgerEntry, type
|
|
13
|
+
export { type LedgerEntry, type ProviderLedger, storeLedger } from "./computer-ledger.js";
|
|
14
14
|
export { type LearningPlace, type LearningWorkspace, learningWorkspace, type LearningWorkspaceOptions } from "./learning-workspace.js";
|
|
15
|
-
export { ARCHIL_MAX_EXEC_S,
|
|
15
|
+
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
16
16
|
export { type RunComputer, type RunHold, runTools, type RunTools, withKindTools } from "./run-tools.js";
|
|
17
17
|
export { inputOf, phoneOf, screenOf } from "./computer-ports.js";
|
|
18
|
-
export { type ClaimSide, computerReadiness, type ComputerSetting, type
|
|
18
|
+
export { type ClaimSide, computerReadiness, type ComputerSetting, type KindRegistry, type LaunchedComputer, type Port, resolveComputer, type ResolvedComputer, runShellOf, shellPlaceOf, type StartedComputer, } from "./resolve-computer.js";
|
|
19
19
|
export { computerProviderFactories, computerProviderMakers, type ProviderLoad } from "./computer-providers.js";
|
|
20
20
|
export { claimComputer, claimKinds, type ComputerDeps, computerDepsFrom, type ComputerDepsOptions, computerSpecOf, DAEMON_CACHE_IN_VOLUME, DOCKER_HOST_ADDRESSES_ENV, type DockerComputerOptions, dockerHostAddressesOf, dockerVolumeOf, } from "./computer-deps.js";
|
|
21
21
|
export { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type ComputerRun, type ImageWait, type OpenComputerView, type ProviderMakers, type ViewEnd } from "./computer-for-claim.js";
|
package/dist/workspace/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { ARCHIL_CONTROL_URLS, ArchilMountCredentialError, listTokenUsers, mintMo
|
|
|
11
11
|
export { ARCHIL_API_KEY_ENV, archilApiKey } from "./archil-key.js";
|
|
12
12
|
export { openRunWorkspace } from "./run-workspace.js";
|
|
13
13
|
export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace } from "./server-run-workspace.js";
|
|
14
|
-
export {
|
|
14
|
+
export { storeLedger } from "./computer-ledger.js";
|
|
15
15
|
export { learningWorkspace } from "./learning-workspace.js";
|
|
16
16
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
17
17
|
export { runTools, withKindTools } from "./run-tools.js";
|
|
@@ -10,6 +10,9 @@ export type LocalWorkspaceOptions = {
|
|
|
10
10
|
/** A Workspace on folder `root` of this machine. The folder must be there when it is first used (else UNAVAILABLE).
|
|
11
11
|
* `options` are a test's: the path-resolving branch forced, and a hook where a swap would land. */
|
|
12
12
|
export declare const localWorkspace: (root: string, options?: LocalWorkspaceOptions) => Workspace;
|
|
13
|
+
/** The folder of this machine that `work` is, by its path: a LocalWorkspace's root; undefined for any other Workspace (a
|
|
14
|
+
* Mode 2 run's folder on its disk, one attached to a computer), whose files no local path reaches. */
|
|
15
|
+
export declare const localFolderOf: (work: Workspace) => string | undefined;
|
|
13
16
|
/** `work` as a Workspace: a folder of this machine, by its path, becomes its LocalWorkspace. For the callers that still
|
|
14
17
|
* hand a run's folder by its path (the run's start and its process), until they hand the run's Workspace. */
|
|
15
18
|
export declare const workspaceAt: (work: string | Workspace) => Workspace;
|
package/dist/workspace/local.js
CHANGED
|
@@ -223,6 +223,10 @@ class LocalWorkspace {
|
|
|
223
223
|
this.#root = root;
|
|
224
224
|
this.#options = options;
|
|
225
225
|
}
|
|
226
|
+
/** The folder `work` is over, by its path, when it is a LocalWorkspace; undefined for any other Workspace. */
|
|
227
|
+
static folderOf(work) {
|
|
228
|
+
return work instanceof LocalWorkspace ? work.#root : undefined;
|
|
229
|
+
}
|
|
226
230
|
/** The root, its links resolved once (the root itself is trusted; nothing below it is), held open. */
|
|
227
231
|
async #openRoot() {
|
|
228
232
|
try {
|
|
@@ -601,6 +605,8 @@ class LocalWorkspace {
|
|
|
601
605
|
const cap = options.maxOutput ?? EXEC_OUTPUT_MAX;
|
|
602
606
|
if (!Number.isSafeInteger(cap) || cap < 0)
|
|
603
607
|
throw new WorkspaceError("REFUSED", "exec's maxOutput is a whole number, 0 or more");
|
|
608
|
+
if (options.network !== undefined)
|
|
609
|
+
throw new WorkspaceError("REFUSED", "a command here runs on this machine, which cannot deny its network: nothing ran");
|
|
604
610
|
const cwd = options.cwd ?? "";
|
|
605
611
|
const segments = relativeSegments(cwd);
|
|
606
612
|
const { signal } = options;
|
|
@@ -745,6 +751,9 @@ class LocalWorkspace {
|
|
|
745
751
|
/** A Workspace on folder `root` of this machine. The folder must be there when it is first used (else UNAVAILABLE).
|
|
746
752
|
* `options` are a test's: the path-resolving branch forced, and a hook where a swap would land. */
|
|
747
753
|
export const localWorkspace = (root, options = {}) => new LocalWorkspace(root, options);
|
|
754
|
+
/** The folder of this machine that `work` is, by its path: a LocalWorkspace's root; undefined for any other Workspace (a
|
|
755
|
+
* Mode 2 run's folder on its disk, one attached to a computer), whose files no local path reaches. */
|
|
756
|
+
export const localFolderOf = (work) => LocalWorkspace.folderOf(work);
|
|
748
757
|
/** `work` as a Workspace: a folder of this machine, by its path, becomes its LocalWorkspace. For the callers that still
|
|
749
758
|
* hand a run's folder by its path (the run's start and its process), until they hand the run's Workspace. */
|
|
750
759
|
export const workspaceAt = (work) => (typeof work === "string" ? localWorkspace(work) : work);
|
package/dist/workspace/paths.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
// for it
|
|
9
9
|
// and on this machine alone:
|
|
10
10
|
// <data>/scratch/<agent>/<run> a run's scratch folder (scratchFolder): never on the disk above, so in
|
|
11
|
-
// no Workspace: a harness's
|
|
12
|
-
// at
|
|
11
|
+
// no Workspace: a harness's working directory, and its private files
|
|
12
|
+
// in harness/<claim's epoch>, swept at that claim's end
|
|
13
|
+
// (runner/cli-run-spec.ts)
|
|
13
14
|
// <agent> is the id in lower case, a dash, and 16 hex digits of the id's SHA-256, so ids that differ only in case never
|
|
14
15
|
// share a folder on a disk that folds case.
|
|
15
16
|
//
|
|
@@ -15,8 +15,12 @@ export type PiEnvOptions = {
|
|
|
15
15
|
readonly aliases?: readonly string[];
|
|
16
16
|
/** bash's whole environment: nothing of this process's is passed. */
|
|
17
17
|
readonly env: Readonly<Record<string, string>>;
|
|
18
|
+
/** Shell text bash runs before each command string (a bash policy's, bash-read-only.ts policyPrelude). */
|
|
19
|
+
readonly prelude?: string;
|
|
18
20
|
/** bash's deadline when a call names none, in seconds. */
|
|
19
21
|
readonly defaultTimeoutS: number;
|
|
22
|
+
/** Each command's network (a bash policy's on Archil's exec: run-tools.ts). */
|
|
23
|
+
readonly network?: "deny";
|
|
20
24
|
};
|
|
21
25
|
/** pi's ExecutionEnv over `workspace`, the run's folder named `options.cwd`. */
|
|
22
26
|
export declare function piEnv(workspace: Workspace, options: PiEnvOptions): ExecutionEnv;
|
package/dist/workspace/pi-env.js
CHANGED
|
@@ -203,13 +203,14 @@ export function piEnv(workspace, options) {
|
|
|
203
203
|
};
|
|
204
204
|
const run = (argv) => workspace.exec(argv, {
|
|
205
205
|
cwd: where.value, env: { ...options.env, ...(given?.env ?? {}) }, timeoutMs: Math.max(1, Math.round(timeoutS * 1000)), maxOutput: 0,
|
|
206
|
-
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
206
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}), ...(options.network ? { network: options.network } : {}),
|
|
207
207
|
onOutput: ({ stream, data }) => {
|
|
208
208
|
emit(decoders[stream].decode(data), stream);
|
|
209
209
|
keep(data);
|
|
210
210
|
},
|
|
211
211
|
});
|
|
212
|
-
const
|
|
212
|
+
const line = typeof command === "string" ? `${options.prelude ?? ""}${command}` : undefined;
|
|
213
|
+
const argvs = line !== undefined ? [["bash", "-c", line], ["sh", "-c", line]] : [[...command]];
|
|
213
214
|
let ran;
|
|
214
215
|
try {
|
|
215
216
|
for (const argv of argvs) {
|
|
@@ -7,10 +7,12 @@ import type { Workspace } from "./workspace.js";
|
|
|
7
7
|
/** The setting kind (what an agent is given, not a computer's capabilities().kind), a machine's kind and groups, and one
|
|
8
8
|
* provider of the kind registry: the computer module's own types. Where a run's shell is: the kernel registry's. */
|
|
9
9
|
export type { ComputerSettingKind, KindCapabilities, ProviderEntry, ShellPlace };
|
|
10
|
-
/** An agent's computer setting
|
|
10
|
+
/** An agent's computer setting. `image`: the one of the provider's configurations it selects; absent, the default. A
|
|
11
|
+
* sandbox's may ask for GPUs. */
|
|
11
12
|
export type ComputerSetting = {
|
|
12
13
|
readonly kind: string;
|
|
13
14
|
readonly provider?: string | null;
|
|
15
|
+
readonly image?: string;
|
|
14
16
|
readonly gpu?: GpuSpec;
|
|
15
17
|
};
|
|
16
18
|
/** The computer module's kind registry (src/kinds.ts), by its own names: the setting kinds, why a machine does not serve
|
|
@@ -60,9 +62,12 @@ export type ClaimSide = {
|
|
|
60
62
|
/** Its daemon's answer (docker-daemon.ts), asked when a launch on such a provider fails: none answering is refused in
|
|
61
63
|
* the one wording a run's start and Settings → Computers say (noDockerWords). Absent: the launch's own words. */
|
|
62
64
|
daemon?(provider: string): Promise<DockerDaemon>;
|
|
65
|
+
/** `configuration`: the provider's configuration the setting selected; its options go to the provider with the keys,
|
|
66
|
+
* and its image, when it names one, is the computer's. `gpu`: a sandbox's GPUs, held to that configuration. */
|
|
63
67
|
launch(entry: ProviderEntry, spec: {
|
|
64
68
|
readonly kind: ComputerSettingKind;
|
|
65
69
|
readonly keys: Readonly<Record<string, string>>;
|
|
70
|
+
readonly configuration: KindCapabilities;
|
|
66
71
|
readonly mount?: MountSpec;
|
|
67
72
|
readonly gpu?: GpuSpec;
|
|
68
73
|
readonly signal?: AbortSignal;
|
|
@@ -74,8 +79,8 @@ export type Port = "files" | "exec" | "processes" | "screen" | "input" | "phone"
|
|
|
74
79
|
/** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
|
|
75
80
|
* key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
|
|
76
81
|
export declare const providerKeys: (registry: Pick<KindRegistry, "PROVIDERS">, keyOf: (name: string) => Promise<string | undefined>) => ClaimSide["keysOf"];
|
|
77
|
-
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
78
|
-
*
|
|
82
|
+
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
83
|
+
* descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
|
|
79
84
|
export declare const vendorNetworkOnly: (network: readonly string[] | undefined) => boolean;
|
|
80
85
|
/** Whether a provider's computers can't have no network: it declares its network forms and "none" isn't one (a cloud
|
|
81
86
|
* phone, a hosted browser, Local Chrome). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkGpu } from "@parcha/agentrun-computer";
|
|
1
|
+
import { checkGpu, configurationOf, imagesOf } from "@parcha/agentrun-computer";
|
|
2
2
|
import { noDockerWords } from "../docker-daemon.js";
|
|
3
3
|
/** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
|
|
4
4
|
* key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
|
|
@@ -11,8 +11,8 @@ export const providerKeys = (registry, keyOf) => async (provider) => {
|
|
|
11
11
|
}
|
|
12
12
|
return keys;
|
|
13
13
|
};
|
|
14
|
-
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
15
|
-
*
|
|
14
|
+
/** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
|
|
15
|
+
* descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
|
|
16
16
|
export const vendorNetworkOnly = (network) => network !== undefined && network.length > 0 && network.every((one) => one === "open");
|
|
17
17
|
/** Whether a provider's computers can't have no network: it declares its network forms and "none" isn't one (a cloud
|
|
18
18
|
* phone, a hosted browser, Local Chrome). */
|
|
@@ -82,6 +82,11 @@ function mountsFolder(kind, entry, serving, mode) {
|
|
|
82
82
|
}
|
|
83
83
|
/** The configurations of `entry` that serve `kind`. */
|
|
84
84
|
const servingOf = (registry, entry, kind) => entry.capabilities.filter((one) => registry.servingRefusals(one, kind).length === 0);
|
|
85
|
+
/** The one configuration of `serving` the setting selects (configurationOf), as a list: [] when its image names none. */
|
|
86
|
+
const selectedOf = (serving, setting, entry, kind) => {
|
|
87
|
+
const one = configurationOf(serving, setting.image, entry.defaultImage?.[kind]);
|
|
88
|
+
return one ? [one] : [];
|
|
89
|
+
};
|
|
85
90
|
/**
|
|
86
91
|
* Where a run of an agent with computer `setting` has its shell in `mode` (shellPlaceOf), read off the setting and the
|
|
87
92
|
* kind registry before anything starts: what the claim's runTools gives the run once its computer is started. "computer"
|
|
@@ -101,7 +106,7 @@ export function runShellOf(setting, mode, registry) {
|
|
|
101
106
|
const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
|
|
102
107
|
if (!entry)
|
|
103
108
|
return "none";
|
|
104
|
-
const serving = servingOf(registry, entry, kind);
|
|
109
|
+
const serving = selectedOf(servingOf(registry, entry, kind), setting, entry, kind);
|
|
105
110
|
if (serving.length === 0)
|
|
106
111
|
return "none";
|
|
107
112
|
const mounts = mountsFolder(kind, entry, serving, mode);
|
|
@@ -146,8 +151,21 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
146
151
|
const why = entry.capabilities.map((one) => registry.servingRefusals(one, kind)).sort((a, b) => a.length - b.length)[0] ?? [];
|
|
147
152
|
return { refused: `${entry.label} gives no ${kind} computer${why.length > 0 ? `: ${why.join("; ")}` : ""}. Pick ${pick}` };
|
|
148
153
|
}
|
|
149
|
-
// The
|
|
150
|
-
|
|
154
|
+
// The configuration the setting's image selects: one the provider does not offer for the kind is refused, naming those
|
|
155
|
+
// it does.
|
|
156
|
+
const [configuration] = selectedOf(serving, setting, entry, kind);
|
|
157
|
+
if (!configuration) {
|
|
158
|
+
const images = imagesOf(serving, entry.defaultImage?.[kind]);
|
|
159
|
+
const offers = images.length === 0 ? `offers no ${kind} image to choose: remove the image` : `offers the ${kind} image${images.length === 1 ? "" : "s"} ${images.join(", ")}: pick one`;
|
|
160
|
+
// A configuration its descriptor parks (built, not offered yet): refused saying so, never as an unknown image.
|
|
161
|
+
const parked = entry.parked?.find((one) => one.image === setting.image);
|
|
162
|
+
if (parked)
|
|
163
|
+
return { refused: `${parked.why}, so this agent's ${JSON.stringify(setting.image)} ${kind} is parked. It ${offers} for this agent's computer in ${SETTINGS}.` };
|
|
164
|
+
return { refused: `${entry.label} has no ${kind} image ${JSON.stringify(setting.image)}. It ${offers} for this agent's computer in ${SETTINGS}.` };
|
|
165
|
+
}
|
|
166
|
+
// The run's folder: mounted where the selected configuration has files and exec and the provider mounts the mode's
|
|
167
|
+
// folder.
|
|
168
|
+
const mounts = mountsFolder(kind, entry, [configuration], mode);
|
|
151
169
|
if (kind === "sandbox" && !mounts) {
|
|
152
170
|
if (mode === 1)
|
|
153
171
|
return { refused: `Mode 1 runs a sandbox only on Docker: a ${entry.label} sandbox can't reach the run's folder on this machine. Pick Docker for this agent's computer in ${SETTINGS}, or another kind of computer.` };
|
|
@@ -155,12 +173,11 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
155
173
|
return { refused: `Mode 2 keeps workspaces on Archil; a local Docker computer can't mount them. Pick a remote sandbox for this agent's computer in ${SETTINGS}, or no computer.` };
|
|
156
174
|
return { refused: `A ${entry.label} sandbox can't mount the run's folder from Archil: pick another sandbox for this agent's computer in ${SETTINGS}.` };
|
|
157
175
|
}
|
|
158
|
-
// Its GPUs, a sandbox's alone: in checkGpu's words, against what the configuration
|
|
159
|
-
// mode's folder as the mount it takes (a sandbox here always mounts it).
|
|
176
|
+
// Its GPUs, a sandbox's alone: in checkGpu's words, against what the configuration the setting selected declares, with
|
|
177
|
+
// the mode's folder as the mount it takes (a sandbox here always mounts it).
|
|
160
178
|
const gpu = kind === "sandbox" && setting.gpu ? setting.gpu : undefined;
|
|
161
179
|
if (gpu) {
|
|
162
|
-
const
|
|
163
|
-
const [refusal] = checkGpu(gpu, offered, { kind: mode === 1 ? "bind" : "archil" });
|
|
180
|
+
const [refusal] = checkGpu(gpu, configuration, { kind: mode === 1 ? "bind" : "archil" });
|
|
164
181
|
if (refusal)
|
|
165
182
|
return { refused: `A ${entry.label} sandbox can't have this agent's GPUs: ${refusal.message}. Change the GPUs or the provider for this agent's computer in ${SETTINGS}.` };
|
|
166
183
|
}
|
|
@@ -184,7 +201,7 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
184
201
|
const mount = mounts ? await workspace.mountSpec() : undefined;
|
|
185
202
|
let launched;
|
|
186
203
|
try {
|
|
187
|
-
launched = await side.launch(entry, { kind, keys, ...(mount ? { mount } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(signal ? { signal } : {}) });
|
|
204
|
+
launched = await side.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(signal ? { signal } : {}) });
|
|
188
205
|
}
|
|
189
206
|
catch (error) {
|
|
190
207
|
// A provider that binds a folder of this machine (Docker) whose daemon does not answer: the one wording.
|
|
@@ -81,6 +81,7 @@ export declare function runHands(workspace: Workspace, computer: RunComputer | u
|
|
|
81
81
|
readonly context: Context;
|
|
82
82
|
readonly aliases?: readonly string[];
|
|
83
83
|
readonly hold?: RunHold;
|
|
84
|
+
readonly bashPolicy?: string;
|
|
84
85
|
}): Promise<RunHands>;
|
|
85
86
|
/** A tool as the kernel's registry lists it: what bindTools reads of its ToolDef. */
|
|
86
87
|
export type RegistryDef = {
|
|
@@ -148,6 +149,7 @@ export declare function runTools(workspace: Workspace, computer: RunComputer | u
|
|
|
148
149
|
readonly context: Context;
|
|
149
150
|
readonly aliases?: readonly string[];
|
|
150
151
|
readonly hold?: RunHold;
|
|
152
|
+
readonly bashPolicy?: string;
|
|
151
153
|
}): Promise<RunTools>;
|
|
152
154
|
/** The names a run binds as host tools: what it was granted, then the tools its claimed computer brings by its kind
|
|
153
155
|
* (RunTools.kindTools), each once. Each goes through the run's one gate under its own settings key (a desktop's under
|
|
@@ -2,6 +2,7 @@ import { capabilityToolDefs, createRegistry, endBackground } from "@parcha/agent
|
|
|
2
2
|
import { inputOf, phoneOf, screenOf } from "./computer-ports.js";
|
|
3
3
|
import { answerText, piExecutor } from "./executors.js";
|
|
4
4
|
import { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, shellEnv } from "./hands.js";
|
|
5
|
+
import { policyEnv, policyPrelude } from "../bash-read-only.js";
|
|
5
6
|
import { COMPUTER_ROOT, realOf, workspaceRelative } from "./paths.js";
|
|
6
7
|
import { bashTool, fileTools, OUTPUT_DIR, piEnv, readAnywhereInComputer } from "./pi-env.js";
|
|
7
8
|
import { shellPlaceOf } from "./resolve-computer.js";
|
|
@@ -53,8 +54,13 @@ export async function runHands(workspace, computer, options) {
|
|
|
53
54
|
const names = [cwd, ...(here !== undefined && here !== cwd ? [here] : []), ...(options.aliases ?? [])];
|
|
54
55
|
const maxExecS = mounted === undefined && options.mode === 2 ? ARCHIL_MAX_EXEC_S : MAX_EXEC_S;
|
|
55
56
|
await attached.mkdir(TMP_DIR);
|
|
56
|
-
|
|
57
|
-
const
|
|
57
|
+
// Under a bash policy (an agent's tool_settings.bash.policy), what the policy adds: git's config locked down.
|
|
58
|
+
const env = { ...shellEnv({ tmpdir: `${cwd}/${TMP_DIR}`, ...(mounted === undefined ? { home: cwd } : {}) }), ...policyEnv(options.bashPolicy) };
|
|
59
|
+
// And a prelude: git run only where it holds the whole lock-down (policyPrelude).
|
|
60
|
+
const prelude = policyPrelude(options.bashPolicy);
|
|
61
|
+
// And on Archil's serverless exec, no network for the shell's commands.
|
|
62
|
+
const network = options.bashPolicy !== undefined && mounted === undefined && options.mode === 2 ? { network: "deny" } : {};
|
|
63
|
+
const fileEnv = piEnv(attached, { cwd, aliases: names.slice(1), env, defaultTimeoutS: maxExecS, ...(prelude ? { prelude } : {}), ...network });
|
|
58
64
|
const tools = Object.fromEntries([...fileTools(), bashTool()].map((tool) => [tool.name, tool]));
|
|
59
65
|
const read = mounted === undefined ? tools.read : readAnywhereInComputer(tools.read, attached, names, env);
|
|
60
66
|
const executor = (tool) => piExecutor(tool, fileEnv, options.context);
|
|
@@ -65,7 +71,7 @@ export async function runHands(workspace, computer, options) {
|
|
|
65
71
|
workspace: attached,
|
|
66
72
|
// The computer's processes, for the five background tools: the attached Workspace's own; none when the folder is not
|
|
67
73
|
// attached. The kind's ports beside them.
|
|
68
|
-
hands: { ...handsOf(attached, { maxExecS, env, ...(mounted === undefined ? {} : { processes: attached.process }) }), ...ports },
|
|
74
|
+
hands: { ...handsOf(attached, { maxExecS, env, ...(prelude ? { prelude } : {}), ...network, ...(mounted === undefined ? {} : { processes: attached.process }) }), ...ports },
|
|
69
75
|
shell,
|
|
70
76
|
kinds,
|
|
71
77
|
without,
|
|
@@ -99,6 +99,11 @@ export type ExecOptions = {
|
|
|
99
99
|
/** Ends the call: the whole process group is killed, and exec rejects with the signal's reason (an AbortError). A
|
|
100
100
|
* signal already aborted runs nothing. */
|
|
101
101
|
readonly signal?: AbortSignal;
|
|
102
|
+
/** "deny": the program reaches no network (a bash policy's shell, run-tools.ts). Archil's serverless exec sends it as
|
|
103
|
+
* the container's network policy; where Archil's plan takes none, the program runs with the network open and its
|
|
104
|
+
* stderr starts with a line saying so (archil.ts). A backend that cannot deny a program's network refuses the call
|
|
105
|
+
* (REFUSED) and runs nothing. */
|
|
106
|
+
readonly network?: "deny";
|
|
102
107
|
};
|
|
103
108
|
export type ExecResult = {
|
|
104
109
|
readonly stdout: Uint8Array;
|
package/dist/workspace.d.ts
CHANGED
|
@@ -52,6 +52,3 @@ export declare function walkWork(work: string, visit: (path: string, stats: Stat
|
|
|
52
52
|
depth?: number;
|
|
53
53
|
refused?: (path: string, reason: RefusedReason) => void;
|
|
54
54
|
}): Promise<void>;
|
|
55
|
-
/** Throws unless the kernel refuses a hard link to a file the linker cannot write (fs.protected_hardlinks = 1): with a
|
|
56
|
-
* run's commands under a uid of their own, it keeps them from linking this server's files into their workspace. */
|
|
57
|
-
export declare function assertHardlinkProtection(read?: () => string): void;
|
package/dist/workspace.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// check and the open is refused, not followed. On top of it: the path must be the root joined with its own names (a link
|
|
5
5
|
// anywhere on the way, even one pointing inside the root, is refused), only regular files and directories are read, and a
|
|
6
6
|
// file with a second hard link is refused, since it could be one of this server's own files linked in.
|
|
7
|
-
import { closeSync, constants, openSync,
|
|
7
|
+
import { closeSync, constants, openSync, realpathSync, statSync } from "node:fs";
|
|
8
8
|
import { access, lstat, readdir } from "node:fs/promises";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { Confinement } from "./confine.js";
|
|
@@ -190,16 +190,3 @@ export async function walkWork(work, visit, { skip = () => false, depth = WALK_D
|
|
|
190
190
|
};
|
|
191
191
|
await into("", 0);
|
|
192
192
|
}
|
|
193
|
-
/** Throws unless the kernel refuses a hard link to a file the linker cannot write (fs.protected_hardlinks = 1): with a
|
|
194
|
-
* run's commands under a uid of their own, it keeps them from linking this server's files into their workspace. */
|
|
195
|
-
export function assertHardlinkProtection(read = () => readFileSync("/proc/sys/fs/protected_hardlinks", "utf8")) {
|
|
196
|
-
let value;
|
|
197
|
-
try {
|
|
198
|
-
value = read().trim();
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
throw new Error(`agentrun-serve: fs.protected_hardlinks cannot be read (${error.message}); a run's workspace could hold a link to this server's files`);
|
|
202
|
-
}
|
|
203
|
-
if (value !== "1")
|
|
204
|
-
throw new Error(`agentrun-serve: fs.protected_hardlinks is ${value}, not 1; a run's workspace could hold a link to this server's files`);
|
|
205
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-serve",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.35",
|
|
4
4
|
"description": "The AgentRun server: the /v2 API and console over one store, with runners that run your agents; the deployable process of the AgentRun platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"author": "Parcha Labs, Inc.",
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=24.
|
|
17
|
+
"node": ">=24.22.3"
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/index.js",
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
55
55
|
"@modelcontextprotocol/client": "2.4.0",
|
|
56
56
|
"@modelcontextprotocol/server": "2.4.0",
|
|
57
|
-
"@parcha/agentrun-computer": "0.1.0-beta.
|
|
58
|
-
"@parcha/agentrun-decisions": "0.1.0-beta.
|
|
59
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
60
|
-
"@parcha/agentrun-harness-claude": "0.1.0-beta.
|
|
61
|
-
"@parcha/agentrun-harness-codex": "0.1.0-beta.
|
|
62
|
-
"@parcha/agentrun-jev": "0.1.0-beta.
|
|
63
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
64
|
-
"@parcha/agentrun-pi": "0.1.0-beta.
|
|
65
|
-
"@parcha/pi-browser": "0.1.0-beta.
|
|
66
|
-
"@parcha/pi-durable-agent": "0.1.0-beta.
|
|
67
|
-
"@parcha/pi-durable-disk": "0.1.0-beta.
|
|
68
|
-
"@parcha/pi-transport": "0.1.0-beta.
|
|
57
|
+
"@parcha/agentrun-computer": "0.1.0-beta.35",
|
|
58
|
+
"@parcha/agentrun-decisions": "0.1.0-beta.35",
|
|
59
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.35",
|
|
60
|
+
"@parcha/agentrun-harness-claude": "0.1.0-beta.35",
|
|
61
|
+
"@parcha/agentrun-harness-codex": "0.1.0-beta.35",
|
|
62
|
+
"@parcha/agentrun-jev": "0.1.0-beta.35",
|
|
63
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.35",
|
|
64
|
+
"@parcha/agentrun-pi": "0.1.0-beta.35",
|
|
65
|
+
"@parcha/pi-browser": "0.1.0-beta.35",
|
|
66
|
+
"@parcha/pi-durable-agent": "0.1.0-beta.35",
|
|
67
|
+
"@parcha/pi-durable-disk": "0.1.0-beta.35",
|
|
68
|
+
"@parcha/pi-transport": "0.1.0-beta.35",
|
|
69
69
|
"@secretlint/core": "13.1.0",
|
|
70
70
|
"@secretlint/profiler": "13.1.0",
|
|
71
71
|
"@secretlint/secretlint-rule-preset-recommend": "13.1.0",
|