@plurnk/plurnk-execs 0.4.25 → 0.4.28
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/README.md +3 -3
- package/SPEC.md +7 -4
- package/dist/BaseExecutor.d.ts +1 -1
- package/dist/BaseExecutor.d.ts.map +1 -1
- package/dist/BaseExecutor.js +10 -2
- package/dist/BaseExecutor.js.map +1 -1
- package/dist/SubprocessExecutor.d.ts +3 -3
- package/dist/SubprocessExecutor.d.ts.map +1 -1
- package/dist/SubprocessExecutor.js +22 -16
- package/dist/SubprocessExecutor.js.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +15 -7
- package/dist/runtime.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,16 +35,16 @@ One package may claim many tags (the search sibling claims `search`/`news`/`imag
|
|
|
35
35
|
|
|
36
36
|
The framework instantiates **one executor per tag**, injecting `{ runtime, glyph }` (`ExecutorMetadata`) — branch on `this.runtime` when one class backs several tags. Two ways in:
|
|
37
37
|
|
|
38
|
-
- **Subprocess runtimes** (the common case): subclass **`SubprocessExecutor`** and override one hook — `spawnArgs(runtime, command) → { cmd, args, useShell, stdin? }`. You inherit stdout/stderr streaming, process-group abort, **env scoping**, and exit-code reporting. Override the `binary` getter so `probe()` checks it's on PATH (`null` = always available).
|
|
38
|
+
- **Subprocess runtimes** (the common case): subclass **`SubprocessExecutor`** and override one hook — `spawnArgs(runtime, command, target) → { cmd, args, useShell, stdin? }`. With no `target`, `command` is the inline program; with a `target`, run it as the program and hand `command` to `stdin` (plurnk-execs#15). You inherit stdout/stderr streaming, process-group abort, **env scoping**, and exit-code reporting. Override the `binary` getter so `probe()` checks it's on PATH (`null` = always available).
|
|
39
39
|
- **Logical / in-process runtimes** (sqlite, search, wasm, jq): subclass **`BaseExecutor`** directly and implement:
|
|
40
40
|
- `get channels()` — the output channels you write, each `{ mimetype, defaultState? }`.
|
|
41
41
|
- `run(args) → ExecResult` — do the work, resolve `{ status }`. Never throw for an expected failure — `emit` telemetry and set the channel to `errored` instead.
|
|
42
|
-
- `probe()` *(optional)* — `{ available, detail? }`; defaults to available. Override when you depend on an external binary or config (the `detail` is model-facing on a 501).
|
|
42
|
+
- `probe(signal?)` *(optional)* — `{ available, detail? }`; defaults to available. Override when you depend on an external binary or config (the `detail` is model-facing on a 501). If you spawn a child (or open a connection) to check, hand it `signal` so a resolved/timed-out probe reaps it — no stray write EPIPEs after teardown (plurnk-execs#16).
|
|
43
43
|
- `effect(target)` *(optional)* — `"pure" | "read" | "host"`; the consumer maps it to its proposal policy (host → propose, read/pure → auto-run inline). Classify the **target only**, never the command. Defaults to `host` (the safe end).
|
|
44
44
|
|
|
45
45
|
### 3. What `run` receives (`ExecArgs`) — sinks, never the substrate
|
|
46
46
|
|
|
47
|
-
`{ runtime, command, cwd, env, signal, write(channel, chunk), setState(channel, state), emit(event) }`. The executor gets sinks and honors `signal` — never the db, subscriptions, or wake machinery (those stay in the consumer).
|
|
47
|
+
`{ runtime, command, cwd, target, env, signal, write(channel, chunk, mimetype?), setState(channel, state), emit(event) }`. The executor gets sinks and honors `signal` — never the db, subscriptions, or wake machinery (those stay in the consumer). **`cwd`** is the session workspace (the process working directory); **`target`** is the parsed EXEC `(target)` slot — a referenced resource you interpret **per your tool's CLI**: a *data* runtime reads it as input with `command` as the program (jq `(file):filter`, sqlite `(db):SQL`); an *executable* runtime runs it as the program with `command` as its **stdin** (sh `(cmdline):stdin`, python `(script):stdin`). Resolved relative to `cwd`, `null` when the op names none (plurnk-execs#15). `write`'s optional `mimetype` stamps the channel with the real per-call output type. **`env`**, when the consumer scopes it, is exactly the environment a spawned child should see (the host's own secrets already dropped — never inherit `process.env` for model-run children yourself). Stay stateless across runs beyond your construction metadata.
|
|
48
48
|
|
|
49
49
|
### How the model sees your tag
|
|
50
50
|
|
package/SPEC.md
CHANGED
|
@@ -30,7 +30,8 @@ type ChannelState = "active" | "closed" | "errored";
|
|
|
30
30
|
interface ExecArgs {
|
|
31
31
|
runtime: string; // matched tag; multi-tag executors branch on it
|
|
32
32
|
command: string; // EXEC body: shell line / source / search query
|
|
33
|
-
cwd: string | null; //
|
|
33
|
+
cwd: string | null; // process working dir (session workspace); null for logical runtimes
|
|
34
|
+
target: string | null; // parsed EXEC (target) slot, interpreted per-runtime (data: input+body=program / executable: program+body=stdin); resolved vs cwd; null if none
|
|
34
35
|
signal: AbortSignal; // cancellation — executors must honor it
|
|
35
36
|
write: (channel: string, chunk: string) => void; // write a chunk to a declared channel
|
|
36
37
|
setState: (channel: string, state: ChannelState) => void; // drive a declared channel's lifecycle
|
|
@@ -55,13 +56,13 @@ The executor declares its channels; the consuming scheme seeds the exec entry fr
|
|
|
55
56
|
interface RuntimeAvailability { available: boolean; detail?: string; }
|
|
56
57
|
|
|
57
58
|
abstract class BaseExecutor {
|
|
58
|
-
async probe(): Promise<RuntimeAvailability> { return { available: true }; } // default: available
|
|
59
|
+
async probe(signal?: AbortSignal): Promise<RuntimeAvailability> { return { available: true }; } // default: available
|
|
59
60
|
}
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
`probe()` reports whether the runtime's *environment* is usable here — distinct from whether the *package* is installed (`discover()`). Pure / in-process runtimes (node, sqlite) inherit the available default; runtimes depending on an external binary (`python` → `python3 --version`) or config (`search` → `SEARXNG_URL`) override. `SubprocessExecutor` probes its `binary` getter (`null` = always available).
|
|
63
64
|
|
|
64
|
-
Consumer contract (plurnk-service#181): probe **once at boot, per package** (not per tag — stamp all of a package's tags with the one result), **concurrently under a per-probe timeout**, and **cache**. `probe()` MAY reject; the consumer treats rejection as `{ available: false, detail: <error> }`, so a buggy probe degrades only its runtime. The model is offered a positive list of available runtimes; an attempt at an unavailable one returns **501 carrying `detail`** (so `detail` is model-facing — terse and actionable). A configured default runtime that probes unavailable is a **fail-hard boot error**.
|
|
65
|
+
Consumer contract (plurnk-service#181): probe **once at boot, per package** (not per tag — stamp all of a package's tags with the one result), **concurrently under a per-probe timeout**, and **cache**. The per-probe deadline/cancellation is delivered as the optional **`signal`** — a probe that spawns a child or opens a connection MUST hand `signal` to it, so a resolved or timed-out probe **reaps** it immediately (else an in-flight `--version` write can `EPIPE` after host teardown, plurnk-execs#16). `signal` is ignore-safe: a probe that spawns nothing needs nothing. `probe()` MAY reject; the consumer treats rejection as `{ available: false, detail: <error> }`, so a buggy probe degrades only its runtime. The model is offered a positive list of available runtimes; an attempt at an unavailable one returns **501 carrying `detail`** (so `detail` is model-facing — terse and actionable). A configured default runtime that probes unavailable is a **fail-hard boot error**.
|
|
65
66
|
|
|
66
67
|
### §2.3 Effect (proposal gating)
|
|
67
68
|
|
|
@@ -196,7 +197,7 @@ Execs owns none of the overlay machinery — the live Active/Available state, th
|
|
|
196
197
|
`resolveRuntime(runtime, command) → SpawnArgs` and `isKnownRuntime(runtime)` / `KNOWN_RUNTIMES` translate a subprocess runtime tag into `node:child_process.spawn` arguments:
|
|
197
198
|
|
|
198
199
|
```ts
|
|
199
|
-
interface SpawnArgs { cmd: string; args: string[]; useShell: boolean; }
|
|
200
|
+
interface SpawnArgs { cmd: string; args: string[]; useShell: boolean; stdin?: string; }
|
|
200
201
|
```
|
|
201
202
|
|
|
202
203
|
| Runtime | Spawn |
|
|
@@ -208,6 +209,8 @@ interface SpawnArgs { cmd: string; args: string[]; useShell: boolean; }
|
|
|
208
209
|
|
|
209
210
|
`resolveRuntime` never throws; consumers gate unknown runtimes with `isKnownRuntime` and return 501 before invoking.
|
|
210
211
|
|
|
212
|
+
**With a `(target)`** — `resolveRuntime(runtime, command, target)` runs the **target as the program** and the **body as its stdin** (plurnk-execs#15): a shell runs `sh -c "<target>"` (the shell tokenizes the target — the framework parses nothing), any other runtime runs `<interpreter> <target>` (a single script-file positional). No target → the body is the inline program (`-c`/`-e`) as in the table. This is family-relative: the *data* runtimes (jq/sqlite/wasm) invert it — `target` is the data, `body` the program — inside their own `run()`. Each daughter maps the two raw strings to its own tool's CLI; the parent hands them down and parses neither.
|
|
213
|
+
|
|
211
214
|
The framework wraps this in **`SubprocessExecutor extends BaseExecutor`** — declares `{ stdout, stderr }` channels and implements `run()` (spawn via `resolveRuntime`, stream into the channels, honor `signal`, `emit` `spawn_failed` on a failed start, return `{ status, exitCode }`). Subclasses with their own interpreter table override the **`protected spawnArgs(runtime, command) → SpawnArgs`** hook (default delegates to `resolveRuntime`) — and so inherit run()'s streaming + process-group abort handling. `SpawnArgs.stdin?` lets filter-style runtimes feed their program/input via stdin (`bc`, `tclsh`; or `""` for an `awk` BEGIN with EOF). On abort it signals the whole **process group** (`detached` spawn + `process.kill(-pid, …)`) so shell grandchildren can't leak (plurnk-execs#4): the default abort is a polite **SIGHUP**, once, no escalation; a `KILL[code]` reason carrying `{ signal }` delivers exactly that signal, fire-and-forget; only the consumer's loop-end housekeeping reason (`{ housekeeping: true, graceMs }`) escalates SIGHUP→**SIGKILL** after the consumer-sourced grace (never a magic number here). The `plurnk-execs-common` sibling subclasses it — claiming the whole subprocess set (sh/bash/node/python plus detected host interpreters) via a recipe table behind a `spawnArgs()` / `probe()` override. `isKnownRuntime` / `KNOWN_RUNTIMES` are the legacy 501 gate; the discovery registry + `probe()` supersede them once a consumer wires the registry.
|
|
212
215
|
|
|
213
216
|
## §5 Consumer surface (plurnk-service)
|
package/dist/BaseExecutor.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default abstract class BaseExecutor implements SchemeHandler {
|
|
|
8
8
|
get defaultChannel(): string;
|
|
9
9
|
abstract get channels(): Readonly<Record<string, ChannelDecl>>;
|
|
10
10
|
abstract run(args: ExecArgs): Promise<ExecResult>;
|
|
11
|
-
probe(): Promise<RuntimeAvailability>;
|
|
11
|
+
probe(_signal?: AbortSignal): Promise<RuntimeAvailability>;
|
|
12
12
|
effect(_target: string | null): Effect;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=BaseExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseExecutor.d.ts","sourceRoot":"","sources":["../src/BaseExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAWnH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,YAAa,YAAW,aAAa;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,gBAAgB;IAehD,IAAI,QAAQ,IAAI,cAAc,CAS7B;IAID,IAAI,cAAc,IAAI,MAAM,CAE3B;IAOD,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAO/D,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseExecutor.d.ts","sourceRoot":"","sources":["../src/BaseExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAWnH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,YAAa,YAAW,aAAa;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,gBAAgB;IAehD,IAAI,QAAQ,IAAI,cAAc,CAS7B;IAID,IAAI,cAAc,IAAI,MAAM,CAE3B;IAOD,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAO/D,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB3C,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAYhE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM;CAGzC"}
|
package/dist/BaseExecutor.js
CHANGED
|
@@ -48,11 +48,19 @@ export default class BaseExecutor {
|
|
|
48
48
|
// MAY reject — the consumer treats a rejection as `{ available: false }` —
|
|
49
49
|
// but returning a crafted `{ available: false, detail }` for an expected
|
|
50
50
|
// miss gives a better model-facing reason than a raw error.
|
|
51
|
-
|
|
51
|
+
//
|
|
52
|
+
// `signal` carries the consumer's per-probe deadline/cancellation. An
|
|
53
|
+
// override that spawns a child (or opens a connection) MUST hand it to that
|
|
54
|
+
// child so a resolved or timed-out probe REAPS it at once — otherwise an
|
|
55
|
+
// in-flight `--version` write can EPIPE after the host tears down
|
|
56
|
+
// (plurnk-execs#16). Optional and ignore-safe: a probe that spawns nothing
|
|
57
|
+
// needs nothing.
|
|
58
|
+
async probe(_signal) {
|
|
52
59
|
return { available: true };
|
|
53
60
|
}
|
|
54
61
|
// Side-effect class of an invocation against `target` (the parsed EXEC
|
|
55
|
-
// target —
|
|
62
|
+
// `(target)` slot — the same value run() receives as `args.target`), for the
|
|
63
|
+
// consumer's proposal-gating
|
|
56
64
|
// policy (service#182). MUST be pure, synchronous, and cheap — it runs on
|
|
57
65
|
// the dispatch hot path at propose time: classify the target only, NEVER
|
|
58
66
|
// the command (parsing SQL/shell to judge intent is a sandbox-escape
|
package/dist/BaseExecutor.js.map
CHANGED
|
@@ -1 +1 @@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pE,IAAI,cAAc;QACd,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;IAgBD,wEAAwE;IACxE,0EAA0E;IAC1E,wEAAwE;IACxE,iEAAiE;IACjE,EAAE;IACF,0EAA0E;IAC1E,yEAAyE;IACzE,2EAA2E;IAC3E,yEAAyE;IACzE,4DAA4D;IAC5D,EAAE;IACF,sEAAsE;IACtE,4EAA4E;IAC5E,yEAAyE;IACzE,kEAAkE;IAClE,2EAA2E;IAC3E,iBAAiB;IACjB,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC7B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,uEAAuE;IACvE,6EAA6E;IAC7E,6BAA6B;IAC7B,0EAA0E;IAC1E,yEAAyE;IACzE,qEAAqE;IACrE,4EAA4E;IAC5E,iEAAiE;IACjE,MAAM,CAAC,OAAsB;QACzB,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -4,8 +4,8 @@ export default class SubprocessExecutor extends BaseExecutor {
|
|
|
4
4
|
get channels(): Readonly<Record<string, ChannelDecl>>;
|
|
5
5
|
protected get binary(): string | null;
|
|
6
6
|
effect(_target: string | null): Effect;
|
|
7
|
-
probe(): Promise<RuntimeAvailability>;
|
|
8
|
-
protected spawnArgs(runtime: string, command: string): SpawnArgs;
|
|
9
|
-
run({ runtime, command, cwd, env, signal, write, setState, emit }: ExecArgs): Promise<ExecResult>;
|
|
7
|
+
probe(signal?: AbortSignal): Promise<RuntimeAvailability>;
|
|
8
|
+
protected spawnArgs(runtime: string, command: string, target: string | null): SpawnArgs;
|
|
9
|
+
run({ runtime, command, cwd, target, env, signal, write, setState, emit }: ExecArgs): Promise<ExecResult>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=SubprocessExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubprocessExecutor.d.ts","sourceRoot":"","sources":["../src/SubprocessExecutor.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA6B5G,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,YAAY;IACxD,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAKpD;IAKD,SAAS,KAAK,MAAM,IAAI,MAAM,GAAG,IAAI,CAEpC;IAGQ,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM;IAIhC,KAAK,
|
|
1
|
+
{"version":3,"file":"SubprocessExecutor.d.ts","sourceRoot":"","sources":["../src/SubprocessExecutor.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA6B5G,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,YAAY;IACxD,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAKpD;IAKD,SAAS,KAAK,MAAM,IAAI,MAAM,GAAG,IAAI,CAEpC;IAGQ,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM;IAIhC,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA8BxE,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIvF,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CA6E5G"}
|
|
@@ -44,15 +44,17 @@ export default class SubprocessExecutor extends BaseExecutor {
|
|
|
44
44
|
effect(_target) {
|
|
45
45
|
return "host";
|
|
46
46
|
}
|
|
47
|
-
async probe() {
|
|
47
|
+
async probe(signal) {
|
|
48
48
|
const bin = this.binary;
|
|
49
49
|
if (bin === null)
|
|
50
50
|
return { available: true };
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
51
|
+
if (signal?.aborted)
|
|
52
|
+
return { available: false };
|
|
53
|
+
// No internal deadline — the per-probe timeout is the consumer's (SPEC
|
|
54
|
+
// §2.2), handed in as `signal`. We pass it to spawn so a resolved or
|
|
55
|
+
// timed-out probe REAPS its child at once; no in-flight `--version` write
|
|
56
|
+
// can EPIPE after host teardown (plurnk-execs#16). stdin/stderr are
|
|
57
|
+
// /dev/null'd — only stdout is read, for the version detail.
|
|
56
58
|
return new Promise((resolve) => {
|
|
57
59
|
let settled = false;
|
|
58
60
|
const done = (r) => { if (!settled) {
|
|
@@ -60,23 +62,27 @@ export default class SubprocessExecutor extends BaseExecutor {
|
|
|
60
62
|
resolve(r);
|
|
61
63
|
} };
|
|
62
64
|
let out = "";
|
|
63
|
-
const child = spawn(bin, ["--version"]);
|
|
65
|
+
const child = spawn(bin, ["--version"], { signal, stdio: ["ignore", "pipe", "ignore"] });
|
|
64
66
|
child.stdout?.on("data", (chunk) => { out += chunk.toString("utf8"); });
|
|
65
|
-
child.on("error", () => done(
|
|
67
|
+
child.on("error", (err) => done(err.code === "ABORT_ERR"
|
|
68
|
+
? { available: false }
|
|
69
|
+
: { available: false, detail: `${bin} not found on PATH` }));
|
|
66
70
|
child.on("close", (code) => done(code === 0
|
|
67
71
|
? { available: true, detail: out.trim().split("\n")[0] || undefined }
|
|
68
72
|
: { available: false, detail: `${bin} --version exited ${code}` }));
|
|
69
73
|
});
|
|
70
74
|
}
|
|
71
|
-
// Translate the matched tag + command into spawn args. Default
|
|
72
|
-
// Runtime.resolve (sh/node/python); subclasses with their own
|
|
73
|
-
// table (e.g. the common-REPL harness) override this — and so
|
|
74
|
-
// streaming + process-group abort handling rather than
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
// Translate the matched tag + command + target into spawn args. Default
|
|
76
|
+
// delegates to Runtime.resolve (sh/node/python); subclasses with their own
|
|
77
|
+
// interpreter table (e.g. the common-REPL harness) override this — and so
|
|
78
|
+
// inherit run()'s streaming + process-group abort handling rather than
|
|
79
|
+
// reimplementing it. When `target` is set, the body becomes the program's
|
|
80
|
+
// stdin (plurnk-execs#15) — the daughter maps it; the parent parses nothing.
|
|
81
|
+
spawnArgs(runtime, command, target) {
|
|
82
|
+
return Runtime.resolve(runtime, command, target);
|
|
77
83
|
}
|
|
78
|
-
run({ runtime, command, cwd, env, signal, write, setState, emit }) {
|
|
79
|
-
const { cmd, args, useShell, stdin } = this.spawnArgs(runtime, command);
|
|
84
|
+
run({ runtime, command, cwd, target, env, signal, write, setState, emit }) {
|
|
85
|
+
const { cmd, args, useShell, stdin } = this.spawnArgs(runtime, command, target);
|
|
80
86
|
return new Promise((resolve) => {
|
|
81
87
|
// Already cancelled before we start — don't launch a doomed process.
|
|
82
88
|
if (signal.aborted) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubprocessExecutor.js","sourceRoot":"","sources":["../src/SubprocessExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,OAAO,MAAM,cAAc,CAAC;AAGnC,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,MAAM,cAAc,GAAG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AAO,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBAChF,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBACvB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBACjB,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;oBACzD,OAAO;gBACX,CAAC;gBACD,MAAM,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC;gBACtB,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACxF,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import type { SpawnArgs } from "./types.ts";
|
|
|
2
2
|
export default class Runtime {
|
|
3
3
|
static readonly KNOWN: ReadonlySet<string>;
|
|
4
4
|
static isKnown(runtime: string): boolean;
|
|
5
|
-
static resolve(runtime: string, command: string): SpawnArgs;
|
|
5
|
+
static resolve(runtime: string, command: string, target?: string | null): SpawnArgs;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,OAAO;IAGxB,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAEvC;IAEH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIxC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,OAAO;IAGxB,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAEvC;IAEH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIxC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW,GAAG,SAAS;CAmB5F"}
|
package/dist/runtime.js
CHANGED
|
@@ -13,16 +13,24 @@ export default class Runtime {
|
|
|
13
13
|
static isKnown(runtime) {
|
|
14
14
|
return Runtime.KNOWN.has(runtime);
|
|
15
15
|
}
|
|
16
|
-
static resolve(runtime, command) {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
static resolve(runtime, command, target = null) {
|
|
17
|
+
const shell = runtime === "" || runtime === "sh" || runtime === "bash";
|
|
18
|
+
// With a target the program IS the target and the body is its stdin
|
|
19
|
+
// (plurnk-execs#15): a shell runs the target as a command line (`-c`, so
|
|
20
|
+
// the shell tokenizes it — we don't); any other runtime runs it as a
|
|
21
|
+
// single script-file positional. No target → the body is the program,
|
|
22
|
+
// inline (`-c`/`-e`), as before.
|
|
23
|
+
if (target !== null) {
|
|
24
|
+
if (shell)
|
|
25
|
+
return { cmd: runtime || "sh", args: ["-c", target], useShell: false, stdin: command };
|
|
26
|
+
return { cmd: runtime === "python" ? "python3" : runtime, args: [target], useShell: false, stdin: command };
|
|
19
27
|
}
|
|
20
|
-
if (
|
|
28
|
+
if (shell)
|
|
29
|
+
return { cmd: command, args: [], useShell: true };
|
|
30
|
+
if (runtime === "node")
|
|
21
31
|
return { cmd: "node", args: ["-e", command], useShell: false };
|
|
22
|
-
|
|
23
|
-
if (runtime === "python" || runtime === "python3") {
|
|
32
|
+
if (runtime === "python" || runtime === "python3")
|
|
24
33
|
return { cmd: "python3", args: ["-c", command], useShell: false };
|
|
25
|
-
}
|
|
26
34
|
// Unknown runtime: conservative `<runtime> -c <command>` fallback.
|
|
27
35
|
// Schemes should gate this off with `isKnown` and return 501, but the
|
|
28
36
|
// resolver itself stays total.
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,yEAAyE;AACzE,4EAA4E;AAC5E,8EAA8E;AAC9E,0CAA0C;AAI1C,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,0EAA0E;IAC1E,kEAAkE;IAClE,MAAM,CAAU,KAAK,GAAwB,IAAI,GAAG,CAAC;QACjD,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS;KAChD,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,OAAe;QAC1B,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,OAAe
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,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EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACvF,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACrH,mEAAmE;QACnE,sEAAsE;QACtE,+BAA+B;QAC/B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACpE,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface ExecArgs {
|
|
|
12
12
|
runtime: string;
|
|
13
13
|
command: string;
|
|
14
14
|
cwd: string | null;
|
|
15
|
+
target: string | null;
|
|
15
16
|
env?: NodeJS.ProcessEnv;
|
|
16
17
|
signal: AbortSignal;
|
|
17
18
|
write: (channel: string, chunk: string, mimetype?: string) => void;
|
|
@@ -77,5 +78,5 @@ export interface SpawnArgs {
|
|
|
77
78
|
* Consumers check `isKnownRuntime(runtime)` before calling to enforce a 501 boundary
|
|
78
79
|
* on unconfigured runtimes; this function never throws.
|
|
79
80
|
*/
|
|
80
|
-
export type RuntimeResolver = (runtime: string, command: string) => SpawnArgs;
|
|
81
|
+
export type RuntimeResolver = (runtime: string, command: string, target?: string | null) => SpawnArgs;
|
|
81
82
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAM3D,MAAM,WAAW,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ACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-execs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.28",
|
|
4
4
|
"description": "Framework + contract for the @plurnk/plurnk-execs-* runtime executor family.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plurnk",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"prepare": "npm run build"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@plurnk/plurnk-schemes": "
|
|
49
|
+
"@plurnk/plurnk-schemes": "0.32.6"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^26.0.1",
|