@nathanstephenson/flow 0.1.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 +641 -0
- package/build/workflow-runtime.cjs +213964 -0
- package/dist/backend/claude/async-queue.js +44 -0
- package/dist/backend/claude/auto-compaction.js +10 -0
- package/dist/backend/claude/background-calls.js +116 -0
- package/dist/backend/claude/enquiries.js +162 -0
- package/dist/backend/claude/index.js +1138 -0
- package/dist/backend/claude/mcp.js +55 -0
- package/dist/backend/claude/permissions.js +106 -0
- package/dist/backend/claude/streamed-message.js +120 -0
- package/dist/backend/claude/subagents.js +128 -0
- package/dist/backend/claude/workflow-parent.js +12 -0
- package/dist/backend/claude/workflow-processes.js +95 -0
- package/dist/backend/claude/workflow-subagent.js +234 -0
- package/dist/backend/effort.js +30 -0
- package/dist/backend/fake/index.js +570 -0
- package/dist/backend/mcp.js +190 -0
- package/dist/backend/pi/auto-compaction.js +16 -0
- package/dist/backend/pi/background-calls.js +56 -0
- package/dist/backend/pi/enquiries.js +63 -0
- package/dist/backend/pi/index.js +597 -0
- package/dist/backend/pi/mcp.js +35 -0
- package/dist/backend/pi/subagents.js +23 -0
- package/dist/backend/pi/work.js +104 -0
- package/dist/backend/pi/workflow-parent.js +21 -0
- package/dist/backend/pi/workflow-subagent.js +199 -0
- package/dist/backend/registry.js +34 -0
- package/dist/backend/types.js +1 -0
- package/dist/backend/workflow-tools.js +25 -0
- package/dist/build-id +1 -0
- package/dist/cli/application.js +397 -0
- package/dist/cli/bootstrap.js +535 -0
- package/dist/cli/host-control.js +100 -0
- package/dist/cli/install-guard.js +270 -0
- package/dist/cli/install-process.js +52 -0
- package/dist/cli/main.js +12 -0
- package/dist/cli/update.js +128 -0
- package/dist/client/connection.js +183 -0
- package/dist/client/context-usage.js +66 -0
- package/dist/client/diff.js +36 -0
- package/dist/client/enquiry.js +105 -0
- package/dist/client/markdown.js +192 -0
- package/dist/client/model-choices.js +32 -0
- package/dist/client/permission.js +60 -0
- package/dist/client/project-name.js +19 -0
- package/dist/client/reduce.js +463 -0
- package/dist/client/relative-time.js +30 -0
- package/dist/client/scope-kind.js +28 -0
- package/dist/client/search.js +136 -0
- package/dist/client/session-label.js +9 -0
- package/dist/client/status.js +84 -0
- package/dist/client/tool-chains.js +52 -0
- package/dist/client/tool-summary.js +98 -0
- package/dist/daemon/auth.js +590 -0
- package/dist/daemon/config-store.js +183 -0
- package/dist/daemon/config.js +687 -0
- package/dist/daemon/credential-redaction.js +9 -0
- package/dist/daemon/git.js +312 -0
- package/dist/daemon/host-control-routes.js +29 -0
- package/dist/daemon/host.js +2343 -0
- package/dist/daemon/http.js +19 -0
- package/dist/daemon/log.js +44 -0
- package/dist/daemon/mcp-auth.js +164 -0
- package/dist/daemon/models.js +85 -0
- package/dist/daemon/ownership.js +104 -0
- package/dist/daemon/projects.js +317 -0
- package/dist/daemon/publish.js +289 -0
- package/dist/daemon/pull-request.js +198 -0
- package/dist/daemon/runtime.js +100 -0
- package/dist/daemon/secret-store.js +65 -0
- package/dist/daemon/server.js +827 -0
- package/dist/daemon/shell.js +220 -0
- package/dist/daemon/skills.js +104 -0
- package/dist/daemon/stack-metadata.js +24 -0
- package/dist/daemon/stack.js +743 -0
- package/dist/daemon/store.js +130 -0
- package/dist/daemon/summariser.js +476 -0
- package/dist/daemon/workflow-execution-routes.js +105 -0
- package/dist/daemon/workflow-executions.js +1018 -0
- package/dist/daemon/workflow-mcp.js +20 -0
- package/dist/daemon/workflow-routes.js +102 -0
- package/dist/protocol/attachments.js +59 -0
- package/dist/protocol/commands.js +1 -0
- package/dist/protocol/events.js +20 -0
- package/dist/protocol/fonts.js +26 -0
- package/dist/protocol/git.js +12 -0
- package/dist/protocol/mcp.js +51 -0
- package/dist/protocol/projects.js +21 -0
- package/dist/protocol/publish.js +1 -0
- package/dist/protocol/pull-request.js +1 -0
- package/dist/protocol/secrets.js +4 -0
- package/dist/protocol/settings.js +63 -0
- package/dist/protocol/shells.js +8 -0
- package/dist/protocol/skills.js +16 -0
- package/dist/protocol/stack.js +41 -0
- package/dist/protocol/workflow-executions.js +1 -0
- package/dist/protocol/workflows.js +1 -0
- package/dist/tui/app.js +518 -0
- package/dist/tui/keys.js +54 -0
- package/dist/tui/render.js +366 -0
- package/dist/web/assets.js +10 -0
- package/dist/web/embedded.js +12 -0
- package/dist/web/manifest.js +70 -0
- package/dist/workflows/decisions.js +65 -0
- package/dist/workflows/executors.js +132 -0
- package/dist/workflows/graph.js +276 -0
- package/dist/workflows/json-schema.js +49 -0
- package/dist/workflows/loops.js +102 -0
- package/dist/workflows/mcp.js +18 -0
- package/dist/workflows/records.js +111 -0
- package/dist/workflows/recovery.js +25 -0
- package/dist/workflows/runtime-asset.js +17 -0
- package/dist/workflows/runtime-libs.js +1 -0
- package/dist/workflows/runtime-settings.js +23 -0
- package/dist/workflows/runtime.js +343 -0
- package/dist/workflows/scheduler.js +573 -0
- package/dist/workflows/schema.js +161 -0
- package/dist/workflows/store.js +93 -0
- package/package.json +87 -0
- package/web/dist/assets/__vite-browser-external-2447137e-BvRk9kiK.js +0 -0
- package/web/dist/assets/ghostty-vt-DOMeXDrv.wasm +0 -0
- package/web/dist/assets/index-BC0gLS53.js +106 -0
- package/web/dist/assets/index-CCeZYKES.css +2 -0
- package/web/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/web/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/web/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/web/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/web/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/web/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/web/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/web/dist/assets/rolldown-runtime-B0Z9INg1.js +1 -0
- package/web/dist/assets/select-6i3wxovH.js +1 -0
- package/web/dist/assets/settings-mcp-CcT0ADJR.js +1 -0
- package/web/dist/assets/settings-secrets-CK4uF7fd.js +1 -0
- package/web/dist/assets/settings-workflows-CrbZF-nM.js +23 -0
- package/web/dist/assets/switch-ftZleVB8.js +6 -0
- package/web/dist/assets/workflow-editors-naPqAmYO.js +65 -0
- package/web/dist/assets/workflows-D4T4Gy_7.css +1 -0
- package/web/dist/assets/workflows-hh6ioeEA.js +7 -0
- package/web/dist/assets/workflows-pane-Db-MHf7Z.js +1 -0
- package/web/dist/index.html +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
# Flow
|
|
2
|
+
|
|
3
|
+
Run and watch coding-agent sessions from a terminal or a browser, over more than one agent SDK.
|
|
4
|
+
|
|
5
|
+
- **Local mode (v1)** — a Session Host daemon on loopback, with a TUI and a web UI as equal clients.
|
|
6
|
+
- **Backends** — the Claude Agent SDK (on your own Claude subscription) and the pi SDK (for models
|
|
7
|
+
Claude doesn't serve). Backend is chosen per Agent Session.
|
|
8
|
+
|
|
9
|
+
See [CONTEXT.md](./CONTEXT.md) for the domain language and [docs/adr](./docs/adr) for decisions.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Requires Node.js 22 or later and npm. Linux and macOS installs are checked in CI.
|
|
14
|
+
Use a user-owned npm prefix (for example, from a Node version manager), not sudo or a shared system prefix.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install --global @nathanstephenson/flow
|
|
18
|
+
flow --version
|
|
19
|
+
flow serve
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Open the web handoff URL printed by `flow serve`, or run `flow tui` in another terminal.
|
|
23
|
+
|
|
24
|
+
`flow serve` stays in the foreground. Use `flow serve start` for a background Session Host,
|
|
25
|
+
`flow serve status` to see installed and running versions, and `flow serve stop` to stop it.
|
|
26
|
+
`flow serve restart` only restarts a background-owned host, with its saved address, port and working
|
|
27
|
+
directory. A port of `0` stays dynamic. Restart requires the same OIDC configuration.
|
|
28
|
+
|
|
29
|
+
Stop and restart refuse active work unless you pass `--force`. Force interrupts work gracefully;
|
|
30
|
+
it does not kill the process. Agent Sessions become Dormant and their transcripts remain on disk.
|
|
31
|
+
A TUI attaches to an existing host without stopping it on exit. If the TUI creates its own host,
|
|
32
|
+
that host stops when the TUI exits. One-shot prompts refuse an occupied state root.
|
|
33
|
+
Each `FLOW_STATE_DIR` permits one host. Background output is saved in its private `host.log`.
|
|
34
|
+
If shutdown cannot finish within its deadline, Flow reports failure and retains ownership;
|
|
35
|
+
do not start another host against that state directory. Inspect the log and resolve the stalled
|
|
36
|
+
operation before attempting recovery.
|
|
37
|
+
Configure credentials for the Backend Adapter you use.
|
|
38
|
+
|
|
39
|
+
To check a release from source, run `npm ci` and `npm run test:package`.
|
|
40
|
+
This builds, packs, and installs the archive into a temporary prefix, then checks it
|
|
41
|
+
from an unrelated directory. Build outputs are not tracked in Git.
|
|
42
|
+
|
|
43
|
+
The `prepack` script builds the CLI, web client, and Workflow runtime; users do not need to build them.
|
|
44
|
+
|
|
45
|
+
### Releases
|
|
46
|
+
|
|
47
|
+
Publish the first version manually from a clean, tested `main` checkout, after choosing a license:
|
|
48
|
+
`npm ci`, `npm run test:package`, `npm login`, then `npm publish --access public`.
|
|
49
|
+
Next, configure npm Trusted Publishing for owner `nathanstephenson`, repository `flow`, and
|
|
50
|
+
workflow filename `publish.yml` (GitHub Actions), with direct `npm publish` allowed.
|
|
51
|
+
No npm token secret is used.
|
|
52
|
+
|
|
53
|
+
For later releases, update `package.json` and both lockfile version fields through a PR, merge it,
|
|
54
|
+
then push a matching stable tag such as `v0.1.1` on that `main` commit. The publish workflow
|
|
55
|
+
rejects tags outside `main`, prerelease tags, and mismatched versions. It builds and tests one
|
|
56
|
+
archive without publishing credentials, then publishes that exact archive with OIDC and provenance.
|
|
57
|
+
Protect `main` and release-tag creation in GitHub. Tag creation is the release approval;
|
|
58
|
+
do not tag a version until its license and release contents are approved.
|
|
59
|
+
|
|
60
|
+
## Updating Flow
|
|
61
|
+
|
|
62
|
+
Run `flow update` to install `@nathanstephenson/flow@latest` with the npm selected by PATH.
|
|
63
|
+
Its global prefix must match this exact installation. Only user-owned prefixes without group or
|
|
64
|
+
other write access are supported; their ancestor directories must also prevent replacement by other users. Source, npm-link, root/sudo, shared prefixes, and SEA self-update
|
|
65
|
+
are not supported. Ordinary commands still work for these installations. Update shared or system
|
|
66
|
+
installations manually with npm after stopping all Flow processes.
|
|
67
|
+
|
|
68
|
+
Close all CLI/TUI clients and stop other Session Hosts that use this installation, including those
|
|
69
|
+
under other `FLOW_STATE_DIR` roots. The selected root's background Session Host can stay running:
|
|
70
|
+
Flow stops it, updates, and restores its saved address, port, working directory and OIDC settings
|
|
71
|
+
with a new process. Use `--force` to interrupt active work. Foreground and embedded hosts are refused.
|
|
72
|
+
The same OIDC configuration must be present when you update. No version argument is accepted.
|
|
73
|
+
|
|
74
|
+
Before first adopting this release, stop **all** older Flow processes. Old processes have no
|
|
75
|
+
installation lease and cannot be reliably detected. External `npm install` commands do not honor
|
|
76
|
+
Flow's guard: never run them while Flow is active or an update is in progress.
|
|
77
|
+
|
|
78
|
+
For eligible private installations, the guard registers every CLI process before loading application
|
|
79
|
+
code. Registry errors or changed permissions on an already guarded installation prevent startup;
|
|
80
|
+
they do not disable the guard. It blocks new
|
|
81
|
+
starts across state roots until update and restoration finish. Use `flow`, not `dist/cli/main.js`.
|
|
82
|
+
On failure, Flow attempts to reinstall the previous exact version and restore the host. This is
|
|
83
|
+
best-effort recovery, not preservation of the old package files. A failed update exits nonzero,
|
|
84
|
+
even if recovery succeeds. npm's process group must stop before verification or rollback;
|
|
85
|
+
uncertain termination retains the recovery barrier. Lifecycle scripts that detach into another
|
|
86
|
+
process group are not supported. An unchanged version is reported as unchanged. Restored Session Host
|
|
87
|
+
output is kept in the selected state root's private `host.log`.
|
|
88
|
+
|
|
89
|
+
If the updater dies or recovery fails, startup stays blocked. The error names
|
|
90
|
+
`<prefix>/.flow-installations/<slot>/update.json`. Do not remove it while an updater, npm child,
|
|
91
|
+
or Flow process might still run. Stop them all; use the matching npm to run
|
|
92
|
+
`npm install --global --prefix <prefix> @nathanstephenson/flow@<previous>` (the record stores
|
|
93
|
+
`previous`). Check the package name/version, `dist/build-id`, and bundled `dist/cli/bootstrap.js`
|
|
94
|
+
against a trusted package archive. Only after repair is complete, remove that `update.json`,
|
|
95
|
+
run `flow --version`, and start the Session Host again. Do not delete a live registry mutex.
|
|
96
|
+
|
|
97
|
+
## Publish branch names
|
|
98
|
+
|
|
99
|
+
Publish offers an editable branch name before the first push. It uses the Summary Model
|
|
100
|
+
when configured, with a local fallback otherwise. Confirmation creates a feature branch
|
|
101
|
+
from the default branch, or renames an unpublished branch. Published branches and registered
|
|
102
|
+
stack branches keep their names. No branch changes happen while preparing the review.
|
|
103
|
+
|
|
104
|
+
## Stacked pull requests
|
|
105
|
+
|
|
106
|
+
The browser's Git tab uses `github/gh-stack` directly (tested with v0.1.1).
|
|
107
|
+
Install it on the Session Host with `gh extension install github/gh-stack` and
|
|
108
|
+
authenticate with `gh auth login`. Ordinary Git controls remain available without it.
|
|
109
|
+
|
|
110
|
+
Stack supports Create, Add, Switch, Submit, Sync, and Rebase. Create is offered only
|
|
111
|
+
for a clear chain of at least two existing local branches linked by PR head/base relationships.
|
|
112
|
+
Commit ancestry alone does not identify a stack. Merged members retain their status.
|
|
113
|
+
Create registers the displayed branches; it never accepts names for new branches.
|
|
114
|
+
Ambiguous chains and branches already tracked in a stack are not offered.
|
|
115
|
+
Switching and mutations
|
|
116
|
+
require no working Agent Session in the same Scope, including background work.
|
|
117
|
+
Except for conflict continuation and abort, the working tree must be clean; Flow never
|
|
118
|
+
stashes changes. Use Publish for uncommitted files; stack branches use their active
|
|
119
|
+
parent as the review base and the base for new PRs. Switch only selects local stack
|
|
120
|
+
branches, including numeric branch names.
|
|
121
|
+
|
|
122
|
+
Submit and Sync require a fresh review of the affected branches and PRs. Submit uses
|
|
123
|
+
`gh stack submit --auto`: new PRs are drafts; existing draft states do not change.
|
|
124
|
+
Sync checks remote stack membership at review and confirmation, then fetches,
|
|
125
|
+
rebases, and pushes. If membership differs, reconcile it with `gh stack` outside
|
|
126
|
+
Flow and review again. API failures block Sync. The CLI cannot lock remote membership;
|
|
127
|
+
changes after the final check remain a race. After a Sync conflict, use Rebase to resolve it
|
|
128
|
+
locally, then confirm Sync again. No retry or push happens automatically.
|
|
129
|
+
|
|
130
|
+
A paused Rebase shows conflict files, Continue, and Abort. **Ask agent to fix, then
|
|
131
|
+
continue** sends a normal message to the current Agent Session to resolve and stage
|
|
132
|
+
conflicts, then use `gh stack rebase --continue` only when resolved. It does not grant
|
|
133
|
+
permission to publish, push, sync, or merge. Review the result and refresh Stack.
|
|
134
|
+
Merge and stack restructuring are not exposed.
|
|
135
|
+
|
|
136
|
+
**Copy stack** copies PR titles as formatted links, from top to bottom. **Copy PR link**
|
|
137
|
+
copies one PR. Plain-text paste contains titles only.
|
|
138
|
+
|
|
139
|
+
## Status
|
|
140
|
+
|
|
141
|
+
**M0 (walking skeleton) complete.** The Claude adapter drives real sessions end to end; the Session
|
|
142
|
+
Host, Presentation Transcript, and shared reducer are in place behind the Backend Adapter contract.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm start -- --backend claude "Use Glob to list *.json here, then say DONE"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Verified along the way:
|
|
149
|
+
|
|
150
|
+
- **Spike 0** — the Agent SDK works on subscription credentials with no `ANTHROPIC_API_KEY`, and
|
|
151
|
+
with every `CLAUDE*` variable scrubbed from the child environment (`spikes/subscription-auth.ts`).
|
|
152
|
+
- **Streaming input never self-initialises.** `query()` emits nothing until the input stream yields
|
|
153
|
+
its first message, so a Backend Adapter must not await the init message before returning — it
|
|
154
|
+
deadlocks. Capabilities therefore arrive late, via `capabilities_changed`.
|
|
155
|
+
- **`bypassPermissions` shadows `canUseTool`.** Pre-approved tools are expressed as
|
|
156
|
+
`permissionMode: "default"` plus `allowedTools`, leaving `canUseTool` to handle the fall-through —
|
|
157
|
+
where it raises a Permission Prompt for the human to decide (ADR 0018), or an Enquiry for
|
|
158
|
+
`AskUserQuestion` (ADR 0016). The SDK warns that allowlisted tools skip the callback; that is the
|
|
159
|
+
intent, not a misconfiguration, and it is why `bypassPermissions` would take away the only place a
|
|
160
|
+
tool can be held open on a person. What must never happen is a callback that neither settles nor
|
|
161
|
+
denies: that is a turn nobody can end.
|
|
162
|
+
|
|
163
|
+
**M1 (pi adapter) complete.** Both backends now sit behind the same Backend Adapter contract.
|
|
164
|
+
|
|
165
|
+
pi's real `AgentSessionEvent` union was read out of its type declarations with the compiler API
|
|
166
|
+
(`spikes/probe-type.ts`) rather than inferred, which corrected three things:
|
|
167
|
+
|
|
168
|
+
- **pi separates runs from turns.** `agent_start`/`agent_end` bracket one exchange with the human;
|
|
169
|
+
`turn_start`/`turn_end` fire once per model call, many times inside it. Our `turn_started` /
|
|
170
|
+
`turn_ended` map to `agent_*`. Mapping them to `turn_*` would emit N pairs per prompt.
|
|
171
|
+
- **`agent_end` carries `willRetry`.** When set, pi is about to auto-retry and the exchange is not
|
|
172
|
+
over, so no `turn_ended` is emitted yet.
|
|
173
|
+
- The union has 17 members, including `compaction_start` and `thinking_level_changed`, which are not
|
|
174
|
+
visible from how existing consumers use it.
|
|
175
|
+
|
|
176
|
+
`Capabilities.providers` earns its place: Claude reports `["anthropic"]`, pi reports 32.
|
|
177
|
+
|
|
178
|
+
pi keeps its own credential store, so live pi runs need `pi` + `/login`. The translation itself is
|
|
179
|
+
covered without credentials in `test/backend/pi-mapping.test.ts`, including a regression test that
|
|
180
|
+
we always send `streamingBehavior: "steer"` and never touch pi's native follow-up queue.
|
|
181
|
+
|
|
182
|
+
**M2 (durability and revive) complete.** Agent Sessions outlive the process that started them.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
flow --backend claude "Remember the word marmalade" # prints a session id
|
|
186
|
+
flow --session <id> "What word did I ask you to remember?" # → marmalade
|
|
187
|
+
flow --list
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Transcripts live at `$FLOW_STATE_DIR` (default `~/.flow`), one directory per Agent
|
|
191
|
+
Session: `meta.json` plus append-only `transcript.jsonl`. Writes are synchronous and happen before
|
|
192
|
+
any client is notified — a client must never see an event a restart would lose.
|
|
193
|
+
|
|
194
|
+
- On restart, previously running sessions load as **Dormant**: transcripts readable, nothing
|
|
195
|
+
running, nothing spent. The next message revives them, or `revive` does it explicitly.
|
|
196
|
+
- A turn torn by an unclean shutdown is **closed on load** with `reason: "aborted"`. The transcript
|
|
197
|
+
is append-only, so we record that we now know it ended rather than rewriting it.
|
|
198
|
+
- Dormancy is an event (`session_dormant`), not just host state. Without it a client reducing the
|
|
199
|
+
transcript sees `turn_ended` and shows a ready prompt for a session with no backend attached.
|
|
200
|
+
- A half-written final line in `transcript.jsonl` is tolerated: parsing stops at the last good entry.
|
|
201
|
+
|
|
202
|
+
Claude's `resumeDropsTurn` takes a message id rather than a boolean, so there is no generic
|
|
203
|
+
"drop the torn turn" hint to pass down; the torn turn is closed in our transcript instead.
|
|
204
|
+
|
|
205
|
+
**M3 (transport and TUI) complete.** The terminal client talks to the Session Host over the wire,
|
|
206
|
+
never to a session object.
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
flow serve # Session Host on 127.0.0.1, prints the web handoff URL
|
|
210
|
+
flow tui # terminal client; connects to a running host or embeds one
|
|
211
|
+
flow list
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
TUI keys: `^S` sessions · `^P` models (grouped by provider) · `^E` effort · `esc` abort · `^C` quit.
|
|
215
|
+
Typing while the agent works queues the message rather than interrupting it — steering is a
|
|
216
|
+
deliberate act.
|
|
217
|
+
|
|
218
|
+
Transport is POST for commands and SSE for events. SSE rather than WebSocket because the transcript
|
|
219
|
+
is one-directional and sequence-numbered, so reconnect is `?since=N` — a replay, not a
|
|
220
|
+
resynchronisation protocol — and it needs no dependency in Node or the browser.
|
|
221
|
+
|
|
222
|
+
Two bugs the tests caught that a manual try would likely have missed:
|
|
223
|
+
|
|
224
|
+
- **A stdin chunk is not a keystroke.** A paste arrives as one chunk and an arrow key as a
|
|
225
|
+
three-byte escape sequence, so chunks are tokenised into keys.
|
|
226
|
+
- **Chunk handlers raced.** Key handling is async, so a chunk arriving mid-walk interleaved with the
|
|
227
|
+
previous one and applied keys out of order. Chunks are now processed strictly in sequence.
|
|
228
|
+
|
|
229
|
+
**M4 (web UI) complete.** A richer surface than the TUI, on the same transport and the same reducer.
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
flow serve # prints http://127.0.0.1:PORT/auth?token=… — open that once
|
|
233
|
+
flow serve --port 3000 --address 0.0.0.0 # containers reached via a published port
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Several Agent Sessions on screen at once, collapsible tool calls, file edits rendered as diffs,
|
|
237
|
+
per-pane transcript search, provider-grouped model picker, Steering Queue depth and context usage —
|
|
238
|
+
the surface M6 rebuilds, one Agent Session on screen at a time.
|
|
239
|
+
|
|
240
|
+
The browser ran **the same reducer as the TUI**, not a copy: `src/client/reduce.ts` and
|
|
241
|
+
`src/client/diff.ts` imported only types, so stripping left standalone ESM with no imports — served
|
|
242
|
+
as `/reduce.js` and `/diff.js`, no bundler — and a test loaded what the Session Host actually served
|
|
243
|
+
and asserted it produced state identical to the TypeScript reducer. **Superseded by M6**, which has
|
|
244
|
+
the browser import the reducer instead of being handed it.
|
|
245
|
+
|
|
246
|
+
Assets are served from a manifest held in memory, so a single-executable build has nothing to find on
|
|
247
|
+
disk at runtime. Nothing generated is committed: `src/web/embedded.ts` exports an empty manifest that
|
|
248
|
+
`npm run build:binary` replaces at bundle time, and a source run builds `web/dist` (`prestart`) and
|
|
249
|
+
reads it through the same `manifestOf()` the binary build uses (ADR 0017). Starting without a build
|
|
250
|
+
is refused rather than silently serving nothing.
|
|
251
|
+
|
|
252
|
+
The `/auth` handoff exists because a browser cannot put an `Authorization` header on a navigation or
|
|
253
|
+
an `EventSource`: the token goes into an HttpOnly cookie once, and the UI itself — not just the API
|
|
254
|
+
— requires it. An externally reachable personal deployment should use the OIDC gate below instead.
|
|
255
|
+
|
|
256
|
+
### External OIDC gate
|
|
257
|
+
|
|
258
|
+
Flow can delegate browser admission to any standards-compliant OpenID Provider while preserving the
|
|
259
|
+
bearer header used by CLI/TUI clients. This is a **shared personal deployment**, not multi-user
|
|
260
|
+
isolation: every person admitted by the issuer has full access to every Agent Session, Shell, file,
|
|
261
|
+
secret and Setting the daemon can reach.
|
|
262
|
+
|
|
263
|
+
Configure all four variables or none. Partial or invalid configuration fails before the daemon
|
|
264
|
+
listens; unconfigured deployments keep the local `/auth?token=…` behaviour.
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
export FLOW_OIDC_ISSUER=https://id.example.com
|
|
268
|
+
export FLOW_OIDC_CLIENT_ID=flow
|
|
269
|
+
export FLOW_OIDC_CLIENT_SECRET='replace-me'
|
|
270
|
+
export FLOW_OIDC_PUBLIC_APP_URL=https://flow.example.com
|
|
271
|
+
flow serve --port 4318 # keep loopback when the proxy is on this host
|
|
272
|
+
# or --address 0.0.0.0 in an isolated container network
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Register these URLs at the issuer:
|
|
276
|
+
|
|
277
|
+
- redirect URI: `https://flow.example.com/oauth/callback`
|
|
278
|
+
- back-channel logout URI: `https://flow.example.com/oauth/backchannel`
|
|
279
|
+
|
|
280
|
+
The issuer must support OIDC discovery, Authorization Code, a confidential client authentication
|
|
281
|
+
method (`client_secret_basic` or `client_secret_post`), signed ID tokens, S256 PKCE, refresh tokens,
|
|
282
|
+
and the `openid` scope. Flow requests `offline_access`. Back-channel logout is optional but required
|
|
283
|
+
for immediate revocation when the issuer disables a user; discovery alone cannot report an account
|
|
284
|
+
change. Logout inside Flow does not perform global issuer logout.
|
|
285
|
+
|
|
286
|
+
Terminate HTTPS at the reverse proxy and forward `/`, `/api`, `/assets` and `/oauth` to the daemon,
|
|
287
|
+
including HTTP upgrade for Shell WebSockets and streaming responses for SSE. `FLOW_OIDC_PUBLIC_APP_URL`
|
|
288
|
+
is the only browser origin Flow trusts in this mode. Do not rewrite it from request headers and do
|
|
289
|
+
not expose the daemon directly; Flow intentionally ignores `Forwarded` and `X-Forwarded-*` for its
|
|
290
|
+
security decisions. HTTP issuer/app URLs are accepted only for `localhost`, `127.0.0.1` or `::1`
|
|
291
|
+
development.
|
|
292
|
+
|
|
293
|
+
Provider tokens remain server-side. Flow persists them and opaque browser sessions under
|
|
294
|
+
`$FLOW_STATE_DIR/oidc/` (0700 directory, 0600 file, with no additional application-level encryption),
|
|
295
|
+
rotates refresh tokens, coordinates concurrent refreshes, and applies a seven-day absolute
|
|
296
|
+
browser-session lifetime. Flow logout, expiry, failed
|
|
297
|
+
refresh and valid back-channel notifications revoke the browser session and close its SSE/WebSocket
|
|
298
|
+
connections without ending Agent Sessions.
|
|
299
|
+
|
|
300
|
+
The daemon bearer token remains an explicit administrative bypass:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
curl -H "Authorization: Bearer $(cat "$FLOW_STATE_DIR/token")" \
|
|
304
|
+
https://flow.example.com/api/sessions
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
A bearer client does not enter OIDC and works remotely when the reverse proxy forwards the header.
|
|
308
|
+
Protect that token as full app access. In OIDC mode `/auth` is disabled and an old `flow=` cookie is
|
|
309
|
+
ignored, so the bypass cannot be handed to a browser through Flow.
|
|
310
|
+
|
|
311
|
+
A reproducible local Provider is included for integration testing:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
npm run test:oidc-issuer -- http://127.0.0.1:5173
|
|
315
|
+
# In another terminal, export the four variables it prints, start Flow on :4318, then `npm run dev`.
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
It performs discovery, S256 PKCE, confidential client authentication, signed ID/logout tokens and
|
|
319
|
+
refresh-token rotation. It auto-admits one fixed test subject and is for localhost testing only.
|
|
320
|
+
Nathan's separate OpenAuth-based issuer has not been compatibility-verified by this change.
|
|
321
|
+
|
|
322
|
+
**M5 (single executable) complete.** `npm run build:binary` produces `build/flow`: an esbuild
|
|
323
|
+
bundle injected into a copy of the `node` binary via Node SEA.
|
|
324
|
+
|
|
325
|
+
**Claude Code is a prerequisite for the binary, not a payload.** The Agent SDK spawns the CLI as a
|
|
326
|
+
child process, and a child needs a real file on disk, which a SEA blob cannot provide. Install it
|
|
327
|
+
separately (`npm i -g @anthropic-ai/claude-code`); the binary resolves `claude` from PATH, or from
|
|
328
|
+
`FLOW_CLAUDE_PATH`. Running from source is unaffected — the SDK finds its own copy.
|
|
329
|
+
|
|
330
|
+
Building on macOS additionally needs Xcode command line tools: injection invalidates the `node`
|
|
331
|
+
binary's code signature, so the build strips it, injects into a `NODE_SEA` Mach-O segment, then
|
|
332
|
+
re-signs ad hoc. Without that the kernel SIGKILLs the binary at launch and prints only `killed`.
|
|
333
|
+
|
|
334
|
+
Five things the build needed:
|
|
335
|
+
|
|
336
|
+
- **`import.meta.url` becomes `undefined` in a CommonJS bundle**, which breaks the
|
|
337
|
+
`createRequire(import.meta.url)` calls inside bundled dependencies. The build defines it as a real
|
|
338
|
+
file URL.
|
|
339
|
+
- **pi is loaded lazily** (`src/backend/registry.ts`). It is ESM-only and pulls in native and wasm
|
|
340
|
+
packages, so a bundle cannot require it at startup. On demand, its absence is a clear error when
|
|
341
|
+
you ask for a pi session rather than a crash at launch — the binary is Claude-only unless pi is
|
|
342
|
+
installed alongside it.
|
|
343
|
+
- **The CLI is spawned directly, not through `process.execPath`.** The SDK runs the CLI as
|
|
344
|
+
`<node> <cli-path> …` using `process.execPath` as the interpreter — but inside a single executable
|
|
345
|
+
that *is* the Flow binary, so the spawn re-invokes Flow with the CLI's arguments,
|
|
346
|
+
argument parsing rejects them, and it surfaces as `Claude Code process exited with code 1`. A
|
|
347
|
+
`spawnClaudeCodeProcess` override executes the CLI path itself. It rewrites *only* interpreter
|
|
348
|
+
spawns: a native Claude Code install is spawned with no interpreter at all, so the binary is
|
|
349
|
+
already the command and `args[0]` is a real flag. Hoisting it there executes `--output-format` as
|
|
350
|
+
a program, and the SDK reports that as "native binary exists but failed to launch — probably a
|
|
351
|
+
libc mismatch", which is not what went wrong.
|
|
352
|
+
- **Native `esbuild`, after a spell on `esbuild-wasm`.** The wasm build was chosen to keep the
|
|
353
|
+
lockfile portable: the native package resolves to a per-platform binary, so one installed on macOS
|
|
354
|
+
looked as though it would leave the Linux build broken. It never would have — `package-lock.json`
|
|
355
|
+
is lockfileVersion 3 and records every platform's optional binary rather than the host's, as it
|
|
356
|
+
already did for both agent SDKs and now does for M6's Rolldown and lightningcss bindings too, and
|
|
357
|
+
`npm ci` picks the right one per OS. The shim was defending a property the tree does not have, at
|
|
358
|
+
the price of shipping two esbuilds. The switch produced a byte-identical bundle and took
|
|
359
|
+
`logLevel: "silent"` with it — that existed only because the wasm stdio shim threw writing its own
|
|
360
|
+
summary to a pipe, and the native package writes nothing there at all.
|
|
361
|
+
- **The packaging asymmetry held**, exactly backwards from intuition: pi is in-process and would
|
|
362
|
+
bundle cleanly if not for its native deps, while Claude — the one that looks like a library — is
|
|
363
|
+
the one needing an external executable.
|
|
364
|
+
|
|
365
|
+
**M6 (the web client is bundled) in progress.** The browser client is a Vite and React application
|
|
366
|
+
in `web/`, and it *imports* `src/client/reduce.ts` as TypeScript rather than being served that file
|
|
367
|
+
with its types stripped.
|
|
368
|
+
|
|
369
|
+
M4's arrangement is reversed deliberately. Importing the reducer makes two copies of it impossible
|
|
370
|
+
for the compiler's reasons rather than a test's, and it lifts the ceiling that arrangement imposed:
|
|
371
|
+
nothing shared could import a value, which is why `src/client/diff.ts` compares lines naively. So
|
|
372
|
+
`src/client/` stops being only the shared reducer and becomes the shared front-end core — reducer,
|
|
373
|
+
transport, and the presentation logic both clients need — under a standing rule that everything in
|
|
374
|
+
it stays free of DOM types, because the TUI compiles it under a program that has none.
|
|
375
|
+
|
|
376
|
+
The Session Host learns nothing about Vite. `prebuild:binary` builds `web/dist` and the binary build
|
|
377
|
+
turns it into the manifest it injects; the rest of the chain is untouched. What the host gained is a
|
|
378
|
+
manifest instead of six hard-coded files: content-hashed assets served
|
|
379
|
+
`public, max-age=31536000, immutable`, the Entry Document `no-store` — which is doing real work,
|
|
380
|
+
since an immutably cached one would pin a browser to a deleted asset hash — and a fallback that
|
|
381
|
+
answers an unknown path with the Entry Document so a deep-linked Agent Session survives a reload,
|
|
382
|
+
with `/api` and `/assets` excluded, because a missing hashed chunk answered with HTML costs an hour
|
|
383
|
+
to diagnose.
|
|
384
|
+
|
|
385
|
+
The cost is that drift changes shape rather than going away. Two gates stand in for the test that
|
|
386
|
+
used to execute the served bytes: the build refuses to emit a bundle whose module graph lacks the
|
|
387
|
+
shared client modules, and `test/assets-embedding.test.ts` holds the manifest generator to the
|
|
388
|
+
content types, the base64 boundary and the `immutable` rule the host assumes. Staleness itself is
|
|
389
|
+
not among them, because the manifest is generated by the build that embeds it and cannot lag the
|
|
390
|
+
sources it was built from. Nothing typechecks the embedded bytes any more either — they are
|
|
391
|
+
`JSON.stringify` of a plain object, and the generator is what is tested instead.
|
|
392
|
+
|
|
393
|
+
The UI is master–detail: a sidebar of Agent Sessions and exactly one of them focused in a pane, where
|
|
394
|
+
M4 opened a pane per Agent Session. One at a time is the design rather than a limitation of it — the
|
|
395
|
+
rail carries the state of the others, banded most alive first, and a dot, a Subagent count, a queue
|
|
396
|
+
depth and a relative time per row is enough to monitor any number of them without reading them. Ten modules are
|
|
397
|
+
shared with the terminal client rather than the three the old arrangement allowed, so the model and
|
|
398
|
+
Effort pickers, the status predicates, transcript search and the relative clock are now one
|
|
399
|
+
implementation each instead of two that had already drifted. Styling is stock shadcn/ui on Base UI
|
|
400
|
+
primitives, with no bespoke palette to learn: the six states an Agent Session can be in are mapped
|
|
401
|
+
onto shadcn's own chart tokens, and monospace is kept only where character alignment carries meaning
|
|
402
|
+
— transcript text, tool output, diffs and Scope paths.
|
|
403
|
+
|
|
404
|
+
Nothing automatically proves the shipped bundle renders. The compiler, the module-graph check and the
|
|
405
|
+
hash all prove things about the bundle rather than about the app working, and closing that gap needs
|
|
406
|
+
a browser-driven smoke test that is designed but deferred.
|
|
407
|
+
|
|
408
|
+
## Development
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
npm install
|
|
412
|
+
npm run typecheck # four programs: host, web presentation logic, web app, its Vite config
|
|
413
|
+
npm test
|
|
414
|
+
npm run spike:auth # re-verify subscription auth
|
|
415
|
+
npm run test:oidc-issuer -- http://127.0.0.1:5173 # local standards test Provider
|
|
416
|
+
|
|
417
|
+
FLOW_ASSETS=1 npm test # adds a Vite build, to prove the embedder handles everything it emits
|
|
418
|
+
FLOW_E2E=1 npm test # adds the live Claude contract (spends tokens)
|
|
419
|
+
FLOW_E2E_PI=1 npm test # adds the live pi contract (needs pi credentials)
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
All three stay out of the default loop for the same reason: `npm test` should need no credentials,
|
|
423
|
+
no network and no bundler, so a fresh clone with no `web/dist` — and an `--omit=dev` install with no
|
|
424
|
+
Vite at all — still runs it green. That holds by construction now rather than by care: no test
|
|
425
|
+
reaches a build output, and the ones about serving a web client are handed a fixture
|
|
426
|
+
(`test/assets-fixture.ts`).
|
|
427
|
+
|
|
428
|
+
### The rail
|
|
429
|
+
|
|
430
|
+
Drag its right edge to resize — 180px to 520px, remembered per browser in `localStorage`. Click that
|
|
431
|
+
same edge, or press ⌘B / Ctrl-B, to hide it entirely and give the Presentation Transcript the width.
|
|
432
|
+
The handle takes arrow keys when focused (Shift for a coarser step), because a drag handle that only
|
|
433
|
+
answers to a pointer is unusable without one.
|
|
434
|
+
|
|
435
|
+
The drag deliberately does not go through React: it writes `--sidebar-width` onto the provider
|
|
436
|
+
wrapper and commits to state once, on release. Routing it through state re-rendered the rail and the
|
|
437
|
+
transcript once per frame, and shadcn's own `transition-[width] duration-200` — which the open/close
|
|
438
|
+
slide needs — made the rail chase the pointer two frames behind. `data-resizing` on the wrapper
|
|
439
|
+
suppresses that transition for the length of the gesture and nothing else.
|
|
440
|
+
|
|
441
|
+
The width is remembered; whether the rail is open is not. Reloading into an app with no visible
|
|
442
|
+
navigation is a bad first frame, and hiding the rail is a momentary "give me the width" rather than a
|
|
443
|
+
preference — so it is browser state either way and never a Setting, which would make a laptop and a
|
|
444
|
+
desktop fight over one number.
|
|
445
|
+
|
|
446
|
+
⌘B is what shadcn's Sidebar binds and the muscle memory is worth matching, but it is resolved by
|
|
447
|
+
`web/src/presentation/bindings.ts` like every other key rather than by the component's own `window`
|
|
448
|
+
listener, which is removed. See the FLOW note in `web/src/components/ui/sidebar.tsx`.
|
|
449
|
+
|
|
450
|
+
### Settings
|
|
451
|
+
|
|
452
|
+
Everything configurable lives in one file, `<stateRoot>/config.json`, and is editable from the web
|
|
453
|
+
UI at **Settings** — the gear at the bottom-left of the rail, or `?` for the Keyboard section.
|
|
454
|
+
Settings are machine-wide: they govern every Agent Session on the machine, not one Scope.
|
|
455
|
+
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"retention": { "settled": "1d" },
|
|
459
|
+
"fonts": {
|
|
460
|
+
"chrome": "'Inter Variable', sans-serif",
|
|
461
|
+
"monospace": "'MesloLGS NF', monospace"
|
|
462
|
+
},
|
|
463
|
+
"projects": {
|
|
464
|
+
"root": "~/workspace",
|
|
465
|
+
"include": ["work/api", "e2e", "/srv/elsewhere/thing"]
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
| Setting | Meaning | Default |
|
|
471
|
+
| --- | --- | --- |
|
|
472
|
+
| `retention.settled` | How long a Settled Agent Session survives before it is reaped. A duration — `90m`, `36h`, `1d` — or `never`. | `1d` |
|
|
473
|
+
| `fonts.chrome` | The interface typeface: labels, transcript prose, buttons. | `'Inter Variable', sans-serif` |
|
|
474
|
+
| `fonts.monospace` | The Shell's terminal, and the chrome that aligns character by character. | a Nerd Font stack (below) |
|
|
475
|
+
| `projects.root` | The Project Root: where Candidates are looked for, and what Flow opens on. Absolute or `~`-relative. | none |
|
|
476
|
+
| `projects.include` | The Projects, opted into. Each entry is relative to the Project Root, or absolute. | none |
|
|
477
|
+
|
|
478
|
+
Any section may be omitted and keeps its default. The file is read **leniently** and written
|
|
479
|
+
**strictly**, deliberately: a typo on disk costs only its own default and warns on startup, because
|
|
480
|
+
it must not stop the daemon that owns your Presentation Transcripts from starting — whereas a value
|
|
481
|
+
sent from the browser is refused with the field named, because there is someone waiting who can fix
|
|
482
|
+
it. The Session Host reads the file through one owner (`src/daemon/config-store.ts`) rather than
|
|
483
|
+
copying values at startup, so an edit applies to the running daemon: retention takes effect at the
|
|
484
|
+
next hourly sweep, and a typeface immediately.
|
|
485
|
+
|
|
486
|
+
Shortening `retention.settled` arms a delete. Nothing is removed on save — the sweep does it, within
|
|
487
|
+
the hour — but the Settings page counts the Agent Sessions the new window newly reaches and makes you
|
|
488
|
+
confirm before saving. Only Settled Agent Sessions are ever reaped; an Ended one stays on disk.
|
|
489
|
+
|
|
490
|
+
#### MCP connections
|
|
491
|
+
|
|
492
|
+
Use **Settings → MCP** to add a local command and its arguments, or a remote Streamable HTTP URL.
|
|
493
|
+
Connections are selected by default for new Agent Sessions; turn off the switch to change that default.
|
|
494
|
+
The New Agent Session page lets you choose the connections for that Agent Session.
|
|
495
|
+
|
|
496
|
+
Revive keeps the selected IDs and uses the latest definitions. Edits and deletions do not change an
|
|
497
|
+
open Backend Session. Subagents and Workflow Steps inherit its connections and existing permission
|
|
498
|
+
rules. Pi parent turns and ordinary Subagents still run tools without Flow Permission Prompts.
|
|
499
|
+
|
|
500
|
+
Connection startup does not block Agent Session creation. The first model prompt and Workflow Step
|
|
501
|
+
wait for bounded discovery and tool registration, then proceed even if connections fail. Its MCP
|
|
502
|
+
status shows failures and **Retry**. Retry requires no parent turn, Subagent, Background Call, or
|
|
503
|
+
Workflow Step in flight; new model work waits until Retry finishes.
|
|
504
|
+
For OAuth, select **Sign in**, complete authorization, then return to Flow and select **Retry**.
|
|
505
|
+
OAuth uses one machine-wide identity per connection. Credentials are kept separately from Settings
|
|
506
|
+
in `mcp-credentials.json` with private file permissions. OAuth servers must support dynamic client
|
|
507
|
+
registration. Resources, prompts, and legacy HTTP+SSE are not supported.
|
|
508
|
+
|
|
509
|
+
#### Projects
|
|
510
|
+
|
|
511
|
+
A **Project** is a directory you have opted into starting Agent Sessions from — a *candidate* Scope,
|
|
512
|
+
not a Scope. `projects.include` is the list, and it is the whole of it. A repository Flow can
|
|
513
|
+
see beneath the Project Root is a **Candidate** until it appears there:
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
~/workspace projects.include Offered in the dialog
|
|
517
|
+
├── work/
|
|
518
|
+
│ ├── api/.git Candidate → "work/api" ✓ api (under "work")
|
|
519
|
+
│ └── web/.git Candidate –
|
|
520
|
+
├── mono/.git Candidate → "mono/packages/api" ✓ api (under "mono/packages")
|
|
521
|
+
│ └── packages/api ↑ found by search, not offered as a Candidate
|
|
522
|
+
├── notes/ → "notes" ✓ notes (not a repo)
|
|
523
|
+
└── old-thing/.git Candidate –
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Curation is the point: a root full of repositories is mostly repositories you are not working on
|
|
527
|
+
today. Settings → **Projects** is where the list is built, three ways:
|
|
528
|
+
|
|
529
|
+
- **Candidates** — the repositories found beneath the Project Root, one click each. Found by the
|
|
530
|
+
same walk as before: a directory holding a `.git` is a Candidate, a repository is never looked
|
|
531
|
+
inside (so `node_modules` and build output stay out with no blacklist), three levels deep, hidden
|
|
532
|
+
directories and symlinks skipped.
|
|
533
|
+
- **Any directory** — a search field, because the useful directory is often one no Candidate walk
|
|
534
|
+
would offer. Type a **name** and it fuzzy-matches beneath the Project Root, *reaching inside*
|
|
535
|
+
repositories, which is how `mono/packages/api` is reachable at all. Start with `/` or `~` and it
|
|
536
|
+
completes a **path** anywhere on the machine instead — that is the escape hatch for a Project
|
|
537
|
+
outside the root. The rule is the first character, so `work/api` is still a name, and narrows.
|
|
538
|
+
- **Project Root** — what the other two can see. Clearing it does not clear your Projects; an
|
|
539
|
+
absolute entry does not need it.
|
|
540
|
+
|
|
541
|
+
An opted-in directory need not be a repository, because you chose it deliberately and nothing has to
|
|
542
|
+
guess whether you meant it. An entry whose directory has since gone is **marked**, not dropped —
|
|
543
|
+
silently hiding it would look identical to the Setting having failed to save.
|
|
544
|
+
|
|
545
|
+
Until something is opted in there are no Projects, so the New Agent Session dialog behaves as it
|
|
546
|
+
did before this existed: one prefilled Scope field. Once there is at least one, the dialog leads
|
|
547
|
+
with a Project picker, the Scope field starts empty, and `n` opens with the picker focused — so `n`,
|
|
548
|
+
a few letters, Enter, Enter starts a session in the right repository. The Scope field stays
|
|
549
|
+
editable throughout, for the directory you did not opt in.
|
|
550
|
+
|
|
551
|
+
`flow tui` uses the Project Root when `--scope` is absent. A one-shot
|
|
552
|
+
`flow "<prompt>"` does not: it is run *in* a directory, so that directory is the right
|
|
553
|
+
default and `--scope` is how you say otherwise.
|
|
554
|
+
|
|
555
|
+
#### Fonts
|
|
556
|
+
|
|
557
|
+
**Set `monospace` to a Nerd Font if your prompt is a Powerline one.** Those separators are Private
|
|
558
|
+
Use Area codepoints — U+E0B0 for the arrow, U+E0A0 for the branch — and no stock system font carries
|
|
559
|
+
them, so a shell prompt that uses them renders as tofu until the terminal is told a font that has
|
|
560
|
+
them. Nothing is bundled: the right font is whichever is already installed on the machine doing the
|
|
561
|
+
reading, so the default stack names the common patched families (`MesloLGS NF`,
|
|
562
|
+
`JetBrainsMono Nerd Font`, `FiraCode Nerd Font`, `Hack Nerd Font`) ahead of the stock ones and picks
|
|
563
|
+
whichever it finds. The defaults live in `src/protocol/fonts.ts`, which is the only copy —
|
|
564
|
+
`web/src/index.css` restates them for the first frame and `test/fonts.test.ts` holds the two
|
|
565
|
+
together.
|
|
566
|
+
|
|
567
|
+
A Shell — a terminal the web client draws in one tab of a Dock, the tabbed region below an Agent
|
|
568
|
+
Session's transcript or beside it — needs a pty, which is a native addon. `npm install` builds it,
|
|
569
|
+
and where it cannot be loaded the host reports `shell: false` on `/api/config` and the web client
|
|
570
|
+
offers no Docks at all rather than a picker with nothing in it. A SEA blob cannot contain a native addon, so the binary from `npm run build:binary` has to
|
|
571
|
+
find `node-pty` on disk: it will on the machine that built it, and will not once shipped elsewhere,
|
|
572
|
+
where it reports `shell: false` and serves no Shells (ADR 0008).
|
|
573
|
+
|
|
574
|
+
Working on the web client means a Session Host to talk to, so start the host first:
|
|
575
|
+
|
|
576
|
+
```bash
|
|
577
|
+
npm start -- serve --port 4318 # terminal one: the Session Host
|
|
578
|
+
npm run dev # terminal two: Vite on 127.0.0.1:5173
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
The dev server finds the host through `daemon.json`, or `FLOW_URL` if you set it, and it
|
|
582
|
+
resolves that target once at startup — which is why the host wants a fixed `--port` rather than the
|
|
583
|
+
ephemeral one it picks by default. It proxies `/api`, `/auth` and `/oauth` through, so the browser stays on
|
|
584
|
+
one origin; that single origin is what lets the Session Host go on checking `Origin` strictly with
|
|
585
|
+
no CORS.
|
|
586
|
+
|
|
587
|
+
Do the cookie handoff on **the URL the dev server prints**, not the one the host prints.
|
|
588
|
+
`localhost`, `127.0.0.1` and `[::1]` are three different cookie hosts on one machine, so a cookie
|
|
589
|
+
taken on the host's is not sent to the dev origin, which then answers 401. And `/auth` redirects to
|
|
590
|
+
a relative `/` — which is what makes it work through a proxy at all — so following the host's own
|
|
591
|
+
URL lands you on the built client rather than on the dev server, with none of your unbuilt changes
|
|
592
|
+
in it.
|
|
593
|
+
|
|
594
|
+
Do not install with `npm ci --omit=optional`. Rolldown, lightningcss and esbuild all resolve their
|
|
595
|
+
native bindings through optional dependencies, so omitting them installs cleanly and then fails at
|
|
596
|
+
build time with an unhelpful "cannot find native binding".
|
|
597
|
+
|
|
598
|
+
CI (`.github/workflows/ci.yml`) runs the typecheck, the tests and the binary build. There is no
|
|
599
|
+
rebuild-and-diff step, because nothing generated is committed; the binary build is what proves the
|
|
600
|
+
web client can still be built and embedded.
|
|
601
|
+
|
|
602
|
+
Sources under `src/`, `test/` and `web/src/presentation/` are run through Node's
|
|
603
|
+
`--experimental-strip-types`, so TypeScript there is limited to erasable syntax: no parameter
|
|
604
|
+
properties, enums, or namespaces. Relative imports carry the `.ts` extension and are rewritten on
|
|
605
|
+
build. The rest of `web/` is Vite's and free of that constraint — but `src/client/**` is not,
|
|
606
|
+
however browser-facing it becomes, because the TUI still runs it stripped.
|
|
607
|
+
|
|
608
|
+
### Direct MCP Workflow Steps
|
|
609
|
+
|
|
610
|
+
In **Settings → Workflows**, choose **Add MCP**, select an Agent Session and one of its enabled
|
|
611
|
+
MCP servers, then **Discover tools**. Select the original tool name and compose its arguments using
|
|
612
|
+
literals and available workflow-input/predecessor references. The editor provides JSON Schema
|
|
613
|
+
fields, local references, alternatives, conditional/dependent fields, arrays/tuples and additional
|
|
614
|
+
properties, with the original constraints available for inspection. Validation uses the original
|
|
615
|
+
schema, not a reduced visual approximation. Unknown dialects, formats or validation keywords fail
|
|
616
|
+
explicitly; no constraint is silently discarded. Supported dialects are draft-07, 2019-09 and
|
|
617
|
+
2020-12 (the MCP default).
|
|
618
|
+
|
|
619
|
+
Direct steps support both stdio and Streamable HTTP, including existing OAuth sign-in. They make
|
|
620
|
+
no model call, create no Subagent and add no model tokens. Code-runtime sandbox settings do not
|
|
621
|
+
apply: a stdio server runs as the host user, and HTTP calls use the configured remote service.
|
|
622
|
+
Credentials belong in MCP Settings, never in workflow arguments. Expired/missing authentication
|
|
623
|
+
requires signing in there and a manual Retry; executions never launch a login flow or replay an
|
|
624
|
+
HTTP tool request after a 401.
|
|
625
|
+
|
|
626
|
+
The result is always `{ structuredContent: JSON | null, content: MCPContentBlock[] }`. Absent
|
|
627
|
+
structured content becomes null; text is not parsed as JSON, and links are not downloaded.
|
|
628
|
+
Map `structuredContent` (or its fields) into an Agent's input to review it directly. Successful
|
|
629
|
+
empty/not-found data stays successful and can drive a Branch. Tool errors retain bounded,
|
|
630
|
+
credential-redacted partial output. Results exceeding **100,000 UTF-8 bytes** fail without truncation.
|
|
631
|
+
|
|
632
|
+
Each execution pins connection configuration, server identity and original input/output schemas.
|
|
633
|
+
Changing the definition or reconfiguring a server never retargets an existing execution. Discovery
|
|
634
|
+
and each attempt revalidate these identities. Missing, disabled, changed or unauthenticated tools
|
|
635
|
+
require explicit reconfiguration rather than a fallback.
|
|
636
|
+
|
|
637
|
+
Ask mode prompts privately before **every call**, including single-step tests; auto-accept does not
|
|
638
|
+
prompt. The timeout defaults to **60 seconds**, configurable on the step. Existing failure/timeout
|
|
639
|
+
edges, loops, joins, Retry and Supply output work as for other steps. **Cancellation is not rollback:**
|
|
640
|
+
interrupted or timed-out writes may already have happened. Inspect the remote state before retrying.
|
|
641
|
+
See [the direct MCP execution decision](docs/adr/0025-direct-mcp-workflow-steps.md).
|