@dmmulroy/overseer 0.1.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/bin/os +99 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +6 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/learnings.d.ts +19 -0
- package/dist/api/learnings.d.ts.map +1 -0
- package/dist/api/learnings.js +31 -0
- package/dist/api/learnings.js.map +1 -0
- package/dist/api/tasks.d.ts +69 -0
- package/dist/api/tasks.d.ts.map +1 -0
- package/dist/api/tasks.js +108 -0
- package/dist/api/tasks.js.map +1 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +52 -0
- package/dist/cli.js.map +1 -0
- package/dist/executor.d.ts +12 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +112 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +193 -0
- package/dist/server.js.map +1 -0
- package/dist/tests/executor.test.d.ts +2 -0
- package/dist/tests/executor.test.d.ts.map +1 -0
- package/dist/tests/executor.test.js +169 -0
- package/dist/tests/executor.test.js.map +1 -0
- package/dist/tests/integration.test.d.ts +2 -0
- package/dist/tests/integration.test.d.ts.map +1 -0
- package/dist/tests/integration.test.js +378 -0
- package/dist/tests/integration.test.js.map +1 -0
- package/dist/tests/server.test.d.ts +2 -0
- package/dist/tests/server.test.d.ts.map +1 -0
- package/dist/tests/server.test.js +53 -0
- package/dist/tests/server.test.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +42 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server - registers execute tool with type definitions
|
|
3
|
+
*/
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
import { execute, ExecutionError } from "./executor.js";
|
|
8
|
+
import { CliError, CliTimeoutError } from "./types.js";
|
|
9
|
+
const TOOL_DESCRIPTION = `
|
|
10
|
+
Execute JavaScript code to interact with Overseer task management.
|
|
11
|
+
|
|
12
|
+
Available APIs in sandbox:
|
|
13
|
+
|
|
14
|
+
\`\`\`typescript
|
|
15
|
+
interface Task {
|
|
16
|
+
id: string;
|
|
17
|
+
parentId: string | null;
|
|
18
|
+
description: string;
|
|
19
|
+
context: { own: string; parent?: string; milestone?: string };
|
|
20
|
+
learnings: { milestone: Learning[]; parent: Learning[] };
|
|
21
|
+
priority: 1 | 2 | 3 | 4 | 5;
|
|
22
|
+
completed: boolean;
|
|
23
|
+
depth: 0 | 1 | 2;
|
|
24
|
+
blockedBy: string[];
|
|
25
|
+
blocks: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Learning {
|
|
29
|
+
id: string;
|
|
30
|
+
taskId: string;
|
|
31
|
+
content: string;
|
|
32
|
+
sourceTaskId: string | null;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Tasks API
|
|
37
|
+
// Note: VCS operations (bookmarks, commits) are handled automatically by start/complete
|
|
38
|
+
declare const tasks: {
|
|
39
|
+
list(filter?: { parentId?: string; ready?: boolean; completed?: boolean }): Promise<Task[]>;
|
|
40
|
+
get(id: string): Promise<Task>;
|
|
41
|
+
create(input: {
|
|
42
|
+
description: string;
|
|
43
|
+
context?: string;
|
|
44
|
+
parentId?: string;
|
|
45
|
+
priority?: 1 | 2 | 3 | 4 | 5;
|
|
46
|
+
blockedBy?: string[];
|
|
47
|
+
}): Promise<Task>;
|
|
48
|
+
update(id: string, input: {
|
|
49
|
+
description?: string;
|
|
50
|
+
context?: string;
|
|
51
|
+
priority?: 1 | 2 | 3 | 4 | 5;
|
|
52
|
+
parentId?: string;
|
|
53
|
+
}): Promise<Task>;
|
|
54
|
+
start(id: string): Promise<Task>; // Creates VCS bookmark, records start commit
|
|
55
|
+
complete(id: string, result?: string): Promise<Task>; // Squashes commits, rebases if child task
|
|
56
|
+
reopen(id: string): Promise<Task>;
|
|
57
|
+
delete(id: string): Promise<void>; // Cleans up VCS bookmark
|
|
58
|
+
block(taskId: string, blockerId: string): Promise<void>;
|
|
59
|
+
unblock(taskId: string, blockerId: string): Promise<void>;
|
|
60
|
+
nextReady(milestoneId?: string): Promise<Task | null>;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Learnings API
|
|
64
|
+
declare const learnings: {
|
|
65
|
+
add(taskId: string, content: string, sourceTaskId?: string): Promise<Learning>;
|
|
66
|
+
list(taskId: string): Promise<Learning[]>;
|
|
67
|
+
delete(id: string): Promise<void>;
|
|
68
|
+
};
|
|
69
|
+
\`\`\`
|
|
70
|
+
|
|
71
|
+
Examples:
|
|
72
|
+
|
|
73
|
+
\`\`\`javascript
|
|
74
|
+
// List all ready tasks
|
|
75
|
+
return await tasks.list({ ready: true });
|
|
76
|
+
|
|
77
|
+
// Create milestone with subtask
|
|
78
|
+
const milestone = await tasks.create({
|
|
79
|
+
description: "Build authentication system",
|
|
80
|
+
context: "JWT-based auth with refresh tokens",
|
|
81
|
+
priority: 1
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const subtask = await tasks.create({
|
|
85
|
+
description: "Implement token refresh logic",
|
|
86
|
+
parentId: milestone.id,
|
|
87
|
+
context: "Handle 7-day expiry",
|
|
88
|
+
priority: 2
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Start working on task (auto-creates VCS bookmark)
|
|
92
|
+
await tasks.start(subtask.id);
|
|
93
|
+
|
|
94
|
+
// Get task with full context
|
|
95
|
+
const task = await tasks.get(subtask.id);
|
|
96
|
+
console.log(task.context.milestone); // inherited from root
|
|
97
|
+
|
|
98
|
+
// Complete task (auto-squashes commits) and add learning
|
|
99
|
+
await tasks.complete(task.id, "Implemented using jose library");
|
|
100
|
+
await learnings.add(task.id, "Use jose instead of jsonwebtoken");
|
|
101
|
+
\`\`\`
|
|
102
|
+
`.trim();
|
|
103
|
+
/**
|
|
104
|
+
* Create and configure MCP server
|
|
105
|
+
*/
|
|
106
|
+
export function createServer() {
|
|
107
|
+
const server = new Server({
|
|
108
|
+
name: "overseer-mcp",
|
|
109
|
+
version: "0.1.0",
|
|
110
|
+
}, {
|
|
111
|
+
capabilities: {
|
|
112
|
+
tools: {},
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
// Register tools handler
|
|
116
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
117
|
+
tools: [
|
|
118
|
+
{
|
|
119
|
+
name: "execute",
|
|
120
|
+
description: TOOL_DESCRIPTION,
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {
|
|
124
|
+
code: {
|
|
125
|
+
type: "string",
|
|
126
|
+
description: "JavaScript code to execute (async/await supported)",
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
required: ["code"],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
}));
|
|
134
|
+
// Register tool call handler
|
|
135
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
136
|
+
if (request.params.name !== "execute") {
|
|
137
|
+
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
138
|
+
}
|
|
139
|
+
const code = request.params.arguments?.code;
|
|
140
|
+
if (typeof code !== "string") {
|
|
141
|
+
throw new Error("Missing or invalid 'code' argument");
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const result = await execute(code);
|
|
145
|
+
return {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
text: JSON.stringify(result, null, 2),
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
let errorMessage;
|
|
156
|
+
if (err instanceof ExecutionError) {
|
|
157
|
+
errorMessage = `Execution error: ${err.message}${err.stackTrace ? `\n${err.stackTrace}` : ""}`;
|
|
158
|
+
}
|
|
159
|
+
else if (err instanceof CliTimeoutError) {
|
|
160
|
+
errorMessage = `CLI timeout: ${err.message}`;
|
|
161
|
+
}
|
|
162
|
+
else if (err instanceof CliError) {
|
|
163
|
+
errorMessage = `CLI error (exit ${err.exitCode}): ${err.message}`;
|
|
164
|
+
}
|
|
165
|
+
else if (err instanceof Error) {
|
|
166
|
+
errorMessage = `Error: ${err.message}`;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
errorMessage = `Unknown error: ${String(err)}`;
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
content: [
|
|
173
|
+
{
|
|
174
|
+
type: "text",
|
|
175
|
+
text: errorMessage,
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
isError: true,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return server;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Start MCP server with stdio transport
|
|
186
|
+
*/
|
|
187
|
+
export async function startServer() {
|
|
188
|
+
const server = createServer();
|
|
189
|
+
const transport = new StdioServerTransport();
|
|
190
|
+
await server.connect(transport);
|
|
191
|
+
console.error("Overseer MCP server running on stdio");
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM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EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,YAAY;qBACnB;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.test.d.ts","sourceRoot":"","sources":["../../src/tests/executor.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for VM sandbox executor
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { execute, ExecutionError } from "../executor.js";
|
|
7
|
+
describe("VM Executor", () => {
|
|
8
|
+
describe("Basic Execution", () => {
|
|
9
|
+
it("should execute simple return", async () => {
|
|
10
|
+
const result = await execute("return 42;");
|
|
11
|
+
assert.equal(result, 42);
|
|
12
|
+
});
|
|
13
|
+
it("should execute arithmetic", async () => {
|
|
14
|
+
const result = await execute("return 10 + 20;");
|
|
15
|
+
assert.equal(result, 30);
|
|
16
|
+
});
|
|
17
|
+
it("should execute string operations", async () => {
|
|
18
|
+
const result = await execute('return "hello" + " " + "world";');
|
|
19
|
+
assert.equal(result, "hello world");
|
|
20
|
+
});
|
|
21
|
+
it("should execute object creation", async () => {
|
|
22
|
+
const result = await execute('return { a: 1, b: "test" };');
|
|
23
|
+
// VM context objects have different prototypes - check properties
|
|
24
|
+
assert.equal(result.a, 1);
|
|
25
|
+
assert.equal(result.b, "test");
|
|
26
|
+
});
|
|
27
|
+
it("should execute array operations", async () => {
|
|
28
|
+
const result = await execute("return [1, 2, 3].map(x => x * 2);");
|
|
29
|
+
// VM context arrays have different prototypes - check elements
|
|
30
|
+
assert.equal(result.length, 3);
|
|
31
|
+
assert.equal(result[0], 2);
|
|
32
|
+
assert.equal(result[1], 4);
|
|
33
|
+
assert.equal(result[2], 6);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe("Async Support", () => {
|
|
37
|
+
it("should handle Promise.resolve", async () => {
|
|
38
|
+
const result = await execute('return await Promise.resolve("async");');
|
|
39
|
+
assert.equal(result, "async");
|
|
40
|
+
});
|
|
41
|
+
it("should handle setTimeout in Promise", async () => {
|
|
42
|
+
const result = await execute(`
|
|
43
|
+
return await new Promise(resolve => {
|
|
44
|
+
setTimeout(() => resolve("delayed"), 10);
|
|
45
|
+
});
|
|
46
|
+
`);
|
|
47
|
+
assert.equal(result, "delayed");
|
|
48
|
+
});
|
|
49
|
+
it("should handle multiple awaits", async () => {
|
|
50
|
+
const result = await execute(`
|
|
51
|
+
const a = await Promise.resolve(1);
|
|
52
|
+
const b = await Promise.resolve(2);
|
|
53
|
+
return a + b;
|
|
54
|
+
`);
|
|
55
|
+
assert.equal(result, 3);
|
|
56
|
+
});
|
|
57
|
+
it("should handle async functions", async () => {
|
|
58
|
+
const result = await execute(`
|
|
59
|
+
async function helper() {
|
|
60
|
+
return await Promise.resolve(42);
|
|
61
|
+
}
|
|
62
|
+
return await helper();
|
|
63
|
+
`);
|
|
64
|
+
assert.equal(result, 42);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe("Variable Scope", () => {
|
|
68
|
+
it("should support const declarations", async () => {
|
|
69
|
+
const result = await execute(`
|
|
70
|
+
const x = 10;
|
|
71
|
+
const y = 20;
|
|
72
|
+
return x + y;
|
|
73
|
+
`);
|
|
74
|
+
assert.equal(result, 30);
|
|
75
|
+
});
|
|
76
|
+
it("should support let declarations", async () => {
|
|
77
|
+
const result = await execute(`
|
|
78
|
+
let counter = 0;
|
|
79
|
+
counter++;
|
|
80
|
+
counter++;
|
|
81
|
+
return counter;
|
|
82
|
+
`);
|
|
83
|
+
assert.equal(result, 2);
|
|
84
|
+
});
|
|
85
|
+
it("should support function declarations", async () => {
|
|
86
|
+
const result = await execute(`
|
|
87
|
+
function add(a, b) {
|
|
88
|
+
return a + b;
|
|
89
|
+
}
|
|
90
|
+
return add(5, 7);
|
|
91
|
+
`);
|
|
92
|
+
assert.equal(result, 12);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe("Error Handling", () => {
|
|
96
|
+
it("should throw ExecutionError on syntax error", async () => {
|
|
97
|
+
await assert.rejects(async () => await execute("return {{{;"), ExecutionError);
|
|
98
|
+
});
|
|
99
|
+
it("should throw ExecutionError on runtime error", async () => {
|
|
100
|
+
await assert.rejects(async () => await execute('throw new Error("test");'), ExecutionError);
|
|
101
|
+
});
|
|
102
|
+
it("should throw ExecutionError on undefined variable", async () => {
|
|
103
|
+
await assert.rejects(async () => await execute("return undefinedVar;"), ExecutionError);
|
|
104
|
+
});
|
|
105
|
+
it("should include error message in ExecutionError", async () => {
|
|
106
|
+
try {
|
|
107
|
+
await execute('throw new Error("test error");');
|
|
108
|
+
assert.fail("Should have thrown");
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
assert.ok(err instanceof ExecutionError);
|
|
112
|
+
assert.ok(err.message.includes("test error"));
|
|
113
|
+
// Stack trace may be undefined depending on error type
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe("Output Truncation", () => {
|
|
118
|
+
it("should not truncate small outputs", async () => {
|
|
119
|
+
const result = await execute('return "small output";');
|
|
120
|
+
assert.equal(result, "small output");
|
|
121
|
+
});
|
|
122
|
+
it("should truncate large outputs", async () => {
|
|
123
|
+
const result = await execute(`
|
|
124
|
+
const largeArray = Array(10000).fill("x".repeat(100));
|
|
125
|
+
return largeArray;
|
|
126
|
+
`);
|
|
127
|
+
assert.ok(typeof result === "object" && result !== null);
|
|
128
|
+
const obj = result;
|
|
129
|
+
assert.equal(obj._truncated, true);
|
|
130
|
+
assert.ok(obj.size);
|
|
131
|
+
assert.ok(obj.preview);
|
|
132
|
+
assert.ok(obj.message);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
describe("Sandbox Isolation", () => {
|
|
136
|
+
it("should not have access to process", async () => {
|
|
137
|
+
await assert.rejects(async () => await execute("return process.env;"), ExecutionError);
|
|
138
|
+
});
|
|
139
|
+
it("should not have access to require", async () => {
|
|
140
|
+
await assert.rejects(async () => await execute('return require("fs");'), ExecutionError);
|
|
141
|
+
});
|
|
142
|
+
it("should not have access to global", async () => {
|
|
143
|
+
await assert.rejects(async () => await execute("return global.process;"), ExecutionError);
|
|
144
|
+
});
|
|
145
|
+
it("should have access to console", async () => {
|
|
146
|
+
// Should not throw
|
|
147
|
+
const result = await execute(`
|
|
148
|
+
console.log("test message");
|
|
149
|
+
return "ok";
|
|
150
|
+
`);
|
|
151
|
+
assert.equal(result, "ok");
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
describe("Timeout", () => {
|
|
155
|
+
it.skip("should timeout after 30s (skipped - slow)", async () => {
|
|
156
|
+
await assert.rejects(async () => {
|
|
157
|
+
await execute(`
|
|
158
|
+
// Infinite loop
|
|
159
|
+
while(true) {}
|
|
160
|
+
`);
|
|
161
|
+
}, (err) => {
|
|
162
|
+
assert.ok(err.message.includes("timeout") ||
|
|
163
|
+
err.message.includes("timed out"));
|
|
164
|
+
return true;
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=executor.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.test.js","sourceRoot":"","sources":["../../src/tests/executor.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,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