@keystrokehq/cli 0.1.29 → 0.1.31
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.
|
@@ -59,6 +59,8 @@ Workflows are useful when you know the order of work: call an action, prompt an
|
|
|
59
59
|
| **Durability** | Completed steps are recorded and replayed, so retries resume instead of restarting |
|
|
60
60
|
| **Durable waits** | `ctx.sleep()` and `ctx.hook()` suspend a run for a delay or until it is resumed externally |
|
|
61
61
|
|
|
62
|
+
Workflows also render as an interactive **canvas** in the platform. Keep durable work in steps and orchestrate them directly in `run` — the build blocks steps called outside a workflow file or nested in another call's arguments, and warns on patterns that render as opaque blocks (`.map` over steps, `Promise.all(arr.map(...))`, reused helpers, spread step inputs). Read `search_docs "workflow best practices"` before writing non-trivial workflows.
|
|
63
|
+
|
|
62
64
|
### Common failures
|
|
63
65
|
|
|
64
66
|
- **Research real APIs before mirroring them** — building actions for custom integrations is very common; web search and fetch the actual reference & explore relevant docs, don't guess endpoints or payload shapes.
|
|
@@ -132,6 +134,7 @@ Common pages to read with `query_docs` (e.g. `cat /learn/agents/build-agents.mdx
|
|
|
132
134
|
| `/explore-features` | Guide to find relevant feature documentation |
|
|
133
135
|
| `/learn/agents/build-agents` | Models, tools, subagents, sandboxes, MCP tools on agents |
|
|
134
136
|
| `/learn/workflows/build-workflows` | Steps, orchestration, sandboxes, durable waits |
|
|
137
|
+
| `/learn/workflows/authoring-best-practices` | Canvas-legible, replayable workflow patterns (hard + soft rules) |
|
|
135
138
|
| `/learn/actions/overview` | Action rules (leaf units, no action-in-action) |
|
|
136
139
|
| `/learn/triggers/overview` | Choosing a trigger type |
|
|
137
140
|
| `/learn/credentials/connect-credentials` | Connecting apps, OAuth, project credentials |
|
|
@@ -135,7 +135,28 @@ export default defineWorkflow({
|
|
|
135
135
|
|
|
136
136
|
Use `promptLlm(...)` (import from `@keystrokehq/keystroke/workflow`) for one-shot generation/classification. Use `agent.prompt(...)` when the step needs tools, memory, or multi-turn reasoning.
|
|
137
137
|
|
|
138
|
-
**Durability** — completed steps replay on retry: keep side effects inside steps; make steps idempotent; keep control flow deterministic (no `Date.now()` / randomness)
|
|
138
|
+
**Durability** — completed steps replay on retry: keep side effects inside steps; make steps idempotent; keep control flow deterministic (no `Date.now()` / randomness). Step ids are assigned automatically from each call's position in `run`, so adding or removing an unrelated step never shifts the others. `ctx.sleep`/`ctx.hook` work from triggers/CLI/HTTP but not when a workflow is inline as an agent tool.
|
|
139
|
+
|
|
140
|
+
#### Canvas-legible, replayable workflows
|
|
141
|
+
|
|
142
|
+
The platform renders every workflow as an interactive **canvas** (a deploy-time parser reads your source) and lights up each step in run history. These habits keep steps rendering as real nodes and keep runs replayable. Full detail: `/learn/workflows/authoring-best-practices`.
|
|
143
|
+
|
|
144
|
+
**Principle** — put durable work in steps (`action.run`, `agent.prompt`, `promptLlm`, `ctx.sleep`, `ctx.hook`) and orchestrate them directly in `run` (or a same-file helper). Code between steps isn't checkpointed — it re-runs on every replay.
|
|
145
|
+
|
|
146
|
+
**Hard rules (break them and the build fails):**
|
|
147
|
+
|
|
148
|
+
1. **Never call a step outside a workflow file** — a `.run()` / `.prompt()` in `src/lib/**` or any imported module is invisible and uncorrelated. Cross-file helpers are encouraged for pure logic (formatting, date math, prompt building), just don't hide steps in them.
|
|
149
|
+
2. **Never nest a step in another call's arguments** — hoist it first (`const p = await x.run({}); await y.run({ v: p.field })`).
|
|
150
|
+
|
|
151
|
+
**Soft rules (build warns; the step still runs but renders as one opaque block):**
|
|
152
|
+
|
|
153
|
+
- Call steps **directly in `run()`**; a same-file helper is fine only if called once (reused helpers collapse).
|
|
154
|
+
- Iterate step work with **`for-of`**, not `.map` / `.filter` / `.forEach` / `.reduce`.
|
|
155
|
+
- Parallelize with a **literal** `Promise.all([a.run(), b.run()])`, not `Promise.all(arr.map(...))` / `race` / `allSettled` / `any`.
|
|
156
|
+
- List step **input fields explicitly** — no `...spread` or computed `[key]:` keys.
|
|
157
|
+
- Branch with **`if` / `else` / `switch`**, not step-bearing ternaries.
|
|
158
|
+
- Keep all side effects and non-determinism **inside steps**.
|
|
159
|
+
- Do HTTP/IO through an **action** (prebuilt integration *or* your own `defineAction`/`defineApp`), never a bare `fetch` in `run` — an inline `fetch` is neither a durable step nor a canvas node.
|
|
139
160
|
|
|
140
161
|
### Action — `defineAction`
|
|
141
162
|
|
|
@@ -275,6 +296,7 @@ Below is a sample of some of the most common documentation pages.
|
|
|
275
296
|
| `/learn/agents/test-agents` | Testing agents locally |
|
|
276
297
|
| `/learn/agents/external-channels` | Slack / external channel bindings |
|
|
277
298
|
| `/learn/workflows/build-workflows` | Steps, orchestration, sandboxes |
|
|
299
|
+
| `/learn/workflows/authoring-best-practices` | Canvas-legible, replayable workflow patterns (hard + soft rules) |
|
|
278
300
|
| `/learn/workflows/test-workflows` | Workflow tests |
|
|
279
301
|
| `/learn/workflows/run-workflows` | Running workflows, inspecting output |
|
|
280
302
|
| `/learn/actions/overview` | Action rules (leaf units, no action-in-action) |
|