@vecteur/cli 0.13.1 → 0.15.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 +1 -0
- package/bin/vecteur.js +5 -3
- package/package.json +1 -1
- package/src/client.js +29 -3
- package/src/commands.js +1 -0
- package/src/contract.js +14 -4
- package/src/mcp.js +6 -1
- package/src/projects.js +8 -1
- package/src/session.js +21 -8
package/README.md
CHANGED
|
@@ -176,6 +176,7 @@ Bare invocation in a pipe or CI keeps the previous status output; `vecteur statu
|
|
|
176
176
|
`/unlink` removes that association for this subtree and preserves the draft. `/name` renames
|
|
177
177
|
the current Project or names the one created on first send. `/history` loads older Runs on demand.
|
|
178
178
|
- `/model` selects the next Run's model from the product's model choices (Auto is the default).
|
|
179
|
+
- `/deep` turns deep engineering off (quick Runs) or back on; with Pro deep is the default, on Free the server refuses it and names the upgrade.
|
|
179
180
|
`/mode` explains model, execution location and payer. Runs execute in Vecteur cloud.
|
|
180
181
|
- `@` completes local paths. A whole filename in your ask offers attachment after local
|
|
181
182
|
checks (at most three offers; ambiguous basenames list choices).
|
package/bin/vecteur.js
CHANGED
|
@@ -283,7 +283,7 @@ async function logout(command, env = process.env) {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
function renderAccount(account, origin) {
|
|
286
|
-
return `${account.display_name} <${account.email}> (${account.id}) at ${origin}\n`;
|
|
286
|
+
return `${account.display_name} <${account.email}> (${account.id}) at ${origin} in ${account.organization_name}\n`;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
async function whoami(command, env = process.env) {
|
|
@@ -387,9 +387,11 @@ async function main() {
|
|
|
387
387
|
let value;
|
|
388
388
|
let renderOptions = {};
|
|
389
389
|
if (command.kind === "project_list") {
|
|
390
|
-
const [account, projects] = await Promise.all([
|
|
390
|
+
const [account, projects, storage] = await Promise.all([
|
|
391
|
+
client.accountMe(), client.projectList(), client.storageUsage(),
|
|
392
|
+
]);
|
|
391
393
|
value = { projects, active_projects: account.entitlements.active_projects,
|
|
392
|
-
selected_project_id: config.projectId ?? null };
|
|
394
|
+
selected_project_id: config.projectId ?? null, storage };
|
|
393
395
|
process.stdout.write(command.json ? canonicalJson(value) : humanProjects(value));
|
|
394
396
|
return;
|
|
395
397
|
} else if (command.kind === "project_create") {
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ARTIFACT_MEDIA_TYPES, OWNER_CONTRACT_IDENTITY, RECOVERY_ACTIONS, STORED_WIRE_VERSIONS, STORED_WIRE_VERSION_HEADER,
|
|
8
8
|
WIRE_READER_HEADER, WIRE_READER_VERSION, validateAccount, validateCliRelease, validateCustomerCostProjection,
|
|
9
9
|
validateDeviceAuthorization, validateLimitDenial, validatePatCreated, validateProject, validateQuotaDenial,
|
|
10
|
-
validateRunAck, validateRunStopOffer, validateSource, validateSourceOffer,
|
|
10
|
+
validateRunAck, validateRunStopOffer, validateSource, validateSourceOffer, validateStorageDenial, validateStorageUsage,
|
|
11
11
|
} from "./contract.js";
|
|
12
12
|
import { FIRST_EVENT_SEQ, isStateHash, validateEvent, validateRun } from "./wire.js";
|
|
13
13
|
import { credentialsPath, readCredentials } from "./credentials.js";
|
|
@@ -293,6 +293,9 @@ export async function parseSse(response, runId, onEvent = null, startSeq = FIRST
|
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
/** A history row as the newest-run overlay: the record, its acceptance time, its ask, and `review` when it is a recomputation. */
|
|
297
|
+
const newestRow = row => ({ ...row.response, accepted_at: row.accepted_at, ask: row.request.ask, ...(row.request.review ? { review: true } : {}) });
|
|
298
|
+
|
|
296
299
|
export class VecteurClient {
|
|
297
300
|
constructor(config = configuration(), fetchImpl = fetch) {
|
|
298
301
|
this.config = config;
|
|
@@ -405,6 +408,13 @@ export class VecteurClient {
|
|
|
405
408
|
ownerMessage = `${error.message}; ${quota.current} of ${quota.maximum} active projects used on the ${quota.tier} plan`
|
|
406
409
|
+ (actions.length ? `; next: ${actions.join("; ")}` : "");
|
|
407
410
|
}
|
|
411
|
+
if (candidate === "storage_exhausted") {
|
|
412
|
+
if (!validateStorageDenial(error.storage) || typeof error.message !== "string"
|
|
413
|
+
|| !error.message.length || /[\u0000-\u001f\u007f-\u009f]/.test(error.message)) {
|
|
414
|
+
throw new CliError("storage_invalid", "Server returned malformed storage refusal");
|
|
415
|
+
}
|
|
416
|
+
ownerMessage = [error.message, ...error.storage.usage.actions.map(action => action.label)].join(". ");
|
|
417
|
+
}
|
|
408
418
|
if (candidate === "customer_cost_exhausted") {
|
|
409
419
|
if (!validateLimitDenial(error.limit)) {
|
|
410
420
|
throw new CliError("customer_cost_invalid", "Server returned malformed customer-cost refusal");
|
|
@@ -447,7 +457,7 @@ export class VecteurClient {
|
|
|
447
457
|
} catch (error) {
|
|
448
458
|
if (error?.name === "AbortError") throw error;
|
|
449
459
|
if (error instanceof CliError && [
|
|
450
|
-
"secret_response_refused", "quota_invalid", "recovery_action_invalid", "customer_cost_invalid",
|
|
460
|
+
"secret_response_refused", "quota_invalid", "recovery_action_invalid", "customer_cost_invalid", "storage_invalid",
|
|
451
461
|
].includes(error.code)) refused = error;
|
|
452
462
|
}
|
|
453
463
|
if (refused) throw refused;
|
|
@@ -474,6 +484,14 @@ export class VecteurClient {
|
|
|
474
484
|
}
|
|
475
485
|
}
|
|
476
486
|
|
|
487
|
+
async storageUsage() {
|
|
488
|
+
const value = await this.#json("GET", "/api/storage/usage");
|
|
489
|
+
if (!validateStorageUsage(value)) {
|
|
490
|
+
throw new CliError("storage_invalid", "Server returned malformed storage usage");
|
|
491
|
+
}
|
|
492
|
+
return value;
|
|
493
|
+
}
|
|
494
|
+
|
|
477
495
|
async projectList(signal = undefined) {
|
|
478
496
|
const value = await this.#json("GET", "/api/projects", { signal });
|
|
479
497
|
if (!Array.isArray(value) || !value.every(validateProject)) {
|
|
@@ -694,7 +712,15 @@ export class VecteurClient {
|
|
|
694
712
|
}
|
|
695
713
|
// Client-local presentation overlay, as in the web transcript. Never write this
|
|
696
714
|
// timestamp into the immutable run record or send it back to the server.
|
|
697
|
-
return newest ?
|
|
715
|
+
return newest ? newestRow(newest) : null;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/** The newest Run that is a turn of the study: past any independent recomputation (`request.review`, v6.3), which shows
|
|
719
|
+
* and saves nothing of a turn. Parents still chain onto `projectNewestRun`: the true head. */
|
|
720
|
+
async projectNewestWriterRun(projectId, signal = undefined) {
|
|
721
|
+
const page = await this.projectHistory(projectId, { limit: 25, signal });
|
|
722
|
+
const row = page.runs.find(run => !run.request.review);
|
|
723
|
+
return row ? newestRow(row) : null;
|
|
698
724
|
}
|
|
699
725
|
|
|
700
726
|
async projectHistory(projectId, { limit = 25, before, signal } = {}) {
|
package/src/commands.js
CHANGED
|
@@ -37,6 +37,7 @@ add("drafts", "Recover a saved draft", s => s.recoverDraft());
|
|
|
37
37
|
add("clear", "Clear this draft; Ctrl+_ restores the edit", s => { s.lastClearedDraft = s.draft; s.setDraft(""); });
|
|
38
38
|
add("mode", "Model, execution location and payer", s => s.message(s.modeDetails()));
|
|
39
39
|
add("model", "Choose the next Run's model", s => s.modelChoice(), { requires: "login" });
|
|
40
|
+
add("deep", "Deep engineering off or on for the next Runs (on by default with Pro)", s => s.toggleDeep(), { requires: "login" });
|
|
40
41
|
add("usage", "Read the Project's server-authored usage", async s => {
|
|
41
42
|
if (!s.project) throw new CliError("project_unavailable", "Choose a Project first with /project");
|
|
42
43
|
const client = s.client, project = s.project;
|
package/src/contract.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// GENERATED by scripts/gen-contract.mjs from the owner projections.
|
|
2
|
-
export const OWNER_CONTRACT_IDENTITY = "api-sha256:
|
|
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"}]);
|
|
2
|
+
export const OWNER_CONTRACT_IDENTITY = "api-sha256:c23dad4f150e6ad870161c328ab599766d8d234b6d18ff7fa3a480c197af9ac4;run-wire-sha256:5f02687e884369a37c8a133cdadaba44ec5854b2365ffb0cc56655bf4299e84f";
|
|
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_62","label":"GPT-6.2 Sol","level":"quality"},{"route_id":"gpt_sol","label":"GPT-6.1 Sol","level":"quality","hidden":true},{"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"},{"route_id":"claude_fable","label":"Claude Fable 5.2","level":"quality"}]);
|
|
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"]);
|
|
6
6
|
export const TERMINAL_STATES = Object.freeze(["completed","failed","cancelled","budget"]);
|
|
@@ -8,7 +8,8 @@ export const TERMINAL_DEFECTS = Object.freeze(["budget_exhausted","cancelled","r
|
|
|
8
8
|
export const ARTIFACT_MEDIA_TYPES = Object.freeze({"binary":"application/octet-stream","code":"text/plain","csv":"text/csv","docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","html":"text/html","jpeg":"image/jpeg","json":"application/json","md":"text/markdown","pdf":"application/pdf","png":"image/png","svg":"image/svg+xml","xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
|
|
9
9
|
export const RECOVERY_ACTIONS = Object.freeze({"delete_project":{"label":"Delete a project","href":"/projects"},"upgrade_plan":{"label":"Upgrade your plan","href":"/dashboard/billing"},"wait_for_reset":{"label":"Wait until the UTC reset","href":null}});
|
|
10
10
|
export const STOP_ACTION_HREFS = Object.freeze({"upgrade_plan":"/dashboard/billing?checkout=pro","contact_sales":"/enterprise#enterprise-contact","see_usage":"/dashboard/billing"});
|
|
11
|
-
export const
|
|
11
|
+
export const STORAGE_GB = 1000000000;
|
|
12
|
+
export const PLAN_WORDS = Object.freeze({"enterprise_action":"Talk to us about Enterprise","free_price":"€0","pro_action":"Move to Pro","pro_price":"€50 per month per seat","pro_start":"Create an account to move to Pro","see_plan":"See your plan"});
|
|
12
13
|
export const WIRE_READER_HEADER = "Vecteur-Wire";
|
|
13
14
|
export const STORED_WIRE_VERSION_HEADER = "X-Vecteur-Stored-Wire-Version";
|
|
14
15
|
export const STORED_WIRE_VERSIONS = Object.freeze([6]);
|
|
@@ -16,8 +17,9 @@ export const WIRE_READER_VERSION = 6;
|
|
|
16
17
|
const shape=(v,r,o=[])=>!!v&&typeof v==="object"&&!Array.isArray(v)&&r.every(k=>Object.hasOwn(v,k))&&Object.keys(v).every(k=>r.includes(k)||o.includes(k));
|
|
17
18
|
const exact=(v,k)=>shape(v,k)&&Object.keys(v).length===k.length;
|
|
18
19
|
const text=(v)=>typeof v==="string"&&v.length>0; const integer=(v)=>Number.isSafeInteger(v);
|
|
19
|
-
const ownerAccount=v=>shape(v,["id","email","display_name","tier","org_id","organization_name","organization_role","workspaces","connectors","capabilities","entitlements","avatar_url","display_currency","model_cost_estimates","is_platform_operator"],[])&&(typeof v.id==="string")&&(typeof v.email==="string")&&(typeof v.display_name==="string")&&(ownerTier(v.tier))&&(typeof v.org_id==="string")&&(typeof v.organization_name==="string")&&((v.organization_role==="OWNER"||v.organization_role==="ADMIN"||v.organization_role==="MEMBER"))&&(Array.isArray(v.workspaces)&&v.workspaces.every(x=>ownerWorkspace(x)))&&(Array.isArray(v.connectors)&&v.connectors.every(x=>typeof x==="string"))&&(Array.isArray(v.capabilities)&&v.capabilities.every(x=>ownerCapability(x)))&&(ownerEntitlements(v.entitlements))&&((typeof v.avatar_url==="string"||v.avatar_url===null))&&((v.display_currency==="EUR"||v.display_currency==="USD"))&&(ownerModelCostEstimates(v.model_cost_estimates))&&(typeof v.is_platform_operator==="boolean");
|
|
20
|
+
const ownerAccount=v=>shape(v,["id","email","display_name","tier","org_id","organization_name","organization_role","organizations","workspaces","connectors","capabilities","entitlements","avatar_url","display_currency","model_cost_estimates","is_platform_operator"],[])&&(typeof v.id==="string")&&(typeof v.email==="string")&&(typeof v.display_name==="string")&&(ownerTier(v.tier))&&(typeof v.org_id==="string")&&(typeof v.organization_name==="string")&&((v.organization_role==="OWNER"||v.organization_role==="ADMIN"||v.organization_role==="MEMBER"))&&(Array.isArray(v.organizations)&&v.organizations.every(x=>ownerAccountOrganization(x)))&&(Array.isArray(v.workspaces)&&v.workspaces.every(x=>ownerWorkspace(x)))&&(Array.isArray(v.connectors)&&v.connectors.every(x=>typeof x==="string"))&&(Array.isArray(v.capabilities)&&v.capabilities.every(x=>ownerCapability(x)))&&(ownerEntitlements(v.entitlements))&&((typeof v.avatar_url==="string"||v.avatar_url===null))&&((v.display_currency==="EUR"||v.display_currency==="USD"))&&(ownerModelCostEstimates(v.model_cost_estimates))&&(typeof v.is_platform_operator==="boolean");
|
|
20
21
|
const ownerTier=v=>(v==="free"||v==="pro"||v==="enterprise");
|
|
22
|
+
const ownerAccountOrganization=v=>shape(v,["id","name","role","current"],[])&&(typeof v.id==="string")&&(typeof v.name==="string")&&((v.role==="OWNER"||v.role==="ADMIN"||v.role==="MEMBER"))&&(typeof v.current==="boolean");
|
|
21
23
|
const ownerWorkspace=v=>shape(v,["id","org_id","name","status"],[])&&(typeof v.id==="string")&&(typeof v.org_id==="string")&&(typeof v.name==="string")&&(v.status==="active");
|
|
22
24
|
const ownerCapability=v=>shape(v,["id","affordance","state","required_tier","reason","recovery"],[])&&(typeof v.id==="string")&&((v.affordance==="composer-source"||v.affordance==="workspace-export"||v.affordance==="composer-preference"))&&((v.state==="available"||v.state==="locked"||v.state==="disconnected"||v.state==="unavailable"))&&((v.required_tier==="pro"||v.required_tier==="enterprise"||v.required_tier===null))&&(typeof v.reason==="string")&&((typeof v.recovery==="string"||v.recovery===null));
|
|
23
25
|
const ownerEntitlements=v=>shape(v,["active_projects","seats"],[])&&(ownerActiveProjectEntitlement(v.active_projects))&&(ownerSeatEntitlement(v.seats));
|
|
@@ -41,11 +43,19 @@ const ownerSourceOffer=v=>shape(v,["id","sha256","project_id","source_handle","e
|
|
|
41
43
|
const ownerSourceHandle=v=>shape(v,["cas_ref","acquisition_ref"],[])&&typeof v.cas_ref==="string"&&typeof v.acquisition_ref==="string";
|
|
42
44
|
const ownerOfferExtract=v=>shape(v,["id","locator","extractor_id","extractor_version","text_sha256"],[])&&(typeof v.id==="string")&&(v.locator!==null&&typeof v.locator==="object"&&!Array.isArray(v.locator)&&Object.values(v.locator).every(x=>true))&&(typeof v.extractor_id==="string")&&(typeof v.extractor_version==="string")&&(typeof v.text_sha256==="string");
|
|
43
45
|
const ownerSourceObject=v=>shape(v,["cas_ref","sha256","size","content_type","acquisition_ref","acquisition"],[])&&(typeof v.cas_ref==="string")&&(typeof v.sha256==="string")&&(Number.isFinite(v.size))&&(typeof v.content_type==="string")&&(typeof v.acquisition_ref==="string")&&(ownerSourceAcquisition(v.acquisition));
|
|
46
|
+
const ownerStorageDenial=v=>shape(v,["operation","usage"],["shortfall_bytes"])&&((v.operation==="upload"||v.operation==="turn"))&&(ownerStorageUsage(v.usage))&&(v.shortfall_bytes===undefined||Number.isFinite(v.shortfall_bytes));
|
|
47
|
+
const ownerStorageUsage=v=>shape(v,["state","projects","actions"],["totals"])&&((v.state==="available"||v.state==="full"||v.state==="unavailable"))&&(Array.isArray(v.projects)&&v.projects.every(x=>ownerStorageProject(x)))&&(Array.isArray(v.actions)&&v.actions.every(x=>ownerStorageAction(x)))&&(v.totals===undefined||ownerStorageTotals(v.totals));
|
|
48
|
+
const ownerStorageProject=v=>shape(v,["id","name","working_bytes","object_bytes"],[])&&(typeof v.id==="string")&&(typeof v.name==="string")&&(Number.isFinite(v.working_bytes))&&(Number.isFinite(v.object_bytes));
|
|
49
|
+
const ownerStorageAction=v=>shape(v,["kind","label"],["href","project_id","room_bytes"])&&((v.kind==="request_storage"||v.kind==="delete_project"||v.kind==="upgrade_plan"))&&(typeof v.label==="string")&&(v.href===undefined||typeof v.href==="string")&&(v.project_id===undefined||typeof v.project_id==="string")&&(v.room_bytes===undefined||Number.isFinite(v.room_bytes));
|
|
50
|
+
const ownerStorageTotals=v=>shape(v,["used_bytes","ceiling_bytes","remaining_bytes"],[])&&(Number.isFinite(v.used_bytes))&&(Number.isFinite(v.ceiling_bytes))&&(Number.isFinite(v.remaining_bytes));
|
|
44
51
|
export const validateCliRelease=ownerCliRelease;
|
|
45
52
|
export const validateAccount=v=>ownerAccount(v)&&[v.id,v.email,v.display_name,v.org_id].every(text)&&v.workspaces.every(w=>[w.id,w.org_id,w.name].every(text))&&integer(v.entitlements.active_projects.current)&&v.entitlements.active_projects.current>=0&&(v.entitlements.active_projects.maximum===null||(integer(v.entitlements.active_projects.maximum)&&v.entitlements.active_projects.maximum>=0));
|
|
46
53
|
export const validateQuotaDenial=v=>ownerQuotaDenial(v)&&v.resource==="active_projects"&&integer(v.current)&&v.current>=0&&integer(v.maximum)&&v.maximum>=0&&text(v.tier);
|
|
47
54
|
const plainText=v=>text(v)&&!/[\u0000-\u001f\u007f-\u009f]/.test(v); const costText=v=>v===null||plainText(v); const money=v=>v===null||(integer(v)&&v>=0);
|
|
48
55
|
const costProjection=v=>[v.scope?.id,v.binding_scope?.scope?.id].every(plainText)&&[v.period_start,v.period_end,v.reset_at].every(x=>integer(x)&&x>=0&&x<=8640000000000)&&v.period_start<v.period_end&&v.reset_at===v.period_end&&[v.used,v.scope_used,v.limit,v.remaining].every(money)&&[v.display?.used,v.display?.scope_used,v.display?.limit,v.display?.remaining].every(costText)&&((v.scope_used===null)===(v.display.scope_used===null))&&(v.coverage==="complete"?(v.used!==null&&v.display.used!==null&&((v.limit===null&&v.remaining===null&&v.display.limit===null&&v.display.remaining===null)||(v.limit!==null&&v.remaining!==null&&v.display.limit!==null&&v.display.remaining!==null))):(v.used===null&&v.limit===null&&v.remaining===null&&v.display.used===null&&v.display.limit===null&&v.display.remaining===null));
|
|
56
|
+
const bytes=v=>integer(v)&&v>=0;
|
|
57
|
+
export const validateStorageUsage=v=>ownerStorageUsage(v)&&v.projects.every(p=>plainText(p.id)&&text(p.name)&&bytes(p.working_bytes)&&bytes(p.object_bytes))&&v.actions.every(a=>plainText(a.label)&&(a.room_bytes===undefined||bytes(a.room_bytes)))&&(v.totals===undefined||Object.values(v.totals).every(bytes));
|
|
58
|
+
export const validateStorageDenial=v=>ownerStorageDenial(v)&&validateStorageUsage(v.usage)&&(v.shortfall_bytes===undefined||bytes(v.shortfall_bytes));
|
|
49
59
|
export const validateRunStopOffer=v=>ownerRunStopOffer(v)&&plainText(v.run_id)&&integer(v.as_of)&&v.as_of>0;
|
|
50
60
|
export const validateCustomerCostProjection=v=>ownerCustomerCostProjection(v)&&costProjection(v);
|
|
51
61
|
export const validateLimitDenial=v=>ownerLimitDenial(v)&&costProjection(v)&&v.coverage==="incomplete"&&v.scope_used===null&&v.recovery.length>0;
|
package/src/mcp.js
CHANGED
|
@@ -6,7 +6,7 @@ import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
|
6
6
|
import * as z from "zod/v4";
|
|
7
7
|
|
|
8
8
|
import { CliError, OWNER_WORDED, VecteurClient, redact } from "./client.js";
|
|
9
|
-
import { EVENT_KINDS, STORED_WIRE_VERSIONS, TERMINAL_STATES } from "./contract.js";
|
|
9
|
+
import { EVENT_KINDS, MODEL_CHOICES, STORED_WIRE_VERSIONS, TERMINAL_STATES } from "./contract.js";
|
|
10
10
|
import { canonicalJson, fillPrompt } from "./format.js";
|
|
11
11
|
import { artifactToFolder, materialAttach } from "./exchange.js";
|
|
12
12
|
import { credentialsPath } from "./credentials.js";
|
|
@@ -239,6 +239,11 @@ export async function createVecteurMcpServer(client = new VecteurClient(), shutd
|
|
|
239
239
|
return result;
|
|
240
240
|
});
|
|
241
241
|
|
|
242
|
+
tool(server, "vecteur_model_list", "List model choices in the Vecteur catalogue. MCP Runs use the service and organization default.",
|
|
243
|
+
z.object({}).strict(), z.object({ models: z.array(z.object({
|
|
244
|
+
route_id: z.string(), label: z.string(), level: z.string(),
|
|
245
|
+
}).strict()) }).strict(), () => ({ models: MODEL_CHOICES.filter(row => !row.hidden) }));
|
|
246
|
+
|
|
242
247
|
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
248
|
z.object({}).strict(), workflowListOutput, (_input, context) => client.workflows(signal(context)));
|
|
244
249
|
|
package/src/projects.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { STORAGE_GB } from "./contract.js";
|
|
1
2
|
import { CliError } from "./errors.js";
|
|
2
3
|
|
|
3
4
|
/** Resolve only server-authorized objects. Ids take precedence over names. */
|
|
@@ -38,5 +39,11 @@ export function humanProjects(value) {
|
|
|
38
39
|
const rows = value.projects.map(project =>
|
|
39
40
|
`${project.id === value.selected_project_id ? "*" : " "} ${project.name} (${project.id}) ${project.role}`);
|
|
40
41
|
const allowance = value.active_projects;
|
|
41
|
-
|
|
42
|
+
const summary = value.storage.state === "unavailable" ? "Storage figure unavailable"
|
|
43
|
+
: `Storage: ${storageBytes(value.storage.projects.reduce((sum, project) => sum + project.working_bytes + project.object_bytes, 0))} in visible projects · ${value.storage.state}`;
|
|
44
|
+
return [...rows, `Active projects: ${allowance.current} / ${allowance.maximum ?? "Contract limit"}`, summary].join("\n") + "\n";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function storageBytes(bytes) {
|
|
48
|
+
return bytes < STORAGE_GB ? `${bytes} B` : `${Number((bytes / STORAGE_GB).toFixed(2))} GB`;
|
|
42
49
|
}
|
package/src/session.js
CHANGED
|
@@ -27,7 +27,7 @@ export class Session extends EventEmitter {
|
|
|
27
27
|
this.cwd = cwd; this.env = env; this.noBrowser = noBrowser; this.clientFactory = clientFactory;
|
|
28
28
|
this.origin = resolveOrigin(env, undefined, origin);
|
|
29
29
|
this.status = "Starting"; this.draft = ""; this.project = null; this.run = null; this.binding = null;
|
|
30
|
-
this.attachments = []; this.model = null; this.closed = false; this.busy = false;
|
|
30
|
+
this.attachments = []; this.model = null; this.depth = null; this.closed = false; this.busy = false;
|
|
31
31
|
this.followController = null; this.prompt = null; this.generation = 0;
|
|
32
32
|
this.lifecycle = new AbortController();
|
|
33
33
|
this.offline = offline; this.loginGeneration = 0; this.promptGeneration = 0;
|
|
@@ -220,7 +220,7 @@ export class Session extends EventEmitter {
|
|
|
220
220
|
if (previousAccount && previousAccount !== account.id && !(unsigned && transferUnsigned)) {
|
|
221
221
|
clearTimeout(this.draftTimer); this.registry?.saveDraft(this.draft); this.draft = "";
|
|
222
222
|
this.followController?.abort(); this.generation++; this.run = null; this.project = null; this.binding = null; this.attachments = [];
|
|
223
|
-
this.model = null; this.projectName = null; this.lastPrintedRun = null;
|
|
223
|
+
this.model = null; this.depth = null; this.projectName = null; this.lastPrintedRun = null;
|
|
224
224
|
}
|
|
225
225
|
this.account = account;
|
|
226
226
|
this.activeCredential = { kind: this.env.VECTEUR_TOKEN ? 'environment' : 'stored', token };
|
|
@@ -275,10 +275,16 @@ export class Session extends EventEmitter {
|
|
|
275
275
|
await this.loadNewest();
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
/** The newest turn of the study: a recomputation run after it shows and saves nothing of its own (parents use the true head). */
|
|
279
|
+
async newestTurn(projectId) {
|
|
280
|
+
const newest = await this.client.projectNewestRun(projectId);
|
|
281
|
+
return newest?.review ? this.client.projectNewestWriterRun(projectId) : newest;
|
|
282
|
+
}
|
|
283
|
+
|
|
278
284
|
async loadNewest() {
|
|
279
285
|
if (this.project) {
|
|
280
286
|
this.followController?.abort(); const generation = ++this.generation;
|
|
281
|
-
const newest = await this.
|
|
287
|
+
const newest = await this.newestTurn(this.project.id);
|
|
282
288
|
if (this.closed || generation !== this.generation) return;
|
|
283
289
|
if (newest) {
|
|
284
290
|
this.run = { ...newest, open: !newest.terminal };
|
|
@@ -436,7 +442,7 @@ export class Session extends EventEmitter {
|
|
|
436
442
|
|| a.source_handle.acquisition_ref.localeCompare(b.source_handle.acquisition_ref));
|
|
437
443
|
const body = { ask: text, attachments: selections.map(item => item.source_handle),
|
|
438
444
|
parent_state_hash: newest?.state_hash ?? null, ui_context: { layout: 'folder' },
|
|
439
|
-
...(selections.length ? { selections } : {}), ...(this.model ? { model_choice: this.model } : {}) };
|
|
445
|
+
...(selections.length ? { selections } : {}), ...(this.model ? { model_choice: this.model } : {}), ...(this.depth ? { depth: this.depth } : {}) };
|
|
440
446
|
return this.admitPendingLocked(this.registry.reserveRun(project.id, body, draftRef));
|
|
441
447
|
}, this.env);
|
|
442
448
|
void this.follow().catch(error => this.report(error));
|
|
@@ -711,7 +717,7 @@ export class Session extends EventEmitter {
|
|
|
711
717
|
if (!this.account || !this.project || !this.run?.terminal || this.project.role === 'VIEWER') return;
|
|
712
718
|
try { qualify(); } catch (e) { if (number) throw e; return; }
|
|
713
719
|
const run = this.run, project = this.project;
|
|
714
|
-
if ((await this.
|
|
720
|
+
if ((await this.newestTurn(project.id))?.run_id !== run.run_id) return;
|
|
715
721
|
if (this.project !== project || this.run !== run) throw new CliError('grant_changed','Save destination changed');
|
|
716
722
|
const grant = currentGrant(this.localPin(), this.env);
|
|
717
723
|
const provisional = grant ?? { ...this.localPin(), generation: null };
|
|
@@ -802,7 +808,7 @@ export class Session extends EventEmitter {
|
|
|
802
808
|
try {
|
|
803
809
|
const writer=row.proposalPath?writeProposalConfined:writeNewConfined;
|
|
804
810
|
const fetch=row.bytes?async sink=>{sink(row.bytes);return {bytes:row.bytes.length,content_type:ARTIFACT_MEDIA_TYPES[artifact.kind]};}:sink=>this.client.artifactGet(artifact.cas_ref,project.id,sink);
|
|
805
|
-
const saved = await writer(live, artifact.path, fetch, { ...artifact, runId:proposal.runId }, {env:this.env,pin:()=>this.localPin(),head:id=>this.
|
|
811
|
+
const saved = await writer(live, artifact.path, fetch, { ...artifact, runId:proposal.runId }, {env:this.env,pin:()=>this.localPin(),head:id=>this.newestTurn(id),approval:{rel:artifact.path,exists:row.snapshot.exists,sha256:row.snapshot.sha256}});
|
|
806
812
|
this.message(terminalText(`Saved ${relative(this.cwd,saved.path)} (${saved.bytes} B)`));
|
|
807
813
|
if(row.proposalPath)this.message(terminalText(adoptionHint(relative(this.cwd,saved.path),artifact.path)));
|
|
808
814
|
row.written=true;selected.delete(row);
|
|
@@ -897,14 +903,21 @@ export class Session extends EventEmitter {
|
|
|
897
903
|
modelChoice() { return this.transition(() => this.selectModel()); }
|
|
898
904
|
|
|
899
905
|
async selectModel() {
|
|
900
|
-
this.model = await this.choose("Model for the next Run (Vecteur billing)", MODEL_CHOICES.map(row => ({
|
|
906
|
+
this.model = await this.choose("Model for the next Run (Vecteur billing)", MODEL_CHOICES.filter(row => !row.hidden).map(row => ({
|
|
901
907
|
label: row.route_id === "auto" ? "Auto — Vecteur selects the model" : `${row.label} · ${row.level}`,
|
|
902
908
|
value: row.route_id === "auto" ? null : row.route_id })));
|
|
903
909
|
this.change();
|
|
904
910
|
}
|
|
905
911
|
|
|
906
912
|
modeDetails() {
|
|
907
|
-
return `Execution: Vecteur cloud\nPayer: Project organization ${this.account?.org_id ?? "(sign in first)"}\nNext model: ${this.view().model}\nLast Run model: ${this.run?.requested_route_id || "not known"}`;
|
|
913
|
+
return `Execution: Vecteur cloud\nPayer: Project organization ${this.account?.org_id ?? "(sign in first)"}\nNext model: ${this.view().model}\nDeep engineering: ${this.depth === "quick" ? "off (quick)" : this.depth === "deep" ? "on" : "plan default (on with Pro)"}\nLast Run model: ${this.run?.requested_route_id || "not known"}`;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/** v6.2 deep engineering (D-252): the plan's default (deep with Pro, quick on Free) until /deep switches it; then it
|
|
917
|
+
* alternates quick and deep. The server refuses deep on Free (deep_unentitled) with the upgrade it names. */
|
|
918
|
+
toggleDeep() {
|
|
919
|
+
this.depth = this.depth === "quick" ? "deep" : "quick";
|
|
920
|
+
this.message(this.depth === "quick" ? "Deep engineering off: the next Runs are quick." : "Deep engineering on for the next Runs (Pro): simulates the dated period, gives ranges and a second method; up to about 45 minutes and a higher cost.");
|
|
908
921
|
}
|
|
909
922
|
|
|
910
923
|
statusDetails() {
|