dsh-super-code 0.3.7 → 0.3.8
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 +14 -10
- package/client/index.js +576 -24
- package/cordis.patch.yml +1 -1
- package/docs/Changelog.md +9 -0
- package/docs/Compatibility.md +30 -0
- package/docs/UsageGuide.md +60 -0
- package/lib/connection/directories.d.ts +30 -0
- package/lib/connection/directories.d.ts.map +1 -0
- package/lib/connection/directories.js +82 -0
- package/lib/connection/directories.js.map +1 -0
- package/lib/connection/git.d.ts +5 -0
- package/lib/connection/git.d.ts.map +1 -0
- package/lib/connection/git.js +86 -0
- package/lib/connection/git.js.map +1 -0
- package/lib/connection/http.d.ts +38 -0
- package/lib/connection/http.d.ts.map +1 -0
- package/lib/connection/http.js +275 -0
- package/lib/connection/http.js.map +1 -0
- package/lib/connection/service.d.ts +57 -0
- package/lib/connection/service.d.ts.map +1 -0
- package/lib/connection/service.js +168 -0
- package/lib/connection/service.js.map +1 -0
- package/lib/connection/store.d.ts +21 -0
- package/lib/connection/store.d.ts.map +1 -0
- package/lib/connection/store.js +139 -0
- package/lib/connection/store.js.map +1 -0
- package/lib/connection/tasks.d.ts +84 -0
- package/lib/connection/tasks.d.ts.map +1 -0
- package/lib/connection/tasks.js +270 -0
- package/lib/connection/tasks.js.map +1 -0
- package/lib/connection/types.d.ts +90 -0
- package/lib/connection/types.d.ts.map +1 -0
- package/lib/connection/types.js +21 -0
- package/lib/connection/types.js.map +1 -0
- package/lib/dsh/connection-host.d.ts +81 -0
- package/lib/dsh/connection-host.d.ts.map +1 -0
- package/lib/dsh/connection-host.js +130 -0
- package/lib/dsh/connection-host.js.map +1 -0
- package/lib/dsh/connection.d.ts +72 -0
- package/lib/dsh/connection.d.ts.map +1 -0
- package/lib/dsh/connection.js +183 -0
- package/lib/dsh/connection.js.map +1 -0
- package/lib/dsh/index.d.ts.map +1 -1
- package/lib/dsh/index.js +2 -0
- package/lib/dsh/index.js.map +1 -1
- package/package.json +7 -6
- package/presets/super-code/agent.cordis.yml +1 -1
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/** Local Streamable HTTP boundary. Authentication precedes body parsing and MCP dispatch. */
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
import { timingSafeEqual, randomUUID } from 'node:crypto';
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { pluginVersion } from '../dsh/preset-version.js';
|
|
8
|
+
import { ConnectionError } from './types.js';
|
|
9
|
+
const identity = z.string().min(1).max(128).regex(/^[a-zA-Z0-9_.:-]+$/);
|
|
10
|
+
const prompt = z.string().trim().min(1).max(32000);
|
|
11
|
+
const cursor = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).default(0);
|
|
12
|
+
const waitMs = z.number().int().min(0).max(30000).default(0);
|
|
13
|
+
export function delegationMcpServer(tasks, signal, connectionId = '', requestDirectory, clientName = () => 'mcp', connectionStatus = () => ({ connections: connectionId ? 1 : 0, maxConnections: 1, ids: connectionId ? [connectionId] : [] })) {
|
|
14
|
+
const server = new McpServer({ name: 'dsh-super-code', version: pluginVersion }, { maxToolInputElements: 64 });
|
|
15
|
+
const result = async (run) => {
|
|
16
|
+
try {
|
|
17
|
+
return { content: [{ type: 'text', text: JSON.stringify(await run()) }] };
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return { isError: true, content: [{ type: 'text', text: error instanceof ConnectionError ? error.code : 'operation-unavailable' }] };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
server.registerTool('dsh_sessions', { description: 'List recent DSH conversations for an allowed working directory before choosing dsh_run. Each entry includes taskId, status, reuse availability and linked connection count; the response also includes current/max/available MCP connections and active/available task slots. Pass a listed taskId to dsh_run to reuse that conversation, or set newConversation=true to create a new root.',
|
|
24
|
+
inputSchema: z.object({ cwd: z.string().min(1).max(4096), limit: z.number().int().min(1).max(25).default(10) }).strict(),
|
|
25
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
26
|
+
}, input => result(() => tasks.sessions(input.cwd, input.limit, connectionStatus())));
|
|
27
|
+
server.registerTool('dsh_run', { description: 'Delegate to DSH Super Code. Call dsh_sessions first and let the user choose a history entry. Pass taskId to reuse an exact conversation, or set newConversation=true to explicitly create a new root session. If neither is provided, a new root is created for backward compatibility. Use a stable requestId for retries; conflicts do not dispatch. DSH permissions apply independently of the caller sandbox. A finished turn is not verified acceptance.',
|
|
28
|
+
inputSchema: z.object({ requestId: identity, cwd: z.string().min(1).max(4096), prompt, client: z.string().min(1).max(80).optional(), taskId: identity.optional(), newConversation: z.boolean().optional() }).strict(),
|
|
29
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true },
|
|
30
|
+
}, input => result(() => {
|
|
31
|
+
if (input.taskId) {
|
|
32
|
+
if (input.newConversation)
|
|
33
|
+
throw new ConnectionError('conflicting-session-options');
|
|
34
|
+
return tasks.send({ taskId: input.taskId, requestId: input.requestId, cwd: input.cwd, prompt: input.prompt, connectionId });
|
|
35
|
+
}
|
|
36
|
+
return tasks.run({ requestId: input.requestId, cwd: input.cwd, prompt: input.prompt, client: input.client ?? clientName(), connectionId });
|
|
37
|
+
}));
|
|
38
|
+
server.registerTool('dsh_wait', { description: 'Omit taskId to list service-owned tasks (cursor is a list offset). With taskId, read bounded output, workspace observations and events after cursor. Long-poll up to 30 seconds; timeout/disconnect never cancels execution. waiting_confirmation must be resolved in DSH. finished means execution ended, not acceptance verified.',
|
|
39
|
+
inputSchema: z.object({ taskId: identity.optional(), cursor, waitMs }).strict(),
|
|
40
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
41
|
+
}, (input, extra) => result(() => input.taskId ? tasks.wait(input.taskId, input.cursor, input.waitMs, signal(extra.requestId)) : tasks.list(input.cursor)));
|
|
42
|
+
server.registerTool('dsh_send', { description: 'Explicitly queue a follow-up in a service-owned root session, including after an interruption. Use a new stable requestId for each follow-up. An ambiguous admission is never automatically resent. Does not approve host permissions.',
|
|
43
|
+
inputSchema: z.object({ taskId: identity, requestId: identity, prompt }).strict(),
|
|
44
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true },
|
|
45
|
+
}, input => result(() => tasks.send({ ...input, connectionId })));
|
|
46
|
+
server.registerTool('dsh_cancel', { description: 'Request cancellation of a service-owned root and its managed descendants. Check the returned status; cancelling/unavailable do not confirm that all execution stopped. Already accepted external side effects cannot be undone.',
|
|
47
|
+
inputSchema: z.object({ taskId: identity }).strict(),
|
|
48
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
49
|
+
}, input => result(() => tasks.cancel(input.taskId)));
|
|
50
|
+
server.registerTool('dsh_request_directory', { description: 'Request access to an existing absolute directory (including its descendants). DSH displays a consent dialog; only the user can approve. Repeat the same requestId, path and reason to poll. Pending requests expire after 5 minutes and are discarded on host restart. Rejection is final for that requestId. Never assume access before approved.',
|
|
51
|
+
inputSchema: z.object({ requestId: identity, path: z.string().min(1).max(4096), reason: z.string().trim().min(1).max(1000) }).strict(),
|
|
52
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
53
|
+
}, input => result(() => { if (!requestDirectory)
|
|
54
|
+
throw new ConnectionError('unavailable'); return requestDirectory(input); }));
|
|
55
|
+
return server;
|
|
56
|
+
}
|
|
57
|
+
function reply(res, code, message) {
|
|
58
|
+
res.writeHead(code, { 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'no-store' });
|
|
59
|
+
res.end(message);
|
|
60
|
+
}
|
|
61
|
+
function authorized(req, token) {
|
|
62
|
+
const actual = Buffer.from(req.headers.authorization ?? ''), expected = Buffer.from(`Bearer ${token}`);
|
|
63
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
64
|
+
}
|
|
65
|
+
/** MCP sessions, rather than TCP sockets or individual HTTP requests, define a connection. */
|
|
66
|
+
export class ConnectionHttp {
|
|
67
|
+
tasks;
|
|
68
|
+
requestDirectory;
|
|
69
|
+
server = false;
|
|
70
|
+
requests = 0;
|
|
71
|
+
clients = new Map();
|
|
72
|
+
pending = new Set();
|
|
73
|
+
timer = false;
|
|
74
|
+
constructor(tasks, requestDirectory = undefined) {
|
|
75
|
+
this.tasks = tasks;
|
|
76
|
+
this.requestDirectory = requestDirectory;
|
|
77
|
+
}
|
|
78
|
+
connections() {
|
|
79
|
+
return [...this.clients.values()].filter(client => client.transport.sessionId).map(({ id, name, version, connectedAt, lastSeen }) => ({ id, name, version, connectedAt, lastSeen }));
|
|
80
|
+
}
|
|
81
|
+
async disconnect(id) {
|
|
82
|
+
const client = this.clients.get(id);
|
|
83
|
+
if (!client)
|
|
84
|
+
return;
|
|
85
|
+
this.clients.delete(id);
|
|
86
|
+
client.lifetime.abort();
|
|
87
|
+
for (const call of client.calls.values())
|
|
88
|
+
call.abort();
|
|
89
|
+
await client.mcp.close();
|
|
90
|
+
}
|
|
91
|
+
async prune() {
|
|
92
|
+
const expired = [...this.clients.values()].filter(client => !client.active && Date.now() - client.lastSeen > 10 * 60 * 1000);
|
|
93
|
+
await Promise.all(expired.map(client => this.disconnect(client.id)));
|
|
94
|
+
}
|
|
95
|
+
async start(port, token, maxConnections = 3) {
|
|
96
|
+
if (this.server)
|
|
97
|
+
throw new ConnectionError('already-listening');
|
|
98
|
+
const server = createServer((req, res) => { void this.handle(req, res, port, token, maxConnections).catch(() => { if (!res.headersSent)
|
|
99
|
+
reply(res, 500, 'Request failed');
|
|
100
|
+
else
|
|
101
|
+
res.end(); }); });
|
|
102
|
+
server.requestTimeout = 15000;
|
|
103
|
+
server.headersTimeout = 10000;
|
|
104
|
+
server.keepAliveTimeout = 1000;
|
|
105
|
+
server.maxHeadersCount = 40;
|
|
106
|
+
await new Promise((resolve, reject) => {
|
|
107
|
+
server.once('error', reject);
|
|
108
|
+
server.listen(port, '127.0.0.1', () => { server.removeListener('error', reject); resolve(); });
|
|
109
|
+
}).catch(() => { server.close(); throw new ConnectionError('port-unavailable'); });
|
|
110
|
+
this.server = server;
|
|
111
|
+
this.timer = setInterval(() => { void this.prune().catch(() => { }); }, 5000);
|
|
112
|
+
this.timer.unref();
|
|
113
|
+
}
|
|
114
|
+
async admit(body, maxConnections) {
|
|
115
|
+
if (!body || typeof body !== 'object' || body.method !== 'initialize')
|
|
116
|
+
return false;
|
|
117
|
+
await this.prune();
|
|
118
|
+
if (this.clients.size >= maxConnections)
|
|
119
|
+
throw new ConnectionError('connection-limit');
|
|
120
|
+
const id = randomUUID(), now = Date.now(), lifetime = new AbortController(), calls = new Map();
|
|
121
|
+
const mcp = delegationMcpServer(this.tasks, requestId => calls.get(requestId)?.signal ?? lifetime.signal, id, input => { if (!this.requestDirectory)
|
|
122
|
+
throw new ConnectionError('unavailable'); return this.requestDirectory(input, this.clients.get(id)?.name ?? 'MCP client'); }, () => this.clients.get(id)?.name ?? 'mcp', () => ({ connections: this.clients.size, maxConnections, ids: [...this.clients.keys()] }));
|
|
123
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => id, enableJsonResponse: true,
|
|
124
|
+
onsessionclosed: () => { void this.disconnect(id); } });
|
|
125
|
+
const client = { id, name: 'MCP client', version: '', connectedAt: now, lastSeen: now, mcp, transport, lifetime, calls, active: 0 };
|
|
126
|
+
this.clients.set(id, client);
|
|
127
|
+
mcp.server.oninitialized = () => {
|
|
128
|
+
const info = mcp.server.getClientVersion();
|
|
129
|
+
client.name = (info?.name ?? 'MCP client').slice(0, 80);
|
|
130
|
+
client.version = (info?.version ?? '').slice(0, 80);
|
|
131
|
+
};
|
|
132
|
+
try {
|
|
133
|
+
await mcp.connect(transport);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
await this.disconnect(id);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
return client;
|
|
140
|
+
}
|
|
141
|
+
async handle(req, res, port, token, maxConnections) {
|
|
142
|
+
const address = '127.0.0.1:' + port;
|
|
143
|
+
if (req.headers.host !== address && req.headers.host !== 'localhost:' + port) {
|
|
144
|
+
reply(res, 403, 'Invalid Host');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (req.headers.origin !== undefined) {
|
|
148
|
+
reply(res, 403, 'Origin not allowed');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (req.url !== '/mcp') {
|
|
152
|
+
reply(res, 404, 'Not found');
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!authorized(req, token)) {
|
|
156
|
+
res.setHeader('WWW-Authenticate', 'Bearer');
|
|
157
|
+
reply(res, 401, 'Bearer token required');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (!['POST', 'DELETE'].includes(req.method ?? '')) {
|
|
161
|
+
res.setHeader('Allow', 'POST, DELETE');
|
|
162
|
+
reply(res, 405, 'Use POST or DELETE');
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (req.method === 'POST' && !/^application\/json(?:\s*;|$)/i.test(req.headers['content-type'] ?? '')) {
|
|
166
|
+
reply(res, 415, 'JSON required');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (this.requests >= 12) {
|
|
170
|
+
reply(res, 429, 'Too many requests');
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (Number(req.headers['content-length'] ?? 0) > 131072) {
|
|
174
|
+
reply(res, 413, 'Request too large');
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this.requests++;
|
|
178
|
+
const abort = new AbortController();
|
|
179
|
+
this.pending.add(abort);
|
|
180
|
+
res.once('close', () => abort.abort());
|
|
181
|
+
let client = false, requestId = false, admitted = false;
|
|
182
|
+
try {
|
|
183
|
+
let body;
|
|
184
|
+
if (req.method === 'POST') {
|
|
185
|
+
const chunks = [];
|
|
186
|
+
let length = 0;
|
|
187
|
+
for await (const chunk of req) {
|
|
188
|
+
length += chunk.length;
|
|
189
|
+
if (length > 131072) {
|
|
190
|
+
reply(res, 413, 'Request too large');
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
chunks.push(Buffer.from(chunk));
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
body = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
reply(res, 400, 'Invalid JSON');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (Array.isArray(body)) {
|
|
203
|
+
reply(res, 400, 'Batch requests are not supported');
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const session = req.headers['mcp-session-id'];
|
|
208
|
+
if (session !== undefined) {
|
|
209
|
+
client = typeof session === 'string' ? this.clients.get(session) ?? false : false;
|
|
210
|
+
if (!client) {
|
|
211
|
+
reply(res, 404, 'MCP session not found; initialize again');
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
try {
|
|
217
|
+
client = await this.admit(body, maxConnections);
|
|
218
|
+
admitted = !!client;
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
if (error instanceof ConnectionError && error.code === 'connection-limit') {
|
|
222
|
+
reply(res, 429, 'Maximum MCP connections reached');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
;
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
if (!client) {
|
|
229
|
+
reply(res, 400, 'Initialize an MCP session first');
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
client.active++;
|
|
234
|
+
client.lastSeen = Date.now();
|
|
235
|
+
const id = body && typeof body === 'object' ? body.id : false;
|
|
236
|
+
if (typeof id === 'string' || typeof id === 'number') {
|
|
237
|
+
requestId = id;
|
|
238
|
+
if (client.calls.has(id)) {
|
|
239
|
+
reply(res, 409, 'Duplicate in-flight request ID');
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
client.calls.set(id, abort);
|
|
243
|
+
}
|
|
244
|
+
await client.transport.handleRequest(req, res, body);
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
if (client) {
|
|
248
|
+
client.active--;
|
|
249
|
+
client.lastSeen = Date.now();
|
|
250
|
+
if (requestId !== false && client.calls.get(requestId) === abort)
|
|
251
|
+
client.calls.delete(requestId);
|
|
252
|
+
if (admitted && (!client.transport.sessionId || res.statusCode >= 400))
|
|
253
|
+
await this.disconnect(client.id);
|
|
254
|
+
}
|
|
255
|
+
this.pending.delete(abort);
|
|
256
|
+
this.requests--;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async close() {
|
|
260
|
+
const server = this.server;
|
|
261
|
+
this.server = false;
|
|
262
|
+
if (this.timer) {
|
|
263
|
+
clearInterval(this.timer);
|
|
264
|
+
this.timer = false;
|
|
265
|
+
}
|
|
266
|
+
for (const pending of this.pending)
|
|
267
|
+
pending.abort();
|
|
268
|
+
await Promise.all([...this.clients.keys()].map(id => this.disconnect(id)));
|
|
269
|
+
if (!server)
|
|
270
|
+
return;
|
|
271
|
+
server.closeAllConnections();
|
|
272
|
+
await new Promise(resolve => server.close(() => resolve()));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/connection/http.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE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AC,KAAK;QACT,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QAC/C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAAC,CAAC;QACjE,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,CAAC,KAAK,EAAE,CAAA;QACnD,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAC1E,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,MAAM,CAAC,mBAAmB,EAAE,CAAA;QAC5B,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACnE,CAAC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ConnectionConfig, DelegationHost } from './types.js';
|
|
2
|
+
import { ConnectionStore } from './store.js';
|
|
3
|
+
import { DelegatedTasks } from './tasks.js';
|
|
4
|
+
import type { ConnectedClient } from './http.js';
|
|
5
|
+
import type { DirectoryRequest } from './directories.js';
|
|
6
|
+
export interface ConnectionSnapshot {
|
|
7
|
+
configuration: ConnectionConfig;
|
|
8
|
+
revision: number;
|
|
9
|
+
writable: boolean;
|
|
10
|
+
state: 'disabled' | 'listening' | 'error';
|
|
11
|
+
error: string;
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ConnectionOverview {
|
|
15
|
+
connections: ConnectedClient[];
|
|
16
|
+
sessions: ReturnType<DelegatedTasks['overview']>;
|
|
17
|
+
}
|
|
18
|
+
export type ConnectionSaveResult = {
|
|
19
|
+
ok: true;
|
|
20
|
+
snapshot: ConnectionSnapshot;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
error: string;
|
|
24
|
+
};
|
|
25
|
+
export declare class ConnectionService {
|
|
26
|
+
private readonly store;
|
|
27
|
+
private readonly host;
|
|
28
|
+
private settings;
|
|
29
|
+
private tasks;
|
|
30
|
+
private http;
|
|
31
|
+
private directoryRequests;
|
|
32
|
+
private timer;
|
|
33
|
+
private tail;
|
|
34
|
+
private state;
|
|
35
|
+
private error;
|
|
36
|
+
private observing;
|
|
37
|
+
constructor(store: ConnectionStore, host: DelegationHost);
|
|
38
|
+
initialize(): Promise<void>;
|
|
39
|
+
read(): ConnectionSnapshot;
|
|
40
|
+
overview(): ConnectionOverview;
|
|
41
|
+
disconnect(id: string): Promise<{
|
|
42
|
+
disconnected: true;
|
|
43
|
+
}>;
|
|
44
|
+
pendingDirectories(): DirectoryRequest[];
|
|
45
|
+
resolveDirectory(id: string, decision: string): Promise<{
|
|
46
|
+
status: DirectoryRequest['status'];
|
|
47
|
+
}>;
|
|
48
|
+
private exclusive;
|
|
49
|
+
save(content: string, revision: string): Promise<ConnectionSaveResult>;
|
|
50
|
+
reveal(): {
|
|
51
|
+
token: string;
|
|
52
|
+
};
|
|
53
|
+
rotate(revision: string): Promise<ConnectionSaveResult>;
|
|
54
|
+
private listen;
|
|
55
|
+
close(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/connection/service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,C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AAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,IAAI,CAAA;KAAE,CAAC;IAC7D,kBAAkB,IAAI,gBAAgB,EAAE;IAClC,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;IAarG,OAAO,CAAC,SAAS;IAGX,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA4B5E,MAAM,IAAI;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IACrB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAU/C,MAAM;IAMd,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { realpath, stat } from 'node:fs/promises';
|
|
3
|
+
import { isAbsolute } from 'node:path';
|
|
4
|
+
import { ConnectionError, connectionConfigSchema } from './types.js';
|
|
5
|
+
import { ConnectionStore } from './store.js';
|
|
6
|
+
import { DelegatedTasks } from './tasks.js';
|
|
7
|
+
import { ConnectionHttp } from './http.js';
|
|
8
|
+
import { DirectoryRequests } from './directories.js';
|
|
9
|
+
export class ConnectionService {
|
|
10
|
+
store;
|
|
11
|
+
host;
|
|
12
|
+
settings;
|
|
13
|
+
tasks;
|
|
14
|
+
http;
|
|
15
|
+
directoryRequests;
|
|
16
|
+
timer = false;
|
|
17
|
+
tail = Promise.resolve();
|
|
18
|
+
state = 'disabled';
|
|
19
|
+
error = '';
|
|
20
|
+
observing = false;
|
|
21
|
+
constructor(store, host) {
|
|
22
|
+
this.store = store;
|
|
23
|
+
this.host = host;
|
|
24
|
+
}
|
|
25
|
+
async initialize() {
|
|
26
|
+
await this.store.initialize();
|
|
27
|
+
try {
|
|
28
|
+
this.settings = await this.store.settings();
|
|
29
|
+
this.tasks = new DelegatedTasks(this.store, this.host, () => this.settings.config);
|
|
30
|
+
await this.tasks.initialize();
|
|
31
|
+
this.directoryRequests = new DirectoryRequests(() => this.settings.config.allowedDirectories);
|
|
32
|
+
this.http = new ConnectionHttp(this.tasks, (input, client) => this.exclusive(async () => {
|
|
33
|
+
if (!this.settings.config.enabled)
|
|
34
|
+
throw new ConnectionError('connection-disabled');
|
|
35
|
+
return this.directoryRequests.request(input, client);
|
|
36
|
+
}));
|
|
37
|
+
await this.listen();
|
|
38
|
+
this.timer = setInterval(() => {
|
|
39
|
+
if (this.observing)
|
|
40
|
+
return;
|
|
41
|
+
this.observing = true;
|
|
42
|
+
void this.tasks.tick().catch(() => { this.error = 'storage-unavailable'; }).finally(() => { this.observing = false; });
|
|
43
|
+
}, 1000);
|
|
44
|
+
this.timer.unref();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
await this.store.close();
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
read() {
|
|
52
|
+
return { configuration: structuredClone(this.settings.config), revision: this.settings.revision, writable: true,
|
|
53
|
+
state: this.state, error: this.error, url: `http://127.0.0.1:${this.settings.config.port}/mcp` };
|
|
54
|
+
}
|
|
55
|
+
overview() { return { connections: this.http.connections(), sessions: this.tasks.overview() }; }
|
|
56
|
+
async disconnect(id) { await this.http.disconnect(id); return { disconnected: true }; }
|
|
57
|
+
pendingDirectories() { return this.directoryRequests.pending(); }
|
|
58
|
+
async resolveDirectory(id, decision) {
|
|
59
|
+
if (decision !== 'approved' && decision !== 'rejected')
|
|
60
|
+
throw new ConnectionError('invalid-decision');
|
|
61
|
+
return this.exclusive(() => this.directoryRequests.resolve(id, decision, async (path) => {
|
|
62
|
+
if (!this.settings.config.enabled)
|
|
63
|
+
throw new ConnectionError('connection-disabled');
|
|
64
|
+
const allowedDirectories = [...new Set([...this.settings.config.allowedDirectories, path])];
|
|
65
|
+
if (allowedDirectories.length > 32)
|
|
66
|
+
throw new ConnectionError('directory-limit');
|
|
67
|
+
const next = { ...this.settings, revision: this.settings.revision + 1,
|
|
68
|
+
config: { ...this.settings.config, directoriesConfigured: true, allowedDirectories,
|
|
69
|
+
knownDirectories: [...new Set([...this.settings.config.knownDirectories, path])].slice(-128) } };
|
|
70
|
+
await this.store.saveSettings(next);
|
|
71
|
+
this.settings = next;
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
exclusive(run) {
|
|
75
|
+
const operation = this.tail.then(run);
|
|
76
|
+
this.tail = operation.catch(() => { });
|
|
77
|
+
return operation;
|
|
78
|
+
}
|
|
79
|
+
async save(content, revision) {
|
|
80
|
+
return this.exclusive(async () => {
|
|
81
|
+
if (revision !== String(this.settings.revision))
|
|
82
|
+
return { ok: false, error: 'conflict' };
|
|
83
|
+
let config;
|
|
84
|
+
try {
|
|
85
|
+
if (content.length > 131072)
|
|
86
|
+
throw new Error();
|
|
87
|
+
config = connectionConfigSchema.parse(JSON.parse(content));
|
|
88
|
+
config.maxConcurrent = config.maxConnections;
|
|
89
|
+
if (config.knownDirectories.some(path => !isAbsolute(path)))
|
|
90
|
+
throw new Error();
|
|
91
|
+
config.knownDirectories = [...new Set(config.knownDirectories)];
|
|
92
|
+
config.allowedDirectories = [...new Set(await Promise.all(config.allowedDirectories.map(async (path) => {
|
|
93
|
+
if (!isAbsolute(path))
|
|
94
|
+
throw new Error();
|
|
95
|
+
const canonical = await realpath(path);
|
|
96
|
+
if (!(await stat(canonical)).isDirectory())
|
|
97
|
+
throw new Error();
|
|
98
|
+
return canonical;
|
|
99
|
+
})))].sort();
|
|
100
|
+
if (config.enabled && !config.allowedDirectories.length)
|
|
101
|
+
throw new Error();
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return { ok: false, error: 'invalid' };
|
|
105
|
+
}
|
|
106
|
+
const previous = this.settings.config;
|
|
107
|
+
const next = { ...this.settings, revision: this.settings.revision + 1, config };
|
|
108
|
+
try {
|
|
109
|
+
await this.store.saveSettings(next);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return { ok: false, error: 'save-failed' };
|
|
113
|
+
}
|
|
114
|
+
this.settings = next;
|
|
115
|
+
if (!config.enabled)
|
|
116
|
+
this.directoryRequests.rejectPending();
|
|
117
|
+
const transportChanged = this.state === 'error' || config.enabled !== previous.enabled || config.port !== previous.port || config.maxConnections !== previous.maxConnections;
|
|
118
|
+
if (transportChanged) {
|
|
119
|
+
await this.http.close();
|
|
120
|
+
await this.listen();
|
|
121
|
+
}
|
|
122
|
+
return { ok: true, snapshot: this.read() };
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
reveal() { return { token: this.settings.token }; }
|
|
126
|
+
async rotate(revision) {
|
|
127
|
+
return this.exclusive(async () => {
|
|
128
|
+
if (revision !== String(this.settings.revision))
|
|
129
|
+
return { ok: false, error: 'conflict' };
|
|
130
|
+
const next = { ...this.settings, revision: this.settings.revision + 1, token: randomBytes(32).toString('hex') };
|
|
131
|
+
try {
|
|
132
|
+
await this.store.saveSettings(next);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return { ok: false, error: 'save-failed' };
|
|
136
|
+
}
|
|
137
|
+
this.settings = next;
|
|
138
|
+
await this.http.close();
|
|
139
|
+
await this.listen();
|
|
140
|
+
return { ok: true, snapshot: this.read() };
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async listen() {
|
|
144
|
+
this.error = '';
|
|
145
|
+
this.state = 'disabled';
|
|
146
|
+
if (!this.settings.config.enabled)
|
|
147
|
+
return;
|
|
148
|
+
try {
|
|
149
|
+
await this.http.start(this.settings.config.port, this.settings.token, this.settings.config.maxConnections);
|
|
150
|
+
this.state = 'listening';
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
this.state = 'error';
|
|
154
|
+
this.error = error instanceof ConnectionError ? error.code : 'unavailable';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async close() {
|
|
158
|
+
await this.exclusive(async () => {
|
|
159
|
+
if (this.timer)
|
|
160
|
+
clearInterval(this.timer);
|
|
161
|
+
this.directoryRequests.rejectPending();
|
|
162
|
+
await this.http.close();
|
|
163
|
+
await this.tasks.close();
|
|
164
|
+
await this.store.close();
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/connection/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAOpD,MAAM,OAAO,iBAAiB;IAUC;IAAyC;IAT9D,QAAQ,CAAqB;IAC7B,KAAK,CAAiB;IACtB,IAAI,CAAiB;IACrB,iBAAiB,CAAoB;IACrC,KAAK,GAA2C,KAAK,CAAA;IACrD,IAAI,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1C,KAAK,GAAgC,UAAU,CAAA;IAC/C,KAAK,GAAW,EAAE,CAAA;IAClB,SAAS,GAAY,KAAK,CAAA;IAClC,YAA6B,KAAsB,EAAmB,IAAoB;QAA7D,UAAK,GAAL,KAAK,CAAiB;QAAmB,SAAI,GAAJ,IAAI,CAAgB;IAAG,CAA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,CAAC;QAAC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAA;QACxC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO;YAAE,OAAM;QACzC,IAAI,CAAC;YAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YAAC,IAAI,CAAC,KAAK,GAAG,WAAW,CAAA;QAAC,CAAC;QAC5I,OAAO,KAAK,EAAE,CAAC;YAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;YAAC,IAAI,CAAC,KAAK,GAAG,KAAK,YAAY,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAA;QAAC,CAAC;IACpH,CAAC;IACD,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;YAC9B,IAAI,IAAI,CAAC,KAAK;gBAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACzC,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAA;YACtC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAAC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAAC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAC7E,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ConnectionConfig, DelegatedTask } from './types.js';
|
|
2
|
+
export interface ConnectionSettings {
|
|
3
|
+
revision: number;
|
|
4
|
+
config: ConnectionConfig;
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConnectionStore {
|
|
8
|
+
readonly directory: string;
|
|
9
|
+
private lock;
|
|
10
|
+
private owned;
|
|
11
|
+
constructor(directory: string);
|
|
12
|
+
initialize(): Promise<void>;
|
|
13
|
+
private claim;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
settings(): Promise<ConnectionSettings>;
|
|
16
|
+
saveSettings(value: ConnectionSettings): Promise<void>;
|
|
17
|
+
tasks(): Promise<DelegatedTask[]>;
|
|
18
|
+
saveTasks(tasks: DelegatedTask[]): Promise<void>;
|
|
19
|
+
private write;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/connection/store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAejE,MAAM,WAAW,kBAAkB;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACjG,qBAAa,eAAe;IAGd,QAAQ,CAAC,SAAS,EAAE,MAAM;IAFtC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,KAAK,CAAiB;gBACT,SAAS,EAAE,MAAM;IAChC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAwBnB,KAAK;IAIb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,QAAQ,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAgBvC,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,KAAK,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAUjC,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YACxC,KAAK;CAapB"}
|