@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.
Files changed (135) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +94 -13
  3. package/dist/adapters.js +1 -1
  4. package/dist/agent-delete.d.ts +13 -2
  5. package/dist/agent-delete.js +14 -5
  6. package/dist/agents-store.d.ts +5 -1
  7. package/dist/agents-store.js +10 -4
  8. package/dist/api-only.d.ts +4 -2
  9. package/dist/api-only.js +5 -3
  10. package/dist/archil-routes.d.ts +1 -0
  11. package/dist/archil-routes.js +28 -2
  12. package/dist/computer-setting.d.ts +8 -0
  13. package/dist/computer-setting.js +11 -0
  14. package/dist/computers.d.ts +6 -2
  15. package/dist/computers.js +2 -2
  16. package/dist/console/assets/index-B-D0EM3j.js +733 -0
  17. package/dist/console/assets/index-DlQepP2J.css +1 -0
  18. package/dist/console/index.html +2 -2
  19. package/dist/fal-price.d.ts +76 -0
  20. package/dist/fal-price.js +368 -0
  21. package/dist/learn/commit.d.ts +5 -0
  22. package/dist/learn/commit.js +4 -1
  23. package/dist/learn/compile.d.ts +13 -5
  24. package/dist/learn/compile.js +24 -7
  25. package/dist/learn/delete.d.ts +12 -6
  26. package/dist/learn/delete.js +17 -11
  27. package/dist/learn/folder.d.ts +11 -0
  28. package/dist/learn/folder.js +20 -3
  29. package/dist/learn/learning-of.d.ts +8 -0
  30. package/dist/learn/learning-of.js +8 -0
  31. package/dist/learn/learning.sh +14 -1
  32. package/dist/learn/promote.d.ts +51 -7
  33. package/dist/learn/promote.js +51 -8
  34. package/dist/learning-reset.d.ts +18 -0
  35. package/dist/learning-reset.js +115 -0
  36. package/dist/learning-routes.d.ts +1 -1
  37. package/dist/learning-words.d.ts +5 -0
  38. package/dist/learning-words.js +5 -0
  39. package/dist/learning.d.ts +8 -6
  40. package/dist/learning.js +5 -4
  41. package/dist/llms.txt +1 -0
  42. package/dist/mcp-gateway.d.ts +39 -2
  43. package/dist/mcp-gateway.js +41 -10
  44. package/dist/mcp-pin-first.js +1 -1
  45. package/dist/mcp-servers-store.d.ts +1 -0
  46. package/dist/mcp-servers-store.js +2 -1
  47. package/dist/media-duration.d.ts +2 -0
  48. package/dist/media-duration.js +136 -0
  49. package/dist/openapi.js +45 -12
  50. package/dist/provider.d.ts +8 -0
  51. package/dist/provider.js +14 -2
  52. package/dist/refusal-words.d.ts +0 -3
  53. package/dist/refusal-words.js +0 -3
  54. package/dist/request-metadata.d.ts +20 -0
  55. package/dist/request-metadata.js +24 -0
  56. package/dist/run-launch.d.ts +13 -4
  57. package/dist/run-launch.js +14 -3
  58. package/dist/run-learning-served.d.ts +2 -2
  59. package/dist/run-usage.d.ts +48 -4
  60. package/dist/run-usage.js +156 -39
  61. package/dist/run-view.d.ts +1 -1
  62. package/dist/run-view.js +3 -7
  63. package/dist/runner/adapter-loop.d.ts +3 -1
  64. package/dist/runner/adapter-loop.js +12 -9
  65. package/dist/runner/adapter-run-spec.d.ts +1 -1
  66. package/dist/runner/adapter-run-spec.js +13 -13
  67. package/dist/runner/audit.d.ts +8 -3
  68. package/dist/runner/audit.js +21 -6
  69. package/dist/runner/claim-secrets.d.ts +2 -1
  70. package/dist/runner/claim-secrets.js +5 -3
  71. package/dist/runner/cli-run-spec.d.ts +1 -1
  72. package/dist/runner/cli-run-spec.js +12 -11
  73. package/dist/runner/conformance/harness.js +4 -2
  74. package/dist/runner/dispatch.js +4 -2
  75. package/dist/runner/harness-loops.js +5 -2
  76. package/dist/runner/journal-kinds.d.ts +3 -0
  77. package/dist/runner/learning-end.d.ts +2 -1
  78. package/dist/runner/learning-end.js +47 -22
  79. package/dist/runner/mcp-claim.js +1 -1
  80. package/dist/runner/mcp-run.d.ts +9 -0
  81. package/dist/runner/mcp-run.js +16 -1
  82. package/dist/runner/model-route.js +7 -4
  83. package/dist/runner/promotion.d.ts +40 -21
  84. package/dist/runner/promotion.js +130 -59
  85. package/dist/runner/run-child-host.js +6 -4
  86. package/dist/runner/runner.js +15 -3
  87. package/dist/runner/sdk-loop.d.ts +2 -2
  88. package/dist/runner/sdk-loop.js +3 -3
  89. package/dist/runner/store-port.d.ts +3 -0
  90. package/dist/runner/workflow-spec.js +3 -3
  91. package/dist/runs-over-store.d.ts +5 -2
  92. package/dist/runs-over-store.js +14 -7
  93. package/dist/sdk/check.d.ts +6 -5
  94. package/dist/sdk/check.js +17 -16
  95. package/dist/sdk/runs.js +81 -65
  96. package/dist/server.js +84 -20
  97. package/dist/store/agent-body.d.ts +4 -0
  98. package/dist/store/agent-body.js +4 -1
  99. package/dist/store/index.d.ts +1 -1
  100. package/dist/store/journal/storage.d.ts +2 -0
  101. package/dist/store/journal/storage.js +2 -1
  102. package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
  103. package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
  104. package/dist/store/schema.d.ts +14 -1
  105. package/dist/store/schema.js +42 -4
  106. package/dist/store/sqlite/run-launch.d.ts +22 -0
  107. package/dist/store/sqlite/run-launch.js +72 -7
  108. package/dist/store/sqlite/run-patch.d.ts +2 -1
  109. package/dist/store/sqlite/run-patch.js +4 -3
  110. package/dist/store/sqlite/store.js +141 -29
  111. package/dist/store/store-schema.js +2 -2
  112. package/dist/store/store.d.ts +67 -4
  113. package/dist/store-reads/learning.d.ts +12 -8
  114. package/dist/store-reads/learning.js +33 -24
  115. package/dist/store-reads/loop.d.ts +4 -3
  116. package/dist/store-reads/loop.js +7 -5
  117. package/dist/template-eval.js +4 -4
  118. package/dist/templates.d.ts +3 -0
  119. package/dist/templates.js +7 -5
  120. package/dist/timeline/labels.js +1 -1
  121. package/dist/tools.js +1 -1
  122. package/dist/uploads-archil.js +2 -1
  123. package/dist/uploads.d.ts +0 -3
  124. package/dist/uploads.js +2 -11
  125. package/dist/validate.js +5 -1
  126. package/dist/web-save.d.ts +3 -0
  127. package/dist/web-save.js +17 -2
  128. package/dist/workspace/archil-exec.js +1 -1
  129. package/dist/workspace/archil.js +1 -1
  130. package/dist/workspace/revision-skills.js +24 -11
  131. package/dist/workspace/synced-folder.d.ts +3 -3
  132. package/dist/workspace/synced-folder.js +7 -6
  133. package/package.json +10 -10
  134. package/dist/console/assets/index-Bt1B51b7.js +0 -733
  135. 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
- return { ok: true, path: at, bytes: file.bytes.length, content_type: typed.type, url: final };
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 });
@@ -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
- const there = await work.list(RUN_SKILLS_DIR).then((entries) => new Set(entries.map((entry) => entry.name)), (error) => {
37
- if (error instanceof WorkspaceError && error.code === "NOT_FOUND")
38
- return new Set();
39
- throw error;
40
- });
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);
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 holds from then on (the
42
- * caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a lost one, whose fresh
43
- * mtimes the old manifest would read as every file changed. The links an exec made on the disk (linkObjects), now links
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 holds from then on (the
96
- * caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a lost one, whose fresh
97
- * mtimes the old manifest would read as every file changed. The links an exec made on the disk (linkObjects), now links
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.51",
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.51",
66
- "@parcha/agentrun-decisions": "0.1.0-beta.51",
67
- "@parcha/agentrun-dsl": "0.1.0-beta.51",
68
- "@parcha/agentrun-harness-acp": "0.1.0-beta.51",
69
- "@parcha/agentrun-harness-claude": "0.1.0-beta.51",
70
- "@parcha/agentrun-harness-codex": "0.1.0-beta.51",
71
- "@parcha/agentrun-jev": "0.1.0-beta.51",
72
- "@parcha/agentrun-kernel": "0.1.0-beta.51",
73
- "@parcha/pi-browser": "0.1.0-beta.51",
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",