@withone/cli 2.12.0 → 2.14.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.
@@ -25,7 +25,7 @@ If a flow's description doesn't tell you how to run it, treat that as a bug in t
25
25
  **Storage layout:**
26
26
 
27
27
  - **Folder layout (REQUIRED for new flows):** `.one/flows/<key>/flow.json`, with an optional `lib/` subfolder for `.mjs` code modules. Like a skill — the folder groups the spec with its helper code, so the whole flow is shareable. **Always create new flows here.**
28
- - **Legacy single-file layout (DEPRECATED):** `.one/flows/<key>.flow.json`. Still loads and runs for backward compatibility, but do not create new flows in this layout. When touching an existing single-file flow, migrate it: move `<key>.flow.json` to `<key>/flow.json` and extract any non-trivial `code.source` blocks into `<key>/lib/*.mjs` modules.
28
+ - **Legacy single-file layout (DEPRECATED):** `.one/flows/<key>.flow.json`. Still loads and runs for backward compatibility, but do not create new flows in this layout. When touching an existing single-file flow, migrate it: move `<key>.flow.json` to `<key>/flow.json`. Move a `code.source` block into a `<key>/lib/*.mjs` module only if it needs files, network or timers: modules run with full Node access and make the flow require `--allow-code`.
29
29
 
30
30
  `one flow create` always writes the folder layout.
31
31
 
@@ -93,20 +93,20 @@ process.stdout.write(JSON.stringify(items.filter(i => i.active)));
93
93
  }
94
94
  ```
95
95
 
96
- The module runs as a child `node` process: the flow context `$` is piped to stdin as JSON, and stdout is parsed as JSON and used as the step's output. Modules have full Node APIs available (unlike inline `code.source`, which is sandboxed). Use `code.module` for anything non-trivial; keep `code.source` for one-liners.
96
+ The module runs as a child `node` process: the flow context `$` is piped to stdin as JSON, and stdout is parsed as JSON and used as the step's output. Modules have full Node APIs available (unlike inline `code.source`, which is sandboxed), so **a flow with any `code.module` step only runs with `--allow-code`**, the same way bash steps need `--allow-bash`. Say so in the flow's `description`. Use `code.module` when you need files, network or timers; keep pure data shaping in `code.source`.
97
97
 
98
- #### Inline `code.source` sandbox
98
+ #### Sandbox for inline JavaScript
99
99
 
100
- Inline `code.source` runs inside an async function with a restricted `require`. Only the following Node built-ins are importable:
100
+ Every piece of JavaScript written inside `flow.json` runs in a sandbox: `transform.expression`, `condition.expression`, `while.condition`, step-level `if`/`unless`, and `code.source`. A flow file can come from anywhere (a cloned repo, a shared folder, another agent), so this code cannot start programs, read or write files, or see the CLI's own environment.
101
101
 
102
- - `node:buffer`
103
- - `node:crypto`
104
- - `node:url`
105
- - `node:path`
102
+ - It runs in a separate `node` process started with Node's permission model (`--permission`), an empty environment, and `eval`/`new Function` turned off.
103
+ - `process`, `require` (outside `code.source`), `fetch`, `WebSocket`, `setTimeout`/`setInterval`, `__dirname` and `__filename` are not defined.
104
+ - Inside `code.source`, `await require(name)` loads only these built-ins: `node:buffer`, `node:crypto`, `node:url`, `node:path`. Everything else (`fs`, `http`, `https`, `net`, `child_process`, `process`, `os`, `cluster`, `dgram`, `tls`, `vm`, `worker_threads`) throws `Module "<name>" is blocked in code steps`.
105
+ - `$` is a copy of the flow context. Read from it and `return` a result; changing `$` inside a step does not change what later steps see.
106
+ - Values cross into and out of the sandbox by structured clone: `Date`, `Map`, `Set`, `RegExp`, typed arrays and `undefined` survive; functions and symbols cannot be returned and fail the step.
107
+ - Each evaluation has a 30-second limit for synchronous work and 60 seconds overall. A step that runs longer fails with `timed out`.
106
108
 
107
- Everything else — `fs`, `http`, `https`, `net`, `child_process`, `process`, `os`, `cluster`, `dgram`, `tls`, `vm`, `worker_threads` — is **blocked** and will throw `Module "<name>" is blocked in code steps`. The runtime also does not expose `process`, `__dirname`, `__filename`, `setTimeout`, or `fetch`.
108
-
109
- If you need any of those (filesystem reads, network calls, timers, etc.), use a `code.module` step instead — modules run as a real child `node` process and have the full Node API surface.
109
+ These steps need no flag. If you need files, network calls or timers, use a `code.module` step, which requires `--allow-code`.
110
110
 
111
111
  When an inline `code.source` step throws at runtime, the error message reports the user-relative line and column plus the offending line of source — e.g. `Code step "blowup" failed at line 3:34\n const c = $.steps.mk.output.data.score;\n Cannot read properties of null (reading 'score')`. No need to bisect the step manually.
112
112
 
@@ -118,7 +118,7 @@ If you touch an existing `.one/flows/<key>.flow.json`, migrate it:
118
118
 
119
119
  1. `mkdir -p .one/flows/<key>/lib`
120
120
  2. `mv .one/flows/<key>.flow.json .one/flows/<key>/flow.json`
121
- 3. Extract non-trivial `code.source` blocks into `lib/<step-id>.mjs` and swap the step config from `{ "source": "..." }` to `{ "module": "lib/<step-id>.mjs" }`. One-liners can stay inline.
121
+ 3. Leave `code.source` inline unless it needs files, network or timers. Inline code runs in the sandbox and needs no flag. Moving it to `lib/<step-id>.mjs` (`{ "module": "lib/<step-id>.mjs" }`) gives it full Node access and makes the flow require `--allow-code`.
122
122
  4. `one --agent flow validate <key>`
123
123
  5. Execute and confirm behavior is unchanged.
124
124
 
@@ -708,8 +708,9 @@ Three tools that turn "re-run the whole 40-step flow to debug step 30" into near
708
708
  - **Prefer passthrough actions over custom actions.** Custom actions add server-side fan-out that causes timeouts at scale. The flow runner handles pagination, retries, and rate limiting locally. Find with `-t knowledge` to reach passthrough endpoints (e.g. GET `/gmail/v1/users/{userId}/threads` instead of POST `/gmail/get-threads`)
709
709
  - Connection keys are inputs, not hardcoded — makes workflows portable
710
710
  - Action IDs in examples are placeholders — always use `actions find` to find real IDs
711
- - Code steps support `require('crypto')`, `require('buffer')`, `require('url')`, `require('path')` — `fs`, `http`, `child_process` are blocked
711
+ - Transforms, conditions, `if`/`unless` and `code.source` run in a sandbox with no file, process or network access. `code.source` supports `require('crypto')`, `require('buffer')`, `require('url')`, `require('path')`; `fs`, `http`, `child_process` are blocked
712
712
  - Bash steps require `--allow-bash` flag
713
+ - `code.module` steps require `--allow-code` flag (they run with full Node access)
713
714
  - Action steps validate required params before executing — pass `--skip-validation` to bypass
714
715
  - `--mock` now returns realistic example data from action schemas (instead of echoed config)
715
716
  - State is persisted after every step — resume picks up where it left off
@@ -1,13 +0,0 @@
1
- import {
2
- memSqlCommand,
3
- syncSqlCommand
4
- } from "./chunk-DGQOAFXJ.js";
5
- import "./chunk-J7JWBH45.js";
6
- import "./chunk-Q6PWTATS.js";
7
- import "./chunk-6IRGRC3G.js";
8
- import "./chunk-EITBMRUB.js";
9
- import "./chunk-EWHFGWB3.js";
10
- export {
11
- memSqlCommand,
12
- syncSqlCommand
13
- };