@parcha/agentrun-serve 0.0.0-stage → 0.1.0-beta.30

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 (273) hide show
  1. package/CHANGELOG.md +748 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +2190 -2
  5. package/dist/adapters.d.ts +234 -0
  6. package/dist/adapters.js +585 -0
  7. package/dist/agents.d.ts +130 -0
  8. package/dist/agents.js +308 -0
  9. package/dist/app.d.ts +7 -0
  10. package/dist/app.js +384 -0
  11. package/dist/background.d.ts +28 -0
  12. package/dist/background.js +376 -0
  13. package/dist/bound-files.d.ts +4 -0
  14. package/dist/bound-files.js +164 -0
  15. package/dist/box/record.d.ts +6 -0
  16. package/dist/box/record.js +41 -0
  17. package/dist/box/sweep.d.ts +53 -0
  18. package/dist/box/sweep.js +193 -0
  19. package/dist/box-egress.d.ts +98 -0
  20. package/dist/box-egress.js +259 -0
  21. package/dist/box-image.d.ts +98 -0
  22. package/dist/box-image.js +285 -0
  23. package/dist/box-relay-vm.d.ts +80 -0
  24. package/dist/box-relay-vm.js +389 -0
  25. package/dist/box-relay.d.ts +45 -0
  26. package/dist/box-relay.js +227 -0
  27. package/dist/boxes.d.ts +72 -0
  28. package/dist/boxes.js +189 -0
  29. package/dist/browser-cost.d.ts +41 -0
  30. package/dist/browser-cost.js +158 -0
  31. package/dist/cap.d.ts +332 -0
  32. package/dist/cap.js +992 -0
  33. package/dist/catalog.d.ts +20 -0
  34. package/dist/catalog.js +53 -0
  35. package/dist/cli.d.ts +2 -0
  36. package/dist/cli.js +167 -0
  37. package/dist/coding-tools.d.ts +35 -0
  38. package/dist/coding-tools.js +87 -0
  39. package/dist/console/THIRD-PARTY-NOTICES.txt +1721 -0
  40. package/dist/console/assets/index-34jfpIbQ.js +481 -0
  41. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  42. package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  43. package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-CIEtRijs.woff +0 -0
  44. package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-BB5xRk30.woff +0 -0
  45. package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
  46. package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-BHyURHCj.woff +0 -0
  47. package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-C_uLvvQ5.woff2 +0 -0
  48. package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-Dj6eZy5f.woff2 +0 -0
  49. package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-DpeVePZf.woff +0 -0
  50. package/dist/console/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  51. package/dist/console/assets/jetbrains-mono-greek-400-normal-CNojz0t3.woff +0 -0
  52. package/dist/console/assets/jetbrains-mono-greek-600-normal-3KAm9r92.woff +0 -0
  53. package/dist/console/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
  54. package/dist/console/assets/jetbrains-mono-latin-400-normal-B11XCQ5g.woff +0 -0
  55. package/dist/console/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  56. package/dist/console/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
  57. package/dist/console/assets/jetbrains-mono-latin-600-normal-DXv3JcnD.woff +0 -0
  58. package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  59. package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-DHMOLxAi.woff +0 -0
  60. package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
  61. package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-DiQlUoE6.woff +0 -0
  62. package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-BeU3T8wf.woff +0 -0
  63. package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-ByoDsISC.woff2 +0 -0
  64. package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-CSpzN4cI.woff +0 -0
  65. package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-Dtizs43-.woff2 +0 -0
  66. package/dist/console/assets/schibsted-grotesk-latin-400-normal-Cph9ettZ.woff2 +0 -0
  67. package/dist/console/assets/schibsted-grotesk-latin-400-normal-DfGZKnlb.woff +0 -0
  68. package/dist/console/assets/schibsted-grotesk-latin-600-normal-BGBUNdzT.woff2 +0 -0
  69. package/dist/console/assets/schibsted-grotesk-latin-600-normal-COje25QW.woff +0 -0
  70. package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-4l4lq8zr.woff2 +0 -0
  71. package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-BGzXWJeR.woff +0 -0
  72. package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-8_E36CQj.woff2 +0 -0
  73. package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-C27an7Zc.woff +0 -0
  74. package/dist/console/index.html +15 -0
  75. package/dist/content-filter.d.ts +7 -0
  76. package/dist/content-filter.js +23 -0
  77. package/dist/daytona-api.d.ts +21 -0
  78. package/dist/daytona-api.js +101 -0
  79. package/dist/decision-rows.d.ts +19 -0
  80. package/dist/decision-rows.js +123 -0
  81. package/dist/decisions.d.ts +94 -0
  82. package/dist/decisions.js +184 -0
  83. package/dist/effort-guidance.d.ts +5 -0
  84. package/dist/effort-guidance.js +14 -0
  85. package/dist/environment.d.ts +5 -0
  86. package/dist/environment.js +11 -0
  87. package/dist/errors.d.ts +74 -0
  88. package/dist/errors.js +69 -0
  89. package/dist/exa-keyless.d.ts +35 -0
  90. package/dist/exa-keyless.js +202 -0
  91. package/dist/fetch-page.d.ts +114 -0
  92. package/dist/fetch-page.js +182 -0
  93. package/dist/files.d.ts +65 -0
  94. package/dist/files.js +158 -0
  95. package/dist/grade.d.ts +93 -0
  96. package/dist/grade.js +328 -0
  97. package/dist/graph-served.d.ts +23 -0
  98. package/dist/graph-served.js +75 -0
  99. package/dist/graph-view.d.ts +102 -0
  100. package/dist/graph-view.js +219 -0
  101. package/dist/harness-app.d.ts +40 -0
  102. package/dist/harness-app.js +708 -0
  103. package/dist/harness-opencode/adapter.d.ts +45 -0
  104. package/dist/harness-opencode/adapter.js +272 -0
  105. package/dist/harness-opencode/binary.d.ts +18 -0
  106. package/dist/harness-opencode/binary.js +87 -0
  107. package/dist/harness-opencode/config.d.ts +24 -0
  108. package/dist/harness-opencode/config.js +61 -0
  109. package/dist/harness-opencode/harness.d.ts +77 -0
  110. package/dist/harness-opencode/harness.js +620 -0
  111. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  112. package/dist/harness-opencode/host/mcp.js +208 -0
  113. package/dist/harness-opencode/host/policy.d.ts +71 -0
  114. package/dist/harness-opencode/host/policy.js +419 -0
  115. package/dist/harness-opencode/host/server.d.ts +55 -0
  116. package/dist/harness-opencode/host/server.js +165 -0
  117. package/dist/harness-opencode/index.d.ts +9 -0
  118. package/dist/harness-opencode/index.js +6 -0
  119. package/dist/harness-opencode/verify.d.ts +32 -0
  120. package/dist/harness-opencode/verify.js +75 -0
  121. package/dist/harness-opencode/versions.d.ts +33 -0
  122. package/dist/harness-opencode/versions.js +64 -0
  123. package/dist/harness.d.ts +56 -0
  124. package/dist/harness.js +77 -0
  125. package/dist/home-path.d.ts +27 -0
  126. package/dist/home-path.js +78 -0
  127. package/dist/host-tools.d.ts +30 -0
  128. package/dist/host-tools.js +154 -0
  129. package/dist/host.d.ts +39 -0
  130. package/dist/host.js +85 -0
  131. package/dist/hosted-search.d.ts +27 -0
  132. package/dist/hosted-search.js +133 -0
  133. package/dist/import-sources.d.ts +104 -0
  134. package/dist/import-sources.js +629 -0
  135. package/dist/import-summary.d.ts +25 -0
  136. package/dist/import-summary.js +75 -0
  137. package/dist/import-worker.d.ts +26 -0
  138. package/dist/import-worker.js +41 -0
  139. package/dist/import.d.ts +145 -0
  140. package/dist/import.js +1222 -0
  141. package/dist/index.d.ts +7 -0
  142. package/dist/index.js +6 -0
  143. package/dist/key-check.d.ts +37 -0
  144. package/dist/key-check.js +112 -0
  145. package/dist/key-refusal.d.ts +51 -0
  146. package/dist/key-refusal.js +191 -0
  147. package/dist/learn/check.d.ts +108 -0
  148. package/dist/learn/check.js +277 -0
  149. package/dist/learn/grade.d.ts +80 -0
  150. package/dist/learn/grade.js +445 -0
  151. package/dist/learn/index.d.ts +7 -0
  152. package/dist/learn/index.js +11 -0
  153. package/dist/learn/invisible.d.ts +5 -0
  154. package/dist/learn/invisible.js +42 -0
  155. package/dist/learn/notes.d.ts +59 -0
  156. package/dist/learn/notes.js +147 -0
  157. package/dist/learn/reflect.d.ts +49 -0
  158. package/dist/learn/reflect.js +213 -0
  159. package/dist/learn/secrets.d.ts +18 -0
  160. package/dist/learn/secrets.js +131 -0
  161. package/dist/learn/skills.d.ts +97 -0
  162. package/dist/learn/skills.js +271 -0
  163. package/dist/learned-workflow.d.ts +59 -0
  164. package/dist/learned-workflow.js +191 -0
  165. package/dist/learning-routes.d.ts +196 -0
  166. package/dist/learning-routes.js +609 -0
  167. package/dist/learning-run.d.ts +306 -0
  168. package/dist/learning-run.js +819 -0
  169. package/dist/learning-words.d.ts +76 -0
  170. package/dist/learning-words.js +174 -0
  171. package/dist/learning.d.ts +418 -0
  172. package/dist/learning.js +946 -0
  173. package/dist/llm.d.ts +40 -0
  174. package/dist/llm.js +37 -0
  175. package/dist/llms.txt +37 -0
  176. package/dist/mcp-servers.d.ts +118 -0
  177. package/dist/mcp-servers.js +450 -0
  178. package/dist/mcp.d.ts +51 -0
  179. package/dist/mcp.js +392 -0
  180. package/dist/model.d.ts +186 -0
  181. package/dist/model.js +485 -0
  182. package/dist/monid.d.ts +74 -0
  183. package/dist/monid.js +277 -0
  184. package/dist/openapi/agentrun-v2.openapi.json +4806 -0
  185. package/dist/openapi.d.ts +10 -0
  186. package/dist/openapi.js +1727 -0
  187. package/dist/owner.d.ts +55 -0
  188. package/dist/owner.js +222 -0
  189. package/dist/packs.d.ts +71 -0
  190. package/dist/packs.js +180 -0
  191. package/dist/page.d.ts +32 -0
  192. package/dist/page.js +133 -0
  193. package/dist/paid-calls.d.ts +50 -0
  194. package/dist/paid-calls.js +110 -0
  195. package/dist/pause.d.ts +70 -0
  196. package/dist/pause.js +97 -0
  197. package/dist/pdf-pages.d.ts +44 -0
  198. package/dist/pdf-pages.js +147 -0
  199. package/dist/place.d.ts +69 -0
  200. package/dist/place.js +137 -0
  201. package/dist/print.d.ts +20 -0
  202. package/dist/print.js +29 -0
  203. package/dist/propose.d.ts +40 -0
  204. package/dist/propose.js +112 -0
  205. package/dist/quiet-sqlite-warning.d.ts +1 -0
  206. package/dist/quiet-sqlite-warning.js +14 -0
  207. package/dist/request-start.d.ts +22 -0
  208. package/dist/request-start.js +350 -0
  209. package/dist/result.d.ts +3 -0
  210. package/dist/result.js +5 -0
  211. package/dist/rows.d.ts +46 -0
  212. package/dist/rows.js +121 -0
  213. package/dist/run-box.d.ts +186 -0
  214. package/dist/run-box.js +590 -0
  215. package/dist/run-manifest.d.ts +27 -0
  216. package/dist/run-manifest.js +60 -0
  217. package/dist/runnable.d.ts +83 -0
  218. package/dist/runnable.js +170 -0
  219. package/dist/runs.d.ts +1062 -0
  220. package/dist/runs.js +3020 -0
  221. package/dist/secret-cut.d.ts +27 -0
  222. package/dist/secret-cut.js +109 -0
  223. package/dist/secrets.d.ts +62 -0
  224. package/dist/secrets.js +158 -0
  225. package/dist/server-lock.d.ts +44 -0
  226. package/dist/server-lock.js +140 -0
  227. package/dist/server.d.ts +722 -0
  228. package/dist/server.js +2118 -0
  229. package/dist/sessions.d.ts +4 -0
  230. package/dist/sessions.js +105 -0
  231. package/dist/sign-ins.d.ts +99 -0
  232. package/dist/sign-ins.js +288 -0
  233. package/dist/skills.d.ts +43 -0
  234. package/dist/skills.js +96 -0
  235. package/dist/stats.d.ts +106 -0
  236. package/dist/stats.js +103 -0
  237. package/dist/tool-gate.d.ts +266 -0
  238. package/dist/tool-gate.js +554 -0
  239. package/dist/tool-keys.d.ts +187 -0
  240. package/dist/tool-keys.js +315 -0
  241. package/dist/tool-plane.d.ts +228 -0
  242. package/dist/tool-plane.js +400 -0
  243. package/dist/tools.d.ts +202 -0
  244. package/dist/tools.js +372 -0
  245. package/dist/trigger-secrets.d.ts +32 -0
  246. package/dist/trigger-secrets.js +143 -0
  247. package/dist/triggers.d.ts +439 -0
  248. package/dist/triggers.js +863 -0
  249. package/dist/turn-end.d.ts +24 -0
  250. package/dist/turn-end.js +15 -0
  251. package/dist/turns.d.ts +34 -0
  252. package/dist/turns.js +202 -0
  253. package/dist/uploads.d.ts +104 -0
  254. package/dist/uploads.js +474 -0
  255. package/dist/usage-lines.d.ts +26 -0
  256. package/dist/usage-lines.js +28 -0
  257. package/dist/usage.d.ts +29 -0
  258. package/dist/usage.js +58 -0
  259. package/dist/validate.d.ts +57 -0
  260. package/dist/validate.js +184 -0
  261. package/dist/web-fetch.d.ts +64 -0
  262. package/dist/web-fetch.js +262 -0
  263. package/dist/web-search.d.ts +54 -0
  264. package/dist/web-search.js +136 -0
  265. package/dist/webhooks.d.ts +189 -0
  266. package/dist/webhooks.js +503 -0
  267. package/dist/workspace-paths.d.ts +33 -0
  268. package/dist/workspace-paths.js +104 -0
  269. package/dist/workspace.d.ts +88 -0
  270. package/dist/workspace.js +369 -0
  271. package/launcher/agentrun-serve +109 -0
  272. package/package.json +100 -4
  273. package/skills/agentrun-serve/SKILL.md +128 -0
package/dist/page.js ADDED
@@ -0,0 +1,133 @@
1
+ // The console at "/" (apps/console, which this package's build copies into dist/console): its index.html and Vite's
2
+ // hashed assets under /assets/, public, under one strict CSP. The console signs a person in itself. With accounts it
3
+ // takes the owner's session cookie (owner.ts); without, the server's token as a cookie that the printed link (`/?token=`)
4
+ // sets once. Either stands in for the Bearer header on /v2, and for a write only from this origin with a JSON body, or
5
+ // with any body on a route that takes bytes (a PUT or POST marked `raw` in server.ts). The
6
+ // store's read-only JSON (/api/*, pi-durable-agent's store page's data) answers the Bearer token or either cookie.
7
+ import { createHash, createHmac, timingSafeEqual } from "node:crypto";
8
+ import { readFile, realpath, stat } from "node:fs/promises";
9
+ import { extname, join, sep } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+ import { storeApi } from "@parcha/pi-durable-agent/serve";
12
+ import { ApiError } from "./errors.js";
13
+ const CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'";
14
+ const SECURITY = { "content-security-policy": CSP, "x-content-type-options": "nosniff", "referrer-policy": "no-referrer", "cache-control": "no-store" };
15
+ const HTML = "text/html; charset=utf-8";
16
+ /** The console's build, beside the server. */
17
+ const CONSOLE_DIR = fileURLToPath(new URL("./console/", import.meta.url));
18
+ /** The kinds of file Vite builds the console into; any other is not served. */
19
+ const CONSOLE_TYPES = { ".html": HTML, ".js": "text/javascript; charset=utf-8", ".css": "text/css; charset=utf-8", ".woff2": "font/woff2", ".woff": "font/woff" };
20
+ /** A segment of an asset's path as sent: no dot segment, no hidden file, no percent-encoding, no separator. */
21
+ const CONSOLE_SEGMENT = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
22
+ /** Addresses the console had before it took "/", and the old page's setup and sign-in, which the printed setup link
23
+ * still names: each sends the browser to "/", which keeps the link's #code. */
24
+ const MOVED = new Set(["/console", "/console/", "/setup", "/sign-in"]);
25
+ const digest = (text) => createHash("sha256").update(text).digest();
26
+ const same = (given, expected) => timingSafeEqual(digest(given), digest(expected));
27
+ /** The cookie's value: a MAC of the token, so the cookie is never the API key itself. */
28
+ const sessionOf = (token) => createHmac("sha256", token).update("agentrun-serve page").digest("base64url");
29
+ /** One name per port: cookies are kept per host, not per port, and another server on this machine has another token. */
30
+ const cookieName = (req) => `agentrun-${req.socket.localPort}`;
31
+ const cookiesOf = (req, name) => String(req.headers.cookie ?? "").split(";").map((part) => part.trim()).filter((part) => part.startsWith(`${name}=`)).map((part) => part.slice(name.length + 1));
32
+ export const overHttps = (req) => String(req.headers["x-forwarded-proto"] ?? "").split(",")[0].trim().toLowerCase() === "https";
33
+ export const ownOrigin = (req) => `${overHttps(req) ? "https" : "http"}://${String(req.headers.host ?? "").toLowerCase()}`;
34
+ export const isJson = (req) => String(req.headers["content-type"] ?? "").split(";")[0].trim().toLowerCase() === "application/json";
35
+ /** The owner's session cookie: `__Host-` on https, so no other host or path can set it; else one per port. */
36
+ export const ownerCookieName = (req) => (overHttps(req) ? "__Host-agentrun-session" : `agentrun-${req.socket.localPort}-session`);
37
+ /** A Set-Cookie line for the owner's session: `value`, or an empty one that ends it (`maxAgeS` 0). */
38
+ export const ownerCookie = (req, value, maxAgeS) => `${ownerCookieName(req)}=${value}; HttpOnly; SameSite=Strict; Path=/; Max-Age=${maxAgeS}${overHttps(req) ? "; Secure" : ""}`;
39
+ /** Whether the request holds a session the owner signed in. */
40
+ export const signedIn = (req, owner) => cookiesOf(req, ownerCookieName(req)).some((value) => owner.valid(value));
41
+ function send(req, res, status, type, body, headers = {}) {
42
+ const bytes = typeof body === "string" ? Buffer.from(body) : body;
43
+ res.writeHead(status, { ...SECURITY, "content-type": type, "content-length": bytes.length, ...headers });
44
+ res.end(req.method === "HEAD" ? undefined : bytes);
45
+ }
46
+ const refuse = (req, res, error) => send(req, res, error.status, "application/json", JSON.stringify(error.body(String(res.getHeader("x-request-id") ?? ""))), error.headers);
47
+ const redirect = (res, location, headers = {}) => (res.writeHead(303, { ...SECURITY, location, "content-length": 0, ...headers }), void res.end());
48
+ /** A file of the console: a known type inside `dir`, read through no link that leaves it. Vite's hashed assets are cached
49
+ * for a year; index.html is no-store. */
50
+ async function file(req, res, raw, dir, rel, status = 200) {
51
+ const missing = () => refuse(req, res, new ApiError("not_found", `no file ${raw} in the console`));
52
+ const type = CONSOLE_TYPES[extname(rel).toLowerCase()];
53
+ if (!type || !rel.split("/").every((segment) => CONSOLE_SEGMENT.test(segment)))
54
+ return missing();
55
+ const [root, real] = await Promise.all([realpath(dir).catch(() => null), realpath(join(dir, rel)).catch(() => null)]);
56
+ if (!root || !real) {
57
+ // A refusal (a wrong link token) stays a refusal on a server without its console: only a plain miss is a 404.
58
+ return rel === "index.html" ? send(req, res, status === 200 ? 404 : status, "text/plain; charset=utf-8", "This server was built without its console: run npm ci && npm run build at the repository's root, which builds the console first, then start the server again.\n") : missing();
59
+ }
60
+ if (!real.startsWith(root + sep) || !(await stat(real)).isFile())
61
+ return missing();
62
+ send(req, res, status, type, await readFile(real), { "cache-control": rel.startsWith("assets/") ? "public, max-age=31536000, immutable" : "no-store" });
63
+ }
64
+ async function answer(req, res, raw, server, held) {
65
+ if (req.method !== "GET" && req.method !== "HEAD")
66
+ return refuse(req, res, new ApiError("method_not_allowed", `the console answers GET and HEAD; ${req.method} is not one`, {}, { allow: "GET, HEAD" }));
67
+ if (raw.startsWith("/api/")) {
68
+ if (!held && !same(String(req.headers.authorization ?? ""), `Bearer ${server.token}`)) {
69
+ server.authFailed?.(raw, req.headers.authorization === undefined ? "no_credential" : "wrong_token");
70
+ return refuse(req, res, new ApiError("unauthenticated", "the page's data needs the cookie the printed link sets, or Authorization: Bearer <the token>"));
71
+ }
72
+ const url = new URL(req.url ?? "/", "http://serve");
73
+ const { status, value } = await storeApi({ dir: server.dir })(url.pathname, url.searchParams);
74
+ return send(req, res, status, "application/json; charset=utf-8", JSON.stringify(value));
75
+ }
76
+ const dir = server.console ?? CONSOLE_DIR;
77
+ if (MOVED.has(raw))
78
+ return redirect(res, `/${(req.url ?? "").slice(raw.length)}`);
79
+ if (raw !== "/")
80
+ return file(req, res, raw, dir, raw.slice(1));
81
+ // Without accounts, the printed link's token becomes this browser's cookie once. With an owner the console is the
82
+ // owner's session alone: the token is for scripts and the CLI, and its link signs no browser in.
83
+ const url = new URL(req.url ?? "/", "http://serve");
84
+ const without = () => (url.searchParams.delete("token"), `/${url.searchParams.size ? `?${url.searchParams}` : ""}`);
85
+ // With an owner a token in the address signs nothing in, and leaves it: the same address without it, no cookie.
86
+ if (server.owner && url.searchParams.has("token"))
87
+ return redirect(res, without());
88
+ const given = server.owner ? null : url.searchParams.get("token");
89
+ // A token holds no whitespace, so a space in the link is a "+" that was not encoded.
90
+ if (given !== null && (same(given, server.token) || same(given.replaceAll(" ", "+"), server.token))) {
91
+ return redirect(res, without(), { "set-cookie": `${cookieName(req)}=${sessionOf(server.token)}; HttpOnly; SameSite=Strict; Path=/${overHttps(req) ? "; Secure" : ""}` });
92
+ }
93
+ if (given !== null)
94
+ server.authFailed?.(raw, "wrong_link_token");
95
+ return file(req, res, raw, dir, "index.html", given === null ? 200 : 401);
96
+ }
97
+ /** The requests the owner's password session sends from the page (a write only from this server's own origin, with a
98
+ * JSON body), never under the cookie accounts-off mints from the token. */
99
+ const ownerSessions = new WeakSet();
100
+ /** Whether `req` came from the owner's page under their password session (answerPage). A token, whoever holds it, never
101
+ * did. */
102
+ export const byOwnerSession = (req) => ownerSessions.has(req);
103
+ /**
104
+ * Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/") and the store's /api/*, and
105
+ * returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
106
+ * becomes the Bearer header for a GET or HEAD, and for any other method only when the request's Origin is this server's
107
+ * own origin and its body is application/json, or the request is a PUT or POST to a route that takes bytes, with any
108
+ * content type.
109
+ */
110
+ export function answerPage(req, res, raw, server) {
111
+ const held = server.owner ? signedIn(req, server.owner) : cookiesOf(req, cookieName(req)).some((value) => same(value, sessionOf(server.token)));
112
+ if (raw.startsWith("/v2/")) {
113
+ const safe = req.method === "GET" || req.method === "HEAD";
114
+ const bytes = (req.method === "PUT" || req.method === "POST") && server.takesBytes?.(req.method, raw.slice(3)) === true;
115
+ if (held && req.headers.authorization === undefined && (safe || (req.headers.origin?.toLowerCase() === ownOrigin(req) && (isJson(req) || bytes)))) {
116
+ req.headers.authorization = `Bearer ${server.token}`;
117
+ // The owner's password session (accounts on), never a cookie a token mints: what approving a note asks for, and
118
+ // what capabilities read to say whether this caller may (byOwnerSession).
119
+ if (server.owner)
120
+ ownerSessions.add(req);
121
+ }
122
+ return false;
123
+ }
124
+ if (raw !== "/" && !raw.startsWith("/assets/") && !raw.startsWith("/api/") && !MOVED.has(raw))
125
+ return false;
126
+ answer(req, res, raw, server, held).catch(() => {
127
+ if (!res.headersSent)
128
+ refuse(req, res, new ApiError("internal", "the console could not be read"));
129
+ else
130
+ res.destroy();
131
+ });
132
+ return true;
133
+ }
@@ -0,0 +1,50 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
3
+ /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
4
+ * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
5
+ export declare const PARALLEL_SEARCH_USD = 0.001;
6
+ export declare const PARALLEL_SEARCH_RESULT_USD = 0.001;
7
+ export declare const PARALLEL_SEARCH_INCLUDED = 10;
8
+ export declare const PARALLEL_EXTRACT_USD = 0.001;
9
+ /** One paid request: `name` in the cap's refusal, `tool` and `by` on its records, `usd` its price, `basis` why. */
10
+ export type Fee = {
11
+ name: string;
12
+ tool: string;
13
+ by: string;
14
+ usd: number;
15
+ basis: string;
16
+ };
17
+ /** A fast search for `n` results: $0.001, and $0.001 for each past the 10 it includes. */
18
+ export declare const parallelSearchFee: (n: number) => Fee;
19
+ /** An extract of `urls` URLs (the web tools ask one at a time). */
20
+ export declare const parallelExtractFee: (urls?: number) => Fee;
21
+ /** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by default), or its
22
+ * extract's, by the URLs; undefined for an endpoint the web tools do not ask. */
23
+ export declare function parallelFeeOf(url: string, body: unknown): Fee | undefined;
24
+ /** A paid request the run's cap refused, or whose mark could not be written: nothing was sent. Its message is the
25
+ * refusal, in the cap's words. */
26
+ export declare class PaidRefused extends Error {
27
+ readonly name = "PaidRefused";
28
+ }
29
+ /** Where a paid request is booked: the call it is booked under, and one record written to the run's root, where its
30
+ * spend is read on every harness (cap.ts, harness-app.ts). */
31
+ export type Ledger = {
32
+ call: string;
33
+ record(kind: string, data: Record<string, string | number | null>): Promise<void>;
34
+ };
35
+ export declare const settleIn: (record: Ledger["record"] | undefined) => void;
36
+ /** A settle of `kind` written to the run's root (settleIn), when that is set; else undefined, for the caller's own commit.
37
+ * monid.run's settle goes here too. */
38
+ export declare const settleOnRoot: (kind: string, data: Record<string, string | number | null>) => Promise<void> | undefined;
39
+ /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) is the call's own
40
+ * commit, so a stopped turn sends nothing new; its settle goes to the run's root when that is set (settleIn). */
41
+ export declare const ledgerOf: (api: ToolExecutionApi, context: Context) => Ledger;
42
+ /** `tool` with each call's paid requests booked under it: its execute runs with the call's ledger set. */
43
+ export declare function booking<T extends ToolRegistration>(tool: T): T;
44
+ /** `work` with its paid requests booked in `ledger` (a workflow call node's); with none, booked nowhere. */
45
+ export declare const bookedIn: <T>(ledger: Ledger | undefined, work: () => Promise<T>) => Promise<T>;
46
+ /** `send`, one request to a paid provider at `fee`, under the run's cap and booked under the call it runs in: its
47
+ * response; it throws PaidRefused, in the cap's words, when the cap does not hold its price (or the run's spend is
48
+ * unknown), when no call is set to book it under, or when its mark could not be written, and then nothing is sent. A request that throws throws, settled at its
49
+ * price. */
50
+ export declare function paidRequest(fee: Fee, send: () => Promise<Response>): Promise<Response>;
@@ -0,0 +1,110 @@
1
+ // A web tool's request to Parallel (its search, web-search.ts; its extract, web-fetch.ts), booked as monid.run's call
2
+ // is (monid.ts): under the run's cap by cap.ts' rule for a paid call (what the run has spent and holds, plus the
3
+ // request's price, within the cap; never on an unknown spend), else refused unsent in the cap's words; marked in the
4
+ // run's store before it is sent (TOOL_STARTED, held at its price) and settled after (TOOL_COST, what it charged). A
5
+ // charge is the run's cost, a line of its own on its timeline and /usage's `tools` meter. Every request goes through
6
+ // the run's one Parallel client's `post` (web-fetch.ts), which books it here by the endpoint it asks.
7
+ // Parallel's answers report what they used as SKU counts, never an amount, so each request is booked at Parallel's
8
+ // published price, an estimate: its price on a 2xx; nothing on a 4xx other than a 408 (Parallel refused it before any
9
+ // work); and its price on a 408, a 5xx or a request that failed or was stopped after it was sent, which Parallel may
10
+ // have billed, as the decision provider books Parallel's (@parcha/agentrun-decisions).
11
+ // A request with no call to book it under, or to an endpoint with no price here, is never sent: it fails closed.
12
+ // The call a request is booked under (its id, and how a record is written to the run's store) is set around the call:
13
+ // around a tool's execute by `booking`, where the web tools are bound (tools.ts, host-tools.ts), and around a workflow
14
+ // call node's effect by `bookedIn`, with the ledger the workflow's runner gives it (app.ts). The client deep inside a
15
+ // tool books without the call passed down to it.
16
+ import { AsyncLocalStorage } from "node:async_hooks";
17
+ import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
18
+ import { TOOL_COST, TOOL_STARTED } from "@parcha/pi-durable-agent/timeline";
19
+ import { paidCall } from "./cap.js";
20
+ /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
21
+ * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
22
+ export const PARALLEL_SEARCH_USD = 0.001;
23
+ export const PARALLEL_SEARCH_RESULT_USD = 0.001;
24
+ export const PARALLEL_SEARCH_INCLUDED = 10;
25
+ export const PARALLEL_EXTRACT_USD = 0.001;
26
+ /** In whole millionths of a dollar, so a sum of prices is the price. */
27
+ const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
28
+ /** A fast search for `n` results: $0.001, and $0.001 for each past the 10 it includes. */
29
+ export const parallelSearchFee = (n) => {
30
+ const more = Math.max(0, n - PARALLEL_SEARCH_INCLUDED);
31
+ return { name: "Parallel's search", tool: "web_search", by: "parallel", usd: usd(PARALLEL_SEARCH_USD + PARALLEL_SEARCH_RESULT_USD * more), basis: more ? `Parallel's list price for a fast search of ${n} results` : "Parallel's list price for a fast search" };
32
+ };
33
+ /** An extract of `urls` URLs (the web tools ask one at a time). */
34
+ export const parallelExtractFee = (urls = 1) => ({ name: "Parallel's extract", tool: "web_fetch", by: "parallel", usd: usd(PARALLEL_EXTRACT_USD * urls), basis: urls === 1 ? "Parallel's list price for one URL" : `Parallel's list price for ${urls} URLs` });
35
+ /** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by default), or its
36
+ * extract's, by the URLs; undefined for an endpoint the web tools do not ask. */
37
+ export function parallelFeeOf(url, body) {
38
+ const path = URL.parse(url)?.pathname;
39
+ const asked = (body ?? {});
40
+ if (path === "/v1/search")
41
+ return parallelSearchFee(typeof asked.advanced_settings?.max_results === "number" ? asked.advanced_settings.max_results : PARALLEL_SEARCH_INCLUDED);
42
+ if (path === "/v1/extract")
43
+ return parallelExtractFee(Array.isArray(asked.urls) ? Math.max(1, asked.urls.length) : 1);
44
+ return undefined;
45
+ }
46
+ /** A paid request the run's cap refused, or whose mark could not be written: nothing was sent. Its message is the
47
+ * refusal, in the cap's words. */
48
+ export class PaidRefused extends Error {
49
+ name = "PaidRefused";
50
+ }
51
+ const ledgers = new AsyncLocalStorage();
52
+ /** The run process's own commit to its run's root, outside any one call's turn (app.ts sets it once the run's harness is
53
+ * open). A request's settle (TOOL_COST) is written there: once a turn is stopped, its tool call can no longer commit
54
+ * (pi-durable refuses a task with a durable abort mark), though the request was sent and its charge stands. */
55
+ let rootRecord;
56
+ export const settleIn = (record) => {
57
+ rootRecord = record;
58
+ };
59
+ /** A settle of `kind` written to the run's root (settleIn), when that is set; else undefined, for the caller's own commit.
60
+ * monid.run's settle goes here too. */
61
+ export const settleOnRoot = (kind, data) => rootRecord?.(kind, data);
62
+ /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) is the call's own
63
+ * commit, so a stopped turn sends nothing new; its settle goes to the run's root when that is set (settleIn). */
64
+ export const ledgerOf = (api, context) => ({ call: api.callId, record: (kind, data) => ((kind === TOOL_COST ? settleOnRoot(kind, data) : undefined) ?? api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data })), context)) });
65
+ /** `tool` with each call's paid requests booked under it: its execute runs with the call's ledger set. */
66
+ export function booking(tool) {
67
+ return { ...tool, execute: (args, api, context) => ledgers.run(ledgerOf(api, context), () => tool.execute(args, api, context)) };
68
+ }
69
+ /** `work` with its paid requests booked in `ledger` (a workflow call node's); with none, booked nowhere. */
70
+ export const bookedIn = (ledger, work) => (ledger ? ledgers.run(ledger, work) : work());
71
+ /** Whether Parallel may have billed a request it answered `status`: a 2xx, a 408 or a 5xx; never another 4xx. */
72
+ const billed = (status) => (status >= 200 && status < 300) || status === 408 || status >= 500;
73
+ /** `send`, one request to a paid provider at `fee`, under the run's cap and booked under the call it runs in: its
74
+ * response; it throws PaidRefused, in the cap's words, when the cap does not hold its price (or the run's spend is
75
+ * unknown), when no call is set to book it under, or when its mark could not be written, and then nothing is sent. A request that throws throws, settled at its
76
+ * price. */
77
+ export async function paidRequest(fee, send) {
78
+ const ledger = ledgers.getStore();
79
+ if (!ledger)
80
+ throw new PaidRefused(`${fee.name} was not sent: this request has no call to book it under`);
81
+ const label = { tool: fee.tool, charged_by: fee.by, call: ledger.call };
82
+ const chargeOf = (sent) => ("unmarked" in sent ? undefined : "thrown" in sent || billed(sent.response.status) ? fee.usd : 0);
83
+ const sent = async () => {
84
+ try {
85
+ await ledger.record(TOOL_STARTED, { ...label, heldUsd: fee.usd });
86
+ }
87
+ catch (error) {
88
+ return { unmarked: `${fee.name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})` };
89
+ }
90
+ let outcome;
91
+ try {
92
+ outcome = { response: await send() };
93
+ }
94
+ catch (thrown) {
95
+ outcome = { thrown };
96
+ }
97
+ // Settled at what it may have charged, even when this cannot be written: the request was sent.
98
+ await ledger.record(TOOL_COST, { ...label, usd: chargeOf(outcome) ?? null }).catch(() => undefined);
99
+ return outcome;
100
+ };
101
+ const paid = await paidCall(fee.name, sent, chargeOf, { usd: fee.usd, basis: fee.basis });
102
+ if ("refused" in paid)
103
+ throw new PaidRefused(paid.refused);
104
+ const outcome = paid.result;
105
+ if ("unmarked" in outcome)
106
+ throw new PaidRefused(outcome.unmarked);
107
+ if ("thrown" in outcome)
108
+ throw outcome.thrown;
109
+ return outcome.response;
110
+ }
@@ -0,0 +1,70 @@
1
+ export declare const RUN_PAUSED = "paused";
2
+ export declare const NODE_LOG = "nodes.jsonl";
3
+ export declare const LIVE_VIEW = "live.json";
4
+ export declare const pausedIn: (root: string) => boolean;
5
+ /** `fn`, waiting before each call while the run at `root` is paused. A cancel, or the call's own signal aborting, lets
6
+ * the call go to meet its abort. */
7
+ export declare function gated<P, R>(root: string, fn: (params: P) => Promise<R>): (params: P) => Promise<R>;
8
+ /** One line of the node log. `path` is the execution path; `item` the map item's index, null outside a map. */
9
+ export type NodeLine = {
10
+ t: "node.start" | "node.end";
11
+ path: string;
12
+ kind: string;
13
+ at: string;
14
+ status?: string;
15
+ duration_ms?: number;
16
+ error?: string;
17
+ } | {
18
+ t: "effect.start";
19
+ path: string | null;
20
+ item: number | null;
21
+ tool: string;
22
+ label: string;
23
+ input: unknown;
24
+ at: string;
25
+ } | {
26
+ t: "effect.end";
27
+ path: string | null;
28
+ item: number | null;
29
+ tool: string;
30
+ label: string;
31
+ status: "done" | "failed";
32
+ output?: unknown;
33
+ error?: string;
34
+ error_truncated?: boolean;
35
+ at: string;
36
+ };
37
+ /** Appends to the run's node log; a write that fails is lost, never the run's. */
38
+ export declare const nodeLog: (root: string) => (line: NodeLine) => void;
39
+ /** The node log of the run at `root`, in order; a torn last line is left out. */
40
+ export declare function readNodeLog(root: string): Promise<NodeLine[]>;
41
+ /** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
42
+ export declare const llmAnswers: (lines: readonly NodeLine[]) => {
43
+ t: "effect.end";
44
+ path: string | null;
45
+ item: number | null;
46
+ tool: string;
47
+ label: string;
48
+ status: "done" | "failed";
49
+ output?: unknown;
50
+ error?: string;
51
+ error_truncated?: boolean;
52
+ at: string;
53
+ }[];
54
+ /** What the run's process last wrote of its driver's frame and its receipts. */
55
+ export type LiveView = {
56
+ at: string;
57
+ pin: Record<string, unknown>;
58
+ receipts: Array<Record<string, unknown>>;
59
+ };
60
+ /** The run's live view writer: `receipts` are the ones earlier processes recorded; `driver` is handed over once the
61
+ * workflow's driver is open. It rewrites `live.json` every 300 ms while something changed, and once more at `stop`. */
62
+ export declare function liveView(root: string, receipts: Array<Record<string, unknown>>): {
63
+ driver(next: {
64
+ pinJson(): string;
65
+ }): void;
66
+ receipt(receipt: Record<string, unknown>): void;
67
+ stop(): void;
68
+ };
69
+ /** The live view of the run at `root`; undefined when its process wrote none, or it does not parse. */
70
+ export declare function readLiveView(root: string): Promise<LiveView | undefined>;
package/dist/pause.js ADDED
@@ -0,0 +1,97 @@
1
+ // A workflow run's pause and its node log, both files in the run's directory beside serve.json.
2
+ //
3
+ // Pause: POST /v2/runs/{id}/pause writes the mark `paused`; resume removes it. The run's process gates each node's start,
4
+ // each model call and each decision on it: what is in flight finishes, and nothing new starts while the mark is there.
5
+ // The gate sits before the durable admission of a call and before a call node's deadline is armed, so a node waiting at
6
+ // it was never booked and a kill while paused interrupts nothing. Being a file, a pause outlives the server and the run's
7
+ // process.
8
+ //
9
+ // Node log: `nodes.jsonl`, one JSON line per node start and end and per call's start and end with its input and output,
10
+ // appended by the run's process as they happen, so GET /v2/runs/{id}/graph shows timings and call I/O while the run goes.
11
+ //
12
+ // Live view: `live.json`, the driver's frame and the run's decision receipts, rewritten whole by the run's process when
13
+ // they change. The run's process holds its store exclusively (pi-durable-disk's exclusive profile: no other connection
14
+ // reads it until the process exits), so this file is what GET /v2/runs/{id}/graph reads while the run goes.
15
+ import { appendFileSync, existsSync, renameSync, writeFileSync } from "node:fs";
16
+ import { join } from "node:path";
17
+ import { RUN_CANCELLED } from "./files.js";
18
+ export const RUN_PAUSED = "paused";
19
+ export const NODE_LOG = "nodes.jsonl";
20
+ export const LIVE_VIEW = "live.json";
21
+ const LIVE_MS = 300;
22
+ const POLL_MS = 250;
23
+ export const pausedIn = (root) => existsSync(join(root, RUN_PAUSED));
24
+ /** `fn`, waiting before each call while the run at `root` is paused. A cancel, or the call's own signal aborting, lets
25
+ * the call go to meet its abort. */
26
+ export function gated(root, fn) {
27
+ return async (params) => {
28
+ const signal = params?.signal instanceof AbortSignal ? params.signal : undefined;
29
+ while (pausedIn(root) && !existsSync(join(root, RUN_CANCELLED)) && !signal?.aborted)
30
+ await new Promise((resolve) => setTimeout(resolve, POLL_MS));
31
+ return fn(params);
32
+ };
33
+ }
34
+ /** Appends to the run's node log; a write that fails is lost, never the run's. */
35
+ export const nodeLog = (root) => (line) => {
36
+ try {
37
+ appendFileSync(join(root, NODE_LOG), `${JSON.stringify(line)}\n`, { mode: 0o600 });
38
+ }
39
+ catch { }
40
+ };
41
+ /** The node log of the run at `root`, in order; a torn last line is left out. */
42
+ export async function readNodeLog(root) {
43
+ const { readFile } = await import("node:fs/promises");
44
+ const text = await readFile(join(root, NODE_LOG), "utf8").catch(() => "");
45
+ const out = [];
46
+ for (const line of text.split("\n")) {
47
+ if (!line)
48
+ continue;
49
+ try {
50
+ out.push(JSON.parse(line));
51
+ }
52
+ catch { }
53
+ }
54
+ return out;
55
+ }
56
+ /** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
57
+ export const llmAnswers = (lines) => lines.filter((line) => line.t === "effect.end" && line.tool === "llm" && line.status === "done");
58
+ /** The run's live view writer: `receipts` are the ones earlier processes recorded; `driver` is handed over once the
59
+ * workflow's driver is open. It rewrites `live.json` every 300 ms while something changed, and once more at `stop`. */
60
+ export function liveView(root, receipts) {
61
+ let driver;
62
+ let last = "";
63
+ const file = join(root, LIVE_VIEW);
64
+ const write = () => {
65
+ if (!driver)
66
+ return;
67
+ try {
68
+ const text = `{"at":${JSON.stringify(new Date().toISOString())},"receipts":${JSON.stringify(receipts)},"pin":${driver.pinJson()}}`;
69
+ // The time is left out of the comparison: an unchanged view is not written again.
70
+ const same = text.slice(text.indexOf(',"receipts":'));
71
+ if (same === last)
72
+ return;
73
+ writeFileSync(`${file}.tmp`, text, { mode: 0o600 });
74
+ renameSync(`${file}.tmp`, file);
75
+ last = same;
76
+ }
77
+ catch { }
78
+ };
79
+ const timer = setInterval(write, LIVE_MS);
80
+ timer.unref();
81
+ return {
82
+ driver(next) { driver = next; write(); },
83
+ receipt(receipt) { receipts.push(receipt); },
84
+ stop() { clearInterval(timer); write(); },
85
+ };
86
+ }
87
+ /** The live view of the run at `root`; undefined when its process wrote none, or it does not parse. */
88
+ export async function readLiveView(root) {
89
+ const { readFile } = await import("node:fs/promises");
90
+ try {
91
+ const view = JSON.parse(await readFile(join(root, LIVE_VIEW), "utf8"));
92
+ return view && typeof view === "object" && view.pin && Array.isArray(view.receipts) ? view : undefined;
93
+ }
94
+ catch {
95
+ return undefined;
96
+ }
97
+ }
@@ -0,0 +1,44 @@
1
+ export declare const PDF_PAGES_TOOL = "pdf_pages";
2
+ /** The read-only directory a run's documents are read from: the server's `--documents`. */
3
+ export declare const DOCUMENTS_ENV = "AGENTRUN_SERVE_DOCUMENTS";
4
+ /** The longest side a drawn page may have, in pixels: Jev's image limit (1568 per side; 1569 is refused). */
5
+ export declare const MAX_PAGE_PX = 1568;
6
+ /** `dpi`: the dpi the pages were drawn at (at most the asked one); null for an image that passed through. */
7
+ export type PdfPages = {
8
+ name: string;
9
+ pageCount: number;
10
+ dpi: number | null;
11
+ pages: {
12
+ page: number;
13
+ image: string;
14
+ }[];
15
+ text: string;
16
+ };
17
+ type Located = {
18
+ file: string;
19
+ base: "documents" | "work";
20
+ rel: string;
21
+ };
22
+ /** Where a document named `path` is: the documents directory first, then the run's work directory. */
23
+ export declare function documentPath(path: unknown, where: {
24
+ work: string;
25
+ documents?: string | undefined;
26
+ }): Promise<string>;
27
+ /** The one directory name a document's pages are drawn under, in `work/pages/`: its path below the documents (or work)
28
+ * directory without the extension, each run of other characters than letters, digits, `.`, `_` and `-` (a `/` too)
29
+ * made `_`, cut to its last 48 characters with no leading dot, then `-` and 12 hex characters of the sha256 of which
30
+ * directory and that path. So two documents of one file name in different folders never share a page, the same file
31
+ * always draws under the same name (through a link too), and the name is never a separator, `.` or `..`. */
32
+ export declare function pagesStem({ base, rel }: Pick<Located, "base" | "rel">): string;
33
+ /** The pages and text of the document `args.path`, drawn into `where.work`. */
34
+ export declare function pdfPages(args: Record<string, unknown>, where: {
35
+ work: string;
36
+ documents?: string | undefined;
37
+ signal?: AbortSignal;
38
+ }): Promise<PdfPages>;
39
+ /** A decision node's image by its ref, a path under the run's work directory (a page pdf_pages drew), confined to it. */
40
+ export declare const imageLoader: (work: string) => (ref: string) => Promise<{
41
+ bytes: Uint8Array;
42
+ mime: string;
43
+ }>;
44
+ export {};