@viberaven/mcp 1.6.12 → 1.7.0
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 +7 -1
- package/dist/lib/cli-runner.js +499 -15
- package/dist/server.js +906 -23
- package/dist/tools/index.js +907 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ From the app root: `npx -y viberaven@1.6.12` opens Studio; `npx -y viberaven@1.6
|
|
|
81
81
|
Artifact compatibility command:
|
|
82
82
|
|
|
83
83
|
```bash
|
|
84
|
-
npx -y viberaven
|
|
84
|
+
npx -y viberaven check
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
## Scope And Evidence
|
|
@@ -89,3 +89,9 @@ npx -y viberaven --agent-mode
|
|
|
89
89
|
Checks do not query live policies, prove complete permissions, build or deploy. With RLS off, grants determine actual access. Verify live user access, provider environment, DNS, billing and webhooks separately. A clear result is not a security audit.
|
|
90
90
|
|
|
91
91
|
The [RLS comparison](https://ohad6k.github.io/VibeRaven/examples/proof/rls-comparison/) retains maintainer-authored **1.6.3** runs in local databases, not new scans, hosted Supabase verification or independent endorsement. [Public repository](https://github.com/ohad6k/VibeRaven) | [Agent reference](https://ohad6k.github.io/VibeRaven/llms.txt). License: MIT.
|
|
92
|
+
|
|
93
|
+
### Standalone MCP installation boundary
|
|
94
|
+
|
|
95
|
+
For `viberaven_work_report`, standalone MCP resolves an already installed `@viberaven/cli/package.json` from the MCP installation, and requires its name and exact version to match the MCP candidate. Alternatively, set the host process environment `VIBERAVEN_CLI_PATH` to an absolute matching `dist/cli.js` path. This is an operator-controlled local-candidate setting, not a tool argument. Keep the CLI installation outside the task repository. A regular canonical CLI entry and adjacent manifest are validated before execution.
|
|
96
|
+
|
|
97
|
+
Report runs Node directly with `shell: false`, strips Node/npm environment steering and never invokes npm, npx, package installation or registry fallback. Install/configure the matching candidate separately; reporting fails until it is available. Missing/mismatched installations, process failures, malformed results, output over the bounded transport budget and the 30-second read timeout return a generic error without raw child diagnostics or local paths. Other standalone MCP tools retain their existing pinned npx execution path. The source-level embedded MCP compatibility handler uses its own CLI entry with the same shared bounded report runner. It has parity/regression tests but is not exposed as a second installed CLI server entrypoint; the executable MCP route is `@viberaven/mcp`.
|
package/dist/lib/cli-runner.js
CHANGED
|
@@ -32,12 +32,483 @@ __export(cli_runner_exports, {
|
|
|
32
32
|
mcpVersion: () => mcpVersion,
|
|
33
33
|
resolveCwd: () => resolveCwd,
|
|
34
34
|
runVibeRaven: () => runVibeRaven,
|
|
35
|
+
runVibeRavenDetailed: () => runVibeRavenDetailed,
|
|
35
36
|
safeStringArg: () => safeStringArg
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(cli_runner_exports);
|
|
39
|
+
|
|
40
|
+
// ../../shared/taskContract.ts
|
|
41
|
+
var TASK_CONTRACT_MAX_BYTES = 4800;
|
|
42
|
+
var condition = { type: "object", properties: {
|
|
43
|
+
id: { type: "string", pattern: "^[a-z][a-z0-9_-]{0,39}$" },
|
|
44
|
+
description: { type: "string", minLength: 1, maxLength: 240, pattern: "\\S" }
|
|
45
|
+
}, required: ["id", "description"], additionalProperties: false };
|
|
46
|
+
var TASK_CONTRACT_SCHEMA = {
|
|
47
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
48
|
+
title: "VibeRaven Task contract v1",
|
|
49
|
+
type: "object",
|
|
50
|
+
description: "Declarative task definition, not executable commands or evidence. Runtime also enforces a 4800-byte UTF-8 limit and condition IDs unique across both lists.",
|
|
51
|
+
properties: {
|
|
52
|
+
schemaVersion: { const: 1 },
|
|
53
|
+
status: { type: "string", enum: ["draft", "ready"] },
|
|
54
|
+
request: { type: "string", minLength: 1, maxLength: 1200, pattern: "^\\S(?:[\\s\\S]*\\S)?(?![\\s\\S])" },
|
|
55
|
+
acceptance: { type: "array", items: condition, maxItems: 16, uniqueItems: true },
|
|
56
|
+
mustNotBreak: { type: "array", items: condition, maxItems: 16, uniqueItems: true },
|
|
57
|
+
scope: { type: "object", properties: {
|
|
58
|
+
environment: { type: "string", enum: ["local", "preview", "test-mode"] },
|
|
59
|
+
paths: { type: "array", minItems: 0, maxItems: 16, uniqueItems: true, items: {
|
|
60
|
+
type: "string",
|
|
61
|
+
minLength: 1,
|
|
62
|
+
maxLength: 200,
|
|
63
|
+
pattern: '^(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\\\:*?"<>|\\u0000-\\u001f])(?!/)(?!.*//)(?!.*[. ](?:/|$))[^/]+(?:/[^/]+)*$'
|
|
64
|
+
} },
|
|
65
|
+
providers: { type: "array", maxItems: 8, uniqueItems: true, items: { type: "string", pattern: "^[a-z][a-z0-9-]{0,39}$" } }
|
|
66
|
+
}, required: ["environment", "paths", "providers"], additionalProperties: false }
|
|
67
|
+
},
|
|
68
|
+
required: ["schemaVersion", "status", "request", "acceptance", "mustNotBreak", "scope"],
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
allOf: [{ if: { properties: { status: { const: "ready" } } }, then: { properties: {
|
|
71
|
+
acceptance: { minItems: 1 },
|
|
72
|
+
scope: { properties: { paths: { minItems: 1 } } }
|
|
73
|
+
} } }]
|
|
74
|
+
};
|
|
75
|
+
function validate(value, schema, path2) {
|
|
76
|
+
const fail = () => {
|
|
77
|
+
throw new Error(`Invalid Task contract at ${path2}.`);
|
|
78
|
+
};
|
|
79
|
+
if ("const" in schema && value !== schema.const) fail();
|
|
80
|
+
if (schema.enum && !schema.enum.includes(value)) fail();
|
|
81
|
+
if (schema.type === "object" && (!value || typeof value !== "object" || Array.isArray(value))) fail();
|
|
82
|
+
if (schema.type === "string" && typeof value !== "string") fail();
|
|
83
|
+
if (schema.type === "array" && !Array.isArray(value)) fail();
|
|
84
|
+
if (typeof value === "string" && (schema.minLength !== void 0 && [...value].length < schema.minLength || schema.maxLength !== void 0 && [...value].length > schema.maxLength || schema.pattern && !new RegExp(schema.pattern, "u").test(value))) fail();
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
if (schema.minItems !== void 0 && value.length < schema.minItems || schema.maxItems !== void 0 && value.length > schema.maxItems || schema.uniqueItems && new Set(value.map((v) => JSON.stringify(v))).size !== value.length) fail();
|
|
87
|
+
value.forEach((item, i) => {
|
|
88
|
+
if (schema.items) validate(item, schema.items, `${path2}[${i}]`);
|
|
89
|
+
});
|
|
90
|
+
} else if (value && typeof value === "object") {
|
|
91
|
+
const object = value;
|
|
92
|
+
for (const key of schema.required ?? []) if (!Object.hasOwn(object, key)) fail();
|
|
93
|
+
for (const key of Object.keys(object)) {
|
|
94
|
+
if (schema.additionalProperties === false && !Object.hasOwn(schema.properties ?? {}, key)) fail();
|
|
95
|
+
if (Object.hasOwn(schema.properties ?? {}, key)) validate(object[key], schema.properties[key], `${path2}.${key}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const clause of schema.allOf ?? []) {
|
|
99
|
+
let matches = true;
|
|
100
|
+
try {
|
|
101
|
+
validate(value, clause.if, path2);
|
|
102
|
+
} catch {
|
|
103
|
+
matches = false;
|
|
104
|
+
}
|
|
105
|
+
if (matches) validate(value, clause.then, path2);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function parseTaskContract(raw) {
|
|
109
|
+
const serialized = JSON.stringify(raw);
|
|
110
|
+
if (!serialized || Buffer.byteLength(serialized, "utf8") > TASK_CONTRACT_MAX_BYTES) throw new Error("Task contract exceeds 4800 UTF-8 bytes.");
|
|
111
|
+
validate(raw, TASK_CONTRACT_SCHEMA, "$");
|
|
112
|
+
const contract = JSON.parse(serialized);
|
|
113
|
+
const ids = [...contract.acceptance, ...contract.mustNotBreak].map((c) => c.id);
|
|
114
|
+
if (new Set(ids).size !== ids.length) throw new Error("Task condition IDs must be unique across acceptance and mustNotBreak.");
|
|
115
|
+
if (contract.request.length > 1200) throw new Error("Task request exceeds the account API limit of 1200 characters.");
|
|
116
|
+
return contract;
|
|
117
|
+
}
|
|
118
|
+
function draftTaskContract(request) {
|
|
119
|
+
return parseTaskContract({ schemaVersion: 1, status: "draft", request, acceptance: [], mustNotBreak: [], scope: { environment: "local", paths: [], providers: [] } });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ../../shared/verificationPlan.ts
|
|
123
|
+
var VERIFICATION_PLAN_MAX_BYTES = 65536;
|
|
124
|
+
var HTTP_LIMITS = { bodyBytes: 8192, responseBytes: 8192, requestTimeoutMs: 2e3, totalResponseBytes: 32768 };
|
|
125
|
+
var httpMethods = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
|
|
126
|
+
var httpPathPattern = "^/(?!/)(?!.*%(?:0[0-9a-fA-F]|1[0-9a-fA-F]|20|7[fF]|5[cC]))[!-~]*$(?![\\s\\S])";
|
|
127
|
+
var httpHeaderPattern = "^(?:accept|content-type|stripe-signature|x-(?:fixture|test)-[a-z0-9-]{1,40})$(?![\\s\\S])";
|
|
128
|
+
var httpExpected = {
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: { status: { type: "integer", minimum: 200, maximum: 599 }, json: {}, text: { type: "string", maxLength: HTTP_LIMITS.responseBytes } },
|
|
131
|
+
required: ["status"],
|
|
132
|
+
additionalProperties: false,
|
|
133
|
+
oneOf: [{ required: ["json"], not: { required: ["text"] } }, { required: ["text"], not: { required: ["json"] } }],
|
|
134
|
+
allOf: [{ if: { properties: { status: { enum: [204, 205, 304] } } }, then: { required: ["text"], properties: { text: { const: "" } }, not: { required: ["json"] } } }]
|
|
135
|
+
};
|
|
136
|
+
var httpCase = {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: { request: {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {
|
|
141
|
+
method: { enum: httpMethods },
|
|
142
|
+
path: { type: "string", minLength: 1, maxLength: 2048, allOf: [{ pattern: httpPathPattern }, { not: { pattern: "[\\\\#]" } }] },
|
|
143
|
+
headers: { type: "object", maxProperties: 8, propertyNames: { pattern: httpHeaderPattern }, additionalProperties: { type: "string", maxLength: 512, pattern: "^[ -~]*$(?![\\s\\S])" } },
|
|
144
|
+
body: { type: "string", maxLength: HTTP_LIMITS.bodyBytes }
|
|
145
|
+
},
|
|
146
|
+
required: ["method", "path"],
|
|
147
|
+
additionalProperties: false,
|
|
148
|
+
allOf: [{ if: { properties: { method: { enum: ["GET", "HEAD"] } } }, then: { not: { required: ["body"] } } }]
|
|
149
|
+
}, expected: httpExpected },
|
|
150
|
+
required: ["request", "expected"],
|
|
151
|
+
additionalProperties: false,
|
|
152
|
+
allOf: [{ if: { properties: { request: { properties: { method: { const: "HEAD" } } } } }, then: { properties: { expected: { required: ["text"], properties: { text: { const: "" } }, not: { required: ["json"] } } } } }]
|
|
153
|
+
};
|
|
154
|
+
var id = { type: "string", pattern: "^[a-z][a-z0-9_-]{0,39}$" };
|
|
155
|
+
var verificationPathPattern = '^(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\\\:*?"<>|\\u0000-\\u001f])(?!/)(?!.*//)(?!.*[. ](?:/|$))[^/]+(?:/[^/]+)*$';
|
|
156
|
+
var path = { type: "string", minLength: 1, maxLength: 200, pattern: verificationPathPattern };
|
|
157
|
+
var common = { id, conditionId: id };
|
|
158
|
+
var VERIFICATION_PLAN_SCHEMA = {
|
|
159
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
160
|
+
title: "VibeRaven local verification plan v1",
|
|
161
|
+
type: "object",
|
|
162
|
+
properties: { schemaVersion: { const: 1 }, checks: { type: "array", minItems: 1, maxItems: 32, items: { oneOf: [
|
|
163
|
+
{ type: "object", properties: {
|
|
164
|
+
...common,
|
|
165
|
+
adapter: { const: "module" },
|
|
166
|
+
module: path,
|
|
167
|
+
export: { type: "string", pattern: "^[A-Za-z_$][A-Za-z0-9_$]{0,79}$" },
|
|
168
|
+
cases: { type: "array", minItems: 1, maxItems: 32, items: { type: "object", properties: { args: { type: "array", maxItems: 16 }, expected: {} }, required: ["args", "expected"], additionalProperties: false } }
|
|
169
|
+
}, required: ["id", "conditionId", "adapter", "module", "export", "cases"], additionalProperties: false },
|
|
170
|
+
{ type: "object", properties: { ...common, adapter: { const: "node-test" }, entry: path, frozenPaths: { type: "array", minItems: 0, maxItems: 16, uniqueItems: true, items: path } }, required: ["id", "conditionId", "adapter", "entry", "frozenPaths"], additionalProperties: false },
|
|
171
|
+
{ type: "object", properties: { ...common, adapter: { const: "http" }, module: path, export: { type: "string", pattern: "^[A-Za-z_$][A-Za-z0-9_$]{0,79}$" }, cases: { type: "array", minItems: 1, maxItems: 32, items: httpCase } }, required: ["id", "conditionId", "adapter", "module", "export", "cases"], additionalProperties: false }
|
|
172
|
+
] } } },
|
|
173
|
+
required: ["schemaVersion", "checks"],
|
|
174
|
+
additionalProperties: false,
|
|
175
|
+
description: "Reviewed local observations, not commands or imported proof. Runtime also bounds JSON depth/UTF-8 bytes, including HTTP request/expected bodies to 8192 bytes, rejects unknown condition IDs, and restricts node-test to preservation conditions and frozen test-owned paths. HTTP factories return unlistened Node servers; sequential requests observe volatile state only. Runtime package/config files remain candidate inputs. Expected values remain in the host comparator. Coverage completeness is a human judgment."
|
|
176
|
+
};
|
|
177
|
+
function validVerificationPath(value) {
|
|
178
|
+
return typeof value === "string" && value.length <= 200 && new RegExp(verificationPathPattern, "u").test(value) && !value.split("/").some((p) => /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i.test(p));
|
|
179
|
+
}
|
|
180
|
+
function frozenVerificationPath(path2) {
|
|
181
|
+
return /^(?:tests?|__tests__)(?:\/|$)|(?:^|\/)[^/]+\.(?:test|spec)\.[^/]+$/i.test(path2);
|
|
182
|
+
}
|
|
183
|
+
function keys(value, required) {
|
|
184
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join(",") !== [...required].sort().join(",")) throw new Error("Invalid verification plan fields. Commands and evidence are not accepted.");
|
|
185
|
+
}
|
|
186
|
+
function boundedJson(value, depth = 0) {
|
|
187
|
+
if (depth > 12) throw new Error("Verification JSON exceeds depth 12.");
|
|
188
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return;
|
|
189
|
+
if (typeof value === "number" && Number.isFinite(value)) return;
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
if (value.length > 256) throw new Error("Verification JSON array exceeds 256 items.");
|
|
192
|
+
value.forEach((v) => boundedJson(v, depth + 1));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
196
|
+
if (Object.keys(value).length > 256) throw new Error("Verification JSON object exceeds 256 keys.");
|
|
197
|
+
for (const [k, v] of Object.entries(value)) {
|
|
198
|
+
if (["__proto__", "prototype", "constructor"].includes(k)) throw new Error("Unsafe verification JSON key.");
|
|
199
|
+
boundedJson(v, depth + 1);
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
throw new Error("Verification values must be finite JSON data.");
|
|
204
|
+
}
|
|
205
|
+
function parseVerificationPlan(raw, contract) {
|
|
206
|
+
boundedJson(raw);
|
|
207
|
+
if (Buffer.byteLength(JSON.stringify(raw), "utf8") > VERIFICATION_PLAN_MAX_BYTES) throw new Error("Verification plan exceeds 65536 UTF-8 bytes.");
|
|
208
|
+
keys(raw, ["schemaVersion", "checks"]);
|
|
209
|
+
if (raw.schemaVersion !== 1 || !Array.isArray(raw.checks) || !raw.checks.length || raw.checks.length > 32) throw new Error("Invalid verification plan checks.");
|
|
210
|
+
const seen = /* @__PURE__ */ new Set();
|
|
211
|
+
for (const c of raw.checks) {
|
|
212
|
+
if (!c || typeof c !== "object") throw new Error("Invalid verification check.");
|
|
213
|
+
if (c.adapter === "module" || c.adapter === "http") {
|
|
214
|
+
keys(c, ["id", "conditionId", "adapter", "module", "export", "cases"]);
|
|
215
|
+
if (!validVerificationPath(c.module) || typeof c.export !== "string" || !/^[A-Za-z_$][A-Za-z0-9_$]{0,79}$/.test(c.export) || !Array.isArray(c.cases) || !c.cases.length || c.cases.length > 32) throw new Error("Invalid module verification check.");
|
|
216
|
+
for (const test of c.cases) {
|
|
217
|
+
if (c.adapter === "module") {
|
|
218
|
+
keys(test, ["args", "expected"]);
|
|
219
|
+
if (!Array.isArray(test.args) || test.args.length > 16) throw new Error("Invalid module arguments.");
|
|
220
|
+
} else validateHttpCase(test);
|
|
221
|
+
}
|
|
222
|
+
} else if (c.adapter === "node-test") {
|
|
223
|
+
keys(c, ["id", "conditionId", "adapter", "entry", "frozenPaths"]);
|
|
224
|
+
if (!validVerificationPath(c.entry) || !frozenVerificationPath(c.entry) || !Array.isArray(c.frozenPaths) || c.frozenPaths.length > 16 || new Set(c.frozenPaths).size !== c.frozenPaths.length || c.frozenPaths.some((p) => !validVerificationPath(p) || !frozenVerificationPath(p))) throw new Error("Node-test entries/helpers must be frozen test-owned paths; runtime package/config files stay candidate inputs.");
|
|
225
|
+
if (contract && !contract.mustNotBreak.some((condition2) => condition2.id === c.conditionId)) throw new Error("Node-test checks support mustNotBreak only; use independent module observations for acceptance.");
|
|
226
|
+
} else throw new Error("Unsupported verification adapter. No shell commands are accepted.");
|
|
227
|
+
if (typeof c.id !== "string" || !/^[a-z][a-z0-9_-]{0,39}$/.test(c.id) || seen.has(c.id) || typeof c.conditionId !== "string" || !/^[a-z][a-z0-9_-]{0,39}$/.test(c.conditionId)) throw new Error("Invalid or duplicate verification ID.");
|
|
228
|
+
seen.add(c.id);
|
|
229
|
+
if (contract && ![...contract.acceptance, ...contract.mustNotBreak].some((condition2) => condition2.id === c.conditionId)) throw new Error("Unknown verification condition ID.");
|
|
230
|
+
}
|
|
231
|
+
return JSON.parse(JSON.stringify(raw));
|
|
232
|
+
}
|
|
233
|
+
function validateHttpCase(test) {
|
|
234
|
+
keys(test, ["request", "expected"]);
|
|
235
|
+
const request = test.request, expected = test.expected;
|
|
236
|
+
if (!request || typeof request !== "object" || Array.isArray(request)) throw new Error("Invalid HTTP request.");
|
|
237
|
+
keys(request, ["method", "path", ..."headers" in request ? ["headers"] : [], ..."body" in request ? ["body"] : []]);
|
|
238
|
+
if (!httpMethods.includes(request.method) || typeof request.path !== "string" || request.path.length > 2048 || !new RegExp(httpPathPattern).test(request.path) || /[\\#]/.test(request.path)) throw new Error("Invalid HTTP method or origin-relative path.");
|
|
239
|
+
if ("body" in request && (typeof request.body !== "string" || Buffer.byteLength(request.body, "utf8") > HTTP_LIMITS.bodyBytes || ["GET", "HEAD"].includes(request.method))) throw new Error("Invalid HTTP request body.");
|
|
240
|
+
if ("headers" in request) {
|
|
241
|
+
const headers = request.headers;
|
|
242
|
+
if (!headers || typeof headers !== "object" || Array.isArray(headers) || Object.keys(headers).length > 8 || Object.entries(headers).some(([name, value]) => !new RegExp(httpHeaderPattern).test(name) || typeof value !== "string" || value.length > 512 || /[^ -~]/.test(value))) throw new Error("Invalid synthetic HTTP headers.");
|
|
243
|
+
}
|
|
244
|
+
if (!expected || typeof expected !== "object" || Array.isArray(expected)) throw new Error("Missing HTTP expectation.");
|
|
245
|
+
const hasJson = Object.hasOwn(expected, "json");
|
|
246
|
+
keys(expected, ["status", hasJson ? "json" : "text"]);
|
|
247
|
+
if (!Number.isInteger(expected.status) || expected.status < 200 || expected.status > 599 || !hasJson && typeof expected.text !== "string") throw new Error("Invalid HTTP expectation.");
|
|
248
|
+
if (Buffer.byteLength(hasJson ? JSON.stringify(expected.json) : expected.text, "utf8") > HTTP_LIMITS.responseBytes) throw new Error("HTTP expected body exceeds byte limit.");
|
|
249
|
+
if ((request.method === "HEAD" || [204, 205, 304].includes(expected.status)) && (hasJson || expected.text !== "")) throw new Error("HTTP response must have an empty text body.");
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ../../shared/workTools.ts
|
|
253
|
+
var cwd = { type: "string", minLength: 1, maxLength: 4096 };
|
|
254
|
+
var taskId = { type: "string", pattern: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" };
|
|
255
|
+
var WORK_TOOLS = [
|
|
256
|
+
{
|
|
257
|
+
name: "viberaven_work_start",
|
|
258
|
+
description: "Save a versioned Task contract and run a free local check without login, network, edits or payment. Prefer contract; request alone saves a draft with unknown acceptance. No credentials or shell command fields. Review the returned contract before approving resume. Resume shares its short request and redacted results with the account; the full definition stays local. Provider and non-local contracts are planning only.",
|
|
259
|
+
inputSchema: { type: "object", properties: { cwd, contract: TASK_CONTRACT_SCHEMA, request: { type: "string", minLength: 1, maxLength: 1200 }, cli: { type: "string", enum: ["claude", "codex", "gemini"] }, access: { type: "string", enum: ["ask", "approve"] } }, required: ["cli", "access"], oneOf: [{ required: ["contract"], not: { required: ["request"] } }, { required: ["request"], not: { required: ["contract"] } }], additionalProperties: false }
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: "viberaven_work_resume",
|
|
263
|
+
description: "Resume the SAME saved task through account sign-in, quota or payment. Set approvedContract=true only after explicit human approval of its exact acceptance, must-not-break conditions and declared scope. A draft can be upgraded with contract before any job exists; its request must stay identical. Never authorize sign-in or payment for the person. Execution state is separate from independent verification observations; agent success is not condition proof. Scope declarations are not an enforced sandbox.",
|
|
264
|
+
inputSchema: { type: "object", properties: { cwd, taskId, contract: TASK_CONTRACT_SCHEMA, approvedContract: { type: "boolean" } }, required: ["taskId"], additionalProperties: false }
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: "viberaven_work_status",
|
|
268
|
+
description: "Read the saved Task contract, execution state and independent verification receipts locally without account, network, edits or payment. Current worktree changes invalidate checked proof; missing observations stay not_checked. Checked conditions separately report passed/failed outcomes. Historical agent results do not verify conditions.",
|
|
269
|
+
inputSchema: { type: "object", properties: { cwd, taskId }, required: ["taskId"], additionalProperties: false }
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: "viberaven_work_prepare",
|
|
273
|
+
description: "Before implementing a local Node feature, freeze reviewed expected behavior and actual dirty/untracked baseline. Supports module comparisons, sequential HTTP requests to an isolated local server factory, and frozen Node preservation tests. No login or network; no commands or imported proof. MCP plans are limited to 4800 UTF-8 bytes; larger plans use the CLI JSON file (65536 bytes). No browser, database or live provider proof. Changed plans require a new task.",
|
|
274
|
+
inputSchema: { type: "object", properties: { cwd, taskId, verification: VERIFICATION_PLAN_SCHEMA }, required: ["taskId", "verification"], additionalProperties: false }
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: "viberaven_work_verify",
|
|
278
|
+
description: "Run or resume the SAME frozen plan using the locally available pinned Docker image only. Set approvedVerification=true only after human review/approval. Network is disabled and no dependencies are installed. No login or billing. Missing conditions, dependencies or Docker remain not_checked; completed receipts are reused for the identical candidate. Coding-agent success is not proof.",
|
|
279
|
+
inputSchema: { type: "object", properties: { cwd, taskId, approvedVerification: { type: "boolean" } }, required: ["taskId", "approvedVerification"], additionalProperties: false }
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: "viberaven_work_report",
|
|
283
|
+
description: "Export a bounded local draft proof report with Markdown from current integrity-checked verification receipts. Read-only: no login, network, Docker, agent or GitHub execution. Failed and unknown evidence remain explicit; agent success is not proof. Not authoritative CI or a completed live PR pilot. Review redacted text before sharing; redaction is not a complete secret scanner.",
|
|
284
|
+
inputSchema: { type: "object", properties: { cwd, taskId }, required: ["taskId"], additionalProperties: false }
|
|
285
|
+
}
|
|
286
|
+
];
|
|
287
|
+
var isWorkTool = (name) => WORK_TOOLS.some((tool) => tool.name === name);
|
|
288
|
+
function buildWorkToolArgs(name, raw) {
|
|
289
|
+
const invalid2 = () => {
|
|
290
|
+
throw new Error("Invalid work-tool arguments. Use only the documented Task contract or taskId; no credentials or commands.");
|
|
291
|
+
};
|
|
292
|
+
if (!isWorkTool(name) || !raw || typeof raw !== "object" || Array.isArray(raw)) return invalid2();
|
|
293
|
+
const args = raw;
|
|
294
|
+
const action = name.slice("viberaven_work_".length);
|
|
295
|
+
const allowed = action === "start" ? ["cwd", "request", "contract", "cli", "access"] : action === "resume" ? ["cwd", "taskId", "contract", "approvedContract"] : action === "prepare" ? ["cwd", "taskId", "verification"] : action === "verify" ? ["cwd", "taskId", "approvedVerification"] : ["cwd", "taskId"];
|
|
296
|
+
if (Object.keys(args).some((key) => !allowed.includes(key))) return invalid2();
|
|
297
|
+
if (args.cwd !== void 0 && (typeof args.cwd !== "string" || !args.cwd.trim() || args.cwd.length > 4096 || /[\0\r\n]/.test(args.cwd))) return invalid2();
|
|
298
|
+
const out = ["work", action];
|
|
299
|
+
if (action === "start") {
|
|
300
|
+
if (args.contract === void 0 === (args.request === void 0) || !["claude", "codex", "gemini"].includes(args.cli) || !["ask", "approve"].includes(args.access)) return invalid2();
|
|
301
|
+
if (args.request !== void 0) {
|
|
302
|
+
if (typeof args.request !== "string") return invalid2();
|
|
303
|
+
draftTaskContract(args.request);
|
|
304
|
+
out.push("--request-base64", Buffer.from(args.request, "utf8").toString("base64url"));
|
|
305
|
+
}
|
|
306
|
+
out.push("--source", "mcp", "--cli", args.cli, "--access", args.access);
|
|
307
|
+
} else {
|
|
308
|
+
if (typeof args.taskId !== "string" || !new RegExp(taskId.pattern).test(args.taskId)) return invalid2();
|
|
309
|
+
if (args.approvedContract !== void 0 && typeof args.approvedContract !== "boolean") return invalid2();
|
|
310
|
+
out.push("--id", args.taskId);
|
|
311
|
+
if (args.approvedContract === true) out.push("--approve-contract");
|
|
312
|
+
if (action === "prepare") {
|
|
313
|
+
const plan = JSON.stringify(parseVerificationPlan(args.verification));
|
|
314
|
+
if (Buffer.byteLength(plan, "utf8") > 4800) throw new Error("MCP verification transport exceeds 4800 bytes. Use work prepare --verification <file.json>.");
|
|
315
|
+
out.push("--verification-base64", Buffer.from(plan, "utf8").toString("base64url"));
|
|
316
|
+
}
|
|
317
|
+
if (action === "verify") {
|
|
318
|
+
if (typeof args.approvedVerification !== "boolean") return invalid2();
|
|
319
|
+
if (args.approvedVerification) out.push("--approve-verification");
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (args.contract !== void 0) out.push("--contract-base64", Buffer.from(JSON.stringify(parseTaskContract(args.contract)), "utf8").toString("base64url"));
|
|
323
|
+
return [...out, "--json"];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/lib/cli-runner.ts
|
|
38
327
|
var import_node_child_process = require("node:child_process");
|
|
39
|
-
var
|
|
328
|
+
var import_node_fs3 = require("node:fs");
|
|
329
|
+
var import_node_path2 = require("node:path");
|
|
330
|
+
|
|
331
|
+
// ../../shared/liveTools.ts
|
|
332
|
+
var cwd2 = { type: "string", description: "Local project directory. Defaults to the MCP working directory." };
|
|
333
|
+
var stepId = { type: "string", format: "uuid", description: "The stepId returned by live_start; preserve it through sign-in, payment and retries." };
|
|
334
|
+
var supabaseProjectPattern = "^[a-z]{20}$";
|
|
335
|
+
var vercelProjectPattern = "^prj_[a-zA-Z0-9]{8,80}$";
|
|
336
|
+
var vercelTeamPattern = "^team_[a-zA-Z0-9]{8,80}$";
|
|
337
|
+
var schemaPattern = "^(?!pg_)(?!(?:auth|storage|vault|information_schema)$)[a-z][a-z0-9_]{0,62}$";
|
|
338
|
+
var LIVE_TOOLS = [
|
|
339
|
+
{
|
|
340
|
+
name: "viberaven_live_start",
|
|
341
|
+
description: "Local candidate feature: save a scoped metadata-verification request without provider reads or payment. Supabase catalog reads require a VibeRaven account and explicit human consent on resume. Vercel is deliberately blocked before network access. Local repository checks stay free without an account. Never pass credentials as tool arguments.",
|
|
342
|
+
inputSchema: {
|
|
343
|
+
type: "object",
|
|
344
|
+
properties: {
|
|
345
|
+
cwd: cwd2,
|
|
346
|
+
provider: { type: "string", enum: ["supabase", "vercel"] },
|
|
347
|
+
projectRef: { type: "string", description: "Exact provider project ID: 20 lowercase letters for Supabase, or prj_ followed by 8\u201380 alphanumeric characters for Vercel." },
|
|
348
|
+
schemas: { type: "array", items: { type: "string", pattern: schemaPattern }, minItems: 1, maxItems: 8, uniqueItems: true, description: "1\u20138 lowercase application schemas; defaults to public. Excludes pg_, auth, storage, vault and information_schema. No application-row reads." },
|
|
349
|
+
teamId: { type: "string", pattern: vercelTeamPattern, description: "Optional Vercel team_ ID with 8\u201380 alphanumeric characters. Vercel transport is currently blocked." }
|
|
350
|
+
},
|
|
351
|
+
required: ["provider", "projectRef"],
|
|
352
|
+
additionalProperties: false,
|
|
353
|
+
allOf: [
|
|
354
|
+
{ if: { properties: { provider: { const: "supabase" } } }, then: { properties: { projectRef: { pattern: supabaseProjectPattern } }, not: { required: ["teamId"] } } },
|
|
355
|
+
{ if: { properties: { provider: { const: "vercel" } } }, then: { properties: { projectRef: { pattern: vercelProjectPattern } }, not: { required: ["schemas"] } } }
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
name: "viberaven_live_resume",
|
|
361
|
+
description: "Local candidate feature: resume the SAME saved live step through account connection, allowance and metadata verification. Set approvedRead=true only after the person explicitly approves the named Supabase project/schema catalog read. Show any returned action URL and wait for the person; never approve sign-in or payment for them. Credentials stay local and are never tool arguments. Vercel stays blocked; local checks stay free.",
|
|
362
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, stepId, approvedRead: { type: "boolean", description: "True only after explicit human approval of this saved provider/project/schema read." } }, required: ["stepId"], additionalProperties: false }
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
name: "viberaven_live_status",
|
|
366
|
+
description: "Local candidate feature: read the saved live-step receipt without provider reads, payment or another live-step charge. Evidence is historical and scoped, not proof of application security. Local checks stay free.",
|
|
367
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, stepId }, required: ["stepId"], additionalProperties: false }
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: "viberaven_live_disconnect",
|
|
371
|
+
description: "Local candidate feature: disconnect the saved live step and remove its locally retained provider credential and evidence. Does not alter provider settings or unrelated MCP credentials. Unfinished account reservations expire. Local checks stay free.",
|
|
372
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, stepId }, required: ["stepId"], additionalProperties: false }
|
|
373
|
+
}
|
|
374
|
+
];
|
|
375
|
+
function isLiveTool(name) {
|
|
376
|
+
return LIVE_TOOLS.some((tool) => tool.name === name);
|
|
377
|
+
}
|
|
378
|
+
var uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
379
|
+
function invalid() {
|
|
380
|
+
throw new Error("Invalid live-tool arguments. Use only the documented scope or saved stepId; never pass credentials.");
|
|
381
|
+
}
|
|
382
|
+
function buildLiveToolArgs(name, raw) {
|
|
383
|
+
if (!isLiveTool(name) || !raw || typeof raw !== "object" || Array.isArray(raw)) return invalid();
|
|
384
|
+
const args = raw;
|
|
385
|
+
const allowed = name === "viberaven_live_start" ? ["cwd", "provider", "projectRef", "schemas", "teamId"] : name === "viberaven_live_resume" ? ["cwd", "stepId", "approvedRead"] : ["cwd", "stepId"];
|
|
386
|
+
if (Object.keys(args).some((key) => !allowed.includes(key))) return invalid();
|
|
387
|
+
if (args.cwd !== void 0 && (typeof args.cwd !== "string" || !args.cwd.trim() || args.cwd.length > 4096 || /[\0\r\n]/.test(args.cwd))) return invalid();
|
|
388
|
+
if (name === "viberaven_live_start") {
|
|
389
|
+
if (!["supabase", "vercel"].includes(args.provider) || typeof args.projectRef !== "string" || !new RegExp(args.provider === "supabase" ? supabaseProjectPattern : vercelProjectPattern).test(args.projectRef)) return invalid();
|
|
390
|
+
const out = ["live", "start", "--provider", args.provider, "--project", args.projectRef];
|
|
391
|
+
if (args.schemas !== void 0) {
|
|
392
|
+
if (args.provider !== "supabase" || !Array.isArray(args.schemas) || args.schemas.length < 1 || args.schemas.length > 8 || args.schemas.some((s) => typeof s !== "string" || !new RegExp(schemaPattern).test(s)) || new Set(args.schemas).size !== args.schemas.length) return invalid();
|
|
393
|
+
out.push("--schemas", args.schemas.join(","));
|
|
394
|
+
}
|
|
395
|
+
if (args.teamId !== void 0) {
|
|
396
|
+
if (args.provider !== "vercel" || typeof args.teamId !== "string" || !new RegExp(vercelTeamPattern).test(args.teamId)) return invalid();
|
|
397
|
+
out.push("--team", args.teamId);
|
|
398
|
+
}
|
|
399
|
+
return [...out, "--json"];
|
|
400
|
+
}
|
|
401
|
+
if (typeof args.stepId !== "string" || !uuid.test(args.stepId) || args.approvedRead !== void 0 && typeof args.approvedRead !== "boolean") return invalid();
|
|
402
|
+
return ["live", name.slice("viberaven_live_".length), "--id", args.stepId.toLowerCase(), ...args.approvedRead === true ? ["--approve-read"] : [], "--json"];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/lib/work-report-runner.ts
|
|
406
|
+
var import_node_fs2 = require("node:fs");
|
|
407
|
+
var import_node_module = require("node:module");
|
|
40
408
|
var import_node_path = require("node:path");
|
|
409
|
+
|
|
410
|
+
// ../../shared/workReportRunner.ts
|
|
411
|
+
var import_node_fs = require("node:fs");
|
|
412
|
+
var MAX_OUTPUT_BYTES = 65536;
|
|
413
|
+
var REPORT_TIMEOUT_MS = 3e4;
|
|
414
|
+
var workReportFailure = () => {
|
|
415
|
+
const stdout = JSON.stringify({ error: "Local proof report unavailable. Check the matching installed CLI, task ID, saved state integrity and current source readability.", code: "work_report_unavailable" });
|
|
416
|
+
return { stdout, stderr: "", exitCode: 1, text: `exit 1
|
|
417
|
+
${stdout}` };
|
|
418
|
+
};
|
|
419
|
+
function runWorkReportProcess(entry, args, cwd3, spawnFn2) {
|
|
420
|
+
let canonicalCwd;
|
|
421
|
+
try {
|
|
422
|
+
if (cwd3 !== void 0 && (typeof cwd3 !== "string" || !cwd3.trim())) return Promise.resolve(workReportFailure());
|
|
423
|
+
canonicalCwd = (0, import_node_fs.realpathSync)(cwd3 === void 0 ? process.cwd() : cwd3);
|
|
424
|
+
} catch {
|
|
425
|
+
return Promise.resolve(workReportFailure());
|
|
426
|
+
}
|
|
427
|
+
return new Promise((resolve) => {
|
|
428
|
+
let settled = false, stdoutBytes = 0, stderrBytes = 0;
|
|
429
|
+
const chunks = [];
|
|
430
|
+
let child;
|
|
431
|
+
const finish = (result) => {
|
|
432
|
+
if (!settled) {
|
|
433
|
+
settled = true;
|
|
434
|
+
clearTimeout(timer);
|
|
435
|
+
resolve(result);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
const fail = () => {
|
|
439
|
+
if (settled) return;
|
|
440
|
+
finish(workReportFailure());
|
|
441
|
+
child?.kill();
|
|
442
|
+
};
|
|
443
|
+
const timer = setTimeout(fail, REPORT_TIMEOUT_MS);
|
|
444
|
+
timer.unref();
|
|
445
|
+
try {
|
|
446
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !/^(?:node_|npm_)/i.test(key) && key.toLowerCase() !== "viberaven_cli_path"));
|
|
447
|
+
child = spawnFn2(process.execPath, [entry, ...args], { cwd: canonicalCwd, env, shell: false, windowsHide: true, stdio: ["ignore", "pipe", "pipe"] });
|
|
448
|
+
child.stdout?.on("data", (chunk) => {
|
|
449
|
+
if (settled) return;
|
|
450
|
+
stdoutBytes += chunk.length;
|
|
451
|
+
if (stdoutBytes > MAX_OUTPUT_BYTES - 8) return fail();
|
|
452
|
+
chunks.push(Buffer.from(chunk));
|
|
453
|
+
});
|
|
454
|
+
child.stderr?.on("data", (chunk) => {
|
|
455
|
+
if (settled) return;
|
|
456
|
+
stderrBytes += chunk.length;
|
|
457
|
+
if (stderrBytes > MAX_OUTPUT_BYTES) fail();
|
|
458
|
+
});
|
|
459
|
+
child.on("error", fail);
|
|
460
|
+
child.on("close", (code) => {
|
|
461
|
+
if (settled) return;
|
|
462
|
+
try {
|
|
463
|
+
const stdout = new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks));
|
|
464
|
+
const report = JSON.parse(stdout);
|
|
465
|
+
const requestedId = args[args.indexOf("--id") + 1];
|
|
466
|
+
if (code !== 0 || !report || Array.isArray(report) || report.reportVersion !== 1 || report.taskId !== requestedId || !["passed", "failed", "not_checked"].includes(report.outcome) || typeof report.markdown !== "string" || "error" in report) return finish(workReportFailure());
|
|
467
|
+
finish({ stdout, stderr: "", exitCode: 0, text: `exit 0
|
|
468
|
+
${stdout.trim()}` });
|
|
469
|
+
} catch {
|
|
470
|
+
finish(workReportFailure());
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
} catch {
|
|
474
|
+
fail();
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/lib/work-report-runner.ts
|
|
480
|
+
var within = (root, target) => {
|
|
481
|
+
const rel = (0, import_node_path.relative)(root, target);
|
|
482
|
+
return !rel || !(0, import_node_path.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(`..${import_node_path.sep}`);
|
|
483
|
+
};
|
|
484
|
+
function installedReportCli(version, cwd3) {
|
|
485
|
+
const override = process.env.VIBERAVEN_CLI_PATH;
|
|
486
|
+
if (override !== void 0 && !(0, import_node_path.isAbsolute)(override)) throw new Error("Unavailable installed CLI");
|
|
487
|
+
const selected = override ?? (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_module.createRequire)(__filename).resolve("@viberaven/cli/package.json")), "dist", "cli.js");
|
|
488
|
+
const info = (0, import_node_fs2.lstatSync)(selected);
|
|
489
|
+
if (!info.isFile() || info.isSymbolicLink()) throw new Error("Unavailable installed CLI");
|
|
490
|
+
const entry = (0, import_node_fs2.realpathSync)(selected);
|
|
491
|
+
const root = (0, import_node_fs2.realpathSync)((0, import_node_path.join)((0, import_node_path.dirname)(entry), ".."));
|
|
492
|
+
if (entry !== (0, import_node_path.join)(root, "dist", "cli.js") || within(cwd3, entry)) throw new Error("Unavailable installed CLI");
|
|
493
|
+
const manifestPath = (0, import_node_path.join)(root, "package.json"), manifestInfo = (0, import_node_fs2.lstatSync)(manifestPath);
|
|
494
|
+
if (!manifestInfo.isFile() || manifestInfo.isSymbolicLink() || manifestInfo.size > 65536 || (0, import_node_fs2.realpathSync)(manifestPath) !== manifestPath) throw new Error("Unavailable installed CLI");
|
|
495
|
+
const manifest = JSON.parse((0, import_node_fs2.readFileSync)(manifestPath, "utf8"));
|
|
496
|
+
if (manifest.name !== "@viberaven/cli" || manifest.version !== version) throw new Error("Unavailable installed CLI");
|
|
497
|
+
return entry;
|
|
498
|
+
}
|
|
499
|
+
function runInstalledWorkReport(args, cwd3, version, spawnFn2) {
|
|
500
|
+
let entry, canonicalCwd;
|
|
501
|
+
try {
|
|
502
|
+
if (cwd3 !== void 0 && (typeof cwd3 !== "string" || !cwd3.trim())) return Promise.resolve(workReportFailure());
|
|
503
|
+
canonicalCwd = (0, import_node_fs2.realpathSync)(cwd3 === void 0 ? process.cwd() : cwd3);
|
|
504
|
+
entry = installedReportCli(version, canonicalCwd);
|
|
505
|
+
} catch {
|
|
506
|
+
return Promise.resolve(workReportFailure());
|
|
507
|
+
}
|
|
508
|
+
return runWorkReportProcess(entry, args, canonicalCwd, spawnFn2);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// src/lib/cli-runner.ts
|
|
41
512
|
var CLI_PACKAGE = "@viberaven/cli";
|
|
42
513
|
var MCP_PACKAGE = "@viberaven/mcp";
|
|
43
514
|
var PLAIN_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
@@ -45,14 +516,14 @@ var cachedVersion;
|
|
|
45
516
|
function mcpVersion() {
|
|
46
517
|
if (cachedVersion) return cachedVersion;
|
|
47
518
|
let found;
|
|
48
|
-
for (let dir = __dirname, depth = 0; depth < 4 && !found; depth += 1, dir = (0,
|
|
519
|
+
for (let dir = __dirname, depth = 0; depth < 4 && !found; depth += 1, dir = (0, import_node_path2.dirname)(dir)) {
|
|
49
520
|
try {
|
|
50
|
-
const manifest = JSON.parse((0,
|
|
521
|
+
const manifest = JSON.parse((0, import_node_fs3.readFileSync)((0, import_node_path2.join)(dir, "package.json"), "utf8"));
|
|
51
522
|
if (manifest.name === MCP_PACKAGE && typeof manifest.version === "string") found = manifest.version;
|
|
52
523
|
} catch {
|
|
53
524
|
}
|
|
54
525
|
}
|
|
55
|
-
found ??= true ? "1.
|
|
526
|
+
found ??= true ? "1.7.0" : void 0;
|
|
56
527
|
if (!found || !PLAIN_VERSION.test(found)) {
|
|
57
528
|
throw new Error(`Could not read a valid ${MCP_PACKAGE} version (got ${JSON.stringify(found)}), so the matching ${CLI_PACKAGE} cannot be pinned.`);
|
|
58
529
|
}
|
|
@@ -90,11 +561,11 @@ function safeStringArg(value, label) {
|
|
|
90
561
|
if (/[&|<>^%!"\r\n]/.test(value)) throw new Error(`Unsafe characters in ${label}`);
|
|
91
562
|
return value;
|
|
92
563
|
}
|
|
93
|
-
function resolveCwd(
|
|
94
|
-
if (
|
|
95
|
-
if (typeof
|
|
96
|
-
if (!
|
|
97
|
-
return
|
|
564
|
+
function resolveCwd(cwd3) {
|
|
565
|
+
if (cwd3 === void 0 || cwd3 === null) return process.cwd();
|
|
566
|
+
if (typeof cwd3 !== "string") throw new Error("Invalid cwd: expected string");
|
|
567
|
+
if (!cwd3.trim()) throw new Error("Invalid cwd: expected non-empty string");
|
|
568
|
+
return cwd3;
|
|
98
569
|
}
|
|
99
570
|
function buildNpxCommand(args) {
|
|
100
571
|
if (process.platform === "win32") {
|
|
@@ -109,6 +580,8 @@ function buildHealArgs(prefix, args) {
|
|
|
109
580
|
return cliArgs;
|
|
110
581
|
}
|
|
111
582
|
function buildToolArgs(name, args) {
|
|
583
|
+
if (isLiveTool(name)) return buildLiveToolArgs(name, args);
|
|
584
|
+
if (isWorkTool(name)) return buildWorkToolArgs(name, args);
|
|
112
585
|
switch (name) {
|
|
113
586
|
case "viberaven_check_readiness":
|
|
114
587
|
return ["check", "--json"];
|
|
@@ -156,17 +629,27 @@ function buildToolArgs(name, args) {
|
|
|
156
629
|
throw new Error(`Unknown VibeRaven tool: ${name}`);
|
|
157
630
|
}
|
|
158
631
|
}
|
|
159
|
-
function runVibeRaven(args,
|
|
632
|
+
async function runVibeRaven(args, cwd3) {
|
|
633
|
+
return (await runVibeRavenDetailed(args, cwd3)).text;
|
|
634
|
+
}
|
|
635
|
+
function runVibeRavenDetailed(args, cwd3) {
|
|
636
|
+
if (args[0] === "work" && args[1] === "report") {
|
|
637
|
+
try {
|
|
638
|
+
return runInstalledWorkReport(args, cwd3, mcpVersion(), spawnFn);
|
|
639
|
+
} catch {
|
|
640
|
+
return Promise.resolve(workReportFailure());
|
|
641
|
+
}
|
|
642
|
+
}
|
|
160
643
|
let npxArgs;
|
|
161
644
|
try {
|
|
162
645
|
npxArgs = cliNpxArgs(args);
|
|
163
646
|
} catch (error) {
|
|
164
|
-
return Promise.resolve(`ERROR: ${error instanceof Error ? error.message : String(error)}`);
|
|
647
|
+
return Promise.resolve({ stdout: "", stderr: "", exitCode: 1, text: `ERROR: ${error instanceof Error ? error.message : String(error)}` });
|
|
165
648
|
}
|
|
166
649
|
return new Promise((resolve) => {
|
|
167
650
|
const built = buildNpxCommand(npxArgs);
|
|
168
651
|
const child = spawnFn(built.command, built.args, {
|
|
169
|
-
cwd: resolveCwd(
|
|
652
|
+
cwd: resolveCwd(cwd3),
|
|
170
653
|
env: cliChildEnv(),
|
|
171
654
|
shell: built.shell,
|
|
172
655
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -179,11 +662,11 @@ function runVibeRaven(args, cwd) {
|
|
|
179
662
|
child.stderr?.on("data", (chunk) => {
|
|
180
663
|
stderr += chunk.toString();
|
|
181
664
|
});
|
|
182
|
-
child.on("error", (error) => resolve(`ERROR: ${error.message}`));
|
|
665
|
+
child.on("error", (error) => resolve({ stdout: "", stderr, exitCode: 1, text: `ERROR: ${error.message}` }));
|
|
183
666
|
child.on("close", (code) => {
|
|
184
667
|
const combined = `${stdout}${stderr}`.trim();
|
|
185
|
-
resolve(`exit ${code ?? 1}${combined ? `
|
|
186
|
-
${combined}` : ""}`);
|
|
668
|
+
resolve({ stdout, stderr, exitCode: code ?? 1, text: `exit ${code ?? 1}${combined ? `
|
|
669
|
+
${combined}` : ""}` });
|
|
187
670
|
});
|
|
188
671
|
});
|
|
189
672
|
}
|
|
@@ -200,5 +683,6 @@ ${combined}` : ""}`);
|
|
|
200
683
|
mcpVersion,
|
|
201
684
|
resolveCwd,
|
|
202
685
|
runVibeRaven,
|
|
686
|
+
runVibeRavenDetailed,
|
|
203
687
|
safeStringArg
|
|
204
688
|
});
|