@vecteur/cli 0.12.4 → 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 +11 -0
- package/bin/vecteur.js +22 -6
- package/package.json +2 -2
- package/src/client.js +24 -7
- package/src/commands.js +14 -1
- package/src/contract.js +1 -1
- package/src/format.js +23 -0
- package/src/markdown.js +2 -0
- package/src/mcp.js +32 -3
- package/src/session.js +2 -1
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ For scripts and explicit one-shot commands:
|
|
|
25
25
|
```bash
|
|
26
26
|
vecteur login
|
|
27
27
|
vecteur whoami
|
|
28
|
+
vecteur workflow list
|
|
29
|
+
vecteur workflow show review
|
|
28
30
|
vecteur project list
|
|
29
31
|
vecteur project create 'Transfer study'
|
|
30
32
|
vecteur project use 'Transfer study'
|
|
@@ -40,6 +42,12 @@ Use `vecteur login --origin URL` for another deployment. For automation, supply
|
|
|
40
42
|
through `VECTEUR_TOKEN` and its origin through `VECTEUR_BASE_URL`; never pass a token on argv.
|
|
41
43
|
`--help` and `--version` work without signing in.
|
|
42
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
|
+
|
|
43
51
|
`project list` shows authorized Projects and the server's Organization-wide active Project
|
|
44
52
|
allowance. `project create NAME --workspace NAME_OR_ID` chooses among multiple Workspaces; one
|
|
45
53
|
Workspace is implicit. Names must match exactly and uniquely, or use an id. Quota refusals show
|
|
@@ -76,6 +84,9 @@ SHA-256, and refuse to overwrite a local path. Use `--project ID` when no Projec
|
|
|
76
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`.
|
|
77
85
|
It also exposes `vecteur_run_start` and `vecteur_run_status` for long Runs. `vecteur_artifact_get`
|
|
78
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.
|
|
79
90
|
An MCP host supplies tool arguments; stdout carries only MCP protocol.
|
|
80
91
|
|
|
81
92
|
`vecteur mcp setup claude` (or `codex`) runs that vendor's own `mcp add` once so your Claude Code
|
package/bin/vecteur.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "../src/credentials.js";
|
|
11
11
|
import { downloadArtifact, exportRun } from "../src/download.js";
|
|
12
12
|
import { humanProjects, resolveNamed, resolveRunProject, resolveWorkspace } from "../src/projects.js";
|
|
13
|
-
import { canonicalJson, human, humanCost, progress } from "../src/format.js";
|
|
13
|
+
import { canonicalJson, human, humanCost, humanWorkflow, humanWorkflows, progress } from "../src/format.js";
|
|
14
14
|
import { openBrowser } from "../src/browser.js";
|
|
15
15
|
|
|
16
16
|
function manifest() {
|
|
@@ -43,7 +43,7 @@ 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>] | mcp
|
|
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
|
|
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>
|
|
@@ -156,6 +156,11 @@ function parseCommand(argv) {
|
|
|
156
156
|
return { kind: "project_use", name: args[2], origin, json };
|
|
157
157
|
}
|
|
158
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
|
+
}
|
|
159
164
|
if (workspace !== undefined) throw new CliError("usage_invalid", "Invalid command grammar");
|
|
160
165
|
if (args.length === 1 && args[0] === "login" && !local
|
|
161
166
|
&& projectId === undefined && ask === undefined && output === undefined) {
|
|
@@ -360,6 +365,20 @@ async function main() {
|
|
|
360
365
|
await whoami(command);
|
|
361
366
|
return;
|
|
362
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
|
+
}
|
|
363
382
|
|
|
364
383
|
const config = configuration(process.env, undefined, command.origin);
|
|
365
384
|
rememberOrigin(command.origin, config.origin, process.env);
|
|
@@ -415,10 +434,7 @@ async function main() {
|
|
|
415
434
|
renderOptions.projectId ??= config.projectId;
|
|
416
435
|
renderOptions.origin = config.origin;
|
|
417
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.
|
|
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
|
-
}
|
|
437
|
+
if (value.terminal === "budget") renderOptions.stopOffer = await client.stopOffer(value.run_id);
|
|
422
438
|
// The settled Run is printed first: a later cost read may fail loudly, never erase the answer.
|
|
423
439
|
process.stdout.write(human(value, renderOptions));
|
|
424
440
|
if (command.kind === "run_submit" && value.terminal !== "budget") {
|
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"
|
|
@@ -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": {
|
package/src/client.js
CHANGED
|
@@ -301,8 +301,10 @@ export class VecteurClient {
|
|
|
301
301
|
|
|
302
302
|
async request(method, path, { body, rawBody, contentType, idempotencyKey, accept, acceptEncoding, signal,
|
|
303
303
|
lastEventId, anonymousReadiness = false } = {}) {
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
// Anonymous: no credential and no client identity, for the public reads only (readiness, the workflows).
|
|
305
|
+
if (anonymousReadiness && (method !== "GET" || !["/api/ready", "/api/workflows"].includes(path)
|
|
306
|
+
|| body !== undefined || rawBody !== undefined)) {
|
|
307
|
+
throw new CliError("request_invalid", "Anonymous requests are restricted to readiness and the workflows");
|
|
306
308
|
}
|
|
307
309
|
if (body !== undefined && rawBody !== undefined) throw new CliError("request_invalid", "Choose JSON or raw bytes");
|
|
308
310
|
const controller = new AbortController();
|
|
@@ -426,6 +428,11 @@ export class VecteurClient {
|
|
|
426
428
|
&& error.message.length <= 512 && !/[\r\n\0]/.test(error.message)) {
|
|
427
429
|
ownerMessage = error.message;
|
|
428
430
|
}
|
|
431
|
+
// A workflow ask sent with a blank left (run admission): the server's sentence names the blank.
|
|
432
|
+
if (candidate === "field_invalid" && typeof error.message === "string" && error.message.length <= 512
|
|
433
|
+
&& error.message.startsWith("The question still holds an unfilled blank: ") && !/[\r\n\0]/.test(error.message)) {
|
|
434
|
+
try { ownerMessage = refuseSecretValue(error.message); } catch {}
|
|
435
|
+
}
|
|
429
436
|
if (
|
|
430
437
|
candidate === "client_outdated"
|
|
431
438
|
&& Object.keys(error).sort().join("\n") === "code\nmessage"
|
|
@@ -505,6 +512,21 @@ export class VecteurClient {
|
|
|
505
512
|
} finally { response[RELEASE_TIMEOUT]?.(); }
|
|
506
513
|
}
|
|
507
514
|
|
|
515
|
+
/** The guided workflows (`GET /api/workflows`): public, read anonymously, so before login too. */
|
|
516
|
+
async workflows(signal = undefined) {
|
|
517
|
+
const value = await this.#json("GET", "/api/workflows", { signal, anonymousReadiness: true });
|
|
518
|
+
const text = v => typeof v === "string" && v.length > 0;
|
|
519
|
+
const valid = exactKeys(value, ["object", "data", "has_more"]) && value.object === "list" && Array.isArray(value.data)
|
|
520
|
+
&& value.data.every(w => w && typeof w === "object" && /^[a-z][a-z0-9_]{0,63}$/.test(w.id)
|
|
521
|
+
&& [w.label, w.name, w.description, w.prompt].every(text)
|
|
522
|
+
&& w.steps && [w.steps.bring, w.steps.get].every(text)
|
|
523
|
+
&& (w.files === undefined || (w.files && text(w.files.label) && Array.isArray(w.files.formats)
|
|
524
|
+
&& w.files.formats.every(text)))
|
|
525
|
+
&& Array.isArray(w.arguments) && w.arguments.every(a => a && /^[A-Za-z0-9_]+$/.test(a.name) && text(a.description)));
|
|
526
|
+
if (!valid) throw new CliError("workflows_invalid", "Server returned malformed workflow data");
|
|
527
|
+
return value;
|
|
528
|
+
}
|
|
529
|
+
|
|
508
530
|
async projectCreate(name, workspaceId, signal = undefined, idempotencyKey = undefined) {
|
|
509
531
|
const value = await this.#json("POST", "/api/projects", {
|
|
510
532
|
body: { name, workspace_id: workspaceId }, signal, idempotencyKey,
|
|
@@ -829,11 +851,6 @@ export class VecteurClient {
|
|
|
829
851
|
}
|
|
830
852
|
}
|
|
831
853
|
|
|
832
|
-
/** The authenticated measurement door. Measurement never fails the reader's run. */
|
|
833
|
-
async stopEvent(runId, body, signal = undefined) {
|
|
834
|
-
try { await this.#json("POST", `/api/runs/${encodeURIComponent(runId)}/stop-offer/events`, { signal, body }); } catch (error) { if (error?.name === "AbortError") throw error; }
|
|
835
|
-
}
|
|
836
|
-
|
|
837
854
|
async runGet(runId, signal = undefined) {
|
|
838
855
|
const value = await this.#json("GET", `/api/runs/${encodeURIComponent(runId)}`, { signal });
|
|
839
856
|
return validateRun(value, runId);
|
package/src/commands.js
CHANGED
|
@@ -3,7 +3,8 @@ import { CliError } from "./errors.js";
|
|
|
3
3
|
import { runBlocks, blockText } from "./blocks.js";
|
|
4
4
|
import { openBrowser } from "./browser.js";
|
|
5
5
|
import { diagnose } from "./diagnostics.js";
|
|
6
|
-
import { humanCost, terminalText } from "./format.js";
|
|
6
|
+
import { humanCost, humanWorkflow, humanWorkflows, scaffold, terminalText } from "./format.js";
|
|
7
|
+
import { requestTimeout } from "./client.js";
|
|
7
8
|
import { preferences, savePreferences } from "./preferences.js";
|
|
8
9
|
|
|
9
10
|
export const SHORTCUTS = `Enter sends when ready; while a Run is working it keeps the draft.
|
|
@@ -75,6 +76,18 @@ add("project", "Choose a Project or start a new study draft", async (s, argument
|
|
|
75
76
|
if (s.run?.open || s.registry.state().pendingRun || s.registry.state().pendingCreate) throw new CliError("run_busy", "Resolve or finish the current Run before starting a new study");
|
|
76
77
|
await withAdmissionLock(() => s.registry.unlink(), s.env); s.binding = null; s.project = null; s.run = null; s.attachments = []; s.status = "New Project on first send"; s.change();
|
|
77
78
|
}, { argument: "[list]", requires: "login" });
|
|
79
|
+
add("workflow", "List the guided workflows, or start a draft from one", async (s, id) => {
|
|
80
|
+
if (s.offline) throw new CliError("action_unavailable", "Offline — /resume");
|
|
81
|
+
const { data } = await s.clientFactory({ origin: s.origin, token: "", timeout: requestTimeout(s.env) }).workflows();
|
|
82
|
+
if (!id) return s.message(humanWorkflows(data).trimEnd());
|
|
83
|
+
const workflow = data.find(item => item.id === id);
|
|
84
|
+
if (!workflow) throw new CliError("workflow_not_found", `No workflow ${id}; /workflow lists them`);
|
|
85
|
+
// The engineer's own text is never replaced; an untouched scaffold is.
|
|
86
|
+
if (s.draft.trim() && !data.map(scaffold).includes(s.draft)) throw new CliError("draft_kept", "Your draft is kept; /clear it first to start from a workflow");
|
|
87
|
+
// The blanks this draft may still hold: a send with one left is held here, before any upload or Project is made.
|
|
88
|
+
s.blanks = data.flatMap(item => item.arguments.map(argument => `[${argument.description}]`));
|
|
89
|
+
s.setDraft(scaffold(workflow)); s.message(humanWorkflow(workflow, false).trimEnd());
|
|
90
|
+
}, { argument: "[id]" });
|
|
78
91
|
add("link", "Link an existing Project to this folder", s => s.link(), { requires: "login" });
|
|
79
92
|
add("unlink", "Remove this folder's Project binding", async s => {
|
|
80
93
|
if (s.run?.open || s.busy || s.registry.state().pendingRun || s.registry.state().pendingCreate) throw new CliError("run_busy", "Resolve or finish the current Run before unlinking");
|
package/src/contract.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// GENERATED by scripts/gen-contract.mjs from the owner projections.
|
|
2
|
-
export const OWNER_CONTRACT_IDENTITY = "api-sha256:
|
|
2
|
+
export const OWNER_CONTRACT_IDENTITY = "api-sha256:bea0597dcb6e7e6d576ec53de9016f64c710b6787a0cfa7bcb7c6fe27e73989f;run-wire-sha256:678602fd4f1dba0493ad0f860be24bbf88532945edfe9dbe1555e5145bbbeefb";
|
|
3
3
|
export const MODEL_CHOICES = Object.freeze([{"route_id":"auto","label":"Auto","level":"balanced"},{"route_id":"claude_opus","label":"Claude Opus 5.5","level":"quality"},{"route_id":"claude_sonnet","label":"Claude Sonnet 5.5","level":"balanced"},{"route_id":"claude_haiku","label":"Claude Haiku 5.5","level":"economy"},{"route_id":"gpt_sol","label":"GPT-6.1 Sol","level":"quality"},{"route_id":"gpt_terra","label":"GPT-6.1 Terra","level":"balanced"},{"route_id":"gpt_luna","label":"GPT-6 Luna","level":"economy"},{"route_id":"mistral_large","label":"Mistral Large 4","level":"quality"},{"route_id":"deepseek_flash_eu","label":"DeepSeek V4.1 Flash","level":"balanced"}]);
|
|
4
4
|
export const EVENT_KINDS = Object.freeze(["assistant_delta","tool_call","tool_result","synthesis","artifact","study","review","terminal"]);
|
|
5
5
|
export const TOOL_KINDS = Object.freeze(["bash","python","read","write","edit","search","web","skill","other"]);
|
package/src/format.js
CHANGED
|
@@ -214,3 +214,26 @@ export function progress(event) {
|
|
|
214
214
|
export function plainLine(value) {
|
|
215
215
|
return String(value).replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ");
|
|
216
216
|
}
|
|
217
|
+
|
|
218
|
+
/** A workflow's prompt with each `{{name}}` replaced in ONE pass by a function: a value is never re-read as a blank or as `$&`. */
|
|
219
|
+
export function fillPrompt(workflow, valueOf) {
|
|
220
|
+
return workflow.prompt.replace(/\{\{([A-Za-z0-9_]+)\}\}/g, (blank, name) => {
|
|
221
|
+
const argument = workflow.arguments.find(item => item.name === name);
|
|
222
|
+
return argument ? valueOf(argument) : blank;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The ask the engineer edits: each blank shown as its description in brackets, as the web shows it. */
|
|
227
|
+
export const scaffold = workflow => fillPrompt(workflow, argument => `[${argument.description}]`);
|
|
228
|
+
|
|
229
|
+
export function humanWorkflows(workflows) {
|
|
230
|
+
return workflows.length ? workflows.map(w => `${plainLine(w.id)} · ${plainLine(w.name)} · ${plainLine(w.description)}\n`).join("")
|
|
231
|
+
: "No workflows.\n";
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function humanWorkflow(w, withScaffold = true) {
|
|
235
|
+
return [`${plainLine(w.name)} (${plainLine(w.id)})`, `You give: ${plainLine(w.steps.bring)}`,
|
|
236
|
+
...(w.files ? [`Attach: ${plainLine(w.files.label)} · ${w.files.formats.map(f => plainLine(f).toUpperCase()).join(" ")}`
|
|
237
|
+
+ (w.files.required ? " · required" : "")] : []),
|
|
238
|
+
`You get: ${plainLine(w.steps.get)}`, ...(withScaffold ? ["", terminalText(scaffold(w))] : []), ""].join("\n");
|
|
239
|
+
}
|
package/src/markdown.js
CHANGED
|
@@ -34,6 +34,8 @@ export function closeOpenMarks(source) {
|
|
|
34
34
|
const bold = (plain.replace(/`[^`]*`?/g, '').match(/\*\*/g) ?? []).length % 2 === 1;
|
|
35
35
|
return `${text}${code ? '`' : ''}${bold && !code ? '**' : ''}`;
|
|
36
36
|
}
|
|
37
|
+
const FIGURE_UNIT = /\b(\d+(?:[.,]\d+)?) (?=(?:%|‰|°[CFK]?|[A-Za-zµΩ][A-Za-zµΩ²³]{0,3}(?:[/·.][A-Za-zµΩ²³]{1,3})?)(?:$|[\s,;:.)\]]))/g;
|
|
38
|
+
export const keepUnits = (text) => text.replace(FIGURE_UNIT, '$1\u00a0');
|
|
37
39
|
export function inlinePlain(inline) {
|
|
38
40
|
return inline.map((token) => token.text).join('');
|
|
39
41
|
}
|
package/src/mcp.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as z from "zod/v4";
|
|
|
7
7
|
|
|
8
8
|
import { CliError, OWNER_WORDED, VecteurClient, redact } from "./client.js";
|
|
9
9
|
import { EVENT_KINDS, STORED_WIRE_VERSIONS, TERMINAL_STATES } from "./contract.js";
|
|
10
|
-
import { canonicalJson } from "./format.js";
|
|
10
|
+
import { canonicalJson, fillPrompt } from "./format.js";
|
|
11
11
|
import { artifactToFolder, materialAttach } from "./exchange.js";
|
|
12
12
|
import { credentialsPath } from "./credentials.js";
|
|
13
13
|
import { readStore, withStoreLock, writeStore } from "./store.js";
|
|
@@ -99,6 +99,19 @@ const materialOutput = z.object({
|
|
|
99
99
|
extract_count: z.number().int().safe().nonnegative(),
|
|
100
100
|
selections: z.array(selectionInput).min(1),
|
|
101
101
|
}).strict();
|
|
102
|
+
// `GET /api/workflows` as served: the guided workflows, each an MCP prompt below. The envelope is exact; a workflow
|
|
103
|
+
// is not (unlike the tools' records): the definitions are data that grows, and a member added there must not make
|
|
104
|
+
// an installed CLI refuse the list.
|
|
105
|
+
const text = z.string().min(1);
|
|
106
|
+
const workflowListOutput = z.object({
|
|
107
|
+
object: z.literal("list"), has_more: z.literal(false),
|
|
108
|
+
data: z.array(z.object({
|
|
109
|
+
id: text, label: text, name: text, description: text, prompt: text,
|
|
110
|
+
arguments: z.array(z.object({ name: text, description: text, required: z.literal(true) })),
|
|
111
|
+
files: z.object({ label: text, required: z.boolean(), formats: z.array(text) }).optional(),
|
|
112
|
+
steps: z.object({ bring: text, get: text }),
|
|
113
|
+
})),
|
|
114
|
+
}).strict();
|
|
102
115
|
|
|
103
116
|
function success(value) {
|
|
104
117
|
return {
|
|
@@ -111,7 +124,9 @@ function failure(error, lifecycle = false) {
|
|
|
111
124
|
const code = error instanceof CliError && /^[a-z][a-z0-9_]{0,63}$/.test(error.code)
|
|
112
125
|
? error.code : "internal_error";
|
|
113
126
|
// A read-only (v5) Project and a retired door carry the owner's own sentence (validated by the client).
|
|
114
|
-
|
|
127
|
+
// So does an ask refused for an unfilled workflow blank (the client kept only the server's sentence naming it).
|
|
128
|
+
const message = OWNER_WORDED.includes(code) || (code === "field_invalid" && error.message.startsWith("The question still holds an unfilled blank: "))
|
|
129
|
+
? { message: error.message } : {};
|
|
115
130
|
const details = Object.fromEntries((lifecycle ? ["run_id", "request_key", "parent_state_hash", "pending"] : ["run_id", "pending"])
|
|
116
131
|
.filter(field => error instanceof CliError && Object.hasOwn(error, field))
|
|
117
132
|
.map(field => [field, typeof error[field] === "string" ? redact(error[field]) : error[field]]));
|
|
@@ -131,8 +146,19 @@ function tool(server, name, description, inputSchema, outputSchema, call, lifecy
|
|
|
131
146
|
});
|
|
132
147
|
}
|
|
133
148
|
|
|
134
|
-
export function createVecteurMcpServer(client = new VecteurClient(), shutdownSignal = undefined) {
|
|
149
|
+
export async function createVecteurMcpServer(client = new VecteurClient(), shutdownSignal = undefined) {
|
|
135
150
|
const server = new McpServer({ name: "vecteur", version: "0.1.0" });
|
|
151
|
+
// Each workflow is a prompt, read from the route at start (prompts are registered before connect). An
|
|
152
|
+
// unreachable or older origin starts with no prompt, never a failure: the tools do not depend on it.
|
|
153
|
+
const workflows = await client.workflows(shutdownSignal).catch(() => ({ data: [] }));
|
|
154
|
+
for (const workflow of workflows.data) {
|
|
155
|
+
server.registerPrompt(`vecteur_${workflow.id}`, {
|
|
156
|
+
title: workflow.name, description: workflow.description,
|
|
157
|
+
argsSchema: z.object(Object.fromEntries(workflow.arguments.map(item => [item.name, text.describe(item.description)]))),
|
|
158
|
+
}, values => ({ messages: [{ role: "user", content: { type: "text", text: `${fillPrompt(workflow, item => values[item.name])}\n\n`
|
|
159
|
+
+ (workflow.files?.required ? "Attach the file first with vecteur_material_attach and pass its returned selections. " : "")
|
|
160
|
+
+ "Send this ask with vecteur_run_submit (or vecteur_run_start for a long run) in your project." } }] }));
|
|
161
|
+
}
|
|
136
162
|
// Upload is not admission. Pending material lives in the private local store beside the login,
|
|
137
163
|
// so a restarted server still refuses a submit/start that omits it. It is kept until a submit/start
|
|
138
164
|
// succeeds, including after refusals, unless the caller deliberately discards this Project's material.
|
|
@@ -213,6 +239,9 @@ export function createVecteurMcpServer(client = new VecteurClient(), shutdownSig
|
|
|
213
239
|
return result;
|
|
214
240
|
});
|
|
215
241
|
|
|
242
|
+
tool(server, "vecteur_workflow_list", "List the guided workflows (also served as this server's prompts): what to bring, what you get, and the ask with its {{blanks}}. Fill every blank, then send it with vecteur_run_submit.",
|
|
243
|
+
z.object({}).strict(), workflowListOutput, (_input, context) => client.workflows(signal(context)));
|
|
244
|
+
|
|
216
245
|
return server;
|
|
217
246
|
}
|
|
218
247
|
|
package/src/session.js
CHANGED
|
@@ -298,7 +298,6 @@ export class Session extends EventEmitter {
|
|
|
298
298
|
// At a limit the server says what this reader may do; a failed read names no plan and never fails the Run.
|
|
299
299
|
const stopOffer = run.terminal === "budget" ? await this.client.stopOffer(run.run_id) : undefined;
|
|
300
300
|
if (this.run !== run || this.closed) return false;
|
|
301
|
-
if (stopOffer) void this.client.stopEvent(run.run_id, { event: "shown", surface: "cli" });
|
|
302
301
|
const options = { stopOffer, origin: this.origin };
|
|
303
302
|
this.message(humanRun(run, options), "answer", { runId: run.run_id, sections: runSections(run, options) });
|
|
304
303
|
this.lastPrintedRun = run.run_id;
|
|
@@ -377,6 +376,8 @@ export class Session extends EventEmitter {
|
|
|
377
376
|
return;
|
|
378
377
|
}
|
|
379
378
|
this.setDraft(text);
|
|
379
|
+
const blank = this.blanks?.find(known => text.includes(known));
|
|
380
|
+
if (blank) { this.status = `Replace ${blank} with your own value, then send`; this.change(); return; } // the server refuses it too, later
|
|
380
381
|
this.registry?.saveDraft(text);
|
|
381
382
|
const draftRef = structuredClone(this.registry?.draftRef ?? null);
|
|
382
383
|
this.busy = true; this.status = "Submitting"; this.change();
|