swytchcode-runtime 0.1.0 → 0.1.1

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 CHANGED
@@ -46,8 +46,12 @@ Equivalent to: `swytchcode exec api.report.export --raw` with input on stdin.
46
46
  - **`env`** – Extra environment variables (merged with `process.env`).
47
47
  - **`output`** – `"json"` (default), `"raw"`, or `"stream"`. Default is JSON (stdout must be valid JSON; parse failure throws). Use `"raw"` to get stdout as a string. `"stream"` is not supported and will throw; use the CLI directly for streaming.
48
48
  - **`raw`** – If `true`, same as `output: "raw"`. Kept for backward compatibility.
49
+ - **`dryRun`** – If `true`, pass `--dry-run` to the CLI; the CLI outputs request details (method, url, headers, body) instead of calling the server.
50
+ - **`allowRaw`** – If `true`, pass `--allow-raw` to the CLI; required for executing raw methods (kernel has this disabled by default).
49
51
  - **`debug`** – If `true`, log spawn args, cwd, exit status, and stdout/stderr lengths to stderr.
50
52
 
53
+ This runtime invokes `swytchcode exec [canonical_id]` with the flags above. For full exec behavior (exit codes, output format, pipeline), see the [Swytchcode kernel documentation](https://github.com/swytchcode/swytchcode).
54
+
51
55
  **Debug logs** are also enabled when `SWYTCHCODE_RUNTIME_DEBUG=1` or `SWYTCHCODE_RUNTIME_DEBUG=true` (no code change):
52
56
 
53
57
  ```bash
package/dist/exec.js CHANGED
@@ -36,9 +36,17 @@ function exec(canonicalId, input, options = {}) {
36
36
  }
37
37
  const raw = outputMode === "raw";
38
38
  const args = ["exec", canonicalIdTrimmed, raw ? "--raw" : "--json"];
39
+ if (options.dryRun === true)
40
+ args.push("--dry-run");
41
+ if (options.allowRaw === true)
42
+ args.push("--allow-raw");
39
43
  const cwd = options.cwd ?? process.cwd();
40
44
  const hasInput = input !== undefined && input !== null;
41
45
  log(debug, "spawn:", `swytchcode ${args.join(" ")}`);
46
+ if (options.dryRun === true)
47
+ log(debug, "dry-run:", "enabled");
48
+ if (options.allowRaw === true)
49
+ log(debug, "allow-raw:", "enabled");
42
50
  log(debug, "cwd:", cwd);
43
51
  log(debug, "stdin:", hasInput ? `JSON (${JSON.stringify(input).length} chars)` : "none");
44
52
  const result = (0, node_child_process_1.spawnSync)("swytchcode", args, {
package/dist/types.d.ts CHANGED
@@ -12,6 +12,10 @@ export interface ExecOptions {
12
12
  output?: OutputMode;
13
13
  /** If true, same as `output: "raw"`. Kept for backward compatibility. */
14
14
  raw?: boolean;
15
+ /** If true, pass `--dry-run` to the CLI; request details are output instead of calling the server. */
16
+ dryRun?: boolean;
17
+ /** If true, pass `--allow-raw` to the CLI; required for executing raw methods (disabled by default in kernel). */
18
+ allowRaw?: boolean;
15
19
  /** If true, log spawn/capture details to process.stderr (for debugging). */
16
20
  debug?: boolean;
17
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swytchcode-runtime",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Thin runtime wrapper around the Swytchcode CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",