@github/copilot-sdk 0.2.1-preview.1 → 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 +41 -2
- package/dist/cjs/client.js +85 -9
- 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 +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 +74 -0
- package/dist/types.d.ts +64 -3
- package/package.json +3 -2
|
@@ -92,7 +92,7 @@ export type SessionEvent = {
|
|
|
92
92
|
/**
|
|
93
93
|
* Whether this session supports remote steering via Mission Control
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
remoteSteerable?: boolean;
|
|
96
96
|
};
|
|
97
97
|
} | {
|
|
98
98
|
/**
|
|
@@ -169,6 +169,37 @@ export type SessionEvent = {
|
|
|
169
169
|
* Whether the session was already in use by another client at resume time
|
|
170
170
|
*/
|
|
171
171
|
alreadyInUse?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Whether this session supports remote steering via Mission Control
|
|
174
|
+
*/
|
|
175
|
+
remoteSteerable?: boolean;
|
|
176
|
+
};
|
|
177
|
+
} | {
|
|
178
|
+
/**
|
|
179
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
180
|
+
*/
|
|
181
|
+
id: string;
|
|
182
|
+
/**
|
|
183
|
+
* ISO 8601 timestamp when the event was created
|
|
184
|
+
*/
|
|
185
|
+
timestamp: string;
|
|
186
|
+
/**
|
|
187
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
188
|
+
*/
|
|
189
|
+
parentId: string | null;
|
|
190
|
+
/**
|
|
191
|
+
* When true, the event is transient and not persisted to the session event log on disk
|
|
192
|
+
*/
|
|
193
|
+
ephemeral?: boolean;
|
|
194
|
+
type: "session.remote_steerable_changed";
|
|
195
|
+
/**
|
|
196
|
+
* Notifies Mission Control that the session's remote steering capability has changed
|
|
197
|
+
*/
|
|
198
|
+
data: {
|
|
199
|
+
/**
|
|
200
|
+
* Whether this session now supports remote steering via Mission Control
|
|
201
|
+
*/
|
|
202
|
+
remoteSteerable: boolean;
|
|
172
203
|
};
|
|
173
204
|
} | {
|
|
174
205
|
/**
|
|
@@ -271,6 +302,10 @@ export type SessionEvent = {
|
|
|
271
302
|
description?: string;
|
|
272
303
|
}[];
|
|
273
304
|
};
|
|
305
|
+
/**
|
|
306
|
+
* True when the preceding agentic loop was cancelled via abort signal
|
|
307
|
+
*/
|
|
308
|
+
aborted?: boolean;
|
|
274
309
|
};
|
|
275
310
|
} | {
|
|
276
311
|
/**
|
|
@@ -1550,7 +1585,15 @@ export type SessionEvent = {
|
|
|
1550
1585
|
*/
|
|
1551
1586
|
duration?: number;
|
|
1552
1587
|
/**
|
|
1553
|
-
*
|
|
1588
|
+
* Time to first token in milliseconds. Only available for streaming requests
|
|
1589
|
+
*/
|
|
1590
|
+
ttftMs?: number;
|
|
1591
|
+
/**
|
|
1592
|
+
* Average inter-token latency in milliseconds. Only available for streaming requests
|
|
1593
|
+
*/
|
|
1594
|
+
interTokenLatencyMs?: number;
|
|
1595
|
+
/**
|
|
1596
|
+
* What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
|
|
1554
1597
|
*/
|
|
1555
1598
|
initiator?: string;
|
|
1556
1599
|
/**
|
|
@@ -2938,6 +2981,63 @@ export type SessionEvent = {
|
|
|
2938
2981
|
*/
|
|
2939
2982
|
requestId: string;
|
|
2940
2983
|
};
|
|
2984
|
+
} | {
|
|
2985
|
+
/**
|
|
2986
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
2987
|
+
*/
|
|
2988
|
+
id: string;
|
|
2989
|
+
/**
|
|
2990
|
+
* ISO 8601 timestamp when the event was created
|
|
2991
|
+
*/
|
|
2992
|
+
timestamp: string;
|
|
2993
|
+
/**
|
|
2994
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
2995
|
+
*/
|
|
2996
|
+
parentId: string | null;
|
|
2997
|
+
ephemeral: true;
|
|
2998
|
+
type: "sampling.requested";
|
|
2999
|
+
/**
|
|
3000
|
+
* Sampling request from an MCP server; contains the server name and a requestId for correlation
|
|
3001
|
+
*/
|
|
3002
|
+
data: {
|
|
3003
|
+
/**
|
|
3004
|
+
* Unique identifier for this sampling request; used to respond via session.respondToSampling()
|
|
3005
|
+
*/
|
|
3006
|
+
requestId: string;
|
|
3007
|
+
/**
|
|
3008
|
+
* Name of the MCP server that initiated the sampling request
|
|
3009
|
+
*/
|
|
3010
|
+
serverName: string;
|
|
3011
|
+
/**
|
|
3012
|
+
* The JSON-RPC request ID from the MCP protocol
|
|
3013
|
+
*/
|
|
3014
|
+
mcpRequestId: string | number;
|
|
3015
|
+
[k: string]: unknown;
|
|
3016
|
+
};
|
|
3017
|
+
} | {
|
|
3018
|
+
/**
|
|
3019
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
3020
|
+
*/
|
|
3021
|
+
id: string;
|
|
3022
|
+
/**
|
|
3023
|
+
* ISO 8601 timestamp when the event was created
|
|
3024
|
+
*/
|
|
3025
|
+
timestamp: string;
|
|
3026
|
+
/**
|
|
3027
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
3028
|
+
*/
|
|
3029
|
+
parentId: string | null;
|
|
3030
|
+
ephemeral: true;
|
|
3031
|
+
type: "sampling.completed";
|
|
3032
|
+
/**
|
|
3033
|
+
* Sampling request completion notification signaling UI dismissal
|
|
3034
|
+
*/
|
|
3035
|
+
data: {
|
|
3036
|
+
/**
|
|
3037
|
+
* Request ID of the resolved sampling request; clients should dismiss any UI for this request
|
|
3038
|
+
*/
|
|
3039
|
+
requestId: string;
|
|
3040
|
+
};
|
|
2941
3041
|
} | {
|
|
2942
3042
|
/**
|
|
2943
3043
|
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
@@ -3196,6 +3296,35 @@ export type SessionEvent = {
|
|
|
3196
3296
|
description?: string;
|
|
3197
3297
|
}[];
|
|
3198
3298
|
};
|
|
3299
|
+
} | {
|
|
3300
|
+
/**
|
|
3301
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
3302
|
+
*/
|
|
3303
|
+
id: string;
|
|
3304
|
+
/**
|
|
3305
|
+
* ISO 8601 timestamp when the event was created
|
|
3306
|
+
*/
|
|
3307
|
+
timestamp: string;
|
|
3308
|
+
/**
|
|
3309
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
3310
|
+
*/
|
|
3311
|
+
parentId: string | null;
|
|
3312
|
+
ephemeral: true;
|
|
3313
|
+
type: "capabilities.changed";
|
|
3314
|
+
/**
|
|
3315
|
+
* Session capability change notification
|
|
3316
|
+
*/
|
|
3317
|
+
data: {
|
|
3318
|
+
/**
|
|
3319
|
+
* UI capability changes
|
|
3320
|
+
*/
|
|
3321
|
+
ui?: {
|
|
3322
|
+
/**
|
|
3323
|
+
* Whether elicitation is now supported
|
|
3324
|
+
*/
|
|
3325
|
+
elicitation?: boolean;
|
|
3326
|
+
};
|
|
3327
|
+
};
|
|
3199
3328
|
} | {
|
|
3200
3329
|
/**
|
|
3201
3330
|
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
@@ -3427,9 +3556,9 @@ export type SessionEvent = {
|
|
|
3427
3556
|
*/
|
|
3428
3557
|
name: string;
|
|
3429
3558
|
/**
|
|
3430
|
-
* Connection status: connected, failed, pending, disabled, or not_configured
|
|
3559
|
+
* Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
|
|
3431
3560
|
*/
|
|
3432
|
-
status: "connected" | "failed" | "pending" | "disabled" | "not_configured";
|
|
3561
|
+
status: "connected" | "failed" | "needs-auth" | "pending" | "disabled" | "not_configured";
|
|
3433
3562
|
/**
|
|
3434
3563
|
* Configuration source: user, workspace, plugin, or builtin
|
|
3435
3564
|
*/
|
|
@@ -3461,9 +3590,9 @@ export type SessionEvent = {
|
|
|
3461
3590
|
*/
|
|
3462
3591
|
serverName: string;
|
|
3463
3592
|
/**
|
|
3464
|
-
* New connection status: connected, failed, pending, disabled, or not_configured
|
|
3593
|
+
* New connection status: connected, failed, needs-auth, pending, disabled, or not_configured
|
|
3465
3594
|
*/
|
|
3466
|
-
status: "connected" | "failed" | "pending" | "disabled" | "not_configured";
|
|
3595
|
+
status: "connected" | "failed" | "needs-auth" | "pending" | "disabled" | "not_configured";
|
|
3467
3596
|
};
|
|
3468
3597
|
} | {
|
|
3469
3598
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
export { CopilotClient } from "./client.js";
|
|
7
7
|
export { CopilotSession, type AssistantMessageEvent } from "./session.js";
|
|
8
8
|
export { defineTool, approveAll, SYSTEM_PROMPT_SECTIONS } from "./types.js";
|
|
9
|
-
export type { CommandContext, CommandDefinition, CommandHandler, ConnectionState, CopilotClientOptions, CustomAgentConfig, ElicitationFieldValue, ElicitationParams, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, InputOptions, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
|
9
|
+
export type { CommandContext, CommandDefinition, CommandHandler, ConnectionState, CopilotClientOptions, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationRequest, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, InputOptions, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsHandler, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
package/dist/session.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { MessageConnection } from "vscode-jsonrpc/node.js";
|
|
6
6
|
import { createSessionRpc } from "./generated/rpc.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { ClientSessionApiHandlers } from "./generated/rpc.js";
|
|
8
|
+
import type { CommandHandler, ElicitationHandler, ElicitationRequest, MessageOptions, PermissionHandler, PermissionRequestResult, ReasoningEffort, SectionTransformFn, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionHooks, SessionUiApi, Tool, ToolHandler, TraceContextProvider, TypedSessionEventHandler, UserInputHandler, UserInputResponse } from "./types.js";
|
|
8
9
|
export declare const NO_RESULT_PERMISSION_V2_ERROR = "Permission handlers cannot return 'no-result' when connected to a protocol v2 server.";
|
|
9
10
|
/** Assistant message event - the final response from the assistant. */
|
|
10
11
|
export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
@@ -45,11 +46,14 @@ export declare class CopilotSession {
|
|
|
45
46
|
private commandHandlers;
|
|
46
47
|
private permissionHandler?;
|
|
47
48
|
private userInputHandler?;
|
|
49
|
+
private elicitationHandler?;
|
|
48
50
|
private hooks?;
|
|
49
51
|
private transformCallbacks?;
|
|
50
52
|
private _rpc;
|
|
51
53
|
private traceContextProvider?;
|
|
52
54
|
private _capabilities;
|
|
55
|
+
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
56
|
+
clientSessionApis: ClientSessionApiHandlers;
|
|
53
57
|
/**
|
|
54
58
|
* Creates a new CopilotSession instance.
|
|
55
59
|
*
|
|
@@ -235,6 +239,19 @@ export declare class CopilotSession {
|
|
|
235
239
|
name: string;
|
|
236
240
|
handler: CommandHandler;
|
|
237
241
|
}[]): void;
|
|
242
|
+
/**
|
|
243
|
+
* Registers the elicitation handler for this session.
|
|
244
|
+
*
|
|
245
|
+
* @param handler - The handler to invoke when the server dispatches an elicitation request
|
|
246
|
+
* @internal This method is typically called internally when creating/resuming a session.
|
|
247
|
+
*/
|
|
248
|
+
registerElicitationHandler(handler?: ElicitationHandler): void;
|
|
249
|
+
/**
|
|
250
|
+
* Handles an elicitation.requested broadcast event.
|
|
251
|
+
* Invokes the registered handler and responds via handlePendingElicitation RPC.
|
|
252
|
+
* @internal
|
|
253
|
+
*/
|
|
254
|
+
_handleElicitationRequest(request: ElicitationRequest, requestId: string): Promise<void>;
|
|
238
255
|
/**
|
|
239
256
|
* Sets the host capabilities for this session.
|
|
240
257
|
*
|
package/dist/session.js
CHANGED
|
@@ -24,11 +24,14 @@ class CopilotSession {
|
|
|
24
24
|
commandHandlers = /* @__PURE__ */ new Map();
|
|
25
25
|
permissionHandler;
|
|
26
26
|
userInputHandler;
|
|
27
|
+
elicitationHandler;
|
|
27
28
|
hooks;
|
|
28
29
|
transformCallbacks;
|
|
29
30
|
_rpc = null;
|
|
30
31
|
traceContextProvider;
|
|
31
32
|
_capabilities = {};
|
|
33
|
+
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
34
|
+
clientSessionApis = {};
|
|
32
35
|
/**
|
|
33
36
|
* Typed session-scoped RPC methods.
|
|
34
37
|
*/
|
|
@@ -245,6 +248,22 @@ class CopilotSession {
|
|
|
245
248
|
} else if (event.type === "command.execute") {
|
|
246
249
|
const { requestId, commandName, command, args } = event.data;
|
|
247
250
|
void this._executeCommandAndRespond(requestId, commandName, command, args);
|
|
251
|
+
} else if (event.type === "elicitation.requested") {
|
|
252
|
+
if (this.elicitationHandler) {
|
|
253
|
+
const { message, requestedSchema, mode, elicitationSource, url, requestId } = event.data;
|
|
254
|
+
void this._handleElicitationRequest(
|
|
255
|
+
{
|
|
256
|
+
message,
|
|
257
|
+
requestedSchema,
|
|
258
|
+
mode,
|
|
259
|
+
elicitationSource,
|
|
260
|
+
url
|
|
261
|
+
},
|
|
262
|
+
requestId
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
} else if (event.type === "capabilities.changed") {
|
|
266
|
+
this._capabilities = { ...this._capabilities, ...event.data };
|
|
248
267
|
}
|
|
249
268
|
}
|
|
250
269
|
/**
|
|
@@ -266,6 +285,8 @@ class CopilotSession {
|
|
|
266
285
|
result = "";
|
|
267
286
|
} else if (typeof rawResult === "string") {
|
|
268
287
|
result = rawResult;
|
|
288
|
+
} else if (isToolResultObject(rawResult)) {
|
|
289
|
+
result = rawResult;
|
|
269
290
|
} else {
|
|
270
291
|
result = JSON.stringify(rawResult);
|
|
271
292
|
}
|
|
@@ -385,6 +406,40 @@ class CopilotSession {
|
|
|
385
406
|
this.commandHandlers.set(cmd.name, cmd.handler);
|
|
386
407
|
}
|
|
387
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* Registers the elicitation handler for this session.
|
|
411
|
+
*
|
|
412
|
+
* @param handler - The handler to invoke when the server dispatches an elicitation request
|
|
413
|
+
* @internal This method is typically called internally when creating/resuming a session.
|
|
414
|
+
*/
|
|
415
|
+
registerElicitationHandler(handler) {
|
|
416
|
+
this.elicitationHandler = handler;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Handles an elicitation.requested broadcast event.
|
|
420
|
+
* Invokes the registered handler and responds via handlePendingElicitation RPC.
|
|
421
|
+
* @internal
|
|
422
|
+
*/
|
|
423
|
+
async _handleElicitationRequest(request, requestId) {
|
|
424
|
+
if (!this.elicitationHandler) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
try {
|
|
428
|
+
const result = await this.elicitationHandler(request, { sessionId: this.sessionId });
|
|
429
|
+
await this.rpc.ui.handlePendingElicitation({ requestId, result });
|
|
430
|
+
} catch {
|
|
431
|
+
try {
|
|
432
|
+
await this.rpc.ui.handlePendingElicitation({
|
|
433
|
+
requestId,
|
|
434
|
+
result: { action: "cancel" }
|
|
435
|
+
});
|
|
436
|
+
} catch (rpcError) {
|
|
437
|
+
if (!(rpcError instanceof ConnectionError || rpcError instanceof ResponseError)) {
|
|
438
|
+
throw rpcError;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
388
443
|
/**
|
|
389
444
|
* Sets the host capabilities for this session.
|
|
390
445
|
*
|
|
@@ -743,6 +798,25 @@ class CopilotSession {
|
|
|
743
798
|
await this.rpc.log({ message, ...options });
|
|
744
799
|
}
|
|
745
800
|
}
|
|
801
|
+
function isToolResultObject(value) {
|
|
802
|
+
if (typeof value !== "object" || value === null) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
if (!("textResultForLlm" in value) || typeof value.textResultForLlm !== "string") {
|
|
806
|
+
return false;
|
|
807
|
+
}
|
|
808
|
+
if (!("resultType" in value) || typeof value.resultType !== "string") {
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
const allowedResultTypes = [
|
|
812
|
+
"success",
|
|
813
|
+
"failure",
|
|
814
|
+
"rejected",
|
|
815
|
+
"denied",
|
|
816
|
+
"timeout"
|
|
817
|
+
];
|
|
818
|
+
return allowedResultTypes.includes(value.resultType);
|
|
819
|
+
}
|
|
746
820
|
export {
|
|
747
821
|
CopilotSession,
|
|
748
822
|
NO_RESULT_PERMISSION_V2_ERROR
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for the Copilot SDK
|
|
3
3
|
*/
|
|
4
|
+
import type { SessionFsHandler } from "./generated/rpc.js";
|
|
4
5
|
import type { SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
6
|
+
import type { CopilotSession } from "./session.js";
|
|
5
7
|
export type SessionEvent = GeneratedSessionEvent;
|
|
8
|
+
export type { SessionFsHandler } from "./generated/rpc.js";
|
|
6
9
|
/**
|
|
7
10
|
* Options for creating a CopilotClient
|
|
8
11
|
*/
|
|
@@ -146,11 +149,18 @@ export interface CopilotClientOptions {
|
|
|
146
149
|
* ```
|
|
147
150
|
*/
|
|
148
151
|
onGetTraceContext?: TraceContextProvider;
|
|
152
|
+
/**
|
|
153
|
+
* Custom session filesystem provider.
|
|
154
|
+
* When provided, the client registers as the session filesystem provider
|
|
155
|
+
* on connection, routing all session-scoped file I/O through these callbacks
|
|
156
|
+
* instead of the server's default local filesystem storage.
|
|
157
|
+
*/
|
|
158
|
+
sessionFs?: SessionFsConfig;
|
|
149
159
|
}
|
|
150
160
|
/**
|
|
151
161
|
* Configuration for creating a session
|
|
152
162
|
*/
|
|
153
|
-
export type ToolResultType = "success" | "failure" | "rejected" | "denied";
|
|
163
|
+
export type ToolResultType = "success" | "failure" | "rejected" | "denied" | "timeout";
|
|
154
164
|
export type ToolBinaryResult = {
|
|
155
165
|
data: string;
|
|
156
166
|
mimeType: string;
|
|
@@ -353,6 +363,29 @@ export interface ElicitationParams {
|
|
|
353
363
|
/** JSON Schema describing the form fields to present. */
|
|
354
364
|
requestedSchema: ElicitationSchema;
|
|
355
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Request payload passed to an elicitation handler callback.
|
|
368
|
+
* Extends ElicitationParams with optional metadata fields.
|
|
369
|
+
*/
|
|
370
|
+
export interface ElicitationRequest {
|
|
371
|
+
/** Message describing what information is needed from the user. */
|
|
372
|
+
message: string;
|
|
373
|
+
/** JSON Schema describing the form fields to present. */
|
|
374
|
+
requestedSchema?: ElicitationSchema;
|
|
375
|
+
/** Elicitation mode: "form" for structured input, "url" for browser redirect. */
|
|
376
|
+
mode?: "form" | "url";
|
|
377
|
+
/** The source that initiated the request (e.g. MCP server name). */
|
|
378
|
+
elicitationSource?: string;
|
|
379
|
+
/** URL to open in the user's browser (url mode only). */
|
|
380
|
+
url?: string;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Handler invoked when the server dispatches an elicitation request to this client.
|
|
384
|
+
* Return an {@link ElicitationResult} with the user's response.
|
|
385
|
+
*/
|
|
386
|
+
export type ElicitationHandler = (request: ElicitationRequest, invocation: {
|
|
387
|
+
sessionId: string;
|
|
388
|
+
}) => Promise<ElicitationResult> | ElicitationResult;
|
|
356
389
|
/**
|
|
357
390
|
* Options for the `input()` convenience method.
|
|
358
391
|
*/
|
|
@@ -892,6 +925,12 @@ export interface SessionConfig {
|
|
|
892
925
|
* When provided, enables the ask_user tool allowing the agent to ask questions.
|
|
893
926
|
*/
|
|
894
927
|
onUserInputRequest?: UserInputHandler;
|
|
928
|
+
/**
|
|
929
|
+
* Handler for elicitation requests from the agent.
|
|
930
|
+
* When provided, the server calls back to this client for form-based UI dialogs.
|
|
931
|
+
* Also enables the `elicitation` capability on the session.
|
|
932
|
+
*/
|
|
933
|
+
onElicitationRequest?: ElicitationHandler;
|
|
895
934
|
/**
|
|
896
935
|
* Hook handlers for intercepting session lifecycle events.
|
|
897
936
|
* When provided, enables hooks callback allowing custom logic at various points.
|
|
@@ -942,11 +981,16 @@ export interface SessionConfig {
|
|
|
942
981
|
* but executes earlier in the lifecycle so no events are missed.
|
|
943
982
|
*/
|
|
944
983
|
onEvent?: SessionEventHandler;
|
|
984
|
+
/**
|
|
985
|
+
* Supplies a handler for session filesystem operations. This takes effect
|
|
986
|
+
* only if {@link CopilotClientOptions.sessionFs} is configured.
|
|
987
|
+
*/
|
|
988
|
+
createSessionFsHandler?: (session: CopilotSession) => SessionFsHandler;
|
|
945
989
|
}
|
|
946
990
|
/**
|
|
947
991
|
* Configuration for resuming a session
|
|
948
992
|
*/
|
|
949
|
-
export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "streaming" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "hooks" | "workingDirectory" | "configDir" | "mcpServers" | "customAgents" | "agent" | "skillDirectories" | "disabledSkills" | "infiniteSessions" | "onEvent"> & {
|
|
993
|
+
export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "streaming" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "hooks" | "workingDirectory" | "configDir" | "mcpServers" | "customAgents" | "agent" | "skillDirectories" | "disabledSkills" | "infiniteSessions" | "onEvent" | "createSessionFsHandler"> & {
|
|
950
994
|
/**
|
|
951
995
|
* When true, skips emitting the session.resume event.
|
|
952
996
|
* Useful for reconnecting to a session without triggering resume-related side effects.
|
|
@@ -1072,6 +1116,24 @@ export interface SessionContext {
|
|
|
1072
1116
|
/** Current git branch */
|
|
1073
1117
|
branch?: string;
|
|
1074
1118
|
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Configuration for a custom session filesystem provider.
|
|
1121
|
+
*/
|
|
1122
|
+
export interface SessionFsConfig {
|
|
1123
|
+
/**
|
|
1124
|
+
* Initial working directory for sessions (user's project directory).
|
|
1125
|
+
*/
|
|
1126
|
+
initialCwd: string;
|
|
1127
|
+
/**
|
|
1128
|
+
* Path within each session's SessionFs where the runtime stores
|
|
1129
|
+
* session-scoped files (events, workspace, checkpoints, etc.).
|
|
1130
|
+
*/
|
|
1131
|
+
sessionStatePath: string;
|
|
1132
|
+
/**
|
|
1133
|
+
* Path conventions used by this filesystem provider.
|
|
1134
|
+
*/
|
|
1135
|
+
conventions: "windows" | "posix";
|
|
1136
|
+
}
|
|
1075
1137
|
/**
|
|
1076
1138
|
* Filter options for listing sessions
|
|
1077
1139
|
*/
|
|
@@ -1211,4 +1273,3 @@ export interface ForegroundSessionInfo {
|
|
|
1211
1273
|
/** Workspace path of the foreground session */
|
|
1212
1274
|
workspacePath?: string;
|
|
1213
1275
|
}
|
|
1214
|
-
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/github/copilot-sdk.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.2.1-preview.
|
|
7
|
+
"version": "0.2.1-preview.2",
|
|
8
8
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
9
9
|
"main": "./dist/cjs/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -56,11 +56,12 @@
|
|
|
56
56
|
"author": "GitHub",
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@github/copilot": "^1.0.
|
|
59
|
+
"@github/copilot": "^1.0.15-2",
|
|
60
60
|
"vscode-jsonrpc": "^8.2.1",
|
|
61
61
|
"zod": "^4.3.6"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
+
"@platformatic/vfs": "^0.3.0",
|
|
64
65
|
"@types/node": "^25.2.0",
|
|
65
66
|
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
66
67
|
"@typescript-eslint/parser": "^8.54.0",
|