@vibegrid/mcp 0.4.0-beta.1 → 0.4.0-beta.3
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/dist/index.js +107 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -237,7 +237,8 @@ function createSchema() {
|
|
|
237
237
|
remote_host_label TEXT,
|
|
238
238
|
hook_session_id TEXT,
|
|
239
239
|
status_source TEXT,
|
|
240
|
-
saved_at INTEGER
|
|
240
|
+
saved_at INTEGER,
|
|
241
|
+
sort_order INTEGER NOT NULL DEFAULT 0
|
|
241
242
|
);
|
|
242
243
|
|
|
243
244
|
CREATE TABLE IF NOT EXISTS schedule_log (
|
|
@@ -317,8 +318,20 @@ function createSchema() {
|
|
|
317
318
|
|
|
318
319
|
CREATE INDEX IF NOT EXISTS idx_session_logs_task ON session_logs(task_id);
|
|
319
320
|
CREATE INDEX IF NOT EXISTS idx_session_logs_session ON session_logs(session_id);
|
|
321
|
+
|
|
322
|
+
CREATE TABLE IF NOT EXISTS session_events (
|
|
323
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
324
|
+
session_id TEXT NOT NULL,
|
|
325
|
+
event_type TEXT NOT NULL,
|
|
326
|
+
timestamp TEXT NOT NULL,
|
|
327
|
+
metadata TEXT
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
CREATE INDEX IF NOT EXISTS idx_session_events_session ON session_events(session_id, timestamp DESC);
|
|
331
|
+
CREATE INDEX IF NOT EXISTS idx_session_events_type ON session_events(event_type, timestamp DESC);
|
|
320
332
|
`);
|
|
321
333
|
migrateSchema(d);
|
|
334
|
+
verifySchema(d);
|
|
322
335
|
}
|
|
323
336
|
function migrateSchema(d) {
|
|
324
337
|
const row = d.prepare("SELECT value FROM schema_meta WHERE key = 'schema_version'").get();
|
|
@@ -376,6 +389,62 @@ function migrateSchema(d) {
|
|
|
376
389
|
})();
|
|
377
390
|
logger_default.info("[database] migrated schema to version 2 (ssh credential vault)");
|
|
378
391
|
}
|
|
392
|
+
if (version < 3) {
|
|
393
|
+
d.transaction(() => {
|
|
394
|
+
const sessionCols = d.prepare("PRAGMA table_info(sessions)").all();
|
|
395
|
+
if (!sessionCols.some((c) => c.name === "sort_order")) {
|
|
396
|
+
d.exec("ALTER TABLE sessions ADD COLUMN sort_order INTEGER NOT NULL DEFAULT 0");
|
|
397
|
+
}
|
|
398
|
+
d.prepare(
|
|
399
|
+
"INSERT OR REPLACE INTO schema_meta (key, value) VALUES ('schema_version', '3')"
|
|
400
|
+
).run();
|
|
401
|
+
})();
|
|
402
|
+
logger_default.info("[database] migrated schema to version 3 (session sort order)");
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function verifySchema(d) {
|
|
406
|
+
const expectedByTable = {
|
|
407
|
+
projects: [
|
|
408
|
+
{
|
|
409
|
+
column: "workspace_id",
|
|
410
|
+
ddl: "ALTER TABLE projects ADD COLUMN workspace_id TEXT NOT NULL DEFAULT 'personal'"
|
|
411
|
+
}
|
|
412
|
+
],
|
|
413
|
+
workflows: [
|
|
414
|
+
{
|
|
415
|
+
column: "workspace_id",
|
|
416
|
+
ddl: "ALTER TABLE workflows ADD COLUMN workspace_id TEXT NOT NULL DEFAULT 'personal'"
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
remote_hosts: [
|
|
420
|
+
{ column: "auth_method", ddl: "ALTER TABLE remote_hosts ADD COLUMN auth_method TEXT" },
|
|
421
|
+
{ column: "credential_id", ddl: "ALTER TABLE remote_hosts ADD COLUMN credential_id TEXT" },
|
|
422
|
+
{
|
|
423
|
+
column: "encrypted_password",
|
|
424
|
+
ddl: "ALTER TABLE remote_hosts ADD COLUMN encrypted_password TEXT"
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
sessions: [
|
|
428
|
+
{
|
|
429
|
+
column: "sort_order",
|
|
430
|
+
ddl: "ALTER TABLE sessions ADD COLUMN sort_order INTEGER NOT NULL DEFAULT 0"
|
|
431
|
+
}
|
|
432
|
+
]
|
|
433
|
+
};
|
|
434
|
+
for (const [table, columns] of Object.entries(expectedByTable)) {
|
|
435
|
+
const existing = new Set(
|
|
436
|
+
d.prepare(`PRAGMA table_info(${table})`).all().map((c) => c.name)
|
|
437
|
+
);
|
|
438
|
+
for (const { column, ddl } of columns) {
|
|
439
|
+
if (existing.has(column)) continue;
|
|
440
|
+
try {
|
|
441
|
+
d.exec(ddl);
|
|
442
|
+
logger_default.warn(`[database] self-heal: added missing column ${table}.${column}`);
|
|
443
|
+
} catch (err) {
|
|
444
|
+
logger_default.error(`[database] self-heal: failed to add ${table}.${column}:`, err);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
379
448
|
}
|
|
380
449
|
function loadConfig() {
|
|
381
450
|
const d = getDb();
|
|
@@ -1776,6 +1845,42 @@ function registerSessionTools(server) {
|
|
|
1776
1845
|
}
|
|
1777
1846
|
}
|
|
1778
1847
|
);
|
|
1848
|
+
server.tool(
|
|
1849
|
+
"list_session_events",
|
|
1850
|
+
"List session lifecycle events (created, exited, task_linked, renamed, archived, unarchived). Use for post-mortem analysis and multi-agent coordination.",
|
|
1851
|
+
{
|
|
1852
|
+
session_id: V.id.optional().describe("Filter by session ID"),
|
|
1853
|
+
event_type: z4.enum(["created", "exited", "task_linked", "renamed", "archived", "unarchived"]).optional().describe("Filter by event type"),
|
|
1854
|
+
limit: z4.number().int().min(1).max(200).optional().describe("Max events to return (default: 50)")
|
|
1855
|
+
},
|
|
1856
|
+
async (args) => {
|
|
1857
|
+
try {
|
|
1858
|
+
let events;
|
|
1859
|
+
if (args.session_id) {
|
|
1860
|
+
events = await rpcCall("sessionEvent:listBySession", {
|
|
1861
|
+
sessionId: args.session_id,
|
|
1862
|
+
limit: args.limit ?? 50
|
|
1863
|
+
});
|
|
1864
|
+
} else {
|
|
1865
|
+
events = await rpcCall("sessionEvent:list", {
|
|
1866
|
+
eventType: args.event_type,
|
|
1867
|
+
limit: args.limit ?? 50
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
return { content: [{ type: "text", text: JSON.stringify(events, null, 2) }] };
|
|
1871
|
+
} catch (err) {
|
|
1872
|
+
return {
|
|
1873
|
+
content: [
|
|
1874
|
+
{
|
|
1875
|
+
type: "text",
|
|
1876
|
+
text: `Error listing session events: ${err instanceof Error ? err.message : err}`
|
|
1877
|
+
}
|
|
1878
|
+
],
|
|
1879
|
+
isError: true
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
);
|
|
1779
1884
|
}
|
|
1780
1885
|
|
|
1781
1886
|
// src/tools/workflows.ts
|
|
@@ -2155,7 +2260,7 @@ console.warn = (...args) => _origError("[mcp:warn]", ...args);
|
|
|
2155
2260
|
console.error = (...args) => _origError("[mcp:error]", ...args);
|
|
2156
2261
|
async function main() {
|
|
2157
2262
|
configManager.init();
|
|
2158
|
-
const version = true ? "0.4.0-beta.
|
|
2263
|
+
const version = true ? "0.4.0-beta.3" : createRequire(import.meta.url)("../package.json").version;
|
|
2159
2264
|
const server = createMcpServer(version);
|
|
2160
2265
|
const transport = new StdioServerTransport();
|
|
2161
2266
|
await server.connect(transport);
|