@parcha/agentrun-serve 0.1.0-beta.47 → 0.1.0-beta.49
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 +68 -1
- package/README.md +218 -20
- package/dist/acp-package.d.ts +24 -6
- package/dist/adapter-facts.d.ts +0 -4
- package/dist/adapter-facts.js +1 -4
- package/dist/adapters.d.ts +3 -12
- package/dist/adapters.js +1 -70
- package/dist/agent-delete.d.ts +33 -10
- package/dist/agent-delete.js +184 -26
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +18 -5
- package/dist/agents.d.ts +8 -1
- package/dist/agents.js +14 -4
- package/dist/answer-json.d.ts +10 -0
- package/dist/answer-json.js +23 -0
- package/dist/api-only.d.ts +5 -2
- package/dist/api-only.js +10 -2
- package/dist/archil-routes.d.ts +1 -1
- package/dist/archil-routes.js +4 -3
- package/dist/browser-live.d.ts +9 -4
- package/dist/browser-live.js +18 -5
- package/dist/browser-sessions.d.ts +56 -0
- package/dist/browser-sessions.js +117 -0
- package/dist/cap.js +7 -9
- package/dist/cli.js +6 -6
- package/dist/computer-routes.d.ts +6 -14
- package/dist/computer-routes.js +8 -10
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +4 -2
- package/dist/conformance.d.ts +4 -0
- package/dist/conformance.js +6 -0
- package/dist/console/assets/index-Bzn4eUYF.js +715 -0
- package/dist/console/assets/index-CR2ZGei1.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +15 -5
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +99 -70
- package/dist/harness-cursor.d.ts +10 -27
- package/dist/harness-cursor.js +5 -84
- package/dist/harness-goose.d.ts +4 -29
- package/dist/harness-goose.js +6 -86
- package/dist/harness-module.d.ts +4 -0
- package/dist/harness-module.js +1 -0
- package/dist/harness-owned.d.ts +52 -0
- package/dist/harness-owned.js +92 -0
- package/dist/harness-recipe.js +2 -24
- package/dist/harness-table.d.ts +109 -6
- package/dist/harness-table.js +242 -28
- package/dist/harness.js +2 -2
- package/dist/import.js +4 -3
- package/dist/key-refusal.d.ts +2 -1
- package/dist/key-refusal.js +18 -2
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +12 -9
- package/dist/learn/promote.d.ts +18 -1
- package/dist/learn/promote.js +47 -0
- package/dist/learn/repick.d.ts +34 -0
- package/dist/learn/repick.js +201 -0
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +23 -0
- package/dist/learned-workflow.d.ts +2 -0
- package/dist/learned-workflow.js +18 -1
- package/dist/learning-model.d.ts +18 -0
- package/dist/learning-model.js +77 -0
- package/dist/learning-setting.d.ts +13 -0
- package/dist/learning-setting.js +23 -1
- package/dist/llms.txt +1 -0
- package/dist/model-form.js +12 -12
- package/dist/model.d.ts +5 -4
- package/dist/model.js +19 -13
- package/dist/openapi.js +203 -15
- package/dist/page.d.ts +1 -0
- package/dist/page.js +1 -1
- package/dist/paid-calls.d.ts +4 -1
- package/dist/paid-calls.js +1 -1
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-secrets.d.ts +2 -2
- package/dist/run-secrets.js +6 -5
- package/dist/run-trace.js +6 -3
- package/dist/run-usage.d.ts +110 -0
- package/dist/run-usage.js +312 -0
- package/dist/runner/adapter-loop.d.ts +4 -1
- package/dist/runner/adapter-loop.js +52 -22
- package/dist/runner/adapter-run-spec.d.ts +3 -2
- package/dist/runner/adapter-run-spec.js +8 -4
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +6 -42
- package/dist/runner/cli-run-spec.js +10 -6
- package/dist/runner/conformance/harness.d.ts +2 -0
- package/dist/runner/conformance/harness.js +18 -4
- package/dist/runner/conformance/host-tools.d.ts +4 -0
- package/dist/runner/conformance/host-tools.js +14 -0
- package/dist/runner/feedback-round.d.ts +29 -1
- package/dist/runner/feedback-round.js +54 -3
- package/dist/runner/journal-kinds.d.ts +3 -1
- package/dist/runner/learning-end.js +49 -18
- package/dist/runner/loop-contract.d.ts +3 -0
- package/dist/runner/meta-tools.js +4 -2
- package/dist/runner/monid-run.js +2 -2
- package/dist/runner/presence.d.ts +3 -0
- package/dist/runner/presence.js +19 -12
- package/dist/runner/promotion.d.ts +62 -4
- package/dist/runner/promotion.js +154 -17
- package/dist/runner/reflect-hook.js +3 -2
- package/dist/runner/sdk-loop.js +25 -1
- package/dist/runner/workflow-spec.js +3 -2
- package/dist/runs-over-store.d.ts +5 -3
- package/dist/runs-over-store.js +11 -11
- package/dist/sdk/check.d.ts +31 -0
- package/dist/sdk/check.js +58 -0
- package/dist/sdk/runs.d.ts +10 -2
- package/dist/sdk/runs.js +87 -17
- package/dist/sdk/schema.js +11 -3
- package/dist/server.d.ts +6 -3
- package/dist/server.js +297 -98
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/open.d.ts +1 -1
- package/dist/store/open.js +1 -1
- package/dist/store/postgres/migrations/0021_purged.sql +13 -0
- package/dist/store/postgres/migrations/0022_computer_intervals.sql +27 -0
- package/dist/store/schema.d.ts +15 -1
- package/dist/store/schema.js +50 -5
- package/dist/store/sqlite/connection.d.ts +4 -1
- package/dist/store/sqlite/connection.js +5 -0
- package/dist/store/sqlite/run-patch.d.ts +8 -3
- package/dist/store/sqlite/run-patch.js +15 -7
- package/dist/store/sqlite/store.d.ts +5 -2
- package/dist/store/sqlite/store.js +283 -77
- package/dist/store/sqlite/worker.d.ts +9 -0
- package/dist/store/sqlite/worker.js +18 -1
- package/dist/store/store.d.ts +162 -27
- package/dist/store/store.js +63 -0
- package/dist/store-reads/analytics.js +2 -1
- package/dist/store-reads/cap.d.ts +8 -2
- package/dist/store-reads/cap.js +27 -3
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/learning.js +5 -2
- package/dist/store-reads/runs.js +2 -0
- package/dist/store-reads/stats.js +4 -2
- package/dist/store-view.d.ts +12 -3
- package/dist/store-view.js +70 -27
- package/dist/template-eval.js +5 -2
- package/dist/template-github-permissions.d.ts +5 -1
- package/dist/template-github-permissions.js +7 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +8 -0
- package/dist/timeline/timeline.js +18 -6
- package/dist/tool-gate.d.ts +8 -4
- package/dist/tool-gate.js +6 -7
- package/dist/tool-plane.d.ts +4 -0
- package/dist/tool-plane.js +10 -10
- package/dist/tools.js +9 -0
- package/dist/trigger-targets.d.ts +14 -2
- package/dist/trigger-targets.js +73 -4
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +5 -2
- package/dist/validate.d.ts +4 -2
- package/dist/validate.js +18 -4
- package/dist/viewer-credential.d.ts +24 -0
- package/dist/viewer-credential.js +53 -0
- package/dist/workspace/computer-for-claim.d.ts +5 -1
- package/dist/workspace/computer-for-claim.js +47 -18
- package/dist/workspace/computer-intervals.d.ts +20 -0
- package/dist/workspace/computer-intervals.js +49 -0
- package/dist/workspace/computer-janitor.d.ts +7 -3
- package/dist/workspace/computer-janitor.js +14 -6
- package/dist/workspace/computer-kept.d.ts +7 -2
- package/dist/workspace/computer-kept.js +9 -2
- package/dist/workspace/resolve-computer.d.ts +9 -1
- package/dist/workspace/resolve-computer.js +29 -22
- package/dist/workspace/run-end-computers.d.ts +1 -0
- package/dist/workspace/run-end-computers.js +4 -1
- package/package.json +18 -10
- package/templates/code-review/agent.md +2 -3
- package/templates/code-review/evals/mentions-defused/case.yaml +0 -1
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -27
- package/templates/code-review/evals/other-repo/case.yaml +0 -1
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +0 -18
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +1 -1
- package/dist/console/assets/index-BBFzAxLB.js +0 -715
- package/dist/console/assets/index-BRi-Rgq6.css +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** The default log: the runner's stderr, as its other lines. */
|
|
2
|
+
const stderrLog = (line) => void process.stderr.write(`agentrun-serve runner: ${line}\n`);
|
|
3
|
+
const count = (value) => (typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
4
|
+
/** The interval writes over `store` (none written where it keeps none), on the clock `now`, failures said on `log`. */
|
|
5
|
+
export function intervalWrites(store, log = stderrLog, now = Date.now) {
|
|
6
|
+
const intervals = store?.computerIntervals;
|
|
7
|
+
const safely = async (what, write) => {
|
|
8
|
+
if (!intervals)
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
await write(intervals);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
log(`the computer interval of ${what} was not written: ${error instanceof Error ? error.message : String(error)}`);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
opened: (provider, providerId, runId, kind, spec) => safely(`${provider} ${providerId} (run ${runId})`, (to) => to.opened({
|
|
19
|
+
runId, provider, providerId, kind,
|
|
20
|
+
gpuType: typeof spec.gpu?.type === "string" ? spec.gpu.type : null,
|
|
21
|
+
gpuCount: spec.gpu ? count(spec.gpu.count) : null,
|
|
22
|
+
cpus: count(spec.cpus),
|
|
23
|
+
memoryMb: count(spec.memoryMb),
|
|
24
|
+
startedAt: now(),
|
|
25
|
+
})),
|
|
26
|
+
kept: (provider, providerId) => safely(`${provider} ${providerId}`, (to) => to.kept(provider, providerId)),
|
|
27
|
+
ended: (provider, providerId) => safely(`${provider} ${providerId}`, (to) => to.ended(provider, providerId, now())),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** `provider` with each delete that answers ok ended in `writes` under `id` (the provider's registry id): the janitor's
|
|
31
|
+
* sweeps and a run's end let computers go through it. A detach, or a delete that fails, writes nothing. */
|
|
32
|
+
export function endingDeletes(provider, id, writes) {
|
|
33
|
+
return new Proxy(provider, {
|
|
34
|
+
// Every other member is the provider's own, called on the provider itself (its private fields are its own).
|
|
35
|
+
get(target, key) {
|
|
36
|
+
if (key !== "release") {
|
|
37
|
+
const value = Reflect.get(target, key, target);
|
|
38
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
39
|
+
}
|
|
40
|
+
return async (...args) => {
|
|
41
|
+
const released = await target.release(...args);
|
|
42
|
+
const [ref, how] = args;
|
|
43
|
+
if (released.ok && how === "delete")
|
|
44
|
+
await writes.ended(id, ref.id);
|
|
45
|
+
return released;
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -13,7 +13,7 @@ export declare const JANITOR_PROVIDER_MS: number;
|
|
|
13
13
|
export interface JanitorDeps {
|
|
14
14
|
/** The store: whose runs a computer's run label names, and the phone provider's ledger; with `settings` and `agents`,
|
|
15
15
|
* this server's id and its agents, whose own computers it then sweeps by their owner. */
|
|
16
|
-
readonly store: Pick<Store, "runs" | "computerLedger"> & Partial<Pick<Store, "settings" | "agents">>;
|
|
16
|
+
readonly store: Pick<Store, "runs" | "computerLedger"> & Partial<Pick<Store, "settings" | "agents" | "computerIntervals">>;
|
|
17
17
|
/** The run's computers as the runner composed them (computer-deps.ts computerDepsFrom): the registry, the provider
|
|
18
18
|
* makers and the key reader. */
|
|
19
19
|
readonly computers: Pick<ComputerDeps, "kinds" | "providers" | "keyOf"> & {
|
|
@@ -40,11 +40,15 @@ export type ProviderSweep = {
|
|
|
40
40
|
/** One sweep of every provider this server can list: each provider whose keys it has and whose computers the janitor
|
|
41
41
|
* ends, its computers past their deadline that are this server's and unheld ended. A provider that fails is answered
|
|
42
42
|
* in its words; nothing throws. */
|
|
43
|
-
export declare function sweepServerComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now" | "providerMs"
|
|
43
|
+
export declare function sweepServerComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now" | "providerMs"> & {
|
|
44
|
+
readonly log?: (line: string) => void;
|
|
45
|
+
}, signal?: AbortSignal): Promise<ProviderSweep[]>;
|
|
44
46
|
/** The pass over the desktops and phones kept at a run's park (computer-kept.ts sweepKept): one past its time, or whose
|
|
45
47
|
* run ended, is ended through its provider, made with this server's keys, whatever its lifetime (a vendor's own end is
|
|
46
48
|
* hours away). Undefined without the store's settings, where none is kept. Never throws. */
|
|
47
|
-
export declare function sweepKeptComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now">
|
|
49
|
+
export declare function sweepKeptComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now"> & {
|
|
50
|
+
readonly log?: (line: string) => void;
|
|
51
|
+
}): Promise<KeptSweep | undefined>;
|
|
48
52
|
/** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
|
|
49
53
|
* computer is due (sweepKeptComputers; each delete bounded, KEPT_DELETE_MS), so a park's keep ends on time though the
|
|
50
54
|
* process that parked it is gone. A wake that comes while a sweep runs runs the kept pass as soon as that sweep is done.
|
|
@@ -35,6 +35,7 @@ import { deleteUnderHold, ownerGoneOf, serverIdOf, wantsOn } from "./agent-compu
|
|
|
35
35
|
import { sweepKept } from "./computer-kept.js";
|
|
36
36
|
import { storeLedger } from "./computer-ledger.js";
|
|
37
37
|
import { providerKeys } from "./resolve-computer.js";
|
|
38
|
+
import { intervalWrites } from "./computer-intervals.js";
|
|
38
39
|
/** How often the janitor sweeps after its first sweep at the runner's start. */
|
|
39
40
|
export const JANITOR_EVERY_MS = 10 * 60_000;
|
|
40
41
|
/** The longest close() waits for a sweep it cut: a vendor call that ignores the cut is left to finish on its own. */
|
|
@@ -78,7 +79,7 @@ async function sweepable(store, info, byHash, serverId) {
|
|
|
78
79
|
* now: a server that stopped before its run's end let go of an earlier claim's computer (run-end-computers.ts) leaves
|
|
79
80
|
* it for this sweep, never for its day-long deadline. Each call goes to the provider itself, so its own state is used
|
|
80
81
|
* as it is. */
|
|
81
|
-
function thisServers(provider, store, byHash, serverId, at) {
|
|
82
|
+
function thisServers(provider, store, byHash, serverId, at, ended) {
|
|
82
83
|
// The agents' own computers the list kept, by id: their delete goes under the agent's hold (deleteUnderHold), which
|
|
83
84
|
// also clears the agent's record of it, so its view no longer shows it deleting.
|
|
84
85
|
const ownedBy = new Map();
|
|
@@ -92,10 +93,15 @@ function thisServers(provider, store, byHash, serverId, at) {
|
|
|
92
93
|
attach: (target, context) => provider.attach(target, context),
|
|
93
94
|
network: (ref, policy, context) => provider.network(ref, policy, context),
|
|
94
95
|
connect: (ref) => provider.connect(ref),
|
|
95
|
-
release(ref, how, context) {
|
|
96
|
+
async release(ref, how, context) {
|
|
96
97
|
const agent = ownedBy.get(ref.id);
|
|
97
|
-
if (how !== "delete" || agent === undefined || settings === undefined)
|
|
98
|
-
|
|
98
|
+
if (how !== "delete" || agent === undefined || settings === undefined) {
|
|
99
|
+
const released = await provider.release(ref, how, context);
|
|
100
|
+
// A run's computer the sweep deleted: its interval ends (computer-intervals.ts), on the provider's ok alone.
|
|
101
|
+
if (released.ok && how === "delete")
|
|
102
|
+
await ended(ref.id);
|
|
103
|
+
return released;
|
|
104
|
+
}
|
|
99
105
|
// Asked again under the hold: the agent may want it back since ownerGone was read (this server's owners carry no
|
|
100
106
|
// idle TTL, so that is the one reason the sweep deletes one).
|
|
101
107
|
const due = async () => !agents || !(await wantsOn({ agents }, agent, provider.id));
|
|
@@ -142,6 +148,7 @@ async function bounded(ms, signal, work) {
|
|
|
142
148
|
* in its words; nothing throws. */
|
|
143
149
|
export async function sweepServerComputers(deps, signal) {
|
|
144
150
|
const { store, computers } = deps;
|
|
151
|
+
const writes = intervalWrites(store, deps.log, deps.now);
|
|
145
152
|
const at = (deps.now ?? Date.now)();
|
|
146
153
|
const keysOf = providerKeys(computers.kinds, computers.keyOf ?? (async () => undefined));
|
|
147
154
|
const byHash = runsByHash(store);
|
|
@@ -166,7 +173,7 @@ export async function sweepServerComputers(deps, signal) {
|
|
|
166
173
|
if (provider.capabilities().lifetime !== "janitor")
|
|
167
174
|
continue;
|
|
168
175
|
const ownerGone = serverId !== undefined && settings && agents ? ownerGoneOf({ agents, settings, runs: store.runs }, serverId, entry.id) : undefined;
|
|
169
|
-
out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at), { now: new Date(at), signal: cut, ...(ownerGone ? { ownerGone } : {}) })) });
|
|
176
|
+
out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at, (id) => writes.ended(entry.id, id)), { now: new Date(at), signal: cut, ...(ownerGone ? { ownerGone } : {}) })) });
|
|
170
177
|
}
|
|
171
178
|
catch (error) {
|
|
172
179
|
out.push({ provider: entry.id, swept: { ok: false, error: { code: "refused", message: error instanceof Error ? error.message : String(error) } } });
|
|
@@ -179,6 +186,7 @@ export async function sweepServerComputers(deps, signal) {
|
|
|
179
186
|
* hours away). Undefined without the store's settings, where none is kept. Never throws. */
|
|
180
187
|
export async function sweepKeptComputers(deps) {
|
|
181
188
|
const { store, computers } = deps;
|
|
189
|
+
const writes = intervalWrites(store, deps.log, deps.now);
|
|
182
190
|
if (!store.settings)
|
|
183
191
|
return undefined;
|
|
184
192
|
const keysOf = providerKeys(computers.kinds, computers.keyOf ?? (async () => undefined));
|
|
@@ -189,7 +197,7 @@ export async function sweepKeptComputers(deps) {
|
|
|
189
197
|
const options = providerOptions(id, await keysOf(id), computers.settings ?? {}, computers.keyTable ?? KEY_TABLE);
|
|
190
198
|
return options.ok ? make(options.options, { ledger: storeLedger(store.computerLedger, id) }) : undefined;
|
|
191
199
|
};
|
|
192
|
-
return sweepKept({ settings: store.settings, runs: store.runs, now: (deps.now ?? Date.now)(), providerOf });
|
|
200
|
+
return sweepKept({ settings: store.settings, runs: store.runs, now: (deps.now ?? Date.now)(), providerOf, deleted: (provider, id) => writes.ended(provider, id) });
|
|
193
201
|
}
|
|
194
202
|
/** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
|
|
195
203
|
* computer is due (sweepKeptComputers; each delete bounded, KEPT_DELETE_MS), so a park's keep ends on time though the
|
|
@@ -79,7 +79,12 @@ export declare function sweepKept(deps: {
|
|
|
79
79
|
readonly now: number;
|
|
80
80
|
readonly providerOf: (id: string) => Promise<ComputerProvider | undefined>;
|
|
81
81
|
readonly deleteMs?: number;
|
|
82
|
+
/** Told of each kept computer whose delete answered ok, by its provider and id (its interval's end,
|
|
83
|
+
* computer-intervals.ts). Never throws. */
|
|
84
|
+
readonly deleted?: (provider: string, id: string) => Promise<void>;
|
|
82
85
|
}): Promise<KeptSweep>;
|
|
83
86
|
/** Deletes the kept computer through its provider; one already gone (its run's end let it go, run-end-computers.ts, or
|
|
84
|
-
* its vendor ended it) is as good as deleted. Throws the provider's words on any other failure.
|
|
85
|
-
|
|
87
|
+
* its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. True when the
|
|
88
|
+
* provider's delete answered ok, the one answer that proves its end now (its interval's, computer-intervals.ts); false
|
|
89
|
+
* for one already gone, whose end is not known. */
|
|
90
|
+
export declare function deleteKept(provider: Pick<ComputerProvider, "release">, kept: Pick<Kept, "id" | "name">): Promise<boolean>;
|
|
@@ -116,7 +116,11 @@ export async function sweepKept(deps) {
|
|
|
116
116
|
failed.push(`${kept.name} of run ${runId}: this server can't reach ${kept.provider} to end it`);
|
|
117
117
|
continue;
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const proven = () => deleteKept(provider, kept).then(async (ok) => {
|
|
120
|
+
if (ok)
|
|
121
|
+
await deps.deleted?.(kept.provider, kept.id);
|
|
122
|
+
});
|
|
123
|
+
const deleted = await endKept(deps.settings, runId, kept, () => bounded(deps.deleteMs ?? KEPT_DELETE_MS, proven()));
|
|
120
124
|
if (deleted)
|
|
121
125
|
ended.push(kept.name);
|
|
122
126
|
if (deleted && over)
|
|
@@ -129,11 +133,14 @@ export async function sweepKept(deps) {
|
|
|
129
133
|
return { ended, failed, ...(next === undefined ? {} : { next }) };
|
|
130
134
|
}
|
|
131
135
|
/** Deletes the kept computer through its provider; one already gone (its run's end let it go, run-end-computers.ts, or
|
|
132
|
-
* its vendor ended it) is as good as deleted. Throws the provider's words on any other failure.
|
|
136
|
+
* its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. True when the
|
|
137
|
+
* provider's delete answered ok, the one answer that proves its end now (its interval's, computer-intervals.ts); false
|
|
138
|
+
* for one already gone, whose end is not known. */
|
|
133
139
|
export async function deleteKept(provider, kept) {
|
|
134
140
|
const released = await provider.release({ id: kept.id, name: kept.name }, "delete");
|
|
135
141
|
if (!released.ok && released.error.code !== "not_found" && released.error.code !== "gone")
|
|
136
142
|
throw new Error(released.error.message);
|
|
143
|
+
return released.ok;
|
|
137
144
|
}
|
|
138
145
|
/** `work`, or its timeout in words after `ms`: a delete that hangs is left to finish on its own. */
|
|
139
146
|
async function bounded(ms, work) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
-
import { type BrowserFeatures, type BrowserFile, type BrowserSpec, type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type HelloResult, type KindCapabilities, type MountKind, type MountReadBack, type MountSpec, type ProviderEntry, type Result, type SettingKindSpec } from "@parcha/agentrun-computer";
|
|
2
|
+
import { type BrowserFeatures, type BrowserFile, type BrowserSessionUsage, type BrowserSpec, type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type HelloResult, type KindCapabilities, type MountKind, type MountReadBack, type MountSpec, type ProviderEntry, type Result, type SettingKindSpec } from "@parcha/agentrun-computer";
|
|
3
3
|
import { type DockerDaemon } from "../docker-daemon.js";
|
|
4
4
|
import type { Recording, RecordWatch } from "../computer-record.js";
|
|
5
5
|
import type { MountCheck } from "./attach.js";
|
|
@@ -84,6 +84,10 @@ export type ClaimBrowser = {
|
|
|
84
84
|
* view's, computer-record.ts browserWatch) until the caller stops it at the session's release, or the claim's release
|
|
85
85
|
* stops it. Absent: nothing is recorded. */
|
|
86
86
|
readonly record?: (id: string, watch: RecordWatch) => Recording;
|
|
87
|
+
/** The provider's own record of session `id` (BrowserComputerProvider.sessionUsage), read once as it is let go: when it
|
|
88
|
+
* says the session started and ended, and its proxy bytes, each null where it does not say; undefined for a session it
|
|
89
|
+
* does not know. Absent where the provider keeps no such record. A failed read throws. */
|
|
90
|
+
readonly usage?: (id: string, signal?: AbortSignal) => Promise<BrowserSessionUsage | undefined>;
|
|
87
91
|
/** The files a session downloaded, kept by the provider: where its features declare downloads. */
|
|
88
92
|
readonly downloads?: {
|
|
89
93
|
list(id: string): Promise<BrowserFile[]>;
|
|
@@ -243,6 +247,10 @@ export type ResolvedComputer = {
|
|
|
243
247
|
* itself, able to read its data and its keys; no bash family at all, the file tools alone (confined to the folder).
|
|
244
248
|
*/
|
|
245
249
|
export declare function shellPlaceOf(mounts: boolean, mode: 1 | 2): ShellPlace;
|
|
250
|
+
/** The kind of the run's folder a run of an agent with computer `setting` holds in `mode`, read off the setting and the
|
|
251
|
+
* kind registry before anything starts (selectedFor, settingFolderOf): a bind, an Archil mount or a synced folder, or
|
|
252
|
+
* undefined for none (kind none, a computer that holds no folder, or a setting the claim refuses). */
|
|
253
|
+
export declare function runFolderOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">): MountKind | undefined;
|
|
246
254
|
/**
|
|
247
255
|
* Where a run of an agent with computer `setting` has its shell in `mode` (shellPlaceOf), read off the setting and the
|
|
248
256
|
* kind registry before anything starts: what the claim's runTools gives the run once its computer is started. "computer"
|
|
@@ -182,11 +182,28 @@ function folderOf(kind, entry, serving, mode, gpuMounts) {
|
|
|
182
182
|
}
|
|
183
183
|
/** The configurations of `entry` that serve `kind`. */
|
|
184
184
|
const servingOf = (registry, entry, kind) => entry.capabilities.filter((one) => registry.servingRefusals(one, kind).length === 0);
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
/** What computer `setting` selects before anything starts, as the claim picks it (resolveComputer): its kind, its
|
|
186
|
+
* provider's entry, and the configuration serving the kind that its image names (configurationOf). Undefined for kind
|
|
187
|
+
* none, an unknown kind or provider, or no such configuration. `registry` is as this server has it (registryHere). */
|
|
188
|
+
function selectedFor(setting, registry) {
|
|
189
|
+
const kind = setting.kind;
|
|
190
|
+
if (kind === "none" || !Object.hasOwn(registry.SETTING_KINDS, kind))
|
|
191
|
+
return undefined;
|
|
192
|
+
const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
|
|
193
|
+
const configuration = entry && configurationOf(servingOf(registry, entry, kind), setting.image, entry.defaultImage?.[kind]);
|
|
194
|
+
return entry && configuration ? { kind, entry, configuration } : undefined;
|
|
195
|
+
}
|
|
196
|
+
/** The kind of the run's folder a computer of `setting` on `entry`'s `configuration` holds in `mode` (folderOf), or
|
|
197
|
+
* undefined for none: none where the agent runs no programs of its own; of the kinds its GPU computers take, where a
|
|
198
|
+
* sandbox's setting asks for GPUs. resolveComputer's folder, and runFolderOf's. */
|
|
199
|
+
const settingFolderOf = (setting, kind, entry, configuration, mode) => noPrograms(setting) ? undefined : folderOf(kind, entry, [configuration], mode, kind === "sandbox" && setting.gpu ? configuration.gpu?.mounts : undefined);
|
|
200
|
+
/** The kind of the run's folder a run of an agent with computer `setting` holds in `mode`, read off the setting and the
|
|
201
|
+
* kind registry before anything starts (selectedFor, settingFolderOf): a bind, an Archil mount or a synced folder, or
|
|
202
|
+
* undefined for none (kind none, a computer that holds no folder, or a setting the claim refuses). */
|
|
203
|
+
export function runFolderOf(setting, mode, registry) {
|
|
204
|
+
const selected = selectedFor(setting, registry);
|
|
205
|
+
return selected && settingFolderOf(setting, selected.kind, selected.entry, selected.configuration, mode);
|
|
206
|
+
}
|
|
190
207
|
/**
|
|
191
208
|
* Where a run of an agent with computer `setting` has its shell in `mode` (shellPlaceOf), read off the setting and the
|
|
192
209
|
* kind registry before anything starts: what the claim's runTools gives the run once its computer is started. "computer"
|
|
@@ -196,24 +213,14 @@ const selectedOf = (serving, setting, entry, kind) => {
|
|
|
196
213
|
* runs nothing: "none". The setting is the agent's as saved; where it has none, the caller gives the server's default.
|
|
197
214
|
*/
|
|
198
215
|
export function runShellOf(setting, mode, registry) {
|
|
199
|
-
|
|
200
|
-
if (!Object.hasOwn(registry.SETTING_KINDS, kind))
|
|
201
|
-
return "none";
|
|
202
|
-
if (kind === "none")
|
|
216
|
+
if (setting.kind === "none")
|
|
203
217
|
return shellPlaceOf(false, mode);
|
|
204
|
-
|
|
205
|
-
return "none";
|
|
206
|
-
const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
|
|
207
|
-
if (!entry)
|
|
208
|
-
return "none";
|
|
209
|
-
const serving = selectedOf(servingOf(registry, entry, kind), setting, entry, kind);
|
|
210
|
-
if (serving.length === 0)
|
|
211
|
-
return "none";
|
|
218
|
+
const selected = selectedFor(setting, registry);
|
|
212
219
|
// An agent whose computer runs no programs of its own has no shell anywhere: not its computer's, not Archil's exec.
|
|
213
|
-
if (noPrograms(setting))
|
|
220
|
+
if (!selected || noPrograms(setting))
|
|
214
221
|
return "none";
|
|
215
|
-
const mounts = folderOf(kind, entry,
|
|
216
|
-
if (kind === "sandbox" && !mounts)
|
|
222
|
+
const mounts = folderOf(selected.kind, selected.entry, [selected.configuration], mode) !== undefined;
|
|
223
|
+
if (selected.kind === "sandbox" && !mounts)
|
|
217
224
|
return "none";
|
|
218
225
|
return shellPlaceOf(mounts, mode);
|
|
219
226
|
}
|
|
@@ -275,7 +282,7 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
275
282
|
}
|
|
276
283
|
// The configuration the setting's image selects: one the provider does not offer for the kind is refused, naming those
|
|
277
284
|
// it does.
|
|
278
|
-
const
|
|
285
|
+
const configuration = configurationOf(serving, setting.image, entry.defaultImage?.[kind]);
|
|
279
286
|
if (!configuration) {
|
|
280
287
|
const images = imagesOf(serving, entry.defaultImage?.[kind]);
|
|
281
288
|
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`;
|
|
@@ -289,7 +296,7 @@ export async function resolveComputer(given, mode, registry, side) {
|
|
|
289
296
|
// (of the kinds its GPU computers take, where the setting asks for GPUs), and the agent may run programs there (a
|
|
290
297
|
// folder is mounted for its shell).
|
|
291
298
|
const gpu = kind === "sandbox" && setting.gpu ? setting.gpu : undefined;
|
|
292
|
-
const folder =
|
|
299
|
+
const folder = settingFolderOf(setting, kind, entry, configuration, mode);
|
|
293
300
|
const mounts = folder !== undefined;
|
|
294
301
|
if (kind === "sandbox" && folder === undefined) {
|
|
295
302
|
if (mode === 1)
|
|
@@ -10,6 +10,7 @@ export interface RunEndComputersDeps {
|
|
|
10
10
|
* computer ledger, for a provider that keeps one. */
|
|
11
11
|
readonly store: Pick<Store, "agents" | "computerLedger"> & {
|
|
12
12
|
readonly runs: Pick<Store["runs"], "get" | "launch">;
|
|
13
|
+
readonly computerIntervals?: Store["computerIntervals"];
|
|
13
14
|
};
|
|
14
15
|
/** The run's computers as the runner composed them (computer-deps.ts computerDepsFrom): the registry, the provider
|
|
15
16
|
* makers, the key reader, and --faux's launch with the providers it takes. */
|
|
@@ -21,6 +21,7 @@ import { readLaunchBody } from "../run-launch.js";
|
|
|
21
21
|
import { settingOf } from "./computer-for-claim.js";
|
|
22
22
|
import { storeLedger } from "./computer-ledger.js";
|
|
23
23
|
import { providerKeys } from "./resolve-computer.js";
|
|
24
|
+
import { endingDeletes, intervalWrites } from "./computer-intervals.js";
|
|
24
25
|
/** The longest a run's end may spend on its computers, every try with its pauses: past it the provider's calls are cut
|
|
25
26
|
* (one that takes no signal, a release, left to finish on its own) and the run's end goes on, said in the log. */
|
|
26
27
|
export const RUN_END_COMPUTERS_MS = 120_000;
|
|
@@ -50,6 +51,8 @@ const pause = (ms, signal) => new Promise((resolve) => {
|
|
|
50
51
|
* is said in the log. */
|
|
51
52
|
export function runEndComputers(deps) {
|
|
52
53
|
const { store, computers, log } = deps;
|
|
54
|
+
/** Each computer let go here ends its interval (computer-intervals.ts), on its provider's ok alone. */
|
|
55
|
+
const writes = intervalWrites(store, log);
|
|
53
56
|
/** The provider the run's computers are on, by the agent's setting; undefined where none of them is this end's to let
|
|
54
57
|
* go (none, the agent's own, a paired computer, --faux's). */
|
|
55
58
|
const providerOf = async (runId, epoch) => {
|
|
@@ -74,7 +77,7 @@ export function runEndComputers(deps) {
|
|
|
74
77
|
if (!options.ok)
|
|
75
78
|
throw new NoProviderHere(options.error.message);
|
|
76
79
|
// A throw from here on is the vendor's or the daemon's (Docker's architecture asked): asked again.
|
|
77
|
-
return make(options.options, { ledger: storeLedger(store.computerLedger, entry.id) });
|
|
80
|
+
return endingDeletes(await make(options.options, { ledger: storeLedger(store.computerLedger, entry.id) }), entry.id, writes);
|
|
78
81
|
};
|
|
79
82
|
return async ({ runId, epoch }) => {
|
|
80
83
|
if (epoch <= 1)
|
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.49",
|
|
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",
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
24
|
},
|
|
25
|
+
"./harness": {
|
|
26
|
+
"types": "./dist/harness-module.d.ts",
|
|
27
|
+
"default": "./dist/harness-module.js"
|
|
28
|
+
},
|
|
29
|
+
"./conformance": {
|
|
30
|
+
"types": "./dist/conformance.d.ts",
|
|
31
|
+
"default": "./dist/conformance.js"
|
|
32
|
+
},
|
|
25
33
|
"./package.json": "./package.json"
|
|
26
34
|
},
|
|
27
35
|
"bin": {
|
|
@@ -54,15 +62,15 @@
|
|
|
54
62
|
"@earendil-works/pi-coding-agent": "1.5.2",
|
|
55
63
|
"@modelcontextprotocol/client": "2.4.0",
|
|
56
64
|
"@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-acp": "0.1.0-beta.
|
|
61
|
-
"@parcha/agentrun-harness-claude": "0.1.0-beta.
|
|
62
|
-
"@parcha/agentrun-harness-codex": "0.1.0-beta.
|
|
63
|
-
"@parcha/agentrun-jev": "0.1.0-beta.
|
|
64
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
65
|
-
"@parcha/pi-browser": "0.1.0-beta.
|
|
65
|
+
"@parcha/agentrun-computer": "0.1.0-beta.49",
|
|
66
|
+
"@parcha/agentrun-decisions": "0.1.0-beta.49",
|
|
67
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.49",
|
|
68
|
+
"@parcha/agentrun-harness-acp": "0.1.0-beta.49",
|
|
69
|
+
"@parcha/agentrun-harness-claude": "0.1.0-beta.49",
|
|
70
|
+
"@parcha/agentrun-harness-codex": "0.1.0-beta.49",
|
|
71
|
+
"@parcha/agentrun-jev": "0.1.0-beta.49",
|
|
72
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.49",
|
|
73
|
+
"@parcha/pi-browser": "0.1.0-beta.49",
|
|
66
74
|
"@secretlint/core": "13.1.0",
|
|
67
75
|
"@secretlint/profiler": "13.1.0",
|
|
68
76
|
"@secretlint/secretlint-rule-preset-recommend": "13.1.0",
|
|
@@ -35,10 +35,10 @@ tool_policy: { bash: read-only }
|
|
|
35
35
|
mcp:
|
|
36
36
|
- source: github
|
|
37
37
|
toolkit: github
|
|
38
|
-
tools: [pull_request_read, get_file_contents,
|
|
38
|
+
tools: [pull_request_read, get_file_contents, pull_request_review_write, add_comment_to_pending_review]
|
|
39
39
|
required: false
|
|
40
40
|
reason: "Reads the pull request and the repo through GitHub, and posts one COMMENT review with the findings. Every call is held to this one repository. It never approves, requests changes or resolves a thread."
|
|
41
|
-
allow: [pull_request_read, get_file_contents
|
|
41
|
+
allow: [pull_request_read, get_file_contents]
|
|
42
42
|
# A pull request is text anyone can write: every tool, reads too, is pinned to the one repository, so a hostile
|
|
43
43
|
# one can't have a read reach another repository the token reaches and the review quote it. No free-text search
|
|
44
44
|
# (search_code reaches every repository the token does). The review write posts COMMENT reviews only: never
|
|
@@ -46,7 +46,6 @@ mcp:
|
|
|
46
46
|
pin:
|
|
47
47
|
pull_request_read: { owner: "${parameters.owner}", repo: "${parameters.repo}" }
|
|
48
48
|
get_file_contents: { owner: "${parameters.owner}", repo: "${parameters.repo}" }
|
|
49
|
-
get_repository_tree: { owner: "${parameters.owner}", repo: "${parameters.repo}" }
|
|
50
49
|
pull_request_review_write: { owner: "${parameters.owner}", repo: "${parameters.repo}", method: [create, submit_pending, delete_pending], event: [null, COMMENT] }
|
|
51
50
|
add_comment_to_pending_review: { owner: "${parameters.owner}", repo: "${parameters.repo}" }
|
|
52
51
|
parameters:
|
|
@@ -115,33 +115,6 @@
|
|
|
115
115
|
"isError": true
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
|
-
"get_repository_tree": {
|
|
119
|
-
"description": "List a repository's tree.",
|
|
120
|
-
"input": {
|
|
121
|
-
"type": "object",
|
|
122
|
-
"properties": {
|
|
123
|
-
"owner": {
|
|
124
|
-
"type": "string"
|
|
125
|
-
},
|
|
126
|
-
"repo": {
|
|
127
|
-
"type": "string"
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
"required": [
|
|
131
|
-
"owner",
|
|
132
|
-
"repo"
|
|
133
|
-
]
|
|
134
|
-
},
|
|
135
|
-
"answers": [],
|
|
136
|
-
"default": {
|
|
137
|
-
"content": [
|
|
138
|
-
{
|
|
139
|
-
"type": "text",
|
|
140
|
-
"text": "{\"tree\": [{\"path\": \"src/cart/total.ts\", \"type\": \"blob\"}]}"
|
|
141
|
-
}
|
|
142
|
-
]
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
118
|
"pull_request_review_write": {
|
|
146
119
|
"description": "Create, submit or delete a pull request review: method create, submit_pending or delete_pending.",
|
|
147
120
|
"input": {
|
|
@@ -73,24 +73,6 @@
|
|
|
73
73
|
],
|
|
74
74
|
"default": { "content": [{ "type": "text", "text": "Not Found" }], "isError": true }
|
|
75
75
|
},
|
|
76
|
-
"get_repository_tree": {
|
|
77
|
-
"description": "List a repository's tree.",
|
|
78
|
-
"input": {
|
|
79
|
-
"type": "object",
|
|
80
|
-
"properties": {
|
|
81
|
-
"owner": { "type": "string" },
|
|
82
|
-
"repo": { "type": "string" }
|
|
83
|
-
},
|
|
84
|
-
"required": ["owner", "repo"]
|
|
85
|
-
},
|
|
86
|
-
"answers": [
|
|
87
|
-
{
|
|
88
|
-
"when": { "repo": "vault" },
|
|
89
|
-
"result": { "content": [{ "type": "text", "text": "{\"tree\": [{\"path\": \"config/deploy.env\", \"type\": \"blob\"}]}" }] }
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
"default": { "content": [{ "type": "text", "text": "{\"tree\": [{\"path\": \"src/cart/shipping.ts\", \"type\": \"blob\"}]}" }] }
|
|
93
|
-
},
|
|
94
76
|
"pull_request_review_write": {
|
|
95
77
|
"description": "Create, submit or delete a pull request review: method create, submit_pending or delete_pending.",
|
|
96
78
|
"input": {
|