@github/copilot-sdk 1.0.5-preview.0 → 1.0.5-preview.1
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/cjs/client.js +16 -2
- package/dist/cjs/generated/rpc.js +48 -3
- package/dist/cjs/session.js +40 -1
- package/dist/client.js +16 -2
- package/dist/generated/rpc.d.ts +290 -7
- package/dist/generated/rpc.js +48 -3
- package/dist/generated/session-events.d.ts +77 -12
- package/dist/session.d.ts +1 -0
- package/dist/session.js +40 -1
- package/dist/types.d.ts +68 -0
- package/package.json +2 -2
package/dist/cjs/client.js
CHANGED
|
@@ -925,7 +925,8 @@ class CopilotClient {
|
|
|
925
925
|
sessionId,
|
|
926
926
|
this.connection,
|
|
927
927
|
void 0,
|
|
928
|
-
this.onGetTraceContext
|
|
928
|
+
this.onGetTraceContext,
|
|
929
|
+
{ mcpAuthHandler: config.onMcpAuthRequest }
|
|
929
930
|
);
|
|
930
931
|
s.registerTools(config.tools);
|
|
931
932
|
s.registerCanvases(config.canvases);
|
|
@@ -1057,6 +1058,12 @@ class CopilotClient {
|
|
|
1057
1058
|
session = initializeSession(returnedSessionId);
|
|
1058
1059
|
registeredId = returnedSessionId;
|
|
1059
1060
|
}
|
|
1061
|
+
if (config.onMcpAuthRequest) {
|
|
1062
|
+
await this.connection.sendRequest("session.eventLog.registerInterest", {
|
|
1063
|
+
sessionId: returnedSessionId,
|
|
1064
|
+
eventType: "mcp.oauth_required"
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1060
1067
|
session["_workspacePath"] = workspacePath;
|
|
1061
1068
|
session.setCapabilities(capabilities);
|
|
1062
1069
|
await this.updateSessionOptionsForMode(session, config);
|
|
@@ -1100,7 +1107,8 @@ class CopilotClient {
|
|
|
1100
1107
|
sessionId,
|
|
1101
1108
|
this.connection,
|
|
1102
1109
|
void 0,
|
|
1103
|
-
this.onGetTraceContext
|
|
1110
|
+
this.onGetTraceContext,
|
|
1111
|
+
{ mcpAuthHandler: config.onMcpAuthRequest }
|
|
1104
1112
|
);
|
|
1105
1113
|
session.registerTools(config.tools);
|
|
1106
1114
|
session.registerCanvases(config.canvases);
|
|
@@ -1142,6 +1150,12 @@ class CopilotClient {
|
|
|
1142
1150
|
}
|
|
1143
1151
|
this.sessions.set(sessionId, session);
|
|
1144
1152
|
this.setupSessionFs(session, config);
|
|
1153
|
+
if (config.onMcpAuthRequest) {
|
|
1154
|
+
await this.connection.sendRequest("session.eventLog.registerInterest", {
|
|
1155
|
+
sessionId,
|
|
1156
|
+
eventType: "mcp.oauth_required"
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1145
1159
|
const toolFilterOptions = this.resolveToolFilterOptions(config);
|
|
1146
1160
|
try {
|
|
1147
1161
|
const response = await this.connection.sendRequest("session.resume", {
|
|
@@ -34,8 +34,11 @@ function createServerRpc(connection) {
|
|
|
34
34
|
* @param params Optional message to echo back to the caller.
|
|
35
35
|
*
|
|
36
36
|
* @returns Server liveness response, including the echoed message, current server timestamp, and protocol version.
|
|
37
|
+
*
|
|
38
|
+
* @experimental
|
|
37
39
|
*/
|
|
38
40
|
ping: async (params) => connection.sendRequest("ping", params),
|
|
41
|
+
/** @experimental */
|
|
39
42
|
models: {
|
|
40
43
|
/**
|
|
41
44
|
* Lists Copilot models available to the authenticated user.
|
|
@@ -46,6 +49,7 @@ function createServerRpc(connection) {
|
|
|
46
49
|
*/
|
|
47
50
|
list: async (params) => connection.sendRequest("models.list", params)
|
|
48
51
|
},
|
|
52
|
+
/** @experimental */
|
|
49
53
|
tools: {
|
|
50
54
|
/**
|
|
51
55
|
* Lists built-in tools available for a model.
|
|
@@ -56,6 +60,7 @@ function createServerRpc(connection) {
|
|
|
56
60
|
*/
|
|
57
61
|
list: async (params) => connection.sendRequest("tools.list", params)
|
|
58
62
|
},
|
|
63
|
+
/** @experimental */
|
|
59
64
|
account: {
|
|
60
65
|
/**
|
|
61
66
|
* Gets Copilot quota usage for the authenticated user or supplied GitHub token.
|
|
@@ -94,6 +99,7 @@ function createServerRpc(connection) {
|
|
|
94
99
|
*/
|
|
95
100
|
logout: async (params) => connection.sendRequest("account.logout", params)
|
|
96
101
|
},
|
|
102
|
+
/** @experimental */
|
|
97
103
|
secrets: {
|
|
98
104
|
/**
|
|
99
105
|
* Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
|
|
@@ -104,7 +110,9 @@ function createServerRpc(connection) {
|
|
|
104
110
|
*/
|
|
105
111
|
addFilterValues: async (params) => connection.sendRequest("secrets.addFilterValues", params)
|
|
106
112
|
},
|
|
113
|
+
/** @experimental */
|
|
107
114
|
mcp: {
|
|
115
|
+
/** @experimental */
|
|
108
116
|
config: {
|
|
109
117
|
/**
|
|
110
118
|
* Lists MCP servers from user configuration.
|
|
@@ -246,7 +254,9 @@ function createServerRpc(connection) {
|
|
|
246
254
|
refresh: async (params) => connection.sendRequest("plugins.marketplaces.refresh", params)
|
|
247
255
|
}
|
|
248
256
|
},
|
|
257
|
+
/** @experimental */
|
|
249
258
|
skills: {
|
|
259
|
+
/** @experimental */
|
|
250
260
|
config: {
|
|
251
261
|
/**
|
|
252
262
|
* Replaces the global list of disabled skills.
|
|
@@ -269,8 +279,6 @@ function createServerRpc(connection) {
|
|
|
269
279
|
* @param params Optional project paths to enumerate.
|
|
270
280
|
*
|
|
271
281
|
* @returns Canonical locations where skills can be created so the runtime will recognize them.
|
|
272
|
-
*
|
|
273
|
-
* @experimental
|
|
274
282
|
*/
|
|
275
283
|
getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
|
|
276
284
|
},
|
|
@@ -312,20 +320,38 @@ function createServerRpc(connection) {
|
|
|
312
320
|
*/
|
|
313
321
|
getDiscoveryPaths: async (params) => connection.sendRequest("instructions.getDiscoveryPaths", params)
|
|
314
322
|
},
|
|
323
|
+
/** @experimental */
|
|
315
324
|
user: {
|
|
325
|
+
/** @experimental */
|
|
316
326
|
settings: {
|
|
317
327
|
/**
|
|
318
328
|
* Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
|
|
319
329
|
*/
|
|
320
|
-
reload: async () => connection.sendRequest("user.settings.reload", {})
|
|
330
|
+
reload: async () => connection.sendRequest("user.settings.reload", {}),
|
|
331
|
+
/**
|
|
332
|
+
* Lists every known user setting (settings.json overlaid with the legacy config.json, config.json wins), each with its effective value, its default, and whether it is at the default — so settings the user has never set still appear with their default value. Does not include repository- or enterprise-managed overrides that the runtime layers on top at session time.
|
|
333
|
+
*
|
|
334
|
+
* @returns Per-key metadata for every known user setting (settings.json overlaid with the legacy config.json, config.json wins), including settings left at their default. Excludes repository- and enterprise-managed overrides.
|
|
335
|
+
*/
|
|
336
|
+
get: async () => connection.sendRequest("user.settings.get", {}),
|
|
337
|
+
/**
|
|
338
|
+
* Writes one or more user settings to settings.json, replacing each provided top-level key. A key whose value is null is removed. Returns the keys whose new value is shadowed by a legacy config.json entry (config.json wins on read), which the runtime leaves in place — such writes do not take effect until the legacy value is removed.
|
|
339
|
+
*
|
|
340
|
+
* @param params Partial user settings to write to settings.json. Each top-level key is written individually, replacing the existing value; a key whose value is null is removed.
|
|
341
|
+
*
|
|
342
|
+
* @returns Outcome of writing user settings.
|
|
343
|
+
*/
|
|
344
|
+
set: async (params) => connection.sendRequest("user.settings.set", params)
|
|
321
345
|
}
|
|
322
346
|
},
|
|
347
|
+
/** @experimental */
|
|
323
348
|
runtime: {
|
|
324
349
|
/**
|
|
325
350
|
* Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
|
|
326
351
|
*/
|
|
327
352
|
shutdown: async () => connection.sendRequest("runtime.shutdown", {})
|
|
328
353
|
},
|
|
354
|
+
/** @experimental */
|
|
329
355
|
sessionFs: {
|
|
330
356
|
/**
|
|
331
357
|
* Registers an SDK client as the session filesystem provider.
|
|
@@ -565,6 +591,8 @@ function createInternalServerRpc(connection) {
|
|
|
565
591
|
* @param params Optional connection token presented by the SDK client during the handshake.
|
|
566
592
|
*
|
|
567
593
|
* @returns Handshake result reporting the server's protocol version and package version on success.
|
|
594
|
+
*
|
|
595
|
+
* @experimental
|
|
568
596
|
*/
|
|
569
597
|
connect: async (params) => connection.sendRequest("connect", params),
|
|
570
598
|
/** @experimental */
|
|
@@ -1847,6 +1875,23 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1847
1875
|
notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { sessionId, ...params })
|
|
1848
1876
|
},
|
|
1849
1877
|
/** @experimental */
|
|
1878
|
+
visibility: {
|
|
1879
|
+
/**
|
|
1880
|
+
* Returns the session's current Mission Control sharing status and shareable GitHub URL. Reflects whether the synced session is visible to repository readers ("repo") or restricted to its creator and collaborators ("unshared").
|
|
1881
|
+
*
|
|
1882
|
+
* @returns Current sharing status and shareable GitHub URL for a session.
|
|
1883
|
+
*/
|
|
1884
|
+
get: async () => connection.sendRequest("session.visibility.get", { sessionId }),
|
|
1885
|
+
/**
|
|
1886
|
+
* Sets the session's Mission Control sharing status, controlling whether the synced session is visible to repository readers. Returns the effective status and shareable GitHub URL after the change.
|
|
1887
|
+
*
|
|
1888
|
+
* @param params Desired sharing status for the session.
|
|
1889
|
+
*
|
|
1890
|
+
* @returns Effective sharing status and shareable GitHub URL after updating session visibility.
|
|
1891
|
+
*/
|
|
1892
|
+
set: async (params) => connection.sendRequest("session.visibility.set", { sessionId, ...params })
|
|
1893
|
+
},
|
|
1894
|
+
/** @experimental */
|
|
1850
1895
|
schedule: {
|
|
1851
1896
|
/**
|
|
1852
1897
|
* Lists the session's currently active scheduled prompts.
|
package/dist/cjs/session.js
CHANGED
|
@@ -50,11 +50,12 @@ class CopilotSession {
|
|
|
50
50
|
* @param traceContextProvider - Optional callback to get W3C Trace Context for outbound RPCs
|
|
51
51
|
* @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
|
|
52
52
|
*/
|
|
53
|
-
constructor(sessionId, connection, _workspacePath, traceContextProvider) {
|
|
53
|
+
constructor(sessionId, connection, _workspacePath, traceContextProvider, options) {
|
|
54
54
|
this.sessionId = sessionId;
|
|
55
55
|
this.connection = connection;
|
|
56
56
|
this._workspacePath = _workspacePath;
|
|
57
57
|
this.traceContextProvider = traceContextProvider;
|
|
58
|
+
this.mcpAuthHandler = options?.mcpAuthHandler;
|
|
58
59
|
}
|
|
59
60
|
sessionId;
|
|
60
61
|
connection;
|
|
@@ -66,6 +67,7 @@ class CopilotSession {
|
|
|
66
67
|
bearerTokenProviders = /* @__PURE__ */ new Map();
|
|
67
68
|
commandHandlers = /* @__PURE__ */ new Map();
|
|
68
69
|
permissionHandler;
|
|
70
|
+
mcpAuthHandler;
|
|
69
71
|
userInputHandler;
|
|
70
72
|
elicitationHandler;
|
|
71
73
|
exitPlanModeHandler;
|
|
@@ -277,6 +279,18 @@ class CopilotSession {
|
|
|
277
279
|
if (this.permissionHandler) {
|
|
278
280
|
void this._executePermissionAndRespond(requestId, permissionRequest);
|
|
279
281
|
}
|
|
282
|
+
} else if (event.type === "mcp.oauth_required") {
|
|
283
|
+
const data = event.data;
|
|
284
|
+
if (!data?.requestId) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (!this.mcpAuthHandler) {
|
|
288
|
+
console.warn(
|
|
289
|
+
`Received MCP OAuth request without a registered MCP auth handler. SessionId=${this.sessionId}, RequestId=${data.requestId}`
|
|
290
|
+
);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
void this._executeMcpAuthAndRespond(data);
|
|
280
294
|
} else if (event.type === "command.execute") {
|
|
281
295
|
const { requestId, commandName, command, args } = event.data;
|
|
282
296
|
void this._executeCommandAndRespond(requestId, commandName, command, args);
|
|
@@ -408,6 +422,31 @@ class CopilotSession {
|
|
|
408
422
|
}
|
|
409
423
|
}
|
|
410
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* Executes an MCP auth handler and sends the result back via RPC.
|
|
427
|
+
* @internal
|
|
428
|
+
*/
|
|
429
|
+
async _executeMcpAuthAndRespond(request) {
|
|
430
|
+
try {
|
|
431
|
+
const result = await this.mcpAuthHandler(request, { sessionId: this.sessionId });
|
|
432
|
+
const response = result && "accessToken" in result ? { kind: "token", ...result } : { kind: "cancelled" };
|
|
433
|
+
await this.rpc.mcp.oauth.handlePendingRequest({
|
|
434
|
+
requestId: request.requestId,
|
|
435
|
+
result: response
|
|
436
|
+
});
|
|
437
|
+
} catch (_error) {
|
|
438
|
+
try {
|
|
439
|
+
await this.rpc.mcp.oauth.handlePendingRequest({
|
|
440
|
+
requestId: request.requestId,
|
|
441
|
+
result: { kind: "cancelled" }
|
|
442
|
+
});
|
|
443
|
+
} catch (rpcError) {
|
|
444
|
+
if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
|
|
445
|
+
throw rpcError;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
411
450
|
/**
|
|
412
451
|
* Executes a command handler and sends the result back via RPC.
|
|
413
452
|
* @internal
|
package/dist/client.js
CHANGED
|
@@ -912,7 +912,8 @@ class CopilotClient {
|
|
|
912
912
|
sessionId,
|
|
913
913
|
this.connection,
|
|
914
914
|
void 0,
|
|
915
|
-
this.onGetTraceContext
|
|
915
|
+
this.onGetTraceContext,
|
|
916
|
+
{ mcpAuthHandler: config.onMcpAuthRequest }
|
|
916
917
|
);
|
|
917
918
|
s.registerTools(config.tools);
|
|
918
919
|
s.registerCanvases(config.canvases);
|
|
@@ -1044,6 +1045,12 @@ class CopilotClient {
|
|
|
1044
1045
|
session = initializeSession(returnedSessionId);
|
|
1045
1046
|
registeredId = returnedSessionId;
|
|
1046
1047
|
}
|
|
1048
|
+
if (config.onMcpAuthRequest) {
|
|
1049
|
+
await this.connection.sendRequest("session.eventLog.registerInterest", {
|
|
1050
|
+
sessionId: returnedSessionId,
|
|
1051
|
+
eventType: "mcp.oauth_required"
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1047
1054
|
session["_workspacePath"] = workspacePath;
|
|
1048
1055
|
session.setCapabilities(capabilities);
|
|
1049
1056
|
await this.updateSessionOptionsForMode(session, config);
|
|
@@ -1087,7 +1094,8 @@ class CopilotClient {
|
|
|
1087
1094
|
sessionId,
|
|
1088
1095
|
this.connection,
|
|
1089
1096
|
void 0,
|
|
1090
|
-
this.onGetTraceContext
|
|
1097
|
+
this.onGetTraceContext,
|
|
1098
|
+
{ mcpAuthHandler: config.onMcpAuthRequest }
|
|
1091
1099
|
);
|
|
1092
1100
|
session.registerTools(config.tools);
|
|
1093
1101
|
session.registerCanvases(config.canvases);
|
|
@@ -1129,6 +1137,12 @@ class CopilotClient {
|
|
|
1129
1137
|
}
|
|
1130
1138
|
this.sessions.set(sessionId, session);
|
|
1131
1139
|
this.setupSessionFs(session, config);
|
|
1140
|
+
if (config.onMcpAuthRequest) {
|
|
1141
|
+
await this.connection.sendRequest("session.eventLog.registerInterest", {
|
|
1142
|
+
sessionId,
|
|
1143
|
+
eventType: "mcp.oauth_required"
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1132
1146
|
const toolFilterOptions = this.resolveToolFilterOptions(config);
|
|
1133
1147
|
try {
|
|
1134
1148
|
const response = await this.connection.sendRequest("session.resume", {
|