@withone/cli 1.20.3 → 1.21.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 +3 -3
- package/dist/{chunk-DPOG6BQ5.js → chunk-KZOFPEHD.js} +806 -19
- package/dist/flow-runner-CXZ6AWXT.js +28 -0
- package/dist/index.js +63 -556
- package/package.json +1 -1
- package/skills/one/references/flows.md +87 -2
- package/dist/flow-runner-UWZL2FPJ.js +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
# One Workflows — Multi-Step API Workflows
|
|
2
2
|
|
|
3
|
-
Workflows chain actions across platforms
|
|
3
|
+
Workflows chain actions across platforms. Like n8n/Zapier but file-based.
|
|
4
|
+
|
|
5
|
+
## Before you execute a flow you did NOT author — READ THIS
|
|
6
|
+
|
|
7
|
+
Nothing about a flow's runtime requirements is guessable from its name. Before `flow execute`, do one of these:
|
|
8
|
+
|
|
9
|
+
1. **Recommended:** `one --agent flow list` — the JSON output includes `requiresBash`, `usesCodeModules`, `inputs` (with `autoResolvable`), `stepTypes`, and the flow's `description`. Fastest path to knowing what you need.
|
|
10
|
+
2. Read the flow's `description` field from the JSON. Authors are required (see "Author conventions" below) to state `--allow-bash` requirements and non-auto-resolving inputs there.
|
|
11
|
+
3. `one --agent flow execute <key> --dry-run` to see resolved inputs and step plan without side effects.
|
|
12
|
+
|
|
13
|
+
If you skip this, you will hit errors like *"Workflow X contains bash steps. Re-run with --allow-bash."* — the CLI pre-flights and fails fast, but the error is entirely avoidable by reading first.
|
|
14
|
+
|
|
15
|
+
## Author conventions — write flows that are safe to execute blind
|
|
16
|
+
|
|
17
|
+
The `description` field is the contract with future executors. It MUST state:
|
|
18
|
+
|
|
19
|
+
- **`--allow-bash` if any step is type `bash`.** e.g. *"Fetches recent Gmail and summarizes with Claude Haiku. Requires `--allow-bash`."*
|
|
20
|
+
- **Every input that does NOT have a `connection` hint.** Connection inputs auto-resolve when exactly one matching connection exists; everything else must be passed via `-i name=value`.
|
|
21
|
+
- **Any files/directories the flow writes to.**
|
|
22
|
+
|
|
23
|
+
If a flow's description doesn't tell you how to run it, treat that as a bug in the flow and fix it.
|
|
24
|
+
|
|
25
|
+
**Storage layout:**
|
|
26
|
+
|
|
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.
|
|
29
|
+
|
|
30
|
+
`one flow create` always writes the folder layout.
|
|
4
31
|
|
|
5
32
|
## Building a Workflow
|
|
6
33
|
|
|
@@ -37,7 +64,65 @@ You MUST call knowledge for every action in the workflow — it tells you the ex
|
|
|
37
64
|
one --agent flow create <key> --definition '<json>'
|
|
38
65
|
```
|
|
39
66
|
|
|
40
|
-
Or write directly to `.one/flows/<key>.flow.json`.
|
|
67
|
+
Or write directly to `.one/flows/<key>/flow.json` (folder layout) or the legacy `.one/flows/<key>.flow.json`.
|
|
68
|
+
|
|
69
|
+
### Code modules (`lib/` folder)
|
|
70
|
+
|
|
71
|
+
A `code` step can reference an external `.mjs` module instead of inlining JS as a JSON string:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
.one/flows/my-flow/
|
|
75
|
+
├── flow.json
|
|
76
|
+
└── lib/
|
|
77
|
+
└── process-data.mjs
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
// lib/process-data.mjs
|
|
82
|
+
const $ = JSON.parse(await new Response(process.stdin).text());
|
|
83
|
+
const items = $.steps.fetch.response.data ?? [];
|
|
84
|
+
process.stdout.write(JSON.stringify(items.filter(i => i.active)));
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"id": "processData",
|
|
90
|
+
"name": "Process",
|
|
91
|
+
"type": "code",
|
|
92
|
+
"code": { "module": "lib/process-data.mjs" }
|
|
93
|
+
}
|
|
94
|
+
```
|
|
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.
|
|
97
|
+
|
|
98
|
+
Whatever JSON a module writes to stdout becomes both `$.steps.<id>.output` and `$.steps.<id>.response` (aliases). Downstream steps can reference either.
|
|
99
|
+
|
|
100
|
+
### Migrating a legacy single-file flow
|
|
101
|
+
|
|
102
|
+
If you touch an existing `.one/flows/<key>.flow.json`, migrate it:
|
|
103
|
+
|
|
104
|
+
1. `mkdir -p .one/flows/<key>/lib`
|
|
105
|
+
2. `mv .one/flows/<key>.flow.json .one/flows/<key>/flow.json`
|
|
106
|
+
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.
|
|
107
|
+
4. `one --agent flow validate <key>`
|
|
108
|
+
5. Execute and confirm behavior is unchanged.
|
|
109
|
+
|
|
110
|
+
**Inline source → module translation.** Inline `code.source` is an async function body where `$` is in scope and you `return` the result. A module reads `$` from stdin and writes the result to stdout. Mechanical transform:
|
|
111
|
+
|
|
112
|
+
Before (inline):
|
|
113
|
+
```js
|
|
114
|
+
const items = $.steps.fetch.response.data;
|
|
115
|
+
return { active: items.filter(i => i.active) };
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
After (`lib/<step-id>.mjs`):
|
|
119
|
+
```js
|
|
120
|
+
const $ = JSON.parse(await new Response(process.stdin).text());
|
|
121
|
+
const items = $.steps.fetch.response.data;
|
|
122
|
+
process.stdout.write(JSON.stringify({ active: items.filter(i => i.active) }));
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Two rules: (1) prepend the stdin-read line, (2) replace `return X` with `process.stdout.write(JSON.stringify(X))`.
|
|
41
126
|
|
|
42
127
|
### Step 5: Validate
|
|
43
128
|
|