@viberaven/mcp 1.6.11 → 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 +12 -6
- 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/dist/server.js
CHANGED
|
@@ -30,6 +30,482 @@ var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
|
30
30
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
31
31
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
32
32
|
|
|
33
|
+
// ../../shared/liveTools.ts
|
|
34
|
+
var cwd = { type: "string", description: "Local project directory. Defaults to the MCP working directory." };
|
|
35
|
+
var stepId = { type: "string", format: "uuid", description: "The stepId returned by live_start; preserve it through sign-in, payment and retries." };
|
|
36
|
+
var supabaseProjectPattern = "^[a-z]{20}$";
|
|
37
|
+
var vercelProjectPattern = "^prj_[a-zA-Z0-9]{8,80}$";
|
|
38
|
+
var vercelTeamPattern = "^team_[a-zA-Z0-9]{8,80}$";
|
|
39
|
+
var schemaPattern = "^(?!pg_)(?!(?:auth|storage|vault|information_schema)$)[a-z][a-z0-9_]{0,62}$";
|
|
40
|
+
var LIVE_TOOLS = [
|
|
41
|
+
{
|
|
42
|
+
name: "viberaven_live_start",
|
|
43
|
+
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.",
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
cwd,
|
|
48
|
+
provider: { type: "string", enum: ["supabase", "vercel"] },
|
|
49
|
+
projectRef: { type: "string", description: "Exact provider project ID: 20 lowercase letters for Supabase, or prj_ followed by 8\u201380 alphanumeric characters for Vercel." },
|
|
50
|
+
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." },
|
|
51
|
+
teamId: { type: "string", pattern: vercelTeamPattern, description: "Optional Vercel team_ ID with 8\u201380 alphanumeric characters. Vercel transport is currently blocked." }
|
|
52
|
+
},
|
|
53
|
+
required: ["provider", "projectRef"],
|
|
54
|
+
additionalProperties: false,
|
|
55
|
+
allOf: [
|
|
56
|
+
{ if: { properties: { provider: { const: "supabase" } } }, then: { properties: { projectRef: { pattern: supabaseProjectPattern } }, not: { required: ["teamId"] } } },
|
|
57
|
+
{ if: { properties: { provider: { const: "vercel" } } }, then: { properties: { projectRef: { pattern: vercelProjectPattern } }, not: { required: ["schemas"] } } }
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "viberaven_live_resume",
|
|
63
|
+
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.",
|
|
64
|
+
inputSchema: { type: "object", properties: { cwd, stepId, approvedRead: { type: "boolean", description: "True only after explicit human approval of this saved provider/project/schema read." } }, required: ["stepId"], additionalProperties: false }
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "viberaven_live_status",
|
|
68
|
+
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.",
|
|
69
|
+
inputSchema: { type: "object", properties: { cwd, stepId }, required: ["stepId"], additionalProperties: false }
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "viberaven_live_disconnect",
|
|
73
|
+
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.",
|
|
74
|
+
inputSchema: { type: "object", properties: { cwd, stepId }, required: ["stepId"], additionalProperties: false }
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
function isLiveTool(name) {
|
|
78
|
+
return LIVE_TOOLS.some((tool) => tool.name === name);
|
|
79
|
+
}
|
|
80
|
+
function isLiveToolFailure(exitCode, receipt) {
|
|
81
|
+
if (exitCode !== 0) return true;
|
|
82
|
+
if (!receipt || typeof receipt !== "object") return false;
|
|
83
|
+
const value = receipt;
|
|
84
|
+
return Boolean(value.error) || ["blocked", "failed", "unsupported", "requires_retry"].includes(String(value.state));
|
|
85
|
+
}
|
|
86
|
+
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;
|
|
87
|
+
function invalid() {
|
|
88
|
+
throw new Error("Invalid live-tool arguments. Use only the documented scope or saved stepId; never pass credentials.");
|
|
89
|
+
}
|
|
90
|
+
function buildLiveToolArgs(name, raw) {
|
|
91
|
+
if (!isLiveTool(name) || !raw || typeof raw !== "object" || Array.isArray(raw)) return invalid();
|
|
92
|
+
const args = raw;
|
|
93
|
+
const allowed = name === "viberaven_live_start" ? ["cwd", "provider", "projectRef", "schemas", "teamId"] : name === "viberaven_live_resume" ? ["cwd", "stepId", "approvedRead"] : ["cwd", "stepId"];
|
|
94
|
+
if (Object.keys(args).some((key) => !allowed.includes(key))) return invalid();
|
|
95
|
+
if (args.cwd !== void 0 && (typeof args.cwd !== "string" || !args.cwd.trim() || args.cwd.length > 4096 || /[\0\r\n]/.test(args.cwd))) return invalid();
|
|
96
|
+
if (name === "viberaven_live_start") {
|
|
97
|
+
if (!["supabase", "vercel"].includes(args.provider) || typeof args.projectRef !== "string" || !new RegExp(args.provider === "supabase" ? supabaseProjectPattern : vercelProjectPattern).test(args.projectRef)) return invalid();
|
|
98
|
+
const out = ["live", "start", "--provider", args.provider, "--project", args.projectRef];
|
|
99
|
+
if (args.schemas !== void 0) {
|
|
100
|
+
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();
|
|
101
|
+
out.push("--schemas", args.schemas.join(","));
|
|
102
|
+
}
|
|
103
|
+
if (args.teamId !== void 0) {
|
|
104
|
+
if (args.provider !== "vercel" || typeof args.teamId !== "string" || !new RegExp(vercelTeamPattern).test(args.teamId)) return invalid();
|
|
105
|
+
out.push("--team", args.teamId);
|
|
106
|
+
}
|
|
107
|
+
return [...out, "--json"];
|
|
108
|
+
}
|
|
109
|
+
if (typeof args.stepId !== "string" || !uuid.test(args.stepId) || args.approvedRead !== void 0 && typeof args.approvedRead !== "boolean") return invalid();
|
|
110
|
+
return ["live", name.slice("viberaven_live_".length), "--id", args.stepId.toLowerCase(), ...args.approvedRead === true ? ["--approve-read"] : [], "--json"];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ../providers/registry.generated.mjs
|
|
114
|
+
var registry_generated_default = {
|
|
115
|
+
"supabase": {
|
|
116
|
+
"hash": "e03ec354e648f89c22202df2e908e48e1ee88b733af8fe8becd70c8089001e45",
|
|
117
|
+
"pack": {
|
|
118
|
+
"schemaVersion": 1,
|
|
119
|
+
"provider": "supabase",
|
|
120
|
+
"displayName": "Supabase",
|
|
121
|
+
"packVersion": "1.0.0",
|
|
122
|
+
"reviewedAt": "2026-10-27",
|
|
123
|
+
"summary": "Plan Supabase-backed features with explicit identity, permissions, keys and provider seams. Repo rules are available; live catalog checks are planned and have not run.",
|
|
124
|
+
"applicability": [
|
|
125
|
+
"Supabase Data API, Auth, Postgres, Storage and Edge Functions.",
|
|
126
|
+
"Works with any hosting provider; Vercel is an optional seam, not a requirement."
|
|
127
|
+
],
|
|
128
|
+
"limits": [
|
|
129
|
+
"This pack is knowledge, not a scan, live connection or approval to change a provider.",
|
|
130
|
+
"Catalog metadata cannot prove row isolation or application behavior. Test the feature in an authorized test environment.",
|
|
131
|
+
"Local guidance and repository checks remain free without an account. Future live steps need an account; their free monthly quota is undecided.",
|
|
132
|
+
"No feature-building advantage over plain Claude is claimed before P3 comparison."
|
|
133
|
+
],
|
|
134
|
+
"sources": [
|
|
135
|
+
{
|
|
136
|
+
"id": "keys",
|
|
137
|
+
"title": "API keys",
|
|
138
|
+
"url": "https://supabase.com/docs/guides/api/api-keys"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"id": "rls",
|
|
142
|
+
"title": "Row Level Security",
|
|
143
|
+
"url": "https://supabase.com/docs/guides/database/postgres/row-level-security"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": "grants",
|
|
147
|
+
"title": "New table Data API exposure",
|
|
148
|
+
"url": "https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": "functions",
|
|
152
|
+
"title": "Database functions",
|
|
153
|
+
"url": "https://supabase.com/docs/guides/database/functions"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "connections",
|
|
157
|
+
"title": "Connecting to Postgres",
|
|
158
|
+
"url": "https://supabase.com/docs/guides/database/connecting-to-postgres"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"id": "clerk",
|
|
162
|
+
"title": "Third-party auth with Clerk",
|
|
163
|
+
"url": "https://supabase.com/docs/guides/auth/third-party/clerk"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": "vercel",
|
|
167
|
+
"title": "Vercel Marketplace integration",
|
|
168
|
+
"url": "https://supabase.com/docs/guides/integrations/vercel-marketplace"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": "edge-auth",
|
|
172
|
+
"title": "Securing Edge Functions",
|
|
173
|
+
"url": "https://supabase.com/docs/guides/functions/auth"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"id": "storage",
|
|
177
|
+
"title": "Storage access control",
|
|
178
|
+
"url": "https://supabase.com/docs/guides/storage/security/access-control"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"id": "email",
|
|
182
|
+
"title": "Sending emails from an Edge Function",
|
|
183
|
+
"url": "https://supabase.com/docs/guides/functions/examples/send-emails"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"id": "mcp",
|
|
187
|
+
"title": "Supabase MCP",
|
|
188
|
+
"url": "https://supabase.com/docs/guides/ai-tools/mcp"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"setup": [
|
|
192
|
+
{
|
|
193
|
+
"id": "choose-data-path",
|
|
194
|
+
"title": "Choose Data API or direct Postgres",
|
|
195
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
196
|
+
"text": "Record the target project and whether calls use supabase-js/Data API or a direct Postgres driver. Connection and permission checks differ.",
|
|
197
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
198
|
+
"sources": [
|
|
199
|
+
"connections"
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"id": "split-client-server-keys",
|
|
204
|
+
"title": "Separate public and server clients",
|
|
205
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
206
|
+
"text": "Use a publishable key for public clients. Keep sb_secret_ and legacy service_role credentials server-side; they bypass RLS. End-user identity comes from a user token, not the project key.",
|
|
207
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
208
|
+
"sources": [
|
|
209
|
+
"keys"
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"id": "define-ownership",
|
|
214
|
+
"title": "Define ownership before tables",
|
|
215
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
216
|
+
"text": "Enable RLS where appropriate and define role/owner predicates for the feature. Review grants separately.",
|
|
217
|
+
"evidence": "Review migrations, then test allowed and denied actors in an authorized fixture.",
|
|
218
|
+
"sources": [
|
|
219
|
+
"rls",
|
|
220
|
+
"grants"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"id": "function-auth-boundary",
|
|
225
|
+
"title": "Choose Edge Function authentication",
|
|
226
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
227
|
+
"text": "Decide whether a function accepts user JWTs, service calls or signed webhooks. New API keys are not JWTs. Disabling verify_jwt requires explicit handler authorization; it is not an authentication fix by itself.",
|
|
228
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
229
|
+
"sources": [
|
|
230
|
+
"keys",
|
|
231
|
+
"edge-auth"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"id": "feature-evidence",
|
|
236
|
+
"title": "Define the evidence before implementation",
|
|
237
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
238
|
+
"text": "List repo assertions, provider metadata assertions and application tests separately. Planned live capabilities below currently return no observations.",
|
|
239
|
+
"evidence": "A task-specific test plan with each unchecked boundary visible.",
|
|
240
|
+
"sources": [
|
|
241
|
+
"mcp"
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"gotchas": [
|
|
246
|
+
{
|
|
247
|
+
"id": "grants-not-policies",
|
|
248
|
+
"title": "42501 is not automatically an RLS bug",
|
|
249
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
250
|
+
"text": "New Data API tables may lack grants. Grant only intended operations/roles; an RLS policy does not supply table privileges. Do not disable RLS to fix permission denied.",
|
|
251
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
252
|
+
"sources": [
|
|
253
|
+
"grants"
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"id": "update-select",
|
|
258
|
+
"title": "UPDATE needs a SELECT policy",
|
|
259
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
260
|
+
"text": "Review the SELECT policy as well as UPDATE predicates. USING applies to existing rows; WITH CHECK constrains the new row. Test owner changes explicitly.",
|
|
261
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
262
|
+
"sources": [
|
|
263
|
+
"rls"
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"id": "invoker-views",
|
|
268
|
+
"title": "Views need their own access review",
|
|
269
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
270
|
+
"text": "On supported PostgreSQL versions, security_invoker views use the caller permissions. A view can otherwise bypass intended RLS restrictions depending on its owner.",
|
|
271
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
272
|
+
"sources": [
|
|
273
|
+
"rls"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"id": "definer-execute",
|
|
278
|
+
"title": "Function ownership and EXECUTE matter",
|
|
279
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
280
|
+
"text": "Prefer invoker functions. For a necessary SECURITY DEFINER, constrain search_path and review EXECUTE privileges, including PUBLIC. Do not use elevated functions as a blanket permission workaround.",
|
|
281
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
282
|
+
"sources": [
|
|
283
|
+
"functions"
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"id": "pooler-mode",
|
|
288
|
+
"title": "Pooler ports have different semantics",
|
|
289
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
290
|
+
"text": "Session and transaction pooling serve different connection lifetimes. Transaction pooling does not support prepared statements; match the driver configuration to the documented mode instead of changing ports blindly.",
|
|
291
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
292
|
+
"sources": [
|
|
293
|
+
"connections"
|
|
294
|
+
]
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"id": "storage-upsert",
|
|
298
|
+
"title": "Storage replacement is more than INSERT",
|
|
299
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
300
|
+
"text": "Storage upsert needs SELECT and UPDATE privileges in addition to INSERT. Test replacement separately from a first upload.",
|
|
301
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
302
|
+
"sources": [
|
|
303
|
+
"storage"
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
"changes": [
|
|
308
|
+
{
|
|
309
|
+
"id": "data-api-default-grants",
|
|
310
|
+
"title": "New tables require explicit Data API grants",
|
|
311
|
+
"appliesTo": "New public tables reached via Data API or GraphQL; inspect the project setting and grants.",
|
|
312
|
+
"text": "The announcement schedules existing-project rollout for 2026-10-30; new projects started receiving the default on 2026-05-30. Existing table grants remain. Direct Postgres callers are outside this specific change.",
|
|
313
|
+
"evidence": "Review live project metadata after authorized connection; a date alone does not prove rollout.",
|
|
314
|
+
"sources": [
|
|
315
|
+
"grants"
|
|
316
|
+
],
|
|
317
|
+
"effectiveOn": "2026-10-30",
|
|
318
|
+
"status": "announced"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"id": "publishable-secret-migration",
|
|
322
|
+
"title": "Use current API-key families",
|
|
323
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
324
|
+
"text": "Prefer sb_publishable_ and sb_secret_ over the legacy JWT-based project keys. Audit key consumers and Edge Function authorization during migration; do not invent a universal removal date.",
|
|
325
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
326
|
+
"sources": [
|
|
327
|
+
"keys"
|
|
328
|
+
],
|
|
329
|
+
"effectiveOn": "unknown",
|
|
330
|
+
"status": "undated"
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"seams": [
|
|
334
|
+
{
|
|
335
|
+
"id": "supabase-vercel",
|
|
336
|
+
"title": "Vercel environment names and targets",
|
|
337
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
338
|
+
"text": "Check the integration-provided names against code. NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY belong to the public client; SUPABASE_SECRET_KEY stays server-side. Verify the target environment separately.",
|
|
339
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
340
|
+
"sources": [
|
|
341
|
+
"vercel"
|
|
342
|
+
],
|
|
343
|
+
"providers": [
|
|
344
|
+
"supabase",
|
|
345
|
+
"vercel"
|
|
346
|
+
]
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"id": "supabase-clerk",
|
|
350
|
+
"title": "Clerk user identity and Supabase authorization",
|
|
351
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
352
|
+
"text": "Configure the Clerk third-party integration in Supabase. Pass the Clerk session token through the client accessToken callback. Review the authenticated role claim and ownership predicates; successful sign-in alone does not authorize every row.",
|
|
353
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
354
|
+
"sources": [
|
|
355
|
+
"clerk"
|
|
356
|
+
],
|
|
357
|
+
"providers": [
|
|
358
|
+
"supabase",
|
|
359
|
+
"clerk"
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"id": "supabase-resend",
|
|
364
|
+
"title": "Resend from an Edge Function",
|
|
365
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
366
|
+
"text": "Keep RESEND_API_KEY in the function environment and authorize the function caller. Check the sending-domain setup and test email delivery separately from a successful function invocation.",
|
|
367
|
+
"evidence": "Inspect the relevant configuration and test the requested behavior; guidance is not observed evidence.",
|
|
368
|
+
"sources": [
|
|
369
|
+
"email",
|
|
370
|
+
"edge-auth"
|
|
371
|
+
],
|
|
372
|
+
"providers": [
|
|
373
|
+
"supabase",
|
|
374
|
+
"resend"
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
"repo-checks": [
|
|
379
|
+
{
|
|
380
|
+
"id": "repo-rls",
|
|
381
|
+
"title": "Migration RLS checks",
|
|
382
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
383
|
+
"text": "Reference the existing local checks for missing RLS and policies. Their findings describe repository SQL, not applied provider state.",
|
|
384
|
+
"evidence": "Run viberaven check --json in the project and retain the actual finding IDs.",
|
|
385
|
+
"sources": [
|
|
386
|
+
"rls"
|
|
387
|
+
],
|
|
388
|
+
"ruleIds": [
|
|
389
|
+
"rls_disabled",
|
|
390
|
+
"rls_no_policies"
|
|
391
|
+
],
|
|
392
|
+
"status": "implemented"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"id": "repo-keys",
|
|
396
|
+
"title": "Client credential boundary",
|
|
397
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
398
|
+
"text": "Existing local rules detect service-role credentials in client env or code; an absent finding is not proof that no secret was ever exposed.",
|
|
399
|
+
"evidence": "Run the local check and inspect relevant source files.",
|
|
400
|
+
"sources": [
|
|
401
|
+
"keys"
|
|
402
|
+
],
|
|
403
|
+
"ruleIds": [
|
|
404
|
+
"service_role_key_in_client_env",
|
|
405
|
+
"service_role_key_in_client_code"
|
|
406
|
+
],
|
|
407
|
+
"status": "implemented"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"id": "repo-grant-review",
|
|
411
|
+
"title": "Grants and function privileges",
|
|
412
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
413
|
+
"text": "The audit has checks for Data API grants and SECURITY DEFINER functions. Review the emitted evidence and unsupported cases.",
|
|
414
|
+
"evidence": "Run viberaven audit --vercel-supabase --json; report only checks that actually ran.",
|
|
415
|
+
"sources": [
|
|
416
|
+
"grants",
|
|
417
|
+
"functions"
|
|
418
|
+
],
|
|
419
|
+
"ruleIds": [
|
|
420
|
+
"supabase-data-api-grants",
|
|
421
|
+
"supabase-security-definer-functions"
|
|
422
|
+
],
|
|
423
|
+
"status": "implemented"
|
|
424
|
+
}
|
|
425
|
+
],
|
|
426
|
+
"live-checks": [
|
|
427
|
+
{
|
|
428
|
+
"id": "live-relation-policy",
|
|
429
|
+
"title": "Selected relation and policy metadata",
|
|
430
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
431
|
+
"text": "Planned adapter: selected schemas, relation RLS flags and bounded policy metadata. No application rows, query logs, samples or function execution.",
|
|
432
|
+
"evidence": "Future timestamped, project-bound metadata receipt; not implemented in P1.",
|
|
433
|
+
"sources": [
|
|
434
|
+
"rls",
|
|
435
|
+
"mcp"
|
|
436
|
+
],
|
|
437
|
+
"capability": "supabase-catalog-rls",
|
|
438
|
+
"status": "planned",
|
|
439
|
+
"scope": "catalog-metadata"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"id": "live-grants",
|
|
443
|
+
"title": "Table and function grant metadata",
|
|
444
|
+
"appliesTo": "Supabase projects using the named feature.",
|
|
445
|
+
"text": "Planned adapter: selected relation grants and function identity/EXECUTE/security-mode metadata. Exclude function bodies and customer data.",
|
|
446
|
+
"evidence": "Future allowlisted catalog receipt; missing permissions must remain not_checked.",
|
|
447
|
+
"sources": [
|
|
448
|
+
"grants",
|
|
449
|
+
"functions"
|
|
450
|
+
],
|
|
451
|
+
"capability": "supabase-catalog-grants",
|
|
452
|
+
"status": "planned",
|
|
453
|
+
"scope": "catalog-metadata"
|
|
454
|
+
}
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
// ../providers/index.mjs
|
|
461
|
+
var PROVIDER_TOOL = {
|
|
462
|
+
name: "provider_playbook",
|
|
463
|
+
title: "Get a provider playbook",
|
|
464
|
+
description: `Plan setup and integration before implementing a feature that touches a provider. Returns versioned setup guidance, gotchas, dated changes, integration seams, existing repo checks and planned live checks with official sources. Available packs: ${Object.keys(registry_generated_default).sort().join(", ")}.
|
|
465
|
+
Limits: guidance only; does not connect to providers, read your project, run checks or verify that a feature works.`,
|
|
466
|
+
inputSchema: { type: "object", properties: { provider: { type: "string", minLength: 1, maxLength: 40, pattern: "^[a-z][a-z0-9-]*$", description: "Provider id, for example supabase. Unsupported ids return the available packs." } }, required: ["provider"], additionalProperties: false },
|
|
467
|
+
outputSchema: { type: "object", properties: { provider: { type: "string" }, packVersion: { type: "string" }, packHash: { type: "string" }, pack: { type: "object" }, verification: { type: "object" }, nextStep: { type: "object" } }, required: ["provider", "packVersion", "packHash", "pack", "verification", "nextStep"] },
|
|
468
|
+
annotations: { title: "Get a provider playbook", readOnlyHint: true, destructiveHint: false, openWorldHint: false, idempotentHint: true }
|
|
469
|
+
};
|
|
470
|
+
var listProviders = () => Object.keys(registry_generated_default).sort();
|
|
471
|
+
function renderPlaybook(result) {
|
|
472
|
+
const { pack } = result;
|
|
473
|
+
const lines = [`${pack.displayName} provider playbook ${pack.packVersion} (reviewed ${pack.reviewedAt})`, pack.summary, "Guidance only. Repository and live checks: not checked.", ""];
|
|
474
|
+
for (const section of ["setup", "gotchas", "changes", "seams", "repo-checks", "live-checks"]) {
|
|
475
|
+
lines.push(section.toUpperCase());
|
|
476
|
+
for (const item of pack[section]) {
|
|
477
|
+
lines.push(`- ${item.title}: ${item.text}`, ` Applies: ${item.appliesTo}`, ` Evidence needed: ${item.evidence}`);
|
|
478
|
+
if (item.effectiveOn) lines.push(` Date: ${item.effectiveOn} (${item.status})`);
|
|
479
|
+
if (item.ruleIds) lines.push(` Repo rule IDs: ${item.ruleIds.join(", ")}`);
|
|
480
|
+
if (item.capability) lines.push(` Live capability: ${item.capability} (${item.status})`);
|
|
481
|
+
lines.push(` Sources: ${item.sources.map((id2) => pack.sources.find((source) => source.id === id2).url).join(" ")}`);
|
|
482
|
+
}
|
|
483
|
+
lines.push("");
|
|
484
|
+
}
|
|
485
|
+
lines.push("Limits:", ...pack.limits.map((limit) => `- ${limit}`), result.nextStep.message);
|
|
486
|
+
return lines.join("\n");
|
|
487
|
+
}
|
|
488
|
+
function providerPlaybook(args) {
|
|
489
|
+
if (!args || typeof args !== "object" || Array.isArray(args) || Object.keys(args).some((k) => k !== "provider") || typeof args.provider !== "string" || !/^[a-z][a-z0-9-]{0,39}$/.test(args.provider) || !Object.hasOwn(registry_generated_default, args.provider)) {
|
|
490
|
+
const field = args && typeof args === "object" && !Array.isArray(args) && Object.keys(args).some((k) => k !== "provider") ? "arguments" : "provider";
|
|
491
|
+
return { isError: true, content: [{ type: "text", text: `invalid_input: Choose a supported provider.
|
|
492
|
+
Field: ${field}
|
|
493
|
+
Next step: Select an available pack: ${listProviders().join(", ")}. No connection or check was attempted.
|
|
494
|
+
Example arguments: {"provider":"supabase"}` }] };
|
|
495
|
+
}
|
|
496
|
+
const entry = registry_generated_default[args.provider];
|
|
497
|
+
const pack = JSON.parse(JSON.stringify(entry.pack));
|
|
498
|
+
const structuredContent = {
|
|
499
|
+
provider: pack.provider,
|
|
500
|
+
packVersion: pack.packVersion,
|
|
501
|
+
packHash: entry.hash,
|
|
502
|
+
pack,
|
|
503
|
+
verification: { repo: "not_checked", live: "not_checked" },
|
|
504
|
+
nextStep: { phase: "P2-planned", accountRequiredForLive: true, message: "Use this guidance to plan the requested feature and run relevant local checks. Live connections are not implemented in this candidate; do not claim provider verification. Local guidance and checks need no account." }
|
|
505
|
+
};
|
|
506
|
+
return { isError: false, structuredContent, content: [{ type: "text", text: renderPlaybook(structuredContent) }] };
|
|
507
|
+
}
|
|
508
|
+
|
|
33
509
|
// src/tools/readiness.ts
|
|
34
510
|
var cwdSchema = {
|
|
35
511
|
type: "object",
|
|
@@ -158,6 +634,292 @@ var actionTools = [
|
|
|
158
634
|
}
|
|
159
635
|
];
|
|
160
636
|
|
|
637
|
+
// ../../shared/taskContract.ts
|
|
638
|
+
var TASK_CONTRACT_MAX_BYTES = 4800;
|
|
639
|
+
var condition = { type: "object", properties: {
|
|
640
|
+
id: { type: "string", pattern: "^[a-z][a-z0-9_-]{0,39}$" },
|
|
641
|
+
description: { type: "string", minLength: 1, maxLength: 240, pattern: "\\S" }
|
|
642
|
+
}, required: ["id", "description"], additionalProperties: false };
|
|
643
|
+
var TASK_CONTRACT_SCHEMA = {
|
|
644
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
645
|
+
title: "VibeRaven Task contract v1",
|
|
646
|
+
type: "object",
|
|
647
|
+
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.",
|
|
648
|
+
properties: {
|
|
649
|
+
schemaVersion: { const: 1 },
|
|
650
|
+
status: { type: "string", enum: ["draft", "ready"] },
|
|
651
|
+
request: { type: "string", minLength: 1, maxLength: 1200, pattern: "^\\S(?:[\\s\\S]*\\S)?(?![\\s\\S])" },
|
|
652
|
+
acceptance: { type: "array", items: condition, maxItems: 16, uniqueItems: true },
|
|
653
|
+
mustNotBreak: { type: "array", items: condition, maxItems: 16, uniqueItems: true },
|
|
654
|
+
scope: { type: "object", properties: {
|
|
655
|
+
environment: { type: "string", enum: ["local", "preview", "test-mode"] },
|
|
656
|
+
paths: { type: "array", minItems: 0, maxItems: 16, uniqueItems: true, items: {
|
|
657
|
+
type: "string",
|
|
658
|
+
minLength: 1,
|
|
659
|
+
maxLength: 200,
|
|
660
|
+
pattern: '^(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\\\:*?"<>|\\u0000-\\u001f])(?!/)(?!.*//)(?!.*[. ](?:/|$))[^/]+(?:/[^/]+)*$'
|
|
661
|
+
} },
|
|
662
|
+
providers: { type: "array", maxItems: 8, uniqueItems: true, items: { type: "string", pattern: "^[a-z][a-z0-9-]{0,39}$" } }
|
|
663
|
+
}, required: ["environment", "paths", "providers"], additionalProperties: false }
|
|
664
|
+
},
|
|
665
|
+
required: ["schemaVersion", "status", "request", "acceptance", "mustNotBreak", "scope"],
|
|
666
|
+
additionalProperties: false,
|
|
667
|
+
allOf: [{ if: { properties: { status: { const: "ready" } } }, then: { properties: {
|
|
668
|
+
acceptance: { minItems: 1 },
|
|
669
|
+
scope: { properties: { paths: { minItems: 1 } } }
|
|
670
|
+
} } }]
|
|
671
|
+
};
|
|
672
|
+
function validate(value, schema, path2) {
|
|
673
|
+
const fail = () => {
|
|
674
|
+
throw new Error(`Invalid Task contract at ${path2}.`);
|
|
675
|
+
};
|
|
676
|
+
if ("const" in schema && value !== schema.const) fail();
|
|
677
|
+
if (schema.enum && !schema.enum.includes(value)) fail();
|
|
678
|
+
if (schema.type === "object" && (!value || typeof value !== "object" || Array.isArray(value))) fail();
|
|
679
|
+
if (schema.type === "string" && typeof value !== "string") fail();
|
|
680
|
+
if (schema.type === "array" && !Array.isArray(value)) fail();
|
|
681
|
+
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();
|
|
682
|
+
if (Array.isArray(value)) {
|
|
683
|
+
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();
|
|
684
|
+
value.forEach((item, i) => {
|
|
685
|
+
if (schema.items) validate(item, schema.items, `${path2}[${i}]`);
|
|
686
|
+
});
|
|
687
|
+
} else if (value && typeof value === "object") {
|
|
688
|
+
const object = value;
|
|
689
|
+
for (const key of schema.required ?? []) if (!Object.hasOwn(object, key)) fail();
|
|
690
|
+
for (const key of Object.keys(object)) {
|
|
691
|
+
if (schema.additionalProperties === false && !Object.hasOwn(schema.properties ?? {}, key)) fail();
|
|
692
|
+
if (Object.hasOwn(schema.properties ?? {}, key)) validate(object[key], schema.properties[key], `${path2}.${key}`);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
for (const clause of schema.allOf ?? []) {
|
|
696
|
+
let matches = true;
|
|
697
|
+
try {
|
|
698
|
+
validate(value, clause.if, path2);
|
|
699
|
+
} catch {
|
|
700
|
+
matches = false;
|
|
701
|
+
}
|
|
702
|
+
if (matches) validate(value, clause.then, path2);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function parseTaskContract(raw) {
|
|
706
|
+
const serialized = JSON.stringify(raw);
|
|
707
|
+
if (!serialized || Buffer.byteLength(serialized, "utf8") > TASK_CONTRACT_MAX_BYTES) throw new Error("Task contract exceeds 4800 UTF-8 bytes.");
|
|
708
|
+
validate(raw, TASK_CONTRACT_SCHEMA, "$");
|
|
709
|
+
const contract = JSON.parse(serialized);
|
|
710
|
+
const ids = [...contract.acceptance, ...contract.mustNotBreak].map((c) => c.id);
|
|
711
|
+
if (new Set(ids).size !== ids.length) throw new Error("Task condition IDs must be unique across acceptance and mustNotBreak.");
|
|
712
|
+
if (contract.request.length > 1200) throw new Error("Task request exceeds the account API limit of 1200 characters.");
|
|
713
|
+
return contract;
|
|
714
|
+
}
|
|
715
|
+
function draftTaskContract(request) {
|
|
716
|
+
return parseTaskContract({ schemaVersion: 1, status: "draft", request, acceptance: [], mustNotBreak: [], scope: { environment: "local", paths: [], providers: [] } });
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// ../../shared/verificationPlan.ts
|
|
720
|
+
var VERIFICATION_PLAN_MAX_BYTES = 65536;
|
|
721
|
+
var HTTP_LIMITS = { bodyBytes: 8192, responseBytes: 8192, requestTimeoutMs: 2e3, totalResponseBytes: 32768 };
|
|
722
|
+
var httpMethods = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
|
|
723
|
+
var httpPathPattern = "^/(?!/)(?!.*%(?:0[0-9a-fA-F]|1[0-9a-fA-F]|20|7[fF]|5[cC]))[!-~]*$(?![\\s\\S])";
|
|
724
|
+
var httpHeaderPattern = "^(?:accept|content-type|stripe-signature|x-(?:fixture|test)-[a-z0-9-]{1,40})$(?![\\s\\S])";
|
|
725
|
+
var httpExpected = {
|
|
726
|
+
type: "object",
|
|
727
|
+
properties: { status: { type: "integer", minimum: 200, maximum: 599 }, json: {}, text: { type: "string", maxLength: HTTP_LIMITS.responseBytes } },
|
|
728
|
+
required: ["status"],
|
|
729
|
+
additionalProperties: false,
|
|
730
|
+
oneOf: [{ required: ["json"], not: { required: ["text"] } }, { required: ["text"], not: { required: ["json"] } }],
|
|
731
|
+
allOf: [{ if: { properties: { status: { enum: [204, 205, 304] } } }, then: { required: ["text"], properties: { text: { const: "" } }, not: { required: ["json"] } } }]
|
|
732
|
+
};
|
|
733
|
+
var httpCase = {
|
|
734
|
+
type: "object",
|
|
735
|
+
properties: { request: {
|
|
736
|
+
type: "object",
|
|
737
|
+
properties: {
|
|
738
|
+
method: { enum: httpMethods },
|
|
739
|
+
path: { type: "string", minLength: 1, maxLength: 2048, allOf: [{ pattern: httpPathPattern }, { not: { pattern: "[\\\\#]" } }] },
|
|
740
|
+
headers: { type: "object", maxProperties: 8, propertyNames: { pattern: httpHeaderPattern }, additionalProperties: { type: "string", maxLength: 512, pattern: "^[ -~]*$(?![\\s\\S])" } },
|
|
741
|
+
body: { type: "string", maxLength: HTTP_LIMITS.bodyBytes }
|
|
742
|
+
},
|
|
743
|
+
required: ["method", "path"],
|
|
744
|
+
additionalProperties: false,
|
|
745
|
+
allOf: [{ if: { properties: { method: { enum: ["GET", "HEAD"] } } }, then: { not: { required: ["body"] } } }]
|
|
746
|
+
}, expected: httpExpected },
|
|
747
|
+
required: ["request", "expected"],
|
|
748
|
+
additionalProperties: false,
|
|
749
|
+
allOf: [{ if: { properties: { request: { properties: { method: { const: "HEAD" } } } } }, then: { properties: { expected: { required: ["text"], properties: { text: { const: "" } }, not: { required: ["json"] } } } } }]
|
|
750
|
+
};
|
|
751
|
+
var id = { type: "string", pattern: "^[a-z][a-z0-9_-]{0,39}$" };
|
|
752
|
+
var verificationPathPattern = '^(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\\\:*?"<>|\\u0000-\\u001f])(?!/)(?!.*//)(?!.*[. ](?:/|$))[^/]+(?:/[^/]+)*$';
|
|
753
|
+
var path = { type: "string", minLength: 1, maxLength: 200, pattern: verificationPathPattern };
|
|
754
|
+
var common = { id, conditionId: id };
|
|
755
|
+
var VERIFICATION_PLAN_SCHEMA = {
|
|
756
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
757
|
+
title: "VibeRaven local verification plan v1",
|
|
758
|
+
type: "object",
|
|
759
|
+
properties: { schemaVersion: { const: 1 }, checks: { type: "array", minItems: 1, maxItems: 32, items: { oneOf: [
|
|
760
|
+
{ type: "object", properties: {
|
|
761
|
+
...common,
|
|
762
|
+
adapter: { const: "module" },
|
|
763
|
+
module: path,
|
|
764
|
+
export: { type: "string", pattern: "^[A-Za-z_$][A-Za-z0-9_$]{0,79}$" },
|
|
765
|
+
cases: { type: "array", minItems: 1, maxItems: 32, items: { type: "object", properties: { args: { type: "array", maxItems: 16 }, expected: {} }, required: ["args", "expected"], additionalProperties: false } }
|
|
766
|
+
}, required: ["id", "conditionId", "adapter", "module", "export", "cases"], additionalProperties: false },
|
|
767
|
+
{ 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 },
|
|
768
|
+
{ 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 }
|
|
769
|
+
] } } },
|
|
770
|
+
required: ["schemaVersion", "checks"],
|
|
771
|
+
additionalProperties: false,
|
|
772
|
+
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."
|
|
773
|
+
};
|
|
774
|
+
function validVerificationPath(value) {
|
|
775
|
+
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));
|
|
776
|
+
}
|
|
777
|
+
function frozenVerificationPath(path2) {
|
|
778
|
+
return /^(?:tests?|__tests__)(?:\/|$)|(?:^|\/)[^/]+\.(?:test|spec)\.[^/]+$/i.test(path2);
|
|
779
|
+
}
|
|
780
|
+
function keys(value, required) {
|
|
781
|
+
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.");
|
|
782
|
+
}
|
|
783
|
+
function boundedJson(value, depth = 0) {
|
|
784
|
+
if (depth > 12) throw new Error("Verification JSON exceeds depth 12.");
|
|
785
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return;
|
|
786
|
+
if (typeof value === "number" && Number.isFinite(value)) return;
|
|
787
|
+
if (Array.isArray(value)) {
|
|
788
|
+
if (value.length > 256) throw new Error("Verification JSON array exceeds 256 items.");
|
|
789
|
+
value.forEach((v) => boundedJson(v, depth + 1));
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
793
|
+
if (Object.keys(value).length > 256) throw new Error("Verification JSON object exceeds 256 keys.");
|
|
794
|
+
for (const [k, v] of Object.entries(value)) {
|
|
795
|
+
if (["__proto__", "prototype", "constructor"].includes(k)) throw new Error("Unsafe verification JSON key.");
|
|
796
|
+
boundedJson(v, depth + 1);
|
|
797
|
+
}
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
throw new Error("Verification values must be finite JSON data.");
|
|
801
|
+
}
|
|
802
|
+
function parseVerificationPlan(raw, contract) {
|
|
803
|
+
boundedJson(raw);
|
|
804
|
+
if (Buffer.byteLength(JSON.stringify(raw), "utf8") > VERIFICATION_PLAN_MAX_BYTES) throw new Error("Verification plan exceeds 65536 UTF-8 bytes.");
|
|
805
|
+
keys(raw, ["schemaVersion", "checks"]);
|
|
806
|
+
if (raw.schemaVersion !== 1 || !Array.isArray(raw.checks) || !raw.checks.length || raw.checks.length > 32) throw new Error("Invalid verification plan checks.");
|
|
807
|
+
const seen = /* @__PURE__ */ new Set();
|
|
808
|
+
for (const c of raw.checks) {
|
|
809
|
+
if (!c || typeof c !== "object") throw new Error("Invalid verification check.");
|
|
810
|
+
if (c.adapter === "module" || c.adapter === "http") {
|
|
811
|
+
keys(c, ["id", "conditionId", "adapter", "module", "export", "cases"]);
|
|
812
|
+
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.");
|
|
813
|
+
for (const test of c.cases) {
|
|
814
|
+
if (c.adapter === "module") {
|
|
815
|
+
keys(test, ["args", "expected"]);
|
|
816
|
+
if (!Array.isArray(test.args) || test.args.length > 16) throw new Error("Invalid module arguments.");
|
|
817
|
+
} else validateHttpCase(test);
|
|
818
|
+
}
|
|
819
|
+
} else if (c.adapter === "node-test") {
|
|
820
|
+
keys(c, ["id", "conditionId", "adapter", "entry", "frozenPaths"]);
|
|
821
|
+
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.");
|
|
822
|
+
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.");
|
|
823
|
+
} else throw new Error("Unsupported verification adapter. No shell commands are accepted.");
|
|
824
|
+
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.");
|
|
825
|
+
seen.add(c.id);
|
|
826
|
+
if (contract && ![...contract.acceptance, ...contract.mustNotBreak].some((condition2) => condition2.id === c.conditionId)) throw new Error("Unknown verification condition ID.");
|
|
827
|
+
}
|
|
828
|
+
return JSON.parse(JSON.stringify(raw));
|
|
829
|
+
}
|
|
830
|
+
function validateHttpCase(test) {
|
|
831
|
+
keys(test, ["request", "expected"]);
|
|
832
|
+
const request = test.request, expected = test.expected;
|
|
833
|
+
if (!request || typeof request !== "object" || Array.isArray(request)) throw new Error("Invalid HTTP request.");
|
|
834
|
+
keys(request, ["method", "path", ..."headers" in request ? ["headers"] : [], ..."body" in request ? ["body"] : []]);
|
|
835
|
+
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.");
|
|
836
|
+
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.");
|
|
837
|
+
if ("headers" in request) {
|
|
838
|
+
const headers = request.headers;
|
|
839
|
+
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.");
|
|
840
|
+
}
|
|
841
|
+
if (!expected || typeof expected !== "object" || Array.isArray(expected)) throw new Error("Missing HTTP expectation.");
|
|
842
|
+
const hasJson = Object.hasOwn(expected, "json");
|
|
843
|
+
keys(expected, ["status", hasJson ? "json" : "text"]);
|
|
844
|
+
if (!Number.isInteger(expected.status) || expected.status < 200 || expected.status > 599 || !hasJson && typeof expected.text !== "string") throw new Error("Invalid HTTP expectation.");
|
|
845
|
+
if (Buffer.byteLength(hasJson ? JSON.stringify(expected.json) : expected.text, "utf8") > HTTP_LIMITS.responseBytes) throw new Error("HTTP expected body exceeds byte limit.");
|
|
846
|
+
if ((request.method === "HEAD" || [204, 205, 304].includes(expected.status)) && (hasJson || expected.text !== "")) throw new Error("HTTP response must have an empty text body.");
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// ../../shared/workTools.ts
|
|
850
|
+
var cwd2 = { type: "string", minLength: 1, maxLength: 4096 };
|
|
851
|
+
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}$" };
|
|
852
|
+
var WORK_TOOLS = [
|
|
853
|
+
{
|
|
854
|
+
name: "viberaven_work_start",
|
|
855
|
+
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.",
|
|
856
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, 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 }
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
name: "viberaven_work_resume",
|
|
860
|
+
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.",
|
|
861
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, taskId, contract: TASK_CONTRACT_SCHEMA, approvedContract: { type: "boolean" } }, required: ["taskId"], additionalProperties: false }
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
name: "viberaven_work_status",
|
|
865
|
+
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.",
|
|
866
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, taskId }, required: ["taskId"], additionalProperties: false }
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
name: "viberaven_work_prepare",
|
|
870
|
+
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.",
|
|
871
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, taskId, verification: VERIFICATION_PLAN_SCHEMA }, required: ["taskId", "verification"], additionalProperties: false }
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
name: "viberaven_work_verify",
|
|
875
|
+
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.",
|
|
876
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, taskId, approvedVerification: { type: "boolean" } }, required: ["taskId", "approvedVerification"], additionalProperties: false }
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
name: "viberaven_work_report",
|
|
880
|
+
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.",
|
|
881
|
+
inputSchema: { type: "object", properties: { cwd: cwd2, taskId }, required: ["taskId"], additionalProperties: false }
|
|
882
|
+
}
|
|
883
|
+
];
|
|
884
|
+
var isWorkTool = (name) => WORK_TOOLS.some((tool) => tool.name === name);
|
|
885
|
+
function buildWorkToolArgs(name, raw) {
|
|
886
|
+
const invalid2 = () => {
|
|
887
|
+
throw new Error("Invalid work-tool arguments. Use only the documented Task contract or taskId; no credentials or commands.");
|
|
888
|
+
};
|
|
889
|
+
if (!isWorkTool(name) || !raw || typeof raw !== "object" || Array.isArray(raw)) return invalid2();
|
|
890
|
+
const args = raw;
|
|
891
|
+
const action = name.slice("viberaven_work_".length);
|
|
892
|
+
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"];
|
|
893
|
+
if (Object.keys(args).some((key) => !allowed.includes(key))) return invalid2();
|
|
894
|
+
if (args.cwd !== void 0 && (typeof args.cwd !== "string" || !args.cwd.trim() || args.cwd.length > 4096 || /[\0\r\n]/.test(args.cwd))) return invalid2();
|
|
895
|
+
const out = ["work", action];
|
|
896
|
+
if (action === "start") {
|
|
897
|
+
if (args.contract === void 0 === (args.request === void 0) || !["claude", "codex", "gemini"].includes(args.cli) || !["ask", "approve"].includes(args.access)) return invalid2();
|
|
898
|
+
if (args.request !== void 0) {
|
|
899
|
+
if (typeof args.request !== "string") return invalid2();
|
|
900
|
+
draftTaskContract(args.request);
|
|
901
|
+
out.push("--request-base64", Buffer.from(args.request, "utf8").toString("base64url"));
|
|
902
|
+
}
|
|
903
|
+
out.push("--source", "mcp", "--cli", args.cli, "--access", args.access);
|
|
904
|
+
} else {
|
|
905
|
+
if (typeof args.taskId !== "string" || !new RegExp(taskId.pattern).test(args.taskId)) return invalid2();
|
|
906
|
+
if (args.approvedContract !== void 0 && typeof args.approvedContract !== "boolean") return invalid2();
|
|
907
|
+
out.push("--id", args.taskId);
|
|
908
|
+
if (args.approvedContract === true) out.push("--approve-contract");
|
|
909
|
+
if (action === "prepare") {
|
|
910
|
+
const plan = JSON.stringify(parseVerificationPlan(args.verification));
|
|
911
|
+
if (Buffer.byteLength(plan, "utf8") > 4800) throw new Error("MCP verification transport exceeds 4800 bytes. Use work prepare --verification <file.json>.");
|
|
912
|
+
out.push("--verification-base64", Buffer.from(plan, "utf8").toString("base64url"));
|
|
913
|
+
}
|
|
914
|
+
if (action === "verify") {
|
|
915
|
+
if (typeof args.approvedVerification !== "boolean") return invalid2();
|
|
916
|
+
if (args.approvedVerification) out.push("--approve-verification");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
if (args.contract !== void 0) out.push("--contract-base64", Buffer.from(JSON.stringify(parseTaskContract(args.contract)), "utf8").toString("base64url"));
|
|
920
|
+
return [...out, "--json"];
|
|
921
|
+
}
|
|
922
|
+
|
|
161
923
|
// src/tools/npm.ts
|
|
162
924
|
var npmTools = [
|
|
163
925
|
{
|
|
@@ -176,8 +938,116 @@ var npmTools = [
|
|
|
176
938
|
|
|
177
939
|
// src/lib/cli-runner.ts
|
|
178
940
|
var import_node_child_process = require("node:child_process");
|
|
179
|
-
var
|
|
941
|
+
var import_node_fs3 = require("node:fs");
|
|
942
|
+
var import_node_path2 = require("node:path");
|
|
943
|
+
|
|
944
|
+
// src/lib/work-report-runner.ts
|
|
945
|
+
var import_node_fs2 = require("node:fs");
|
|
946
|
+
var import_node_module = require("node:module");
|
|
180
947
|
var import_node_path = require("node:path");
|
|
948
|
+
|
|
949
|
+
// ../../shared/workReportRunner.ts
|
|
950
|
+
var import_node_fs = require("node:fs");
|
|
951
|
+
var MAX_OUTPUT_BYTES = 65536;
|
|
952
|
+
var REPORT_TIMEOUT_MS = 3e4;
|
|
953
|
+
var workReportFailure = () => {
|
|
954
|
+
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" });
|
|
955
|
+
return { stdout, stderr: "", exitCode: 1, text: `exit 1
|
|
956
|
+
${stdout}` };
|
|
957
|
+
};
|
|
958
|
+
function runWorkReportProcess(entry, args, cwd3, spawnFn2) {
|
|
959
|
+
let canonicalCwd;
|
|
960
|
+
try {
|
|
961
|
+
if (cwd3 !== void 0 && (typeof cwd3 !== "string" || !cwd3.trim())) return Promise.resolve(workReportFailure());
|
|
962
|
+
canonicalCwd = (0, import_node_fs.realpathSync)(cwd3 === void 0 ? process.cwd() : cwd3);
|
|
963
|
+
} catch {
|
|
964
|
+
return Promise.resolve(workReportFailure());
|
|
965
|
+
}
|
|
966
|
+
return new Promise((resolve) => {
|
|
967
|
+
let settled = false, stdoutBytes = 0, stderrBytes = 0;
|
|
968
|
+
const chunks = [];
|
|
969
|
+
let child;
|
|
970
|
+
const finish = (result) => {
|
|
971
|
+
if (!settled) {
|
|
972
|
+
settled = true;
|
|
973
|
+
clearTimeout(timer);
|
|
974
|
+
resolve(result);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
const fail = () => {
|
|
978
|
+
if (settled) return;
|
|
979
|
+
finish(workReportFailure());
|
|
980
|
+
child?.kill();
|
|
981
|
+
};
|
|
982
|
+
const timer = setTimeout(fail, REPORT_TIMEOUT_MS);
|
|
983
|
+
timer.unref();
|
|
984
|
+
try {
|
|
985
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !/^(?:node_|npm_)/i.test(key) && key.toLowerCase() !== "viberaven_cli_path"));
|
|
986
|
+
child = spawnFn2(process.execPath, [entry, ...args], { cwd: canonicalCwd, env, shell: false, windowsHide: true, stdio: ["ignore", "pipe", "pipe"] });
|
|
987
|
+
child.stdout?.on("data", (chunk) => {
|
|
988
|
+
if (settled) return;
|
|
989
|
+
stdoutBytes += chunk.length;
|
|
990
|
+
if (stdoutBytes > MAX_OUTPUT_BYTES - 8) return fail();
|
|
991
|
+
chunks.push(Buffer.from(chunk));
|
|
992
|
+
});
|
|
993
|
+
child.stderr?.on("data", (chunk) => {
|
|
994
|
+
if (settled) return;
|
|
995
|
+
stderrBytes += chunk.length;
|
|
996
|
+
if (stderrBytes > MAX_OUTPUT_BYTES) fail();
|
|
997
|
+
});
|
|
998
|
+
child.on("error", fail);
|
|
999
|
+
child.on("close", (code) => {
|
|
1000
|
+
if (settled) return;
|
|
1001
|
+
try {
|
|
1002
|
+
const stdout = new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks));
|
|
1003
|
+
const report = JSON.parse(stdout);
|
|
1004
|
+
const requestedId = args[args.indexOf("--id") + 1];
|
|
1005
|
+
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());
|
|
1006
|
+
finish({ stdout, stderr: "", exitCode: 0, text: `exit 0
|
|
1007
|
+
${stdout.trim()}` });
|
|
1008
|
+
} catch {
|
|
1009
|
+
finish(workReportFailure());
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
} catch {
|
|
1013
|
+
fail();
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// src/lib/work-report-runner.ts
|
|
1019
|
+
var within = (root, target) => {
|
|
1020
|
+
const rel = (0, import_node_path.relative)(root, target);
|
|
1021
|
+
return !rel || !(0, import_node_path.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(`..${import_node_path.sep}`);
|
|
1022
|
+
};
|
|
1023
|
+
function installedReportCli(version, cwd3) {
|
|
1024
|
+
const override = process.env.VIBERAVEN_CLI_PATH;
|
|
1025
|
+
if (override !== void 0 && !(0, import_node_path.isAbsolute)(override)) throw new Error("Unavailable installed CLI");
|
|
1026
|
+
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");
|
|
1027
|
+
const info = (0, import_node_fs2.lstatSync)(selected);
|
|
1028
|
+
if (!info.isFile() || info.isSymbolicLink()) throw new Error("Unavailable installed CLI");
|
|
1029
|
+
const entry = (0, import_node_fs2.realpathSync)(selected);
|
|
1030
|
+
const root = (0, import_node_fs2.realpathSync)((0, import_node_path.join)((0, import_node_path.dirname)(entry), ".."));
|
|
1031
|
+
if (entry !== (0, import_node_path.join)(root, "dist", "cli.js") || within(cwd3, entry)) throw new Error("Unavailable installed CLI");
|
|
1032
|
+
const manifestPath = (0, import_node_path.join)(root, "package.json"), manifestInfo = (0, import_node_fs2.lstatSync)(manifestPath);
|
|
1033
|
+
if (!manifestInfo.isFile() || manifestInfo.isSymbolicLink() || manifestInfo.size > 65536 || (0, import_node_fs2.realpathSync)(manifestPath) !== manifestPath) throw new Error("Unavailable installed CLI");
|
|
1034
|
+
const manifest = JSON.parse((0, import_node_fs2.readFileSync)(manifestPath, "utf8"));
|
|
1035
|
+
if (manifest.name !== "@viberaven/cli" || manifest.version !== version) throw new Error("Unavailable installed CLI");
|
|
1036
|
+
return entry;
|
|
1037
|
+
}
|
|
1038
|
+
function runInstalledWorkReport(args, cwd3, version, spawnFn2) {
|
|
1039
|
+
let entry, canonicalCwd;
|
|
1040
|
+
try {
|
|
1041
|
+
if (cwd3 !== void 0 && (typeof cwd3 !== "string" || !cwd3.trim())) return Promise.resolve(workReportFailure());
|
|
1042
|
+
canonicalCwd = (0, import_node_fs2.realpathSync)(cwd3 === void 0 ? process.cwd() : cwd3);
|
|
1043
|
+
entry = installedReportCli(version, canonicalCwd);
|
|
1044
|
+
} catch {
|
|
1045
|
+
return Promise.resolve(workReportFailure());
|
|
1046
|
+
}
|
|
1047
|
+
return runWorkReportProcess(entry, args, canonicalCwd, spawnFn2);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// src/lib/cli-runner.ts
|
|
181
1051
|
var CLI_PACKAGE = "@viberaven/cli";
|
|
182
1052
|
var MCP_PACKAGE = "@viberaven/mcp";
|
|
183
1053
|
var PLAIN_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
@@ -185,14 +1055,14 @@ var cachedVersion;
|
|
|
185
1055
|
function mcpVersion() {
|
|
186
1056
|
if (cachedVersion) return cachedVersion;
|
|
187
1057
|
let found;
|
|
188
|
-
for (let dir = __dirname, depth = 0; depth < 4 && !found; depth += 1, dir = (0,
|
|
1058
|
+
for (let dir = __dirname, depth = 0; depth < 4 && !found; depth += 1, dir = (0, import_node_path2.dirname)(dir)) {
|
|
189
1059
|
try {
|
|
190
|
-
const manifest = JSON.parse((0,
|
|
1060
|
+
const manifest = JSON.parse((0, import_node_fs3.readFileSync)((0, import_node_path2.join)(dir, "package.json"), "utf8"));
|
|
191
1061
|
if (manifest.name === MCP_PACKAGE && typeof manifest.version === "string") found = manifest.version;
|
|
192
1062
|
} catch {
|
|
193
1063
|
}
|
|
194
1064
|
}
|
|
195
|
-
found ??= true ? "1.
|
|
1065
|
+
found ??= true ? "1.7.0" : void 0;
|
|
196
1066
|
if (!found || !PLAIN_VERSION.test(found)) {
|
|
197
1067
|
throw new Error(`Could not read a valid ${MCP_PACKAGE} version (got ${JSON.stringify(found)}), so the matching ${CLI_PACKAGE} cannot be pinned.`);
|
|
198
1068
|
}
|
|
@@ -224,11 +1094,11 @@ function safeStringArg(value, label) {
|
|
|
224
1094
|
if (/[&|<>^%!"\r\n]/.test(value)) throw new Error(`Unsafe characters in ${label}`);
|
|
225
1095
|
return value;
|
|
226
1096
|
}
|
|
227
|
-
function resolveCwd(
|
|
228
|
-
if (
|
|
229
|
-
if (typeof
|
|
230
|
-
if (!
|
|
231
|
-
return
|
|
1097
|
+
function resolveCwd(cwd3) {
|
|
1098
|
+
if (cwd3 === void 0 || cwd3 === null) return process.cwd();
|
|
1099
|
+
if (typeof cwd3 !== "string") throw new Error("Invalid cwd: expected string");
|
|
1100
|
+
if (!cwd3.trim()) throw new Error("Invalid cwd: expected non-empty string");
|
|
1101
|
+
return cwd3;
|
|
232
1102
|
}
|
|
233
1103
|
function buildNpxCommand(args) {
|
|
234
1104
|
if (process.platform === "win32") {
|
|
@@ -243,6 +1113,8 @@ function buildHealArgs(prefix, args) {
|
|
|
243
1113
|
return cliArgs;
|
|
244
1114
|
}
|
|
245
1115
|
function buildToolArgs(name, args) {
|
|
1116
|
+
if (isLiveTool(name)) return buildLiveToolArgs(name, args);
|
|
1117
|
+
if (isWorkTool(name)) return buildWorkToolArgs(name, args);
|
|
246
1118
|
switch (name) {
|
|
247
1119
|
case "viberaven_check_readiness":
|
|
248
1120
|
return ["check", "--json"];
|
|
@@ -290,17 +1162,24 @@ function buildToolArgs(name, args) {
|
|
|
290
1162
|
throw new Error(`Unknown VibeRaven tool: ${name}`);
|
|
291
1163
|
}
|
|
292
1164
|
}
|
|
293
|
-
function
|
|
1165
|
+
function runVibeRavenDetailed(args, cwd3) {
|
|
1166
|
+
if (args[0] === "work" && args[1] === "report") {
|
|
1167
|
+
try {
|
|
1168
|
+
return runInstalledWorkReport(args, cwd3, mcpVersion(), spawnFn);
|
|
1169
|
+
} catch {
|
|
1170
|
+
return Promise.resolve(workReportFailure());
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
294
1173
|
let npxArgs;
|
|
295
1174
|
try {
|
|
296
1175
|
npxArgs = cliNpxArgs(args);
|
|
297
1176
|
} catch (error) {
|
|
298
|
-
return Promise.resolve(`ERROR: ${error instanceof Error ? error.message : String(error)}`);
|
|
1177
|
+
return Promise.resolve({ stdout: "", stderr: "", exitCode: 1, text: `ERROR: ${error instanceof Error ? error.message : String(error)}` });
|
|
299
1178
|
}
|
|
300
1179
|
return new Promise((resolve) => {
|
|
301
1180
|
const built = buildNpxCommand(npxArgs);
|
|
302
1181
|
const child = spawnFn(built.command, built.args, {
|
|
303
|
-
cwd: resolveCwd(
|
|
1182
|
+
cwd: resolveCwd(cwd3),
|
|
304
1183
|
env: cliChildEnv(),
|
|
305
1184
|
shell: built.shell,
|
|
306
1185
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -313,11 +1192,11 @@ function runVibeRaven(args, cwd) {
|
|
|
313
1192
|
child.stderr?.on("data", (chunk) => {
|
|
314
1193
|
stderr += chunk.toString();
|
|
315
1194
|
});
|
|
316
|
-
child.on("error", (error) => resolve(`ERROR: ${error.message}`));
|
|
1195
|
+
child.on("error", (error) => resolve({ stdout: "", stderr, exitCode: 1, text: `ERROR: ${error.message}` }));
|
|
317
1196
|
child.on("close", (code) => {
|
|
318
1197
|
const combined = `${stdout}${stderr}`.trim();
|
|
319
|
-
resolve(`exit ${code ?? 1}${combined ? `
|
|
320
|
-
${combined}` : ""}`);
|
|
1198
|
+
resolve({ stdout, stderr, exitCode: code ?? 1, text: `exit ${code ?? 1}${combined ? `
|
|
1199
|
+
${combined}` : ""}` });
|
|
321
1200
|
});
|
|
322
1201
|
});
|
|
323
1202
|
}
|
|
@@ -334,7 +1213,10 @@ var ALL_TOOLS = [
|
|
|
334
1213
|
contextMap,
|
|
335
1214
|
...actionTools,
|
|
336
1215
|
...healTools,
|
|
337
|
-
...npmTools
|
|
1216
|
+
...npmTools,
|
|
1217
|
+
...WORK_TOOLS,
|
|
1218
|
+
PROVIDER_TOOL,
|
|
1219
|
+
...LIVE_TOOLS
|
|
338
1220
|
];
|
|
339
1221
|
function parseJsonObjectFromToolText(text) {
|
|
340
1222
|
const start = text.indexOf("{");
|
|
@@ -345,16 +1227,16 @@ function parseJsonObjectFromToolText(text) {
|
|
|
345
1227
|
return void 0;
|
|
346
1228
|
}
|
|
347
1229
|
}
|
|
348
|
-
async function callTool(name, args) {
|
|
349
|
-
return runVibeRaven(buildToolArgs(name, args || {}), args?.cwd);
|
|
350
|
-
}
|
|
351
1230
|
async function handleRequest(method, params) {
|
|
352
1231
|
if (method === "tools/list") return { tools: ALL_TOOLS };
|
|
353
1232
|
if (method === "tools/call") {
|
|
354
|
-
|
|
355
|
-
const
|
|
1233
|
+
if (params.name === "provider_playbook") return providerPlaybook(params.arguments);
|
|
1234
|
+
const args = params.arguments || {};
|
|
1235
|
+
const { text, stdout, exitCode } = await runVibeRavenDetailed(buildToolArgs(params.name, args), args.cwd);
|
|
1236
|
+
const parsed = parseJsonObjectFromToolText(stdout);
|
|
356
1237
|
return {
|
|
357
1238
|
content: [{ type: "text", text }],
|
|
1239
|
+
...params.name.startsWith("viberaven_work_") && exitCode !== 0 || isLiveTool(params.name) && isLiveToolFailure(exitCode, parsed) ? { isError: true } : {},
|
|
358
1240
|
...parsed ? { structuredContent: parsed } : {}
|
|
359
1241
|
};
|
|
360
1242
|
}
|
|
@@ -362,14 +1244,15 @@ async function handleRequest(method, params) {
|
|
|
362
1244
|
}
|
|
363
1245
|
|
|
364
1246
|
// src/server.ts
|
|
365
|
-
var SERVER_INFO = { name: "viberaven-mcp", version: "1.
|
|
1247
|
+
var SERVER_INFO = { name: "viberaven-mcp", version: "1.7.0" };
|
|
366
1248
|
var INSTRUCTIONS = [
|
|
367
1249
|
"VibeRaven reads a repository and lists launch gaps for AI-built apps that deploy on Vercel and use Supabase.",
|
|
368
1250
|
"Suggest one viberaven_check_readiness run before such an app launches or is handed off, after a Supabase migration or policy change,",
|
|
369
1251
|
"or when the user pastes a production error about RLS, env vars, the database connection, the service role key or a Stripe webhook.",
|
|
370
1252
|
"This is advice, not a gate: the user decides when to ship.",
|
|
371
1253
|
"It is a repository check, not a live database test. It cannot show which RLS policies are live in production, and a clear result is not a security audit.",
|
|
372
|
-
"
|
|
1254
|
+
"The existing repository checks are scoped to Vercel and Supabase; they do not cover every provider.",
|
|
1255
|
+
"For feature planning, provider_playbook returns versioned provider knowledge independently of hosting. Read the supported pack and its limits; retrieval does not execute checks or connect to providers.",
|
|
373
1256
|
"After fixes, call viberaven_verify once per batch, not after every edit."
|
|
374
1257
|
].join(" ");
|
|
375
1258
|
var server = new import_server.Server(SERVER_INFO, { capabilities: { tools: {} }, instructions: INSTRUCTIONS });
|