@parcha/agentrun-serve 0.1.0-beta.51 → 0.1.0-beta.52
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 +38 -0
- package/README.md +94 -13
- package/dist/adapters.js +1 -1
- package/dist/agent-delete.d.ts +13 -2
- package/dist/agent-delete.js +14 -5
- package/dist/agents-store.d.ts +5 -1
- package/dist/agents-store.js +10 -4
- package/dist/api-only.d.ts +4 -2
- package/dist/api-only.js +5 -3
- package/dist/archil-routes.d.ts +1 -0
- package/dist/archil-routes.js +28 -2
- package/dist/computer-setting.d.ts +8 -0
- package/dist/computer-setting.js +11 -0
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +2 -2
- package/dist/console/assets/index-B-D0EM3j.js +733 -0
- package/dist/console/assets/index-DlQepP2J.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/fal-price.d.ts +76 -0
- package/dist/fal-price.js +368 -0
- package/dist/learn/commit.d.ts +5 -0
- package/dist/learn/commit.js +4 -1
- package/dist/learn/compile.d.ts +13 -5
- package/dist/learn/compile.js +24 -7
- package/dist/learn/delete.d.ts +12 -6
- package/dist/learn/delete.js +17 -11
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +20 -3
- package/dist/learn/learning-of.d.ts +8 -0
- package/dist/learn/learning-of.js +8 -0
- package/dist/learn/learning.sh +14 -1
- package/dist/learn/promote.d.ts +51 -7
- package/dist/learn/promote.js +51 -8
- package/dist/learning-reset.d.ts +18 -0
- package/dist/learning-reset.js +115 -0
- package/dist/learning-routes.d.ts +1 -1
- package/dist/learning-words.d.ts +5 -0
- package/dist/learning-words.js +5 -0
- package/dist/learning.d.ts +8 -6
- package/dist/learning.js +5 -4
- package/dist/llms.txt +1 -0
- package/dist/mcp-gateway.d.ts +39 -2
- package/dist/mcp-gateway.js +41 -10
- package/dist/mcp-pin-first.js +1 -1
- package/dist/mcp-servers-store.d.ts +1 -0
- package/dist/mcp-servers-store.js +2 -1
- package/dist/media-duration.d.ts +2 -0
- package/dist/media-duration.js +136 -0
- package/dist/openapi.js +45 -12
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +14 -2
- package/dist/refusal-words.d.ts +0 -3
- package/dist/refusal-words.js +0 -3
- package/dist/request-metadata.d.ts +20 -0
- package/dist/request-metadata.js +24 -0
- package/dist/run-launch.d.ts +13 -4
- package/dist/run-launch.js +14 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-usage.d.ts +48 -4
- package/dist/run-usage.js +156 -39
- package/dist/run-view.d.ts +1 -1
- package/dist/run-view.js +3 -7
- package/dist/runner/adapter-loop.d.ts +3 -1
- package/dist/runner/adapter-loop.js +12 -9
- package/dist/runner/adapter-run-spec.d.ts +1 -1
- package/dist/runner/adapter-run-spec.js +13 -13
- package/dist/runner/audit.d.ts +8 -3
- package/dist/runner/audit.js +21 -6
- package/dist/runner/claim-secrets.d.ts +2 -1
- package/dist/runner/claim-secrets.js +5 -3
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +12 -11
- package/dist/runner/conformance/harness.js +4 -2
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/harness-loops.js +5 -2
- package/dist/runner/journal-kinds.d.ts +3 -0
- package/dist/runner/learning-end.d.ts +2 -1
- package/dist/runner/learning-end.js +47 -22
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +16 -1
- package/dist/runner/model-route.js +7 -4
- package/dist/runner/promotion.d.ts +40 -21
- package/dist/runner/promotion.js +130 -59
- package/dist/runner/run-child-host.js +6 -4
- package/dist/runner/runner.js +15 -3
- package/dist/runner/sdk-loop.d.ts +2 -2
- package/dist/runner/sdk-loop.js +3 -3
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/workflow-spec.js +3 -3
- package/dist/runs-over-store.d.ts +5 -2
- package/dist/runs-over-store.js +14 -7
- package/dist/sdk/check.d.ts +6 -5
- package/dist/sdk/check.js +17 -16
- package/dist/sdk/runs.js +81 -65
- package/dist/server.js +84 -20
- package/dist/store/agent-body.d.ts +4 -0
- package/dist/store/agent-body.js +4 -1
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +2 -0
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
- package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
- package/dist/store/schema.d.ts +14 -1
- package/dist/store/schema.js +42 -4
- package/dist/store/sqlite/run-launch.d.ts +22 -0
- package/dist/store/sqlite/run-launch.js +72 -7
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +4 -3
- package/dist/store/sqlite/store.js +141 -29
- package/dist/store/store-schema.js +2 -2
- package/dist/store/store.d.ts +67 -4
- package/dist/store-reads/learning.d.ts +12 -8
- package/dist/store-reads/learning.js +33 -24
- package/dist/store-reads/loop.d.ts +4 -3
- package/dist/store-reads/loop.js +7 -5
- package/dist/template-eval.js +4 -4
- package/dist/templates.d.ts +3 -0
- package/dist/templates.js +7 -5
- package/dist/timeline/labels.js +1 -1
- package/dist/tools.js +1 -1
- package/dist/uploads-archil.js +2 -1
- package/dist/uploads.d.ts +0 -3
- package/dist/uploads.js +2 -11
- package/dist/validate.js +5 -1
- package/dist/web-save.d.ts +3 -0
- package/dist/web-save.js +17 -2
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/revision-skills.js +24 -11
- package/dist/workspace/synced-folder.d.ts +3 -3
- package/dist/workspace/synced-folder.js +7 -6
- package/package.json +10 -10
- package/dist/console/assets/index-Bt1B51b7.js +0 -733
- package/dist/console/assets/index-sVftE9Ht.css +0 -1
package/dist/web-save.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { extname } from "node:path";
|
|
5
5
|
import { defineTool } from "@earendil-works/pi-durable";
|
|
6
6
|
import { extensionOf, typeOf } from "./file-types.js";
|
|
7
|
+
import { mediaSeconds } from "./media-duration.js";
|
|
7
8
|
import { clip, URL_MAX } from "./web-fetch-direct.js";
|
|
8
9
|
import { forModel } from "./result.js";
|
|
9
10
|
import { isWorkspaceError, workspaceErrorWords } from "./workspace/index.js";
|
|
@@ -203,12 +204,26 @@ export async function webSave(args, work, options = {}) {
|
|
|
203
204
|
catch (error) {
|
|
204
205
|
return { ...failed(error), url: final };
|
|
205
206
|
}
|
|
206
|
-
|
|
207
|
+
const seconds = lengthOf(file.bytes, typed.type);
|
|
208
|
+
return { ok: true, path: at, bytes: file.bytes.length, content_type: typed.type, ...(seconds === undefined ? {} : { duration_s: seconds }), url: final };
|
|
207
209
|
}
|
|
208
210
|
finally {
|
|
209
211
|
release();
|
|
210
212
|
}
|
|
211
213
|
}
|
|
214
|
+
/** An audio or video file's length in seconds, rounded to the millisecond; undefined for any other type, or when its bytes
|
|
215
|
+
* don't give it. Never throws: a saved file is answered saved whatever its bytes hold. */
|
|
216
|
+
function lengthOf(bytes, type) {
|
|
217
|
+
if (!/^(audio|video)\//.test(type))
|
|
218
|
+
return undefined;
|
|
219
|
+
try {
|
|
220
|
+
const seconds = mediaSeconds(bytes);
|
|
221
|
+
return seconds === undefined ? undefined : Math.round(seconds * 1000) / 1000;
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
212
227
|
/** The words the model reads: the answer's JSON. */
|
|
213
228
|
export const savedText = (answer) => JSON.stringify(answer);
|
|
214
229
|
/** web_save on `work`, its download through `guard` (a test's or the fakes' resolver and fetch, none for the network), its
|
|
@@ -216,7 +231,7 @@ export const savedText = (answer) => JSON.stringify(answer);
|
|
|
216
231
|
export function webSaveTool(work, guard, slots) {
|
|
217
232
|
return defineTool({
|
|
218
233
|
name: WEB_SAVE_TOOL,
|
|
219
|
-
description: `Download one file from a public URL into this run's folder, where it stays (the run's Files show and play it): use it for a generated image, audio or video a service answered with a link that expires. path is where to save it, relative to the run's folder; a bare name (cat.png) goes under ${MEDIA_DIR}/. A path that already holds a file is refused, never overwritten. The file must be a type its bytes show: an image (png, jpeg, gif, webp), audio (mp3, wav, ogg, m4a) or video (mp4, webm), and the path must have an extension of that type (cat.png, not cat or cat.bin); any other type (a page, a PDF, text) is saved only to a path whose extension names the type the host declares. At most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB and ${SAVE_TIMEOUT_MS / 60_000} minutes. A private or local address, a port other than 80 or 443, or a scheme other than http(s) is refused, at every redirect too. Answers JSON: { ok: true, path, bytes, content_type, url } (url the final one, after redirects), or { ok: false, url, refused } when it was refused, { ok: false, url, error } when it failed; nothing is left at the path when it does not save.`,
|
|
234
|
+
description: `Download one file from a public URL into this run's folder, where it stays (the run's Files show and play it): use it for a generated image, audio or video a service answered with a link that expires. path is where to save it, relative to the run's folder; a bare name (cat.png) goes under ${MEDIA_DIR}/. A path that already holds a file is refused, never overwritten. The file must be a type its bytes show: an image (png, jpeg, gif, webp), audio (mp3, wav, ogg, m4a) or video (mp4, webm), and the path must have an extension of that type (cat.png, not cat or cat.bin); any other type (a page, a PDF, text) is saved only to a path whose extension names the type the host declares. At most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB and ${SAVE_TIMEOUT_MS / 60_000} minutes. A private or local address, a port other than 80 or 443, or a scheme other than http(s) is refused, at every redirect too. Answers JSON: { ok: true, path, bytes, content_type, duration_s?, url } (url the final one, after redirects; duration_s an audio or video file's length in seconds, when its bytes give it: mp3, wav, mp4, m4a), or { ok: false, url, refused } when it was refused, { ok: false, url, error } when it failed; nothing is left at the path when it does not save.`,
|
|
220
235
|
parameters: {
|
|
221
236
|
type: "object",
|
|
222
237
|
additionalProperties: false,
|
|
@@ -222,7 +222,7 @@ export async function archilExec(disk, job) {
|
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
224
|
case "link": throw new WorkspaceError("ESCAPE", `${show(job.cwd)} has a symbolic link on the way, and a workspace follows none`, { path });
|
|
225
|
-
case "nocwd": throw new WorkspaceError("NOT_FOUND", `${show(job.cwd)} is not there`, { path });
|
|
225
|
+
case "nocwd": throw new WorkspaceError("NOT_FOUND", `${show(job.cwd)} is not there (exec; Archil: no folder ${job.root}/${path} on disk ${disk.id})`, { path });
|
|
226
226
|
case "notdir": throw new WorkspaceError("REFUSED", `${show(job.cwd)} is not a directory`, { path });
|
|
227
227
|
case "noprog": throw new WorkspaceError("NOT_FOUND", `${JSON.stringify(job.argv[0])} is not a program here (PATH ${JSON.stringify(job.env.PATH ?? "")})`, { path });
|
|
228
228
|
case "noroot": throw new WorkspaceError("UNAVAILABLE", `the workspace's folder ${job.root} or its spill folder was not mounted`, { path });
|
package/dist/workspace/archil.js
CHANGED
|
@@ -444,7 +444,7 @@ class ArchilWorkspace {
|
|
|
444
444
|
if (entries.size === 0 && rel !== "") {
|
|
445
445
|
const kind = await this.#kind(rel).catch((error) => { throw failed(error, rel, "list"); });
|
|
446
446
|
if (kind === undefined)
|
|
447
|
-
throw new WorkspaceError("NOT_FOUND", `${show(rel)} is not there`, { path: rel });
|
|
447
|
+
throw new WorkspaceError("NOT_FOUND", `${show(rel)} is not there (list; Archil: nothing under ${prefix} on disk ${this.#disk.id})`, { path: rel });
|
|
448
448
|
if (kind === "file")
|
|
449
449
|
throw new WorkspaceError("REFUSED", `${show(rel)} is not a directory`, { path: rel });
|
|
450
450
|
}
|
|
@@ -33,16 +33,29 @@ export async function layOwnSkills(work, skills, options = {}) {
|
|
|
33
33
|
files.push([brought[0], kind.text]);
|
|
34
34
|
if (!files.length)
|
|
35
35
|
return brought;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
try {
|
|
37
|
+
// What is there is asked with stat, which answers a fresh folder's missing .agents/skills/ with undefined: no error
|
|
38
|
+
// is read as "not there", so no check of an error's class decides it (a run's own process gets its errors over its
|
|
39
|
+
// channel, where beta.50 lost WorkspaceError's class and failed every new run that had a skill).
|
|
40
|
+
const there = (await work.stat(RUN_SKILLS_DIR)) === undefined ? new Set() : new Set((await work.list(RUN_SKILLS_DIR)).map((entry) => entry.name));
|
|
41
|
+
const missing = files.filter(([path]) => !there.has(relativeSegments(path)[0]));
|
|
42
|
+
if (!missing.length)
|
|
43
|
+
return brought;
|
|
44
|
+
await work.mkdir(RUN_SKILLS_DIR);
|
|
45
|
+
for (const [path, text] of missing)
|
|
46
|
+
await work.write(`${RUN_SKILLS_DIR}/${path}`, text);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw laidFailed(error);
|
|
50
|
+
}
|
|
47
51
|
return brought;
|
|
48
52
|
}
|
|
53
|
+
/** A lay's failure, saying it was the lay of the run's skills: a WorkspaceError keeps its code, its path and its words
|
|
54
|
+
* (the backend's, an Archil key and Archil's own included) after that. */
|
|
55
|
+
function laidFailed(error) {
|
|
56
|
+
const code = error?.code;
|
|
57
|
+
if (!(error instanceof Error) || error.name !== "WorkspaceError" || typeof code !== "string")
|
|
58
|
+
return error;
|
|
59
|
+
const path = error.path;
|
|
60
|
+
return new WorkspaceError(code, `laying the run's skills in ${RUN_SKILLS_DIR}/: ${error.message}`, { ...(typeof path === "string" ? { path } : {}), cause: error });
|
|
61
|
+
}
|
|
@@ -38,9 +38,9 @@ export type HeldFolder = {
|
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
40
|
* The stored folder pushed into the computer's empty /workspace through `client` (the computer's own, under no sync),
|
|
41
|
-
* one streaming tar, then the computer's listing read as the manifest: the sync the claim
|
|
42
|
-
* caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a
|
|
43
|
-
*
|
|
41
|
+
* one streaming tar, each file at PUSHED_MTIME, then the computer's listing read as the manifest: the sync the claim
|
|
42
|
+
* holds from then on (the caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a
|
|
43
|
+
* lost one, whose files the old manifest does not describe. The links an exec made on the disk (linkObjects), now links
|
|
44
44
|
* in the computer, are then removed from the disk. Throws in words where the push, the listing or a remove fails.
|
|
45
45
|
*/
|
|
46
46
|
export declare function holdSynced(store: FolderStore, client: ComputerClient, stored: StoredFolder, signal?: AbortSignal): Promise<FolderSync>;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
// the disk (storedFolder, holdSynced).
|
|
24
24
|
// - Every write of a claim's goes through fencedStore: once a later claim has taken the run (the run's epoch and runner
|
|
25
25
|
// say so, held or not), it is refused, never sent.
|
|
26
|
-
import { fail, folderPathProblem, FolderSync, ok, pushTar, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES, tarStream, WORKSPACE } from "@parcha/agentrun-computer";
|
|
26
|
+
import { fail, folderPathProblem, FolderSync, ok, PUSHED_MTIME, pushTar, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES, tarStream, WORKSPACE } from "@parcha/agentrun-computer";
|
|
27
27
|
/** How many files a push reads ahead of the one the tar is writing. */
|
|
28
28
|
const AHEAD = 4;
|
|
29
29
|
const FILE_MODE = 0o644;
|
|
@@ -66,7 +66,8 @@ const quiet = (promise) => {
|
|
|
66
66
|
return promise;
|
|
67
67
|
};
|
|
68
68
|
/** The folder's entries as tar entries, by path (a directory before what is in it), then its links: each file read
|
|
69
|
-
* AHEAD ahead of the one written, so what is held is those few, never the folder
|
|
69
|
+
* AHEAD ahead of the one written, so what is held is those few, never the folder; each file at PUSHED_MTIME, which
|
|
70
|
+
* the baseline after the push needs. */
|
|
70
71
|
async function* tarEntries(store, { entries, meta }) {
|
|
71
72
|
const modeOf = (path, fallback) => (Object.hasOwn(meta.modes, path) ? meta.modes[path] : fallback);
|
|
72
73
|
const sorted = [...entries].sort(byPath);
|
|
@@ -85,16 +86,16 @@ async function* tarEntries(store, { entries, meta }) {
|
|
|
85
86
|
}
|
|
86
87
|
const body = await reads.shift();
|
|
87
88
|
ahead();
|
|
88
|
-
yield { name: entry.path, type: "file", mode: modeOf(entry.path, FILE_MODE), body };
|
|
89
|
+
yield { name: entry.path, type: "file", mode: modeOf(entry.path, FILE_MODE), body, mtime: PUSHED_MTIME };
|
|
89
90
|
}
|
|
90
91
|
for (const [path, target] of Object.entries(meta.links))
|
|
91
92
|
yield { name: path, type: "symlink", mode: 0o777, link: target };
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* The stored folder pushed into the computer's empty /workspace through `client` (the computer's own, under no sync),
|
|
95
|
-
* one streaming tar, then the computer's listing read as the manifest: the sync the claim
|
|
96
|
-
* caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a
|
|
97
|
-
*
|
|
96
|
+
* one streaming tar, each file at PUSHED_MTIME, then the computer's listing read as the manifest: the sync the claim
|
|
97
|
+
* holds from then on (the caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a
|
|
98
|
+
* lost one, whose files the old manifest does not describe. The links an exec made on the disk (linkObjects), now links
|
|
98
99
|
* in the computer, are then removed from the disk. Throws in words where the push, the listing or a remove fails.
|
|
99
100
|
*/
|
|
100
101
|
export async function holdSynced(store, client, stored, signal) {
|
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.52",
|
|
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",
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
"@earendil-works/pi-coding-agent": "1.5.2",
|
|
63
63
|
"@modelcontextprotocol/client": "2.4.0",
|
|
64
64
|
"@modelcontextprotocol/server": "2.4.0",
|
|
65
|
-
"@parcha/agentrun-computer": "0.1.0-beta.
|
|
66
|
-
"@parcha/agentrun-decisions": "0.1.0-beta.
|
|
67
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
68
|
-
"@parcha/agentrun-harness-acp": "0.1.0-beta.
|
|
69
|
-
"@parcha/agentrun-harness-claude": "0.1.0-beta.
|
|
70
|
-
"@parcha/agentrun-harness-codex": "0.1.0-beta.
|
|
71
|
-
"@parcha/agentrun-jev": "0.1.0-beta.
|
|
72
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
73
|
-
"@parcha/pi-browser": "0.1.0-beta.
|
|
65
|
+
"@parcha/agentrun-computer": "0.1.0-beta.52",
|
|
66
|
+
"@parcha/agentrun-decisions": "0.1.0-beta.52",
|
|
67
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.52",
|
|
68
|
+
"@parcha/agentrun-harness-acp": "0.1.0-beta.52",
|
|
69
|
+
"@parcha/agentrun-harness-claude": "0.1.0-beta.52",
|
|
70
|
+
"@parcha/agentrun-harness-codex": "0.1.0-beta.52",
|
|
71
|
+
"@parcha/agentrun-jev": "0.1.0-beta.52",
|
|
72
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.52",
|
|
73
|
+
"@parcha/pi-browser": "0.1.0-beta.52",
|
|
74
74
|
"@secretlint/core": "13.1.0",
|
|
75
75
|
"@secretlint/profiler": "13.1.0",
|
|
76
76
|
"@secretlint/secretlint-rule-preset-recommend": "13.1.0",
|