@github/copilot-sdk 0.2.1-preview.0 → 0.2.1-preview.2
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 +83 -30
- package/dist/cjs/client.js +88 -11
- package/dist/cjs/generated/rpc.js +69 -3
- package/dist/cjs/session.js +74 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.js +89 -12
- package/dist/generated/rpc.d.ts +419 -2
- package/dist/generated/rpc.js +67 -2
- package/dist/generated/session-events.d.ts +138 -5
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +18 -1
- package/dist/session.js +74 -0
- package/dist/types.d.ts +64 -3
- package/package.json +3 -2
package/dist/client.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
StreamMessageReader,
|
|
11
11
|
StreamMessageWriter
|
|
12
12
|
} from "vscode-jsonrpc/node.js";
|
|
13
|
-
import { createServerRpc } from "./generated/rpc.js";
|
|
13
|
+
import { createServerRpc, registerClientSessionApiHandlers } from "./generated/rpc.js";
|
|
14
14
|
import { getSdkProtocolVersion } from "./sdkProtocolVersion.js";
|
|
15
15
|
import { CopilotSession, NO_RESULT_PERMISSION_V2_ERROR } from "./session.js";
|
|
16
16
|
import { getTraceContext } from "./telemetry.js";
|
|
@@ -96,6 +96,8 @@ class CopilotClient {
|
|
|
96
96
|
processExitPromise = null;
|
|
97
97
|
// Rejects when CLI process exits
|
|
98
98
|
negotiatedProtocolVersion = null;
|
|
99
|
+
/** Connection-level session filesystem config, set via constructor option. */
|
|
100
|
+
sessionFsConfig = null;
|
|
99
101
|
/**
|
|
100
102
|
* Typed server-scoped RPC methods.
|
|
101
103
|
* @throws Error if the client is not connected
|
|
@@ -155,8 +157,10 @@ class CopilotClient {
|
|
|
155
157
|
}
|
|
156
158
|
this.onListModels = options.onListModels;
|
|
157
159
|
this.onGetTraceContext = options.onGetTraceContext;
|
|
160
|
+
this.sessionFsConfig = options.sessionFs ?? null;
|
|
161
|
+
const effectiveEnv = options.env ?? process.env;
|
|
158
162
|
this.options = {
|
|
159
|
-
cliPath: options.cliUrl ? void 0 : options.cliPath || getBundledCliPath(),
|
|
163
|
+
cliPath: options.cliUrl ? void 0 : options.cliPath || effectiveEnv.COPILOT_CLI_PATH || getBundledCliPath(),
|
|
160
164
|
cliArgs: options.cliArgs ?? [],
|
|
161
165
|
cwd: options.cwd ?? process.cwd(),
|
|
162
166
|
port: options.port || 0,
|
|
@@ -167,7 +171,7 @@ class CopilotClient {
|
|
|
167
171
|
logLevel: options.logLevel || "debug",
|
|
168
172
|
autoStart: options.autoStart ?? true,
|
|
169
173
|
autoRestart: false,
|
|
170
|
-
env:
|
|
174
|
+
env: effectiveEnv,
|
|
171
175
|
githubToken: options.githubToken,
|
|
172
176
|
// Default useLoggedInUser to false when githubToken is provided, otherwise true
|
|
173
177
|
useLoggedInUser: options.useLoggedInUser ?? (options.githubToken ? false : true),
|
|
@@ -225,6 +229,13 @@ class CopilotClient {
|
|
|
225
229
|
}
|
|
226
230
|
await this.connectToServer();
|
|
227
231
|
await this.verifyProtocolVersion();
|
|
232
|
+
if (this.sessionFsConfig) {
|
|
233
|
+
await this.connection.sendRequest("sessionFs.setProvider", {
|
|
234
|
+
initialCwd: this.sessionFsConfig.initialCwd,
|
|
235
|
+
sessionStatePath: this.sessionFsConfig.sessionStatePath,
|
|
236
|
+
conventions: this.sessionFsConfig.conventions
|
|
237
|
+
});
|
|
238
|
+
}
|
|
228
239
|
this.state = "connected";
|
|
229
240
|
} catch (error) {
|
|
230
241
|
this.state = "error";
|
|
@@ -436,6 +447,9 @@ class CopilotClient {
|
|
|
436
447
|
if (config.onUserInputRequest) {
|
|
437
448
|
session.registerUserInputHandler(config.onUserInputRequest);
|
|
438
449
|
}
|
|
450
|
+
if (config.onElicitationRequest) {
|
|
451
|
+
session.registerElicitationHandler(config.onElicitationRequest);
|
|
452
|
+
}
|
|
439
453
|
if (config.hooks) {
|
|
440
454
|
session.registerHooks(config.hooks);
|
|
441
455
|
}
|
|
@@ -449,6 +463,15 @@ class CopilotClient {
|
|
|
449
463
|
session.on(config.onEvent);
|
|
450
464
|
}
|
|
451
465
|
this.sessions.set(sessionId, session);
|
|
466
|
+
if (this.sessionFsConfig) {
|
|
467
|
+
if (config.createSessionFsHandler) {
|
|
468
|
+
session.clientSessionApis.sessionFs = config.createSessionFsHandler(session);
|
|
469
|
+
} else {
|
|
470
|
+
throw new Error(
|
|
471
|
+
"createSessionFsHandler is required in session config when sessionFs is enabled in client options."
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
452
475
|
try {
|
|
453
476
|
const response = await this.connection.sendRequest("session.create", {
|
|
454
477
|
...await getTraceContext(this.onGetTraceContext),
|
|
@@ -473,6 +496,7 @@ class CopilotClient {
|
|
|
473
496
|
provider: config.provider,
|
|
474
497
|
requestPermission: true,
|
|
475
498
|
requestUserInput: !!config.onUserInputRequest,
|
|
499
|
+
requestElicitation: !!config.onElicitationRequest,
|
|
476
500
|
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
|
|
477
501
|
workingDirectory: config.workingDirectory,
|
|
478
502
|
streaming: config.streaming,
|
|
@@ -543,6 +567,9 @@ class CopilotClient {
|
|
|
543
567
|
if (config.onUserInputRequest) {
|
|
544
568
|
session.registerUserInputHandler(config.onUserInputRequest);
|
|
545
569
|
}
|
|
570
|
+
if (config.onElicitationRequest) {
|
|
571
|
+
session.registerElicitationHandler(config.onElicitationRequest);
|
|
572
|
+
}
|
|
546
573
|
if (config.hooks) {
|
|
547
574
|
session.registerHooks(config.hooks);
|
|
548
575
|
}
|
|
@@ -556,6 +583,15 @@ class CopilotClient {
|
|
|
556
583
|
session.on(config.onEvent);
|
|
557
584
|
}
|
|
558
585
|
this.sessions.set(sessionId, session);
|
|
586
|
+
if (this.sessionFsConfig) {
|
|
587
|
+
if (config.createSessionFsHandler) {
|
|
588
|
+
session.clientSessionApis.sessionFs = config.createSessionFsHandler(session);
|
|
589
|
+
} else {
|
|
590
|
+
throw new Error(
|
|
591
|
+
"createSessionFsHandler is required in session config when sessionFs is enabled in client options."
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
559
595
|
try {
|
|
560
596
|
const response = await this.connection.sendRequest("session.resume", {
|
|
561
597
|
...await getTraceContext(this.onGetTraceContext),
|
|
@@ -580,6 +616,7 @@ class CopilotClient {
|
|
|
580
616
|
provider: config.provider,
|
|
581
617
|
requestPermission: true,
|
|
582
618
|
requestUserInput: !!config.onUserInputRequest,
|
|
619
|
+
requestElicitation: !!config.onElicitationRequest,
|
|
583
620
|
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
|
|
584
621
|
workingDirectory: config.workingDirectory,
|
|
585
622
|
configDir: config.configDir,
|
|
@@ -791,16 +828,50 @@ class CopilotClient {
|
|
|
791
828
|
if (!this.connection) {
|
|
792
829
|
throw new Error("Client not connected");
|
|
793
830
|
}
|
|
794
|
-
const response = await this.connection.sendRequest("session.list", {
|
|
831
|
+
const response = await this.connection.sendRequest("session.list", {
|
|
832
|
+
filter
|
|
833
|
+
});
|
|
795
834
|
const { sessions } = response;
|
|
796
|
-
return sessions.map(
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
835
|
+
return sessions.map(CopilotClient.toSessionMetadata);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Gets metadata for a specific session by ID.
|
|
839
|
+
*
|
|
840
|
+
* This provides an efficient O(1) lookup of a single session's metadata
|
|
841
|
+
* instead of listing all sessions. Returns undefined if the session is not found.
|
|
842
|
+
*
|
|
843
|
+
* @param sessionId - The ID of the session to look up
|
|
844
|
+
* @returns A promise that resolves with the session metadata, or undefined if not found
|
|
845
|
+
* @throws Error if the client is not connected
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```typescript
|
|
849
|
+
* const metadata = await client.getSessionMetadata("session-123");
|
|
850
|
+
* if (metadata) {
|
|
851
|
+
* console.log(`Session started at: ${metadata.startTime}`);
|
|
852
|
+
* }
|
|
853
|
+
* ```
|
|
854
|
+
*/
|
|
855
|
+
async getSessionMetadata(sessionId) {
|
|
856
|
+
if (!this.connection) {
|
|
857
|
+
throw new Error("Client not connected");
|
|
858
|
+
}
|
|
859
|
+
const response = await this.connection.sendRequest("session.getMetadata", { sessionId });
|
|
860
|
+
const { session } = response;
|
|
861
|
+
if (!session) {
|
|
862
|
+
return void 0;
|
|
863
|
+
}
|
|
864
|
+
return CopilotClient.toSessionMetadata(session);
|
|
865
|
+
}
|
|
866
|
+
static toSessionMetadata(raw) {
|
|
867
|
+
return {
|
|
868
|
+
sessionId: raw.sessionId,
|
|
869
|
+
startTime: new Date(raw.startTime),
|
|
870
|
+
modifiedTime: new Date(raw.modifiedTime),
|
|
871
|
+
summary: raw.summary,
|
|
872
|
+
isRemote: raw.isRemote,
|
|
873
|
+
context: raw.context
|
|
874
|
+
};
|
|
804
875
|
}
|
|
805
876
|
/**
|
|
806
877
|
* Gets the foreground session ID in TUI+server mode.
|
|
@@ -1130,6 +1201,12 @@ stderr: ${stderrOutput}`
|
|
|
1130
1201
|
"systemMessage.transform",
|
|
1131
1202
|
async (params) => await this.handleSystemMessageTransform(params)
|
|
1132
1203
|
);
|
|
1204
|
+
const sessions = this.sessions;
|
|
1205
|
+
registerClientSessionApiHandlers(this.connection, (sessionId) => {
|
|
1206
|
+
const session = sessions.get(sessionId);
|
|
1207
|
+
if (!session) throw new Error(`No session found for sessionId: ${sessionId}`);
|
|
1208
|
+
return session.clientSessionApis;
|
|
1209
|
+
});
|
|
1133
1210
|
this.connection.onClose(() => {
|
|
1134
1211
|
this.state = "disconnected";
|
|
1135
1212
|
});
|
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;
|