@parcha/agentrun-serve 0.1.0-beta.48 → 0.1.0-beta.50

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 (170) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +236 -26
  3. package/dist/agent-delete.d.ts +36 -12
  4. package/dist/agent-delete.js +213 -30
  5. package/dist/agents-store.d.ts +6 -2
  6. package/dist/agents-store.js +18 -5
  7. package/dist/agents.d.ts +8 -1
  8. package/dist/agents.js +14 -4
  9. package/dist/answer-json.d.ts +2 -2
  10. package/dist/answer-json.js +3 -4
  11. package/dist/api-only.d.ts +7 -10
  12. package/dist/api-only.js +9 -11
  13. package/dist/archil-routes.d.ts +1 -1
  14. package/dist/archil-routes.js +4 -3
  15. package/dist/browser-sessions.d.ts +56 -0
  16. package/dist/browser-sessions.js +117 -0
  17. package/dist/compute-cost.d.ts +101 -0
  18. package/dist/compute-cost.js +250 -0
  19. package/dist/computer-routes.d.ts +4 -15
  20. package/dist/computer-routes.js +6 -10
  21. package/dist/console/assets/index-D0mr9wfZ.css +1 -0
  22. package/dist/console/assets/index-D7G6o-1E.js +720 -0
  23. package/dist/console/index.html +2 -2
  24. package/dist/errors.d.ts +4 -1
  25. package/dist/errors.js +15 -5
  26. package/dist/eval-previous.d.ts +52 -0
  27. package/dist/eval-previous.js +164 -0
  28. package/dist/file-types.d.ts +2 -0
  29. package/dist/file-types.js +3 -1
  30. package/dist/harness.js +2 -1
  31. package/dist/import.js +4 -3
  32. package/dist/learn/check.d.ts +16 -4
  33. package/dist/learn/check.js +30 -26
  34. package/dist/learn/promote.d.ts +7 -1
  35. package/dist/learn/promote.js +47 -0
  36. package/dist/learn/repick.d.ts +43 -0
  37. package/dist/learn/repick.js +202 -0
  38. package/dist/learn/workflow-draft.d.ts +4 -0
  39. package/dist/learn/workflow-draft.js +10 -7
  40. package/dist/learned-workflow.d.ts +2 -0
  41. package/dist/learned-workflow.js +19 -2
  42. package/dist/learning-setting.d.ts +13 -0
  43. package/dist/learning-setting.js +23 -1
  44. package/dist/llms.txt +1 -1
  45. package/dist/openapi.js +180 -14
  46. package/dist/paid-calls.d.ts +17 -7
  47. package/dist/paid-calls.js +15 -9
  48. package/dist/run-launch.d.ts +2 -2
  49. package/dist/run-launch.js +2 -1
  50. package/dist/run-learning-served.d.ts +1 -1
  51. package/dist/run-timeline-served.js +5 -3
  52. package/dist/run-usage.d.ts +125 -0
  53. package/dist/run-usage.js +394 -0
  54. package/dist/runner/adapter-loop.d.ts +4 -0
  55. package/dist/runner/adapter-loop.js +66 -21
  56. package/dist/runner/adapter-run-spec.d.ts +8 -3
  57. package/dist/runner/adapter-run-spec.js +13 -6
  58. package/dist/runner/big-writes.d.ts +33 -0
  59. package/dist/runner/big-writes.js +105 -0
  60. package/dist/runner/cli-run-spec.js +14 -6
  61. package/dist/runner/conformance/harness.d.ts +2 -0
  62. package/dist/runner/conformance/harness.js +18 -4
  63. package/dist/runner/feedback-round.d.ts +29 -1
  64. package/dist/runner/feedback-round.js +54 -3
  65. package/dist/runner/held.d.ts +4 -1
  66. package/dist/runner/journal-kinds.d.ts +3 -1
  67. package/dist/runner/learning-end.js +54 -18
  68. package/dist/runner/loop-contract.d.ts +3 -0
  69. package/dist/runner/metrics.d.ts +4 -0
  70. package/dist/runner/metrics.js +9 -0
  71. package/dist/runner/monid-run.js +2 -2
  72. package/dist/runner/promotion.js +8 -2
  73. package/dist/runner/reflect-hook.js +3 -2
  74. package/dist/runner/run-child-host.d.ts +15 -2
  75. package/dist/runner/run-child-host.js +24 -8
  76. package/dist/runner/run-child.js +3 -0
  77. package/dist/runner/save-slots.d.ts +9 -0
  78. package/dist/runner/save-slots.js +91 -0
  79. package/dist/runs-over-store.d.ts +3 -2
  80. package/dist/runs-over-store.js +9 -7
  81. package/dist/sdk/runs.d.ts +3 -4
  82. package/dist/sdk/runs.js +10 -7
  83. package/dist/sdk/runtimes.d.ts +19 -0
  84. package/dist/sdk/runtimes.js +23 -0
  85. package/dist/sdk/schema.d.ts +14 -8
  86. package/dist/sdk/schema.js +18 -6
  87. package/dist/server.d.ts +7 -3
  88. package/dist/server.js +223 -100
  89. package/dist/store/agent-body.d.ts +2 -3
  90. package/dist/store/agent-body.js +3 -2
  91. package/dist/store/index.d.ts +2 -2
  92. package/dist/store/index.js +1 -1
  93. package/dist/store/journal/storage.js +1 -1
  94. package/dist/store/open.d.ts +1 -1
  95. package/dist/store/open.js +1 -1
  96. package/dist/store/postgres/migrations/0021_purged.sql +13 -0
  97. package/dist/store/postgres/migrations/0022_computer_intervals.sql +27 -0
  98. package/dist/store/postgres/migrations/0023_computer_interval_resources.sql +14 -0
  99. package/dist/store/schema.d.ts +20 -1
  100. package/dist/store/schema.js +60 -5
  101. package/dist/store/sqlite/connection.d.ts +4 -1
  102. package/dist/store/sqlite/connection.js +5 -0
  103. package/dist/store/sqlite/run-patch.d.ts +8 -3
  104. package/dist/store/sqlite/run-patch.js +15 -7
  105. package/dist/store/sqlite/store.d.ts +2 -1
  106. package/dist/store/sqlite/store.js +279 -68
  107. package/dist/store/sqlite/worker.d.ts +9 -0
  108. package/dist/store/sqlite/worker.js +18 -1
  109. package/dist/store/store.d.ts +149 -9
  110. package/dist/store/store.js +63 -0
  111. package/dist/store-reads/analytics.js +2 -1
  112. package/dist/store-reads/cap.d.ts +17 -7
  113. package/dist/store-reads/cap.js +54 -4
  114. package/dist/store-reads/decisions.d.ts +21 -0
  115. package/dist/store-reads/decisions.js +22 -0
  116. package/dist/store-reads/journal.d.ts +8 -2
  117. package/dist/store-reads/journal.js +27 -8
  118. package/dist/store-reads/learning.d.ts +1 -1
  119. package/dist/store-reads/learning.js +5 -2
  120. package/dist/store-reads/runs.js +2 -0
  121. package/dist/store-reads/stats.js +4 -2
  122. package/dist/store-view.d.ts +12 -1
  123. package/dist/store-view.js +98 -38
  124. package/dist/template-eval.d.ts +15 -1
  125. package/dist/template-eval.js +92 -13
  126. package/dist/templates.d.ts +1 -1
  127. package/dist/templates.js +4 -3
  128. package/dist/timeline/labels.js +17 -0
  129. package/dist/tool-list.js +1 -0
  130. package/dist/tools.d.ts +6 -2
  131. package/dist/tools.js +22 -1
  132. package/dist/trigger-targets.d.ts +28 -9
  133. package/dist/trigger-targets.js +19 -16
  134. package/dist/triggers.d.ts +2 -1
  135. package/dist/triggers.js +5 -2
  136. package/dist/validate.d.ts +4 -2
  137. package/dist/validate.js +13 -3
  138. package/dist/viewer-credential.d.ts +3 -4
  139. package/dist/viewer-credential.js +6 -4
  140. package/dist/web-fake.d.ts +25 -0
  141. package/dist/web-fake.js +38 -1
  142. package/dist/web-save.d.ts +75 -0
  143. package/dist/web-save.js +235 -0
  144. package/dist/workspace/archil-claim.d.ts +5 -2
  145. package/dist/workspace/archil-claim.js +5 -2
  146. package/dist/workspace/archil-disk.d.ts +10 -1
  147. package/dist/workspace/archil-disk.js +19 -1
  148. package/dist/workspace/archil.d.ts +3 -0
  149. package/dist/workspace/archil.js +101 -16
  150. package/dist/workspace/computer-for-claim.d.ts +19 -1
  151. package/dist/workspace/computer-for-claim.js +88 -20
  152. package/dist/workspace/computer-intervals.d.ts +26 -0
  153. package/dist/workspace/computer-intervals.js +58 -0
  154. package/dist/workspace/computer-janitor.d.ts +7 -3
  155. package/dist/workspace/computer-janitor.js +14 -6
  156. package/dist/workspace/computer-kept.d.ts +7 -2
  157. package/dist/workspace/computer-kept.js +9 -2
  158. package/dist/workspace/pieced.d.ts +14 -0
  159. package/dist/workspace/pieced.js +23 -0
  160. package/dist/workspace/resolve-computer.d.ts +7 -4
  161. package/dist/workspace/resolve-computer.js +21 -32
  162. package/dist/workspace/run-disk.js +32 -12
  163. package/dist/workspace/run-end-computers.d.ts +1 -0
  164. package/dist/workspace/run-end-computers.js +4 -1
  165. package/dist/workspace/run-workspace.d.ts +1 -1
  166. package/dist/workspace/run-workspace.js +11 -6
  167. package/package.json +10 -10
  168. package/templates/README.md +36 -7
  169. package/dist/console/assets/index-CTGegcKt.css +0 -1
  170. package/dist/console/assets/index-D1Se6mgG.js +0 -715
package/dist/validate.js CHANGED
@@ -250,18 +250,21 @@ export function inputSchemaIssues(schema, at = "definition.input_schema") {
250
250
  }
251
251
  /**
252
252
  * The input schema in force for an agentic revision whose definition has `schema` (none: DEFAULT_INPUT_SCHEMA). `content`
253
- * is always taken, as text: a run's message, which a follow-up and a trigger's line add to. It stays required when the
254
- * schema requires nothing else, as an agent with no schema requires it.
253
+ * is always taken, as text: a run's message, which a follow-up and a trigger's line add to. It is required when the
254
+ * schema has no field of its own, as an agent with no schema requires it. A schema whose own fields are all optional
255
+ * (a template's `pr_number`, given by hand and left out of a trigger's runs) leaves `required` empty: a run gives
256
+ * content or one of those fields, which inputIssues checks, so an input that says nothing is still refused.
255
257
  */
256
258
  export function inputSchemaOf(schema) {
257
259
  if (!isObject(schema))
258
260
  return DEFAULT_INPUT_SCHEMA;
259
261
  const properties = isObject(schema.properties) ? schema.properties : {};
260
262
  const required = Array.isArray(schema.required) ? schema.required.filter((key) => typeof key === "string") : [];
263
+ const ownOptional = required.length === 0 && Object.keys(properties).some((key) => key !== "content");
261
264
  return {
262
265
  ...schema,
263
266
  properties: { ...properties, content: properties.content ?? { type: "string" } },
264
- required: required.some((key) => key !== "content") ? required : [...new Set([...required, "content"])],
267
+ required: required.some((key) => key !== "content") || ownOptional ? required : [...new Set([...required, "content"])],
265
268
  };
266
269
  }
267
270
  /** Each JSON Schema keyword's issue reason (InputIssue.reason): a keyword not named here is `invalid`. */
@@ -305,6 +308,13 @@ export function inputIssues(input, schema, at = "input") {
305
308
  else
306
309
  add(where, KEYWORD_REASON[error.keyword] ?? "invalid", `${where} ${error.message}`);
307
310
  }
311
+ // A schema in force that requires nothing (inputSchemaOf: its own fields all optional) takes content or one of them:
312
+ // an input naming none says nothing, said at content, with the fields that would do instead.
313
+ const named = isObject(schema.properties) ? Object.keys(schema.properties) : [];
314
+ if (Array.isArray(schema.required) && schema.required.length === 0 && isObject(input) && !named.some((key) => input[key] !== undefined)) {
315
+ const instead = named.filter((key) => key !== "content").map((key) => `${at}.${key}`);
316
+ add(`${at}.content`, "missing", `${at}.content is required${instead.length ? `, or one of ${instead.join(", ")}` : ""}`);
317
+ }
308
318
  return out;
309
319
  }
310
320
  /** The parts of a JSON Pointer as the compiler writes it (`/topics/0`, `#/properties/company`). */
@@ -19,7 +19,6 @@ export declare function viewerCredentialFor(key: Buffer, runId: string, credenti
19
19
  /** The credential a request to a run's live view carries: the link's query parameter (the page), else its cookie (the
20
20
  * page's files and socket). */
21
21
  export declare function viewerCredentialOf(req: IncomingMessage): string | undefined;
22
- /** The cookie the page's answer sets: run `runId`'s live view's path alone, until the credential expires. */
23
- export declare const viewerCookie: (req: IncomingMessage, runId: string, credential: string, expiresAt: number, now: number) => string;
24
- /** When `credential` expires (ms since the epoch): read only after viewerCredentialFor took it. */
25
- export declare const viewerExpiry: (credential: string) => number;
22
+ /** The cookie the page's answer sets, for a credential viewerCredentialFor took: run `runId`'s live view's path alone,
23
+ * until the credential expires. */
24
+ export declare function viewerCookie(req: IncomingMessage, runId: string, credential: string): string;
@@ -45,7 +45,9 @@ export function viewerCredentialOf(req) {
45
45
  const given = query === undefined ? null : new URLSearchParams(query).get(VIEWER_PARAM);
46
46
  return given ?? cookiesOf(req, COOKIE)[0];
47
47
  }
48
- /** The cookie the page's answer sets: run `runId`'s live view's path alone, until the credential expires. */
49
- export const viewerCookie = (req, runId, credential, expiresAt, now) => `${COOKIE}=${credential}; HttpOnly; SameSite=Strict; Path=/v2/runs/${runId}/computer/live; Max-Age=${Math.max(0, Math.floor((expiresAt - now) / 1000))}${overHttps(req) ? "; Secure" : ""}`;
50
- /** When `credential` expires (ms since the epoch): read only after viewerCredentialFor took it. */
51
- export const viewerExpiry = (credential) => Number(credential.split(".")[0]);
48
+ /** The cookie the page's answer sets, for a credential viewerCredentialFor took: run `runId`'s live view's path alone,
49
+ * until the credential expires. */
50
+ export function viewerCookie(req, runId, credential) {
51
+ const expiresAt = Number(credential.split(".")[0]);
52
+ return `${COOKIE}=${credential}; HttpOnly; SameSite=Strict; Path=/v2/runs/${runId}/computer/live; Max-Age=${Math.max(0, Math.floor((expiresAt - Date.now()) / 1000))}${overHttps(req) ? "; Secure" : ""}`;
53
+ }
@@ -2,6 +2,7 @@ import { type Page, type Part } from "./web-fetch-direct.js";
2
2
  import { type WebPage } from "./web-fetch.js";
3
3
  import { type Hit, type Search } from "./web-search.js";
4
4
  import type { Plane } from "./tool-plane.js";
5
+ import type { PublicFetchOptions } from "@parcha/pi-browser";
5
6
  export type SearchAnswer = {
6
7
  query: string;
7
8
  results: Hit[];
@@ -18,6 +19,21 @@ export type FetchAnswer = {
18
19
  url: string;
19
20
  error: string;
20
21
  };
22
+ /** A saved file's answer: its body as text or as base64, its declared type and status. */
23
+ export type FileBody = {
24
+ status?: number;
25
+ content_type?: string;
26
+ } & ({
27
+ text: string;
28
+ } | {
29
+ base64: string;
30
+ });
31
+ export type SaveAnswer = ({
32
+ url: string;
33
+ } & FileBody) | {
34
+ url: string;
35
+ error: string;
36
+ };
21
37
  export type WebFixture = {
22
38
  search: {
23
39
  answers: SearchAnswer[];
@@ -37,6 +53,12 @@ export type WebFixture = {
37
53
  error: string;
38
54
  };
39
55
  };
56
+ save?: {
57
+ answers: SaveAnswer[];
58
+ default?: FileBody | {
59
+ error: string;
60
+ };
61
+ };
40
62
  };
41
63
  /** A case's web fake: every web call failing, or a fixture. */
42
64
  export type WebFake = "unavailable" | WebFixture;
@@ -51,6 +73,9 @@ export declare function fakeSearch(fake: WebFake, args: Record<string, unknown>,
51
73
  export declare function fakeFetch(fake: WebFake, url: unknown, part?: Part & {
52
74
  signal?: AbortSignal;
53
75
  }): Promise<WebPage | Page>;
76
+ /** The guard's resolver and fetch for web_save in `fake`: every name a public address, each file answered from the
77
+ * fixture's `save` (by exact URL, else its default), every other URL a refused connection, as a host that is down. */
78
+ export declare function fakeSaveOptions(fake: WebFake): Pick<PublicFetchOptions, "lookup" | "fetchImpl">;
54
79
  /** A faked run's plane: web_search never a harness's own search (Claude's or Codex's, which would answer in its stead), so
55
80
  * the run's own web_search tool, the one the fake answers through, is the one its harness offers. */
56
81
  export declare function fakedPlane(plane: Plane | undefined): Plane | undefined;
package/dist/web-fake.js CHANGED
@@ -4,7 +4,10 @@
4
4
  // RATE_LIMITED), and every page fails as a fetch whose connection is refused does (the guarded direct fetch's own words,
5
5
  // web-fetch-direct.ts readDirect). A fixture: each search answered by the first answer whose `query` (a regular
6
6
  // expression, case-insensitive) matches the query, else its default; each page by the answer for exactly its URL, else
7
- // its default, read through the guarded direct fetch's own path (its URL, port and status checks, its parts).
7
+ // its default, read through the guarded direct fetch's own path (its URL, port and status checks, its parts). web_save's
8
+ // files (web-save.ts) answer from the fixture's optional `save`: each file by the answer for exactly its URL, else its
9
+ // default, else a refused connection, downloaded through web_save's own guarded path (every hop checked, the cap, the type
10
+ // checked against the bytes); `unavailable` refuses every connection.
8
11
  //
9
12
  // Only the eval's own in-process runner binds it (runner/beside.ts `evalFakes`, by the agent the eval made for the run):
10
13
  // no package field, API field, setting or environment variable reaches it, so no other server's runs ever see a fake.
@@ -55,6 +58,22 @@ export function webFixtureOf(value, at, bad) {
55
58
  });
56
59
  if (!pageOk(fetch.default, false))
57
60
  say("fetch.default is {status?, title?, text} or {error}");
61
+ const statusOk = (status) => status === undefined || (Number.isInteger(status) && status >= 200 && status <= 599);
62
+ const fileOk = (answer, keyed) => isObject(answer) && (!keyed || (isText(answer.url) && URL.canParse(answer.url)))
63
+ && (isText(answer.error) ? answer.text === undefined && answer.base64 === undefined : (isText(answer.text) !== isText(answer.base64)) && (answer.text === undefined || isText(answer.text)) && (answer.base64 === undefined || isText(answer.base64)) && statusOk(answer.status) && (answer.content_type === undefined || isText(answer.content_type)));
64
+ if (value.save !== undefined) {
65
+ const save = value.save;
66
+ if (!isObject(save) || !Array.isArray(save.answers))
67
+ say("save is {answers, default?}, answers a list of {url, content_type?, status?, text | base64} or {url, error}");
68
+ else {
69
+ save.answers.forEach((answer, i) => {
70
+ if (!fileOk(answer, true))
71
+ say(`save.answers.${i} is {url, content_type?, status?, text | base64} or {url, error}, its url absolute and its status 200 to 599`);
72
+ });
73
+ if (save.default !== undefined && !fileOk(save.default, false))
74
+ say("save.default is {content_type?, status?, text | base64} or {error}");
75
+ }
76
+ }
58
77
  for (const problem of problems)
59
78
  bad(problem);
60
79
  return problems.length ? undefined : value;
@@ -95,6 +114,24 @@ export async function fakeFetch(fake, url, part = {}) {
95
114
  // A page served as text has no title of its own: the fixture's.
96
115
  return page.ok && answer && !("error" in answer) && answer.title ? { ...page, title: clip(answer.title, TITLE_CAP) } : page;
97
116
  }
117
+ /** The guard's resolver and fetch for web_save in `fake`: every name a public address, each file answered from the
118
+ * fixture's `save` (by exact URL, else its default), every other URL a refused connection, as a host that is down. */
119
+ export function fakeSaveOptions(fake) {
120
+ return {
121
+ lookup: async () => [PUBLIC_ADDRESS],
122
+ fetchImpl: async (url) => {
123
+ const save = fake === "unavailable" ? undefined : fake.save;
124
+ const answer = save?.answers.find((one) => one.url === String(url)) ?? save?.default;
125
+ if (answer === undefined)
126
+ throw new TypeError("fetch failed", { cause: Object.assign(new Error("connect ECONNREFUSED"), { code: "ECONNREFUSED" }) });
127
+ if ("error" in answer)
128
+ throw new TypeError(answer.error);
129
+ const status = answer.status ?? 200;
130
+ const body = "base64" in answer ? Buffer.from(answer.base64, "base64") : answer.text;
131
+ return new Response(NULL_BODY.has(status) ? null : body, { status, headers: answer.content_type ? { "content-type": answer.content_type } : {} });
132
+ },
133
+ };
134
+ }
98
135
  /** A faked run's plane: web_search never a harness's own search (Claude's or Codex's, which would answer in its stead), so
99
136
  * the run's own web_search tool, the one the fake answers through, is the one its harness offers. */
100
137
  export function fakedPlane(plane) {
@@ -0,0 +1,75 @@
1
+ import type { JsonValue } from "@earendil-works/chord/json";
2
+ import type { TSchema } from "typebox";
3
+ import { type ToolRegistration } from "@earendil-works/pi-durable";
4
+ import type { PublicFetchOptions } from "@parcha/pi-browser";
5
+ import { type Workspace } from "./workspace/index.js";
6
+ export declare const WEB_SAVE_TOOL = "web_save";
7
+ /** The most bytes a saved file may have. */
8
+ export declare const SAVE_MAX_BYTES: number;
9
+ /** One deadline for a whole download: a 200 MiB file at about 350 KB/s. A page's 30 s (web-fetch-direct.ts) would cut a
10
+ * large file on any link under about 7 MB/s. */
11
+ export declare const SAVE_TIMEOUT_MS = 600000;
12
+ /** The folder a bare name is saved in. */
13
+ export declare const MEDIA_DIR = "media";
14
+ /** The longest path web_save takes, and the most characters of a declared type and of a failure's words an answer
15
+ * carries: with the URL's URL_MAX, they bound every answer (host-bounds.test.mjs). */
16
+ export declare const PATH_MAX_CHARS = 1024;
17
+ export declare const TYPE_MAX_CHARS = 255;
18
+ export declare const WORDS_MAX_CHARS = 2000;
19
+ export type Saved = {
20
+ ok: true;
21
+ path: string;
22
+ bytes: number;
23
+ content_type: string;
24
+ url: string;
25
+ };
26
+ export type Unsaved = {
27
+ ok: false;
28
+ url: string;
29
+ path?: string;
30
+ refused: string;
31
+ } | {
32
+ ok: false;
33
+ url: string;
34
+ path?: string;
35
+ error: string;
36
+ };
37
+ /** The guard's resolver and fetch (a test's, or the fakes'), the caller's signal, a lower cap, and other slots than the
38
+ * server's (a test's). */
39
+ export type SaveOptions = Omit<PublicFetchOptions, "maxBytes"> & {
40
+ maxBytes?: number;
41
+ timeoutMs?: number;
42
+ slots?: SaveSlots;
43
+ };
44
+ /** The most web_save downloads at once per runner, across its runs (SERVER_SLOTS); the rest wait under their own
45
+ * deadline. Each holds its file in memory until its one write: its size when its host states its length, about twice
46
+ * that at the peak when it does not (publicDownload). So a runner's downloads hold at most 800 MiB at 200 MiB a file,
47
+ * about 1.6 GiB when no host states a length; Mode 2's pieced writes (runner/big-writes.ts) can add 800 MiB more. */
48
+ export declare const SAVE_CONCURRENCY = 4;
49
+ /** Slots for downloads, handed out first come first served. `take` answers the slot's release (once), or rejects with
50
+ * the signal's reason if it aborts first, leaving the queue. */
51
+ export type SaveSlots = {
52
+ readonly size: number;
53
+ readonly busy: number;
54
+ readonly waiting: number;
55
+ take(signal: AbortSignal): Promise<() => void>;
56
+ };
57
+ export declare function saveSlots(size: number): SaveSlots;
58
+ /** The runner's one gate: at most SAVE_CONCURRENCY downloads at once per runner, across its runs. A run in the runner's
59
+ * own process takes it here; a run in a process of its own takes it over its channel (runner/save-slots.ts). */
60
+ export declare const SERVER_SLOTS: SaveSlots;
61
+ /** The type `bytes` are saved as at `path`, the host having declared `declared`, or why they are refused. */
62
+ export declare function typeFor(bytes: Uint8Array, declared: string, path: string): {
63
+ type: string;
64
+ } | {
65
+ refused: string;
66
+ };
67
+ /** Where `path` is saved: as given, or under media/ when it names no folder. */
68
+ export declare const savePath: (path: string) => string;
69
+ /** `args.url` downloaded and saved at `args.path` in `work`: what was saved, or why nothing was. Never throws. */
70
+ export declare function webSave(args: unknown, work: Workspace, options?: SaveOptions): Promise<Saved | Unsaved>;
71
+ /** The words the model reads: the answer's JSON. */
72
+ export declare const savedText: (answer: Saved | Unsaved) => string;
73
+ /** web_save on `work`, its download through `guard` (a test's or the fakes' resolver and fetch, none for the network), its
74
+ * slots `slots` (none: SERVER_SLOTS). */
75
+ export declare function webSaveTool(work: () => Promise<Workspace> | Workspace, guard: () => Promise<Omit<PublicFetchOptions, "maxBytes" | "signal">> | Omit<PublicFetchOptions, "maxBytes" | "signal">, slots?: SaveSlots): ToolRegistration<TSchema, JsonValue>;
@@ -0,0 +1,235 @@
1
+ // web_save: one public file saved into the run's Workspace (a bare name under media/), so a link that expires becomes a
2
+ // file the run keeps. It downloads through the public-host guard's bytes variant (pi-browser publicDownload, web_fetch's
3
+ // hop loop) and writes once through the Workspace, never over a path in use, a media type only when its bytes agree.
4
+ import { extname } from "node:path";
5
+ import { defineTool } from "@earendil-works/pi-durable";
6
+ import { extensionOf, typeOf } from "./file-types.js";
7
+ import { clip, URL_MAX } from "./web-fetch-direct.js";
8
+ import { forModel } from "./result.js";
9
+ import { isWorkspaceError, workspaceErrorWords } from "./workspace/index.js";
10
+ export const WEB_SAVE_TOOL = "web_save";
11
+ /** The most bytes a saved file may have. */
12
+ export const SAVE_MAX_BYTES = 200 * 1024 * 1024;
13
+ /** One deadline for a whole download: a 200 MiB file at about 350 KB/s. A page's 30 s (web-fetch-direct.ts) would cut a
14
+ * large file on any link under about 7 MB/s. */
15
+ export const SAVE_TIMEOUT_MS = 600_000;
16
+ /** The folder a bare name is saved in. */
17
+ export const MEDIA_DIR = "media";
18
+ /** The longest path web_save takes, and the most characters of a declared type and of a failure's words an answer
19
+ * carries: with the URL's URL_MAX, they bound every answer (host-bounds.test.mjs). */
20
+ export const PATH_MAX_CHARS = 1_024;
21
+ export const TYPE_MAX_CHARS = 255;
22
+ export const WORDS_MAX_CHARS = 2_000;
23
+ /** The most web_save downloads at once per runner, across its runs (SERVER_SLOTS); the rest wait under their own
24
+ * deadline. Each holds its file in memory until its one write: its size when its host states its length, about twice
25
+ * that at the peak when it does not (publicDownload). So a runner's downloads hold at most 800 MiB at 200 MiB a file,
26
+ * about 1.6 GiB when no host states a length; Mode 2's pieced writes (runner/big-writes.ts) can add 800 MiB more. */
27
+ export const SAVE_CONCURRENCY = 4;
28
+ export function saveSlots(size) {
29
+ let busy = 0;
30
+ const queue = [];
31
+ const releaser = () => {
32
+ let done = false;
33
+ return () => {
34
+ if (done)
35
+ return;
36
+ done = true;
37
+ // The slot goes straight to the next waiter, so busy only drops when no one waits.
38
+ const next = queue.shift();
39
+ if (next)
40
+ next();
41
+ else
42
+ busy--;
43
+ };
44
+ };
45
+ return {
46
+ size,
47
+ get busy() { return busy; },
48
+ get waiting() { return queue.length; },
49
+ take(signal) {
50
+ if (signal.aborted)
51
+ return Promise.reject(signal.reason);
52
+ if (busy < size) {
53
+ busy++;
54
+ return Promise.resolve(releaser());
55
+ }
56
+ return new Promise((resolve, reject) => {
57
+ const leave = () => {
58
+ queue.splice(queue.indexOf(grant), 1);
59
+ reject(signal.reason);
60
+ };
61
+ const grant = () => {
62
+ signal.removeEventListener("abort", leave);
63
+ resolve(releaser());
64
+ };
65
+ queue.push(grant);
66
+ signal.addEventListener("abort", leave, { once: true });
67
+ });
68
+ },
69
+ };
70
+ }
71
+ /** The runner's one gate: at most SAVE_CONCURRENCY downloads at once per runner, across its runs. A run in the runner's
72
+ * own process takes it here; a run in a process of its own takes it over its channel (runner/save-slots.ts). */
73
+ export const SERVER_SLOTS = saveSlots(SAVE_CONCURRENCY);
74
+ const ascii = (b, at, text) => b.length >= at + text.length && [...text].every((c, i) => b[at + i] === c.charCodeAt(0));
75
+ const MEDIA = [
76
+ { types: ["image/png"], test: (b) => b.length >= 8 && [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a].every((x, i) => b[i] === x) },
77
+ { types: ["image/jpeg"], test: (b) => b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff },
78
+ { types: ["image/gif"], test: (b) => ascii(b, 0, "GIF87a") || ascii(b, 0, "GIF89a") },
79
+ { types: ["image/webp"], test: (b) => ascii(b, 0, "RIFF") && ascii(b, 8, "WEBP") },
80
+ { types: ["audio/wav"], test: (b) => ascii(b, 0, "RIFF") && ascii(b, 8, "WAVE") },
81
+ // An ID3 tag, or an MPEG audio frame's sync: eleven set bits, then a layer that is not the reserved 00 (which is AAC's).
82
+ { types: ["audio/mpeg"], test: (b) => ascii(b, 0, "ID3") || (b.length >= 2 && b[0] === 0xff && (b[1] & 0xe0) === 0xe0 && (b[1] & 0x06) !== 0) },
83
+ { types: ["audio/ogg"], test: (b) => ascii(b, 0, "OggS") },
84
+ // ISO media: an ftyp box first. Its brand says audio (M4A, M4B) or not; either type may be declared or named.
85
+ { types: ["video/mp4", "audio/mp4"], test: (b) => ascii(b, 4, "ftyp") && !(ascii(b, 8, "M4A ") || ascii(b, 8, "M4B ")) },
86
+ { types: ["audio/mp4", "video/mp4"], test: (b) => ascii(b, 4, "ftyp") },
87
+ // EBML: WebM (and Matroska).
88
+ { types: ["video/webm", "audio/webm"], test: (b) => b[0] === 0x1a && b[1] === 0x45 && b[2] === 0xdf && b[3] === 0xa3 },
89
+ ];
90
+ /** Every type MEDIA checks: one of these declared must carry its signature. */
91
+ const MEDIA_TYPES = new Set(MEDIA.flatMap((kind) => kind.types));
92
+ /** Names hosts give some of those types besides the one file-types.ts serves. */
93
+ const ALIASES = new Map([["image/jpg", "image/jpeg"], ["image/pjpeg", "image/jpeg"], ["audio/mp3", "audio/mpeg"], ["audio/x-wav", "audio/wav"], ["audio/wave", "audio/wav"], ["audio/vnd.wave", "audio/wav"], ["audio/x-m4a", "audio/mp4"], ["audio/m4a", "audio/mp4"]]);
94
+ /** Declared types that say nothing about the bytes. */
95
+ const UNTYPED = new Set(["", "application/octet-stream", "binary/octet-stream", "application/binary"]);
96
+ /** A Content-Type as its bare type, lower case, its parameters dropped and its aliases resolved. */
97
+ const bare = (type) => {
98
+ const plain = (type ?? "").split(";")[0].trim().toLowerCase();
99
+ return ALIASES.get(plain) ?? plain;
100
+ };
101
+ /** The type `bytes` are saved as at `path`, the host having declared `declared`, or why they are refused. */
102
+ export function typeFor(bytes, declared, path) {
103
+ if (declared.length > TYPE_MAX_CHARS)
104
+ return { refused: `refused: the host's Content-Type is longer than ${TYPE_MAX_CHARS} characters` };
105
+ const said = bare(declared);
106
+ const named = typeOf(path) === undefined ? undefined : bare(typeOf(path));
107
+ const ext = path.slice(path.lastIndexOf("/") + 1).includes(".") ? path.slice(path.lastIndexOf(".")) : "";
108
+ const kind = MEDIA.find((one) => one.test(bytes));
109
+ if (kind) {
110
+ const sniffed = kind.types[0];
111
+ if (!UNTYPED.has(said) && !kind.types.includes(said))
112
+ return { refused: `refused: the host says ${said}, but the bytes are ${sniffed}` };
113
+ if (named && !kind.types.includes(named))
114
+ return { refused: `refused: the path's extension ${ext} is ${named}, but the bytes are ${sniffed}; save it under an extension of that type` };
115
+ if (!named) {
116
+ const type = kind.types.includes(said) ? said : sniffed;
117
+ // audio/webm has no extension of its own; .webm (video/webm) holds it.
118
+ return { refused: `refused: ${path} has no extension of ${type}; save it as ${path.slice(0, path.length - extname(path).length)}.${extensionOf(type) ?? extensionOf(sniffed)}` };
119
+ }
120
+ return { type: named };
121
+ }
122
+ if (MEDIA_TYPES.has(said))
123
+ return { refused: `refused: the host says ${said}, but the bytes are not ${said}` };
124
+ if (named !== undefined && named === said)
125
+ return { type: said };
126
+ return { refused: `refused: ${said ? `${said} is` : "a file with no type is"} not a media type this server plays${named ? `, and the path's extension ${ext} says ${named}` : ", and the path's extension does not say it is"}` };
127
+ }
128
+ /** A failure's words, at most WORDS_MAX_CHARS. */
129
+ const wordsOf = (error) => clip(String(error?.message ?? error), WORDS_MAX_CHARS);
130
+ /** Where `path` is saved: as given, or under media/ when it names no folder. */
131
+ export const savePath = (path) => (path.includes("/") ? path : `${MEDIA_DIR}/${path}`);
132
+ /** `args.url` downloaded and saved at `args.path` in `work`: what was saved, or why nothing was. Never throws. */
133
+ export async function webSave(args, work, options = {}) {
134
+ const { url, path } = (args && typeof args === "object" ? args : {});
135
+ const shown = typeof url === "string" ? clip(url, URL_MAX) : "";
136
+ if (typeof url !== "string" || !URL.canParse(url))
137
+ return { ok: false, url: shown, error: "url is not an absolute URL" };
138
+ if (url.length > URL_MAX)
139
+ return { ok: false, url: shown, error: `url is longer than ${URL_MAX.toLocaleString("en-US")} characters` };
140
+ if (typeof path !== "string" || path === "")
141
+ return { ok: false, url: shown, error: "path is required: where in the run's folder to save the file (a bare name goes under media/)" };
142
+ if (path.length > PATH_MAX_CHARS)
143
+ return { ok: false, url: shown, error: `path is longer than ${PATH_MAX_CHARS.toLocaleString("en-US")} characters` };
144
+ const at = savePath(path);
145
+ const failed = (error) => {
146
+ const words = workspaceErrorWords(error);
147
+ if (words)
148
+ return isWorkspaceError(error, "ESCAPE") || isWorkspaceError(error, "REFUSED") || isWorkspaceError(error, "EXISTS") ? { ok: false, url: shown, path: at, refused: clip(`refused: ${words}`, WORDS_MAX_CHARS) } : { ok: false, url: shown, path: at, error: clip(words, WORDS_MAX_CHARS) };
149
+ return { ok: false, url: shown, path: at, error: wordsOf(error) };
150
+ };
151
+ const taken = async () => {
152
+ const there = await work.stat(at);
153
+ return there ? { ok: false, url: shown, path: at, refused: `refused: ${at} already holds a ${there.kind === "dir" ? "folder" : there.kind === "link" ? "link" : "file"}; web_save never overwrites, so pick another path` } : undefined;
154
+ };
155
+ try {
156
+ const before = await taken();
157
+ if (before)
158
+ return before;
159
+ }
160
+ catch (error) {
161
+ return failed(error);
162
+ }
163
+ const { BrowserFailureError, publicDownload } = await import("@parcha/pi-browser");
164
+ const { timeoutMs = SAVE_TIMEOUT_MS, maxBytes = SAVE_MAX_BYTES, slots = SERVER_SLOTS, ...guard } = options;
165
+ const signal = AbortSignal.any([AbortSignal.timeout(timeoutMs), ...(guard.signal ? [guard.signal] : [])]);
166
+ const cut = (error, waited) => {
167
+ const name = error?.name;
168
+ if (name === "TimeoutError" && !guard.signal?.aborted)
169
+ return { ok: false, url: shown, path: at, error: `the download did not finish in ${timeoutMs / 1000} s${waited}` };
170
+ return { ok: false, url: shown, path: at, error: wordsOf(error) };
171
+ };
172
+ let release;
173
+ try {
174
+ release = await slots.take(signal);
175
+ }
176
+ catch (error) {
177
+ return cut(error, `: it waited all that time for a free download slot (at most ${slots.size} at once)`);
178
+ }
179
+ // The slot is held while the bytes are in memory: through the download, the type check and the write.
180
+ try {
181
+ let file;
182
+ try {
183
+ file = await publicDownload(url, { ...guard, maxBytes, signal });
184
+ }
185
+ catch (error) {
186
+ if (error instanceof BrowserFailureError && error.failure.code === "refused")
187
+ return { ok: false, url: shown, path: at, refused: clip(error.message, WORDS_MAX_CHARS) };
188
+ return cut(error, "");
189
+ }
190
+ const final = clip(file.url, URL_MAX);
191
+ if (file.bytes === null)
192
+ return { ok: false, url: final, path: at, error: `the host answered ${file.status}` };
193
+ const typed = typeFor(file.bytes, file.contentType, at);
194
+ if ("refused" in typed)
195
+ return { ok: false, url: final, path: at, refused: clip(typed.refused, WORDS_MAX_CHARS) };
196
+ try {
197
+ // Again just before the write: a file made at the path while the download ran is kept, not replaced.
198
+ const after = await taken();
199
+ if (after)
200
+ return { ...after, url: final };
201
+ await work.write(at, file.bytes);
202
+ }
203
+ catch (error) {
204
+ return { ...failed(error), url: final };
205
+ }
206
+ return { ok: true, path: at, bytes: file.bytes.length, content_type: typed.type, url: final };
207
+ }
208
+ finally {
209
+ release();
210
+ }
211
+ }
212
+ /** The words the model reads: the answer's JSON. */
213
+ export const savedText = (answer) => JSON.stringify(answer);
214
+ /** web_save on `work`, its download through `guard` (a test's or the fakes' resolver and fetch, none for the network), its
215
+ * slots `slots` (none: SERVER_SLOTS). */
216
+ export function webSaveTool(work, guard, slots) {
217
+ return defineTool({
218
+ 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.`,
220
+ parameters: {
221
+ type: "object",
222
+ additionalProperties: false,
223
+ properties: {
224
+ url: { type: "string", description: "The file's absolute http(s) URL." },
225
+ path: { type: "string", description: `Where to save it in the run's folder, e.g. ${MEDIA_DIR}/cat.png; a bare name goes under ${MEDIA_DIR}/.` },
226
+ },
227
+ required: ["url", "path"],
228
+ },
229
+ replay: "unsafe",
230
+ execute: async (args, _api, context) => {
231
+ const answer = await webSave(args, await work(), { ...(await guard()), ...(context?.abortSignal ? { signal: context.abortSignal } : {}), ...(slots ? { slots } : {}) });
232
+ return forModel(savedText(answer), { details: answer });
233
+ },
234
+ });
235
+ }
@@ -27,12 +27,15 @@ export interface ArchilClaimOptions {
27
27
  readonly makeDisk?: (options: ArchilDiskOptions) => ArchilDisk;
28
28
  /** The run's mount credential, minted when a mount first asks: the run and this claim's epoch (its token user's
29
29
  * nickname, agentrun:<run>:<epoch>, so a reclaim removes an earlier claim's first) and its ttl (the run's lifetime
30
- * bound, the safety net if the remove never comes); a loopback control plane and its fetch in a test. Absent: a mount
31
- * is refused in words. */
30
+ * bound, the safety net if the remove never comes). Absent: a mount is refused in words. */
32
31
  readonly mount?: {
33
32
  readonly runId: string;
34
33
  readonly epoch: number;
35
34
  readonly ttlMs: number;
35
+ };
36
+ /** Archil's control plane, where the run's disk is read (and made) and its mount credential minted: a loopback fake
37
+ * and its fetch in a test. Absent: the region's own. */
38
+ readonly control?: {
36
39
  readonly baseUrl?: string;
37
40
  readonly fetch?: typeof fetch;
38
41
  };
@@ -22,6 +22,7 @@ import { archilDisk, pinnedImage } from "./archil-disk.js";
22
22
  import { mintMountToken, nicknameOf, removeMountToken, removeOlderMountTokens, removeRunMountTokens } from "./archil-mount-credential.js";
23
23
  import { COMPUTER_LIFETIME_MS } from "./computer-deps.js";
24
24
  import { heldOrThrow } from "../runner/held.js";
25
+ import { piecedWorkspace } from "./pieced.js";
25
26
  import { runDiskOf } from "./run-disk.js";
26
27
  export { ARCHIL_API_KEY_ROW };
27
28
  /** A claim this step refused, in words a person reads: no Archil call was made. */
@@ -61,7 +62,9 @@ export async function archilWhereHeld(options) {
61
62
  secrets: new Set(),
62
63
  release: () => void given.release().catch(() => undefined),
63
64
  };
64
- HELD_ARCHIL.set(claim, given.workspace);
65
+ // A write bigger than a piece crosses in pieces its runner pulls, and is written there once (runner/big-writes.ts): one
66
+ // call would not fit the channel's frame.
67
+ HELD_ARCHIL.set(claim, piecedWorkspace(given.workspace, given.pieces, options.signal));
65
68
  return claim;
66
69
  }
67
70
  export async function archilClaim(options) {
@@ -84,7 +87,7 @@ export async function archilClaim(options) {
84
87
  held.add(apiKey);
85
88
  // The run's disk first (run-disk.ts): its launch's, else its agent's, made now when it has none; every call below is on
86
89
  // it alone, the run's mount credential minted, revoked and reclaimed there.
87
- const control = { region: settings.region, key: () => apiKey, ...(options.mount?.baseUrl ? { baseUrl: options.mount.baseUrl } : {}), ...(options.mount?.fetch ? { fetch: options.mount.fetch } : {}) };
90
+ const control = { region: settings.region, key: () => apiKey, ...(options.control?.baseUrl ? { baseUrl: options.control.baseUrl } : {}), ...(options.control?.fetch ? { fetch: options.control.fetch } : {}) };
88
91
  let chosen;
89
92
  try {
90
93
  chosen = await runDiskOf({ store: options.run.store, agentId: options.run.agentId, ...(options.mount ? { runId: options.mount.runId } : {}), ...(options.run.launch ? { launch: options.run.launch } : {}), control, signal: options.signal });
@@ -60,9 +60,18 @@ export type ArchilExecAnswer = {
60
60
  readonly stdout: string;
61
61
  readonly stderr: string;
62
62
  };
63
+ /** The disk itself is not there: Archil's lookup of it, made before the SDK's first call, answered 404 (removed, or the
64
+ * key's account or region holds none of that id). Every SDK call fails with it. It carries no HTTP `status`, so no
65
+ * caller reads it as a missing file or folder. */
66
+ export declare class ArchilDiskMissing extends Error {
67
+ readonly disk: string;
68
+ readonly region: string;
69
+ constructor(disk: string, region: string, words: string, options?: ErrorOptions);
70
+ }
63
71
  /**
64
72
  * An Archil disk, keys relative to its root. A failed call rejects with an error carrying the HTTP `status` when there
65
- * was an answer (the SDK's ArchilS3Error and ArchilApiError do, and so does the ranged read here).
73
+ * was an answer (the SDK's ArchilS3Error and ArchilApiError do, and so does the ranged read here), or, from every call
74
+ * but the ranged read, ArchilDiskMissing when Archil has no such disk.
66
75
  */
67
76
  export interface ArchilDisk {
68
77
  readonly id: string;
@@ -16,6 +16,19 @@ export function pinnedImage(image) {
16
16
  }
17
17
  /** The one network an exec is given: no egress. */
18
18
  export const DENY_EGRESS = Object.freeze({ egress: Object.freeze({ default: "deny" }) });
19
+ /** The disk itself is not there: Archil's lookup of it, made before the SDK's first call, answered 404 (removed, or the
20
+ * key's account or region holds none of that id). Every SDK call fails with it. It carries no HTTP `status`, so no
21
+ * caller reads it as a missing file or folder. */
22
+ export class ArchilDiskMissing extends Error {
23
+ disk;
24
+ region;
25
+ constructor(disk, region, words, options) {
26
+ super(`the Archil disk ${disk} is not there in region ${region}: ${words}`, options);
27
+ this.disk = disk;
28
+ this.region = region;
29
+ this.name = "ArchilDiskMissing";
30
+ }
31
+ }
19
32
  const LOOPBACK = /^(?:127\.\d+\.\d+\.\d+|localhost|\[::1\])$/; // key-gate: loopback-rule names loopback hosts to allow plain http only to them, in tests
20
33
  /** The S3 endpoint, checked: https on an Archil host whose name carries the region ("aws-us-east-1" → "…​.us-east-1.aws.
21
34
  * …archil.com"), or, when the control plane is a loopback one too (a test), http(s) to this machine's loopback. */
@@ -143,7 +156,12 @@ class SdkArchilDisk {
143
156
  const { region, baseUrl } = this.#options;
144
157
  const { Archil } = await import("disk");
145
158
  const client = new Archil({ apiKey, region, s3BaseUrl: this.#s3, ...(baseUrl === undefined ? {} : { baseUrl }) });
146
- return { client, disk: await client.disks.get(this.id) };
159
+ const disk = await client.disks.get(this.id).catch((error) => {
160
+ if (error?.status !== 404)
161
+ throw error;
162
+ throw new ArchilDiskMissing(this.id, region, String(error?.message ?? error), { cause: error });
163
+ });
164
+ return { client, disk };
147
165
  })();
148
166
  // A failed start (the key refused, the disk not found) is tried again by the next call.
149
167
  ready.catch(() => { if (this.#ready === ready) {
@@ -39,6 +39,9 @@ declare class ArchilWorkspace implements Workspace {
39
39
  stat(path: string): Promise<Stat | undefined>;
40
40
  list(dir: string): Promise<Entry[]>;
41
41
  mkdir(dir: string): Promise<void>;
42
+ /** The root made on the disk when it is not there yet; one already there is not put again, so a computer whose mount
43
+ * holds it (Archil's write delegation refuses a put there) never stands in the way. A failure throws, in Archil's words. */
44
+ ensureRoot(): Promise<void>;
42
45
  grep(pattern: string, options?: GrepOptions): Promise<GrepResult>;
43
46
  remove(path: string, options?: {
44
47
  readonly recursive?: boolean;