@parcha/agentrun-serve 0.1.0-beta.61 → 0.1.0-beta.63
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 +113 -0
- package/README.md +128 -20
- package/dist/adapters.js +4 -2
- package/dist/agent-delete.d.ts +3 -3
- package/dist/agent-delete.js +50 -4
- package/dist/api-only.d.ts +4 -0
- package/dist/api-only.js +5 -1
- 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/chatgpt-plan.d.ts +33 -8
- package/dist/chatgpt-plan.js +141 -24
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +19 -8
- 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-C9ffXUR5.js → backend-BxQ2G1M0.js} +2 -2
- package/dist/console/assets/index-C8Y5Zl8x.js +639 -0
- package/dist/console/assets/share-CjBJ_rxP.js +6 -0
- 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/harness-opencode/adapter.d.ts +3 -1
- package/dist/harness-opencode/adapter.js +6 -2
- package/dist/harness-opencode/harness.d.ts +4 -0
- package/dist/harness-opencode/harness.js +6 -1
- package/dist/harness-table.d.ts +7 -0
- package/dist/harness-table.js +6 -3
- package/dist/host-tools.d.ts +18 -3
- package/dist/host-tools.js +27 -4
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/learn/ledger.d.ts +37 -16
- package/dist/learn/ledger.js +56 -24
- package/dist/learn/promote.d.ts +4 -1
- package/dist/learned-nodes.d.ts +2 -1
- package/dist/learned-nodes.js +2 -1
- package/dist/learning-cost.d.ts +5 -3
- package/dist/learning-model.js +7 -5
- package/dist/learning-work.d.ts +69 -0
- package/dist/learning-work.js +148 -0
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- 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 +10 -3
- package/dist/ollama-provider.js +17 -7
- package/dist/openapi.js +51 -20
- 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 +25 -9
- package/dist/place.js +37 -11
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/run-export.js +7 -4
- package/dist/run-launch.d.ts +6 -1
- package/dist/run-launch.js +26 -6
- 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-view.js +9 -3
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +21 -11
- package/dist/runner/adapter-loop.js +95 -28
- package/dist/runner/adapter-run-spec.d.ts +20 -4
- package/dist/runner/adapter-run-spec.js +64 -30
- package/dist/runner/adapters/index.d.ts +6 -0
- package/dist/runner/adapters/index.js +5 -1
- package/dist/runner/adapters/pi.d.ts +42 -3
- package/dist/runner/adapters/pi.js +114 -13
- package/dist/runner/audit.d.ts +8 -2
- package/dist/runner/audit.js +34 -18
- package/dist/runner/book-cut.d.ts +6 -0
- package/dist/runner/book-cut.js +38 -0
- package/dist/runner/claim-secrets.d.ts +12 -5
- package/dist/runner/claim-secrets.js +28 -12
- package/dist/runner/cli-run-spec.d.ts +0 -2
- package/dist/runner/cli-run-spec.js +54 -25
- package/dist/runner/dispatch.js +2 -0
- package/dist/runner/harness-loops.d.ts +5 -0
- package/dist/runner/harness-loops.js +4 -1
- package/dist/runner/held.d.ts +6 -3
- package/dist/runner/learned-first.d.ts +5 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +15 -8
- package/dist/runner/learning-end.js +23 -7
- package/dist/runner/live-ticker.js +3 -1
- package/dist/runner/loop-contract.d.ts +8 -1
- package/dist/runner/main.js +2 -0
- package/dist/runner/mcp-run.d.ts +5 -0
- package/dist/runner/mcp-run.js +18 -0
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +5 -3
- package/dist/runner/model-route.d.ts +4 -0
- package/dist/runner/model-route.js +1 -1
- package/dist/runner/native-loop.js +2 -2
- package/dist/runner/pr-checkout.d.ts +12 -0
- package/dist/runner/pr-checkout.js +21 -2
- package/dist/runner/promotion.d.ts +9 -2
- package/dist/runner/promotion.js +79 -28
- package/dist/runner/reflect-hook.d.ts +7 -0
- package/dist/runner/reflect-hook.js +2 -1
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +65 -41
- package/dist/runner/run-child.js +2 -0
- package/dist/runner/runner.d.ts +9 -0
- package/dist/runner/runner.js +158 -25
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/workflow-calls.d.ts +4 -3
- package/dist/runner/workflow-calls.js +41 -12
- package/dist/runner/workflow-first.js +4 -3
- package/dist/runner/workflow-loop.js +13 -1
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/secret-cut.d.ts +4 -0
- package/dist/secret-cut.js +1 -1
- package/dist/secret-rules.d.ts +2 -1
- package/dist/secret-rules.js +88 -24
- package/dist/server.d.ts +10 -1
- package/dist/server.js +131 -44
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +669 -0
- package/dist/store/schema.d.ts +4 -3
- package/dist/store/schema.js +4 -3
- package/dist/store/seal.d.ts +8 -2
- package/dist/store/seal.js +13 -2
- package/dist/store/sqlite/learning-rows.js +2 -1
- package/dist/store/sqlite/run-patch.js +4 -4
- package/dist/store/sqlite/store.js +28 -4
- package/dist/store/store.d.ts +5 -0
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/store-reads/journal.d.ts +2 -0
- package/dist/store-reads/journal.js +1 -1
- package/dist/store-reads/learning.d.ts +4 -3
- package/dist/store-reads/learning.js +62 -18
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +18 -1
- 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-list.d.ts +4 -0
- package/dist/tool-list.js +4 -0
- package/dist/tool-plane.d.ts +1 -0
- package/dist/tool-plane.js +6 -2
- package/dist/tools.js +2 -2
- package/dist/trigger-composio.js +1 -1
- 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/attach.js +22 -5
- 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 +17 -4
- 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/templates/kyb/agent.md +7 -1
- package/templates/kyb/evals/list-file-fuzzy-alias/case.yaml +10 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/graders/finds-the-transliteration.md +17 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/prompt.md +7 -0
- package/templates/kyb/evals/list-file-hit/case.yaml +10 -0
- package/templates/kyb/evals/list-file-hit/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-hit/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-hit/graders/hits-by-company-number.md +18 -0
- package/templates/kyb/evals/list-file-hit/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-hit/prompt.md +7 -0
- package/templates/kyb/evals/list-file-no-hit/case.yaml +10 -0
- package/templates/kyb/evals/list-file-no-hit/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-no-hit/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-no-hit/graders/no-hit-by-whole-file.md +12 -0
- package/templates/kyb/evals/list-file-no-hit/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-no-hit/prompt.md +7 -0
- package/templates/kyb/evals/list-file-short-name/case.yaml +9 -0
- package/templates/kyb/evals/list-file-short-name/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-short-name/graders/finds-the-short-name.md +19 -0
- package/templates/kyb/evals/list-file-short-name/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-short-name/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-short-name/prompt.md +7 -0
- package/templates/kyb/evals/list-file-split-name/case.yaml +11 -0
- package/templates/kyb/evals/list-file-split-name/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-split-name/graders/finds-the-director.md +18 -0
- package/templates/kyb/evals/list-file-split-name/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-split-name/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-split-name/prompt.md +7 -0
- package/templates/kyb/kyb.schema.json +2 -2
- package/templates/kyb/rules/SANCTIONS.md +82 -13
- package/dist/console/assets/index-BnZV3lvW.js +0 -639
- package/dist/console/assets/share-B1o5mJ56.js +0 -6
- /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
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,10 +2517,11 @@ 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
|
|
2521
|
-
*
|
|
2522
|
-
*
|
|
2523
|
-
|
|
2520
|
+
/** A user's prompt opening a line, `$`, `%` or `❯`, and the command after it; or a full PS1 prompt ending in `$` or
|
|
2521
|
+
* `#` (`user@host:~/app$`, `root@c:/#`, `[deploy@web-1 app]$`), a virtualenv's `(venv) ` before either. A bare `#`
|
|
2522
|
+
* and `>` are left out: they open a markdown heading or quote far more often than a root prompt (`# Export`), and
|
|
2523
|
+
* their env commands are read by ENV_COMMAND as before. */
|
|
2524
|
+
const PROMPT_HEAD = /^\s{0,8}(?:\([^()\n]{1,64}\)[ \t]{1,3})?(?:[$%❯]|(?:[A-Za-z0-9_.-]{1,64}@[A-Za-z0-9_.-]{1,128}:[^\s]{0,256}|\[[^\]@\n]{1,64}@[^\]\n]{1,192}\])[$#])\s{1,3}(?=\S)/;
|
|
2524
2525
|
/** 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). */
|
|
2525
2526
|
const DUMP_MARKER_LINE = /^\s{0,8}\[redacted:[a-z0-9-]{1,64}(?: \d{1,9} lines)?\]\s{0,8}$/;
|
|
2526
2527
|
const notMarker = (body) => !DUMP_MARKER_LINE.test(body);
|
|
@@ -2598,7 +2599,15 @@ const READ_TOOL = /^\s{0,8}(?:⏺\s{0,2})?Read\(([^()\s]{1,512})\)\s{0,8}$/;
|
|
|
2598
2599
|
const readPath = (body) => READ_COMMAND.exec(body)?.[2] ?? READ_TOOL.exec(body)?.[1];
|
|
2599
2600
|
/** The file a command prints whole, when it is one read alone (`cat ~/.pgpass`): its output is that file's content
|
|
2600
2601
|
* (ruling LVI). */
|
|
2601
|
-
export const commandReadPath = (command) => (command === undefined ? undefined :
|
|
2602
|
+
export const commandReadPath = (command) => (command === undefined ? undefined : factsOf(command).readPath);
|
|
2603
|
+
let lastCommand;
|
|
2604
|
+
function factsOf(command) {
|
|
2605
|
+
if (lastCommand?.command === command)
|
|
2606
|
+
return lastCommand.facts;
|
|
2607
|
+
const facts = { readPath: readPath(command), paths: pathWords(command), dumps: command.trim() !== "" && printsEnvironment(command), names: new Map() };
|
|
2608
|
+
lastCommand = { command, facts };
|
|
2609
|
+
return facts;
|
|
2610
|
+
}
|
|
2602
2611
|
/** Quote and escape characters, dropped before a command line is read: a quoted script's words are the line's own
|
|
2603
2612
|
* words however deep its shells nest (`bash -c "bash -c 'env'"`), and a word spelled across quotes or behind a
|
|
2604
2613
|
* backslash (`e"n"v`, `\env`) reads whole. No depth is followed, so none can run out. */
|
|
@@ -2617,14 +2626,20 @@ const WORD_REDIRECT = /\d{0,2}[<>]/;
|
|
|
2617
2626
|
* `env.APP_SEED`, `o.environ`, `Bun.env`, `ENVIRON[`, `</proc/1/environ`, `$env:A`, `std::env`). */
|
|
2618
2627
|
const ENV_TOKEN_BREAK = /[^a-z0-9_-]{1,4096}/;
|
|
2619
2628
|
/** A dotfile `.env` (`.env`, `.env.example`, `src/.env`) named as a word or after a path's `/`, `=`, `<`, `>`, `,` or
|
|
2620
|
-
*
|
|
2621
|
-
* before their dot and are read.
|
|
2622
|
-
|
|
2629
|
+
* `:`, its whole name up to where a path ends: a file, which env-file reads, not the environment. `process.env`,
|
|
2630
|
+
* `process?.env`, `Bun.env` keep the character before their dot and are read. A glob or a brace (`.env*`, `.env.*`,
|
|
2631
|
+
* `.env.{local,production}`) names no one file env-file can test: it is no path end, so its env token stays (11-26).
|
|
2632
|
+
* Its case is env-file's (ENV_FILE_NAME): `.ENV` or `.Env.local` is no file env-file cuts, so its env token stays too. */
|
|
2633
|
+
const DOT_ENV_FILE = /(^|[ \t/=<>,:])\.env(?:\.[A-Za-z0-9_-]{1,64}){0,8}(?=$|[\s/;|&<>),:])/g;
|
|
2634
|
+
/** A line break before a member access's dot (`process` then ` .env` on the next line, a chained call's formatting):
|
|
2635
|
+
* dropped, so the member reads joined to what it is a member of. */
|
|
2636
|
+
const MEMBER_BREAK = /[ \t]{0,64}\r?\n\s{0,64}(?=\.[A-Za-z_$])/g;
|
|
2623
2637
|
/** A token that runs, names or reads the environment wherever it stands in a line: env, printenv, envsubst, environ (a
|
|
2624
|
-
* /proc file, awk's ENVIRON, Python's os.environ),
|
|
2625
|
-
* compgen, systemd's show-environment, a container's
|
|
2638
|
+
* /proc file, awk's ENVIRON, Python's os.environ), environment (systemd's Environment property, /etc/environment),
|
|
2639
|
+
* getenv and GetEnvironmentVariables, PHP's $_ENV and $_SERVER, compgen, systemd's show-environment, a container's
|
|
2640
|
+
* inspect, xtrace. An env token in a file's name is read so too
|
|
2626
2641
|
* (`ls src/env.ts`, `cp .env.example .env`): an over-cut, ruled so. */
|
|
2627
|
-
const ENV_WORD = /^(?:(?:print)?env|envsubst|environ
|
|
2642
|
+
const ENV_WORD = /^(?:(?:print)?env|envsubst|environ(?:ment)?|compgen|show-environment|inspect|_env|_server|xtrace)$|^getenv/;
|
|
2628
2643
|
/** A variable's expansion: sh's `$NAME` and any `${...}` (`${!v}` too), cmd's `%NAME%`. */
|
|
2629
2644
|
const VARIABLE_WORD = /\$(?:\{|[A-Za-z_])|%[A-Za-z_][A-Za-z0-9_]{0,127}%/;
|
|
2630
2645
|
/** A flag that turns xtrace on (`set -x`, `set -ex`, `bash -x`, `sh -xc`): each command is printed with its variables
|
|
@@ -2634,8 +2649,11 @@ const XTRACE_FLAG = /^-[a-z]{0,8}x[a-z]{0,8}$/;
|
|
|
2634
2649
|
const HERE_INPUT = /<</;
|
|
2635
2650
|
/** export's or declare's flag that prints (`-p`, `-px`). */
|
|
2636
2651
|
const PRINT_FLAG = /^-[A-Za-z]{0,8}p/;
|
|
2637
|
-
/** ps's
|
|
2638
|
-
|
|
2652
|
+
/** ps's option word that adds each process's environment: BSD-style `e` (`ps e`, `ps eww`, `ps auxe`), or `E` with or
|
|
2653
|
+
* without a dash (`ps auxE`, `ps -E`, `ps -wwE`). procps' `-e` (every process) is no such option. */
|
|
2654
|
+
const PS_ENV_OPTION = /^(?:[a-z]{0,16}e[a-z]{0,16}|-?[A-Za-z]{0,16}E[A-Za-z]{0,16})$/;
|
|
2655
|
+
/** heroku's config command and its subcommands (`heroku config`, `heroku config:get NAME`): a host's config vars. */
|
|
2656
|
+
const HEROKU_CONFIG = /^config(?::|$)/i;
|
|
2639
2657
|
/** Commands that print their arguments: with a variable anywhere in the line, its value is read as printed. */
|
|
2640
2658
|
const PRINT_WORDS = new Set(["echo", "printf", "print", "puts", "say", "write-output", "write-host"]);
|
|
2641
2659
|
/** Builtins that print every variable given no name to set: with flags alone, or a printing flag. */
|
|
@@ -2660,14 +2678,17 @@ function argsAfter(words, at) {
|
|
|
2660
2678
|
}
|
|
2661
2679
|
/** Whether a command of a line, quotes dropped, prints the environment by its builtins' arguments: set with nothing
|
|
2662
2680
|
* after it, or set or a shell with an xtrace flag; export, declare, typeset or readonly with flags alone or a printing
|
|
2663
|
-
* flag; ps with an `e` option. */
|
|
2681
|
+
* flag; ps with an `e` or `E` option; heroku's config. */
|
|
2664
2682
|
function pieceDumps(piece) {
|
|
2665
2683
|
const words = piece.split(COMMAND_BLANKS).filter(Boolean);
|
|
2666
2684
|
return words.some((word, at) => {
|
|
2667
2685
|
const name = wordName(word);
|
|
2668
|
-
if (!XTRACE_WORDS.has(name) && !DECLARE_WORDS.has(name) && name !== "ps")
|
|
2686
|
+
if (!XTRACE_WORDS.has(name) && !DECLARE_WORDS.has(name) && name !== "ps" && name !== "heroku")
|
|
2669
2687
|
return false;
|
|
2670
2688
|
const args = argsAfter(words, at);
|
|
2689
|
+
// A redirect attached to the argument (`config>/tmp/x`) is no part of it, as wordName reads a command's name.
|
|
2690
|
+
if (name === "heroku")
|
|
2691
|
+
return args.some((arg) => HEROKU_CONFIG.test(arg.split(WORD_REDIRECT)[0]));
|
|
2671
2692
|
if (XTRACE_WORDS.has(name) && args.some((arg) => XTRACE_FLAG.test(arg.toLowerCase())))
|
|
2672
2693
|
return true;
|
|
2673
2694
|
if (name === "set")
|
|
@@ -2688,13 +2709,16 @@ function pieceDumps(piece) {
|
|
|
2688
2709
|
function printsEnvironment(command) {
|
|
2689
2710
|
if (command.length > COMMAND_MAX)
|
|
2690
2711
|
return true;
|
|
2691
|
-
|
|
2692
|
-
|
|
2712
|
+
// Read twice: with a member access across a line break joined (`process\n .env` is `process.env`), and as written,
|
|
2713
|
+
// where that break still ends a command (`readonly\n.venv/bin/python`: readonly alone prints, joined it read as python).
|
|
2714
|
+
const unquoted = command.replace(COMMAND_QUOTES, "");
|
|
2715
|
+
const lines = [unquoted.replace(MEMBER_BREAK, "").replace(DOT_ENV_FILE, "$1"), unquoted.replace(DOT_ENV_FILE, "$1")];
|
|
2716
|
+
const tokens = lines.flatMap((line) => line.toLowerCase().split(ENV_TOKEN_BREAK));
|
|
2693
2717
|
if (tokens.some((token) => ENV_WORD.test(token)))
|
|
2694
2718
|
return true;
|
|
2695
2719
|
if (VARIABLE_WORD.test(command) && (HERE_INPUT.test(command) || tokens.some((token) => PRINT_WORDS.has(token))))
|
|
2696
2720
|
return true;
|
|
2697
|
-
return line.split(COMMAND_SPLIT).some(pieceDumps);
|
|
2721
|
+
return lines.some((line) => line.split(COMMAND_SPLIT).some(pieceDumps));
|
|
2698
2722
|
}
|
|
2699
2723
|
/** 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
|
|
2700
2724
|
* 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
|
|
@@ -2706,10 +2730,38 @@ function wholeDump(text) {
|
|
|
2706
2730
|
const start = text.length - text.trimStart().length;
|
|
2707
2731
|
return end > start ? [{ start, end }] : [];
|
|
2708
2732
|
}
|
|
2733
|
+
/** A prompt inside a line flattened from many (a run's title): one PROMPT_HEAD opens, after a blank or at the start. */
|
|
2734
|
+
const FLAT_PROMPT = /(?<=^|\s)(?:\([^()\n]{1,64}\)[ \t]{1,3})?(?:[$%❯]|(?:[A-Za-z0-9_.-]{1,64}@[A-Za-z0-9_.-]{1,128}:[^\s]{0,256}|\[[^\]@\n]{1,64}@[^\]\n]{1,192}\])[$#])[ \t]{1,3}(?=\S)/g;
|
|
2735
|
+
const FLAT_WORD = /\S{1,4096}/g;
|
|
2736
|
+
/** The most words a flattened command is read for before its output's first NAME=value. */
|
|
2737
|
+
const FLAT_COMMAND_WORDS = 16;
|
|
2738
|
+
/** A transcript flattened onto one line (11-26: a run's title is its first message with every run of blanks one
|
|
2739
|
+
* space, so `$ printenv\nAPP_SEED=v\n...` reads `$ printenv APP_SEED=v ...`): after each prompt, the fewest words that
|
|
2740
|
+
* print the environment (printsEnvironment) followed by a NAME=value word (ENV_LINE) are the command, and from that word
|
|
2741
|
+
* to the next prompt or the text's end is its output, cut. Where a flattened command ends can't be told from its
|
|
2742
|
+
* output's first word, so `$ env NAME=value command` is cut there too: an over-cut, fails closed, and only for a text
|
|
2743
|
+
* its caller says was flattened. */
|
|
2744
|
+
function flatDumps(text) {
|
|
2745
|
+
const prompts = [...text.matchAll(FLAT_PROMPT)];
|
|
2746
|
+
const out = [];
|
|
2747
|
+
for (const [at, prompt] of prompts.entries()) {
|
|
2748
|
+
const from = prompt.index + prompt[0].length;
|
|
2749
|
+
const segment = text.slice(from, at + 1 < prompts.length ? prompts[at + 1].index : text.length).trimEnd();
|
|
2750
|
+
const words = [...segment.matchAll(FLAT_WORD)];
|
|
2751
|
+
for (let next = 1; next < words.length && next <= FLAT_COMMAND_WORDS; next++) {
|
|
2752
|
+
const head = words[next].index;
|
|
2753
|
+
if (!ENV_LINE.test(segment.slice(head)) || !printsEnvironment(segment.slice(0, head).trimEnd()))
|
|
2754
|
+
continue;
|
|
2755
|
+
out.push({ start: from + head, end: from + segment.length });
|
|
2756
|
+
break;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
return out;
|
|
2760
|
+
}
|
|
2709
2761
|
/** A command's output, given apart from its command (ruling LVI): all of it is a dump when the command prints the
|
|
2710
2762
|
* environment or a variable's value, alone on its line or among others. An approval outcome's head line is cut with
|
|
2711
2763
|
* it (ruled so: never split on run-view's words). */
|
|
2712
|
-
const commandDumps = (text, given) => (given !== undefined &&
|
|
2764
|
+
const commandDumps = (text, given) => (given !== undefined && factsOf(given).dumps ? wholeDump(text) : []);
|
|
2713
2765
|
const PATH_SEPARATOR = /[\\/]/;
|
|
2714
2766
|
const ENV_FILE_NAME = /^(?:\.env(?:rc)?|\.env\.[A-Za-z0-9_.-]{1,64}|[A-Za-z0-9_.-]{1,64}\.env)$/;
|
|
2715
2767
|
const ENV_TEMPLATE = /\.(?:example|sample|template|tmpl|dist|defaults?|schema)$/i;
|
|
@@ -2755,12 +2807,24 @@ const COMMAND_WORD_SPLIT = /[\s|;&<>()]{1,64}/;
|
|
|
2755
2807
|
const OPTION_NAME = /^-{1,2}[A-Za-z0-9-]{1,64}=/;
|
|
2756
2808
|
const WORD_QUOTES = /["']/g;
|
|
2757
2809
|
const COMMAND_MAX = 65_536;
|
|
2758
|
-
|
|
2810
|
+
/** Whether a command names, anywhere in its words, a path `fits` takes: asked once a command and predicate (factsOf),
|
|
2811
|
+
* so a call's output read string by string never walks its command's words again. `fits` is a module-level function. */
|
|
2812
|
+
function commandNames(command, fits) {
|
|
2813
|
+
if (command === undefined)
|
|
2814
|
+
return false;
|
|
2815
|
+
const { paths, names } = factsOf(command);
|
|
2816
|
+
let named = names.get(fits);
|
|
2817
|
+
if (named === undefined)
|
|
2818
|
+
names.set(fits, (named = paths.some(fits)));
|
|
2819
|
+
return named;
|
|
2820
|
+
}
|
|
2821
|
+
const dockerConfigPath = (path) => DOCKER_CONFIG.test(path);
|
|
2822
|
+
const pathWords = (command) => command.slice(0, COMMAND_MAX).split(COMMAND_WORD_SPLIT).map((word) => word.replace(OPTION_NAME, "").replace(WORD_QUOTES, "")).filter(Boolean);
|
|
2759
2823
|
/** The text whole, its trailing blanks left out, when the caller says it is the content of a file `fits` names: the call
|
|
2760
2824
|
* read that file (`ctx.path`), or its command names one anywhere (ruling LXII d: `grep app ~/.pgpass`, `jq . ~/.docker/
|
|
2761
2825
|
* config.json`, `grep -v ^# .env`; an over-cut, `ls ~/.ssh/known_hosts`'s, fails closed). */
|
|
2762
2826
|
const wholeText = (text, ctx, fits) => {
|
|
2763
|
-
if (!((ctx.path !== undefined && fits(ctx.path)) ||
|
|
2827
|
+
if (!((ctx.path !== undefined && fits(ctx.path)) || commandNames(ctx.command, fits)) || DUMP_MARKER_LINE.test(text))
|
|
2764
2828
|
return [];
|
|
2765
2829
|
const end = text.trimEnd().length;
|
|
2766
2830
|
return end > 0 ? [{ start: 0, end }] : [];
|
|
@@ -2950,7 +3014,7 @@ export const SCRUB_RULES = Object.freeze([
|
|
|
2950
3014
|
rule("base64-pem", "format", (text, ctx) => base64Pems(nestedBlanked(text, ctx?.source), linesOfContext(text, ctx))),
|
|
2951
3015
|
SECRETLINT,
|
|
2952
3016
|
HELD,
|
|
2953
|
-
rule("env-dump", "dump", (text, ctx) => [...envDumps(text), ...commandDumps(text, ctx.command)]),
|
|
3017
|
+
rule("env-dump", "dump", (text, ctx) => [...envDumps(text), ...commandDumps(text, ctx.command), ...(ctx.flattened ? flatDumps(text) : [])]),
|
|
2954
3018
|
rule("env-file", "dump", (text, ctx) => [...wholeText(text, ctx, envFilePath), ...fileReads(text, envFilePath, (body) => ENV_FILE_LINE.test(body))]),
|
|
2955
3019
|
rule("credential-file", "dump", (text, ctx) => [...wholeText(text, ctx, credentialFilePath), ...fileReads(text, credentialFilePath, (body) => notPrompt(body) && notMarker(body))]),
|
|
2956
3020
|
// A key file read (authorized_keys, known_hosts, a key) or a config read is a dump; key lines printed with no read
|
|
@@ -2998,7 +3062,7 @@ export const RULE_PATTERNS = Object.freeze({
|
|
|
2998
3062
|
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,
|
|
2999
3063
|
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,
|
|
3000
3064
|
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,
|
|
3001
|
-
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,
|
|
3065
|
+
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, MEMBER_BREAK, ENV_WORD, VARIABLE_WORD, XTRACE_FLAG, HERE_INPUT, PRINT_FLAG, PS_ENV_OPTION, HEROKU_CONFIG, PROMPT_HEAD, FLAT_PROMPT, FLAT_WORD, NAME_RUN, READ_COMMAND, READ_TOOL, PATH_SEPARATOR, ENV_FILE_NAME, ENV_TEMPLATE, SSH_FILE,
|
|
3002
3066
|
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,
|
|
3003
3067
|
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,
|
|
3004
3068
|
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
|
@@ -99,6 +99,11 @@ export type ServeOptions = {
|
|
|
99
99
|
* (the console, sign-in, setup, settings, MCP, triggers, hooks, ...) with a 404 before anything reads the request.
|
|
100
100
|
* It has no owner: accounts and open setup are off, there being no page to sign in to. */
|
|
101
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;
|
|
102
107
|
/** AGENTRUN_API_ONLY_MCP_ORIGINS, read as the environment's is (the serve README's API-only section); only with apiOnly. */
|
|
103
108
|
apiOnlyMcpOrigins?: readonly string[];
|
|
104
109
|
/** The launch hook (AGENTRUN_LAUNCH_HOOK_URL and _SECRET, trigger-launch-hook.ts): each trigger firing that would start
|
|
@@ -197,6 +202,9 @@ export type ServeOptions = {
|
|
|
197
202
|
console?: string;
|
|
198
203
|
/** How long a run's process may finish its turn after SIGTERM (default 30s): `8s`, `500ms`, `1m`. */
|
|
199
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;
|
|
200
208
|
/** How often the runs' listings' builder looks again when it found nothing to build (run-listing.ts; default
|
|
201
209
|
* LISTER_IDLE_MS). `Infinity`: it builds only when Serve.listingSettled asks, so a test reads what a list builds alone. */
|
|
202
210
|
listerIdleMs?: number;
|
|
@@ -261,7 +269,8 @@ export type ServeOptions = {
|
|
|
261
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
|
|
262
270
|
* the run's state changes under it (runs-over-store.ts message). */
|
|
263
271
|
beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
|
|
264
|
-
/** 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. */
|
|
265
274
|
shareScrub?: CutScrub;
|
|
266
275
|
/** A test's seam: step 2 of DELETE /agents/{id} (agent-delete.ts) in place of the learning module's deleteLearning over
|
|
267
276
|
* the agent's learning (learn/delete.ts), the server's own. */
|