@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/src/localfiles.js CHANGED
@@ -45,8 +45,6 @@ export function qualify({ platform = process.platform, version = process.version
45
45
  const [major, minor] = version.split('.').map(Number);
46
46
  if (platform !== 'linux' || major < 20 || (major === 20 && minor < 8)) fail('platform_unqualified', 'Local file authority requires Linux and Node >=20.8');
47
47
  }
48
- export const localProcessEnv = (env, root) => ({ PATH: env.PATH ?? '/usr/bin:/bin', HOME: env.HOME ?? root,
49
- TMPDIR: env.TMPDIR, XDG_CONFIG_HOME: env.XDG_CONFIG_HOME, LANG: 'C.UTF-8', PYTHONDONTWRITEBYTECODE: '1' });
50
48
  function directory(env) { return dirname(credentialsPath(env)); }
51
49
  function store(env, name) { return join(directory(env), name + '.json'); }
52
50
  function readGrants(env) {
@@ -137,8 +135,7 @@ export function endGrants({ origin, accountId, root } = {}, env = process.env) {
137
135
  const value = readGrants(env);
138
136
  const intent = journal(env); intent.grantEnds ??= {};
139
137
  const affected = [];
140
- // An invocation may hold only an in-memory execution marker. An explicit folder
141
- // revoke must still advance its generation, even before any file grant exists.
138
+ // An explicit folder revoke advances its generation even before any file grant exists.
142
139
  const explicit = origin && accountId && root ? {
143
140
  [grantKey({ origin, accountId, root: { path: root } })]: { origin, accountId, root: { path: root }, generation: 0 },
144
141
  } : {};
@@ -185,26 +182,9 @@ export function rootIdentity(path) {
185
182
  if (!info.isDirectory()) fail('folder_invalid');
186
183
  return { path: real, ...inode(info) };
187
184
  }
188
- export function executionGrant(pin, env = process.env) {
185
+ export function pinCheck(grant, pin, env = process.env) {
189
186
  requireLock(env);
190
- const grant = currentGrant(pin, env) ?? { ...pin, generation: readGrants(env).generations[grantKey(pin)] ?? 0 };
191
- return { ...grant, execCredential: pin.credential.token, execPid: process.pid };
192
- }
193
- export function checkGrantLive(grant, pin, env = process.env) {
194
- requireLock(env);
195
- if (grant.accountId !== pin.accountId || grant.origin !== pin.origin || grant.root.path !== pin.root.path || grant.execCredential !== pin.credential.token
196
- || (readGrants(env).generations[grantKey(grant)] ?? 0) !== grant.generation) fail('grant_changed', 'Local permission changed; draft kept. Confirm again.');
197
- }
198
- export function consumeExec(runId, requestId, env = process.env) {
199
- requireLock(env);
200
- const value = journal(env); value.executions ??= [];
201
- if (value.executions.some(row => row.runId === runId && row.requestId === requestId)) fail('executor_consumed');
202
- value.executions.push({runId,requestId}); saveJournal(env,value);
203
- }
204
- export function pinCheck(grant, pin, env = process.env, { execution = false } = {}) {
205
- requireLock(env);
206
- if (execution && (grant.execCredential !== pin.credential.token || grant.execPid !== process.pid)) fail('grant_changed');
207
- const live = currentGrant(grant, env) ?? (execution && (readGrants(env).generations[grantKey(grant)] ?? 0) === grant.generation ? grant : null);
187
+ const live = currentGrant(grant, env);
208
188
  if (!live || live.generation !== grant.generation || live.projectId !== pin.projectId
209
189
  || pin.accountId !== grant.accountId || pin.origin !== grant.origin) fail('grant_changed', 'Local permission changed; draft kept. Confirm again.');
210
190
  if (pin.role === 'VIEWER') fail('role_forbidden');
@@ -578,7 +558,6 @@ export async function writeProposalConfined(grant, rel, fetchBytes, expected, op
578
558
  }
579
559
  export function admissionIntent(origin, projectId, key, body, env = process.env) {
580
560
  requireLock(env); const j = journal(env);
581
- if (body.local_exec !== undefined) fail('admission_unresolved', 'Execution consent cannot be frozen; observe the Project history');
582
561
  j.admissions ??= {};
583
562
  const id = hash(JSON.stringify([origin, projectId, key]));
584
563
  const prior = j.admissions[id];
@@ -595,9 +574,8 @@ export async function reconcileAdmissions(client, origin, env = process.env) {
595
574
  requireLock(env);
596
575
  for (const [id, row] of Object.entries(journal(env).admissions ?? {})) {
597
576
  if (row.origin !== origin) continue;
598
- if (row.body?.local_exec !== undefined) fail('admission_unresolved', 'Saved execution consent expired; observe the Project history');
599
577
  try { await client.runAdmit(row.projectId, row.body, row.key); admissionResolved(id, env); }
600
- catch (e) { if (e.admission === 'refused' || ['state_fork', 'state_busy'].includes(e.code)) admissionResolved(id, env); else throw e; }
578
+ catch (e) { if (e.admission === 'refused' || ['state_fork', 'state_busy', 'not_supported', 'project_read_only'].includes(e.code)) admissionResolved(id, env); else throw e; }
601
579
  }
602
580
  }
603
581
 
package/src/markdown.js CHANGED
@@ -1,12 +1,44 @@
1
1
  // GENERATED from frontend/src/run/markdown.ts; no runtime frontend dependency.
2
+ export const studyPath = (value) => value.replace(/(?<![\w.-])(?:\/work)?\/study\//g, '');
3
+ export const readerPaths = (source) => studyPath(source.replace(/`(?:\/work)?\/study\/?`|(?<![\w/.-])(?:\/work)?\/study\/?(?=[\s:;,.!?)]|$)/g, 'the study folder'));
4
+ const LISTED_FILE = /^\s*[-*]\s+`?[\w./-]+\.\w{1,5}`?\s*$/;
5
+ const LIST_LEAD = /^(?:\*\*)?(?:all\s+|the\s+)?(?:files?|deliverables?|outputs?|everything)\b[^\n]*:\s*(?:\*\*)?$/i;
6
+ export function withoutClosingFileList(source) {
7
+ const lines = source.split('\n');
8
+ const out = [];
9
+ for (let at = 0; at < lines.length; at += 1) {
10
+ if (LIST_LEAD.test(readerPaths(lines[at]).trim())) {
11
+ let end = at + 1;
12
+ while (end < lines.length && lines[end].trim() === '')
13
+ end += 1;
14
+ let last = end;
15
+ while (last < lines.length && LISTED_FILE.test(lines[last]))
16
+ last += 1;
17
+ if (last > end && (last === lines.length || !/^\s*[-*]\s/.test(lines[last]))) {
18
+ at = last - 1;
19
+ while (out.length && out.at(-1).trim() === '')
20
+ out.pop();
21
+ continue;
22
+ }
23
+ }
24
+ out.push(lines[at]);
25
+ }
26
+ return out.join('\n').trimEnd();
27
+ }
28
+ export function closeOpenMarks(source) {
29
+ if (source.split('\n').filter((line) => /^\s*```/.test(line)).length % 2)
30
+ return `${source}\n${'```'}`;
31
+ const text = /^\s*```/.test(source.split('\n').at(-1) ?? '') ? source : source.replace(/(?:\*\*|`)+$/, '');
32
+ const plain = text.replace(/```[\s\S]*?```/g, '');
33
+ const code = (plain.match(/`/g) ?? []).length % 2 === 1;
34
+ const bold = (plain.replace(/`[^`]*`?/g, '').match(/\*\*/g) ?? []).length % 2 === 1;
35
+ return `${text}${code ? '`' : ''}${bold && !code ? '**' : ''}`;
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');
2
39
  export function inlinePlain(inline) {
3
40
  return inline.map((token) => token.text).join('');
4
41
  }
5
- export function tableGrid(block) {
6
- const header = block.header.map(inlinePlain);
7
- const rows = block.rows.map((row) => row.map(inlinePlain));
8
- return header.length ? [header, ...rows] : rows;
9
- }
10
42
  const INLINE_PATTERN = /(!\[[^\]]*\]\([^)\s]+\)|`[^`]+`|\[[^\]\n]+\]\([^)\s]+\)|\*\*[^*]+\*\*|\*[^*]+\*|\$[A-Za-z_][A-Za-z0-9_.]*\$)/g;
11
43
  const LINK_TOKEN = /^\[([^\]\n]+)\]\(([^)\s]+)\)$/;
12
44
  const IMAGE_TOKEN = /^!\[([^\]]*)\]\(([^)\s]+)\)$/;
@@ -79,66 +111,6 @@ export function parseInline(text) {
79
111
  }
80
112
  return out;
81
113
  }
82
- export function withholdOpenTokens(text) {
83
- const scrubbed = text.replace(/\\[*`$]/g, ' ');
84
- const cuts = [];
85
- const backticks = [...scrubbed.matchAll(/`/g)];
86
- if (backticks.length % 2 === 1)
87
- cuts.push(backticks[backticks.length - 1].index ?? 0);
88
- const bolds = [...scrubbed.matchAll(/\*\*/g)];
89
- if (bolds.length % 2 === 1)
90
- cuts.push(bolds[bolds.length - 1].index ?? 0);
91
- const openReference = /\$[A-Za-z_][A-Za-z0-9_.]*$/.exec(scrubbed);
92
- if (openReference)
93
- cuts.push(openReference.index);
94
- const openLink = /\[[^\]\n]*\]\([^)\s]*$/.exec(scrubbed);
95
- if (openLink)
96
- cuts.push(openLink.index);
97
- const tablePrefix = trailingTableDelimiterPrefix(text);
98
- if (tablePrefix !== null)
99
- cuts.push(tablePrefix);
100
- if (!cuts.length)
101
- return text;
102
- return text.slice(0, Math.min(...cuts));
103
- }
104
- function trailingTableDelimiterPrefix(text) {
105
- const lines = text.split('\n');
106
- if (lines.length < 2)
107
- return null;
108
- const candidate = lines[lines.length - 1];
109
- const header = lines[lines.length - 2];
110
- if (!TABLE_ROW.test(candidate) || !TABLE_ROW.test(header))
111
- return null;
112
- if (lines.slice(0, -1).filter((line) => line.startsWith('```')).length % 2 === 1)
113
- return null;
114
- if (lines.length > 2 && TABLE_ROW.test(lines[lines.length - 3]))
115
- return null;
116
- const cells = (line) => line.trim().replace(/^\||\|$/g, '').split('|').map((cell) => cell.trim());
117
- const delimiter = cells(candidate);
118
- const headerCells = cells(header);
119
- if (delimiter.length >= headerCells.length)
120
- return null;
121
- if (!delimiter.every((cell) => /^:?-+:?$/.test(cell)))
122
- return null;
123
- return text.lastIndexOf('\n') + 1;
124
- }
125
- export function splitStream(source) {
126
- const lines = source.split('\n');
127
- let fenceOpen = -1;
128
- let offset = 0;
129
- for (const line of lines) {
130
- if (line.startsWith('```'))
131
- fenceOpen = fenceOpen === -1 ? offset : -1;
132
- offset += line.length + 1;
133
- }
134
- if (fenceOpen !== -1) {
135
- return { frozen: source.slice(0, fenceOpen), tail: source.slice(fenceOpen) };
136
- }
137
- const boundary = source.lastIndexOf('\n\n');
138
- if (boundary === -1)
139
- return { frozen: '', tail: source };
140
- return { frozen: source.slice(0, boundary + 2), tail: source.slice(boundary + 2) };
141
- }
142
114
  export function parseMarkdown(source) {
143
115
  const blocks = [];
144
116
  const lines = source.split('\n');
@@ -202,12 +174,15 @@ export function parseMarkdown(source) {
202
174
  if (BULLET_ROW.test(line) || NUMBERED_ROW.test(line)) {
203
175
  const ordered = NUMBERED_ROW.test(line);
204
176
  const pattern = ordered ? NUMBERED_ROW : BULLET_ROW;
177
+ const base = /^\s*/.exec(line)[0].length;
205
178
  const items = [];
206
179
  while (index < lines.length) {
207
- const item = pattern.exec(lines[index]);
208
- if (!item)
180
+ const indent = /^\s*/.exec(lines[index])[0].length;
181
+ const nested = indent >= base + 2 && items.length > 0;
182
+ const item = (nested ? BULLET_ROW.exec(lines[index]) ?? NUMBERED_ROW.exec(lines[index]) : pattern.exec(lines[index]));
183
+ if (!item || (!nested && indent > base + 1))
209
184
  break;
210
- items.push(parseInline(item[1]));
185
+ items.push({ inline: parseInline(item[1]), depth: nested ? 1 : 0, ordered: nested ? NUMBERED_ROW.test(lines[index]) : ordered });
211
186
  index += 1;
212
187
  }
213
188
  blocks.push({ kind: 'list', ordered, items });
package/src/mcp.js CHANGED
@@ -5,9 +5,9 @@ import { McpServer } from "@modelcontextprotocol/server";
5
5
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
6
6
  import * as z from "zod/v4";
7
7
 
8
- import { CliError, VecteurClient, redact } from "./client.js";
9
- import { EVENT_KINDS, RETIRED_EVENT_KINDS, STORED_WIRE_VERSIONS, TERMINAL_STATES } from "./contract.js";
10
- import { canonicalJson } from "./format.js";
8
+ import { CliError, OWNER_WORDED, VecteurClient, redact } from "./client.js";
9
+ import { EVENT_KINDS, STORED_WIRE_VERSIONS, TERMINAL_STATES } from "./contract.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";
@@ -21,21 +21,11 @@ const selectionInput = z.object({
21
21
  selected_extract_ids: z.array(z.string().min(1)).min(1),
22
22
  method: z.literal("exact-extract"),
23
23
  }).strict();
24
- // v5 §2.5 explicit Produce: one named specialist child, started by the host before Engineering's turn. A38: Code Produce
25
- // is off at the run door, so this tool does not offer it; the door's `produce_unavailable` words still name any entry kept off.
26
- const produceInput = z.object({
27
- specialist: z.enum(["business", "knowledge"]).describe("Business, or Knowledge documents (profile nasa or esa; a document needs a completed analysis in this Project first)"),
28
- mode: z.string().min(1).max(64),
29
- target: z.string().min(1).max(256).optional(),
30
- profile: z.string().min(1).max(256).optional(),
31
- standard: z.string().min(1).max(256).optional(),
32
- }).strict();
33
24
  const submitInput = z.object({
34
25
  project_id: z.string().min(1),
35
26
  ask: z.string().min(1),
36
27
  selections: z.array(selectionInput).min(1).optional(),
37
28
  discard_pending_material: z.boolean().optional(),
38
- produce: produceInput.optional(),
39
29
  }).strict();
40
30
  const runInput = z.object({ run_id: z.string().min(1) }).strict();
41
31
  const startInput = z.object({
@@ -49,21 +39,15 @@ const ackFields = {
49
39
  run_id: z.string().min(1), state_hash: z.string().min(1),
50
40
  accepted_at: z.number().int().safe(), requested_route_id: z.string().min(1),
51
41
  };
52
- const ackOutput = z.object(ackFields).strict();
53
42
  const startOutput = z.object({ ...ackFields, parent_state_hash: z.string().nullable() }).strict();
54
- const answerInput = z.object({
55
- run_id: z.string().min(1), clarification_id: z.string().min(1),
56
- answers: z.array(z.object({ id: z.string().min(1), selected: z.array(z.string()),
57
- custom: z.string().nullable().optional() }).strict()).min(1),
58
- }).strict();
43
+ // The four wire v6 states, or "" while the Run is open.
44
+ const terminalOutput = z.union([z.enum([...TERMINAL_STATES]), z.literal("")]);
59
45
  const statusOutput = z.object({
60
- run_id: z.string().min(1), terminal: z.union([z.enum([...TERMINAL_STATES]), z.literal("")]),
61
- last_seq: z.number().int().safe().min(-1), clarification: z.record(z.string(), z.json()).nullable(),
46
+ run_id: z.string().min(1), terminal: terminalOutput, last_seq: z.number().int().safe().min(-1),
62
47
  }).strict();
63
- const eventKind = z.enum([...EVENT_KINDS, ...RETIRED_EVENT_KINDS]);
64
48
  const eventOutput = z.object({
65
49
  run_id: z.string().min(1), seq: z.number().int().safe().nonnegative(),
66
- kind: eventKind,
50
+ kind: z.enum([...EVENT_KINDS]),
67
51
  payload: z.record(z.string(), z.json()),
68
52
  }).strict();
69
53
  const memberOutput = z.object({
@@ -75,53 +59,28 @@ const projectOutput = z.object({
75
59
  workspace_id: z.string().min(1), role: z.enum(["OWNER", "EDITOR", "VIEWER"]),
76
60
  members: z.array(memberOutput),
77
61
  created_at: z.number().int().safe(), updated_at: z.number().int().safe(),
62
+ engine: z.enum(["v5", "v6"]).optional(),
78
63
  }).strict();
79
- const billableDimensionsOutput = z.object({
80
- uncached_input: z.number().int().safe().nonnegative(),
81
- cache_read: z.number().int().safe().nonnegative(),
82
- cache_write: z.number().int().safe().nonnegative(),
83
- output: z.number().int().safe().nonnegative(),
84
- cache_write_class: z.string().min(1).nullable().optional(),
85
- cache_write_duration_s: z.number().int().safe().nonnegative().nullable().optional(),
86
- provider_tier: z.string().min(1).nullable().optional(),
87
- long_context_band: z.string().min(1).nullable().optional(),
88
- }).strict();
89
- const runControlEgressOutput = z.object({
90
- candidate: z.number().int().safe().nonnegative(),
91
- call: z.number().int().safe().nonnegative(),
92
- }).strict();
93
- const runControlOutput = z.object({
94
- id: z.string().min(1),
95
- kind: z.enum(["steer", "answer_now"]),
96
- sequence: z.number().int().safe().positive(),
97
- state: z.enum(["queued", "claimed", "dispatched", "not_dispatched"]),
98
- attempt: z.number().int().safe().nonnegative().nullable(),
99
- step: z.number().int().safe().nonnegative().nullable(),
100
- egress: runControlEgressOutput.nullable(),
101
- text: z.string().nullable().optional(),
102
- }).strict();
103
- const admittedOutput = z.object({
104
- run_id: z.string().min(1), state_hash: z.string().min(1), result_hash: z.string(),
105
- requested_route_id: z.string().min(1), profile: z.string().min(1),
106
- stored_wire_version: z.union(STORED_WIRE_VERSIONS.map(version => z.literal(version))),
107
- terminal: z.union([z.enum([...TERMINAL_STATES]), z.literal("")]),
64
+ // The owner's RunRecord, field for field; identity, state and events are checked, usage is the owner's object as served.
65
+ const runOutput = z.object({
66
+ run_id: z.string().min(1), project_id: z.string().min(1).optional(),
67
+ state_hash: z.string().regex(/^[0-9a-f]{64}$/), result_hash: z.string(),
68
+ requested_route_id: z.string().min(1).optional(), profile: z.string().optional(),
69
+ stored_wire_version: z.union(STORED_WIRE_VERSIONS.map(version => z.literal(version))).optional(),
70
+ terminal: terminalOutput,
71
+ usage: z.record(z.string(), z.json()).nullable().optional(),
72
+ accepted_at: z.number().int().safe().optional(),
108
73
  duration_seconds: z.number().int().safe().nonnegative().nullable().optional(),
109
- usage: z.object({
110
- coverage: z.enum(["complete", "incomplete"]), provider_id: z.string().min(1),
111
- model_id: z.string().min(1), observed_at: z.number().int().safe().nonnegative(),
112
- billable_dimensions: z.array(billableDimensionsOutput).min(1),
113
- }).strict(),
114
74
  events: z.array(eventOutput),
115
- controls: z.array(runControlOutput),
116
75
  }).strict().refine(value => value.terminal === ""
117
76
  ? value.result_hash === "" && value.events.at(-1)?.kind !== "terminal"
118
- : value.result_hash.length > 0, "Run terminal and result hash are not paired");
77
+ : value.result_hash.length > 0 && value.events.at(-1)?.kind === "terminal", "Run terminal and result hash are not paired");
119
78
 
120
79
  const artifactInput = z.object({
121
80
  project_id: z.string().min(1),
122
81
  cas_ref: z.string().regex(/^sha256:[0-9a-f]{64}$/).optional(),
123
82
  run_id: z.string().min(1).optional(),
124
- artifact_id: z.string().min(1).optional(),
83
+ artifact_path: z.string().min(1).optional(),
125
84
  output: z.string().min(1).optional(),
126
85
  }).strict();
127
86
  const artifactOutput = z.object({
@@ -140,6 +99,19 @@ const materialOutput = z.object({
140
99
  extract_count: z.number().int().safe().nonnegative(),
141
100
  selections: z.array(selectionInput).min(1),
142
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();
143
115
 
144
116
  function success(value) {
145
117
  return {
@@ -151,8 +123,10 @@ function success(value) {
151
123
  function failure(error, lifecycle = false) {
152
124
  const code = error instanceof CliError && /^[a-z][a-z0-9_]{0,63}$/.test(error.code)
153
125
  ? error.code : "internal_error";
154
- // A38: the run door's product words naming the Produce entry it keeps off (validated by the client) ride along.
155
- const message = code === "produce_unavailable" ? { message: error.message } : {};
126
+ // A read-only (v5) Project and a retired door carry the owner's own sentence (validated by the client).
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 } : {};
156
130
  const details = Object.fromEntries((lifecycle ? ["run_id", "request_key", "parent_state_hash", "pending"] : ["run_id", "pending"])
157
131
  .filter(field => error instanceof CliError && Object.hasOwn(error, field))
158
132
  .map(field => [field, typeof error[field] === "string" ? redact(error[field]) : error[field]]));
@@ -172,8 +146,19 @@ function tool(server, name, description, inputSchema, outputSchema, call, lifecy
172
146
  });
173
147
  }
174
148
 
175
- export function createVecteurMcpServer(client = new VecteurClient(), shutdownSignal = undefined) {
149
+ export async function createVecteurMcpServer(client = new VecteurClient(), shutdownSignal = undefined) {
176
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
+ }
177
162
  // Upload is not admission. Pending material lives in the private local store beside the login,
178
163
  // so a restarted server still refuses a submit/start that omits it. It is kept until a submit/start
179
164
  // succeeds, including after refusals, unless the caller deliberately discards this Project's material.
@@ -212,42 +197,38 @@ export function createVecteurMcpServer(client = new VecteurClient(), shutdownSig
212
197
 
213
198
  tool(server, "vecteur_run_submit",
214
199
  "Submit an ask and return its terminal record. Pass vecteur_material_attach's returned selections verbatim; omitting this Project's pending material refuses, also after a server restart (attach again for its selections). Set discard_pending_material=true to forget this Project's pending material and use only the supplied selections (or none). For long Runs use vecteur_run_start and poll vecteur_run_status.",
215
- submitInput, admittedOutput, async ({ project_id: projectId, ask, selections, discard_pending_material, produce }, context) => {
200
+ submitInput, runOutput, async ({ project_id: projectId, ask, selections, discard_pending_material }, context) => {
216
201
  const progressToken = context.mcpReq._meta?.progressToken;
217
202
  const onEvent = progressToken === undefined ? null : (event) => context.mcpReq.notify({
218
203
  method: "notifications/progress",
219
204
  params: {
220
205
  progressToken,
221
- progress: event.seq + 1,
206
+ progress: event.seq, // events are numbered from 1 (wire.js FIRST_EVENT_SEQ): the count delivered
222
207
  message: event.kind,
223
208
  },
224
209
  });
225
- return withMaterial(projectId, selections, discard_pending_material, () => client.runSubmit(projectId, ask, onEvent, signal(context), undefined, selections,
226
- produce === undefined ? undefined : { kind: "produce", ...produce }));
210
+ return withMaterial(projectId, selections, discard_pending_material, () => client.runSubmit(projectId, ask, onEvent, signal(context), undefined, selections));
227
211
  });
228
212
 
229
- tool(server, "vecteur_run_get", "Get one Vecteur run record, including an open run.", runInput, admittedOutput,
213
+ tool(server, "vecteur_run_get", "Get one Vecteur run record, including an open run.", runInput, runOutput,
230
214
  ({ run_id: runId }, context) => client.runGet(runId, signal(context)));
231
215
 
232
216
  tool(server, "vecteur_run_events", "Validate run events against its direct record.", runInput,
233
- admittedOutput, ({ run_id: runId }, context) => client.runEvents(runId, null, signal(context)));
217
+ runOutput, ({ run_id: runId }, context) => client.runEvents(runId, null, signal(context)));
234
218
 
235
219
  tool(server, "vecteur_run_start", "Admit without waiting. Pass attached material's returned selections verbatim; omitting this Project's pending material refuses, also after a server restart (attach again for its selections). Set discard_pending_material=true to forget this Project's pending material and use only the supplied selections (or none). Freeze request_key, ask and parent_state_hash (null for no head) for retries. Detaching never cancels.",
236
220
  startInput, startOutput, ({ project_id, ask, request_key, parent_state_hash, selections, discard_pending_material }, context) =>
237
221
  withMaterial(project_id, selections, discard_pending_material, () => client.runStart(project_id, ask, {
238
222
  requestKey: request_key, parentStateHash: parent_state_hash, selections, signal: signal(context),
239
223
  })), true);
240
- tool(server, "vecteur_run_status", "Poll one bounded Run record; preserve its terminal and latest requested clarification verbatim.",
224
+ tool(server, "vecteur_run_status", "Poll one bounded Run record: its terminal state (completed, failed, cancelled, budget; empty while open) and last event sequence. A question from the agent is its answer; reply with a new ask.",
241
225
  runInput, statusOutput, ({ run_id }, context) => client.runStatus(run_id, signal(context)), true);
242
- tool(server, "vecteur_clarification_answer", "Answer the requested clarification with wire answers, including multi-select and custom text. Stale or duplicate answers refuse.",
243
- answerInput, ackOutput, ({ run_id, clarification_id, answers }, context) =>
244
- client.clarificationAnswer(run_id, clarification_id, answers, signal(context)), true);
245
226
 
246
227
  const cwd = process.cwd();
247
228
  tool(server, "vecteur_artifact_get",
248
- "Download one run artifact into the server's working folder (never outside it), verified against its sha256 CAS id. Give cas_ref, or run_id with artifact_id. Never overwrites.",
249
- artifactInput, artifactOutput, ({ project_id: projectId, cas_ref: casRef, run_id: runId, artifact_id: artifactId, output }, context) =>
250
- artifactToFolder(client, { projectId, casRef, runId, artifactId, output, cwd, signal: signal(context) }));
229
+ "Download one run artifact into the server's working folder (never outside it), verified against its sha256 CAS id. Give cas_ref, or run_id with artifact_path. Never overwrites.",
230
+ artifactInput, artifactOutput, ({ project_id: projectId, cas_ref: casRef, run_id: runId, artifact_path: artifactPath, output }, context) =>
231
+ artifactToFolder(client, { projectId, casRef, runId, artifactPath, output, cwd, signal: signal(context) }));
251
232
 
252
233
  tool(server, "vecteur_material_attach",
253
234
  `Upload one local file to ${client.config.origin}. Pass the returned selections verbatim to vecteur_run_submit or vecteur_run_start for this Project; upload alone is not Run admission. Requires confirm_origin equal to that origin and expected_state_hash equal to the current head (null if none).`,
@@ -258,6 +239,9 @@ export function createVecteurMcpServer(client = new VecteurClient(), shutdownSig
258
239
  return result;
259
240
  });
260
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
+
261
245
  return server;
262
246
  }
263
247