@parcha/agentrun-serve 0.1.0-beta.60 → 0.1.0-beta.62

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 (179) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +139 -22
  3. package/dist/acp-package.d.ts +4 -0
  4. package/dist/api-only.d.ts +23 -1
  5. package/dist/api-only.js +43 -4
  6. package/dist/archil-settings.d.ts +9 -0
  7. package/dist/archil-settings.js +8 -1
  8. package/dist/bash-read-only.d.ts +3 -0
  9. package/dist/bash-read-only.js +6 -3
  10. package/dist/browser-person.d.ts +1 -1
  11. package/dist/browser-person.js +1 -1
  12. package/dist/calendar/tools.js +1 -1
  13. package/dist/chatgpt-plan.d.ts +26 -8
  14. package/dist/chatgpt-plan.js +89 -21
  15. package/dist/claude-login.d.ts +12 -5
  16. package/dist/claude-login.js +28 -3
  17. package/dist/cli.js +61 -18
  18. package/dist/composio-triggers.d.ts +9 -3
  19. package/dist/computers.d.ts +3 -0
  20. package/dist/computers.js +2 -1
  21. package/dist/console/assets/{backend-QnwGVBeU.js → backend-DEgVn5lC.js} +1 -1
  22. package/dist/console/assets/index-CG5tELph.js +639 -0
  23. package/dist/console/assets/share-CIeFK2Oe.js +6 -0
  24. package/dist/console/assets/{styles-CcceGcu2.js → styles-BGZxYkky.js} +2 -2
  25. package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
  26. package/dist/console/index.html +3 -3
  27. package/dist/console/share.html +3 -3
  28. package/dist/cut-pool.d.ts +14 -0
  29. package/dist/cut-pool.js +98 -0
  30. package/dist/cut-worker.d.ts +14 -0
  31. package/dist/cut-worker.js +16 -0
  32. package/dist/decisions.d.ts +4 -0
  33. package/dist/decisions.js +9 -1
  34. package/dist/env-switch.d.ts +3 -0
  35. package/dist/env-switch.js +3 -0
  36. package/dist/errors.d.ts +1 -0
  37. package/dist/errors.js +2 -0
  38. package/dist/harness-check.js +2 -1
  39. package/dist/harness-recipe.d.ts +13 -2
  40. package/dist/harness-recipe.js +30 -7
  41. package/dist/harness-sign-in.js +2 -1
  42. package/dist/harness-table.d.ts +12 -3
  43. package/dist/harness-table.js +13 -8
  44. package/dist/import.d.ts +8 -1
  45. package/dist/import.js +36 -5
  46. package/dist/key-check.js +22 -8
  47. package/dist/key-refusal.js +6 -4
  48. package/dist/learn/secrets.d.ts +2 -1
  49. package/dist/learn/secrets.js +2 -2
  50. package/dist/learned-nodes.d.ts +37 -0
  51. package/dist/learned-nodes.js +24 -0
  52. package/dist/local-model.d.ts +144 -0
  53. package/dist/local-model.js +214 -0
  54. package/dist/mcp-gateway.d.ts +24 -0
  55. package/dist/mcp-gateway.js +97 -8
  56. package/dist/mcp-probe.d.ts +7 -0
  57. package/dist/mcp-probe.js +7 -0
  58. package/dist/mcp-servers-store.d.ts +7 -10
  59. package/dist/mcp-servers-store.js +15 -9
  60. package/dist/native/cli.js +5 -1
  61. package/dist/ollama-provider.d.ts +42 -0
  62. package/dist/ollama-provider.js +118 -2
  63. package/dist/openapi.js +85 -16
  64. package/dist/otel/tracer.d.ts +6 -3
  65. package/dist/otel/tracer.js +24 -6
  66. package/dist/page.d.ts +7 -0
  67. package/dist/page.js +17 -4
  68. package/dist/place.d.ts +28 -11
  69. package/dist/place.js +43 -14
  70. package/dist/print.d.ts +3 -2
  71. package/dist/print.js +8 -6
  72. package/dist/redact/match.d.ts +17 -4
  73. package/dist/redact/match.js +57 -15
  74. package/dist/run-export.js +4 -2
  75. package/dist/run-launch.js +16 -3
  76. package/dist/run-model-key.d.ts +2 -1
  77. package/dist/run-model-key.js +2 -1
  78. package/dist/run-reads-over-store.d.ts +7 -0
  79. package/dist/run-reads-over-store.js +32 -4
  80. package/dist/run-usage.js +3 -2
  81. package/dist/runnable.d.ts +6 -3
  82. package/dist/runnable.js +16 -6
  83. package/dist/runner/adapter-loop.d.ts +8 -1
  84. package/dist/runner/adapter-loop.js +148 -29
  85. package/dist/runner/adapter-run-spec.d.ts +9 -6
  86. package/dist/runner/adapter-run-spec.js +38 -52
  87. package/dist/runner/adapters/index.d.ts +4 -0
  88. package/dist/runner/adapters/index.js +2 -1
  89. package/dist/runner/adapters/pi.d.ts +3 -2
  90. package/dist/runner/adapters/pi.js +3 -1
  91. package/dist/runner/audit.d.ts +1 -1
  92. package/dist/runner/claim-secrets.d.ts +3 -1
  93. package/dist/runner/claim-secrets.js +18 -7
  94. package/dist/runner/cli-run-spec.js +24 -17
  95. package/dist/runner/compare-end.d.ts +1 -1
  96. package/dist/runner/dispatch.js +4 -2
  97. package/dist/runner/harness-loops.d.ts +14 -0
  98. package/dist/runner/harness-loops.js +51 -5
  99. package/dist/runner/held.d.ts +4 -1
  100. package/dist/runner/live-ticker.js +5 -4
  101. package/dist/runner/loop-contract.d.ts +4 -1
  102. package/dist/runner/mcp-claim.js +3 -2
  103. package/dist/runner/mcp-run.d.ts +24 -4
  104. package/dist/runner/mcp-run.js +47 -2
  105. package/dist/runner/meta-tools.js +4 -4
  106. package/dist/runner/metrics.d.ts +6 -0
  107. package/dist/runner/metrics.js +12 -4
  108. package/dist/runner/monid-run.js +3 -1
  109. package/dist/runner/native-loop.js +3 -3
  110. package/dist/runner/redact.d.ts +3 -0
  111. package/dist/runner/redact.js +7 -0
  112. package/dist/runner/run-child-host.d.ts +10 -6
  113. package/dist/runner/run-child-host.js +44 -29
  114. package/dist/runner/run-child.js +1 -0
  115. package/dist/runner/runner.js +2 -0
  116. package/dist/runner/sdk-loop.js +5 -3
  117. package/dist/runner/workflow-calls.d.ts +5 -1
  118. package/dist/runner/workflow-calls.js +65 -19
  119. package/dist/runner/workflow-loop.d.ts +1 -1
  120. package/dist/runner/workflow-loop.js +3 -1
  121. package/dist/runner/workflow-spec.d.ts +4 -0
  122. package/dist/runner/workflow-spec.js +18 -13
  123. package/dist/runs-over-store.d.ts +2 -2
  124. package/dist/runs-over-store.js +1 -1
  125. package/dist/secret-cut.js +7 -4
  126. package/dist/secret-rules.d.ts +0 -1
  127. package/dist/secret-rules.js +122 -88
  128. package/dist/server.d.ts +17 -1
  129. package/dist/server.js +208 -69
  130. package/dist/share-host.d.ts +111 -0
  131. package/dist/share-host.js +666 -0
  132. package/dist/slack.js +2 -1
  133. package/dist/store/postgres/migrate.js +3 -1
  134. package/dist/store-reads/analytics.d.ts +15 -0
  135. package/dist/store-reads/analytics.js +17 -0
  136. package/dist/store-reads/learning.d.ts +5 -4
  137. package/dist/store-reads/learning.js +7 -4
  138. package/dist/suggestions.js +32 -3
  139. package/dist/templates.d.ts +3 -1
  140. package/dist/templates.js +7 -3
  141. package/dist/tool-gate.d.ts +25 -9
  142. package/dist/tool-gate.js +58 -19
  143. package/dist/tool-plane.d.ts +24 -1
  144. package/dist/tool-plane.js +75 -3
  145. package/dist/tools.d.ts +12 -2
  146. package/dist/tools.js +42 -7
  147. package/dist/trigger-composio.js +1 -1
  148. package/dist/trigger-launch-hook.d.ts +2 -2
  149. package/dist/trigger-launch-hook.js +1 -1
  150. package/dist/triggers.d.ts +7 -4
  151. package/dist/triggers.js +4 -4
  152. package/dist/webhooks.d.ts +3 -0
  153. package/dist/webhooks.js +5 -0
  154. package/dist/workspace/archil-claim.d.ts +7 -3
  155. package/dist/workspace/archil-claim.js +13 -5
  156. package/dist/workspace/archil-mount-credential.d.ts +6 -0
  157. package/dist/workspace/archil-mount-credential.js +11 -0
  158. package/dist/workspace/computer-deps.d.ts +5 -3
  159. package/dist/workspace/computer-deps.js +11 -9
  160. package/dist/workspace/computer-for-claim.d.ts +6 -2
  161. package/dist/workspace/computer-for-claim.js +43 -12
  162. package/dist/workspace/computer-janitor.d.ts +7 -4
  163. package/dist/workspace/computer-janitor.js +7 -4
  164. package/dist/workspace/computer-kept.d.ts +7 -1
  165. package/dist/workspace/computer-kept.js +7 -1
  166. package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
  167. package/dist/workspace/mount-revoke-left.d.ts +16 -4
  168. package/dist/workspace/mount-revoke-left.js +42 -22
  169. package/dist/workspace/resolve-computer.d.ts +11 -5
  170. package/dist/workspace/resolve-computer.js +22 -13
  171. package/dist/workspace/run-end-computers.js +1 -1
  172. package/dist/workspace/run-tools.d.ts +10 -3
  173. package/dist/workspace/run-tools.js +5 -4
  174. package/dist/wrapped.d.ts +29 -2
  175. package/dist/wrapped.js +20 -3
  176. package/launcher/agentrun-serve +1 -1
  177. package/package.json +12 -12
  178. package/dist/console/assets/index-DZi-muIj.js +0 -629
  179. package/dist/console/assets/share-pz61zIn9.js +0 -6
@@ -143,7 +143,6 @@ export declare const envFilePath: (path: string) => boolean;
143
143
  /** A path under a .ssh folder. */
144
144
  export declare const sshFilePath: (path: string) => boolean;
145
145
  export declare const credentialFilePath: (path: string) => boolean;
146
- export declare const commandPaths: (command: string | undefined) => string[];
147
146
  export declare const SCRUB_RULES: readonly ScrubRule[];
148
147
  /** Every module-level pattern the rules read, by name: secret-scrub.test.mjs walks each (redact/match.ts SECRET_SHAPES are scanners, linear by construction)
149
148
  * and fails on an unbounded quantifier outside its allowlist, and fails on a module-level pattern missing here. */
@@ -2313,7 +2313,7 @@ const DOCKER_AUTHS_BEFORE = 65_536;
2313
2313
  /** Each `"auths"` in the text and whether the call read a config.json are found once a text (ruling LXXIII), never
2314
2314
  * once a match: a text of many `"auth"` keys is read in linear time. */
2315
2315
  const dockerAuth = (text, ctx) => {
2316
- const read = [ctx.path, ...commandPaths(ctx.command)].some((path) => path !== undefined && DOCKER_CONFIG.test(path));
2316
+ const read = (ctx.path !== undefined && dockerConfigPath(ctx.path)) || commandNames(ctx.command, dockerConfigPath);
2317
2317
  const auths = [];
2318
2318
  if (!read)
2319
2319
  for (let at = text.indexOf(DOCKER_AUTHS); at >= 0; at = text.indexOf(DOCKER_AUTHS, at + 1))
@@ -2517,6 +2517,10 @@ function after(lines, at, fits) {
2517
2517
  /** A shell's prompt opening a line: the next command, where a file's printed contents end. */
2518
2518
  const PROMPT_LINE = /^\s{0,8}(?:[$#%❯]|>>?)\s{1,3}\S/;
2519
2519
  const notPrompt = (body) => !PROMPT_LINE.test(body);
2520
+ /** A user's prompt opening a line, `$`, `%` or `❯`, and the command after it. `#` and `>` are left out: they open a
2521
+ * markdown heading or quote far more often than a root prompt (`# Export`), and their env commands are read by
2522
+ * ENV_COMMAND as before. */
2523
+ const PROMPT_HEAD = /^\s{0,8}[$%❯]\s{1,3}(?=\S)/;
2520
2524
  /** A line that is a dump's cut already made: no file's content (ruling VIII: a cut text read again is cut no more). */
2521
2525
  const DUMP_MARKER_LINE = /^\s{0,8}\[redacted:[a-z0-9-]{1,64}(?: \d{1,9} lines)?\]\s{0,8}$/;
2522
2526
  const notMarker = (body) => !DUMP_MARKER_LINE.test(body);
@@ -2534,12 +2538,28 @@ const ENV_NAMES = new Set(["PATH", "HOME", "SHELL", "USER", "PWD", "LANG"]);
2534
2538
  const ENV_UNCOMMANDED_LINES = 8;
2535
2539
  /** NAME=value lines in a row printed by an env command on the line before (a blank between allowed), any number of
2536
2540
  * them; eight or more holding two login names; or all `declare -x` lines (export -p's own output, its command's mark).
2537
- * And the values printenv NAME... or echo $KEY prints, one line a name. */
2541
+ * And the values printenv NAME... or echo $KEY prints, one line a name; and all of a prompted command's output when
2542
+ * the command prints the environment. */
2538
2543
  function envDumps(text) {
2539
2544
  const lines = linesOf(text);
2540
2545
  const out = [];
2541
2546
  for (let at = 0; at < lines.length;) {
2542
2547
  const body = lines[at].body;
2548
+ // A prompt line whose command prints the environment (11-25 r2): its output runs to the next `$`, `%` or `❯`
2549
+ // prompt or a dump's marker, whatever its lines look like: a multi-line value no longer ends it.
2550
+ const prompt = PROMPT_HEAD.exec(body);
2551
+ if (prompt && printsEnvironment(body.slice(prompt[0].length))) {
2552
+ let to = at;
2553
+ // Only a `$`, `%` or `❯` prompt ends it: a `#` or `>` line is a value's comment or quote, or a continued command.
2554
+ while (to + 1 < lines.length && !PROMPT_HEAD.test(lines[to + 1].body) && notMarker(lines[to + 1].body))
2555
+ to++;
2556
+ while (to > at && blank(lines[to]))
2557
+ to--;
2558
+ if (to > at)
2559
+ out.push({ start: rawStart(text, lines[at + 1].start), end: lines[to].end });
2560
+ at = to + 1;
2561
+ continue;
2562
+ }
2543
2563
  const named = PRINTENV_NAMES.exec(body);
2544
2564
  const echoed = ECHO_VARIABLE.exec(body);
2545
2565
  if (named || (echoed && secretName(echoed[2]))) {
@@ -2578,64 +2598,65 @@ const READ_TOOL = /^\s{0,8}(?:⏺\s{0,2})?Read\(([^()\s]{1,512})\)\s{0,8}$/;
2578
2598
  const readPath = (body) => READ_COMMAND.exec(body)?.[2] ?? READ_TOOL.exec(body)?.[1];
2579
2599
  /** The file a command prints whole, when it is one read alone (`cat ~/.pgpass`): its output is that file's content
2580
2600
  * (ruling LVI). */
2581
- export const commandReadPath = (command) => (command === undefined ? undefined : readPath(command));
2601
+ export const commandReadPath = (command) => (command === undefined ? undefined : factsOf(command).readPath);
2602
+ let lastCommand;
2603
+ function factsOf(command) {
2604
+ if (lastCommand?.command === command)
2605
+ return lastCommand.facts;
2606
+ const facts = { readPath: readPath(command), paths: pathWords(command), dumps: command.trim() !== "" && printsEnvironment(command), names: new Map() };
2607
+ lastCommand = { command, facts };
2608
+ return facts;
2609
+ }
2610
+ /** Quote and escape characters, dropped before a command line is read: a quoted script's words are the line's own
2611
+ * words however deep its shells nest (`bash -c "bash -c 'env'"`), and a word spelled across quotes or behind a
2612
+ * backslash (`e"n"v`, `\env`) reads whole. No depth is followed, so none can run out. */
2613
+ const COMMAND_QUOTES = /["'\\]/g;
2582
2614
  /** Where a command line splits into the commands it runs: `;`, `&&`, `||`, a pipe, a lone `&` (not a redirection's:
2583
- * `2>&1`, `&>`), a line break, a subshell's or a substitution's `(` and `)`, a backtick. Quotes are not read: a split
2584
- * inside them only makes more pieces to read, and an env word in one is read as a command (`echo "a; env"`, an over-cut
2585
- * that fails closed). */
2615
+ * `2>&1`, `&>`), a line break, a subshell's or a substitution's `(` and `)`, a backtick. */
2586
2616
  const COMMAND_SPLIT = /;|&&|\|\||\||(?<![<>&])&(?![&>])|\n|\(|\)|`/;
2587
2617
  const COMMAND_BLANKS = /[ \t\r]{1,4096}/;
2588
- /** A shell prompt standing as a piece's first word (`$ env`, `C:\app> set`). */
2589
- const PROMPT_WORD = /^(?:[$#%>❯]|[A-Za-z]:\\[^>\n]{0,256}>)$/;
2590
- /** A leading assignment (`FOO=1 printenv A`): the command follows it. */
2591
- const ASSIGNMENT_WORD = /^[A-Za-z_][A-Za-z0-9_]{0,127}=/;
2592
2618
  /** A redirection (`2>&1`, `>/tmp/e`, `&>log`); one that is its operator alone takes the next word as its file. */
2593
2619
  const REDIRECT_WORD = /^(?:\d{1,2}|&)?(?:<<?|>>?)(?:&\d{0,2}-?)?/;
2594
2620
  const REDIRECT_ALONE = /^(?:\d{1,2}|&)?(?:<<?|>>?)$/;
2595
- /** A variable's expansion in a word (`$APP_SEED`, `"x=${A}"`). */
2596
- const VARIABLE_WORD = /\$\{?[A-Za-z_]/;
2597
- /** A word's quotes at its ends (`'env'`, `env"` past a split inside quotes). */
2598
- const WORD_EDGE_QUOTES = /^["']{1,8}|["']{1,8}$/g;
2599
- /** A shell's flag that runs its next words as a script (`-c`, `-lc`). */
2600
- const SCRIPT_FLAG = /^-[A-Za-z]{0,8}c[A-Za-z]{0,8}$/;
2601
- const NUMBER_WORD = /^\d{1,12}(?:\.\d{1,6})?[smhd]?$/;
2621
+ /** A redirection written against a word (`env>/tmp/e`): the word is what comes before it. */
2622
+ const WORD_REDIRECT = /\d{0,2}[<>]/;
2623
+ /** Where a line, quotes dropped and lower-cased, splits into the tokens an env name is read from: anything but a
2624
+ * letter, a digit, `_` or `-`. A name joined to other characters is a token of its own (`process["env"]`,
2625
+ * `env.APP_SEED`, `o.environ`, `Bun.env`, `ENVIRON[`, `</proc/1/environ`, `$env:A`, `std::env`). */
2626
+ const ENV_TOKEN_BREAK = /[^a-z0-9_-]{1,4096}/;
2627
+ /** A dotfile `.env` (`.env`, `.env.example`, `src/.env`) named as a word or after a path's `/`, `=`, `<`, `>`, `,` or
2628
+ * `:`: a file, which env-file reads, not the environment. `process.env`, `process?.env`, `Bun.env` keep the character
2629
+ * before their dot and are read. */
2630
+ const DOT_ENV_FILE = /(^|[ \t/=<>,:])\.env(?![a-z0-9_-])/gi;
2631
+ /** A token that runs, names or reads the environment wherever it stands in a line: env, printenv, envsubst, environ (a
2632
+ * /proc file, awk's ENVIRON, Python's os.environ), getenv and GetEnvironmentVariables, PHP's $_ENV and $_SERVER,
2633
+ * compgen, systemd's show-environment, a container's inspect, xtrace. An env token in a file's name is read so too
2634
+ * (`ls src/env.ts`, `cp .env.example .env`): an over-cut, ruled so. */
2635
+ const ENV_WORD = /^(?:(?:print)?env|envsubst|environ|compgen|show-environment|inspect|_env|_server|xtrace)$|^getenv/;
2636
+ /** A variable's expansion: sh's `$NAME` and any `${...}` (`${!v}` too), cmd's `%NAME%`. */
2637
+ const VARIABLE_WORD = /\$(?:\{|[A-Za-z_])|%[A-Za-z_][A-Za-z0-9_]{0,127}%/;
2638
+ /** A flag that turns xtrace on (`set -x`, `set -ex`, `bash -x`, `sh -xc`): each command is printed with its variables
2639
+ * expanded. */
2640
+ const XTRACE_FLAG = /^-[a-z]{0,8}x[a-z]{0,8}$/;
2641
+ /** A here-document or here-string: what it holds is expanded into a command's input. */
2642
+ const HERE_INPUT = /<</;
2602
2643
  /** export's or declare's flag that prints (`-p`, `-px`). */
2603
2644
  const PRINT_FLAG = /^-[A-Za-z]{0,8}p/;
2604
- /** Words a command can stand behind: grouping, control flow, negation. */
2605
- const LEAD_WORDS = new Set(["{", "}", "!", "if", "then", "else", "elif", "do", "while", "until"]);
2606
- /** Commands that run the command after them (their flags, a flag's argument and a number between). */
2607
- const WRAPPERS = new Set(["sudo", "doas", "exec", "command", "builtin", "time", "nice", "nohup", "timeout", "stdbuf", "ionice", "chrt", "unbuffer"]);
2608
- const WRAPPER_ARG_FLAGS = new Set(["-u", "-g", "-n", "-p", "-c", "-s", "-k", "-C", "-o", "-e", "-i"]);
2609
- const ENV_ARG_FLAGS = new Set(["-u", "--unset", "-C", "--chdir"]);
2610
- const SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
2611
- const commandName = (word) => {
2612
- const bare = word.replace(WORD_EDGE_QUOTES, "");
2613
- return bare.slice(bare.lastIndexOf("/") + 1);
2645
+ /** ps's BSD-style option word that adds each process's environment (`ps e`, `ps eww`, `ps auxe`). */
2646
+ const PS_ENV_OPTION = /^[a-z]{0,16}e[a-z]{0,16}$/;
2647
+ /** Commands that print their arguments: with a variable anywhere in the line, its value is read as printed. */
2648
+ const PRINT_WORDS = new Set(["echo", "printf", "print", "puts", "say", "write-output", "write-host"]);
2649
+ /** Builtins that print every variable given no name to set: with flags alone, or a printing flag. */
2650
+ const DECLARE_WORDS = new Set(["export", "declare", "typeset", "readonly"]);
2651
+ /** set and the shells, whose -x flag turns xtrace on. */
2652
+ const XTRACE_WORDS = new Set(["set", "sh", "bash", "zsh", "dash", "ksh"]);
2653
+ /** A word's name: before a redirection written against it, past its path, lower case. */
2654
+ const wordName = (word) => {
2655
+ const bare = word.split(WORD_REDIRECT)[0];
2656
+ return bare.slice(bare.lastIndexOf("/") + 1).toLowerCase();
2614
2657
  };
2615
- /** Whether one command of a line prints the environment or a variable's value: env or printenv (env's own options and
2616
- * assignments aside, no command after it), set or export with no argument, export or declare -p, compgen -v, an echo
2617
- * or printf of a variable, or a shell's `-c` script that does. Read past a prompt, grouping and control-flow words,
2618
- * wrappers (`sudo -E`, `nice -n 5`, `exec`, a path), leading assignments and redirections. An echo of any variable
2619
- * counts, a secret name or not (`cd x && echo $PWD && npm test` cuts the test's output too: an over-cut, fails
2620
- * closed). */
2621
- function pieceDumps(piece, depth) {
2622
- const words = piece.split(COMMAND_BLANKS).filter(Boolean);
2623
- let at = 0;
2624
- while (at < words.length) {
2625
- const word = words[at];
2626
- if (PROMPT_WORD.test(word) || LEAD_WORDS.has(word) || ASSIGNMENT_WORD.test(word)) {
2627
- at++;
2628
- continue;
2629
- }
2630
- if (!WRAPPERS.has(commandName(word)))
2631
- break;
2632
- at++;
2633
- while (at < words.length && (words[at].startsWith("-") || NUMBER_WORD.test(words[at])))
2634
- at += WRAPPER_ARG_FLAGS.has(words[at]) ? 2 : 1;
2635
- }
2636
- if (at >= words.length)
2637
- return false;
2638
- const name = commandName(words[at]);
2658
+ /** A command's arguments after the word at `at`, its redirections left out. */
2659
+ function argsAfter(words, at) {
2639
2660
  const args = [];
2640
2661
  for (let i = at + 1; i < words.length; i++) {
2641
2662
  if (REDIRECT_ALONE.test(words[i]))
@@ -2643,44 +2664,45 @@ function pieceDumps(piece, depth) {
2643
2664
  else if (!REDIRECT_WORD.test(words[i]))
2644
2665
  args.push(words[i]);
2645
2666
  }
2646
- const flagsOnly = args.every((arg) => arg.startsWith("-"));
2647
- switch (name) {
2648
- case "printenv":
2649
- return true;
2650
- case "env":
2651
- for (let i = 0; i < args.length; i++) {
2652
- if (ENV_ARG_FLAGS.has(args[i]))
2653
- i++;
2654
- else if (!args[i].startsWith("-") && !ASSIGNMENT_WORD.test(args[i]))
2655
- return false;
2656
- }
2667
+ return args;
2668
+ }
2669
+ /** Whether a command of a line, quotes dropped, prints the environment by its builtins' arguments: set with nothing
2670
+ * after it, or set or a shell with an xtrace flag; export, declare, typeset or readonly with flags alone or a printing
2671
+ * flag; ps with an `e` option. */
2672
+ function pieceDumps(piece) {
2673
+ const words = piece.split(COMMAND_BLANKS).filter(Boolean);
2674
+ return words.some((word, at) => {
2675
+ const name = wordName(word);
2676
+ if (!XTRACE_WORDS.has(name) && !DECLARE_WORDS.has(name) && name !== "ps")
2677
+ return false;
2678
+ const args = argsAfter(words, at);
2679
+ if (XTRACE_WORDS.has(name) && args.some((arg) => XTRACE_FLAG.test(arg.toLowerCase())))
2657
2680
  return true;
2658
- case "set":
2681
+ if (name === "set")
2659
2682
  return args.length === 0;
2660
- case "export":
2661
- case "declare":
2662
- case "typeset":
2663
- return flagsOnly || args.some((arg) => PRINT_FLAG.test(arg));
2664
- case "compgen":
2665
- return args.includes("-v");
2666
- case "echo":
2667
- case "printf":
2668
- return args.some((arg) => VARIABLE_WORD.test(arg));
2669
- default: {
2670
- if (!SHELLS.has(name) || depth >= 2)
2671
- return false;
2672
- const flag = args.findIndex((arg) => SCRIPT_FLAG.test(arg));
2673
- return flag >= 0 && printsEnvironment(args.slice(flag + 1).join(" ").replace(WORD_EDGE_QUOTES, ""), depth + 1);
2674
- }
2675
- }
2683
+ if (DECLARE_WORDS.has(name))
2684
+ return args.every((arg) => arg.startsWith("-")) || args.some((arg) => PRINT_FLAG.test(arg));
2685
+ return name === "ps" && args.some((arg) => PS_ENV_OPTION.test(arg));
2686
+ });
2676
2687
  }
2677
- /** Whether a call's command line prints the environment or a variable's value, any one of its commands (`env`,
2678
- * `cd app && env | sort`, `printenv A; printenv A B`, `(env)`, `bash -c 'env'`). A line longer than is read is read so
2679
- * too: what lies past the read can't be told (fails closed). */
2680
- function printsEnvironment(command, depth = 0) {
2688
+ /** Whether a call's command line prints the environment or a variable's value (`env`, `cd app && env | sort`,
2689
+ * `bash -c "bash -c 'env'"`, `cat</proc/self/environ`, `node -p 'process["env"]'`). Quotes and escapes are dropped,
2690
+ * and the line is read as tokens, not command shapes (11-25 r2: a reader of shapes, wrappers, env's own command or
2691
+ * nested shells, missed one more each time). A dump when any token is an env token (`sudo -n env`, `ssh host env`,
2692
+ * `jq -rn 'env.A'`), a builtin's arguments make one (pieceDumps), or a token that prints (echo, printf, print, an
2693
+ * awk program's print) or a here-string stands in a line with a variable anywhere (`cd x && echo $PWD && npm test`
2694
+ * cuts the test's output too: an over-cut, fails closed). A line longer than is read is read so too. Not seen: what
2695
+ * an earlier call set up (an alias, a symlink to an environ file, a script it wrote), which no line reader can. */
2696
+ function printsEnvironment(command) {
2681
2697
  if (command.length > COMMAND_MAX)
2682
2698
  return true;
2683
- return command.split(COMMAND_SPLIT).some((piece) => pieceDumps(piece, depth));
2699
+ const line = command.replace(COMMAND_QUOTES, "").replace(DOT_ENV_FILE, "$1");
2700
+ const tokens = line.toLowerCase().split(ENV_TOKEN_BREAK);
2701
+ if (tokens.some((token) => ENV_WORD.test(token)))
2702
+ return true;
2703
+ if (VARIABLE_WORD.test(command) && (HERE_INPUT.test(command) || tokens.some((token) => PRINT_WORDS.has(token))))
2704
+ return true;
2705
+ return line.split(COMMAND_SPLIT).some(pieceDumps);
2684
2706
  }
2685
2707
  /** All of a call's output as one dump, from its first character that is not a blank to its last (11-25 read): its
2686
2708
  * lines can't be told apart by command, a value can span lines, and a first line that opens like a JSON field or a
@@ -2695,7 +2717,7 @@ function wholeDump(text) {
2695
2717
  /** A command's output, given apart from its command (ruling LVI): all of it is a dump when the command prints the
2696
2718
  * environment or a variable's value, alone on its line or among others. An approval outcome's head line is cut with
2697
2719
  * it (ruled so: never split on run-view's words). */
2698
- const commandDumps = (text, given) => (given !== undefined && given.trim() !== "" && printsEnvironment(given) ? wholeDump(text) : []);
2720
+ const commandDumps = (text, given) => (given !== undefined && factsOf(given).dumps ? wholeDump(text) : []);
2699
2721
  const PATH_SEPARATOR = /[\\/]/;
2700
2722
  const ENV_FILE_NAME = /^(?:\.env(?:rc)?|\.env\.[A-Za-z0-9_.-]{1,64}|[A-Za-z0-9_.-]{1,64}\.env)$/;
2701
2723
  const ENV_TEMPLATE = /\.(?:example|sample|template|tmpl|dist|defaults?|schema)$/i;
@@ -2741,12 +2763,24 @@ const COMMAND_WORD_SPLIT = /[\s|;&<>()]{1,64}/;
2741
2763
  const OPTION_NAME = /^-{1,2}[A-Za-z0-9-]{1,64}=/;
2742
2764
  const WORD_QUOTES = /["']/g;
2743
2765
  const COMMAND_MAX = 65_536;
2744
- export const commandPaths = (command) => command === undefined ? [] : command.slice(0, COMMAND_MAX).split(COMMAND_WORD_SPLIT).map((word) => word.replace(OPTION_NAME, "").replace(WORD_QUOTES, "")).filter(Boolean);
2766
+ /** Whether a command names, anywhere in its words, a path `fits` takes: asked once a command and predicate (factsOf),
2767
+ * so a call's output read string by string never walks its command's words again. `fits` is a module-level function. */
2768
+ function commandNames(command, fits) {
2769
+ if (command === undefined)
2770
+ return false;
2771
+ const { paths, names } = factsOf(command);
2772
+ let named = names.get(fits);
2773
+ if (named === undefined)
2774
+ names.set(fits, (named = paths.some(fits)));
2775
+ return named;
2776
+ }
2777
+ const dockerConfigPath = (path) => DOCKER_CONFIG.test(path);
2778
+ const pathWords = (command) => command.slice(0, COMMAND_MAX).split(COMMAND_WORD_SPLIT).map((word) => word.replace(OPTION_NAME, "").replace(WORD_QUOTES, "")).filter(Boolean);
2745
2779
  /** The text whole, its trailing blanks left out, when the caller says it is the content of a file `fits` names: the call
2746
2780
  * read that file (`ctx.path`), or its command names one anywhere (ruling LXII d: `grep app ~/.pgpass`, `jq . ~/.docker/
2747
2781
  * config.json`, `grep -v ^# .env`; an over-cut, `ls ~/.ssh/known_hosts`'s, fails closed). */
2748
2782
  const wholeText = (text, ctx, fits) => {
2749
- if (!((ctx.path !== undefined && fits(ctx.path)) || commandPaths(ctx.command).some(fits)) || DUMP_MARKER_LINE.test(text))
2783
+ if (!((ctx.path !== undefined && fits(ctx.path)) || commandNames(ctx.command, fits)) || DUMP_MARKER_LINE.test(text))
2750
2784
  return [];
2751
2785
  const end = text.trimEnd().length;
2752
2786
  return end > 0 ? [{ start: 0, end }] : [];
@@ -2984,7 +3018,7 @@ export const RULE_PATTERNS = Object.freeze({
2984
3018
  CODE_CALL, IDENT_CHAIN, MEMBER_CHAIN, CODE_CASE, CAMEL_OR_SNAKE, CALL_AFTER, LITERAL_START, YAML_NODE, ELIDED_AFTER, REFERENCE, ELIDED, TRAILING_PUNCTUATION, SENTENCE_END, BARE_START, EDGE_BLANK, EDGE_TOKEN_PUNCT, SLUG_OFF, SLUG_ENDS, PEM_END, PEM_BEGIN, PEM_OFF, PEM_TAIL, PEM_BODY_LINE, PEM_LAST_LINE, PEM_END_LINE, LEAD_TOKEN, DIGIT_START, BASE64_CHAR, BACKSLASH_RUN, BARE_STOP, URL_USERINFO, NAME_KEY_OFF, IDENTIFIER, ENDS_ENTRY, ENTRY_END_AFTER, TYPE_SUFFIX, TYPE_AFTER, LOCAL_LEAD, LOCAL_END, NESTED_ESCAPE, COOKIE_SPLIT, LINT_URL, CAMEL_HUMP, NAME_SEPARATORS, DIGITS_ONLY,
2985
3019
  UPPER_NAME, LEAD_AT_START, LINE_PREFIX, LINE_REST, CODE_KEYWORD, CODE_EXPRESSION, OPENERS, CLOSERS, INI_HEADER, INI_LINE, NPMRC_AUTH, NPM_COMMAND, NPM_SET_SCAN, NPM_SET_AUTH, NPM_AUTH_KEY, ESCAPED_QUOTE_BEFORE, ESCAPED_QUOTE_AFTER, DOTTED_KEY_BEFORE, CODE_END, MEMBER_OBJECT_BEFORE, CODE_ROOT_BEFORE, STATEMENT_END_AFTER, REFERENCE_START, ENV_ASSIGN, HF_TOKEN, DIGITALOCEAN_TOKEN, PYPI_TOKEN, SENDGRID_KEY, ASSIGN, ASSIGN_SPACED, ASSIGN_COLON, SSHPASS, MYSQL_COMMAND, PASSWORD_FLAG, LOGIN_COMMAND,
2986
3020
  REDIS_COMMAND, LOGIN_SCAN, LOGIN_P, REDIS_SCAN, REDIS_A, MYSQL_SCAN, MYSQL_P, OPENSSL_PASS, NETRC, AUTH_HEADER, TOKEN_RUN, CODE_KEY_BEFORE, URL_SAFE_RUN, BASE64_RUN_BEFORE, BASE64_RUN_AFTER, LETTER_OR_DIGIT, ENV_NAME_RUN, BASE64_CHARS, COOKIE_HEADER, COOKIE_PAIR, CURL_COMMAND, CURL_SCAN, CURL_USER, GLUED_STOP, NUMBERED, JSON_FIELD_OPEN, PROMPT_LINE,
2987
- ENV_LINE, ENV_COMMAND, PRINTENV_NAMES, ECHO_VARIABLE, COMMAND_SPLIT, COMMAND_BLANKS, PROMPT_WORD, ASSIGNMENT_WORD, REDIRECT_WORD, REDIRECT_ALONE, VARIABLE_WORD, WORD_EDGE_QUOTES, SCRIPT_FLAG, NUMBER_WORD, PRINT_FLAG, NAME_RUN, READ_COMMAND, READ_TOOL, PATH_SEPARATOR, ENV_FILE_NAME, ENV_TEMPLATE, SSH_FILE,
3021
+ ENV_LINE, ENV_COMMAND, PRINTENV_NAMES, ECHO_VARIABLE, COMMAND_QUOTES, COMMAND_SPLIT, COMMAND_BLANKS, REDIRECT_WORD, REDIRECT_ALONE, WORD_REDIRECT, ENV_TOKEN_BREAK, DOT_ENV_FILE, ENV_WORD, VARIABLE_WORD, XTRACE_FLAG, HERE_INPUT, PRINT_FLAG, PS_ENV_OPTION, PROMPT_HEAD, NAME_RUN, READ_COMMAND, READ_TOOL, PATH_SEPARATOR, ENV_FILE_NAME, ENV_TEMPLATE, SSH_FILE,
2988
3022
  CREDENTIAL_FILE, FILE_VARIABLE, ENV_FILE_LINE, KEY_LINE, SSH_CONFIG, COMMENT_LINE, PEM_LINE, BASE64_LINE, PEM_HEADER_LINE, HOME_UNIX, HOME_WINDOWS, SEGMENT_AFTER,
2989
3023
  TRAILING_SLASHES, HOME_USER, CLAUDE_SLUG, CLAUDE_PROJECTS_BEFORE, SLUG_OFF_CHARS, SLUG_USER, BOT_TRAILER, DUMP_MARKER_LINE, EMAIL, EXAMPLE_DOMAIN, NO_REPLY_LOCAL, NO_REPLY_DOMAIN, FORGE_NO_REPLY, USER_ONLY_BEFORE, PORT_PASSWORD, HOST_SHAPED, IPV4, VERSION_BEFORE, PRE_RELEASE_AFTER,
2990
3024
  BUILD_AFTER, RANGE_AFTER, IPV6, IPV6_GROUPS, ENV_PREFIX_BEFORE, ENV_PREFIX_AFTER, ENV_PREFIX_CHAIN, ENV_PREFIX_STATEMENT, ENV_FLAG, HELM_LIST_FLAG, HELM_SET, HELM_NAME, RESOURCE_NAME, SECRET_OBJECT_NAME, CONNECTION_PASSWORD, ADO_PAIR, CONNECTION_KEY_PAIR, BLANKS, LIBPQ_PAIR_AFTER, FORMAT_FIELD, PWD_PATH, QUERY_VALUE_STOP, QUERY_PASSWORD, ARGUMENT_TAIL, NEXT_ASSIGNMENT, ASSIGNMENT_BEFORE,
package/dist/server.d.ts CHANGED
@@ -9,6 +9,7 @@ import { type Place } from "./place.js";
9
9
  import { type ApiToken } from "./api-token.js";
10
10
  import { type CutScrub } from "./run-export.js";
11
11
  import { type Store } from "./store/index.js";
12
+ import { type Machine } from "./local-model.js";
12
13
  import { type BoxOffer, type ContainerFacts } from "./place-offers.js";
13
14
  import { type Wait } from "./docker-host-addresses.js";
14
15
  import { type StoredKeys } from "./secrets.js";
@@ -98,6 +99,11 @@ export type ServeOptions = {
98
99
  * (the console, sign-in, setup, settings, MCP, triggers, hooks, ...) with a 404 before anything reads the request.
99
100
  * It has no owner: accounts and open setup are off, there being no page to sign in to. */
100
101
  apiOnly?: boolean;
102
+ /** The share host (`--share-host`, AGENTRUN_SHARE_HOST=1, share-host.ts): serve shares under /r/ alone (a share's page,
103
+ * its stored bundle, the page's assets, /r/v2/shares and /r/v2/health) and refuse every other address with a 404
104
+ * before anything reads the request. No runner beside it, no owner (accounts and open setup are off), and its share
105
+ * URLs on `publicUrl` (AGENTRUN_PUBLIC_URL): a start on an address other than loopback without one is refused. */
106
+ shareHost?: boolean;
101
107
  /** AGENTRUN_API_ONLY_MCP_ORIGINS, read as the environment's is (the serve README's API-only section); only with apiOnly. */
102
108
  apiOnlyMcpOrigins?: readonly string[];
103
109
  /** The launch hook (AGENTRUN_LAUNCH_HOOK_URL and _SECRET, trigger-launch-hook.ts): each trigger firing that would start
@@ -196,12 +202,21 @@ export type ServeOptions = {
196
202
  console?: string;
197
203
  /** How long a run's process may finish its turn after SIGTERM (default 30s): `8s`, `500ms`, `1m`. */
198
204
  drainTimeout?: string;
205
+ /** How long a cut read of a run's file waits for its cut (cut-pool.ts) before it is refused 503 (default CUT_MS). For
206
+ * tests. */
207
+ cutMs?: number;
199
208
  /** How often the runs' listings' builder looks again when it found nothing to build (run-listing.ts; default
200
209
  * LISTER_IDLE_MS). `Infinity`: it builds only when Serve.listingSettled asks, so a test reads what a list builds alone. */
201
210
  listerIdleMs?: number;
202
211
  /** How often a timeline page that waits (`wait_ms`) reads the store again while nothing changed (default 1000 ms,
203
212
  * run-reads-over-store.ts). A test's server reads sooner, so a change is served without the rest of a second's wait. */
204
213
  timelinePollMs?: number;
214
+ /** For tests: this machine as GET /settings/local-model reads it (local-model.ts Machine), in place of the real one, so no
215
+ * test reads the hardware it runs on. */
216
+ machine?: () => Promise<Machine>;
217
+ /** For tests: how long a local model pull may go with no byte from Ollama before it stops (ollama-provider.ts
218
+ * PULL_STALL_MS, two minutes, by default). */
219
+ pullStallMs?: number;
205
220
  /** No runner beside this server in its process (the CLI's --no-runner, the image's server-and-runner): a paired
206
221
  * computer's socket is held here while no run holds it, and relayed to the runner that holds a run of it
207
222
  * (workspace/paired-route.ts); while no runner relays, a pairing code, the pair answer and each paired computer say no
@@ -254,7 +269,8 @@ export type ServeOptions = {
254
269
  * command row is written, with the run's id and the message's text, so a test can hold a message at the run's door while
255
270
  * the run's state changes under it (runs-over-store.ts message). */
256
271
  beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
257
- /** A test's seam: the scrubber GET /runs/{id}/export cuts with (run-export.ts), in place of secret-cut.ts scrub. */
272
+ /** A test's seam: the scrubber GET /runs/{id}/export cuts with (run-export.ts), and a share host scrubs an upload with
273
+ * (share-host.ts), in place of secret-cut.ts scrub. */
258
274
  shareScrub?: CutScrub;
259
275
  /** A test's seam: step 2 of DELETE /agents/{id} (agent-delete.ts) in place of the learning module's deleteLearning over
260
276
  * the agent's learning (learn/delete.ts), the server's own. */