@a5c-ai/babysitter-sdk 0.0.181-staging.c883dba5 → 0.0.181-staging.e06e9e2d
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/cli/commands/mcpServe.d.ts +9 -0
- package/dist/cli/commands/mcpServe.d.ts.map +1 -0
- package/dist/cli/commands/mcpServe.js +31 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +8 -2
- package/dist/cli/mcpServeEntry.d.ts +3 -0
- package/dist/cli/mcpServeEntry.d.ts.map +1 -0
- package/dist/cli/mcpServeEntry.js +8 -0
- package/dist/harness/claudeCode.d.ts.map +1 -1
- package/dist/harness/claudeCode.js +2 -1
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +50 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +21 -0
- package/dist/mcp/tools/discovery.d.ts +3 -0
- package/dist/mcp/tools/discovery.d.ts.map +1 -0
- package/dist/mcp/tools/discovery.js +113 -0
- package/dist/mcp/tools/runs.d.ts +3 -0
- package/dist/mcp/tools/runs.d.ts.map +1 -0
- package/dist/mcp/tools/runs.js +273 -0
- package/dist/mcp/tools/sessions.d.ts +3 -0
- package/dist/mcp/tools/sessions.d.ts.map +1 -0
- package/dist/mcp/tools/sessions.js +219 -0
- package/dist/mcp/tools/tasks.d.ts +3 -0
- package/dist/mcp/tools/tasks.d.ts.map +1 -0
- package/dist/mcp/tools/tasks.js +230 -0
- package/dist/mcp/util/errors.d.ts +14 -0
- package/dist/mcp/util/errors.d.ts.map +1 -0
- package/dist/mcp/util/errors.js +10 -0
- package/dist/mcp/util/resolve-run-dir.d.ts +6 -0
- package/dist/mcp/util/resolve-run-dir.d.ts.map +1 -0
- package/dist/mcp/util/resolve-run-dir.js +47 -0
- package/dist/runtime/intrinsics/task.d.ts.map +1 -1
- package/dist/runtime/intrinsics/task.js +2 -1
- package/dist/runtime/replay/effectIndex.d.ts.map +1 -1
- package/dist/runtime/replay/effectIndex.js +4 -3
- package/package.json +4 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcp:serve command - Launch the babysitter MCP server on stdio transport.
|
|
3
|
+
*
|
|
4
|
+
* stdout is reserved for MCP protocol messages; all logging goes to stderr.
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleMcpServe(args: {
|
|
7
|
+
json: boolean;
|
|
8
|
+
}): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=mcpServe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpServe.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcpServe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B7E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* mcp:serve command - Launch the babysitter MCP server on stdio transport.
|
|
4
|
+
*
|
|
5
|
+
* stdout is reserved for MCP protocol messages; all logging goes to stderr.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.handleMcpServe = handleMcpServe;
|
|
9
|
+
const mcp_1 = require("../../mcp");
|
|
10
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
11
|
+
async function handleMcpServe(args) {
|
|
12
|
+
const server = (0, mcp_1.createBabysitterMcpServer)();
|
|
13
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
14
|
+
await server.connect(transport);
|
|
15
|
+
process.stderr.write(args.json
|
|
16
|
+
? JSON.stringify({ status: "running", transport: "stdio" }) + "\n"
|
|
17
|
+
: "Babysitter MCP server running on stdio\n");
|
|
18
|
+
// Graceful shutdown on SIGINT / SIGTERM
|
|
19
|
+
const shutdown = async () => {
|
|
20
|
+
process.stderr.write("Shutting down MCP server...\n");
|
|
21
|
+
await server.close();
|
|
22
|
+
process.exit(0);
|
|
23
|
+
};
|
|
24
|
+
process.on("SIGINT", () => void shutdown());
|
|
25
|
+
process.on("SIGTERM", () => void shutdown());
|
|
26
|
+
// Keep the process alive — the transport manages its own I/O loop.
|
|
27
|
+
// Return a code that the CLI runner will never actually see (we exit via signal).
|
|
28
|
+
return await new Promise(() => {
|
|
29
|
+
// intentionally never resolves
|
|
30
|
+
});
|
|
31
|
+
}
|
package/dist/cli/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;AAqiB/G;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BlE;AAOD,2EAA2E;AAC3E,QAAA,MAAM,sBAAsB,sCAAgC,CAAC;AA0+C7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBAgRpD,MAAM;EAIvB"}
|
package/dist/cli/main.js
CHANGED
|
@@ -56,6 +56,7 @@ const health_1 = require("./commands/health");
|
|
|
56
56
|
const configure_1 = require("./commands/configure");
|
|
57
57
|
const session_1 = require("./commands/session");
|
|
58
58
|
const skill_1 = require("./commands/skill");
|
|
59
|
+
const mcpServe_1 = require("./commands/mcpServe");
|
|
59
60
|
const hookLog_1 = require("./commands/hookLog");
|
|
60
61
|
const hookRun_1 = require("./commands/hookRun");
|
|
61
62
|
const profile_1 = require("./commands/profile");
|
|
@@ -101,6 +102,7 @@ const USAGE = `Usage:
|
|
|
101
102
|
babysitter plugin:update-marketplace --marketplace-name <name> [--marketplace-branch <ref>] [--global|--project] [--json] [--verbose]
|
|
102
103
|
babysitter plugin:update-registry [<pluginName>] [--plugin-name <name>] [--plugin-version <ver>] [--global|--project] [--json] [--verbose]
|
|
103
104
|
babysitter plugin:remove-from-registry [<pluginName>] [--plugin-name <name>] [--global|--project] [--json] [--verbose]
|
|
105
|
+
babysitter mcp:serve [--json]
|
|
104
106
|
babysitter health [--json] [--verbose]
|
|
105
107
|
babysitter configure [show|validate|paths] [--json] [--defaults-only]
|
|
106
108
|
babysitter version
|
|
@@ -644,7 +646,7 @@ function resolveArtifactAbsolutePath(runDir, ref) {
|
|
|
644
646
|
});
|
|
645
647
|
return candidates[0].absolute;
|
|
646
648
|
}
|
|
647
|
-
return path.join(absoluteRunDir, normalized);
|
|
649
|
+
return collapseDoubledA5cRuns(path.join(absoluteRunDir, normalized));
|
|
648
650
|
}
|
|
649
651
|
function collectArtifactCandidates(runDir, ref) {
|
|
650
652
|
const seen = new Map();
|
|
@@ -654,7 +656,7 @@ function collectArtifactCandidates(runDir, ref) {
|
|
|
654
656
|
const outsideRun = relative.startsWith("..");
|
|
655
657
|
seen.set(normalizedAbs, { absolute: normalizedAbs, relative, outsideRun });
|
|
656
658
|
};
|
|
657
|
-
pushCandidate(path.join(runDir, ref));
|
|
659
|
+
pushCandidate(collapseDoubledA5cRuns(path.join(runDir, ref)));
|
|
658
660
|
pushCandidate(path.resolve(ref));
|
|
659
661
|
return Array.from(seen.values());
|
|
660
662
|
}
|
|
@@ -1823,6 +1825,7 @@ const VALID_COMMANDS = [
|
|
|
1823
1825
|
"plugin:update-marketplace",
|
|
1824
1826
|
"plugin:update-registry",
|
|
1825
1827
|
"plugin:remove-from-registry",
|
|
1828
|
+
"mcp:serve",
|
|
1826
1829
|
"health",
|
|
1827
1830
|
"configure",
|
|
1828
1831
|
"version",
|
|
@@ -2132,6 +2135,9 @@ function createBabysitterCli() {
|
|
|
2132
2135
|
return await (0, plugin_1.handlePluginRemoveFromRegistry)(pluginArgs);
|
|
2133
2136
|
}
|
|
2134
2137
|
}
|
|
2138
|
+
if (parsed.command === "mcp:serve") {
|
|
2139
|
+
return await (0, mcpServe_1.handleMcpServe)({ json: parsed.json });
|
|
2140
|
+
}
|
|
2135
2141
|
if (parsed.command === "health") {
|
|
2136
2142
|
return await (0, health_1.handleHealthCommand)({
|
|
2137
2143
|
json: parsed.json,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpServeEntry.d.ts","sourceRoot":"","sources":["../../src/cli/mcpServeEntry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const mcpServe_1 = require("./commands/mcpServe");
|
|
5
|
+
(0, mcpServe_1.handleMcpServe)({ json: false }).catch((err) => {
|
|
6
|
+
process.stderr.write(`Fatal: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
7
|
+
process.exit(1);
|
|
8
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeCode.d.ts","sourceRoot":"","sources":["../../src/harness/claudeCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"claudeCode.d.ts","sourceRoot":"","sources":["../../src/harness/claudeCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2BH,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;AA8xBjB,wBAAgB,uBAAuB,IAAI,cAAc,CA4DxD"}
|
|
@@ -52,6 +52,7 @@ const journal_1 = require("../storage/journal");
|
|
|
52
52
|
const runFiles_1 = require("../storage/runFiles");
|
|
53
53
|
const effectIndex_1 = require("../runtime/replay/effectIndex");
|
|
54
54
|
const completionProof_1 = require("../cli/completionProof");
|
|
55
|
+
const resolveInputPath_1 = require("../cli/resolveInputPath");
|
|
55
56
|
const skill_1 = require("../cli/commands/skill");
|
|
56
57
|
const session_1 = require("../session");
|
|
57
58
|
const session_2 = require("../cli/commands/session");
|
|
@@ -210,7 +211,7 @@ async function handleStopHookImpl(args) {
|
|
|
210
211
|
}
|
|
211
212
|
log.info(`Resolved pluginRoot: ${resolvedPluginRoot || "(empty)"}`);
|
|
212
213
|
log.info(`Resolved stateDir: ${stateDir}`);
|
|
213
|
-
const runsDir = args.runsDir || ".a5c/runs";
|
|
214
|
+
const runsDir = (0, resolveInputPath_1.collapseDoubledA5cRuns)(path.resolve(args.runsDir || ".a5c/runs"));
|
|
214
215
|
// 3. Check iteration — try primary stateDir, then fallback to .a5c/state/
|
|
215
216
|
let filePath = (0, session_1.getSessionFilePath)(stateDir, sessionId);
|
|
216
217
|
log.info(`Checking session file at: ${filePath}`);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createBabysitterMcpServer } from "./server";
|
|
2
|
+
/**
|
|
3
|
+
* Start the MCP server on stdio transport.
|
|
4
|
+
* This is the main entry point for running the babysitter MCP server.
|
|
5
|
+
*/
|
|
6
|
+
export declare function startStdioServer(): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAErD;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKtD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createBabysitterMcpServer = void 0;
|
|
37
|
+
exports.startStdioServer = startStdioServer;
|
|
38
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
39
|
+
var server_1 = require("./server");
|
|
40
|
+
Object.defineProperty(exports, "createBabysitterMcpServer", { enumerable: true, get: function () { return server_1.createBabysitterMcpServer; } });
|
|
41
|
+
/**
|
|
42
|
+
* Start the MCP server on stdio transport.
|
|
43
|
+
* This is the main entry point for running the babysitter MCP server.
|
|
44
|
+
*/
|
|
45
|
+
async function startStdioServer() {
|
|
46
|
+
const { createBabysitterMcpServer } = await Promise.resolve().then(() => __importStar(require("./server")));
|
|
47
|
+
const server = createBabysitterMcpServer();
|
|
48
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
49
|
+
await server.connect(transport);
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASpE,wBAAgB,yBAAyB,IAAI,SAAS,CAUrD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBabysitterMcpServer = createBabysitterMcpServer;
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const runs_1 = require("./tools/runs");
|
|
6
|
+
const tasks_1 = require("./tools/tasks");
|
|
7
|
+
const sessions_1 = require("./tools/sessions");
|
|
8
|
+
const discovery_1 = require("./tools/discovery");
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const pkg = require("../../package.json");
|
|
11
|
+
function createBabysitterMcpServer() {
|
|
12
|
+
const server = new mcp_js_1.McpServer({
|
|
13
|
+
name: "babysitter",
|
|
14
|
+
version: pkg.version
|
|
15
|
+
});
|
|
16
|
+
(0, runs_1.registerRunTools)(server);
|
|
17
|
+
(0, tasks_1.registerTaskTools)(server);
|
|
18
|
+
(0, sessions_1.registerSessionTools)(server);
|
|
19
|
+
(0, discovery_1.registerDiscoveryTools)(server);
|
|
20
|
+
return server;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/discovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAwF9D"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.registerDiscoveryTools = registerDiscoveryTools;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const zod_1 = require("zod");
|
|
39
|
+
const health_1 = require("../../cli/commands/health");
|
|
40
|
+
const configure_1 = require("../../cli/commands/configure");
|
|
41
|
+
const skill_1 = require("../../cli/commands/skill");
|
|
42
|
+
const errors_1 = require("../util/errors");
|
|
43
|
+
function registerDiscoveryTools(server) {
|
|
44
|
+
// ── skill_discover ──────────────────────────────────────────────────
|
|
45
|
+
server.tool("skill_discover", "Discover available skills, agents, and process definitions", {
|
|
46
|
+
pluginRoot: zod_1.z
|
|
47
|
+
.string()
|
|
48
|
+
.describe("Plugin root directory to scan for skills"),
|
|
49
|
+
runId: zod_1.z
|
|
50
|
+
.string()
|
|
51
|
+
.optional()
|
|
52
|
+
.describe("Run ID for domain-scoped discovery"),
|
|
53
|
+
runsDir: zod_1.z.string().optional().describe("Override runs directory path"),
|
|
54
|
+
includeRemote: zod_1.z
|
|
55
|
+
.boolean()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe("Include remote skill sources"),
|
|
58
|
+
processPath: zod_1.z
|
|
59
|
+
.string()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("Process file path for specialization scoping"),
|
|
62
|
+
}, async (args) => {
|
|
63
|
+
try {
|
|
64
|
+
const pluginRoot = path.resolve(args.pluginRoot);
|
|
65
|
+
const result = await (0, skill_1.discoverSkillsInternal)({
|
|
66
|
+
pluginRoot,
|
|
67
|
+
runId: args.runId,
|
|
68
|
+
runsDir: args.runsDir,
|
|
69
|
+
includeRemote: args.includeRemote,
|
|
70
|
+
processPath: args.processPath,
|
|
71
|
+
includeProcesses: true,
|
|
72
|
+
});
|
|
73
|
+
return (0, errors_1.toolResult)({
|
|
74
|
+
skills: result.skills,
|
|
75
|
+
agents: result.agents,
|
|
76
|
+
processes: result.processes,
|
|
77
|
+
summary: result.summary,
|
|
78
|
+
cached: result.cached,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
// ── health ──────────────────────────────────────────────────────────
|
|
86
|
+
server.tool("health", "Check the health and configuration status of the babysitter installation", {}, async () => {
|
|
87
|
+
try {
|
|
88
|
+
const result = await (0, health_1.runHealthCheck)({ json: true });
|
|
89
|
+
return (0, errors_1.toolResult)({
|
|
90
|
+
status: result.status,
|
|
91
|
+
summary: result.summary,
|
|
92
|
+
checks: result.checks,
|
|
93
|
+
nextSteps: result.nextSteps,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// ── configure_show ──────────────────────────────────────────────────
|
|
101
|
+
server.tool("configure_show", "Show current babysitter configuration and environment", {}, () => {
|
|
102
|
+
try {
|
|
103
|
+
const result = (0, configure_1.configureShow)({});
|
|
104
|
+
return (0, errors_1.toolResult)({
|
|
105
|
+
values: result.values,
|
|
106
|
+
timestamp: result.timestamp,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/runs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAuFpE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiNxD"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.registerRunTools = registerRunTools;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const zod_1 = require("zod");
|
|
39
|
+
const runtime_1 = require("../../runtime");
|
|
40
|
+
const storage_1 = require("../../storage");
|
|
41
|
+
const stateCache_1 = require("../../runtime/replay/stateCache");
|
|
42
|
+
const errors_1 = require("../util/errors");
|
|
43
|
+
const resolve_run_dir_1 = require("../util/resolve-run-dir");
|
|
44
|
+
/**
|
|
45
|
+
* Parse an entrypoint specifier like "path/to/file.js#exportName" into its parts.
|
|
46
|
+
*/
|
|
47
|
+
function parseEntrypoint(entrypoint) {
|
|
48
|
+
const hashIndex = entrypoint.lastIndexOf("#");
|
|
49
|
+
if (hashIndex <= 0) {
|
|
50
|
+
return { importPath: entrypoint };
|
|
51
|
+
}
|
|
52
|
+
const importPath = entrypoint.slice(0, hashIndex);
|
|
53
|
+
const exportName = entrypoint.slice(hashIndex + 1) || undefined;
|
|
54
|
+
return { importPath, exportName };
|
|
55
|
+
}
|
|
56
|
+
const RUN_LIFECYCLE_TYPES = new Set(["RUN_CREATED", "RUN_COMPLETED", "RUN_FAILED"]);
|
|
57
|
+
function findLastLifecycleEvent(events) {
|
|
58
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
59
|
+
if (RUN_LIFECYCLE_TYPES.has(events[i].type)) {
|
|
60
|
+
return events[i];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function deriveRunState(lastLifecycleEventType, pendingCount) {
|
|
66
|
+
if (lastLifecycleEventType === "RUN_COMPLETED")
|
|
67
|
+
return "completed";
|
|
68
|
+
if (lastLifecycleEventType === "RUN_FAILED")
|
|
69
|
+
return "failed";
|
|
70
|
+
if (pendingCount > 0)
|
|
71
|
+
return "waiting";
|
|
72
|
+
return "created";
|
|
73
|
+
}
|
|
74
|
+
function countPendingEffects(events) {
|
|
75
|
+
const requested = new Map();
|
|
76
|
+
const resolved = new Set();
|
|
77
|
+
for (const event of events) {
|
|
78
|
+
if (event.type === "EFFECT_REQUESTED") {
|
|
79
|
+
const data = event.data;
|
|
80
|
+
if (data.effectId) {
|
|
81
|
+
requested.set(data.effectId, {
|
|
82
|
+
effectId: data.effectId,
|
|
83
|
+
kind: data.kind ?? "unknown",
|
|
84
|
+
label: data.label,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (event.type === "EFFECT_RESOLVED") {
|
|
89
|
+
const data = event.data;
|
|
90
|
+
if (data.effectId) {
|
|
91
|
+
resolved.add(data.effectId);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const pendingEffects = [];
|
|
96
|
+
const pendingByKind = {};
|
|
97
|
+
for (const [effectId, info] of requested) {
|
|
98
|
+
if (!resolved.has(effectId)) {
|
|
99
|
+
pendingEffects.push(info);
|
|
100
|
+
pendingByKind[info.kind] = (pendingByKind[info.kind] ?? 0) + 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { pendingEffects, pendingByKind };
|
|
104
|
+
}
|
|
105
|
+
function registerRunTools(server) {
|
|
106
|
+
// ── run_create ──────────────────────────────────────────────────────
|
|
107
|
+
server.tool("run_create", "Create a new babysitter run for a given process definition", {
|
|
108
|
+
processId: zod_1.z.string().describe("The process identifier to run"),
|
|
109
|
+
entrypoint: zod_1.z.string().describe("Path to the process JS entrypoint file (optionally path#exportName)"),
|
|
110
|
+
inputs: zod_1.z.string().optional().describe("JSON-encoded inputs for the process"),
|
|
111
|
+
runsDir: zod_1.z.string().optional().describe("Override runs directory path"),
|
|
112
|
+
prompt: zod_1.z.string().optional().describe("Prompt or description for the run"),
|
|
113
|
+
}, async (args) => {
|
|
114
|
+
try {
|
|
115
|
+
const { importPath, exportName } = parseEntrypoint(args.entrypoint);
|
|
116
|
+
const absoluteImportPath = path.resolve(importPath);
|
|
117
|
+
const runsDir = (0, resolve_run_dir_1.resolveRunDir)(args.runsDir);
|
|
118
|
+
let inputs;
|
|
119
|
+
if (args.inputs) {
|
|
120
|
+
try {
|
|
121
|
+
inputs = JSON.parse(args.inputs);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return (0, errors_1.toolError)("Invalid JSON in inputs parameter");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const result = await (0, runtime_1.createRun)({
|
|
128
|
+
runsDir,
|
|
129
|
+
process: {
|
|
130
|
+
processId: args.processId,
|
|
131
|
+
importPath: absoluteImportPath,
|
|
132
|
+
exportName,
|
|
133
|
+
},
|
|
134
|
+
prompt: args.prompt,
|
|
135
|
+
inputs,
|
|
136
|
+
});
|
|
137
|
+
return (0, errors_1.toolResult)({
|
|
138
|
+
runId: result.runId,
|
|
139
|
+
runDir: result.runDir,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
// ── run_status ──────────────────────────────────────────────────────
|
|
147
|
+
server.tool("run_status", "Get the current status and metadata of a run", {
|
|
148
|
+
runId: zod_1.z.string().describe("The run ID to query"),
|
|
149
|
+
runsDir: zod_1.z.string().optional().describe("Override runs directory path"),
|
|
150
|
+
}, async (args) => {
|
|
151
|
+
try {
|
|
152
|
+
const runsDir = (0, resolve_run_dir_1.resolveRunDir)(args.runsDir);
|
|
153
|
+
const runDir = path.join(runsDir, args.runId);
|
|
154
|
+
const metadata = await (0, storage_1.readRunMetadata)(runDir);
|
|
155
|
+
const journal = await (0, storage_1.loadJournal)(runDir);
|
|
156
|
+
const lastLifecycleEvent = findLastLifecycleEvent(journal);
|
|
157
|
+
const { pendingEffects, pendingByKind } = countPendingEffects(journal);
|
|
158
|
+
const state = deriveRunState(lastLifecycleEvent?.type, pendingEffects.length);
|
|
159
|
+
const completionProof = state === "completed" ? metadata.completionProof : undefined;
|
|
160
|
+
return (0, errors_1.toolResult)({
|
|
161
|
+
runId: metadata.runId,
|
|
162
|
+
processId: metadata.processId,
|
|
163
|
+
state,
|
|
164
|
+
pendingEffects,
|
|
165
|
+
pendingByKind,
|
|
166
|
+
completionProof: completionProof ?? null,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
// ── run_iterate ─────────────────────────────────────────────────────
|
|
174
|
+
server.tool("run_iterate", "Execute one orchestration iteration for a run", {
|
|
175
|
+
runId: zod_1.z.string().describe("The run ID to iterate"),
|
|
176
|
+
runsDir: zod_1.z.string().optional().describe("Override runs directory path"),
|
|
177
|
+
}, async (args) => {
|
|
178
|
+
try {
|
|
179
|
+
const runsDir = (0, resolve_run_dir_1.resolveRunDir)(args.runsDir);
|
|
180
|
+
const runDir = path.join(runsDir, args.runId);
|
|
181
|
+
const result = await (0, runtime_1.orchestrateIteration)({ runDir });
|
|
182
|
+
if (result.status === "completed") {
|
|
183
|
+
const metadata = await (0, storage_1.readRunMetadata)(runDir);
|
|
184
|
+
const completionProof = metadata.completionProof ?? null;
|
|
185
|
+
return (0, errors_1.toolResult)({
|
|
186
|
+
status: "completed",
|
|
187
|
+
output: result.output,
|
|
188
|
+
completionProof,
|
|
189
|
+
metadata: result.metadata,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (result.status === "failed") {
|
|
193
|
+
return (0, errors_1.toolResult)({
|
|
194
|
+
status: "failed",
|
|
195
|
+
error: result.error instanceof Error ? result.error.message : result.error,
|
|
196
|
+
metadata: result.metadata,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// status === "waiting"
|
|
200
|
+
return (0, errors_1.toolResult)({
|
|
201
|
+
status: "waiting",
|
|
202
|
+
nextActions: result.nextActions.map((action) => ({
|
|
203
|
+
effectId: action.effectId,
|
|
204
|
+
kind: action.kind,
|
|
205
|
+
label: action.label,
|
|
206
|
+
labels: action.labels,
|
|
207
|
+
taskId: action.taskId,
|
|
208
|
+
stepId: action.stepId,
|
|
209
|
+
})),
|
|
210
|
+
metadata: result.metadata,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
// ── run_events ──────────────────────────────────────────────────────
|
|
218
|
+
server.tool("run_events", "List journal events for a run", {
|
|
219
|
+
runId: zod_1.z.string().describe("The run ID to query"),
|
|
220
|
+
runsDir: zod_1.z.string().optional().describe("Override runs directory path"),
|
|
221
|
+
limit: zod_1.z.number().optional().describe("Maximum number of events to return"),
|
|
222
|
+
filterType: zod_1.z.string().optional().describe("Filter events by type (e.g. EFFECT_REQUESTED)"),
|
|
223
|
+
reverse: zod_1.z.boolean().optional().describe("Return events in reverse chronological order"),
|
|
224
|
+
}, async (args) => {
|
|
225
|
+
try {
|
|
226
|
+
const runsDir = (0, resolve_run_dir_1.resolveRunDir)(args.runsDir);
|
|
227
|
+
const runDir = path.join(runsDir, args.runId);
|
|
228
|
+
const journal = await (0, storage_1.loadJournal)(runDir);
|
|
229
|
+
// Apply type filter
|
|
230
|
+
const filterType = args.filterType?.toUpperCase();
|
|
231
|
+
const filtered = filterType
|
|
232
|
+
? journal.filter((event) => event.type.toUpperCase() === filterType)
|
|
233
|
+
: journal;
|
|
234
|
+
// Apply ordering
|
|
235
|
+
const ordered = args.reverse ? filtered.slice().reverse() : filtered;
|
|
236
|
+
// Apply limit
|
|
237
|
+
const limited = args.limit !== undefined ? ordered.slice(0, args.limit) : ordered;
|
|
238
|
+
return (0, errors_1.toolResult)({
|
|
239
|
+
total: journal.length,
|
|
240
|
+
matching: filtered.length,
|
|
241
|
+
showing: limited.length,
|
|
242
|
+
events: limited.map((event) => ({
|
|
243
|
+
seq: event.seq,
|
|
244
|
+
type: event.type,
|
|
245
|
+
recordedAt: event.recordedAt,
|
|
246
|
+
data: event.data,
|
|
247
|
+
})),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
// ── run_rebuild_state ───────────────────────────────────────────────
|
|
255
|
+
server.tool("run_rebuild_state", "Rebuild the state cache for a run from its journal", {
|
|
256
|
+
runId: zod_1.z.string().describe("The run ID to rebuild state for"),
|
|
257
|
+
runsDir: zod_1.z.string().optional().describe("Override runs directory path"),
|
|
258
|
+
}, async (args) => {
|
|
259
|
+
try {
|
|
260
|
+
const runsDir = (0, resolve_run_dir_1.resolveRunDir)(args.runsDir);
|
|
261
|
+
const runDir = path.join(runsDir, args.runId);
|
|
262
|
+
const snapshot = await (0, stateCache_1.rebuildStateCache)(runDir);
|
|
263
|
+
return (0, errors_1.toolResult)({
|
|
264
|
+
success: true,
|
|
265
|
+
stateVersion: snapshot.stateVersion,
|
|
266
|
+
journalHead: snapshot.journalHead,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
return (0, errors_1.toolError)(err instanceof Error ? err.message : String(err));
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sessions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAcpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4N5D"}
|