@github/copilot-sdk 0.2.1-preview.1 → 0.2.1-unstable.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/README.md +41 -2
- package/dist/cjs/client.js +85 -9
- package/dist/cjs/generated/rpc.js +69 -3
- package/dist/cjs/session.js +53 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.js +86 -10
- package/dist/generated/rpc.d.ts +419 -2
- package/dist/generated/rpc.js +67 -2
- package/dist/generated/session-events.d.ts +135 -6
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +18 -1
- package/dist/session.js +53 -0
- package/dist/types.d.ts +63 -2
- package/package.json +3 -2
package/dist/generated/rpc.d.ts
CHANGED
|
@@ -171,6 +171,165 @@ export interface AccountGetQuotaResult {
|
|
|
171
171
|
};
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
+
export interface McpConfigListResult {
|
|
175
|
+
/**
|
|
176
|
+
* All MCP servers from user config, keyed by name
|
|
177
|
+
*/
|
|
178
|
+
servers: {
|
|
179
|
+
/**
|
|
180
|
+
* MCP server configuration (local/stdio or remote/http)
|
|
181
|
+
*/
|
|
182
|
+
[k: string]: {
|
|
183
|
+
/**
|
|
184
|
+
* Tools to include. Defaults to all tools if not specified.
|
|
185
|
+
*/
|
|
186
|
+
tools?: string[];
|
|
187
|
+
type?: "local" | "stdio";
|
|
188
|
+
isDefaultServer?: boolean;
|
|
189
|
+
filterMapping?: {
|
|
190
|
+
[k: string]: "none" | "markdown" | "hidden_characters";
|
|
191
|
+
} | ("none" | "markdown" | "hidden_characters");
|
|
192
|
+
timeout?: number;
|
|
193
|
+
command: string;
|
|
194
|
+
args: string[];
|
|
195
|
+
cwd?: string;
|
|
196
|
+
env?: {
|
|
197
|
+
[k: string]: string;
|
|
198
|
+
};
|
|
199
|
+
} | {
|
|
200
|
+
/**
|
|
201
|
+
* Tools to include. Defaults to all tools if not specified.
|
|
202
|
+
*/
|
|
203
|
+
tools?: string[];
|
|
204
|
+
type: "http" | "sse";
|
|
205
|
+
isDefaultServer?: boolean;
|
|
206
|
+
filterMapping?: {
|
|
207
|
+
[k: string]: "none" | "markdown" | "hidden_characters";
|
|
208
|
+
} | ("none" | "markdown" | "hidden_characters");
|
|
209
|
+
timeout?: number;
|
|
210
|
+
url: string;
|
|
211
|
+
headers?: {
|
|
212
|
+
[k: string]: string;
|
|
213
|
+
};
|
|
214
|
+
oauthClientId?: string;
|
|
215
|
+
oauthPublicClient?: boolean;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
export interface McpConfigAddParams {
|
|
220
|
+
/**
|
|
221
|
+
* Unique name for the MCP server
|
|
222
|
+
*/
|
|
223
|
+
name: string;
|
|
224
|
+
/**
|
|
225
|
+
* MCP server configuration (local/stdio or remote/http)
|
|
226
|
+
*/
|
|
227
|
+
config: {
|
|
228
|
+
/**
|
|
229
|
+
* Tools to include. Defaults to all tools if not specified.
|
|
230
|
+
*/
|
|
231
|
+
tools?: string[];
|
|
232
|
+
type?: "local" | "stdio";
|
|
233
|
+
isDefaultServer?: boolean;
|
|
234
|
+
filterMapping?: {
|
|
235
|
+
[k: string]: "none" | "markdown" | "hidden_characters";
|
|
236
|
+
} | ("none" | "markdown" | "hidden_characters");
|
|
237
|
+
timeout?: number;
|
|
238
|
+
command: string;
|
|
239
|
+
args: string[];
|
|
240
|
+
cwd?: string;
|
|
241
|
+
env?: {
|
|
242
|
+
[k: string]: string;
|
|
243
|
+
};
|
|
244
|
+
} | {
|
|
245
|
+
/**
|
|
246
|
+
* Tools to include. Defaults to all tools if not specified.
|
|
247
|
+
*/
|
|
248
|
+
tools?: string[];
|
|
249
|
+
type: "http" | "sse";
|
|
250
|
+
isDefaultServer?: boolean;
|
|
251
|
+
filterMapping?: {
|
|
252
|
+
[k: string]: "none" | "markdown" | "hidden_characters";
|
|
253
|
+
} | ("none" | "markdown" | "hidden_characters");
|
|
254
|
+
timeout?: number;
|
|
255
|
+
url: string;
|
|
256
|
+
headers?: {
|
|
257
|
+
[k: string]: string;
|
|
258
|
+
};
|
|
259
|
+
oauthClientId?: string;
|
|
260
|
+
oauthPublicClient?: boolean;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
export interface McpConfigUpdateParams {
|
|
264
|
+
/**
|
|
265
|
+
* Name of the MCP server to update
|
|
266
|
+
*/
|
|
267
|
+
name: string;
|
|
268
|
+
/**
|
|
269
|
+
* MCP server configuration (local/stdio or remote/http)
|
|
270
|
+
*/
|
|
271
|
+
config: {
|
|
272
|
+
/**
|
|
273
|
+
* Tools to include. Defaults to all tools if not specified.
|
|
274
|
+
*/
|
|
275
|
+
tools?: string[];
|
|
276
|
+
type?: "local" | "stdio";
|
|
277
|
+
isDefaultServer?: boolean;
|
|
278
|
+
filterMapping?: {
|
|
279
|
+
[k: string]: "none" | "markdown" | "hidden_characters";
|
|
280
|
+
} | ("none" | "markdown" | "hidden_characters");
|
|
281
|
+
timeout?: number;
|
|
282
|
+
command: string;
|
|
283
|
+
args: string[];
|
|
284
|
+
cwd?: string;
|
|
285
|
+
env?: {
|
|
286
|
+
[k: string]: string;
|
|
287
|
+
};
|
|
288
|
+
} | {
|
|
289
|
+
/**
|
|
290
|
+
* Tools to include. Defaults to all tools if not specified.
|
|
291
|
+
*/
|
|
292
|
+
tools?: string[];
|
|
293
|
+
type: "http" | "sse";
|
|
294
|
+
isDefaultServer?: boolean;
|
|
295
|
+
filterMapping?: {
|
|
296
|
+
[k: string]: "none" | "markdown" | "hidden_characters";
|
|
297
|
+
} | ("none" | "markdown" | "hidden_characters");
|
|
298
|
+
timeout?: number;
|
|
299
|
+
url: string;
|
|
300
|
+
headers?: {
|
|
301
|
+
[k: string]: string;
|
|
302
|
+
};
|
|
303
|
+
oauthClientId?: string;
|
|
304
|
+
oauthPublicClient?: boolean;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
export interface McpConfigRemoveParams {
|
|
308
|
+
/**
|
|
309
|
+
* Name of the MCP server to remove
|
|
310
|
+
*/
|
|
311
|
+
name: string;
|
|
312
|
+
}
|
|
313
|
+
export interface SessionFsSetProviderResult {
|
|
314
|
+
/**
|
|
315
|
+
* Whether the provider was set successfully
|
|
316
|
+
*/
|
|
317
|
+
success: boolean;
|
|
318
|
+
}
|
|
319
|
+
export interface SessionFsSetProviderParams {
|
|
320
|
+
/**
|
|
321
|
+
* Initial working directory for sessions
|
|
322
|
+
*/
|
|
323
|
+
initialCwd: string;
|
|
324
|
+
/**
|
|
325
|
+
* Path within each session's SessionFs where the runtime stores files for that session
|
|
326
|
+
*/
|
|
327
|
+
sessionStatePath: string;
|
|
328
|
+
/**
|
|
329
|
+
* Path conventions used by this filesystem
|
|
330
|
+
*/
|
|
331
|
+
conventions: "windows" | "posix";
|
|
332
|
+
}
|
|
174
333
|
export interface SessionModelGetCurrentResult {
|
|
175
334
|
/**
|
|
176
335
|
* Currently active model identifier
|
|
@@ -543,9 +702,9 @@ export interface SessionMcpListResult {
|
|
|
543
702
|
*/
|
|
544
703
|
name: string;
|
|
545
704
|
/**
|
|
546
|
-
* Connection status: connected, failed, pending, disabled, or not_configured
|
|
705
|
+
* Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
|
|
547
706
|
*/
|
|
548
|
-
status: "connected" | "failed" | "pending" | "disabled" | "not_configured";
|
|
707
|
+
status: "connected" | "failed" | "needs-auth" | "pending" | "disabled" | "not_configured";
|
|
549
708
|
/**
|
|
550
709
|
* Configuration source: user, workspace, plugin, or builtin
|
|
551
710
|
*/
|
|
@@ -867,6 +1026,37 @@ export interface SessionUiElicitationParams {
|
|
|
867
1026
|
required?: string[];
|
|
868
1027
|
};
|
|
869
1028
|
}
|
|
1029
|
+
export interface SessionUiHandlePendingElicitationResult {
|
|
1030
|
+
/**
|
|
1031
|
+
* Whether the response was accepted. False if the request was already resolved by another client.
|
|
1032
|
+
*/
|
|
1033
|
+
success: boolean;
|
|
1034
|
+
}
|
|
1035
|
+
export interface SessionUiHandlePendingElicitationParams {
|
|
1036
|
+
/**
|
|
1037
|
+
* Target session identifier
|
|
1038
|
+
*/
|
|
1039
|
+
sessionId: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* The unique request ID from the elicitation.requested event
|
|
1042
|
+
*/
|
|
1043
|
+
requestId: string;
|
|
1044
|
+
/**
|
|
1045
|
+
* The elicitation response (accept with form values, decline, or cancel)
|
|
1046
|
+
*/
|
|
1047
|
+
result: {
|
|
1048
|
+
/**
|
|
1049
|
+
* The user's response: accept (submitted), decline (rejected), or cancel (dismissed)
|
|
1050
|
+
*/
|
|
1051
|
+
action: "accept" | "decline" | "cancel";
|
|
1052
|
+
/**
|
|
1053
|
+
* The form values submitted by the user (present when action is 'accept')
|
|
1054
|
+
*/
|
|
1055
|
+
content?: {
|
|
1056
|
+
[k: string]: string | number | boolean | string[];
|
|
1057
|
+
};
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
870
1060
|
export interface SessionPermissionsHandlePendingPermissionRequestResult {
|
|
871
1061
|
/**
|
|
872
1062
|
* Whether the permission request was handled successfully
|
|
@@ -967,6 +1157,197 @@ export interface SessionShellKillParams {
|
|
|
967
1157
|
*/
|
|
968
1158
|
signal?: "SIGTERM" | "SIGKILL" | "SIGINT";
|
|
969
1159
|
}
|
|
1160
|
+
export interface SessionFsReadFileResult {
|
|
1161
|
+
/**
|
|
1162
|
+
* File content as UTF-8 string
|
|
1163
|
+
*/
|
|
1164
|
+
content: string;
|
|
1165
|
+
}
|
|
1166
|
+
export interface SessionFsReadFileParams {
|
|
1167
|
+
/**
|
|
1168
|
+
* Target session identifier
|
|
1169
|
+
*/
|
|
1170
|
+
sessionId: string;
|
|
1171
|
+
/**
|
|
1172
|
+
* Path using SessionFs conventions
|
|
1173
|
+
*/
|
|
1174
|
+
path: string;
|
|
1175
|
+
}
|
|
1176
|
+
export interface SessionFsWriteFileParams {
|
|
1177
|
+
/**
|
|
1178
|
+
* Target session identifier
|
|
1179
|
+
*/
|
|
1180
|
+
sessionId: string;
|
|
1181
|
+
/**
|
|
1182
|
+
* Path using SessionFs conventions
|
|
1183
|
+
*/
|
|
1184
|
+
path: string;
|
|
1185
|
+
/**
|
|
1186
|
+
* Content to write
|
|
1187
|
+
*/
|
|
1188
|
+
content: string;
|
|
1189
|
+
/**
|
|
1190
|
+
* Optional POSIX-style mode for newly created files
|
|
1191
|
+
*/
|
|
1192
|
+
mode?: number;
|
|
1193
|
+
}
|
|
1194
|
+
export interface SessionFsAppendFileParams {
|
|
1195
|
+
/**
|
|
1196
|
+
* Target session identifier
|
|
1197
|
+
*/
|
|
1198
|
+
sessionId: string;
|
|
1199
|
+
/**
|
|
1200
|
+
* Path using SessionFs conventions
|
|
1201
|
+
*/
|
|
1202
|
+
path: string;
|
|
1203
|
+
/**
|
|
1204
|
+
* Content to append
|
|
1205
|
+
*/
|
|
1206
|
+
content: string;
|
|
1207
|
+
/**
|
|
1208
|
+
* Optional POSIX-style mode for newly created files
|
|
1209
|
+
*/
|
|
1210
|
+
mode?: number;
|
|
1211
|
+
}
|
|
1212
|
+
export interface SessionFsExistsResult {
|
|
1213
|
+
/**
|
|
1214
|
+
* Whether the path exists
|
|
1215
|
+
*/
|
|
1216
|
+
exists: boolean;
|
|
1217
|
+
}
|
|
1218
|
+
export interface SessionFsExistsParams {
|
|
1219
|
+
/**
|
|
1220
|
+
* Target session identifier
|
|
1221
|
+
*/
|
|
1222
|
+
sessionId: string;
|
|
1223
|
+
/**
|
|
1224
|
+
* Path using SessionFs conventions
|
|
1225
|
+
*/
|
|
1226
|
+
path: string;
|
|
1227
|
+
}
|
|
1228
|
+
export interface SessionFsStatResult {
|
|
1229
|
+
/**
|
|
1230
|
+
* Whether the path is a file
|
|
1231
|
+
*/
|
|
1232
|
+
isFile: boolean;
|
|
1233
|
+
/**
|
|
1234
|
+
* Whether the path is a directory
|
|
1235
|
+
*/
|
|
1236
|
+
isDirectory: boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* File size in bytes
|
|
1239
|
+
*/
|
|
1240
|
+
size: number;
|
|
1241
|
+
/**
|
|
1242
|
+
* ISO 8601 timestamp of last modification
|
|
1243
|
+
*/
|
|
1244
|
+
mtime: string;
|
|
1245
|
+
/**
|
|
1246
|
+
* ISO 8601 timestamp of creation
|
|
1247
|
+
*/
|
|
1248
|
+
birthtime: string;
|
|
1249
|
+
}
|
|
1250
|
+
export interface SessionFsStatParams {
|
|
1251
|
+
/**
|
|
1252
|
+
* Target session identifier
|
|
1253
|
+
*/
|
|
1254
|
+
sessionId: string;
|
|
1255
|
+
/**
|
|
1256
|
+
* Path using SessionFs conventions
|
|
1257
|
+
*/
|
|
1258
|
+
path: string;
|
|
1259
|
+
}
|
|
1260
|
+
export interface SessionFsMkdirParams {
|
|
1261
|
+
/**
|
|
1262
|
+
* Target session identifier
|
|
1263
|
+
*/
|
|
1264
|
+
sessionId: string;
|
|
1265
|
+
/**
|
|
1266
|
+
* Path using SessionFs conventions
|
|
1267
|
+
*/
|
|
1268
|
+
path: string;
|
|
1269
|
+
/**
|
|
1270
|
+
* Create parent directories as needed
|
|
1271
|
+
*/
|
|
1272
|
+
recursive?: boolean;
|
|
1273
|
+
/**
|
|
1274
|
+
* Optional POSIX-style mode for newly created directories
|
|
1275
|
+
*/
|
|
1276
|
+
mode?: number;
|
|
1277
|
+
}
|
|
1278
|
+
export interface SessionFsReaddirResult {
|
|
1279
|
+
/**
|
|
1280
|
+
* Entry names in the directory
|
|
1281
|
+
*/
|
|
1282
|
+
entries: string[];
|
|
1283
|
+
}
|
|
1284
|
+
export interface SessionFsReaddirParams {
|
|
1285
|
+
/**
|
|
1286
|
+
* Target session identifier
|
|
1287
|
+
*/
|
|
1288
|
+
sessionId: string;
|
|
1289
|
+
/**
|
|
1290
|
+
* Path using SessionFs conventions
|
|
1291
|
+
*/
|
|
1292
|
+
path: string;
|
|
1293
|
+
}
|
|
1294
|
+
export interface SessionFsReaddirWithTypesResult {
|
|
1295
|
+
/**
|
|
1296
|
+
* Directory entries with type information
|
|
1297
|
+
*/
|
|
1298
|
+
entries: {
|
|
1299
|
+
/**
|
|
1300
|
+
* Entry name
|
|
1301
|
+
*/
|
|
1302
|
+
name: string;
|
|
1303
|
+
/**
|
|
1304
|
+
* Entry type
|
|
1305
|
+
*/
|
|
1306
|
+
type: "file" | "directory";
|
|
1307
|
+
}[];
|
|
1308
|
+
}
|
|
1309
|
+
export interface SessionFsReaddirWithTypesParams {
|
|
1310
|
+
/**
|
|
1311
|
+
* Target session identifier
|
|
1312
|
+
*/
|
|
1313
|
+
sessionId: string;
|
|
1314
|
+
/**
|
|
1315
|
+
* Path using SessionFs conventions
|
|
1316
|
+
*/
|
|
1317
|
+
path: string;
|
|
1318
|
+
}
|
|
1319
|
+
export interface SessionFsRmParams {
|
|
1320
|
+
/**
|
|
1321
|
+
* Target session identifier
|
|
1322
|
+
*/
|
|
1323
|
+
sessionId: string;
|
|
1324
|
+
/**
|
|
1325
|
+
* Path using SessionFs conventions
|
|
1326
|
+
*/
|
|
1327
|
+
path: string;
|
|
1328
|
+
/**
|
|
1329
|
+
* Remove directories and their contents recursively
|
|
1330
|
+
*/
|
|
1331
|
+
recursive?: boolean;
|
|
1332
|
+
/**
|
|
1333
|
+
* Ignore errors if the path does not exist
|
|
1334
|
+
*/
|
|
1335
|
+
force?: boolean;
|
|
1336
|
+
}
|
|
1337
|
+
export interface SessionFsRenameParams {
|
|
1338
|
+
/**
|
|
1339
|
+
* Target session identifier
|
|
1340
|
+
*/
|
|
1341
|
+
sessionId: string;
|
|
1342
|
+
/**
|
|
1343
|
+
* Source path using SessionFs conventions
|
|
1344
|
+
*/
|
|
1345
|
+
src: string;
|
|
1346
|
+
/**
|
|
1347
|
+
* Destination path using SessionFs conventions
|
|
1348
|
+
*/
|
|
1349
|
+
dest: string;
|
|
1350
|
+
}
|
|
970
1351
|
/** Create typed server-scoped RPC methods (no session required). */
|
|
971
1352
|
export declare function createServerRpc(connection: MessageConnection): {
|
|
972
1353
|
ping: (params: PingParams) => Promise<PingResult>;
|
|
@@ -979,6 +1360,17 @@ export declare function createServerRpc(connection: MessageConnection): {
|
|
|
979
1360
|
account: {
|
|
980
1361
|
getQuota: () => Promise<AccountGetQuotaResult>;
|
|
981
1362
|
};
|
|
1363
|
+
mcp: {
|
|
1364
|
+
config: {
|
|
1365
|
+
list: () => Promise<McpConfigListResult>;
|
|
1366
|
+
add: (params: McpConfigAddParams) => Promise<void>;
|
|
1367
|
+
update: (params: McpConfigUpdateParams) => Promise<void>;
|
|
1368
|
+
remove: (params: McpConfigRemoveParams) => Promise<void>;
|
|
1369
|
+
};
|
|
1370
|
+
};
|
|
1371
|
+
sessionFs: {
|
|
1372
|
+
setProvider: (params: SessionFsSetProviderParams) => Promise<SessionFsSetProviderResult>;
|
|
1373
|
+
};
|
|
982
1374
|
};
|
|
983
1375
|
/** Create typed session-scoped RPC methods. */
|
|
984
1376
|
export declare function createSessionRpc(connection: MessageConnection, sessionId: string): {
|
|
@@ -1049,6 +1441,7 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
|
|
|
1049
1441
|
};
|
|
1050
1442
|
ui: {
|
|
1051
1443
|
elicitation: (params: Omit<SessionUiElicitationParams, "sessionId">) => Promise<SessionUiElicitationResult>;
|
|
1444
|
+
handlePendingElicitation: (params: Omit<SessionUiHandlePendingElicitationParams, "sessionId">) => Promise<SessionUiHandlePendingElicitationResult>;
|
|
1052
1445
|
};
|
|
1053
1446
|
permissions: {
|
|
1054
1447
|
handlePendingPermissionRequest: (params: Omit<SessionPermissionsHandlePendingPermissionRequestParams, "sessionId">) => Promise<SessionPermissionsHandlePendingPermissionRequestResult>;
|
|
@@ -1059,3 +1452,27 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
|
|
|
1059
1452
|
kill: (params: Omit<SessionShellKillParams, "sessionId">) => Promise<SessionShellKillResult>;
|
|
1060
1453
|
};
|
|
1061
1454
|
};
|
|
1455
|
+
/** Handler for `sessionFs` client session API methods. */
|
|
1456
|
+
export interface SessionFsHandler {
|
|
1457
|
+
readFile(params: SessionFsReadFileParams): Promise<SessionFsReadFileResult>;
|
|
1458
|
+
writeFile(params: SessionFsWriteFileParams): Promise<void>;
|
|
1459
|
+
appendFile(params: SessionFsAppendFileParams): Promise<void>;
|
|
1460
|
+
exists(params: SessionFsExistsParams): Promise<SessionFsExistsResult>;
|
|
1461
|
+
stat(params: SessionFsStatParams): Promise<SessionFsStatResult>;
|
|
1462
|
+
mkdir(params: SessionFsMkdirParams): Promise<void>;
|
|
1463
|
+
readdir(params: SessionFsReaddirParams): Promise<SessionFsReaddirResult>;
|
|
1464
|
+
readdirWithTypes(params: SessionFsReaddirWithTypesParams): Promise<SessionFsReaddirWithTypesResult>;
|
|
1465
|
+
rm(params: SessionFsRmParams): Promise<void>;
|
|
1466
|
+
rename(params: SessionFsRenameParams): Promise<void>;
|
|
1467
|
+
}
|
|
1468
|
+
/** All client session API handler groups. */
|
|
1469
|
+
export interface ClientSessionApiHandlers {
|
|
1470
|
+
sessionFs?: SessionFsHandler;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Register client session API handlers on a JSON-RPC connection.
|
|
1474
|
+
* The server calls these methods to delegate work to the client.
|
|
1475
|
+
* Each incoming call includes a `sessionId` in the params; the registration
|
|
1476
|
+
* function uses `getHandlers` to resolve the session's handlers.
|
|
1477
|
+
*/
|
|
1478
|
+
export declare function registerClientSessionApiHandlers(connection: MessageConnection, getHandlers: (sessionId: string) => ClientSessionApiHandlers): void;
|
package/dist/generated/rpc.js
CHANGED
|
@@ -9,6 +9,17 @@ function createServerRpc(connection) {
|
|
|
9
9
|
},
|
|
10
10
|
account: {
|
|
11
11
|
getQuota: async () => connection.sendRequest("account.getQuota", {})
|
|
12
|
+
},
|
|
13
|
+
mcp: {
|
|
14
|
+
config: {
|
|
15
|
+
list: async () => connection.sendRequest("mcp.config.list", {}),
|
|
16
|
+
add: async (params) => connection.sendRequest("mcp.config.add", params),
|
|
17
|
+
update: async (params) => connection.sendRequest("mcp.config.update", params),
|
|
18
|
+
remove: async (params) => connection.sendRequest("mcp.config.remove", params)
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
sessionFs: {
|
|
22
|
+
setProvider: async (params) => connection.sendRequest("sessionFs.setProvider", params)
|
|
12
23
|
}
|
|
13
24
|
};
|
|
14
25
|
}
|
|
@@ -80,7 +91,8 @@ function createSessionRpc(connection, sessionId) {
|
|
|
80
91
|
handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params })
|
|
81
92
|
},
|
|
82
93
|
ui: {
|
|
83
|
-
elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params })
|
|
94
|
+
elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
|
|
95
|
+
handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params })
|
|
84
96
|
},
|
|
85
97
|
permissions: {
|
|
86
98
|
handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params })
|
|
@@ -92,7 +104,60 @@ function createSessionRpc(connection, sessionId) {
|
|
|
92
104
|
}
|
|
93
105
|
};
|
|
94
106
|
}
|
|
107
|
+
function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
108
|
+
connection.onRequest("sessionFs.readFile", async (params) => {
|
|
109
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
110
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
111
|
+
return handler.readFile(params);
|
|
112
|
+
});
|
|
113
|
+
connection.onRequest("sessionFs.writeFile", async (params) => {
|
|
114
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
115
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
116
|
+
return handler.writeFile(params);
|
|
117
|
+
});
|
|
118
|
+
connection.onRequest("sessionFs.appendFile", async (params) => {
|
|
119
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
120
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
121
|
+
return handler.appendFile(params);
|
|
122
|
+
});
|
|
123
|
+
connection.onRequest("sessionFs.exists", async (params) => {
|
|
124
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
125
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
126
|
+
return handler.exists(params);
|
|
127
|
+
});
|
|
128
|
+
connection.onRequest("sessionFs.stat", async (params) => {
|
|
129
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
130
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
131
|
+
return handler.stat(params);
|
|
132
|
+
});
|
|
133
|
+
connection.onRequest("sessionFs.mkdir", async (params) => {
|
|
134
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
135
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
136
|
+
return handler.mkdir(params);
|
|
137
|
+
});
|
|
138
|
+
connection.onRequest("sessionFs.readdir", async (params) => {
|
|
139
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
140
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
141
|
+
return handler.readdir(params);
|
|
142
|
+
});
|
|
143
|
+
connection.onRequest("sessionFs.readdirWithTypes", async (params) => {
|
|
144
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
145
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
146
|
+
return handler.readdirWithTypes(params);
|
|
147
|
+
});
|
|
148
|
+
connection.onRequest("sessionFs.rm", async (params) => {
|
|
149
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
150
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
151
|
+
return handler.rm(params);
|
|
152
|
+
});
|
|
153
|
+
connection.onRequest("sessionFs.rename", async (params) => {
|
|
154
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
155
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
156
|
+
return handler.rename(params);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
95
159
|
export {
|
|
96
160
|
createServerRpc,
|
|
97
|
-
createSessionRpc
|
|
161
|
+
createSessionRpc,
|
|
162
|
+
registerClientSessionApiHandlers
|
|
98
163
|
};
|