@vecteur/cli 0.11.1 → 0.13.1
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 +39 -45
- package/bin/vecteur.js +46 -101
- package/package.json +4 -4
- package/src/blocks.js +43 -170
- package/src/client.js +62 -271
- package/src/commands.js +21 -45
- package/src/contract.js +19 -60
- package/src/download.js +2 -7
- package/src/exchange.js +6 -5
- package/src/format.js +82 -596
- package/src/localfiles.js +4 -26
- package/src/markdown.js +43 -68
- package/src/mcp.js +60 -76
- package/src/session.js +67 -377
- package/src/stop-words.js +19 -0
- package/src/terminal.js +7 -25
- package/src/tui/view.js +25 -62
- package/src/wire.js +73 -0
- package/src/executor.js +0 -171
- package/src/produce.js +0 -49
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
|
|
5
|
+
calls the runner, engine or database directly.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install -g @vecteur/cli
|
|
@@ -13,21 +13,20 @@ 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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Only scanned UTF-8 output tails (16,000/8,000 bytes) return to Vecteur; credential-shaped or
|
|
23
|
-
unsupported output withholds both tails. A lost start acknowledgement never spawns; unknown
|
|
24
|
-
outcomes are never retried. Restarted sessions observe existing Runs without execution authority.
|
|
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.
|
|
25
22
|
|
|
26
23
|
For scripts and explicit one-shot commands:
|
|
27
24
|
|
|
28
25
|
```bash
|
|
29
26
|
vecteur login
|
|
30
27
|
vecteur whoami
|
|
28
|
+
vecteur workflow list
|
|
29
|
+
vecteur workflow show review
|
|
31
30
|
vecteur project list
|
|
32
31
|
vecteur project create 'Transfer study'
|
|
33
32
|
vecteur project use 'Transfer study'
|
|
@@ -43,6 +42,12 @@ Use `vecteur login --origin URL` for another deployment. For automation, supply
|
|
|
43
42
|
through `VECTEUR_TOKEN` and its origin through `VECTEUR_BASE_URL`; never pass a token on argv.
|
|
44
43
|
`--help` and `--version` work without signing in.
|
|
45
44
|
|
|
45
|
+
`workflow list` shows the guided workflows (review, feasibility, trade study) and `workflow show ID`
|
|
46
|
+
what to bring, what you get and the ask with its blanks in [brackets]; both read the public
|
|
47
|
+
`/api/workflows` route, work before login and honour `--json`. In a session, `/workflow ID` puts that
|
|
48
|
+
ask in the draft (never over your own text). Replace every blank before sending: an ask that still
|
|
49
|
+
holds one is refused `field_invalid`.
|
|
50
|
+
|
|
46
51
|
`project list` shows authorized Projects and the server's Organization-wide active Project
|
|
47
52
|
allowance. `project create NAME --workspace NAME_OR_ID` chooses among multiple Workspaces; one
|
|
48
53
|
Workspace is implicit. Names must match exactly and uniquely, or use an id. Quota refusals show
|
|
@@ -68,17 +73,20 @@ again, which would start another turn. Start a fresh study with `vecteur project
|
|
|
68
73
|
embedded events match the stream. Redirects, secret-shaped responses, malformed responses and
|
|
69
74
|
timeouts fail nonzero. `--json` sorts object keys for deterministic machine output.
|
|
70
75
|
|
|
71
|
-
Human run output shows the
|
|
72
|
-
terminal cause
|
|
73
|
-
the server's display strings. Machine run output remains the unchanged canonical record. Artifact
|
|
76
|
+
Human run output shows the working trace, the answer, the files with their download commands, the
|
|
77
|
+
typed terminal state and cause, and—after `run submit`—the selected Project's UTC-month customer cost
|
|
78
|
+
using the server's display strings (at a `budget` terminal, the stop card instead). Machine run output remains the unchanged canonical record. Artifact
|
|
74
79
|
downloads use the Project-scoped admitted CAS route, verify the declared length, media type and
|
|
75
80
|
SHA-256, and refuse to overwrite a local path. Use `--project ID` when no Project is selected.
|
|
76
81
|
|
|
77
82
|
`vecteur mcp` serves MCP over stdio using the same credentials and public client. It exposes
|
|
78
83
|
`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).
|
|
79
84
|
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`.
|
|
80
|
-
It also exposes `vecteur_run_start
|
|
81
|
-
|
|
85
|
+
It also exposes `vecteur_run_start` and `vecteur_run_status` for long Runs. `vecteur_artifact_get`
|
|
86
|
+
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.
|
|
87
|
+
Each guided workflow is also an MCP prompt, `vecteur_<id>` (all arguments required), read from the
|
|
88
|
+
origin when the server starts (none if it is unreachable); `vecteur_workflow_list` returns the same
|
|
89
|
+
definitions for hosts that show tools but not prompts.
|
|
82
90
|
An MCP host supplies tool arguments; stdout carries only MCP protocol.
|
|
83
91
|
|
|
84
92
|
`vecteur mcp setup claude` (or `codex`) runs that vendor's own `mcp add` once so your Claude Code
|
|
@@ -92,7 +100,7 @@ mode in which the vendor session appears inside Vecteur's TUI and web.
|
|
|
92
100
|
new folder: `answer.md` (exact answer bytes), `run.json` (the canonical record) and every artifact,
|
|
93
101
|
each verified against its SHA-256 CAS id. Nothing is overwritten.
|
|
94
102
|
|
|
95
|
-
## Claude Code and Codex: attach, poll,
|
|
103
|
+
## Claude Code and Codex: attach, poll, export
|
|
96
104
|
|
|
97
105
|
Both vendors use the same lifecycle recipe. Sign in to Vecteur and to your vendor separately;
|
|
98
106
|
use `vecteur mcp setup claude` / `vecteur handoff claude`, or substitute `codex`. The installed
|
|
@@ -113,26 +121,15 @@ vecteur run submit --no-wait --parent "$H" --request-key orbit-20261107-01 \
|
|
|
113
121
|
vecteur run get RUN_ID --json
|
|
114
122
|
# Optional validated event replay (the stream has the configured request timeout):
|
|
115
123
|
vecteur run events RUN_ID --json
|
|
116
|
-
#
|
|
117
|
-
vecteur run answer RUN_ID --clarification CLARIFICATION_ID --answers answers.json --json
|
|
118
|
-
vecteur run get RUN_ID --json
|
|
124
|
+
# A question from Vecteur is the Run's answer: reply with a new submit on the new head.
|
|
119
125
|
vecteur run export RUN_ID -p PROJECT_ID --output orbit-result --json
|
|
120
126
|
```
|
|
121
127
|
|
|
122
|
-
`answers.json` is the wire answer array; `--answers -` reads the same JSON from stdin:
|
|
123
|
-
|
|
124
|
-
```json
|
|
125
|
-
[{"id":"orbit","selected":["leo","meo"],"custom":"Include a polar case"},
|
|
126
|
-
{"id":"mass","selected":[],"custom":"550 kg"}]
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
The server owns valid question/option ids, multi-select, expiry and stale/duplicate refusals.
|
|
130
128
|
MCP hosts use `vecteur_run_start({project_id, ask, request_key, parent_state_hash})`, then poll
|
|
131
|
-
`vecteur_run_status({run_id})
|
|
132
|
-
`
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
payload verbatim only while requested. Stopping polling detaches and never cancels the Run.
|
|
129
|
+
`vecteur_run_status({run_id})`. Start returns the RunAck plus the resolved `parent_state_hash`.
|
|
130
|
+
Status returns `{run_id, terminal, last_seq}`: one bounded record read, `terminal` empty while the
|
|
131
|
+
Run is open, last sequence `-1` when no events exist. Stopping polling detaches and never cancels
|
|
132
|
+
the Run.
|
|
136
133
|
|
|
137
134
|
`--attach` is explicit consent to upload exactly those files to the command's explicit or
|
|
138
135
|
selected Project at the authenticated origin, for Vecteur cloud and the Run's model provider.
|
|
@@ -156,7 +153,7 @@ without that file remains `admission_unresolved`; a conflicting same-key retry a
|
|
|
156
153
|
`admission_unresolved`. Inspect Project history before choosing a new key. No newest Run is
|
|
157
154
|
presented as recovered, and the client never generates a replacement key. Transport, timeout,
|
|
158
155
|
pending, unknown and malformed-ack errors carry the request key and parent once resolved.
|
|
159
|
-
Only `run submit --no-wait`
|
|
156
|
+
Only `run submit --no-wait` emits one JSON error object on stderr
|
|
160
157
|
(`code`, `message`, optional `run_id`, `request_key`, `parent_state_hash`); stdout holds only the
|
|
161
158
|
success record. Existing blocking CLI and MCP success outputs and CLI error bytes are preserved;
|
|
162
159
|
MCP errors may additionally name an admitted `run_id`.
|
|
@@ -178,8 +175,8 @@ Bare invocation in a pipe or CI keeps the previous status output; `vecteur statu
|
|
|
178
175
|
- `/project` chooses a Project for this session; `/link` saves the folder association.
|
|
179
176
|
`/unlink` removes that association for this subtree and preserves the draft. `/name` renames
|
|
180
177
|
the current Project or names the one created on first send. `/history` loads older Runs on demand.
|
|
181
|
-
- `/model` selects the next Run's model
|
|
182
|
-
explains
|
|
178
|
+
- `/model` selects the next Run's model from the product's model choices (Auto is the default).
|
|
179
|
+
`/mode` explains model, execution location and payer. Runs execute in Vecteur cloud.
|
|
183
180
|
- `@` completes local paths. A whole filename in your ask offers attachment after local
|
|
184
181
|
checks (at most three offers; ambiguous basenames list choices).
|
|
185
182
|
A refused name prints `name: not offered (reason)` and asks whether to send without it.
|
|
@@ -199,11 +196,9 @@ Bare invocation in a pipe or CI keeps the previous status output; `vecteur statu
|
|
|
199
196
|
Up to eight files, **8 MiB each** (reduced from 16 MiB) and 32 MiB total; all available extracts
|
|
200
197
|
are selected. `/clear-files` removes pending selections. A retry of an admitted upload uses
|
|
201
198
|
its frozen source handle and never rereads the local file.
|
|
202
|
-
-
|
|
203
|
-
and `/answer-now` submit instructions; acceptance is distinct from execution.
|
|
199
|
+
- An ask sent while a Run is working is kept as your draft; send it when the Run ends.
|
|
204
200
|
- `/cancel` or double Esc requests cloud Run cancellation. Ctrl+D on an empty composer or
|
|
205
201
|
`/quit` detaches; the cloud Run continues. Ctrl+C clears a nonempty composer.
|
|
206
|
-
- `/package <number>` saves a result into its own new folder and prints how to continue. Local execution needs its separate consent; attached test reports join the next turn as your evidence, not an accepted result.
|
|
207
202
|
- After a terminal head Run, a save-new prompt offers absent artifact paths, including missing
|
|
208
203
|
parent directories. Identical bytes preselect the shortest path; `d` shows every path and
|
|
209
204
|
lets you choose any. `yes` installs verified bytes without overwriting, `n` declines.
|
|
@@ -253,7 +248,7 @@ request evidence stays until resolved. Account draft recovery requires the same
|
|
|
253
248
|
previously bound by a successful account read. Never-signed-in drafts occupy a separate unsigned
|
|
254
249
|
namespace with no Project authority; only explicit login transfers them into an account. Neither
|
|
255
250
|
recovery path grants server access. Selections hold metadata until send and must be selected
|
|
256
|
-
again after restart
|
|
251
|
+
again after restart. A newer store version is refused without
|
|
257
252
|
rewriting it. Previous CLI versions ignore the separate folder registry.
|
|
258
253
|
|
|
259
254
|
## Local file authority limits
|
|
@@ -329,7 +324,7 @@ limit; identity-checked cleanup has the same last-check race. Node provides no o
|
|
|
329
324
|
boundary for eliminating it here. The TUI has no `--project` attachment door;
|
|
330
325
|
`run submit --no-wait -p OTHER --attach ...` grants only that invocation's explicit destination.
|
|
331
326
|
|
|
332
|
-
Explicit `/download`, `/copy`, `/export`, `artifact get`, `run export
|
|
327
|
+
Explicit `/download`, `/copy`, `/export`, `artifact get`, `run export`
|
|
333
328
|
and MCP `materialAttach` retain their own consent/ownership boundaries. They are not uses of the
|
|
334
329
|
new persistent local grant; MCP attachment remains the integration-doors owner.
|
|
335
330
|
|
|
@@ -341,7 +336,7 @@ One package, one session owner, two views; stage 1 has no daemon or second appli
|
|
|
341
336
|
|---|---|
|
|
342
337
|
| `bin/vecteur.js` | TTY dispatch and preserved script/MCP commands; lazy terminal loading |
|
|
343
338
|
| `session.js`, `commands.js` | Cloud actions, prompts, recovery and view facts |
|
|
344
|
-
| `client.js` | Public API, auth transport,
|
|
339
|
+
| `client.js`, `wire.js` | Public API, auth transport, sources and cursor replay; wire v6 event and record validation |
|
|
345
340
|
| `credentials.js`, `folders.js`, `store.js` | Existing login, account/folder metadata and atomic persistence |
|
|
346
341
|
| `localfiles.js` | Grants, anchored reads/writes, exclusions/scan, local lock, admission/save journals and recovery |
|
|
347
342
|
| `input.js`, `terminal.js` | Grapheme-aware composer, paste, signals and the single stdout writer |
|
|
@@ -355,10 +350,9 @@ Ink failed the frozen startup budget. Completed output is appended; resize aband
|
|
|
355
350
|
geometry so it never guesses how many reflowed scrollback lines to erase. Neither view authorizes
|
|
356
351
|
operations or issues requests itself.
|
|
357
352
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
handoffs retain their own identity and lifecycle.
|
|
353
|
+
Nothing runs on this computer: a Run executes in Vecteur cloud, and folder links and file grants
|
|
354
|
+
authorize no execution. Explicit attach and verified save-new are the file transfer doors. Native
|
|
355
|
+
Claude/Codex handoffs retain their own identity and lifecycle.
|
|
362
356
|
|
|
363
357
|
The intended platform matrix includes Linux, macOS and Windows Terminal, plus screen-reader
|
|
364
358
|
qualification. Current evidence and unresolved cases belong in the stage-1 WBS/backlog; Linux
|
package/bin/vecteur.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Executor } from "../src/executor.js";
|
|
3
|
-
import { withLocalLock, executionGrant, rootIdentity, qualify } from "../src/localfiles.js";
|
|
4
2
|
import { readFileSync } from "node:fs";
|
|
5
|
-
import { createHash } from "node:crypto";
|
|
6
3
|
|
|
7
4
|
import {
|
|
8
5
|
CliError, VecteurClient, admittedFailure, configuration, isStateHash, isTokenShaped, redact,
|
|
9
|
-
requestTimeout, resolveOrigin, shouldOpenBrowser, waitForDeviceAuthorization, isRequestKey,
|
|
6
|
+
requestTimeout, resolveOrigin, shouldOpenBrowser, waitForDeviceAuthorization, isRequestKey,
|
|
10
7
|
} from "../src/client.js";
|
|
11
8
|
import {
|
|
12
9
|
clearCredentials, credentialsPath, readCredentials, setCurrentOrigin, writeCredentials, selectProject,
|
|
13
10
|
} from "../src/credentials.js";
|
|
14
|
-
import { downloadArtifact,
|
|
11
|
+
import { downloadArtifact, exportRun } from "../src/download.js";
|
|
15
12
|
import { humanProjects, resolveNamed, resolveRunProject, resolveWorkspace } from "../src/projects.js";
|
|
16
|
-
import { canonicalJson,
|
|
13
|
+
import { canonicalJson, human, humanCost, humanWorkflow, humanWorkflows, progress } from "../src/format.js";
|
|
17
14
|
import { openBrowser } from "../src/browser.js";
|
|
18
15
|
|
|
19
16
|
function manifest() {
|
|
@@ -46,15 +43,14 @@ function refuseOldNode() {
|
|
|
46
43
|
|
|
47
44
|
function helpText(version) {
|
|
48
45
|
return `vecteur ${version}
|
|
49
|
-
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>] |
|
|
46
|
+
login | logout | whoami | workflow list | workflow show <id> | 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
|
|
50
47
|
mcp setup claude|codex adds Vecteur to your Claude Code/Codex · handoff claude|codex opens it in this terminal with Vecteur attached
|
|
51
48
|
status | doctor | (bare vecteur opens an interactive session)
|
|
52
49
|
--help --version --json --origin <url> --no-browser --offline --plain --no-color --local -p/--project -a/--ask --output <path>
|
|
53
50
|
update [--check] [--yes] [--origin <url>] updates the executing installation
|
|
54
51
|
run submit continues the Project's current head; --parent <state-hash> admits it only if that is still the head
|
|
55
52
|
run submit --no-wait --request-key K [--parent H|none] [--attach PATH…] -p ID -a ASK --json
|
|
56
|
-
|
|
57
|
-
Claude Code/Codex recipe: submit --no-wait --parent H --request-key K --attach PATH…; run get / run events; run answer; run export
|
|
53
|
+
Claude Code/Codex recipe: submit --no-wait --parent H --request-key K --attach PATH…; run get / run events; run export
|
|
58
54
|
`;
|
|
59
55
|
}
|
|
60
56
|
|
|
@@ -83,7 +79,7 @@ function parseCommand(argv) {
|
|
|
83
79
|
if (indexes.length > 1) throw new CliError("usage_invalid", "Invalid command grammar");
|
|
84
80
|
if (indexes.length === 0) return undefined;
|
|
85
81
|
const index = indexes[0];
|
|
86
|
-
if (!value(args[index + 1])
|
|
82
|
+
if (!value(args[index + 1])) throw new CliError("usage_invalid", "Invalid command grammar");
|
|
87
83
|
const option = args[index + 1];
|
|
88
84
|
args = args.filter((_, i) => i !== index && i !== index + 1);
|
|
89
85
|
return option;
|
|
@@ -112,11 +108,6 @@ function parseCommand(argv) {
|
|
|
112
108
|
const output = takeOption("--output");
|
|
113
109
|
const parent = takeOption("--parent");
|
|
114
110
|
const noWait = takeFlag("--no-wait"), requestKey = takeOption("--request-key");
|
|
115
|
-
const allowExec = takeFlag("--allow-exec");
|
|
116
|
-
if (allowExec && (noWait || requestKey !== undefined || args[0] !== "run" || args[1] !== "submit")) {
|
|
117
|
-
throw new CliError("usage_invalid", "--allow-exec requires foreground run submit, without --no-wait or --request-key; MCP has no local executor");
|
|
118
|
-
}
|
|
119
|
-
const clarification = takeOption("--clarification"), answers = takeOption("--answers");
|
|
120
111
|
if (parent !== undefined && (!(isStateHash(parent) || noWait && parent === "none") || args[0] !== "run" || args[1] !== "submit")) {
|
|
121
112
|
throw new CliError("usage_invalid", "Invalid command grammar");
|
|
122
113
|
}
|
|
@@ -125,19 +116,14 @@ function parseCommand(argv) {
|
|
|
125
116
|
}
|
|
126
117
|
if (version) return { kind: "version" };
|
|
127
118
|
if (help) return { kind: "help" };
|
|
128
|
-
if (noWait || requestKey !== undefined || paths.length
|
|
119
|
+
if (noWait || requestKey !== undefined || paths.length) {
|
|
129
120
|
const common = !noBrowser && !offline && !checkUpdate && !yesUpdate && !plain && !noColor && !local
|
|
130
121
|
&& workspace === undefined && output === undefined;
|
|
131
122
|
if (common && args.length === 2 && args[0] === "run" && args[1] === "submit" && noWait
|
|
132
|
-
&& value(ask)
|
|
123
|
+
&& value(ask)) {
|
|
133
124
|
if (!isRequestKey(requestKey)) throw new CliError("request_key_invalid", "--request-key requires 8–64 letters, digits, _ or -");
|
|
134
125
|
return { kind: "run_start", projectId, ask, requestKey, parent: parent === "none" ? null : parent, paths, origin, json };
|
|
135
126
|
}
|
|
136
|
-
if (common && args.length === 3 && args[0] === "run" && args[1] === "answer" && value(args[2])
|
|
137
|
-
&& value(clarification) && answers !== undefined && !noWait && requestKey === undefined && !paths.length
|
|
138
|
-
&& projectId === undefined && ask === undefined && parent === undefined) {
|
|
139
|
-
return { kind: "run_answer", id: args[2], clarification, answers, origin, json };
|
|
140
|
-
}
|
|
141
127
|
throw new CliError("usage_invalid", "Invalid command grammar");
|
|
142
128
|
}
|
|
143
129
|
if (args.length === 1 && args[0] === "update" && !json && !local && !offline && !plain && !noColor
|
|
@@ -170,6 +156,11 @@ function parseCommand(argv) {
|
|
|
170
156
|
return { kind: "project_use", name: args[2], origin, json };
|
|
171
157
|
}
|
|
172
158
|
}
|
|
159
|
+
if (args[0] === "workflow" && projectId === undefined && ask === undefined && output === undefined
|
|
160
|
+
&& workspace === undefined && !noBrowser && !local) {
|
|
161
|
+
if (args.length === 2 && args[1] === "list") return { kind: "workflow_list", origin, json };
|
|
162
|
+
if (args.length === 3 && args[1] === "show" && value(args[2])) return { kind: "workflow_show", id: args[2], origin, json };
|
|
163
|
+
}
|
|
173
164
|
if (workspace !== undefined) throw new CliError("usage_invalid", "Invalid command grammar");
|
|
174
165
|
if (args.length === 1 && args[0] === "login" && !local
|
|
175
166
|
&& projectId === undefined && ask === undefined && output === undefined) {
|
|
@@ -190,7 +181,7 @@ function parseCommand(argv) {
|
|
|
190
181
|
}
|
|
191
182
|
if (args.length === 2 && args[0] === "run" && args[1] === "submit"
|
|
192
183
|
&& (projectId === undefined || value(projectId)) && value(ask) && output === undefined) {
|
|
193
|
-
return { kind: "run_submit", projectId, ask, parent, origin, json
|
|
184
|
+
return { kind: "run_submit", projectId, ask, parent, origin, json };
|
|
194
185
|
}
|
|
195
186
|
if (args.length === 3 && args[0] === "run" && args[1] === "get" && value(args[2])
|
|
196
187
|
&& projectId === undefined && ask === undefined && output === undefined) {
|
|
@@ -207,10 +198,6 @@ function parseCommand(argv) {
|
|
|
207
198
|
&& ask === undefined) {
|
|
208
199
|
return { kind: "artifact_get", id: args[2], projectId, output, origin, json };
|
|
209
200
|
}
|
|
210
|
-
if (args.length === 4 && args[0] === "projection" && args[1] === "get"
|
|
211
|
-
&& value(args[2]) && value(args[3]) && ask === undefined) {
|
|
212
|
-
return { kind: "projection_get", runId: args[2], id: args[3], projectId, output, origin, json };
|
|
213
|
-
}
|
|
214
201
|
throw new CliError("usage_invalid", "Invalid command grammar");
|
|
215
202
|
}
|
|
216
203
|
|
|
@@ -311,7 +298,6 @@ async function whoami(command, env = process.env) {
|
|
|
311
298
|
async function main() {
|
|
312
299
|
refuseOldNode();
|
|
313
300
|
const command = parseCommand(process.argv.slice(2));
|
|
314
|
-
if (command.allowExec) qualify();
|
|
315
301
|
if (command.kind === "version") {
|
|
316
302
|
process.stdout.write(`vecteur ${manifest().version}\n`);
|
|
317
303
|
return;
|
|
@@ -379,6 +365,20 @@ async function main() {
|
|
|
379
365
|
await whoami(command);
|
|
380
366
|
return;
|
|
381
367
|
}
|
|
368
|
+
// The workflows are public: read anonymously, so they work before login and need no stored origin to match.
|
|
369
|
+
if (command.kind === "workflow_list" || command.kind === "workflow_show") {
|
|
370
|
+
const client = new VecteurClient({ origin: resolveOrigin(process.env, undefined, command.origin),
|
|
371
|
+
token: "", timeout: requestTimeout(process.env) });
|
|
372
|
+
const { data } = await client.workflows();
|
|
373
|
+
if (command.kind === "workflow_list") {
|
|
374
|
+
process.stdout.write(command.json ? canonicalJson(data) : humanWorkflows(data));
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const workflow = data.find(item => item.id === command.id);
|
|
378
|
+
if (!workflow) throw new CliError("workflow_not_found", `No workflow ${command.id}; next: vecteur workflow list`);
|
|
379
|
+
process.stdout.write(command.json ? canonicalJson(workflow) : humanWorkflow(workflow));
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
382
|
|
|
383
383
|
const config = configuration(process.env, undefined, command.origin);
|
|
384
384
|
rememberOrigin(command.origin, config.origin, process.env);
|
|
@@ -416,17 +416,6 @@ async function main() {
|
|
|
416
416
|
+ value.files.map(file => ` ${file.path} · ${file.bytes} bytes${file.cas_ref ? " · verified" : ""}\n`).join(""));
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
else if (command.kind === "projection_get") {
|
|
420
|
-
const projectId = await resolveRunProject(client, command.projectId);
|
|
421
|
-
const run = await client.runGet(command.runId);
|
|
422
|
-
const matches = run.events.filter(event => event.kind === "engineering_projection"
|
|
423
|
-
&& event.payload?.projection_id === command.id && event.payload?.kind === "transfer_table");
|
|
424
|
-
if (matches.length !== 1) throw new CliError("projection_invalid", "Run has no unique transfer table projection");
|
|
425
|
-
value = await downloadProjection(client, projectId, command.runId, matches[0].payload, command.output);
|
|
426
|
-
process.stdout.write(command.json ? canonicalJson(value)
|
|
427
|
-
: `Downloaded ${value.bytes} bytes to ${value.path} (${value.content_type}; ${value.disposition})\n`);
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
419
|
else if (command.kind === "run_start") {
|
|
431
420
|
const projectId = await resolveRunProject(client, command.projectId);
|
|
432
421
|
value = await client.runStartLocal(projectId, command.ask, { requestKey: command.requestKey,
|
|
@@ -434,78 +423,34 @@ async function main() {
|
|
|
434
423
|
process.stdout.write(canonicalJson(value));
|
|
435
424
|
return;
|
|
436
425
|
}
|
|
437
|
-
else if (command.kind === "run_answer") {
|
|
438
|
-
let answers;
|
|
439
|
-
try { answers = JSON.parse(readFileSync(command.answers === "-" ? 0 : command.answers, "utf8")); }
|
|
440
|
-
catch { throw new CliError("answers_invalid", "--answers must name a readable JSON answer array, or - for stdin"); }
|
|
441
|
-
value = await client.clarificationAnswer(command.id, command.clarification, validateAnswers(answers));
|
|
442
|
-
process.stdout.write(canonicalJson(value));
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
426
|
else if (command.kind === "run_submit") {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (command.allowExec) {
|
|
449
|
-
const project = await client.projectGet(projectId);
|
|
450
|
-
const pin = { origin: client.config.origin, accountId: "credential:" + createHash("sha256").update(client.config.token).digest("hex"), projectId, role: project.role,
|
|
451
|
-
root: rootIdentity(process.cwd()), provenance: "invocation", credential: { token: client.config.token,
|
|
452
|
-
kind: process.env.VECTEUR_TOKEN ? "environment" : "stored" } };
|
|
453
|
-
const grant = await withLocalLock(() => executionGrant(pin));
|
|
454
|
-
executor = new Executor({ client, grant, pin: () => pin, session: true });
|
|
455
|
-
}
|
|
456
|
-
value = await client.runSubmit(projectId, command.ask, onEvent, undefined, command.parent, undefined, undefined, executor);
|
|
457
|
-
if (!command.json) {
|
|
458
|
-
try {
|
|
459
|
-
const currentTransferIds = await verifiedTransferIds(client, value);
|
|
460
|
-
const stopped = stopViewOf(value.events);
|
|
461
|
-
const stopOffer = stopped ? await client.stopOffer(value.run_id) : undefined;
|
|
462
|
-
if (stopped?.cause === "plan_limit") await client.stopEvent(value.run_id, { event: "shown", surface: "cli" });
|
|
463
|
-
process.stdout.write(human(value, { projectId, currentTransferIds, stopOffer, origin: config.origin }));
|
|
464
|
-
// A stop states the limit that fired; "22 % used" below it reads as a contradiction (record §3). `vecteur` usage stays one command away.
|
|
465
|
-
if (!stopped) {
|
|
466
|
-
const cost = await client.customerCost(projectId);
|
|
467
|
-
process.stdout.write(`\n${humanCost(cost)}`);
|
|
468
|
-
}
|
|
469
|
-
} catch (error) {
|
|
470
|
-
throw admittedFailure(error, value.run_id);
|
|
471
|
-
}
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
427
|
+
renderOptions = { projectId: await resolveRunProject(client, command.projectId) };
|
|
428
|
+
value = await client.runSubmit(renderOptions.projectId, command.ask, onEvent, undefined, command.parent);
|
|
474
429
|
} else if (command.kind === "run_get") value = await client.runGet(command.id);
|
|
475
430
|
else value = await client.runEvents(command.id, onEvent);
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
renderOptions.currentTransferIds = await verifiedTransferIds(client, value);
|
|
481
|
-
const stopped = stopViewOf(value.events);
|
|
482
|
-
if (stopped) {
|
|
483
|
-
renderOptions.stopOffer = await client.stopOffer(value.run_id);
|
|
484
|
-
if (stopped.cause === "plan_limit") await client.stopEvent(value.run_id, { event: "shown", surface: "cli" });
|
|
485
|
-
}
|
|
431
|
+
if (command.json) { process.stdout.write(canonicalJson(value)); return; }
|
|
432
|
+
if (!Array.isArray(value?.events)) { process.stdout.write(human(value)); return; }
|
|
433
|
+
try {
|
|
434
|
+
renderOptions.projectId ??= config.projectId;
|
|
486
435
|
renderOptions.origin = config.origin;
|
|
436
|
+
// 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.
|
|
437
|
+
if (value.terminal === "budget") renderOptions.stopOffer = await client.stopOffer(value.run_id);
|
|
438
|
+
// The settled Run is printed first: a later cost read may fail loudly, never erase the answer.
|
|
439
|
+
process.stdout.write(human(value, renderOptions));
|
|
440
|
+
if (command.kind === "run_submit" && value.terminal !== "budget") {
|
|
441
|
+
process.stdout.write(`\n${humanCost(await client.customerCost(renderOptions.projectId))}`);
|
|
442
|
+
}
|
|
443
|
+
} catch (error) {
|
|
444
|
+
throw command.kind === "run_submit" ? admittedFailure(error, value.run_id) : error;
|
|
487
445
|
}
|
|
488
|
-
process.stdout.write(command.json ? canonicalJson(value) : human(value, renderOptions));
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
async function verifiedTransferIds(client, run) {
|
|
492
|
-
const ids = new Set();
|
|
493
|
-
for (const projection of currentTransferTables(run.events ?? [])) {
|
|
494
|
-
const read = await client.projectionGet(
|
|
495
|
-
projection.project_id, run.run_id, projection, async () => {},
|
|
496
|
-
);
|
|
497
|
-
if (read.disposition === "current") ids.add(projection.projection_id);
|
|
498
|
-
}
|
|
499
|
-
return ids;
|
|
500
446
|
}
|
|
501
447
|
|
|
502
|
-
//
|
|
503
|
-
// must still print the legacy error bytes, including on a parser/configuration failure.
|
|
448
|
+
// The detached door (`run submit --no-wait`) reports failures as JSON; option values are skipped when identifying it.
|
|
504
449
|
function lifecycleInvocation(argv) {
|
|
505
450
|
const tokens = [];
|
|
506
451
|
let noWait = false;
|
|
507
452
|
const options = new Set(["--origin", "--project", "-p", "--ask", "-a", "--workspace", "--output", "--parent",
|
|
508
|
-
"--request-key"
|
|
453
|
+
"--request-key"]);
|
|
509
454
|
for (let i = 0; i < argv.length; i++) {
|
|
510
455
|
if (options.has(argv[i])) { i++; continue; }
|
|
511
456
|
if (argv[i] === "--no-wait") { noWait = true; continue; }
|
|
@@ -515,7 +460,7 @@ function lifecycleInvocation(argv) {
|
|
|
515
460
|
}
|
|
516
461
|
if (!argv[i].startsWith("-")) tokens.push(argv[i]);
|
|
517
462
|
}
|
|
518
|
-
return tokens[0] === "run" &&
|
|
463
|
+
return tokens[0] === "run" && tokens[1] === "submit" && noWait;
|
|
519
464
|
}
|
|
520
465
|
|
|
521
466
|
main().catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vecteur/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"vecteur": "bin/vecteur.js"
|
|
@@ -10,18 +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",
|
|
15
|
-
"src/produce.js",
|
|
16
16
|
"src/exchange.js",
|
|
17
17
|
"src/errors.js",
|
|
18
18
|
"src/format.js",
|
|
19
|
+
"src/stop-words.js",
|
|
19
20
|
"src/mcp.js",
|
|
20
21
|
"src/projects.js",
|
|
21
22
|
"src/store.js",
|
|
22
23
|
"src/folders.js",
|
|
23
24
|
"src/localfiles.js",
|
|
24
|
-
"src/executor.js",
|
|
25
25
|
"src/browser.js",
|
|
26
26
|
"src/blocks.js",
|
|
27
27
|
"src/session.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@modelcontextprotocol/client": "2.0.0"
|
|
55
55
|
},
|
|
56
|
-
"description": "The Vecteur command line
|
|
56
|
+
"description": "The Vecteur command line — one login, the same product as the web app, from any directory.",
|
|
57
57
|
"license": "UNLICENSED",
|
|
58
58
|
"repository": "git+https://github.com/vecteurspace/vecteur-cli.git",
|
|
59
59
|
"publishConfig": {
|