@vecteur/cli 0.10.0 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/commands.js CHANGED
@@ -1,17 +1,20 @@
1
+ import { withAdmissionLock } from "./localfiles.js";
1
2
  import { CliError } from "./errors.js";
2
- import { runView } from "./blocks.js";
3
+ import { runBlocks, blockText } from "./blocks.js";
3
4
  import { openBrowser } from "./browser.js";
4
5
  import { diagnose } from "./diagnostics.js";
5
- import { humanCost } from "./format.js";
6
+ import { humanCost, terminalText } from "./format.js";
6
7
  import { preferences, savePreferences } from "./preferences.js";
7
8
 
8
- export const SHORTCUTS = `Enter sends when ready; while running it offers steering or keeps the draft.
9
+ export const SHORTCUTS = `Enter sends when ready; while a Run is working it keeps the draft.
9
10
  Alt+Enter / Ctrl+J newline; backslash then Enter is the portable fallback.
10
- Paste never sends. Tab completes commands; arrows select; Esc closes a menu.
11
+ Bracketed paste never sends. Plain/dumb multiline chunks stay drafts; a split-read
12
+ lone CR/CRLF is indistinguishable from Enter and can send.
13
+ Tab completes commands; arrows select; Esc closes a menu.
11
14
  Home/End or Ctrl+A/E: line boundaries. Alt+B/F: words. Ctrl+W: cut word.
12
15
  Ctrl+K/U: cut line tail/head. Ctrl+Y: restore cut. Ctrl+_: undo edit.
13
16
  Up/Down: multiline movement, then history at its boundary. Ctrl+R: search history.
14
- ? on empty input: shortcuts. Ctrl+O: step details. Ctrl+L: redraw.
17
+ ? on empty input: shortcuts. Ctrl+O: full block details. Ctrl+L: redraw.
15
18
  Ctrl+C with text clears it (Ctrl+_ restores). Empty idle Ctrl+C twice exits.
16
19
  Esc twice or empty Ctrl+C twice requests cancellation of the same cloud Run.
17
20
  Ctrl+D on empty input saves and detaches; the cloud Run continues. /quit also exits.`;
@@ -31,8 +34,8 @@ add("resume", "Reconnect or reconcile an interrupted ask", s => s.resume());
31
34
  add("quit", "Save draft and detach; cloud Run continues", s => s.close(), { aliases: ["exit"] });
32
35
  add("drafts", "Recover a saved draft", s => s.recoverDraft());
33
36
  add("clear", "Clear this draft; Ctrl+_ restores the edit", s => { s.lastClearedDraft = s.draft; s.setDraft(""); });
34
- add("mode", "Lead, model, execution location and payer", s => s.message(s.modeDetails()));
35
- add("model", "Choose the next Run's server model or route", s => s.modelChoice(), { requires: "login" });
37
+ add("mode", "Model, execution location and payer", s => s.message(s.modeDetails()));
38
+ add("model", "Choose the next Run's model", s => s.modelChoice(), { requires: "login" });
36
39
  add("usage", "Read the Project's server-authored usage", async s => {
37
40
  if (!s.project) throw new CliError("project_unavailable", "Choose a Project first with /project");
38
41
  const client = s.client, project = s.project;
@@ -70,12 +73,12 @@ add("project", "Choose a Project or start a new study draft", async (s, argument
70
73
  ]);
71
74
  if (action !== "new") return s.link({ persist: action === "link" });
72
75
  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");
73
- s.registry.unlink(); s.binding = null; s.project = null; s.run = null; s.attachments = []; s.status = "New Project on first send"; s.change();
76
+ 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();
74
77
  }, { argument: "[list]", requires: "login" });
75
78
  add("link", "Link an existing Project to this folder", s => s.link(), { requires: "login" });
76
- add("unlink", "Remove this folder's Project binding", s => {
79
+ add("unlink", "Remove this folder's Project binding", async s => {
77
80
  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");
78
- s.followController?.abort(); s.generation++; s.registry.unlink(); s.binding = null; s.project = null; s.run = null; s.status = "Folder unlinked"; s.change();
81
+ s.followController?.abort(); s.generation++; await withAdmissionLock(() => s.registry.unlink(), s.env); s.binding = null; s.project = null; s.run = null; s.status = "Folder unlinked"; s.change();
79
82
  }, { requires: "login" });
80
83
  add("history", "Read earlier Runs in this Project", s => s.history(), { requires: "login" });
81
84
  add("name", "Name the Project", (s, value) => s.transition(async () => {
@@ -90,10 +93,15 @@ add("clear-files", "Remove pending attachments", s => {
90
93
  if (s.busy || s.registry?.state().pendingRun) throw new CliError("session_busy", "Resolve the pending action before clearing files");
91
94
  s.attachments = []; s.change();
92
95
  });
93
- add("files", "Selected inputs and downloadable results", s => s.message([
94
- ...s.attachments.map(item => `Pending: ${item.path} (${item.bytes.length} bytes; not uploaded)`),
95
- ...runView(s.run).artifacts.map((item, i) => `${i + 1}. ${item.filename} · ${item.kind} · /download ${i + 1} · /web`),
96
- ].join("\n") || "No selected files or artifacts."));
96
+ add("files", "Selected inputs, local authority and downloadable results", (s, argument) => {
97
+ if (argument === 'revoke') return s.revokeFiles();
98
+ const match = /^save (\d+)$/.exec(argument);
99
+ if (match) return s.transition(() => s.offerSaves(Number(match[1])));
100
+ const diff = /^diff (\d+)$/.exec(argument);
101
+ if (diff) return s.transition(() => s.fileDiff(Number(diff[1])));
102
+ if (argument) throw new CliError('usage_invalid', 'Use /files, /files revoke, /files save N or /files diff N');
103
+ return s.listFiles();
104
+ }, {argument:'[revoke|save N|diff N]'});
97
105
  add("download", "Save and verify a result file", (s, argument) => {
98
106
  const match = /^(\d+)(?:\s+(.+))?$/.exec(argument);
99
107
  if (!match) throw new CliError("usage_invalid", "Use /download <artifact number> [output path]");
@@ -101,14 +109,11 @@ add("download", "Save and verify a result file", (s, argument) => {
101
109
  }, { argument: "<number> [path]", required: true, requires: "login" });
102
110
  add("export", "Export the answer, Run record and verified files to a new folder", (s, path) => s.exportRun(path || undefined), { argument: "[folder]", requires: "login" });
103
111
  add("copy", "Copy the exact answer or save it to a new file", (s, path) => s.copy(path || undefined), { argument: "[path]" });
104
- add("answer", "Answer the current clarification", s => s.answer(), { requires: "question" });
105
- add("steer", "Send an instruction to the running Run", (s, text) => s.steer(text), { argument: "<instruction>", required: true, requires: "run" });
106
- add("answer-now", "Ask the running Run to conclude", s => s.steer(""), { requires: "run" });
107
112
  add("cancel", "Request cancellation; keep completed work", s => s.cancel(), { requires: "run" });
108
- add("details", "Read the current or numbered step", (s, argument) => {
109
- const steps = runView(s.run).steps;
110
- const event = argument ? steps[Number(argument) - 1] : steps.at(-1);
111
- s.message(event ? JSON.stringify(event.payload, null, 2) : "No step details yet.");
113
+ add("details", "Read the current or numbered block in full", (s, argument) => {
114
+ const blocks = runBlocks(s.run);
115
+ const block = argument ? blocks[Number(argument) - 1] : blocks.findLast(b => b.kind === "tool") ?? blocks.at(-1);
116
+ s.message(block ? terminalText(blockText(block, { full: true })) : "No block details yet.");
112
117
  }, { argument: "[number]" });
113
118
  add("handoff", "Open your Claude Code or Codex here with Vecteur attached", (s, vendor) => {
114
119
  if (!["claude", "codex"].includes(vendor)) throw new CliError("usage_invalid", "Use /handoff claude or /handoff codex");
@@ -131,7 +136,6 @@ export function unavailable(row, session) {
131
136
  if (!session.account) return "Sign in — /login";
132
137
  if (row.requires === "login") return "";
133
138
  if (session.project?.role === "VIEWER") return "Read-only Project";
134
- if (row.requires === "question") return runView(session.run).question ? "" : "No pending question";
135
139
  return session.run?.open ? "" : "No running Run";
136
140
  }
137
141
  export function completions(query = "", session) {
package/src/contract.js CHANGED
@@ -1,22 +1,22 @@
1
- // GENERATED by scripts/gen-contract.mjs from owner TypeScript projections.
2
- export const OWNER_CONTRACT_IDENTITY = "api-sha256:b78084db722fba9eb9c159fcc93b29d12db0760ded46263aca2ad2fcf97d6a3f;run-wire-sha256:7bc5c77a90d6093cff5179533d4f4b6326056057dd677740cac097ebc0c8fb54";
3
- export const MODEL_CATALOGUE = Object.freeze([{"profile_id":"glm","label":"GLM 5.3","model":"z-ai/glm-5.3","provider":"tensorx","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://tensorx.ai/trust-security/","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":null,"eligibility_sha256":"9b77e192a34bc1e2dc909a84a736d4e21f5d5835f25aae763380ac6f7c7907a7","hosting":"provider_api","reasoning":null,"image_input":false,"training_permitted":false,"retention_mode":"zero_retention","retention_stated_days":null,"retention_fact":"Prompts and completions are processed with zero data retention.","zero_retention_endpoint":true,"policy_source_url":"https://tensorx.ai/terms-of-service/","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"TensorX Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://tensorx.ai/terms-of-service/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"flash","label":"DeepSeek V4.1 Flash 1017","model":"deepseek/deepseek-v4.1-flash-1017","provider":"tensorx","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://tensorx.ai/trust-security/","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":null,"eligibility_sha256":"0bb3844773a56a555dde5f20b2c8cab0271d937a246b7c3ae642fd98e49516e9","hosting":"provider_api","reasoning":"low","image_input":false,"training_permitted":false,"retention_mode":"zero_retention","retention_stated_days":null,"retention_fact":"Prompts and completions are processed with zero data retention.","zero_retention_endpoint":true,"policy_source_url":"https://tensorx.ai/terms-of-service/","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"TensorX Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://tensorx.ai/terms-of-service/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"kimi_k3","label":"Kimi K3","model":"moonshotai/kimi-k3","provider":"tensorx","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://tensorx.ai/trust-security/","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":null,"eligibility_sha256":"e69f8b077c57c5636da412ce31d2a2e2eff6210ecc8832044250ea81a6ce3d9b","hosting":"provider_api","reasoning":null,"image_input":false,"training_permitted":false,"retention_mode":"zero_retention","retention_stated_days":null,"retention_fact":"Prompts and completions are processed with zero data retention.","zero_retention_endpoint":true,"policy_source_url":"https://tensorx.ai/terms-of-service/","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"TensorX Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://tensorx.ai/terms-of-service/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"deepseek_pro","label":"DeepSeek V4 Pro","model":"deepseek/deepseek-v4-pro-0813","provider":"tensorx","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://tensorx.ai/trust-security/","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":null,"eligibility_sha256":"82cb953f9b3d7ee90d4de9b8e3abc8dcff16379ac0f446d9d194cea5d3ec2585","hosting":"provider_api","reasoning":null,"image_input":false,"training_permitted":false,"retention_mode":"zero_retention","retention_stated_days":null,"retention_fact":"Prompts and completions are processed with zero data retention.","zero_retention_endpoint":true,"policy_source_url":"https://tensorx.ai/terms-of-service/","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"TensorX Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://tensorx.ai/terms-of-service/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"glm_flash","label":"GLM 5.3 Flash","model":"z-ai/glm-5.3-flash","provider":"tensorx","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://tensorx.ai/trust-security/","admitted_context_window_tokens":1000000,"dialect":"openai_chat","execution_placement":null,"eligibility_sha256":"9b38c17e45100344956e5235c97ab6195de9e426108ceab63eba172b7a617592","hosting":"provider_api","reasoning":null,"image_input":false,"training_permitted":false,"retention_mode":"zero_retention","retention_stated_days":null,"retention_fact":"Prompts and completions are processed with zero data retention.","zero_retention_endpoint":true,"policy_source_url":"https://tensorx.ai/terms-of-service/","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"TensorX Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://tensorx.ai/terms-of-service/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"mistral","label":"Mistral Small 4","model":"mistral-small-2603","provider":"mistral","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://docs.mistral.ai/inference/regional-inference","admitted_context_window_tokens":262144,"dialect":"mistral_conversations","execution_placement":null,"eligibility_sha256":"8bf0ba9bc0ef536214e0248d8fc918f302f38b4e406883c4b9854ec9594aa77a","hosting":"provider_api","reasoning":null,"image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"Commercial API data has published privacy and retention controls with documented exceptions; zero data retention requires separate account approval and enablement.","zero_retention_endpoint":false,"policy_source_url":"https://docs.mistral.ai/admin/monitor-comply/privacy-data-controls","policy_checked_at":"2026-08-28","policy_expires_at":"2026-11-26","operator_entity":"Mistral AI","operator_country":"France","governing_law":"France","operator_source_url":"https://legal.mistral.ai/terms/commercial-terms-of-service","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"mistral_medium","label":"Mistral Medium 3.5","model":"mistral-medium-2604","provider":"mistral","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://docs.mistral.ai/inference/regional-inference","admitted_context_window_tokens":262144,"dialect":"mistral_conversations","execution_placement":null,"eligibility_sha256":"8c52e7ab13e7ec0c21777e9742b675ced4ef07b3166d3bdec6a129b0200f67d7","hosting":"provider_api","reasoning":null,"image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"Commercial API data has published privacy and retention controls with documented exceptions; zero data retention requires separate account approval and enablement.","zero_retention_endpoint":false,"policy_source_url":"https://docs.mistral.ai/admin/monitor-comply/privacy-data-controls","policy_checked_at":"2026-08-28","policy_expires_at":"2026-11-26","operator_entity":"Mistral AI","operator_country":"France","governing_law":"France","operator_source_url":"https://legal.mistral.ai/terms/commercial-terms-of-service","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"mistral_large","label":"Mistral Large 4","model":"mistral-large-4","provider":"mistral","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://docs.mistral.ai/inference/regional-inference","admitted_context_window_tokens":1048576,"dialect":"mistral_conversations","execution_placement":null,"eligibility_sha256":"fd34bc87a87f1cbe9345e3a961fa0938fb51d51d7799bb6173e810df23895ebc","hosting":"provider_api","reasoning":"medium","image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"Commercial API data has published privacy and retention controls with documented exceptions; zero data retention requires separate account approval and enablement.","zero_retention_endpoint":false,"policy_source_url":"https://docs.mistral.ai/admin/monitor-comply/privacy-data-controls","policy_checked_at":"2026-08-28","policy_expires_at":"2026-11-26","operator_entity":"Mistral AI","operator_country":"France","governing_law":"France","operator_source_url":"https://legal.mistral.ai/terms/commercial-terms-of-service","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"luna","label":"GPT-6 Luna","model":"gpt-6-luna","provider":"openai","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://developers.openai.com/api/docs/guides/your-data","admitted_context_window_tokens":131072,"dialect":"openai_responses","execution_placement":null,"eligibility_sha256":"5aad437ed7ad769d6e824d6a24e0ce7253a2cf65483f9af998257ba4b3a62210","hosting":"provider_api","reasoning":"medium","image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Chat Completions abuse-monitoring logs are normally retained up to 30 days, with documented legal and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://platform.openai.com/docs/models/default-usage-policies-by-endpoint","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"OpenAI Ireland Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://openai.com/policies/services-agreement/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"sol","label":"GPT-6.1 Sol","model":"gpt-6.1-sol","provider":"openai","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://developers.openai.com/api/docs/guides/your-data","admitted_context_window_tokens":131072,"dialect":"openai_responses","execution_placement":null,"eligibility_sha256":"d8d6c3f90abcce5c33a0fbaca1e20c01be408460a5a0ade3ed676e31a09bf128","hosting":"provider_api","reasoning":"medium","image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Chat Completions abuse-monitoring logs are normally retained up to 30 days, with documented legal and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://platform.openai.com/docs/models/default-usage-policies-by-endpoint","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"OpenAI Ireland Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://openai.com/policies/services-agreement/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"astra","label":"GPT-6 Astra","model":"gpt-6-astra","provider":"openai","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://developers.openai.com/api/docs/guides/your-data","admitted_context_window_tokens":131072,"dialect":"openai_responses","execution_placement":null,"eligibility_sha256":"166b94ca70d14249e14bcf080b92643772d3ebdb75fd3ab81c15a6a7fb2d6e5a","hosting":"provider_api","reasoning":"high","image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Chat Completions abuse-monitoring logs are normally retained up to 30 days, with documented legal and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://platform.openai.com/docs/models/default-usage-policies-by-endpoint","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"OpenAI Ireland Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://openai.com/policies/services-agreement/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"claude_fable","label":"Claude Fable 5.1","model":"claude-fable-5-1","provider":"anthropic","data_residency":"US","data_residency_source":"vendor","data_residency_source_url":"https://privacy.claude.com/en/articles/7996890-where-are-your-servers-located-do-you-host-your-models-on-eu-servers","admitted_context_window_tokens":131072,"dialect":"anthropic_messages","execution_placement":null,"eligibility_sha256":"75224e4a7464da37d21c6b4b1ed4567a73b4430faad20221560899534404a8a7","hosting":"provider_api","reasoning":null,"image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Commercial API inputs and outputs are normally retained up to 30 days, with documented legal, policy and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://privacy.claude.com/en/articles/7996866-how-long-do-you-store-my-organization-s-data","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"Anthropic Ireland, Limited","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://www.anthropic.com/legal/commercial-terms","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"claude_opus","label":"Claude Opus 5.5","model":"claude-opus-5-5","provider":"anthropic","data_residency":"US","data_residency_source":"vendor","data_residency_source_url":"https://privacy.claude.com/en/articles/7996890-where-are-your-servers-located-do-you-host-your-models-on-eu-servers","admitted_context_window_tokens":131072,"dialect":"anthropic_messages","execution_placement":null,"eligibility_sha256":"70fcb6021cb82980290ea4d431106bdf5dd0ccace8b012e44e83f07c61019e4d","hosting":"provider_api","reasoning":null,"image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Commercial API inputs and outputs are normally retained up to 30 days, with documented legal, policy and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://privacy.claude.com/en/articles/7996866-how-long-do-you-store-my-organization-s-data","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"Anthropic Ireland, Limited","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://www.anthropic.com/legal/commercial-terms","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"claude_sonnet","label":"Claude Sonnet 5.5","model":"claude-sonnet-5-5","provider":"anthropic","data_residency":"US","data_residency_source":"vendor","data_residency_source_url":"https://privacy.claude.com/en/articles/7996890-where-are-your-servers-located-do-you-host-your-models-on-eu-servers","admitted_context_window_tokens":131072,"dialect":"anthropic_messages","execution_placement":null,"eligibility_sha256":"8892913a3ed87bae501dcfc300c51cb1342ede2956ef3a40d44ce30602f5d939","hosting":"provider_api","reasoning":null,"image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Commercial API inputs and outputs are normally retained up to 30 days, with documented legal, policy and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://privacy.claude.com/en/articles/7996866-how-long-do-you-store-my-organization-s-data","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"Anthropic Ireland, Limited","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://www.anthropic.com/legal/commercial-terms","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"claude_haiku","label":"Claude Haiku 5.5","model":"claude-haiku-5-5","provider":"anthropic","data_residency":"US","data_residency_source":"vendor","data_residency_source_url":"https://privacy.claude.com/en/articles/7996890-where-are-your-servers-located-do-you-host-your-models-on-eu-servers","admitted_context_window_tokens":131072,"dialect":"anthropic_messages","execution_placement":null,"eligibility_sha256":"32647fa178a427705d04b7ec6447810da7016d36725c8625bbdc8ea5677e24f7","hosting":"provider_api","reasoning":null,"image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Commercial API inputs and outputs are normally retained up to 30 days, with documented legal, policy and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://privacy.claude.com/en/articles/7996866-how-long-do-you-store-my-organization-s-data","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"Anthropic Ireland, Limited","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://www.anthropic.com/legal/commercial-terms","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"nebius_nemotron","label":"Nemotron 3.5 Lightning","model":"nvidia/Nemotron-3_5-Lightning","provider":"nebius","data_residency":"EU","data_residency_source":"vendor","data_residency_source_url":"https://docs.tokenfactory.nebius.com/legal/legal-quick-guide","admitted_context_window_tokens":1048576,"dialect":"openai_chat","execution_placement":null,"eligibility_sha256":"f0586d343f97c23ed000e00ed86236c3c0c91b3300b2763079e8f6879c081e16","hosting":"provider_api","reasoning":null,"image_input":false,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"Without organization-level zero data retention, inputs and outputs may be retained solely for speculative decoding; retained data is stored in Finland in the European Union.","zero_retention_endpoint":false,"policy_source_url":"https://docs.tokenfactory.nebius.com/legal/legal-quick-guide","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"Nebius B.V.","operator_country":"Netherlands","governing_law":"Netherlands","operator_source_url":"https://docs.nebius.com/legal/agreement","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"openrouter_glm","label":"GLM 5.3","model":"z-ai/glm-5.3","provider":"openrouter","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":"GLOBAL","eligibility_sha256":"99d39ebcf0661d9556db669cfe118c59f94fb253476fa1a23bafb42938cc9a4b","hosting":"provider_api","reasoning":"low","image_input":false,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"OpenRouter retains prompts only on opt-in or for CSAM review, reporting and legal preservation, ZDR traffic included; downstream commercial policies have documented retention exceptions. This route makes no platform-wide zero-retention guarantee.","zero_retention_endpoint":true,"policy_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","policy_checked_at":"2026-10-30","policy_expires_at":"2026-11-29","operator_entity":"OpenRouter, Inc.","operator_country":"United States","governing_law":"New York, United States","operator_source_url":"https://openrouter.ai/terms","downstream_provider":"DeepInfra","downstream_policy_fact":"DeepInfra does not train on API inputs for these models; in-memory processing has documented debugging and security logging exceptions."},{"profile_id":"openrouter_ling","label":"Ling 3.1 Flash","model":"inclusionai/ling-3.1-flash","provider":"openrouter","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":"GLOBAL","eligibility_sha256":"713b2ca20ed060398e1589baa4f2d9759a462e7985c2c4ec8456e8216ed949d0","hosting":"provider_api","reasoning":"off","image_input":false,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"OpenRouter retains prompts only on opt-in or for CSAM review, reporting and legal preservation, ZDR traffic included; downstream commercial policies have documented retention exceptions. This route makes no platform-wide zero-retention guarantee.","zero_retention_endpoint":true,"policy_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","policy_checked_at":"2026-10-30","policy_expires_at":"2026-11-29","operator_entity":"OpenRouter, Inc.","operator_country":"United States","governing_law":"New York, United States","operator_source_url":"https://openrouter.ai/terms","downstream_provider":"DeepInfra","downstream_policy_fact":"DeepInfra does not train on API inputs for these models and does not store submitted data on disk; it holds it in memory during inference."},{"profile_id":"gpt_terra","label":"GPT-6.1 Terra","model":"gpt-6.1-terra","provider":"openai","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://developers.openai.com/api/docs/guides/your-data","admitted_context_window_tokens":131072,"dialect":"openai_responses","execution_placement":null,"eligibility_sha256":"09e58e0478782db24bd9cdca7a8d04805716045e622830c9770fd823a083c6f7","hosting":"provider_api","reasoning":"medium","image_input":true,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":30,"retention_fact":"Chat Completions abuse-monitoring logs are normally retained up to 30 days, with documented legal and safety exceptions.","zero_retention_endpoint":false,"policy_source_url":"https://platform.openai.com/docs/models/default-usage-policies-by-endpoint","policy_checked_at":"2026-10-30","policy_expires_at":"2027-01-28","operator_entity":"OpenAI Ireland Ltd.","operator_country":"Ireland","governing_law":"Ireland","operator_source_url":"https://openai.com/policies/services-agreement/","downstream_provider":null,"downstream_policy_fact":null},{"profile_id":"openrouter_gemini_flash","label":"Gemini 3.8 Flash","model":"google/gemini-3.8-flash","provider":"openrouter","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":"GLOBAL","eligibility_sha256":"fe98eada28b9f5521600959ed87e6634923e1b10136c053ceae485919fb85ba8","hosting":"provider_api","reasoning":"medium","image_input":false,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"OpenRouter retains prompts only on opt-in or for CSAM review, reporting and legal preservation, ZDR traffic included; downstream commercial policies have documented retention exceptions. This route makes no platform-wide zero-retention guarantee.","zero_retention_endpoint":false,"policy_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","policy_checked_at":"2026-10-30","policy_expires_at":"2026-11-29","operator_entity":"OpenRouter, Inc.","operator_country":"United States","governing_law":"New York, United States","operator_source_url":"https://openrouter.ai/terms","downstream_provider":"Google","downstream_policy_fact":"Google does not train on Vertex AI customer data without permission; prompts its abuse classifiers flag may be stored up to 90 days (OpenRouter Safety Retention on every Vertex endpoint since 2026-10-18), so this endpoint is not strict zero-retention."},{"profile_id":"openrouter_gemini_argon","label":"Gemini 4 Argon","model":"google/gemini-4-argon","provider":"openrouter","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":"GLOBAL","eligibility_sha256":"80efc4df5597ab3e9d4584bb065e381a2ae91b4f5d3f9187d6de7e3e568035d2","hosting":"provider_api","reasoning":"high","image_input":false,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"OpenRouter retains prompts only on opt-in or for CSAM review, reporting and legal preservation, ZDR traffic included; downstream commercial policies have documented retention exceptions. This route makes no platform-wide zero-retention guarantee.","zero_retention_endpoint":false,"policy_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","policy_checked_at":"2026-10-30","policy_expires_at":"2026-11-29","operator_entity":"OpenRouter, Inc.","operator_country":"United States","governing_law":"New York, United States","operator_source_url":"https://openrouter.ai/terms","downstream_provider":"Google","downstream_policy_fact":"Google does not train on Vertex AI customer data without permission; prompts its abuse classifiers flag may be stored up to 90 days (OpenRouter Safety Retention on every Vertex endpoint since 2026-10-18), so this endpoint is not strict zero-retention."},{"profile_id":"openrouter_grok","label":"Grok 4.7","model":"x-ai/grok-4.7","provider":"openrouter","data_residency":"GLOBAL","data_residency_source":"vendor","data_residency_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","admitted_context_window_tokens":131072,"dialect":"openai_chat","execution_placement":"GLOBAL","eligibility_sha256":"bf4c95e82a447814818183288ba7d8d8673453403ff93817fe6e3a8617968715","hosting":"provider_api","reasoning":"low","image_input":false,"training_permitted":false,"retention_mode":"published_with_exceptions","retention_stated_days":null,"retention_fact":"OpenRouter retains prompts only on opt-in or for CSAM review, reporting and legal preservation, ZDR traffic included; downstream commercial policies have documented retention exceptions. This route makes no platform-wide zero-retention guarantee.","zero_retention_endpoint":true,"policy_source_url":"https://openrouter.ai/docs/guides/privacy/provider-logging","policy_checked_at":"2026-10-30","policy_expires_at":"2026-11-29","operator_entity":"OpenRouter, Inc.","operator_country":"United States","governing_law":"New York, United States","operator_source_url":"https://openrouter.ai/terms","downstream_provider":"xAI","downstream_policy_fact":"xAI never trains on API inputs or outputs without permission; under ZDR inputs and outputs are never persisted to disk."}]);
4
- export const PRODUCT_ROUTES = Object.freeze([{"route_id":"auto","label":"Auto","level":"balanced","region":"GLOBAL","route_sha256":"3d76e34a3fc43eddafb9d16d45ffbb85ce0d7cad72add85101e83322eabb383a","max_provider_switches":1,"candidates":[{"profile_id":"gpt_terra","provider_id":"openai","model_id":"gpt-6.1-terra","jurisdiction":"GLOBAL"},{"profile_id":"flash","provider_id":"tensorx","model_id":"deepseek/deepseek-v4.1-flash-1017","jurisdiction":"EU"}]},{"route_id":"auto_eu","label":"Auto EU","level":"balanced","region":"EU","route_sha256":"a1d9f41cb4ce71bf1925e33a838c78c4009416fe04d05795b3fbb7d4ea482162","max_provider_switches":1,"candidates":[{"profile_id":"flash","provider_id":"tensorx","model_id":"deepseek/deepseek-v4.1-flash-1017","jurisdiction":"EU"},{"profile_id":"glm_flash","provider_id":"tensorx","model_id":"z-ai/glm-5.3-flash","jurisdiction":"EU"}]},{"route_id":"quality","label":"Best quality","level":"quality","region":"GLOBAL","route_sha256":"88474569b15517cbc3b8b004588b41622b16b88529b5178f7a5159d4c535d2fd","max_provider_switches":1,"candidates":[{"profile_id":"astra","provider_id":"openai","model_id":"gpt-6-astra","jurisdiction":"GLOBAL"},{"profile_id":"claude_opus","provider_id":"anthropic","model_id":"claude-opus-5-5","jurisdiction":"US"}]},{"route_id":"quality_eu","label":"Best quality EU","level":"quality","region":"EU","route_sha256":"00fd959a8d8106119969bdb21f19b23edefa772642b34cb4b7d4107aa36c22dc","max_provider_switches":1,"candidates":[{"profile_id":"flash","provider_id":"tensorx","model_id":"deepseek/deepseek-v4.1-flash-1017","jurisdiction":"EU"},{"profile_id":"glm","provider_id":"tensorx","model_id":"z-ai/glm-5.3","jurisdiction":"EU"}]},{"route_id":"economy","label":"Lowest cost","level":"economy","region":"GLOBAL","route_sha256":"f9a74312bb237c9f5fc1af1defa3ed1711d10dca8cd1c0ef0c44ab5ac5b27501","max_provider_switches":1,"candidates":[{"profile_id":"luna","provider_id":"openai","model_id":"gpt-6-luna","jurisdiction":"GLOBAL"},{"profile_id":"claude_haiku","provider_id":"anthropic","model_id":"claude-haiku-5-5","jurisdiction":"US"}]},{"route_id":"economy_eu","label":"Lowest cost EU","level":"economy","region":"EU","route_sha256":"e56851dc6469526a05132b82bc1905d27b4fe4a9143c31c7f3e9df7f1265dcad","max_provider_switches":1,"candidates":[{"profile_id":"glm_flash","provider_id":"tensorx","model_id":"z-ai/glm-5.3-flash","jurisdiction":"EU"},{"profile_id":"flash","provider_id":"tensorx","model_id":"deepseek/deepseek-v4.1-flash-1017","jurisdiction":"EU"}]}]);
5
- export const EXECUTION_HORIZONS = Object.freeze([{"tier":"free","max_steps":30},{"tier":"pro","max_steps":50},{"tier":"enterprise","max_steps":null}]);
6
- export const CATALOGUE_ENVELOPE_SHA256 = Object.freeze("39127ad6b8c5fe026872dd15d42e2a052575a1fde28f7a103134e47a899da6d0");
1
+ // GENERATED by scripts/gen-contract.mjs from the owner projections.
2
+ export const OWNER_CONTRACT_IDENTITY = "api-sha256:1973f8517a4c3f6cbbfd2cfc9dffb477a75a8bf3cd2291577a4f07e0b6edd614;run-wire-sha256:678602fd4f1dba0493ad0f860be24bbf88532945edfe9dbe1555e5145bbbeefb";
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
+ export const EVENT_KINDS = Object.freeze(["assistant_delta","tool_call","tool_result","synthesis","artifact","study","review","terminal"]);
5
+ export const TOOL_KINDS = Object.freeze(["bash","python","read","write","edit","search","web","skill","other"]);
6
+ export const TERMINAL_STATES = Object.freeze(["completed","failed","cancelled","budget"]);
7
+ export const TERMINAL_DEFECTS = Object.freeze(["budget_exhausted","cancelled","runner_restart","turn_timeout","agent_error","provider_error","slot_unavailable","workspace_quota"]);
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"});
7
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}});
8
- export const EVENT_KINDS = Object.freeze(["source","step_started","step_finished","tool_call","tool_result","synthesis","artifact","terminal","heartbeat","assistant_delta","knowledge_binding","engineering_projection","provider_attempt","clarification","clarification_evidence","input_rows"]);
9
- export const RETIRED_EVENT_KINDS = Object.freeze(["context_frame","cta","step_label"]);
10
- export const TERMINAL_FIELDS = Object.freeze(["answer","capacity","defect","deliverable_asked","evidence_dag","instruction_source","intent","missing_input_need","missing_inputs","provider_retry_offer","recovery","refusal_unfounded","state","steps","study_unpublished","unmet_wanted"]);
11
- export const TERMINAL_STATES = Object.freeze(["ok","partial","blocked","refused","infeasible_physics","capability_gap"]);
12
- export const ARTIFACT_MEDIA_TYPES = Object.freeze({"binary":"application/octet-stream","code":"text/plain","csv":"text/csv","docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","drive":"application/vnd.google-drive","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"});
13
- export const TERMINAL_RECOVERY_DECLARATIONS = Object.freeze({"answer_now":[["start_run",["project_id"]]],"artifact_publication_missing":[["start_run",["project_id"]]],"artifact_store_unavailable":[["start_run",["project_id"]]],"budget_exhausted":[["start_run",["project_id"]]],"cancelled":[["start_run",["project_id"]]],"carriage_capacity":[["start_run",["project_id"]]],"cause_unrecorded":[["start_run",["project_id"]]],"clarification_custody_invalid":[["start_run",["project_id"]]],"clarification_custody_lost":[["start_run",["project_id"]]],"clarification_resume_invalid":[["start_run",["project_id"]]],"clarification_unpersisted":[["start_run",["project_id"]]],"context_unselected":[["start_run",["project_id"]]],"credential_class_disclosure":[["start_run",["project_id"]]],"deliverable_missing":[["start_run",["project_id"]]],"design_state_missing":[["start_run",["project_id"]]],"evidence_admission_invalid":[["start_run",["project_id"]]],"evidence_artifact_invalid":[["start_run",["project_id"]]],"evidence_artifact_unbound":[["start_run",["project_id"]]],"evidence_binding_unresolved":[["start_run",["project_id"]]],"evidence_context_invalid":[["start_run",["project_id"]]],"evidence_extract_unreached":[["start_run",["project_id"]]],"evidence_missing":[["start_run",["project_id"]]],"evidence_owner_receipt_mismatch":[["start_run",["project_id"]]],"evidence_owner_receipt_missing":[["start_run",["project_id"]]],"evidence_payload_invalid":[["start_run",["project_id"]]],"evidence_reached_invalid":[["start_run",["project_id"]]],"evidence_replay_invalid":[["start_run",["project_id"]]],"evidence_run_mismatch":[["start_run",["project_id"]]],"evidence_seal_collision":[["start_run",["project_id"]]],"evidence_selected_unreached":[["start_run",["project_id"]]],"execution_route_invalid":[["start_run",["project_id"]]],"executor_root_invalid":[["start_run",["project_id"]]],"extraction_offer_invalid":[["start_run",["project_id"]]],"extraction_offer_tampered":[["start_run",["project_id"]]],"fact_support_unread":[["start_run",["project_id"]]],"harness_arm_invalid":[["start_run",["project_id"]]],"harness_event_unmapped":[["start_run",["project_id"]]],"harness_exited":[["start_run",["project_id"]]],"harness_mapping_failed":[["start_run",["project_id"]]],"harness_session_invalid":[["start_run",["project_id"]]],"harness_session_missing":[["start_run",["project_id"]]],"harness_timeout":[["start_run",["project_id"]]],"infeasible_physics":[["start_run",["project_id"]]],"lab_denied":[["start_run",["project_id"]]],"lab_failed":[["start_run",["project_id"]]],"lab_not_reproduced":[["start_run",["project_id"]]],"lease_interval_invalid":[["start_run",["project_id"]]],"ledger_malformed":[["start_run",["project_id"]]],"max_tokens":[["start_run",["project_id"]]],"no_facts":[["start_run",["project_id"]]],"not_a_decision_i_can_make":[["start_run",["project_id"]]],"out_of_physics":[["start_run",["project_id"]]],"profile_eligibility_changed":[["start_run",["project_id"]]],"prompt_provenance_unavailable":[["start_run",["project_id"]]],"provider_budget_exhausted":[["start_run",["project_id"]]],"provider_budget_missing":[["start_run",["project_id"]]],"provider_budget_unavailable":[["start_run",["project_id"]]],"provider_relay_absent":[["start_run",["project_id"]]],"provider_route_control_invalid":[["start_run",["project_id"]]],"provider_route_exhausted":[["start_run",["project_id"]],["retry_run",["source_run_id","offer_id","generation"]]],"provider_route_failure_unobserved":[["start_run",["project_id"]]],"provider_route_reconciliation_invalid":[["start_run",["project_id"]]],"provider_route_restart_terminal":[["start_run",["project_id"]]],"provider_training_opted_in":[["start_run",["project_id"]]],"publish_seal_missing":[["start_run",["project_id"]]],"refusal_unfounded":[["start_run",["project_id"]]],"replay_capture_digest_mismatch":[["start_run",["project_id"]]],"replay_capture_invalid":[["start_run",["project_id"]]],"replay_config_incomplete":[["start_run",["project_id"]]],"replay_failed":[["start_run",["project_id"]]],"replay_no_requests":[["start_run",["project_id"]]],"replay_patch_invalid":[["start_run",["project_id"]]],"replay_plugin_absent":[["start_run",["project_id"]]],"replay_provider_socket":[["start_run",["project_id"]]],"replay_receipt_invalid":[["start_run",["project_id"]]],"replay_receipt_owner_chown":[["start_run",["project_id"]]],"replay_receipt_owner_incomplete":[["start_run",["project_id"]]],"replay_receipt_owner_invalid":[["start_run",["project_id"]]],"replay_request_observation_count":[["start_run",["project_id"]]],"replay_request_observation_invalid":[["start_run",["project_id"]]],"replay_request_observation_missing":[["start_run",["project_id"]]],"replay_request_owner_chown":[["start_run",["project_id"]]],"replay_socket_observation_invalid":[["start_run",["project_id"]]],"replay_socket_observation_missing":[["start_run",["project_id"]]],"replay_socket_owner_chown":[["start_run",["project_id"]]],"row_budget":[["start_run",["project_id"]]],"run_database_capability_refused":[["start_run",["project_id"]]],"runtime_unavailable":[["start_run",["project_id"]]],"sealed_contract_violated":[["start_run",["project_id"]]],"sealed_file_missing":[["start_run",["project_id"]]],"seat_patch_absent":[["start_run",["project_id"]]],"seat_patch_drift":[["start_run",["project_id"]]],"selection_admission_invalid":[["start_run",["project_id"]]],"selection_context_invalid":[["start_run",["project_id"]]],"selection_receipt_conflict":[["start_run",["project_id"]]],"selection_receipt_invalid":[["start_run",["project_id"]]],"selection_receipt_missing":[["start_run",["project_id"]]],"selection_required":[["start_run",["project_id"]]],"state_corrupt":[["start_run",["project_id"]]],"state_file_invalid":[["start_run",["project_id"]]],"state_invalid":[["start_run",["project_id"]]],"state_payload_overflow":[["start_run",["project_id"]]],"state_unencodable":[["start_run",["project_id"]]],"state_version_unknown":[["start_run",["project_id"]]],"unreceipted_numbers":[["start_run",["project_id"]]],"usage_egress_mismatch":[["start_run",["project_id"]]],"wall_budget":[["start_run",["project_id"]]],"wanted_not_computed":[["start_run",["project_id"]]]});
14
- export const ORIGIN_KINDS = Object.freeze(["user","hypothesis","derived","knowledge","file","catalog","default"]);
15
- export const ORIGIN_WORD = Object.freeze({"user":"your brief","hypothesis":"assumed","derived":"derived","knowledge":"Vecteur knowledge","file":"your file","catalog":"catalogue","default":"default","unattributed":"unstated"});
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 PLAN_WORDS = Object.freeze({"enterprise_action":"Talk to us about Enterprise","free_price":"€0","pro_action":"Move to Pro","pro_price":"€50 a month","pro_start":"Create an account to move to Pro","see_plan":"See your plan"});
12
+ export const WIRE_READER_HEADER = "Vecteur-Wire";
13
+ export const STORED_WIRE_VERSION_HEADER = "X-Vecteur-Stored-Wire-Version";
14
+ export const STORED_WIRE_VERSIONS = Object.freeze([6]);
15
+ export const WIRE_READER_VERSION = 6;
16
16
  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
17
  const exact=(v,k)=>shape(v,k)&&Object.keys(v).length===k.length;
18
18
  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_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")&&((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");
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
20
  const ownerTier=v=>(v==="free"||v==="pro"||v==="enterprise");
21
21
  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
22
  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));
@@ -28,44 +28,31 @@ const ownerModelCostEstimate=v=>shape(v,["selection_id","customer_gross_microusd
28
28
  const ownerModelCostTick=v=>shape(v,["customer_gross_microusd","display"],[])&&(Number.isFinite(v.customer_gross_microusd))&&(typeof v.display==="string");
29
29
  const ownerCliRelease=v=>shape(v,["package","version","contract","registry","integrity","channel","release"],[])&&(v.package==="@vecteur/cli")&&(typeof v.version==="string")&&(typeof v.contract==="string")&&(v.registry==="https://registry.npmjs.org")&&((typeof v.integrity==="string"||v.integrity===null))&&((v.channel==="stable"||v.channel==="preview"))&&(typeof v.release==="string");
30
30
  const ownerQuotaDenial=v=>shape(v,["resource","current","maximum","tier","recovery"],[])&&(typeof v.resource==="string")&&(Number.isFinite(v.current))&&(Number.isFinite(v.maximum))&&(typeof v.tier==="string")&&(Array.isArray(v.recovery)&&v.recovery.every(x=>typeof x==="string"));
31
- const ownerCustomerCostProjection=v=>shape(v,["schema","scope","binding_scope","period_start","period_end","unit","used","scope_used","limit","remaining","reset_at","coverage","display"],[])&&(v.schema==="vecteur.customer-cost-projection.v1")&&(ownerCostScope(v.scope))&&(ownerCostBindingScope(v.binding_scope))&&(Number.isFinite(v.period_start))&&(Number.isFinite(v.period_end))&&(v.unit==="customer_gross_microusd")&&((Number.isFinite(v.used)||v.used===null))&&((Number.isFinite(v.scope_used)||v.scope_used===null))&&((Number.isFinite(v.limit)||v.limit===null))&&((Number.isFinite(v.remaining)||v.remaining===null))&&(Number.isFinite(v.reset_at))&&((v.coverage==="complete"||v.coverage==="incomplete"))&&(ownerCustomerCostDisplay(v.display));
31
+ const ownerCustomerCostProjection=v=>shape(v,["schema","scope","period","binding_scope","period_start","period_end","unit","used","scope_used","limit","remaining","committed","reset_at","coverage","next_action","display"],[])&&(v.schema==="vecteur.customer-cost-projection.v1")&&(ownerCostScope(v.scope))&&((v.period==="utc_week"||v.period==="utc_month"||v.period==="contract"))&&(ownerCostBindingScope(v.binding_scope))&&(Number.isFinite(v.period_start))&&(Number.isFinite(v.period_end))&&(v.unit==="customer_gross_microusd")&&((Number.isFinite(v.used)||v.used===null))&&((Number.isFinite(v.scope_used)||v.scope_used===null))&&((Number.isFinite(v.limit)||v.limit===null))&&((Number.isFinite(v.remaining)||v.remaining===null))&&((Number.isFinite(v.committed)||v.committed===null))&&(Number.isFinite(v.reset_at))&&((v.coverage==="complete"||v.coverage==="incomplete"))&&((v.next_action==="upgrade_plan"||v.next_action==="renew_contract"||v.next_action==="raise_restriction"||v.next_action==="ask_organization_admin"||v.next_action===null))&&(ownerCustomerCostDisplay(v.display));
32
32
  const ownerCostScope=v=>shape(v,["type","id"],[])&&((v.type==="organization"||v.type==="workspace"||v.type==="project"||v.type==="user"))&&(typeof v.id==="string");
33
- const ownerCostBindingScope=v=>shape(v,["kind","scope"],[])&&((v.kind==="platform_tier"||v.kind==="restriction"||v.kind==="unlimited"))&&(ownerCostScope(v.scope));
34
- const ownerCustomerCostDisplay=v=>shape(v,["currency","used","scope_used","limit","remaining"],[])&&((v.currency==="EUR"||v.currency==="USD"))&&((typeof v.used==="string"||v.used===null))&&((typeof v.scope_used==="string"||v.scope_used===null))&&((typeof v.limit==="string"||v.limit===null))&&((typeof v.remaining==="string"||v.remaining===null));
35
- const ownerLimitDenial=v=>shape(v,["schema","scope","binding_scope","period_start","period_end","unit","used","scope_used","limit","remaining","reset_at","coverage","display","dimension","recovery"],[])&&(v.schema==="vecteur.customer-cost-projection.v1")&&(ownerCostScope(v.scope))&&(ownerCostBindingScope(v.binding_scope))&&(Number.isFinite(v.period_start))&&(Number.isFinite(v.period_end))&&(v.unit==="customer_gross_microusd")&&((Number.isFinite(v.used)||v.used===null))&&((Number.isFinite(v.scope_used)||v.scope_used===null))&&((Number.isFinite(v.limit)||v.limit===null))&&((Number.isFinite(v.remaining)||v.remaining===null))&&(Number.isFinite(v.reset_at))&&((v.coverage==="complete"||v.coverage==="incomplete"))&&(ownerCustomerCostDisplay(v.display))&&(v.dimension==="customer_cost")&&(Array.isArray(v.recovery)&&v.recovery.every(x=>(x==="wait_for_reset"||x==="upgrade_plan")));
36
- const ownerArtifact=v=>shape(v,["id","kind","cas_ref","filename"],["produced_by_step","from_input_rows","build_receipt_id","output_index","path","revision","origin_call_id","preview","supersedes_cas_ref","execution_id"])&&(typeof v.id==="string")&&((v.kind==="docx"||v.kind==="xlsx"||v.kind==="pdf"||v.kind==="md"||v.kind==="csv"||v.kind==="html"||v.kind==="code"||v.kind==="drive"||v.kind==="png"||v.kind==="jpeg"||v.kind==="svg"||v.kind==="json"||v.kind==="binary"))&&(ownerCasRef(v.cas_ref))&&(typeof v.filename==="string")&&(v.produced_by_step===undefined||(typeof v.produced_by_step==="string"||v.produced_by_step===null))&&(v.from_input_rows===undefined||(Array.isArray(v.from_input_rows)&&v.from_input_rows.every(x=>typeof x==="string")||v.from_input_rows===null))&&(v.build_receipt_id===undefined||(typeof v.build_receipt_id==="string"||v.build_receipt_id===null))&&(v.output_index===undefined||(Number.isFinite(v.output_index)||v.output_index===null))&&(v.path===undefined||(typeof v.path==="string"||v.path===null))&&(v.revision===undefined||(Number.isFinite(v.revision)||v.revision===null))&&(v.origin_call_id===undefined||(typeof v.origin_call_id==="string"||v.origin_call_id===null))&&(v.preview===undefined||(v.preview==="text"||v.preview==="code"||v.preview==="csv"||v.preview==="table"||v.preview==="series"||v.preview==="image"||v.preview==="html"||v.preview==="docx"||v.preview==="xlsx"||v.preview==="pdf"||v.preview==="binary"||v.preview===null))&&(v.supersedes_cas_ref===undefined||(ownerCasRef(v.supersedes_cas_ref)||v.supersedes_cas_ref===null))&&(v.execution_id===undefined||(typeof v.execution_id==="string"||v.execution_id===null));
37
- const ownerCasRef=v=>typeof v==="string";
38
- const ownerSynthesis=v=>shape(v,["answer","core","terminal"],[])&&(typeof v.answer==="string")&&(v.core!==null&&typeof v.core==="object"&&!Array.isArray(v.core)&&Object.values(v.core).every(x=>true))&&((v.terminal==="ok"||v.terminal==="partial"||v.terminal==="blocked"||v.terminal==="refused"||v.terminal==="infeasible_physics"||v.terminal==="capability_gap"));
39
- const ownerRunControl=v=>shape(v,["id","kind","sequence","state","attempt","step","egress"],["text"])&&(typeof v.id==="string")&&((v.kind==="steer"||v.kind==="answer_now"))&&(Number.isFinite(v.sequence))&&((v.state==="queued"||v.state==="claimed"||v.state==="dispatched"||v.state==="not_dispatched"))&&((Number.isFinite(v.attempt)||v.attempt===null))&&((Number.isFinite(v.step)||v.step===null))&&((ownerRunControlEgress(v.egress)||v.egress===null))&&(v.text===undefined||(typeof v.text==="string"||v.text===null));
40
- const ownerRunControlEgress=v=>shape(v,["candidate","call"],[])&&(Number.isFinite(v.candidate))&&(Number.isFinite(v.call));
41
- const ownerStoredWireVersion=v=>(v===1||v===2);
33
+ const ownerCostBindingScope=v=>shape(v,["kind","scope"],[])&&((v.kind==="platform_tier"||v.kind==="contract"||v.kind==="restriction"||v.kind==="unlimited"))&&(ownerCostScope(v.scope));
34
+ const ownerCustomerCostDisplay=v=>shape(v,["currency","used","scope_used","limit","remaining","committed"],[])&&((v.currency==="EUR"||v.currency==="USD"))&&((typeof v.used==="string"||v.used===null))&&((typeof v.scope_used==="string"||v.scope_used===null))&&((typeof v.limit==="string"||v.limit===null))&&((typeof v.remaining==="string"||v.remaining===null))&&((typeof v.committed==="string"||v.committed===null));
35
+ const ownerRunStopOffer=v=>shape(v,["schema","run_id","as_of","actions","continuation"],[])&&(v.schema==="vecteur.run-stop-offer.v1")&&(typeof v.run_id==="string")&&(Number.isFinite(v.as_of))&&(Array.isArray(v.actions)&&v.actions.every(x=>(x==="upgrade_plan"||x==="ask_owner"||x==="contact_sales"||x==="see_usage"||x==="continue_with_model")))&&((ownerStopContinuation(v.continuation)||v.continuation===null));
36
+ const ownerStopContinuation=v=>shape(v,["model_choice","label","source_run","parent_state_hash","expires_at"],[])&&(typeof v.model_choice==="string")&&(typeof v.label==="string")&&(typeof v.source_run==="string")&&(typeof v.parent_state_hash==="string")&&(Number.isFinite(v.expires_at));
37
+ const ownerLimitDenial=v=>shape(v,["schema","scope","period","binding_scope","period_start","period_end","unit","used","scope_used","limit","remaining","committed","reset_at","coverage","next_action","display","dimension","recovery"],[])&&(v.schema==="vecteur.customer-cost-projection.v1")&&(ownerCostScope(v.scope))&&((v.period==="utc_week"||v.period==="utc_month"||v.period==="contract"))&&(ownerCostBindingScope(v.binding_scope))&&(Number.isFinite(v.period_start))&&(Number.isFinite(v.period_end))&&(v.unit==="customer_gross_microusd")&&((Number.isFinite(v.used)||v.used===null))&&((Number.isFinite(v.scope_used)||v.scope_used===null))&&((Number.isFinite(v.limit)||v.limit===null))&&((Number.isFinite(v.remaining)||v.remaining===null))&&((Number.isFinite(v.committed)||v.committed===null))&&(Number.isFinite(v.reset_at))&&((v.coverage==="complete"||v.coverage==="incomplete"))&&((v.next_action==="upgrade_plan"||v.next_action==="renew_contract"||v.next_action==="raise_restriction"||v.next_action==="ask_organization_admin"||v.next_action===null))&&(ownerCustomerCostDisplay(v.display))&&(v.dimension==="customer_cost")&&(Array.isArray(v.recovery)&&v.recovery.every(x=>(x==="wait_for_reset"||x==="upgrade_plan"||x==="renew_contract")));
42
38
  const ownerSourceObjectWithOffer=v=>shape(v,["cas_ref","sha256","size","content_type","acquisition_ref","acquisition","offer"],[])&&(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))&&(ownerSourceOffer(v.offer));
43
39
  const ownerSourceAcquisition=v=>shape(v,["kind","provider_ref","provider_version"],[])&&((v.kind==="local"||v.kind==="google_drive"))&&((typeof v.provider_ref==="string"||v.provider_ref===null))&&((typeof v.provider_version==="string"||v.provider_version===null));
44
40
  const ownerSourceOffer=v=>shape(v,["id","sha256","project_id","source_handle","extracts"],[])&&(typeof v.id==="string")&&(typeof v.sha256==="string")&&(typeof v.project_id==="string")&&(ownerSourceHandle(v.source_handle))&&(Array.isArray(v.extracts)&&v.extracts.every(x=>ownerOfferExtract(x)));
45
- const ownerSourceHandle=v=>shape(v,["cas_ref","acquisition_ref"],[])&&(ownerCasRef(v.cas_ref))&&(ownerAcquisitionRef(v.acquisition_ref));
46
- const ownerAcquisitionRef=v=>typeof v==="string";
47
- const ownerOfferExtract=v=>shape(v,["id","locator","extractor_id","extractor_version","text_sha256"],[])&&(typeof v.id==="string")&&(ownerLocator(v.locator))&&(typeof v.extractor_id==="string")&&(typeof v.extractor_version==="string")&&(typeof v.text_sha256==="string");
48
- const ownerLocator=v=>shape(v,["kind"],["page","block","sheet","start_cell","end_cell"])&&(typeof v.kind==="string")&&(v.page===undefined||(Number.isFinite(v.page)||v.page===null))&&(v.block===undefined||(Number.isFinite(v.block)||v.block===null))&&(v.sheet===undefined||(typeof v.sheet==="string"||v.sheet===null))&&(v.start_cell===undefined||(typeof v.start_cell==="string"||v.start_cell===null))&&(v.end_cell===undefined||(typeof v.end_cell==="string"||v.end_cell===null));
41
+ const ownerSourceHandle=v=>shape(v,["cas_ref","acquisition_ref"],[])&&typeof v.cas_ref==="string"&&typeof v.acquisition_ref==="string";
42
+ 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");
49
43
  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));
50
44
  export const validateCliRelease=ownerCliRelease;
51
45
  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));
52
46
  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);
53
47
  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);
54
48
  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));
49
+ export const validateRunStopOffer=v=>ownerRunStopOffer(v)&&plainText(v.run_id)&&integer(v.as_of)&&v.as_of>0;
55
50
  export const validateCustomerCostProjection=v=>ownerCustomerCostProjection(v)&&costProjection(v);
56
51
  export const validateLimitDenial=v=>ownerLimitDenial(v)&&costProjection(v)&&v.coverage==="incomplete"&&v.scope_used===null&&v.recovery.length>0;
57
- export const validateArtifact=v=>ownerArtifact(v)&&plainText(v.id)&&/^sha256:[0-9a-f]{64}$/.test(v.cas_ref)&&plainText(v.filename);
58
52
  export const validateSource=v=>ownerSourceObject(v)||ownerSourceObjectWithOffer(v);
59
53
  export const validateSourceOffer=v=>ownerSourceOffer(v);
60
- export const validateSynthesis=v=>ownerSynthesis(v)&&text(v.answer)&&!/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/.test(v.answer);
61
54
  const member=(v)=>exact(v,["user_id","email","display_name","role"])&&[v.user_id,v.email,v.display_name].every(text)&&["OWNER","EDITOR","VIEWER"].includes(v.role);
62
- export const validateProject=(v)=>exact(v,["id","name","org_id","workspace_id","role","members","created_at","updated_at"])&&[v.id,v.name,v.org_id,v.workspace_id].every(text)&&["OWNER","EDITOR","VIEWER"].includes(v.role)&&Array.isArray(v.members)&&v.members.every(member)&&integer(v.created_at)&&integer(v.updated_at);
55
+ export const validateProject=(v)=>shape(v,["id","name","org_id","workspace_id","role","members","created_at","updated_at"],["engine"])&&(v.engine===undefined||v.engine==="v5"||v.engine==="v6")&&[v.id,v.name,v.org_id,v.workspace_id].every(text)&&["OWNER","EDITOR","VIEWER"].includes(v.role)&&Array.isArray(v.members)&&v.members.every(member)&&integer(v.created_at)&&integer(v.updated_at);
63
56
  export const validateRunAck=(v)=>exact(v,["run_id","state_hash","accepted_at","requested_route_id"])&&[v.run_id,v.state_hash,v.requested_route_id].every(text)&&integer(v.accepted_at);
64
- const dimension=(v)=>shape(v,["uncached_input","cache_read","cache_write","output"],["cache_write_class","cache_write_duration_s","provider_tier","long_context_band"])&&["uncached_input","cache_read","cache_write","output"].every(k=>integer(v[k])&&v[k]>=0)&&[v.cache_write_class,v.provider_tier,v.long_context_band].every(x=>x===undefined||x===null||text(x))&&(v.cache_write_duration_s===undefined||v.cache_write_duration_s===null||(integer(v.cache_write_duration_s)&&v.cache_write_duration_s>=0));
65
- const usage=(v)=>exact(v,["coverage","provider_id","model_id","observed_at","billable_dimensions"])&&["complete","incomplete"].includes(v.coverage)&&[v.provider_id,v.model_id].every(text)&&integer(v.observed_at)&&v.observed_at>=0&&Array.isArray(v.billable_dimensions)&&v.billable_dimensions.length>0&&v.billable_dimensions.every(dimension);
66
- const control=v=>ownerRunControl(v)&&/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(v.id)&&integer(v.sequence)&&v.sequence>=1&&v.sequence<=32&&(v.kind==="steer"?typeof v.text==="string"&&v.text.trim().length>0&&Buffer.byteLength(v.text,"utf8")<=8192:v.text===undefined||v.text===null)&&((v.attempt===null&&v.step===null)||(integer(v.attempt)&&v.attempt>=0&&integer(v.step)&&v.step>0))&&(v.egress===null||(integer(v.egress.candidate)&&v.egress.candidate>=0&&integer(v.egress.call)&&v.egress.call>=0))&&(v.state==="queued"?v.attempt===null&&v.egress===null:v.state==="claimed"?v.attempt!==null&&v.egress===null:v.state==="dispatched"?v.attempt!==null&&v.egress!==null:v.egress===null);
67
- const controls=v=>Array.isArray(v)&&v.length<=32&&v.every(control)&&new Set(v.map(x=>x.id)).size===v.length&&v.every((x,i)=>i===0||v[i-1].sequence<x.sequence);
68
- export const validateAdmitted=(v)=>shape(v,["run_id","state_hash","result_hash","requested_route_id","profile","terminal","usage","events","stored_wire_version","controls"],["duration_seconds"])&&ownerStoredWireVersion(v.stored_wire_version)&&[v.run_id,v.state_hash,v.requested_route_id,v.profile].every(text)&&((v.terminal===""&&v.result_hash===""&&Array.isArray(v.events)&&(v.events.length===0||v.events.at(-1)?.kind!=="terminal"))||(TERMINAL_STATES.includes(v.terminal)&&text(v.result_hash)))&&usage(v.usage)&&Array.isArray(v.events)&&controls(v.controls)&&(v.duration_seconds===undefined||v.duration_seconds===null||(integer(v.duration_seconds)&&v.duration_seconds>=0));
69
57
  export const validatePatCreated=(v)=>exact(v,["id","name","token","prefix","project_id","scopes","created_at","expires_at"])&&[v.id,v.name,v.token,v.prefix].every(text)&&(v.project_id===null||text(v.project_id))&&Array.isArray(v.scopes)&&v.scopes.every(s=>["project:read","project:execute"].includes(s))&&integer(v.created_at)&&integer(v.expires_at);
70
58
  export const validateDeviceAuthorization=(v)=>exact(v,["device_code","user_code","verification_uri","verification_uri_complete","expires_at","interval"])&&[v.device_code,v.user_code,v.verification_uri,v.verification_uri_complete].every(text)&&integer(v.expires_at)&&integer(v.interval)&&v.interval>=0;
71
- export const validateRunControl=control;
@@ -1,3 +1,4 @@
1
+ import { localMutation, endGrants } from "./localfiles.js";
1
2
  import { rmSync } from "node:fs";
2
3
  import { homedir } from "node:os";
3
4
  import { isAbsolute, join } from "node:path";
@@ -114,6 +115,13 @@ export function setCurrentOrigin(origin, env = process.env) {
114
115
  }
115
116
 
116
117
  export function clearCredentials(env = process.env, origin = undefined) {
118
+ return localMutation('credentials', { origin }, env, () => {
119
+ endGrants({ origin }, env);
120
+ return clearCredentialsLocked(env, origin);
121
+ });
122
+ }
123
+
124
+ function clearCredentialsLocked(env, origin) {
117
125
  return withStoreLock(credentialsPath(env), () => {
118
126
  const path = credentialsPath(env);
119
127
  if (origin === undefined) {
package/src/download.js CHANGED
@@ -12,18 +12,13 @@ function defaultName(casRef) {
12
12
  /**
13
13
  * Stream admitted bytes to a private sibling, then publish with an atomic no-overwrite link.
14
14
  * A remote filename never reaches this path: the caller either supplies --output or receives
15
- * a digest-derived basename, so traversal and shell metacharacters cannot arrive from RunWire.
15
+ * a digest-derived basename, so traversal and shell metacharacters cannot arrive from the wire.
16
16
  */
17
17
  export async function downloadArtifact(client, casRef, projectId, output) {
18
18
  return downloadTo(output ?? defaultName(casRef),
19
19
  chunk => client.artifactGet(casRef, projectId, chunk));
20
20
  }
21
21
 
22
- export async function downloadProjection(client, projectId, runId, projection, output) {
23
- return downloadTo(output ?? `transfer-table-${projection.projection_id.slice(11, 23)}.json`,
24
- chunk => client.projectionGet(projectId, runId, projection, chunk));
25
- }
26
-
27
22
  async function downloadTo(filename, fetchBytes) {
28
23
  const target = resolve(filename);
29
24
  const temporary = resolve(dirname(target), `.vecteur-${basename(target)}-${randomUUID()}.part`);
@@ -69,7 +64,7 @@ export async function exportRun(client, run, projectId, directory) {
69
64
  await writeFile(join(target, name), bytes, { flag: "wx", mode: 0o600 });
70
65
  files.push({ path: join(target, name), bytes: Buffer.byteLength(bytes) });
71
66
  };
72
- if (sections.answer !== undefined) await write("answer.md", sections.answer);
67
+ if (sections.answer) await write("answer.md", sections.answer);
73
68
  await write("run.json", canonicalJson(run));
74
69
  const used = new Set(["answer.md", "run.json"]);
75
70
  for (const { artifact } of sections.artifacts) {
package/src/errors.js CHANGED
@@ -7,8 +7,11 @@
7
7
  * shared vocabulary, so it owns a file and neither side reaches through the other.
8
8
  */
9
9
  export class CliError extends Error {
10
- constructor(code, message) {
10
+ constructor(code, message, details = {}) {
11
11
  super(message);
12
12
  this.code = code;
13
+ for (const field of ["run_id", "request_key", "parent_state_hash"]) {
14
+ if (Object.hasOwn(details, field)) this[field] = details[field];
15
+ }
13
16
  }
14
17
  }
@@ -0,0 +1,86 @@
1
+ import { constants } from "node:fs";
2
+ import { open, realpath } from "node:fs/promises";
3
+ import { basename, dirname, extname, join, resolve, sep } from "node:path";
4
+
5
+ import { CliError } from "./errors.js";
6
+ import { downloadArtifact } from "./download.js";
7
+ import { runArtifacts } from "./blocks.js";
8
+
9
+ // The run door's material cap (backend asgi.MAX_MATERIAL_BYTES): one figure everywhere.
10
+ export const MAX_MATERIAL_BYTES = 16 * 1024 * 1024;
11
+ export const MEDIA = { ".txt": "text/plain", ".md": "text/markdown", ".csv": "text/csv", ".json": "application/json",
12
+ ...Object.fromEntries(['.py', '.m', '.jl', '.r', '.c', '.h', '.cpp', '.f90', '.toml', '.yaml', '.yml', '.ini', '.cfg', '.tex', '.rst'].map(ext => [ext, 'text/plain'])),
13
+ ".pdf": "application/pdf", ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" };
14
+
15
+ const inside = (root, path) => path === root || path.startsWith(root + sep);
16
+
17
+ /** A path the caller named, resolved against the working folder; it may not leave that folder. */
18
+ async function contained(cwd, name, { leaf }) {
19
+ const root = await realpath(cwd);
20
+ const target = resolve(root, name);
21
+ const parent = await realpath(leaf ? dirname(target) : target).catch(() => {
22
+ throw new CliError("path_invalid", "Path does not exist inside the working folder");
23
+ });
24
+ if (!inside(root, parent)) throw new CliError("path_outside_folder", "Path leaves the working folder");
25
+ return leaf ? join(parent, basename(target)) : parent;
26
+ }
27
+
28
+ /** Digest-verified artifact download (the `vecteur run export` verifier) into the working folder. */
29
+ export async function artifactToFolder(client, { projectId, casRef, runId, artifactPath, output, cwd, signal }) {
30
+ if (!casRef) {
31
+ if (!runId || !artifactPath) throw new CliError("usage_invalid", "Give cas_ref, or run_id with artifact_path");
32
+ const run = await client.runGet(runId, signal);
33
+ const found = runArtifacts(run.events).find(artifact => artifact.path === artifactPath);
34
+ if (!found) throw new CliError("artifact_unavailable", "Run has no such artifact");
35
+ casRef = found.cas_ref;
36
+ }
37
+ const target = await contained(cwd, output ?? `artifact-${String(casRef).slice(7, 19)}`, { leaf: true });
38
+ const result = await downloadArtifact(client, casRef, projectId, target);
39
+ return { path: result.path, bytes: result.bytes, cas_ref: casRef, content_type: result.content_type, verified: true };
40
+ }
41
+
42
+ /** The CLI --attach selection: every offered extract, in canonical order. */
43
+ export async function selectSource(client, projectId, source, signal) {
44
+ const offer = source.offer ?? await client.inputOffer(projectId, source, signal);
45
+ if (!offer.extracts.length) throw new CliError("extraction_unavailable", "This file has no selectable extracts");
46
+ return { source_handle: { cas_ref: source.cas_ref, acquisition_ref: source.acquisition_ref },
47
+ offer_id: offer.id, selected_extract_ids: offer.extracts.map(extract => extract.id).sort(), method: "exact-extract" };
48
+ }
49
+
50
+ /**
51
+ * Upload one local file as Project material through the same inputs door as `/attach`. The
52
+ * destination is disclosed and must be confirmed verbatim; a foreign, read-only or moved-on
53
+ * Project refuses before any byte leaves.
54
+ */
55
+ export async function materialAttach(client, { projectId, path, confirmOrigin, expectedStateHash, cwd, signal }) {
56
+ const origin = client.config.origin;
57
+ if (confirmOrigin !== origin) throw new CliError("destination_unconfirmed", `Upload goes to ${origin}; confirm that origin`);
58
+ const project = await client.projectGet(projectId, signal);
59
+ if (project.role === "VIEWER") throw new CliError("role_forbidden", "Editor access is required to attach material");
60
+ const newest = await client.projectNewestRun(projectId, signal);
61
+ if ((newest?.state_hash ?? null) !== expectedStateHash) {
62
+ throw new CliError("project_stale", "Project head moved; read the latest run and retry");
63
+ }
64
+ const filename = await contained(cwd, path, { leaf: false });
65
+ const handle = await open(filename, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
66
+ let bytes;
67
+ try {
68
+ const info = await handle.stat();
69
+ if (!info.isFile() || info.size <= 0 || info.size > MAX_MATERIAL_BYTES) {
70
+ throw new CliError("attachment_invalid", "Select one non-empty file no larger than 16 MiB");
71
+ }
72
+ bytes = await handle.readFile();
73
+ const after = await handle.stat();
74
+ if (bytes.length !== info.size || after.mtimeMs !== info.mtimeMs || after.ctimeMs !== info.ctimeMs) {
75
+ throw new CliError("attachment_changed", "File changed while reading; select it again");
76
+ }
77
+ } finally { await handle.close(); }
78
+ const media = MEDIA[extname(filename).toLowerCase()] ?? "application/octet-stream";
79
+ const source = await client.inputAdd(projectId, bytes, media, signal);
80
+ const selection = await selectSource(client, projectId, source, signal);
81
+ return {
82
+ project_id: projectId, project_name: project.name, destination: origin, filename: basename(filename),
83
+ bytes: bytes.length, cas_ref: source.cas_ref, acquisition_ref: source.acquisition_ref,
84
+ offer_id: selection.offer_id, extract_count: selection.selected_extract_ids.length, selections: [selection],
85
+ };
86
+ }