@plurnk/plurnk-execs-jq 1.16.5 → 1.18.0
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 +7 -7
- package/dist/Jq.d.ts +3 -2
- package/dist/Jq.d.ts.map +1 -1
- package/dist/Jq.js +24 -6
- package/dist/Jq.js.map +1 -1
- package/docs/jq.md +27 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @plurnk/plurnk-execs-jq
|
|
2
2
|
|
|
3
|
-
`jq` runtime executor for [plurnk-service](https://github.com/plurnk/plurnk-service)'s `exec` scheme. Drives
|
|
3
|
+
`jq` runtime executor for [plurnk-service](https://github.com/plurnk/plurnk-service)'s `exec` scheme. Drives `jq` by shelling the system `jq` binary to filter/transform JSON — no third-party JSON-filter library.
|
|
4
4
|
|
|
5
5
|
A `@plurnk/plurnk-execs-*` sibling built on the [plurnk-execs](https://github.com/plurnk/plurnk-service/tree/main/plurnk-execs) framework.
|
|
6
6
|
|
|
@@ -12,11 +12,11 @@ is self-contained.
|
|
|
12
12
|
|
|
13
13
|
| Heading / body | Runs | Purpose |
|
|
14
14
|
| --------------------------------------------------------------------- | --------------------------------- | ---------------------------------- |
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
15
|
+
| `jq`<br>`{"a":1}` | `jq -n '{"a":1}'` | Construct or validate inline JSON. |
|
|
16
|
+
| `jq`<br>`[1,2,3] \| add` | `jq -n '[1,2,3] \| add'` | Compute without input. |
|
|
17
|
+
| `jq (data.json)`<br>`.users[].name` | `jq '.users[].name' data.json` | Filter a file. |
|
|
18
|
+
| `jq (data.json)` | `jq '.' data.json` | Apply identity to a file. |
|
|
19
|
+
| `jq (sqlite:///1/2/3/sqlite#results)`<br>`.[] \| .name` | Consumer materializes the target. | Filter a prior runtime's output. |
|
|
20
20
|
|
|
21
21
|
Output streams to `#results` as `application/jsonl`: one compact JSON value per
|
|
22
22
|
line ({§executor-output-address}).
|
|
@@ -25,7 +25,7 @@ line ({§executor-output-address}).
|
|
|
25
25
|
|
|
26
26
|
- **`effect`** — inline/`-n` is `pure`; a target data source is `read`. Both
|
|
27
27
|
bypass the human proposal gate, then stream on the same next-turn path as
|
|
28
|
-
every
|
|
28
|
+
every execution ({§executor-effect}).
|
|
29
29
|
- **`probe`** — `jq` on PATH (`jq --version`).
|
|
30
30
|
- **Errors** return RFC 9457 Problems (`jq-error`, `spawn-failed`) in the
|
|
31
31
|
terminal operation result.
|
package/dist/Jq.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BaseExecutor } from "@plurnk/plurnk-execs";
|
|
2
|
-
import type { ChannelDecl, Effect, ExecArgs, ExecResult, RuntimeAvailability } from "@plurnk/plurnk-execs";
|
|
2
|
+
import type { ChannelDecl, Effect, ExecArgs, ExecInput, ExecResult, RuntimeAvailability } from "@plurnk/plurnk-execs";
|
|
3
3
|
export default class Jq extends BaseExecutor {
|
|
4
4
|
get channels(): Readonly<Record<string, ChannelDecl>>;
|
|
5
5
|
effect(target: string | null): Effect;
|
|
6
6
|
probe(signal?: AbortSignal): Promise<RuntimeAvailability>;
|
|
7
|
-
|
|
7
|
+
prepare(input: ExecInput): Promise<import("@plurnk/plurnk-execs").ExecPreparation>;
|
|
8
|
+
run({ runtime, body, metadata, cwd, target, env, signal, write, setState, registerInput }: ExecArgs): Promise<ExecResult>;
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=Jq.d.ts.map
|
package/dist/Jq.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jq.d.ts","sourceRoot":"","sources":["../src/Jq.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"Jq.d.ts","sourceRoot":"","sources":["../src/Jq.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA6D,MAAM,sBAAsB,CAAC;AAC/G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAgBtH,MAAM,CAAC,OAAO,OAAO,EAAG,SAAQ,YAAY;IAKxC,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAEpD;IAGQ,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE7C;IAEc,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAevE;IAEQ,OAAO,CAAC,KAAK,EAAE,SAAS,2DAAgE;IAE3F,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAuG9H;CACJ"}
|
package/dist/Jq.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { BaseExecutor, ErrorDetail, Results } from "@plurnk/plurnk-execs";
|
|
2
|
+
import { BaseExecutor, ErrorDetail, InvocationMetadata, Results, SubprocessInput } from "@plurnk/plurnk-execs";
|
|
3
3
|
// jq executor — shells the system `jq` binary (no third-party JSON-filter lib).
|
|
4
4
|
// Invocation model:
|
|
5
5
|
// body = the jq program (defaults to `.` identity if empty)
|
|
6
6
|
// target = optional data source; present → jq reads that file; absent → `-n`
|
|
7
7
|
// (null input) so the body is self-contained.
|
|
8
|
-
//
|
|
9
|
-
//
|
|
8
|
+
// A jq fence with target data.json filters that file with its body, while a
|
|
9
|
+
// targetless jq fence runs its body against null input. A tag-addressed prior stream can be the target
|
|
10
10
|
// once the consumer resolves it to a path ({§executor-output-address}).
|
|
11
11
|
//
|
|
12
12
|
// jq is a leaf process (no shell, no grandchildren), so a plain signal-based
|
|
@@ -43,7 +43,18 @@ export default class Jq extends BaseExecutor {
|
|
|
43
43
|
: { available: false, detail: `jq --version exited ${code}` }));
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
prepare(input) { return InvocationMetadata.prepare(input, { stdin: true }); }
|
|
47
|
+
async run({ runtime, body, metadata, cwd, target, env, signal, write, setState, registerInput }) {
|
|
48
|
+
const parsed = InvocationMetadata.parse({ runtime, body, metadata, cwd, target }, { stdin: true });
|
|
49
|
+
if ("failure" in parsed) {
|
|
50
|
+
setState("results", "errored");
|
|
51
|
+
return parsed.failure;
|
|
52
|
+
}
|
|
53
|
+
const interactive = parsed.options.stdin === "open";
|
|
54
|
+
if (interactive && registerInput === undefined) {
|
|
55
|
+
setState("results", "errored");
|
|
56
|
+
return Results.failure("executor:input", "input-unsupported", 501, "This executor consumer does not provide live input.", {}, { retryable: false });
|
|
57
|
+
}
|
|
47
58
|
const detailLimit = ErrorDetail.configuredLimit();
|
|
48
59
|
if (detailLimit === null) {
|
|
49
60
|
setState("results", "errored");
|
|
@@ -55,7 +66,9 @@ export default class Jq extends BaseExecutor {
|
|
|
55
66
|
// ({§executor-sinks}).
|
|
56
67
|
// -c keeps each value compact on its own line so multi-value output is
|
|
57
68
|
// honest JSONL.
|
|
58
|
-
const args =
|
|
69
|
+
const args = interactive
|
|
70
|
+
? ["-c", "--unbuffered", program, ...(target === null ? [] : [target, "-"])]
|
|
71
|
+
: target !== null ? ["-c", program, target] : ["-c", "-n", program];
|
|
59
72
|
return new Promise((resolve) => {
|
|
60
73
|
let settled = false;
|
|
61
74
|
const finish = (result, state) => {
|
|
@@ -68,7 +81,12 @@ export default class Jq extends BaseExecutor {
|
|
|
68
81
|
let err = "";
|
|
69
82
|
// jq can read the environment (`env`, `$ENV`), so honor the
|
|
70
83
|
// consumer's scoped env when provided ({§exec-env-scoped}).
|
|
71
|
-
const child = spawn("jq", args, { signal, cwd: cwd ?? undefined, env: env ?? process.env
|
|
84
|
+
const child = spawn("jq", args, { signal, cwd: cwd ?? undefined, env: env ?? process.env,
|
|
85
|
+
stdio: [interactive ? "pipe" : "ignore", "pipe", "pipe"] });
|
|
86
|
+
if (interactive && child.stdin) {
|
|
87
|
+
const input = new SubprocessInput(child.stdin, signal);
|
|
88
|
+
registerInput((message) => input.receive(message));
|
|
89
|
+
}
|
|
72
90
|
child.stdout?.on("data", (c) => write("results", c.toString("utf8")));
|
|
73
91
|
child.stderr?.on("data", (c) => { err += c.toString("utf8"); });
|
|
74
92
|
child.on("error", (e) => {
|
package/dist/Jq.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jq.js","sourceRoot":"","sources":["../src/Jq.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Jq.js","sourceRoot":"","sources":["../src/Jq.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG/G,gFAAgF;AAChF,oBAAoB;AACpB,8DAA8D;AAC9D,+EAA+E;AAC/E,yDAAyD;AACzD,4EAA4E;AAC5E,uGAAuG;AACvG,wEAAwE;AACxE,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,uEAAuE;AACvE,wBAAwB;AACxB,MAAM,CAAC,OAAO,OAAO,EAAG,SAAQ,YAAY;IACxC,4EAA4E;IAC5E,2EAA2E;IAC3E,8EAA8E;IAC9E,+BAA+B;IAC/B,IAAI,QAAQ;QACR,OAAO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AAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBACvB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBACjB,MAAM,CAAC,OAAO,CAAC,OAAO,CAClB,aAAa,EACb,WAAW,EACX,GAAG,EACH,6BAA6B,EAC7B,EAAE,EACF;wBACI,KAAK,EAAE,WAAW;wBAClB,SAAS,EAAE,KAAK;qBACnB,CACJ,EAAE,SAAS,CAAC,CAAC;oBACd,OAAO;gBACX,CAAC;gBACD,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;oBAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;oBAAC,OAAO;gBAAC,CAAC;gBAC9D,MAAM,CAAC,OAAO,CAAC,OAAO,CAClB,aAAa,EACb,UAAU,EACV,GAAG,EACH,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;oBACb,CAAC,CAAC,uBAAuB,IAAI,IAAI,CAAC,CAAC,GAAG;oBACtC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,WAAW,CAAC,EAClD,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,EACxB;oBACI,KAAK,EAAE,WAAW;oBAClB,QAAQ,EAAE,sCAAsC;oBAChD,SAAS,EAAE,KAAK;iBACnB,CACJ,EAAE,SAAS,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
package/docs/jq.md
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
The system `jq` as a runtime: the **body is the jq program**, the **`(target)` is the data source**.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
### EXEC0 (jq)
|
|
5
|
+
````jq
|
|
7
6
|
[1,2,3] | add
|
|
7
|
+
````
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
````jq (data.json)
|
|
10
10
|
.users[].name
|
|
11
|
+
````
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
.[] | .
|
|
14
|
-
|
|
13
|
+
````jq (sqlite:///ab3d5678#results)
|
|
14
|
+
.[] | .name
|
|
15
|
+
````
|
|
15
16
|
|
|
16
17
|
The first form has no input and uses `-n`. The second filters a file. The third
|
|
17
|
-
filters the result stream at the emitted
|
|
18
|
+
filters the result stream at the emitted SQLite address.
|
|
18
19
|
|
|
19
20
|
An empty body defaults to `.` (identity). Results land on `#results` as
|
|
20
21
|
`application/jsonl`—one compact value per line—under the emitted `jq://`
|
|
@@ -22,12 +23,29 @@ address.
|
|
|
22
23
|
|
|
23
24
|
## Deliberate departures from the `jq` CLI
|
|
24
25
|
|
|
25
|
-
- **
|
|
26
|
+
- **Batch by default.** Without a target, `-n` supplies null input; a file target filters that file. `[{"stdin": "open"}]` instead waits for JSON values sent to the running invocation. A target plus open stdin reads the file first, then stdin, as `jq program file -` does.
|
|
26
27
|
- **Compact output is forced (`-c`).** `jq`'s pretty-print default would break the channel's JSONL contract; presentation belongs to the consumer's mimetype pipeline, not the filter.
|
|
27
|
-
- **No flag surface.** The body is
|
|
28
|
+
- **No flag surface.** The body is a jq program, not CLI arguments; options such as `--arg`, `-r`, and `-s` are not accepted here.
|
|
28
29
|
|
|
29
30
|
`jq` reads the ambient environment (`env`, `$ENV`) per its own contract — the consumer's scoped env is honored when provided.
|
|
30
31
|
|
|
32
|
+
## Live input
|
|
33
|
+
|
|
34
|
+
````jq [{"stdin": "open"}]
|
|
35
|
+
.value * 2
|
|
36
|
+
````
|
|
37
|
+
|
|
38
|
+
Use the returned stream address, here `jq:///c4e56789`. A SEND body is input
|
|
39
|
+
JSON, not another jq program; this example closes stdin after sending its value:
|
|
40
|
+
|
|
41
|
+
````SEND (jq:///c4e56789) [{"eof": true}]
|
|
42
|
+
{"value":21}
|
|
43
|
+
````
|
|
44
|
+
|
|
45
|
+
Without `[{"eof": true}]`, include an actual trailing newline to delimit each JSON
|
|
46
|
+
value. Open-input output is unbuffered. READ the same address for results;
|
|
47
|
+
SEND acknowledges only input delivery. KILL remains execution cancellation.
|
|
48
|
+
|
|
31
49
|
## Errors
|
|
32
50
|
|
|
33
51
|
A failed program or spawn closes `results` as `errored` with status 500 and an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-execs-jq",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "jq runtime executor for plurnk-service's exec scheme — shells the system jq binary to filter or transform JSON.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plurnk",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"prepublishOnly": "npm audit --audit-level=moderate && npm test"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@plurnk/plurnk-execs": "^1.
|
|
81
|
+
"@plurnk/plurnk-execs": "^1.18.0"
|
|
82
82
|
}
|
|
83
83
|
}
|