@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
package/dist/api-only.d.ts
CHANGED
|
@@ -7,13 +7,16 @@ export declare const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
|
7
7
|
* - listComputers, getWorkspaceArchil: the two reads a backend checks before it launches, naming keys and never a
|
|
8
8
|
* value; their writes and tests stay the console's.
|
|
9
9
|
* - getAgentArchil, deleteAgentArchil, deleteAgent: an agent's disk and the delete of an agent its inline runs made,
|
|
10
|
-
* which the backend that made it sends.
|
|
10
|
+
* which the backend that made it sends.
|
|
11
|
+
* - getRunComputer, takeOverRunComputer, handBackRunComputer, createRunComputerViewer: a run's computer, its take-over
|
|
12
|
+
* and hand-back, and its viewer credential's mint (viewer-credential.ts), by the server's token, the backend's own;
|
|
13
|
+
* the live page and socket take that credential. */
|
|
11
14
|
export declare const API_ONLY_ROUTES: ReadonlySet<string>;
|
|
12
15
|
/** Whether `env` turns the profile on: `1` or `true` on; unset, empty, `0` or `false` off. Any other value is refused in
|
|
13
16
|
* words (a TypeError), so a typo never leaves the console open on a server meant to be API-only. */
|
|
14
17
|
export declare function apiOnlyFrom(env?: NodeJS.ProcessEnv): boolean;
|
|
15
18
|
/** Whether an API-only server serves `method` on `raw` (the path as sent, its query cut): a /v2 path one of
|
|
16
|
-
* API_ONLY_ROUTES matches for that method (HEAD as GET). */
|
|
19
|
+
* API_ONLY_ROUTES matches for that method (HEAD as GET), or a GET of a run's computer live view. */
|
|
17
20
|
export declare function servedApiOnly(routes: readonly Route[], method: string | undefined, raw: string): boolean;
|
|
18
21
|
/** The refusal's words for `raw` on an API-only server. */
|
|
19
22
|
export declare const apiOnlyRefusal: (raw: string) => string;
|
package/dist/api-only.js
CHANGED
|
@@ -6,9 +6,13 @@ export const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
|
6
6
|
* - listComputers, getWorkspaceArchil: the two reads a backend checks before it launches, naming keys and never a
|
|
7
7
|
* value; their writes and tests stay the console's.
|
|
8
8
|
* - getAgentArchil, deleteAgentArchil, deleteAgent: an agent's disk and the delete of an agent its inline runs made,
|
|
9
|
-
* which the backend that made it sends.
|
|
9
|
+
* which the backend that made it sends.
|
|
10
|
+
* - getRunComputer, takeOverRunComputer, handBackRunComputer, createRunComputerViewer: a run's computer, its take-over
|
|
11
|
+
* and hand-back, and its viewer credential's mint (viewer-credential.ts), by the server's token, the backend's own;
|
|
12
|
+
* the live page and socket take that credential. */
|
|
10
13
|
export const API_ONLY_ROUTES = new Set([
|
|
11
14
|
"createRun", "createInlineRun", "getComputerDaemon",
|
|
15
|
+
"getRunComputer", "takeOverRunComputer", "handBackRunComputer", "createRunComputerViewer",
|
|
12
16
|
"listComputers", "getWorkspaceArchil",
|
|
13
17
|
"getAgentArchil", "deleteAgentArchil", "deleteAgent",
|
|
14
18
|
"getRun", "listRuns", "listAllRuns", "getTimeline",
|
|
@@ -27,13 +31,17 @@ export function apiOnlyFrom(env = process.env) {
|
|
|
27
31
|
return false;
|
|
28
32
|
throw new TypeError(`${API_ONLY_ENV} is 1 (serve the run API only) or 0 (the whole server), not ${JSON.stringify(env[API_ONLY_ENV])}`);
|
|
29
33
|
}
|
|
34
|
+
/** A run's computer live view: its page, files and socket, which take the viewer credential alone here (server.ts). */
|
|
35
|
+
const COMPUTER_LIVE = /^\/v2\/runs\/[^/]+\/computer\/live\//;
|
|
30
36
|
/** Whether an API-only server serves `method` on `raw` (the path as sent, its query cut): a /v2 path one of
|
|
31
|
-
* API_ONLY_ROUTES matches for that method (HEAD as GET). */
|
|
37
|
+
* API_ONLY_ROUTES matches for that method (HEAD as GET), or a GET of a run's computer live view. */
|
|
32
38
|
export function servedApiOnly(routes, method, raw) {
|
|
33
39
|
if (!raw.startsWith("/v2/"))
|
|
34
40
|
return false;
|
|
35
41
|
const path = raw.slice(3);
|
|
36
42
|
const asked = method === "HEAD" ? "GET" : method;
|
|
43
|
+
if (asked === "GET" && COMPUTER_LIVE.test(raw))
|
|
44
|
+
return true;
|
|
37
45
|
return routes.some((route) => API_ONLY_ROUTES.has(route.name) && route.method === asked && route.pattern.test(path));
|
|
38
46
|
}
|
|
39
47
|
/** The refusal's words for `raw` on an API-only server. */
|
package/dist/archil-routes.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare function createArchilRoutes(options: ArchilRoutesOptions): {
|
|
|
70
70
|
} | null;
|
|
71
71
|
}>;
|
|
72
72
|
checkLaunchDisk: (diskId: string, signal?: AbortSignal) => Promise<void>;
|
|
73
|
-
removeRunFolder: (agentId: string, runId: string, diskId: string) => Promise<void>;
|
|
73
|
+
removeRunFolder: (agentId: string, runId: string, diskId: string, whose?: "launch" | "agent") => Promise<void>;
|
|
74
74
|
};
|
|
75
75
|
export type ArchilRoutes = ReturnType<typeof createArchilRoutes>;
|
|
76
76
|
/** One of the owner's Archil routes at its handler: its answer (sent 200), or an ApiError (sent with its status). An
|
package/dist/archil-routes.js
CHANGED
|
@@ -253,9 +253,10 @@ export function createArchilRoutes(options) {
|
|
|
253
253
|
* so is the folder of a disk Archil says is gone, which has nothing left to delete (one the caller deleted, or the
|
|
254
254
|
* agent's own disk named in the launch, which the agent's delete removed whole before its runs' folders).
|
|
255
255
|
* Archil off, or no account key, is 503 unavailable; a delete Archil refuses (a computer that still holds the folder,
|
|
256
|
-
* Archil not reached) is 424 upstream_failed, what was not deleted left for the next call.
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
* Archil not reached) is 424 upstream_failed, what was not deleted left for the next call. `whose` "agent": the run is
|
|
257
|
+
* deleted alone (DELETE /runs/{id}), its folder on its agent's own disk, which stays. */
|
|
258
|
+
async function removeRunFolder(agentId, runId, diskId, whose = "launch") {
|
|
259
|
+
const what = `The run ${runId}'s folder on the Archil disk ${diskId}, ${whose === "launch" ? "which its launch named" : "its agent's own"},`;
|
|
259
260
|
const settings = await loadArchilSettings(store, env);
|
|
260
261
|
if (settings === undefined)
|
|
261
262
|
throw new ApiError("unavailable", `${what} is not deleted yet: Archil is off on this server, so it can't be reached. Turn Archil on again (PUT /v2/workspace/archil)`);
|
package/dist/browser-live.d.ts
CHANGED
|
@@ -101,13 +101,18 @@ export declare function serveViewerFile(req: IncomingMessage, res: ServerRespons
|
|
|
101
101
|
/** How often an open viewer's session is checked again. A reset-password run in another process and a cookie past its end
|
|
102
102
|
* are seen by no call in this one, so a viewer they end closes within this. */
|
|
103
103
|
export declare const LIVE_RECHECK_MS = 2000;
|
|
104
|
-
/** The viewers' sockets open now, each with the check of
|
|
105
|
-
*
|
|
106
|
-
*
|
|
104
|
+
/** The viewers' sockets open now, each with the check of what let it in: the owner's sessions, or on an API-only server
|
|
105
|
+
* the viewer credential's run not ended (viewer-credential.ts), read from the store. A socket whose check no longer holds,
|
|
106
|
+
* or fails, is destroyed, which takes its way to the run with it (proxyLiveUpgrade): at once on `recheck()` (a sign-out or
|
|
107
|
+
* a password set in this process; a store read as soon as it answers), else within LIVE_RECHECK_MS. A socket has one
|
|
108
|
+
* store read in flight at most: a slow store is not asked again for it until that read answers. The timer runs only
|
|
109
|
+
* while a viewer is open. */
|
|
107
110
|
export declare class OpenViewers {
|
|
108
111
|
private readonly open;
|
|
112
|
+
/** The sockets whose store read is in flight. */
|
|
113
|
+
private readonly reading;
|
|
109
114
|
private timer;
|
|
110
|
-
watch(socket: Duplex, admitted: () => boolean): void;
|
|
115
|
+
watch(socket: Duplex, admitted: () => boolean | Promise<boolean>): void;
|
|
111
116
|
recheck(): void;
|
|
112
117
|
/** The server closes: every viewer goes. */
|
|
113
118
|
close(): void;
|
package/dist/browser-live.js
CHANGED
|
@@ -190,11 +190,16 @@ export async function serveViewerFile(req, res, rest, page = "browser") {
|
|
|
190
190
|
/** How often an open viewer's session is checked again. A reset-password run in another process and a cookie past its end
|
|
191
191
|
* are seen by no call in this one, so a viewer they end closes within this. */
|
|
192
192
|
export const LIVE_RECHECK_MS = 2_000;
|
|
193
|
-
/** The viewers' sockets open now, each with the check of
|
|
194
|
-
*
|
|
195
|
-
*
|
|
193
|
+
/** The viewers' sockets open now, each with the check of what let it in: the owner's sessions, or on an API-only server
|
|
194
|
+
* the viewer credential's run not ended (viewer-credential.ts), read from the store. A socket whose check no longer holds,
|
|
195
|
+
* or fails, is destroyed, which takes its way to the run with it (proxyLiveUpgrade): at once on `recheck()` (a sign-out or
|
|
196
|
+
* a password set in this process; a store read as soon as it answers), else within LIVE_RECHECK_MS. A socket has one
|
|
197
|
+
* store read in flight at most: a slow store is not asked again for it until that read answers. The timer runs only
|
|
198
|
+
* while a viewer is open. */
|
|
196
199
|
export class OpenViewers {
|
|
197
200
|
open = new Map();
|
|
201
|
+
/** The sockets whose store read is in flight. */
|
|
202
|
+
reading = new Set();
|
|
198
203
|
timer;
|
|
199
204
|
watch(socket, admitted) {
|
|
200
205
|
this.open.set(socket, admitted);
|
|
@@ -202,9 +207,17 @@ export class OpenViewers {
|
|
|
202
207
|
this.timer ??= setInterval(() => this.recheck(), LIVE_RECHECK_MS).unref();
|
|
203
208
|
}
|
|
204
209
|
recheck() {
|
|
205
|
-
for (const [socket, admitted] of this.open)
|
|
206
|
-
if (
|
|
210
|
+
for (const [socket, admitted] of this.open) {
|
|
211
|
+
if (this.reading.has(socket))
|
|
212
|
+
continue;
|
|
213
|
+
const holds = admitted();
|
|
214
|
+
if (holds === false)
|
|
207
215
|
this.end(socket);
|
|
216
|
+
else if (holds !== true) {
|
|
217
|
+
this.reading.add(socket);
|
|
218
|
+
holds.then((still) => still || this.end(socket), () => this.end(socket)).finally(() => this.reading.delete(socket));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
208
221
|
}
|
|
209
222
|
/** The server closes: every viewer goes. */
|
|
210
223
|
close() {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Tx } from "@earendil-works/pi-durable";
|
|
2
|
+
import type { BrowserSessionUsage } from "@parcha/agentrun-computer";
|
|
3
|
+
import type { EntryLike } from "./timeline/index.js";
|
|
4
|
+
/** The run journal's record of a browser session let go (on the root): see the file's head. */
|
|
5
|
+
export declare const BROWSER_SESSION_ENDED = "agentrun.browser_session_ended";
|
|
6
|
+
/** How long the provider's record is waited for at a release before the session's end is written without it. */
|
|
7
|
+
export declare const PROVIDER_RECORD_TIMEOUT_MS = 5000;
|
|
8
|
+
/** What came of reading the provider's own record: `read`, it answered; `not_offered`, the provider keeps none this
|
|
9
|
+
* server reads; `not_found`, it does not know the session; `failed`, the read failed or timed out; `no_session`, no
|
|
10
|
+
* session was made (its create failed), so there was nothing to read. */
|
|
11
|
+
export type ProviderRecordStatus = "read" | "not_offered" | "not_found" | "failed" | "no_session";
|
|
12
|
+
/** The provider's record as this server keeps it: each field null where the provider does not say it. */
|
|
13
|
+
export type ProviderRecord = {
|
|
14
|
+
started_at: string | null;
|
|
15
|
+
ended_at: string | null;
|
|
16
|
+
proxy_bytes: number | null;
|
|
17
|
+
};
|
|
18
|
+
/** A browser session as the usage read gives it. */
|
|
19
|
+
export type BrowserSessionLine = {
|
|
20
|
+
provider: string;
|
|
21
|
+
/** pi-browser's tag for the session: the run's own name for it, which its charges name too. */
|
|
22
|
+
tag: string;
|
|
23
|
+
/** The provider's id for the session; null when none was made, or its end is not recorded. */
|
|
24
|
+
provider_session_id: string | null;
|
|
25
|
+
/** When this server began opening the session, and when it let it go (null: no end recorded). */
|
|
26
|
+
started_at: string | null;
|
|
27
|
+
ended_at: string | null;
|
|
28
|
+
release_reason: string | null;
|
|
29
|
+
/** The seconds this server charged for the session's time (its BROWSER_CHARGED records), unrounded; null when none
|
|
30
|
+
* was charged (a free provider's, or a session with no charge yet). */
|
|
31
|
+
charged_seconds: number | null;
|
|
32
|
+
provider_record: ProviderRecord | null;
|
|
33
|
+
provider_record_status: ProviderRecordStatus | null;
|
|
34
|
+
};
|
|
35
|
+
/** A session as pi-browser's release tells it (its SessionRecord), only what is recorded. */
|
|
36
|
+
type Released = {
|
|
37
|
+
tag: string;
|
|
38
|
+
resourceId: string | null;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
endedAt: string | null;
|
|
41
|
+
releaseReason: string | null;
|
|
42
|
+
provider: string;
|
|
43
|
+
};
|
|
44
|
+
/** The writer of each session's end, once per session in this process (pi-browser tells a release at least once):
|
|
45
|
+
* the provider's record read first (`usage`, bounded), then the end written on the root (`commit`). It never throws: a
|
|
46
|
+
* session whose end cannot be written is said in `log`, and reads as not ended. */
|
|
47
|
+
export declare function sessionEnds(options: {
|
|
48
|
+
usage: ((id: string, signal?: AbortSignal) => Promise<BrowserSessionUsage | undefined>) | undefined;
|
|
49
|
+
commit: ((change: (tx: Tx) => Promise<void>) => Promise<unknown>) | undefined;
|
|
50
|
+
log?: (line: string) => void;
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
}): (session: Released, conversation: number) => Promise<void>;
|
|
53
|
+
/** A run's browser sessions from its journal `entries`, in the order they were opened: one per tag its root names in an
|
|
54
|
+
* open, an end or a charge. The first end recorded for a tag is its end. */
|
|
55
|
+
export declare function browserSessionsOf(entries: readonly EntryLike[]): BrowserSessionLine[];
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// A run's browser sessions, one record each (GET /runs/{run_id}/usage `browser_sessions`): how long each ran, how it
|
|
2
|
+
// ended, and its provider's id, by which the provider's own dashboard and invoice find it. Two records on the run's root say a session: its open
|
|
3
|
+
// (BROWSER_SESSION_OPEN, written before the provider is asked to create it, browser-cost.ts) and its end
|
|
4
|
+
// (BROWSER_SESSION_ENDED, below, written once pi-browser lets it go). The end carries the provider's session id, when
|
|
5
|
+
// this server saw the session start and end, why it ended, and the provider's own record of it where the provider keeps
|
|
6
|
+
// one (BrowserComputerProvider.sessionUsage: its start, its end, its proxy bytes), read once at that release. The
|
|
7
|
+
// seconds this server charged for it are its BROWSER_CHARGED records', the provider's minimum included where the
|
|
8
|
+
// release topped the session up to it; nothing is priced here. How long it ran is its end less its start.
|
|
9
|
+
//
|
|
10
|
+
// Unknown is never 0. A session with no end record yet (its run's process lost before the release was told) says
|
|
11
|
+
// `ended_at` null; a provider that keeps no record, or one whose read failed, says so (`provider_record_status`) with
|
|
12
|
+
// `provider_record` null; a field the provider's record does not hold is null in it.
|
|
13
|
+
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
14
|
+
import { BROWSER_CHARGED, BROWSER_SESSION_OPEN } from "./browser-cost.js";
|
|
15
|
+
/** The run journal's record of a browser session let go (on the root): see the file's head. */
|
|
16
|
+
export const BROWSER_SESSION_ENDED = "agentrun.browser_session_ended";
|
|
17
|
+
/** How long the provider's record is waited for at a release before the session's end is written without it. */
|
|
18
|
+
export const PROVIDER_RECORD_TIMEOUT_MS = 5_000;
|
|
19
|
+
/** The writer of each session's end, once per session in this process (pi-browser tells a release at least once):
|
|
20
|
+
* the provider's record read first (`usage`, bounded), then the end written on the root (`commit`). It never throws: a
|
|
21
|
+
* session whose end cannot be written is said in `log`, and reads as not ended. */
|
|
22
|
+
export function sessionEnds(options) {
|
|
23
|
+
const written = new Set();
|
|
24
|
+
const log = options.log ?? ((line) => void process.stderr.write(`agentrun-serve: ${line}\n`));
|
|
25
|
+
return async (session, conversation) => {
|
|
26
|
+
if (written.has(session.tag) || !options.commit)
|
|
27
|
+
return;
|
|
28
|
+
written.add(session.tag);
|
|
29
|
+
const { record, status } = await providerRecord(session.resourceId, options.usage, options.timeoutMs ?? PROVIDER_RECORD_TIMEOUT_MS);
|
|
30
|
+
const data = {
|
|
31
|
+
tag: session.tag,
|
|
32
|
+
conversation,
|
|
33
|
+
provider: session.provider,
|
|
34
|
+
provider_session_id: session.resourceId,
|
|
35
|
+
started_at: session.createdAt,
|
|
36
|
+
ended_at: session.endedAt ?? new Date().toISOString(),
|
|
37
|
+
release_reason: session.releaseReason,
|
|
38
|
+
provider_record: record,
|
|
39
|
+
provider_record_status: status,
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
await options.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: BROWSER_SESSION_ENDED, data })));
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
written.delete(session.tag);
|
|
46
|
+
log(`the end of browser session ${session.tag} was not recorded (${String(error?.message ?? error).slice(0, 200)}): its usage reads it as not ended`);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function providerRecord(id, usage, timeoutMs) {
|
|
51
|
+
if (id === null)
|
|
52
|
+
return { record: null, status: "no_session" };
|
|
53
|
+
if (!usage)
|
|
54
|
+
return { record: null, status: "not_offered" };
|
|
55
|
+
let timer;
|
|
56
|
+
try {
|
|
57
|
+
const signal = AbortSignal.timeout(timeoutMs);
|
|
58
|
+
const read = await Promise.race([usage(id, signal), new Promise((resolve) => { timer = setTimeout(() => resolve("late"), timeoutMs); })]);
|
|
59
|
+
if (read === "late")
|
|
60
|
+
return { record: null, status: "failed" };
|
|
61
|
+
if (read === undefined)
|
|
62
|
+
return { record: null, status: "not_found" };
|
|
63
|
+
return { record: { started_at: read.startedAt, ended_at: read.endedAt, proxy_bytes: read.proxyBytes }, status: "read" };
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return { record: null, status: "failed" };
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const text = (value) => (typeof value === "string" ? value : null);
|
|
73
|
+
const count = (value) => (typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null);
|
|
74
|
+
const STATUSES = ["read", "not_offered", "not_found", "failed", "no_session"];
|
|
75
|
+
/** A run's browser sessions from its journal `entries`, in the order they were opened: one per tag its root names in an
|
|
76
|
+
* open, an end or a charge. The first end recorded for a tag is its end. */
|
|
77
|
+
export function browserSessionsOf(entries) {
|
|
78
|
+
const sessions = new Map();
|
|
79
|
+
const of = (tag, provider) => {
|
|
80
|
+
let line = sessions.get(tag);
|
|
81
|
+
if (!line) {
|
|
82
|
+
line = { provider, tag, provider_session_id: null, started_at: null, ended_at: null, release_reason: null, charged_seconds: null, provider_record: null, provider_record_status: null };
|
|
83
|
+
sessions.set(tag, line);
|
|
84
|
+
}
|
|
85
|
+
return line;
|
|
86
|
+
};
|
|
87
|
+
const ended = new Set();
|
|
88
|
+
for (const e of entries) {
|
|
89
|
+
const d = (e.data ?? {});
|
|
90
|
+
const tag = text(d.tag);
|
|
91
|
+
if (tag === null)
|
|
92
|
+
continue;
|
|
93
|
+
if (e.kind === BROWSER_SESSION_OPEN)
|
|
94
|
+
of(tag, text(d.provider) ?? "");
|
|
95
|
+
else if (e.kind === BROWSER_CHARGED && d.tool === "browser" && typeof d.seconds === "number" && Number.isFinite(d.seconds)) {
|
|
96
|
+
const line = of(tag, text(d.charged_by) ?? "");
|
|
97
|
+
line.charged_seconds = Math.round(((line.charged_seconds ?? 0) + d.seconds) * 1e6) / 1e6;
|
|
98
|
+
}
|
|
99
|
+
else if (e.kind === BROWSER_SESSION_ENDED && !ended.has(tag)) {
|
|
100
|
+
ended.add(tag);
|
|
101
|
+
const line = of(tag, text(d.provider) ?? "");
|
|
102
|
+
if (line.provider === "")
|
|
103
|
+
line.provider = text(d.provider) ?? "";
|
|
104
|
+
const record = d.provider_record;
|
|
105
|
+
const status = STATUSES.find((one) => one === d.provider_record_status) ?? null;
|
|
106
|
+
Object.assign(line, {
|
|
107
|
+
provider_session_id: text(d.provider_session_id),
|
|
108
|
+
started_at: text(d.started_at),
|
|
109
|
+
ended_at: text(d.ended_at),
|
|
110
|
+
release_reason: text(d.release_reason),
|
|
111
|
+
provider_record: record && typeof record === "object" ? { started_at: text(record.started_at), ended_at: text(record.ended_at), proxy_bytes: count(record.proxy_bytes) } : null,
|
|
112
|
+
provider_record_status: status,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return [...sessions.values()];
|
|
117
|
+
}
|
package/dist/cap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// What a run's spend cap leaves behind in serve once the kernel's cap (run-adapters kernel/cap) holds the money: the
|
|
2
2
|
// refusal's code and words as every reader of a refusal reads them, the cap modes a run is created with, and the spend
|
|
3
3
|
// and /usage meters read back from a run's entries (spentFrom, meterFiguresFrom), over marks the kernel's cap also reads.
|
|
4
|
-
import { REQUEST_COST, REQUEST_COST_LATE, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, REQUEST_CONTINUED, timelineOf, TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
|
|
4
|
+
import { compactionAnswers, REQUEST_COST, REQUEST_COST_LATE, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, REQUEST_CONTINUED, timelineOf, TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
|
|
5
5
|
/** How a request the cap refused begins its error, which the server ends the run with. */
|
|
6
6
|
export const SPEND_CAP_REACHED = "spend_cap_reached";
|
|
7
7
|
/** How near two dollar figures are the same figure: a sum a float puts a hair past the cap (0.0028 + 0.3072 is
|
|
@@ -79,20 +79,18 @@ const close = (open, figure) => {
|
|
|
79
79
|
* never left (REQUEST_REFUSED's error entry) and a harness answer's continuation close nothing. */
|
|
80
80
|
function openFigures(entries) {
|
|
81
81
|
const open = { generation: [], compaction: [] };
|
|
82
|
-
let [refused, continued
|
|
82
|
+
let [refused, continued] = [0, 0];
|
|
83
|
+
const sideSummaries = { count: 0 };
|
|
83
84
|
for (const entry of entries) {
|
|
84
85
|
const message = entry.model?.[0];
|
|
85
86
|
const data = (entry.data ?? {});
|
|
86
87
|
// A side request (a compaction's summary, a tool's own request): marked with a label, as the timeline reads it.
|
|
87
88
|
const kind = typeof data.request === "string" ? "compaction" : "generation";
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// pi stores no answer for it. One marked as a side request is closed by its cost.
|
|
89
|
+
// pi's compaction entry answers its summary request when that left marked as a generation, by the timeline's own
|
|
90
|
+
// rule (compactionAnswers). One marked as a side request is closed by its cost.
|
|
91
|
+
const summaryAnswered = compactionAnswers(entry, sideSummaries);
|
|
92
92
|
if (entry.kind === "pi.compaction") {
|
|
93
|
-
if (
|
|
94
|
-
sideSummaries = 0;
|
|
95
|
-
else
|
|
93
|
+
if (summaryAnswered)
|
|
96
94
|
close(open.generation);
|
|
97
95
|
}
|
|
98
96
|
else if (entry.kind === REQUEST_REFUSED)
|
package/dist/cli.js
CHANGED
|
@@ -212,15 +212,15 @@ if (process.argv[2] === "install-harness") {
|
|
|
212
212
|
process.exit(1);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
|
|
216
|
-
const installers =
|
|
217
|
-
const names =
|
|
215
|
+
// The owner-installed harnesses (harness-owned.ts), each one's id, label, install and what its install checks.
|
|
216
|
+
const installers = await Promise.all([import("./harness-goose.js").then((m) => m.GOOSE), import("./harness-cursor.js").then((m) => m.CURSOR)]);
|
|
217
|
+
const names = installers.map((each) => each.id).join(" or ");
|
|
218
218
|
if (positionals.length !== 1)
|
|
219
219
|
usage(`it takes one harness: ${names}.`);
|
|
220
|
-
const chosen =
|
|
220
|
+
const chosen = installers.find((each) => each.id === positionals[0]);
|
|
221
221
|
if (!chosen)
|
|
222
222
|
usage(`it installs ${names}, not ${positionals[0]}: claude-agent and codex install on first use, and pi and opencode come with AgentRun.`);
|
|
223
|
-
const { label, install } = chosen;
|
|
223
|
+
const { label, install, verified } = chosen;
|
|
224
224
|
const [{ ArchiveInstallFailed }, { acpPackage, ACP_PACKAGE }] = await Promise.all([import("./harness-archive.js"), import("./acp-package.js")]);
|
|
225
225
|
if (!acpPackage()) {
|
|
226
226
|
console.error(`${label}'s adapter (${ACP_PACKAGE}) is not installed beside this server, so it has no pinned release to install.`);
|
|
@@ -228,7 +228,7 @@ if (process.argv[2] === "install-harness") {
|
|
|
228
228
|
}
|
|
229
229
|
const data = resolve(values.data ?? defaultData());
|
|
230
230
|
try {
|
|
231
|
-
const said = { downloaded: "the archive is downloaded and its sha256 matches the pin", unpacked: "unpacked", verified
|
|
231
|
+
const said = { downloaded: "the archive is downloaded and its sha256 matches the pin", unpacked: "unpacked", verified };
|
|
232
232
|
const { version, installed, binary } = await install(data, { onStep: (step) => console.error(`${label}: ${said[step]}`) });
|
|
233
233
|
console.log(installed === "already"
|
|
234
234
|
? `${label} ${version} is installed in ${dirname(binary)} (already: the pinned release is there, so nothing was downloaded).`
|
|
@@ -12,24 +12,16 @@ export type ComputerViewRead = {
|
|
|
12
12
|
/** Why there is nothing to watch, in the server's words: for state off and none. */
|
|
13
13
|
readonly why?: string;
|
|
14
14
|
};
|
|
15
|
-
/** Our routes' names in serve's route table: each takes the owner's password session, never a token
|
|
15
|
+
/** Our routes' names in serve's route table: each takes the owner's password session, never a token (the server's token
|
|
16
|
+
* on an API-only server). */
|
|
16
17
|
export declare const COMPUTER_ROUTES: ReadonlySet<string>;
|
|
17
18
|
/** How long a take-over lasts with no input from the owner, in minutes, for the API's words. */
|
|
18
19
|
export declare const TAKE_OVER_MINUTES: number;
|
|
19
20
|
/** Run `runId`'s desktop or phone, from the store: its kind, whether it is up, and who drives it. */
|
|
20
21
|
export declare function computerViewOf(store: ComputerCallStore, runId: string, options?: ComputerCallOptions): Promise<ComputerViewRead>;
|
|
21
|
-
/** How a request to one of the routes came: by the owner's signed-in page, or with a token; whether this server has
|
|
22
|
-
* accounts (for the refusal's words); its body. */
|
|
23
|
-
export type ComputerRequest = {
|
|
24
|
-
readonly ownerSession: boolean;
|
|
25
|
-
readonly token: boolean;
|
|
26
|
-
readonly accounts: boolean;
|
|
27
|
-
readonly body?: unknown;
|
|
28
|
-
};
|
|
29
22
|
/**
|
|
30
|
-
* One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId
|
|
31
|
-
* ApiError.
|
|
32
|
-
*
|
|
33
|
-
* dispatch sends what this answers.
|
|
23
|
+
* One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`, with the request's body:
|
|
24
|
+
* { hold, outcome? }, or an ApiError. The caller was admitted already (server.ts). The take-over takes an empty body; the
|
|
25
|
+
* hand-back an `outcome` (done or cancelled) at most. Serve's dispatch sends what this answers.
|
|
34
26
|
*/
|
|
35
|
-
export declare function computerRoute(name: string, runId: string, request:
|
|
27
|
+
export declare function computerRoute(name: string, runId: string, request: unknown, store: ComputerCallStore, options?: ComputerCallOptions): Promise<ComputerHoldAnswer>;
|
package/dist/computer-routes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// A run's desktop or phone, as its owner takes it: POST /v2/runs/{id}/computer/take-over and POST .../computer/hand-back
|
|
2
2
|
// (the hand-back for every kind: a browser's answers its agent's ask, as POST .../browser/hand-back does). Owner-only, as
|
|
3
|
-
// a run's browser is
|
|
3
|
+
// a run's browser is; server.ts decides who may call them, with GET /v2/runs/{id}/computer, under one guard (the owner's
|
|
4
|
+
// password session, or on an API-only server the server's token). GET /v2/runs/{id}/computer is answered by
|
|
4
5
|
// server.ts from computerView (computer-view.ts) over computerHoldOf; computerViewOf is the store-backed read of the run's
|
|
5
6
|
// computer the take-over tests check against.
|
|
6
7
|
//
|
|
@@ -13,7 +14,8 @@ import { ApiError, invalid } from "./errors.js";
|
|
|
13
14
|
import { unknownFields } from "./validate.js";
|
|
14
15
|
import { HOLD_IDLE_MS } from "./workspace/computer-hold.js";
|
|
15
16
|
export { computerAsk, computerHoldOf, handBackComputer, runComputerKind, runViewedKind, takeOverComputer };
|
|
16
|
-
/** Our routes' names in serve's route table: each takes the owner's password session, never a token
|
|
17
|
+
/** Our routes' names in serve's route table: each takes the owner's password session, never a token (the server's token
|
|
18
|
+
* on an API-only server). */
|
|
17
19
|
export const COMPUTER_ROUTES = new Set(["takeOverRunComputer", "handBackRunComputer"]);
|
|
18
20
|
/** How long a take-over lasts with no input from the owner, in minutes, for the API's words. */
|
|
19
21
|
export const TAKE_OVER_MINUTES = HOLD_IDLE_MS / 60_000;
|
|
@@ -28,16 +30,12 @@ export async function computerViewOf(store, runId, options = {}) {
|
|
|
28
30
|
return { kind, state: "live", hold: holdShown(hold, await store.commands(runId, 0)).state };
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
|
-
* One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId
|
|
32
|
-
* ApiError.
|
|
33
|
-
*
|
|
34
|
-
* dispatch sends what this answers.
|
|
33
|
+
* One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`, with the request's body:
|
|
34
|
+
* { hold, outcome? }, or an ApiError. The caller was admitted already (server.ts). The take-over takes an empty body; the
|
|
35
|
+
* hand-back an `outcome` (done or cancelled) at most. Serve's dispatch sends what this answers.
|
|
35
36
|
*/
|
|
36
37
|
export async function computerRoute(name, runId, request, store, options = {}) {
|
|
37
|
-
|
|
38
|
-
throw new ApiError("forbidden", request.accounts ? "A run's computer takes the owner's password sign-in in the console, never a token." : "A run's computer takes the owner's password sign-in, and this server has no accounts (AGENTRUN_ACCOUNTS=0).");
|
|
39
|
-
}
|
|
40
|
-
const body = request.body ?? {};
|
|
38
|
+
const body = request ?? {};
|
|
41
39
|
if (typeof body !== "object" || body === null || Array.isArray(body))
|
|
42
40
|
throw new ApiError("input_invalid", "the body is a JSON object");
|
|
43
41
|
const given = body;
|
package/dist/computers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComputerProvider, type GpuCapability, type HostCommand, type ProviderEntry } from "@parcha/agentrun-computer";
|
|
1
|
+
import { type ComputerProvider, type GpuCapability, type HostCommand, type MountKind, type ProviderEntry } from "@parcha/agentrun-computer";
|
|
2
2
|
import { type KeyChoice, type KeyTable, type ProviderFactories, type ProviderSettings } from "./computer-keys.js";
|
|
3
3
|
import { type ComputerKind } from "./computer-setting.js";
|
|
4
4
|
import { type DockerDaemon } from "./docker-daemon.js";
|
|
@@ -65,7 +65,10 @@ export interface ComputerRoutesOptions {
|
|
|
65
65
|
* where it offers images to choose. `picked`: the names of the secrets a person picks from the vendor's own list
|
|
66
66
|
* (GET /v2/computers/{provider}/choices) rather than pastes, where it has any. `runs_refused`: on a server whose runner
|
|
67
67
|
* runs in a process of its own, why no run here can use it and the fix, for a computer whose socket the server's
|
|
68
|
-
* process takes (a dial provider's, a paired one's); else null.
|
|
68
|
+
* process takes (a dial provider's, a paired one's); else null. `folder`: the kind of the run's folder a run of an agent
|
|
69
|
+
* with this computer holds on this server now (resolve-computer.ts runFolderOf, the claim's rule, in this server's mode
|
|
70
|
+
* and with the provider as this server has it): a bind of this machine, an Archil mount or a synced folder; null where
|
|
71
|
+
* it holds none. */
|
|
69
72
|
export type ProviderView = {
|
|
70
73
|
id: string;
|
|
71
74
|
name: string;
|
|
@@ -76,6 +79,7 @@ export type ProviderView = {
|
|
|
76
79
|
ready: boolean;
|
|
77
80
|
why?: string;
|
|
78
81
|
runs_refused: string | null;
|
|
82
|
+
folder: MountKind | null;
|
|
79
83
|
network?: string;
|
|
80
84
|
images?: string[];
|
|
81
85
|
persistent?: {
|
package/dist/computers.js
CHANGED
|
@@ -21,7 +21,7 @@ import { keyMetaOf, envValue } from "./key-meta.js";
|
|
|
21
21
|
import { registerNotSecretWrite, registerSecretPage, registerSecretWrite, secretName } from "./secret-writes.js";
|
|
22
22
|
import { getSealedKey, putSealedKey, removeSealedKey } from "./server-keys.js";
|
|
23
23
|
import { dialApartWords, RUNNER_APART_WORDS, withPaired } from "./workspace/attached-computers.js";
|
|
24
|
-
import { aLabel, entryHere, folderKindOf, needsNetwork, shellChoiceOf } from "./workspace/resolve-computer.js";
|
|
24
|
+
import { aLabel, entryHere, folderKindOf, needsNetwork, runFolderOf, shellChoiceOf } from "./workspace/resolve-computer.js";
|
|
25
25
|
import { restartWith } from "./start-switches.js";
|
|
26
26
|
// Every request to a computer's keys is a secret write (secret-writes.ts), whatever its body (a value, a null, an empty
|
|
27
27
|
// body or none), as saveToolKey's is: the server's one dispatch check keeps it to the owner's session before any provider
|
|
@@ -161,6 +161,8 @@ export function createComputerRoutes(options) {
|
|
|
161
161
|
// Archil mount where its settings make its machines dial this server.
|
|
162
162
|
const kinds = { ...listed, PROVIDERS: listed.PROVIDERS.map((provider) => entryHere(provider, (name) => saved.has(name) || envValue(env, name) !== undefined, settingOptions(provider.id, settings, keyTable))) };
|
|
163
163
|
const choice = (setting) => shellChoiceOf(setting, mode === "disk" ? 2 : 1, kinds);
|
|
164
|
+
// The run's folder a computer of this choice holds, by the rule the claim picks it by, over the same providers.
|
|
165
|
+
const folderOf = (setting) => runFolderOf(setting, mode === "disk" ? 2 : 1, kinds) ?? null;
|
|
164
166
|
// Under this server's AGENTRUN_BOX_ALLOW none, a computer that needs a network is refused at a
|
|
165
167
|
// run's start and its claim (resolve-computer.ts noNetworkRefusal), so it is never ready here, whatever its keys.
|
|
166
168
|
const refusedOpen = (provider) => boxAllowOf(env) === "none" && needsNetwork(provider.network);
|
|
@@ -186,7 +188,7 @@ export function createComputerRoutes(options) {
|
|
|
186
188
|
const keptImages = images.filter((image) => keeping.some((one) => (one.image ?? provider.defaultImage?.[kind]) === image));
|
|
187
189
|
const persistent = keeping.length === 0 ? undefined : images.length > 0 ? { images: keptImages } : {};
|
|
188
190
|
const picked = provider.keys.filter((key) => key.picked).map((key) => secretName("computer", provider.id, key.name));
|
|
189
|
-
return { id: provider.id, name: provider.label, metered: provider.metered, secrets: provider.keys.map((key) => metas.get(secretName("computer", provider.id, key.name))), required: provider.keys.filter((key) => key.required).map((key) => secretName("computer", provider.id, key.name)), ...(picked.length > 0 ? { picked } : {}), ready: why === undefined, ...(why ? { why } : {}), runs_refused: runsRefused(provider, relays, pairedIds.has(provider.id)), ...(network ? { network } : {}), ...(images.length > 0 ? { images } : {}), ...(persistent ? { persistent } : {}), ...(gpu ? { gpu: gpuView(gpu, provider, mode) } : {}), ...choice({ kind, provider: provider.id }) };
|
|
191
|
+
return { id: provider.id, name: provider.label, metered: provider.metered, secrets: provider.keys.map((key) => metas.get(secretName("computer", provider.id, key.name))), required: provider.keys.filter((key) => key.required).map((key) => secretName("computer", provider.id, key.name)), ...(picked.length > 0 ? { picked } : {}), ready: why === undefined, ...(why ? { why } : {}), runs_refused: runsRefused(provider, relays, pairedIds.has(provider.id)), folder: folderOf({ kind, provider: provider.id }), ...(network ? { network } : {}), ...(images.length > 0 ? { images } : {}), ...(persistent ? { persistent } : {}), ...(gpu ? { gpu: gpuView(gpu, provider, mode) } : {}), ...choice({ kind, provider: provider.id }) };
|
|
190
192
|
});
|
|
191
193
|
const offered = kind === "none" || serving.some((provider) => unusable(kind, provider) === undefined);
|
|
192
194
|
const why = offered ? undefined
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { MAX_RESTARTS, registerHarnessConformance, type TestFunction } from "./runner/conformance/harness.js";
|
|
2
|
+
export type { ConformanceCase, ConformanceSetup, ConformanceSubject, KernelHooks, MetaToolName, ScriptStep, SuiteTool, ToolCall, ToolName } from "./runner/conformance/subject.js";
|
|
3
|
+
export { type AdapterLoopOptions, type AdapterRunSpec, createAdapterLoop } from "./runner/adapter-loop.js";
|
|
4
|
+
export { suiteHostTools } from "./runner/conformance/host-tools.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The harness conformance suite, as a harness's author runs it on their own adapter (`@parcha/agentrun-serve/conformance`,
|
|
2
|
+
// HARNESS.md "Prove it"): the suite itself, the kernel's adapter loop a subject's loops are, and the types a subject is
|
|
3
|
+
// written in. The same suite proves every built-in harness in this repository's tests.
|
|
4
|
+
export { MAX_RESTARTS, registerHarnessConformance } from "./runner/conformance/harness.js";
|
|
5
|
+
export { createAdapterLoop } from "./runner/adapter-loop.js";
|
|
6
|
+
export { suiteHostTools } from "./runner/conformance/host-tools.js";
|