@vecteur/cli 0.10.0 → 0.12.4

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  One command line for Vecteur's public API. Sign in through your browser, then use the same
4
4
  Projects and run records as the web app. The client stores your credential locally; it never
5
- calls the OPE, engine or database directly.
5
+ calls the runner, engine or database directly.
6
6
 
7
7
  ```bash
8
8
  npm install -g @vecteur/cli
@@ -13,6 +13,13 @@ vecteur
13
13
  linked to this folder. A new folder creates its Project only when you send your first ask.
14
14
  No `init` command or file in the working directory is required.
15
15
 
16
+ One Run is one turn, executed in Vecteur cloud. A turn prints your ask, a working trace (one line
17
+ per tool call, with its result status), the answer, the files it produced and its terminal state:
18
+ `completed`, `failed`, `cancelled` or `budget`. A `budget` terminal adds the stop card: what the
19
+ server offers this reader (plan, usage). A question from Vecteur is its answer; your reply is your
20
+ next ask. A Project created before the current engine is read-only: an ask to it is refused
21
+ `project_read_only`, and its history stays readable.
22
+
16
23
  For scripts and explicit one-shot commands:
17
24
 
18
25
  ```bash
@@ -48,7 +55,7 @@ login. `project list --json` preserves `{projects, active_projects, selected_pro
48
55
  Run's `state_hash`) and submits the next turn on it, so two submits in a row are two turns of one
49
56
  study, exactly as in the web app. A new Project's first turn has no head. `--parent STATE_HASH`
50
57
  skips the read and admits the turn only if that hash is still the head. The CLI never forks a
51
- Project and never retries: a moved head exits `state_fork` naming the current head, and a Project
58
+ Project and never automatically retries: a moved head exits `state_fork` naming the current head, and a Project
52
59
  whose Run is still open exits `state_busy` naming that Run (and, when it waits on a question, the
53
60
  web address where it can be answered). Nothing is admitted in either case. Once a turn is admitted,
54
61
  any later failure names the Run: check it with `vecteur run get RUN_ID` instead of submitting
@@ -58,14 +65,17 @@ again, which would start another turn. Start a fresh study with `vecteur project
58
65
  embedded events match the stream. Redirects, secret-shaped responses, malformed responses and
59
66
  timeouts fail nonzero. `--json` sorts object keys for deterministic machine output.
60
67
 
61
- Human run output shows the sealed synthesis, input origins, artifact download commands, the typed
62
- terminal cause/recovery, and—after `run submit`—the selected Project's UTC-month customer cost using
63
- the server's display strings. Machine run output remains the unchanged canonical record. Artifact
68
+ Human run output shows the working trace, the answer, the files with their download commands, the
69
+ typed terminal state and cause, and—after `run submit`—the selected Project's UTC-month customer cost
70
+ using the server's display strings (at a `budget` terminal, the stop card instead). Machine run output remains the unchanged canonical record. Artifact
64
71
  downloads use the Project-scoped admitted CAS route, verify the declared length, media type and
65
72
  SHA-256, and refuse to overwrite a local path. Use `--project ID` when no Project is selected.
66
73
 
67
74
  `vecteur mcp` serves MCP over stdio using the same credentials and public client. It exposes
68
- `vecteur_project_get`, `vecteur_run_submit`, `vecteur_run_get` and `vecteur_run_events`.
75
+ `vecteur_project_get`, `vecteur_run_submit`, `vecteur_run_get`, `vecteur_run_events`, `vecteur_artifact_get` (digest-verified download into the working folder, never overwrites) and `vecteur_material_attach` (uploads one file from the working folder after you confirm the origin and the Project head; refuses read-only, foreign or moved-on Projects).
76
+ Pass material_attach's returned `selections` verbatim to `vecteur_run_submit` or `vecteur_run_start` for that Project. For multiple files, concatenate their `selections` arrays. These select the same extracts as CLI `--attach`; upload alone does not admit material to a Run. Omitting that Project's pending material in the same MCP session refuses with `selection_required` before admission; pending material in another Project does not block it. To deliberately abandon pending material, pass the optional boolean `discard_pending_material: true` to submit or start: it clears only that Project's pending tracking before admission and uses the supplied selections, or none if omitted. The discard remains effective if admission refuses; it does not delete uploaded files. Omitting the flag or passing `false` retains the guard. A file with no selectable extracts refuses with `extraction_unavailable`.
77
+ It also exposes `vecteur_run_start` and `vecteur_run_status` for long Runs. `vecteur_artifact_get`
78
+ takes a `cas_ref`, or a `run_id` with the file's `artifact_path`. `vecteur_run_submit` blocks and is suitable only for short asks.
69
79
  An MCP host supplies tool arguments; stdout carries only MCP protocol.
70
80
 
71
81
  `vecteur mcp setup claude` (or `codex`) runs that vendor's own `mcp add` once so your Claude Code
@@ -79,9 +89,74 @@ mode in which the vendor session appears inside Vecteur's TUI and web.
79
89
  new folder: `answer.md` (exact answer bytes), `run.json` (the canonical record) and every artifact,
80
90
  each verified against its SHA-256 CAS id. Nothing is overwritten.
81
91
 
92
+ ## Claude Code and Codex: attach, poll, export
93
+
94
+ Both vendors use the same lifecycle recipe. Sign in to Vecteur and to your vendor separately;
95
+ use `vecteur mcp setup claude` / `vecteur handoff claude`, or substitute `codex`. The installed
96
+ vendor command and its own permissions apply. These recipes have packed CLI/MCP fake-server
97
+ coverage; interactive Claude Code/Codex handoff acceptance is not yet recorded. Vecteur Runs
98
+ use your Vecteur plan; the generalist uses its own provider and billing. Data returned to the
99
+ generalist goes to that assistant's provider.
100
+
101
+ From the folder containing your inputs, choose the Project and pin its last Run's `state_hash`
102
+ as `H` (a 64-character lowercase hex hash). For a Project with no Run, use `--parent none`.
103
+ Choose a fresh request key of 8–64 letters, digits, `_` or `-`, then keep the command unchanged
104
+ for retries:
105
+
106
+ ```bash
107
+ vecteur run submit --no-wait --parent "$H" --request-key orbit-20261107-01 \
108
+ --attach orbit.csv requirements.txt -p PROJECT_ID --ask 'Plot this orbit' --json
109
+ # Read run_id from the acknowledgment, then poll until terminal is nonempty:
110
+ vecteur run get RUN_ID --json
111
+ # Optional validated event replay (the stream has the configured request timeout):
112
+ vecteur run events RUN_ID --json
113
+ # A question from Vecteur is the Run's answer: reply with a new submit on the new head.
114
+ vecteur run export RUN_ID -p PROJECT_ID --output orbit-result --json
115
+ ```
116
+
117
+ MCP hosts use `vecteur_run_start({project_id, ask, request_key, parent_state_hash})`, then poll
118
+ `vecteur_run_status({run_id})`. Start returns the RunAck plus the resolved `parent_state_hash`.
119
+ Status returns `{run_id, terminal, last_seq}`: one bounded record read, `terminal` empty while the
120
+ Run is open, last sequence `-1` when no events exist. Stopping polling detaches and never cancels
121
+ the Run.
122
+
123
+ `--attach` is explicit consent to upload exactly those files to the command's explicit or
124
+ selected Project at the authenticated origin, for Vecteur cloud and the Run's model provider.
125
+ It replaces inherited sources. The invocation grant is never persisted and does not change a
126
+ folder binding or saved Project selection. Paths must be inside the working folder; the same
127
+ Linux/Node qualification, exclusions, no-symlink reader, secret scan, eight-file, 8 MiB/file and
128
+ 32 MiB total limits as interactive selection apply. All extracts are selected. An unsafe member
129
+ of the initial set refuses before any file uploads. Neither filenames nor local paths enter
130
+ the admission/upload bodies. `--attach` applies only to `run submit --no-wait`.
131
+
132
+ With explicit `--parent H|none`, the CLI writes the exact admission body (ask, parent, source
133
+ handles and selections) before dispatch, in a no-overwrite 0600 `request-<key-digest>.json` file
134
+ beside `credentials.json`. Retain that file for recovery. A retry with the same command reuses
135
+ its handles without rereading local files or the head, even if both changed. Changing the ask,
136
+ parent, Project or attachment set with the same key refuses `request_key_reused`. The shared
137
+ admission-intent journal remains in force through a dropped response or killed process.
138
+
139
+ Without `--parent`, the client resolves the head once and reports that parent in its response
140
+ or admission error. This convenience mode has no frozen request file. An interrupted request
141
+ without that file remains `admission_unresolved`; a conflicting same-key retry also reports
142
+ `admission_unresolved`. Inspect Project history before choosing a new key. No newest Run is
143
+ presented as recovered, and the client never generates a replacement key. Transport, timeout,
144
+ pending, unknown and malformed-ack errors carry the request key and parent once resolved.
145
+ Only `run submit --no-wait` emits one JSON error object on stderr
146
+ (`code`, `message`, optional `run_id`, `request_key`, `parent_state_hash`); stdout holds only the
147
+ success record. Existing blocking CLI and MCP success outputs and CLI error bytes are preserved;
148
+ MCP errors may additionally name an admitted `run_id`.
149
+
150
+ `run export` and `artifact get` keep their verified no-overwrite behavior. New MCP local-file
151
+ tools (`vecteur_input_add`, `vecteur_artifact_save`) remain gated on integration-doors §6.1.
152
+
82
153
  ## Interactive session
83
154
 
84
- Enter sends; Ctrl+J or Alt+Enter inserts a line. Bracketed paste is one edit and never sends.
155
+ Enter sends; Ctrl+J or Alt+Enter inserts a line. In rich mode, bracketed paste is one edit and never sends.
156
+ Plain mode and `TERM=dumb` emit no escape bytes: only an input read consisting exactly of CR or
157
+ CRLF submits. A read containing text before its final CR/CRLF stays a draft; all CR/CRLF delimiters
158
+ in that read become newlines. An unmarked paste split into a lone CR/CRLF read can therefore
159
+ submit early; coalesced text and Enter stay in the draft.
85
160
  The rich view uses normal terminal scrollback. `vecteur --plain` gives a linear view;
86
161
  `NO_COLOR=1 vecteur` or `--no-color` removes styling. `TERM=dumb` selects the linear view.
87
162
  Bare invocation in a pipe or CI keeps the previous status output; `vecteur status` always prints it.
@@ -89,21 +164,62 @@ Bare invocation in a pipe or CI keeps the previous status output; `vecteur statu
89
164
  - `/project` chooses a Project for this session; `/link` saves the folder association.
90
165
  `/unlink` removes that association for this subtree and preserves the draft. `/name` renames
91
166
  the current Project or names the one created on first send. `/history` loads older Runs on demand.
92
- - `/model` selects the next Run's model or route from the matched server catalogue. `/mode`
93
- explains leadership, execution location and payer. Stage 1 runs in Vecteur cloud.
94
- - `/attach <path>` previews a selected file and asks before uploading on send. Up to eight
95
- files, 8 MiB each and 32 MiB total; all available extracts are selected. `/clear-files` removes
96
- pending attachments. Nothing scans your directory or uploads unrelated files.
97
- - `/answer` handles clarification, including multiple choices and custom text. `/steer <text>`
98
- and `/answer-now` submit instructions; acceptance is distinct from execution.
167
+ - `/model` selects the next Run's model from the product's model choices (Auto is the default).
168
+ `/mode` explains model, execution location and payer. Runs execute in Vecteur cloud.
169
+ - `@` completes local paths. A whole filename in your ask offers attachment after local
170
+ checks (at most three offers; ambiguous basenames list choices).
171
+ A refused name prints `name: not offered (reason)` and asks whether to send without it.
172
+ Without a grant, ordinary named files are offered by name and size without reading
173
+ their content. Accepting an offer leads to the common first-use permission card; only after
174
+ confirmation is content read and scanned. Credential-shaped content refuses `secret_suspected`
175
+ before upload. With a grant, content is also checked before offering.
176
+ Directory listings and ignore-policy reads stay local.
177
+ `/attach <path>` selects metadata inside the session folder, including before its first send.
178
+ Absolute paths must lie inside that folder; outside paths now refuse `outside_folder`.
179
+ First send asks for `select` and `save-new` permission, naming the folder, Project and origin.
180
+ Send-first and save cards print their full disclosure and every file's selection state to
181
+ scrollback once on opening; a short question and its choices stay live.
182
+ Nothing leaves this computer unless you confirm it. Selected content uploads to Vecteur cloud
183
+ and the Run's model provider route; local residency is not guaranteed. The composer states
184
+ the upload destination. Declining keeps the draft and selections and reads no selected content.
185
+ Up to eight files, **8 MiB each** (reduced from 16 MiB) and 32 MiB total; all available extracts
186
+ are selected. `/clear-files` removes pending selections. A retry of an admitted upload uses
187
+ its frozen source handle and never rereads the local file.
188
+ - An ask sent while a Run is working is kept as your draft; send it when the Run ends.
99
189
  - `/cancel` or double Esc requests cloud Run cancellation. Ctrl+D on an empty composer or
100
190
  `/quit` detaches; the cloud Run continues. Ctrl+C clears a nonempty composer.
101
- - `/files` lists outputs; `/download <number> [path]` verifies bytes and refuses overwrite.
191
+ - After a terminal head Run, a save-new prompt offers absent artifact paths, including missing
192
+ parent directories. Identical bytes preselect the shortest path; `d` shows every path and
193
+ lets you choose any. `yes` installs verified bytes without overwriting, `n` declines.
194
+ This writes once; it makes no synchronization or latest-version promise.
195
+ `/files revoke` ends local permission and withdraws pending proposals. Unlink, any bind/relink
196
+ (even to the same Project and with an explicit session selection), another `/project`, logout
197
+ and root replacement also end permission. `/project` without linking works with fresh consent.
198
+ When a returned path already exists, Vecteur offers a separate proposal:
199
+ `<path>.vecteur-<run8>-<rev>` (collision suffixes `-1` through `-99`). The original is kept.
200
+ Before local read consent, inspection uses metadata only. First-use approval permits the
201
+ comparison, then an informed proposal confirmation; `d` also requires explicit read consent.
202
+ Revoked permission requires fresh consent for `/files diff N`.
203
+ `d` displays `local now → proposed` and, when retained, `base → local now`; diffs are bounded
204
+ and sanitized. The prompt labels **clean**, **local changed**, or **first sync**; identical
205
+ bytes need no write. A target edit or deletion before the approval commits withdraws it,
206
+ refreshes the comparison and requires fresh confirmation. This check does not lock your editor.
207
+ Review and adopt using your own editor or the printed `mv -i -- …` command. Vecteur never
208
+ replaces, renames, moves or deletes the original or a published proposal. `/files` lists
209
+ proposals and `/files diff N` compares their recorded CAS bytes with the current original.
210
+ Adoption is observed when the original matches a recorded proposal, including after restart
211
+ or adoption by move. The next unchanged turn then compares with that adopted baseline.
212
+ Uploaded, saved, adopted and previously observed existing paths are never automatically offered again after deletion, even with changed bytes;
213
+ `/files save N` explicitly offers one again. History is scoped to origin/account/root/Project.
214
+ Cloud and pending `/files` rows remain available when local authority is unavailable (including
215
+ Viewer access and unqualified platforms); optional local observation reports a notice.
216
+ `/files` lists inputs/outputs; `/download <number> [path]` verifies bytes and refuses overwrite.
102
217
  `/copy [path]` preserves the exact answer: terminal clipboard when supported, otherwise a file.
103
218
  - `/resume` reconciles an interrupted submission using its original identity, or follows the
104
219
  same Run from its validated event cursor. A moved head requires an explicit new send.
105
220
  Unknown admission remains pending if authority or transport prevents reconciliation.
106
- - `/details [number]`, `/web`, `/doctor` and `/help` expose details, browser access, diagnostics
221
+ - `Ctrl+O` and `/details [number]` print the full human tool block (changed files, excerpts and code summary).
222
+ - `/web`, `/doctor` and `/help` expose details, browser access, diagnostics
107
223
  and commands. Updates are manual; an incompatible origin supplies its required install command.
108
224
 
109
225
  Folder links are scoped by origin, authenticated account and canonical directory identity.
@@ -120,10 +236,87 @@ overwrite another editor, and admission consumes only its exact draft revision.
120
236
  request evidence stays until resolved. Account draft recovery requires the same credential fingerprint
121
237
  previously bound by a successful account read. Never-signed-in drafts occupy a separate unsigned
122
238
  namespace with no Project authority; only explicit login transfers them into an account. Neither
123
- recovery path grants server access. Attachments are held in
124
- memory until send and must be selected again after restart. A newer store version is refused without
239
+ recovery path grants server access. Selections hold metadata until send and must be selected
240
+ again after restart. A newer store version is refused without
125
241
  rewriting it. Previous CLI versions ignore the separate folder registry.
126
242
 
243
+ ## Local file authority limits
244
+
245
+ Selection and automatic save-new require **Linux and Node >=20.8**. Other platforms and older
246
+ Node versions refuse these capabilities with `platform_unqualified`; cloud commands still work.
247
+ A folder link supplies no permission. Viewer Projects cannot acquire file authority, upload
248
+ inputs, admit Runs or retry them; the server checks EDITOR for both cookies and PATs, and checks
249
+ EDITOR before fetching a Drive import.
250
+
251
+ The fixed exclusions cover credential/vendor directories, `.git`, `.env*`, private-key names,
252
+ `node_modules` and the CLI store; nested `.gitignore`, `.vecteurignore` and root `.git/info/exclude`
253
+ apply with git precedence. A `.git` gitfile is denied and never followed; it supplies no
254
+ `.git/info/exclude`. Unknown/unreadable policy excludes its subtree. If optional filename
255
+ discovery is unavailable, the CLI says so and a plain ask still submits without offers.
256
+ Global `core.excludesFile` is not read. Symlinks, hardlinks, devices, FIFOs, path escapes and detected folder moves refuse.
257
+ Local file authority uploads only strict UTF-8 (with or without BOM) or UTF-16LE/BE text
258
+ with a BOM, with these extensions:
259
+ `.txt`, `.md`, `.csv`, `.json`, `.py`, `.m`, `.jl`, `.r`, `.c`, `.h`, `.cpp`, `.f90`,
260
+ `.toml`, `.yaml`, `.yml`, `.ini`, `.cfg`, `.tex`, `.rst` (case-insensitive).
261
+ A BOM selects exactly its declared encoding; invalid text refuses `scan_unsupported`.
262
+ Without a BOM, only strict UTF-8 is decoded: no encoding heuristics or fallback are used.
263
+ BOM-less UTF-16 is unsupported; export it as UTF-8 or include a UTF-16 BOM.
264
+ Credential shapes are scanned in raw bytes and in a copy of the decoded text with control
265
+ (except tab, CR and LF) and zero-width/format characters removed. Uploaded bytes remain unchanged.
266
+
267
+ **PDF is refused in this slice** (`scan_unsupported`), by `.pdf` extension or `%PDF-` content
268
+ signature anywhere in the file, including after a preamble and under another filename.
269
+ **DOCX and ZIP/OOXML containers are refused** (`scan_unsupported`), by extension or ZIP content
270
+ signature (`PK\x03\x04` anywhere in the file), including under a `.txt` filename. Their reading
271
+ order cannot yet be checked reliably for credentials before upload. Upload Word/PDF files in
272
+ the web app, or attach a text/CSV/Markdown export. No ZIP/XML document scanner is used.
273
+ Other extensions, invalid text encodings and uninspectable binary representations also refuse.
274
+ False positives refuse. This is a bounded representation/pattern check, not a guarantee that every
275
+ secret can be recognized. No local filename or absolute path is added to an upload body.
276
+
277
+ `local-grants.json` records permission generations and pending consent metadata; `local-writes.json`
278
+ records upload evidence, save intents, proposal-to-original/CAS mappings, per-path baseline hashes
279
+ and provenance, observed-existence tombstones and unresolved non-session admissions.
280
+ Grant revocation is fsynced before link/logout metadata and automatic Project binding; a
281
+ journalled revocation intent also blocks old grants and consent if the grant-store write fails or is interrupted.
282
+ Both are private local stores beside `folders.json`. Local admissions and file operations share
283
+ an async, non-reentrant lock in the order local lock → short store lock. **Design deviation:**
284
+ a realpath-canonical Linux abstract Unix socket replaces the spec's literal lock file so SIGKILL
285
+ releases exclusion in the kernel. Another same-user process contends across XDG aliases; another
286
+ OS user in the same network namespace could squat the name (denial of service).
287
+
288
+ Exact baseline bytes are retained privately in `local-bases/<sha256>` beside these stores, mode
289
+ 0600, up to 8 MiB per file and 256 MiB total; oldest snapshots are evicted first. Reads verify the
290
+ digest. If a snapshot is evicted, missing or corrupt, hash-based conflict status remains and the
291
+ display says the base diff is unavailable. Edited proposal files are never used to reconstruct a
292
+ baseline. The code/text extensions `.py .m .jl .r .c .h .cpp .f90 .toml .yaml .yml .ini .cfg .tex .rst`
293
+ upload as `text/plain`, with the same strict content scan. Extract-based upload does not establish
294
+ whole-file model fidelity: fixture J3 runs prove delivery and user adoption mechanically; model-quality
295
+ J3 remains UNKNOWN until the installed literal model run.
296
+
297
+ Downloads finish and verify length, digest and kind-specific media in memory before any local
298
+ mutation. Fsynced intents precede directory/staging creation, writes, publication and cleanup.
299
+ Restart checks root and inode ownership; the post-link two-name state removes its recorded staging
300
+ link before completing. Replacements and unexplained hardlinks are retained and reported.
301
+ A mkdir interrupted before its inode was recorded is retained with
302
+ `may have been created by an interrupted save`; unconditional empty-folder crash cleanup is not promised.
303
+ An unsafe/partial installation reports `install_unverified`, with cleaned and remaining paths.
304
+ The older short store-lock recovery message still applies to `store.js` writes themselves.
305
+
306
+ A save refuses `admission_unresolved, resolve it with /resume` before reading the head while any
307
+ folder's pending admission or the command/MCP admission journal is unresolved for that origin/Project.
308
+ `/resume` retries the exact persisted request/key through the active credential; failed authorization
309
+ keeps the intent unresolved. A local lock cannot fence web/other-machine admissions after the head
310
+ read: that residual window is the local installation sequence, with no network wait. Hostile
311
+ same-OS-user directory/name swaps between the last identity check and a syscall remain a TOCTOU
312
+ limit; identity-checked cleanup has the same last-check race. Node provides no openat2/linkat/flock
313
+ boundary for eliminating it here. The TUI has no `--project` attachment door;
314
+ `run submit --no-wait -p OTHER --attach ...` grants only that invocation's explicit destination.
315
+
316
+ Explicit `/download`, `/copy`, `/export`, `artifact get`, `run export`
317
+ and MCP `materialAttach` retain their own consent/ownership boundaries. They are not uses of the
318
+ new persistent local grant; MCP attachment remains the integration-doors owner.
319
+
127
320
  ## Maintainer boundaries and later stages
128
321
 
129
322
  One package, one session owner, two views; stage 1 has no daemon or second application.
@@ -132,8 +325,9 @@ One package, one session owner, two views; stage 1 has no daemon or second appli
132
325
  |---|---|
133
326
  | `bin/vecteur.js` | TTY dispatch and preserved script/MCP commands; lazy terminal loading |
134
327
  | `session.js`, `commands.js` | Cloud actions, prompts, recovery and view facts |
135
- | `client.js` | Public API, auth transport, validated records, sources, controls and cursor replay |
328
+ | `client.js`, `wire.js` | Public API, auth transport, sources and cursor replay; wire v6 event and record validation |
136
329
  | `credentials.js`, `folders.js`, `store.js` | Existing login, account/folder metadata and atomic persistence |
330
+ | `localfiles.js` | Grants, anchored reads/writes, exclusions/scan, local lock, admission/save journals and recovery |
137
331
  | `input.js`, `terminal.js` | Grapheme-aware composer, paste, signals and the single stdout writer |
138
332
  | `tui/view.js`, `blocks.js` | Rich layout and Run presentation; plain view uses the same session facts |
139
333
  | `markdown.js`, `contract.js` | Generated parser/contracts; no runtime web or SDK import |
@@ -145,11 +339,9 @@ Ink failed the frozen startup budget. Completed output is appended; resize aband
145
339
  geometry so it never guesses how many reflowed scrollback lines to erase. Neither view authorizes
146
340
  operations or issues requests itself.
147
341
 
148
- Later computer-use work adds separate device credentials, grants, IPC/relay and cancellation
149
- subjects. Native Claude/Codex sessions need their own identity and lifecycle; they are not cloud
150
- Runs. A folder link must never become a local execution grant. External tool results enter existing
151
- custody with tool/version/hash/trust metadata. No companion/native/driver stubs, vendor credential
152
- discovery or local execution capability ships in this package.
342
+ Nothing runs on this computer: a Run executes in Vecteur cloud, and folder links and file grants
343
+ authorize no execution. Explicit attach and verified save-new are the file transfer doors. Native
344
+ Claude/Codex handoffs retain their own identity and lifecycle.
153
345
 
154
346
  The intended platform matrix includes Linux, macOS and Windows Terminal, plus screen-reader
155
347
  qualification. Current evidence and unresolved cases belong in the stage-1 WBS/backlog; Linux
package/bin/vecteur.js CHANGED
@@ -3,14 +3,14 @@ import { readFileSync } from "node:fs";
3
3
 
4
4
  import {
5
5
  CliError, VecteurClient, admittedFailure, configuration, isStateHash, isTokenShaped, redact,
6
- requestTimeout, resolveOrigin, shouldOpenBrowser, waitForDeviceAuthorization,
6
+ requestTimeout, resolveOrigin, shouldOpenBrowser, waitForDeviceAuthorization, isRequestKey,
7
7
  } from "../src/client.js";
8
8
  import {
9
9
  clearCredentials, credentialsPath, readCredentials, setCurrentOrigin, writeCredentials, selectProject,
10
10
  } from "../src/credentials.js";
11
- import { downloadArtifact, downloadProjection, exportRun } from "../src/download.js";
11
+ import { downloadArtifact, exportRun } from "../src/download.js";
12
12
  import { humanProjects, resolveNamed, resolveRunProject, resolveWorkspace } from "../src/projects.js";
13
- import { canonicalJson, currentTransferTables, human, humanCost, progress } from "../src/format.js";
13
+ import { canonicalJson, human, humanCost, progress } from "../src/format.js";
14
14
  import { openBrowser } from "../src/browser.js";
15
15
 
16
16
  function manifest() {
@@ -43,12 +43,14 @@ function refuseOldNode() {
43
43
 
44
44
  function helpText(version) {
45
45
  return `vecteur ${version}
46
- login | logout | whoami | project list | project create <name> [--workspace <name-or-id>] | project use <name-or-id> | project get <id> | run submit [-p <id>] -a <ask> [--parent <state-hash>] | run get <id> | run events <id> | run export <id> [--output <dir>] [-p <id>] | artifact get <id> [--output <path>] [-p <id>] | projection get <run-id> <projection-id> [--output <path>] [-p <id>] | mcp
46
+ login | logout | whoami | project list | project create <name> [--workspace <name-or-id>] | project use <name-or-id> | project get <id> | run submit [-p <id>] -a <ask> [--parent <state-hash>] | run get <id> | run events <id> | run export <id> [--output <dir>] [-p <id>] | artifact get <id> [--output <path>] [-p <id>] | mcp
47
47
  mcp setup claude|codex adds Vecteur to your Claude Code/Codex · handoff claude|codex opens it in this terminal with Vecteur attached
48
48
  status | doctor | (bare vecteur opens an interactive session)
49
49
  --help --version --json --origin <url> --no-browser --offline --plain --no-color --local -p/--project -a/--ask --output <path>
50
50
  update [--check] [--yes] [--origin <url>] updates the executing installation
51
51
  run submit continues the Project's current head; --parent <state-hash> admits it only if that is still the head
52
+ run submit --no-wait --request-key K [--parent H|none] [--attach PATH…] -p ID -a ASK --json
53
+ Claude Code/Codex recipe: submit --no-wait --parent H --request-key K --attach PATH…; run get / run events; run export
52
54
  `;
53
55
  }
54
56
 
@@ -82,6 +84,14 @@ function parseCommand(argv) {
82
84
  args = args.filter((_, i) => i !== index && i !== index + 1);
83
85
  return option;
84
86
  };
87
+ const paths = [];
88
+ while (args.includes("--attach")) {
89
+ const index = args.indexOf("--attach");
90
+ let end = index + 1;
91
+ while (value(args[end])) paths.push(args[end++]);
92
+ if (end === index + 1) throw new CliError("usage_invalid", "--attach requires explicit paths");
93
+ args.splice(index, end - index);
94
+ }
85
95
  const version = takeFlag("--version");
86
96
  const help = takeFlag("--help");
87
97
  const json = takeFlag("--json");
@@ -97,7 +107,8 @@ function parseCommand(argv) {
97
107
  const workspace = takeOption("--workspace");
98
108
  const output = takeOption("--output");
99
109
  const parent = takeOption("--parent");
100
- if (parent !== undefined && (!isStateHash(parent) || args[0] !== "run" || args[1] !== "submit")) {
110
+ const noWait = takeFlag("--no-wait"), requestKey = takeOption("--request-key");
111
+ if (parent !== undefined && (!(isStateHash(parent) || noWait && parent === "none") || args[0] !== "run" || args[1] !== "submit")) {
101
112
  throw new CliError("usage_invalid", "Invalid command grammar");
102
113
  }
103
114
  if (args.some((arg) => typeof arg === "string" && arg.startsWith("-"))) {
@@ -105,6 +116,16 @@ function parseCommand(argv) {
105
116
  }
106
117
  if (version) return { kind: "version" };
107
118
  if (help) return { kind: "help" };
119
+ if (noWait || requestKey !== undefined || paths.length) {
120
+ const common = !noBrowser && !offline && !checkUpdate && !yesUpdate && !plain && !noColor && !local
121
+ && workspace === undefined && output === undefined;
122
+ if (common && args.length === 2 && args[0] === "run" && args[1] === "submit" && noWait
123
+ && value(ask)) {
124
+ if (!isRequestKey(requestKey)) throw new CliError("request_key_invalid", "--request-key requires 8–64 letters, digits, _ or -");
125
+ return { kind: "run_start", projectId, ask, requestKey, parent: parent === "none" ? null : parent, paths, origin, json };
126
+ }
127
+ throw new CliError("usage_invalid", "Invalid command grammar");
128
+ }
108
129
  if (args.length === 1 && args[0] === "update" && !json && !local && !offline && !plain && !noColor
109
130
  && !noBrowser && projectId === undefined && ask === undefined && workspace === undefined && output === undefined && parent === undefined) {
110
131
  return { kind: "update", origin, check: checkUpdate, yes: yesUpdate };
@@ -172,10 +193,6 @@ function parseCommand(argv) {
172
193
  && ask === undefined) {
173
194
  return { kind: "artifact_get", id: args[2], projectId, output, origin, json };
174
195
  }
175
- if (args.length === 4 && args[0] === "projection" && args[1] === "get"
176
- && value(args[2]) && value(args[3]) && ask === undefined) {
177
- return { kind: "projection_get", runId: args[2], id: args[3], projectId, output, origin, json };
178
- }
179
196
  throw new CliError("usage_invalid", "Invalid command grammar");
180
197
  }
181
198
 
@@ -380,55 +397,64 @@ async function main() {
380
397
  + value.files.map(file => ` ${file.path} · ${file.bytes} bytes${file.cas_ref ? " · verified" : ""}\n`).join(""));
381
398
  return;
382
399
  }
383
- else if (command.kind === "projection_get") {
400
+ else if (command.kind === "run_start") {
384
401
  const projectId = await resolveRunProject(client, command.projectId);
385
- const run = await client.runGet(command.runId);
386
- const matches = run.events.filter(event => event.kind === "engineering_projection"
387
- && event.payload?.projection_id === command.id && event.payload?.kind === "transfer_table");
388
- if (matches.length !== 1) throw new CliError("projection_invalid", "Run has no unique transfer table projection");
389
- value = await downloadProjection(client, projectId, command.runId, matches[0].payload, command.output);
390
- process.stdout.write(command.json ? canonicalJson(value)
391
- : `Downloaded ${value.bytes} bytes to ${value.path} (${value.content_type}; ${value.disposition})\n`);
402
+ value = await client.runStartLocal(projectId, command.ask, { requestKey: command.requestKey,
403
+ parentStateHash: command.parent, paths: command.paths });
404
+ process.stdout.write(canonicalJson(value));
392
405
  return;
393
406
  }
394
407
  else if (command.kind === "run_submit") {
395
- const projectId = await resolveRunProject(client, command.projectId);
396
- value = await client.runSubmit(projectId, command.ask, onEvent, undefined, command.parent);
397
- if (!command.json) {
398
- try {
399
- const currentTransferIds = await verifiedTransferIds(client, value);
400
- process.stdout.write(human(value, { projectId, currentTransferIds }));
401
- const cost = await client.customerCost(projectId);
402
- process.stdout.write(`\n${humanCost(cost)}`);
403
- } catch (error) {
404
- throw admittedFailure(error, value.run_id);
405
- }
406
- return;
407
- }
408
+ renderOptions = { projectId: await resolveRunProject(client, command.projectId) };
409
+ value = await client.runSubmit(renderOptions.projectId, command.ask, onEvent, undefined, command.parent);
408
410
  } else if (command.kind === "run_get") value = await client.runGet(command.id);
409
411
  else value = await client.runEvents(command.id, onEvent);
410
- if (!command.json && !renderOptions.projectId && config.projectId) {
411
- renderOptions = { projectId: config.projectId };
412
- }
413
- if (!command.json && Array.isArray(value?.events)) {
414
- renderOptions.currentTransferIds = await verifiedTransferIds(client, value);
412
+ if (command.json) { process.stdout.write(canonicalJson(value)); return; }
413
+ if (!Array.isArray(value?.events)) { process.stdout.write(human(value)); return; }
414
+ try {
415
+ renderOptions.projectId ??= config.projectId;
416
+ renderOptions.origin = config.origin;
417
+ // At a limit the server says what this reader may do; the stop card states the limit, so the usage block gives way to it.
418
+ if (value.terminal === "budget") {
419
+ renderOptions.stopOffer = await client.stopOffer(value.run_id);
420
+ if (renderOptions.stopOffer) await client.stopEvent(value.run_id, { event: "shown", surface: "cli" });
421
+ }
422
+ // The settled Run is printed first: a later cost read may fail loudly, never erase the answer.
423
+ process.stdout.write(human(value, renderOptions));
424
+ if (command.kind === "run_submit" && value.terminal !== "budget") {
425
+ process.stdout.write(`\n${humanCost(await client.customerCost(renderOptions.projectId))}`);
426
+ }
427
+ } catch (error) {
428
+ throw command.kind === "run_submit" ? admittedFailure(error, value.run_id) : error;
415
429
  }
416
- process.stdout.write(command.json ? canonicalJson(value) : human(value, renderOptions));
417
430
  }
418
431
 
419
- async function verifiedTransferIds(client, run) {
420
- const ids = new Set();
421
- for (const projection of currentTransferTables(run.events ?? [])) {
422
- const read = await client.projectionGet(
423
- projection.project_id, run.run_id, projection, async () => {},
424
- );
425
- if (read.disposition === "current") ids.add(projection.projection_id);
426
- }
427
- return ids;
432
+ // The detached door (`run submit --no-wait`) reports failures as JSON; option values are skipped when identifying it.
433
+ function lifecycleInvocation(argv) {
434
+ const tokens = [];
435
+ let noWait = false;
436
+ const options = new Set(["--origin", "--project", "-p", "--ask", "-a", "--workspace", "--output", "--parent",
437
+ "--request-key"]);
438
+ for (let i = 0; i < argv.length; i++) {
439
+ if (options.has(argv[i])) { i++; continue; }
440
+ if (argv[i] === "--no-wait") { noWait = true; continue; }
441
+ if (argv[i] === "--attach") {
442
+ while (i + 1 < argv.length && !argv[i + 1].startsWith("-")) i++;
443
+ continue;
444
+ }
445
+ if (!argv[i].startsWith("-")) tokens.push(argv[i]);
446
+ }
447
+ return tokens[0] === "run" && tokens[1] === "submit" && noWait;
428
448
  }
429
449
 
430
450
  main().catch((error) => {
431
451
  const code = error instanceof CliError ? error.code : "internal_error";
432
- process.stderr.write(`${code}: ${redact(error?.message ?? "CLI failed")}\n`);
452
+ const argv = process.argv.slice(2);
453
+ const structured = lifecycleInvocation(argv);
454
+ const message = redact(error?.message ?? "CLI failed");
455
+ const details = Object.fromEntries(["run_id", "request_key", "parent_state_hash"]
456
+ .filter(field => error instanceof CliError && Object.hasOwn(error, field))
457
+ .map(field => [field, typeof error[field] === "string" ? redact(error[field]) : error[field]]));
458
+ process.stderr.write(structured ? canonicalJson({ code, message, ...details }) : `${code}: ${message}\n`);
433
459
  process.exitCode = code === "usage_invalid" ? 2 : 1;
434
460
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vecteur/cli",
3
- "version": "0.10.0",
3
+ "version": "0.12.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "vecteur": "bin/vecteur.js"
@@ -10,14 +10,18 @@
10
10
  "bin/vecteur.js",
11
11
  "src/client.js",
12
12
  "src/contract.js",
13
+ "src/wire.js",
13
14
  "src/credentials.js",
14
15
  "src/download.js",
16
+ "src/exchange.js",
15
17
  "src/errors.js",
16
18
  "src/format.js",
19
+ "src/stop-words.js",
17
20
  "src/mcp.js",
18
21
  "src/projects.js",
19
22
  "src/store.js",
20
23
  "src/folders.js",
24
+ "src/localfiles.js",
21
25
  "src/browser.js",
22
26
  "src/blocks.js",
23
27
  "src/session.js",