@thinkwell/acp 0.5.5 → 0.5.6
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/connection.d.ts.map +1 -1
- package/dist/connection.js +184 -263
- package/dist/connection.js.map +1 -1
- package/dist/generated/features.d.ts +5 -0
- package/dist/generated/features.d.ts.map +1 -0
- package/dist/generated/features.js +4 -0
- package/dist/generated/features.js.map +1 -0
- package/dist/index.js +0 -7
- package/dist/json.js +0 -1
- package/dist/mcp-over-acp-handler.d.ts +3 -8
- package/dist/mcp-over-acp-handler.d.ts.map +1 -1
- package/dist/mcp-over-acp-handler.js +136 -180
- package/dist/mcp-over-acp-handler.js.map +1 -1
- package/dist/mcp-server.js +119 -143
- package/dist/session.js +113 -159
- package/dist/skill-server.js +54 -89
- package/dist/skill.js +41 -107
- package/dist/types.js +0 -7
- package/package.json +6 -5
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGpB,KAAK,mBAAmB,EAKxB,KAAK,cAAc,EAIpB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGpB,KAAK,mBAAmB,EAKxB,KAAK,cAAc,EAIpB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,SAAS,EAMV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAoBlD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC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,CAAC,cAAc,CAAC,CA6CzB;AAoCD;;GAEG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc,CAElE;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/connection.js
CHANGED
|
@@ -1,282 +1,203 @@
|
|
|
1
|
-
import { ClientSideConnection
|
|
2
|
-
import {
|
|
1
|
+
import { ClientSideConnection } from "@agentclientprotocol/sdk";
|
|
2
|
+
import { features } from "./generated/features.js";
|
|
3
|
+
import { appendFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { Conductor, fromCommands, createChannelPair } from "@thinkwell/conductor";
|
|
3
6
|
import { McpOverAcpHandler } from "./mcp-over-acp-handler.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
7
|
+
function logPermission(request, response) {
|
|
8
|
+
const logDir = process.env.THINKWELL_LOG_DIR ?? process.cwd(), logPath = join(logDir, "permissions.ndjson"), record = {
|
|
9
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10
|
+
request,
|
|
11
|
+
response
|
|
12
|
+
};
|
|
13
|
+
appendFileSync(logPath, JSON.stringify(record) + `
|
|
14
|
+
`);
|
|
15
|
+
}
|
|
14
16
|
export class SacpConnection {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
17
|
+
_cleanup;
|
|
18
|
+
_connection;
|
|
19
|
+
_mcpHandler;
|
|
20
|
+
_sessionHandlers = /* @__PURE__ */ new Map();
|
|
21
|
+
_initialized = !1;
|
|
22
|
+
constructor(cleanup, connection, mcpHandler) {
|
|
23
|
+
this._cleanup = cleanup, this._connection = connection, this._mcpHandler = mcpHandler;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the MCP handler for registering servers
|
|
27
|
+
*/
|
|
28
|
+
get mcpHandler() {
|
|
29
|
+
return this._mcpHandler;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the connection (negotiate protocol version and capabilities)
|
|
33
|
+
*/
|
|
34
|
+
async initialize() {
|
|
35
|
+
this._initialized || (await this._connection.initialize({
|
|
36
|
+
protocolVersion: 1,
|
|
37
|
+
clientCapabilities: {}
|
|
38
|
+
}), this._initialized = !0);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a new session
|
|
42
|
+
*/
|
|
43
|
+
async createSession(options) {
|
|
44
|
+
await this.initialize();
|
|
45
|
+
const mcpServers = (options.mcpServers ?? []).map((s) => ({
|
|
46
|
+
type: "http",
|
|
47
|
+
name: s.name,
|
|
48
|
+
url: s.url,
|
|
49
|
+
headers: []
|
|
50
|
+
})), request = {
|
|
51
|
+
cwd: options.cwd ?? process.cwd(),
|
|
52
|
+
mcpServers
|
|
53
|
+
};
|
|
54
|
+
return (await this._connection.newSession(request)).sessionId;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Send a prompt to an existing session
|
|
58
|
+
*/
|
|
59
|
+
async sendPrompt(sessionId, content) {
|
|
60
|
+
const request = {
|
|
61
|
+
sessionId,
|
|
62
|
+
prompt: [{ type: "text", text: content }]
|
|
63
|
+
};
|
|
64
|
+
return this._connection.prompt(request);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Set the handler for session updates
|
|
68
|
+
*/
|
|
69
|
+
setSessionHandler(sessionId, handler) {
|
|
70
|
+
this._sessionHandlers.set(sessionId, handler);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Remove the handler for session updates
|
|
74
|
+
*/
|
|
75
|
+
removeSessionHandler(sessionId) {
|
|
76
|
+
this._sessionHandlers.delete(sessionId);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Handle a session update notification from the agent
|
|
80
|
+
*/
|
|
81
|
+
handleSessionUpdate(notification) {
|
|
82
|
+
const { sessionId } = notification, handler = this._sessionHandlers.get(sessionId);
|
|
83
|
+
if (!handler) {
|
|
84
|
+
console.error(`No handler for session: ${sessionId}`);
|
|
85
|
+
return;
|
|
61
86
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
const update = this._convertNotification(notification);
|
|
88
|
+
update && handler.pushUpdate(update);
|
|
89
|
+
}
|
|
90
|
+
_convertNotification(notification) {
|
|
91
|
+
const { update } = notification;
|
|
92
|
+
switch (update.sessionUpdate) {
|
|
93
|
+
case "agent_message_chunk":
|
|
94
|
+
case "user_message_chunk":
|
|
95
|
+
case "agent_thought_chunk": {
|
|
96
|
+
const content = update.content;
|
|
97
|
+
if (content.type === "text")
|
|
98
|
+
return { type: "text", content: content.text };
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "tool_call":
|
|
102
|
+
return {
|
|
103
|
+
type: "tool_use",
|
|
104
|
+
id: update.toolCallId,
|
|
105
|
+
name: update.title,
|
|
106
|
+
input: update.rawInput ?? {}
|
|
69
107
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Remove the handler for session updates
|
|
80
|
-
*/
|
|
81
|
-
removeSessionHandler(sessionId) {
|
|
82
|
-
this._sessionHandlers.delete(sessionId);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Handle a session update notification from the agent
|
|
86
|
-
*/
|
|
87
|
-
handleSessionUpdate(notification) {
|
|
88
|
-
const { sessionId } = notification;
|
|
89
|
-
const handler = this._sessionHandlers.get(sessionId);
|
|
90
|
-
if (!handler) {
|
|
91
|
-
console.error(`No handler for session: ${sessionId}`);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
// Convert ACP notification to our SessionUpdate type
|
|
95
|
-
const update = this._convertNotification(notification);
|
|
96
|
-
if (update) {
|
|
97
|
-
handler.pushUpdate(update);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
_convertNotification(notification) {
|
|
101
|
-
const { update } = notification;
|
|
102
|
-
// Use the sessionUpdate discriminator to determine type
|
|
103
|
-
switch (update.sessionUpdate) {
|
|
104
|
-
case "agent_message_chunk":
|
|
105
|
-
case "user_message_chunk":
|
|
106
|
-
case "agent_thought_chunk": {
|
|
107
|
-
const content = update.content;
|
|
108
|
-
if (content.type === "text") {
|
|
109
|
-
return { type: "text", content: content.text };
|
|
110
|
-
}
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
case "tool_call": {
|
|
114
|
-
return {
|
|
115
|
-
type: "tool_use",
|
|
116
|
-
id: update.toolCallId,
|
|
117
|
-
name: update.title,
|
|
118
|
-
input: update.rawInput ?? {},
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
case "plan":
|
|
122
|
-
case "tool_call_update":
|
|
123
|
-
case "available_commands_update":
|
|
124
|
-
case "current_mode_update":
|
|
125
|
-
// These are informational updates we don't need to handle
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Close the connection
|
|
132
|
-
*/
|
|
133
|
-
close() {
|
|
134
|
-
this._cleanup();
|
|
108
|
+
case "plan":
|
|
109
|
+
case "tool_call_update":
|
|
110
|
+
case "available_commands_update":
|
|
111
|
+
case "current_mode_update":
|
|
112
|
+
case "config_option_update":
|
|
113
|
+
case "session_info_update":
|
|
114
|
+
case "usage_update":
|
|
115
|
+
break;
|
|
135
116
|
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Close the connection
|
|
121
|
+
*/
|
|
122
|
+
close() {
|
|
123
|
+
this._cleanup();
|
|
124
|
+
}
|
|
136
125
|
}
|
|
137
|
-
/**
|
|
138
|
-
* Create a Client implementation that handles incoming agent requests
|
|
139
|
-
*/
|
|
140
126
|
function createClient(connectionHolder, mcpHandler) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return result ?? {};
|
|
168
|
-
}
|
|
169
|
-
throw new Error(`Unknown extension method: ${method}`);
|
|
170
|
-
},
|
|
171
|
-
// Extension notification handler
|
|
172
|
-
async extNotification(method, params) {
|
|
173
|
-
if (mcpHandler.isMcpRequest(method)) {
|
|
174
|
-
await mcpHandler.routeRequest(method, params);
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
};
|
|
127
|
+
return {
|
|
128
|
+
// Required: Handle session updates from the agent
|
|
129
|
+
sessionUpdate(notification) {
|
|
130
|
+
return connectionHolder.connection ? (connectionHolder.connection.handleSessionUpdate(notification), Promise.resolve()) : (console.error("Connection not yet initialized, dropping session update"), Promise.resolve());
|
|
131
|
+
},
|
|
132
|
+
// Required: Handle permission requests
|
|
133
|
+
requestPermission(request) {
|
|
134
|
+
const response = {
|
|
135
|
+
outcome: {
|
|
136
|
+
outcome: "selected",
|
|
137
|
+
optionId: request.options[0]?.optionId ?? "approve"
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
return features.LOG_PERMISSIONS && logPermission(request, response), Promise.resolve(response);
|
|
141
|
+
},
|
|
142
|
+
// Extension method handler for _mcp/* requests
|
|
143
|
+
async extMethod(method, params) {
|
|
144
|
+
if (mcpHandler.isMcpRequest(method))
|
|
145
|
+
return await mcpHandler.routeRequest(method, params) ?? {};
|
|
146
|
+
throw new Error(`Unknown extension method: ${method}`);
|
|
147
|
+
},
|
|
148
|
+
// Extension notification handler
|
|
149
|
+
async extNotification(method, params) {
|
|
150
|
+
mcpHandler.isMcpRequest(method) && await mcpHandler.routeRequest(method, params);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
178
153
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Connect to an agent via the TypeScript conductor.
|
|
181
|
-
*
|
|
182
|
-
* This creates an in-process conductor that spawns the specified agent command
|
|
183
|
-
* as a subprocess and routes ACP messages through it.
|
|
184
|
-
*
|
|
185
|
-
* @param command - The agent command to run (e.g., ["claude-code-agent"])
|
|
186
|
-
* @returns A SacpConnection for communicating with the agent
|
|
187
|
-
*/
|
|
188
154
|
export async function connect(command) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
return connectToConductor(conductor);
|
|
155
|
+
if (command.length === 0)
|
|
156
|
+
throw new Error("Agent command cannot be empty");
|
|
157
|
+
const conductor = new Conductor({
|
|
158
|
+
instantiator: fromCommands(command)
|
|
159
|
+
});
|
|
160
|
+
return connectToConductor(conductor);
|
|
197
161
|
}
|
|
198
|
-
/**
|
|
199
|
-
* Connect to an in-process conductor.
|
|
200
|
-
*
|
|
201
|
-
* This runs the conductor in the same process, avoiding subprocess overhead.
|
|
202
|
-
* The conductor will manage components (proxies and agent) according to its
|
|
203
|
-
* configured instantiator.
|
|
204
|
-
*
|
|
205
|
-
* @param conductor - The configured Conductor instance to connect to
|
|
206
|
-
* @returns A SacpConnection wrapping the in-process conductor
|
|
207
|
-
*/
|
|
208
162
|
export async function connectToConductor(conductor) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const clientConnector = {
|
|
221
|
-
async connect() {
|
|
222
|
-
return pair.right;
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
// Start the conductor's message loop in the background
|
|
226
|
-
const conductorPromise = conductor.connect(clientConnector);
|
|
227
|
-
// Handle conductor errors/completion
|
|
228
|
-
conductorPromise.catch((error) => {
|
|
229
|
-
console.error("Conductor error:", error);
|
|
163
|
+
const pair = createChannelPair(), stream = componentConnectionToStream(pair.left), mcpHandler = new McpOverAcpHandler(), connectionHolder = { connection: null }, clientConnection = new ClientSideConnection((_agent) => createClient(connectionHolder, mcpHandler), stream), clientConnector = {
|
|
164
|
+
async connect() {
|
|
165
|
+
return pair.right;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
conductor.connect(clientConnector).catch((error) => {
|
|
169
|
+
console.error("Conductor error:", error);
|
|
170
|
+
});
|
|
171
|
+
const cleanup = () => {
|
|
172
|
+
conductor.shutdown().catch((error) => {
|
|
173
|
+
console.error("Conductor shutdown error:", error);
|
|
230
174
|
});
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
conductor.shutdown().catch((error) => {
|
|
234
|
-
console.error("Conductor shutdown error:", error);
|
|
235
|
-
});
|
|
236
|
-
};
|
|
237
|
-
const sacpConnection = new SacpConnection(cleanup, clientConnection, mcpHandler);
|
|
238
|
-
connectionHolder.connection = sacpConnection;
|
|
239
|
-
return sacpConnection;
|
|
175
|
+
}, sacpConnection = new SacpConnection(cleanup, clientConnection, mcpHandler);
|
|
176
|
+
return connectionHolder.connection = sacpConnection, sacpConnection;
|
|
240
177
|
}
|
|
241
|
-
/**
|
|
242
|
-
* Convert a ComponentConnection to the SDK's Stream interface.
|
|
243
|
-
*
|
|
244
|
-
* The SDK expects Web Streams of AnyMessage objects, while the conductor
|
|
245
|
-
* uses a simpler send/messages interface.
|
|
246
|
-
*/
|
|
247
178
|
function componentConnectionToStream(connection) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
close() {
|
|
268
|
-
connection.close();
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
|
-
return { readable, writable };
|
|
179
|
+
const readable = new ReadableStream({
|
|
180
|
+
async start(controller) {
|
|
181
|
+
try {
|
|
182
|
+
for await (const message of connection.messages)
|
|
183
|
+
controller.enqueue(message);
|
|
184
|
+
controller.close();
|
|
185
|
+
} catch (error) {
|
|
186
|
+
controller.error(error);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}), writable = new WritableStream({
|
|
190
|
+
write(message) {
|
|
191
|
+
connection.send(message);
|
|
192
|
+
},
|
|
193
|
+
close() {
|
|
194
|
+
connection.close();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return { readable, writable };
|
|
272
198
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Create a session builder for this connection
|
|
275
|
-
*/
|
|
276
199
|
export function session(connection) {
|
|
277
|
-
|
|
200
|
+
return new SessionBuilder(connection, connection.mcpHandler);
|
|
278
201
|
}
|
|
279
|
-
// Re-export for convenience
|
|
280
202
|
import { SessionBuilder } from "./session.js";
|
|
281
203
|
export { SessionBuilder };
|
|
282
|
-
//# sourceMappingURL=connection.js.map
|
package/dist/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAYrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,GAIlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAYrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,GAIlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;;GAGG;AACH,SAAS,aAAa,CACpB,OAAiC,EACjC,QAAmC;IAEnC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,OAAO;QACP,QAAQ;KACT,CAAC;I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,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/generated/features.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,QAAQ;;;CAGX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/generated/features.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,KAAK;CACnB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
// MCP Server
|
|
2
1
|
export { McpServer, McpServerBuilder, mcpServer } from "./mcp-server.js";
|
|
3
|
-
// MCP-over-ACP Handler
|
|
4
2
|
export { McpOverAcpHandler } from "./mcp-over-acp-handler.js";
|
|
5
|
-
// Session
|
|
6
3
|
export { ActiveSession, SessionBuilder } from "./session.js";
|
|
7
|
-
// Connection
|
|
8
4
|
export { SacpConnection, connect, connectToConductor } from "./connection.js";
|
|
9
|
-
// Skills
|
|
10
5
|
export { parseSkillMd, validateSkillName, validateSkillDescription } from "./skill.js";
|
|
11
|
-
// Skill MCP Server
|
|
12
6
|
export { createSkillServer } from "./skill-server.js";
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
package/dist/json.js
CHANGED
|
@@ -4,12 +4,9 @@ import type { McpConnectResponse } from "./types.js";
|
|
|
4
4
|
* Handler for MCP-over-ACP protocol messages.
|
|
5
5
|
*
|
|
6
6
|
* This class manages the lifecycle of MCP connections tunneled through ACP:
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
* Note: The ACP SDK strips the underscore prefix from extension methods,
|
|
12
|
-
* so we receive "mcp/connect" even though the wire format is "_mcp/connect".
|
|
7
|
+
* - _mcp/connect: Establishes a new MCP connection
|
|
8
|
+
* - _mcp/message: Routes MCP requests to the appropriate server
|
|
9
|
+
* - _mcp/disconnect: Tears down an MCP connection
|
|
13
10
|
*/
|
|
14
11
|
export declare class McpOverAcpHandler {
|
|
15
12
|
/** Maps acp:uuid URLs to registered MCP servers */
|
|
@@ -65,12 +62,10 @@ export declare class McpOverAcpHandler {
|
|
|
65
62
|
handleDisconnect(params: Record<string, unknown>): void;
|
|
66
63
|
/**
|
|
67
64
|
* Check if this is an MCP-over-ACP request.
|
|
68
|
-
* Note: The ACP SDK strips the underscore prefix, so we check for "mcp/".
|
|
69
65
|
*/
|
|
70
66
|
isMcpRequest(method: string): boolean;
|
|
71
67
|
/**
|
|
72
68
|
* Route an MCP-over-ACP request to the appropriate handler.
|
|
73
|
-
* Note: Methods arrive without the underscore prefix (e.g., "mcp/connect" not "_mcp/connect").
|
|
74
69
|
*/
|
|
75
70
|
routeRequest(method: string, params: Record<string, unknown>): Promise<unknown>;
|
|
76
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-over-acp-handler.d.ts","sourceRoot":"","sources":["../src/mcp-over-acp-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAEV,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAmBpB
|
|
1
|
+
{"version":3,"file":"mcp-over-acp-handler.d.ts","sourceRoot":"","sources":["../src/mcp-over-acp-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAEV,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAmBpB;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC5B,mDAAmD;IACnD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqC;IACnE,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,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