@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.
- package/CHANGELOG.md +124 -0
- package/README.md +139 -22
- package/dist/acp-package.d.ts +4 -0
- package/dist/api-only.d.ts +23 -1
- package/dist/api-only.js +43 -4
- package/dist/archil-settings.d.ts +9 -0
- package/dist/archil-settings.js +8 -1
- package/dist/bash-read-only.d.ts +3 -0
- package/dist/bash-read-only.js +6 -3
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +26 -8
- package/dist/chatgpt-plan.js +89 -21
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +61 -18
- package/dist/composio-triggers.d.ts +9 -3
- package/dist/computers.d.ts +3 -0
- package/dist/computers.js +2 -1
- package/dist/console/assets/{backend-QnwGVBeU.js → backend-DEgVn5lC.js} +1 -1
- package/dist/console/assets/index-CG5tELph.js +639 -0
- package/dist/console/assets/share-CIeFK2Oe.js +6 -0
- package/dist/console/assets/{styles-CcceGcu2.js → styles-BGZxYkky.js} +2 -2
- package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/cut-pool.d.ts +14 -0
- package/dist/cut-pool.js +98 -0
- package/dist/cut-worker.d.ts +14 -0
- package/dist/cut-worker.js +16 -0
- package/dist/decisions.d.ts +4 -0
- package/dist/decisions.js +9 -1
- package/dist/env-switch.d.ts +3 -0
- package/dist/env-switch.js +3 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +12 -3
- package/dist/harness-table.js +13 -8
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/key-refusal.js +6 -4
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learned-nodes.d.ts +37 -0
- package/dist/learned-nodes.js +24 -0
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-servers-store.d.ts +7 -10
- package/dist/mcp-servers-store.js +15 -9
- package/dist/native/cli.js +5 -1
- package/dist/ollama-provider.d.ts +42 -0
- package/dist/ollama-provider.js +118 -2
- package/dist/openapi.js +85 -16
- package/dist/otel/tracer.d.ts +6 -3
- package/dist/otel/tracer.js +24 -6
- package/dist/page.d.ts +7 -0
- package/dist/page.js +17 -4
- package/dist/place.d.ts +28 -11
- package/dist/place.js +43 -14
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/redact/match.d.ts +17 -4
- package/dist/redact/match.js +57 -15
- package/dist/run-export.js +4 -2
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +2 -1
- package/dist/run-model-key.js +2 -1
- package/dist/run-reads-over-store.d.ts +7 -0
- package/dist/run-reads-over-store.js +32 -4
- package/dist/run-usage.js +3 -2
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +16 -6
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +148 -29
- package/dist/runner/adapter-run-spec.d.ts +9 -6
- package/dist/runner/adapter-run-spec.js +38 -52
- package/dist/runner/adapters/index.d.ts +4 -0
- package/dist/runner/adapters/index.js +2 -1
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +18 -7
- package/dist/runner/cli-run-spec.js +24 -17
- package/dist/runner/compare-end.d.ts +1 -1
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/harness-loops.d.ts +14 -0
- package/dist/runner/harness-loops.js +51 -5
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/live-ticker.js +5 -4
- package/dist/runner/loop-contract.d.ts +4 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +24 -4
- package/dist/runner/mcp-run.js +47 -2
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +6 -0
- package/dist/runner/metrics.js +12 -4
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +3 -3
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +44 -29
- package/dist/runner/run-child.js +1 -0
- package/dist/runner/runner.js +2 -0
- package/dist/runner/sdk-loop.js +5 -3
- package/dist/runner/workflow-calls.d.ts +5 -1
- package/dist/runner/workflow-calls.js +65 -19
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.d.ts +0 -1
- package/dist/secret-rules.js +122 -88
- package/dist/server.d.ts +17 -1
- package/dist/server.js +208 -69
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +666 -0
- package/dist/slack.js +2 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/store-reads/learning.d.ts +5 -4
- package/dist/store-reads/learning.js +7 -4
- package/dist/suggestions.js +32 -3
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +7 -3
- package/dist/tool-gate.d.ts +25 -9
- package/dist/tool-gate.js +58 -19
- package/dist/tool-plane.d.ts +24 -1
- package/dist/tool-plane.js +75 -3
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-composio.js +1 -1
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.js +5 -0
- package/dist/workspace/archil-claim.d.ts +7 -3
- package/dist/workspace/archil-claim.js +13 -5
- package/dist/workspace/archil-mount-credential.d.ts +6 -0
- package/dist/workspace/archil-mount-credential.js +11 -0
- package/dist/workspace/computer-deps.d.ts +5 -3
- package/dist/workspace/computer-deps.js +11 -9
- package/dist/workspace/computer-for-claim.d.ts +6 -2
- package/dist/workspace/computer-for-claim.js +43 -12
- package/dist/workspace/computer-janitor.d.ts +7 -4
- package/dist/workspace/computer-janitor.js +7 -4
- package/dist/workspace/computer-kept.d.ts +7 -1
- package/dist/workspace/computer-kept.js +7 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
- package/dist/workspace/mount-revoke-left.d.ts +16 -4
- package/dist/workspace/mount-revoke-left.js +42 -22
- package/dist/workspace/resolve-computer.d.ts +11 -5
- package/dist/workspace/resolve-computer.js +22 -13
- package/dist/workspace/run-end-computers.js +1 -1
- package/dist/workspace/run-tools.d.ts +10 -3
- package/dist/workspace/run-tools.js +5 -4
- package/dist/wrapped.d.ts +29 -2
- package/dist/wrapped.js +20 -3
- package/launcher/agentrun-serve +1 -1
- package/package.json +12 -12
- package/dist/console/assets/index-DZi-muIj.js +0 -629
- package/dist/console/assets/share-pz61zIn9.js +0 -6
package/dist/secret-rules.d.ts
CHANGED
|
@@ -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. */
|
package/dist/secret-rules.js
CHANGED
|
@@ -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 =
|
|
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 :
|
|
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.
|
|
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
|
|
2596
|
-
const
|
|
2597
|
-
/**
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
const
|
|
2601
|
-
|
|
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
|
-
/**
|
|
2605
|
-
const
|
|
2606
|
-
/** Commands that
|
|
2607
|
-
const
|
|
2608
|
-
|
|
2609
|
-
const
|
|
2610
|
-
|
|
2611
|
-
const
|
|
2612
|
-
|
|
2613
|
-
|
|
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
|
-
/**
|
|
2616
|
-
|
|
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
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
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
|
-
|
|
2681
|
+
if (name === "set")
|
|
2659
2682
|
return args.length === 0;
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
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
|
|
2678
|
-
* `
|
|
2679
|
-
*
|
|
2680
|
-
|
|
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
|
-
|
|
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 &&
|
|
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
|
-
|
|
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)) ||
|
|
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,
|
|
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),
|
|
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. */
|