@github/copilot-sdk 1.0.2 → 1.0.4

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.
@@ -36,7 +36,35 @@ function createServerRpc(connection) {
36
36
  *
37
37
  * @returns Quota usage snapshots for the resolved user, keyed by quota type.
38
38
  */
39
- getQuota: async (params) => connection.sendRequest("account.getQuota", params)
39
+ getQuota: async (params) => connection.sendRequest("account.getQuota", params),
40
+ /**
41
+ * Gets the currently active authentication credentials from the global auth manager.
42
+ *
43
+ * @returns Current authentication state
44
+ */
45
+ getCurrentAuth: async () => connection.sendRequest("account.getCurrentAuth", {}),
46
+ /**
47
+ * Gets all authenticated users available for account switching.
48
+ *
49
+ * @returns List of all authenticated users
50
+ */
51
+ getAllUsers: async () => connection.sendRequest("account.getAllUsers", {}),
52
+ /**
53
+ * Stores authentication credentials after successful login (e.g., device code flow).
54
+ *
55
+ * @param params Credentials to store after successful authentication
56
+ *
57
+ * @returns Result of a successful login; throws on failure
58
+ */
59
+ login: async (params) => connection.sendRequest("account.login", params),
60
+ /**
61
+ * Removes user authentication from keychain and persisted state.
62
+ *
63
+ * @param params User to log out
64
+ *
65
+ * @returns Logout result indicating if more users remain
66
+ */
67
+ logout: async (params) => connection.sendRequest("account.logout", params)
40
68
  },
41
69
  secrets: {
42
70
  /**
@@ -281,6 +309,31 @@ function createServerRpc(connection) {
281
309
  setProvider: async (params) => connection.sendRequest("sessionFs.setProvider", params)
282
310
  },
283
311
  /** @experimental */
312
+ llmInference: {
313
+ /**
314
+ * Registers an SDK client as the LLM inference callback provider.
315
+ *
316
+ * @returns Indicates whether the calling client was registered as the LLM inference provider.
317
+ */
318
+ setProvider: async () => connection.sendRequest("llmInference.setProvider", {}),
319
+ /**
320
+ * Delivers the response head (status + headers) for an in-flight request, correlated by the requestId the runtime supplied in httpRequestStart. Must be called exactly once per request before any httpResponseChunk frames.
321
+ *
322
+ * @param params Response head.
323
+ *
324
+ * @returns Whether the start frame was accepted.
325
+ */
326
+ httpResponseStart: async (params) => connection.sendRequest("llmInference.httpResponseStart", params),
327
+ /**
328
+ * Delivers a body byte range (or a terminal transport error) for an in-flight response, correlated by requestId. Set `end` true on the last chunk. When `error` is set the response terminates with a transport-level failure and the runtime raises an APIConnectionError.
329
+ *
330
+ * @param params A response body chunk or terminal error.
331
+ *
332
+ * @returns Whether the chunk was accepted.
333
+ */
334
+ httpResponseChunk: async (params) => connection.sendRequest("llmInference.httpResponseChunk", params)
335
+ },
336
+ /** @experimental */
284
337
  sessions: {
285
338
  /**
286
339
  * Creates or resumes a local session and returns the opened session ID.
@@ -1040,10 +1093,18 @@ function createSessionRpc(connection, sessionId) {
1040
1093
  isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { sessionId, ...params }),
1041
1094
  /** @experimental */
1042
1095
  oauth: {
1096
+ /**
1097
+ * Resolves a pending MCP OAuth request with a host-provided token or cancellation. The pending request is emitted as mcp.oauth_required with the data necessary to authorize the request.
1098
+ *
1099
+ * @param params Pending MCP OAuth request ID and host-provided token or cancellation response.
1100
+ *
1101
+ * @returns Indicates whether the pending MCP OAuth response was accepted.
1102
+ */
1103
+ handlePendingRequest: async (params) => connection.sendRequest("session.mcp.oauth.handlePendingRequest", { sessionId, ...params }),
1043
1104
  /**
1044
1105
  * Starts OAuth authentication for a remote MCP server.
1045
1106
  *
1046
- * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, and the callback success-page copy.
1107
+ * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
1047
1108
  *
1048
1109
  * @returns OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
1049
1110
  */
@@ -1121,7 +1182,15 @@ function createSessionRpc(connection, sessionId) {
1121
1182
  *
1122
1183
  * @returns A snapshot of the provider endpoint the session is currently configured to talk to.
1123
1184
  */
1124
- getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params })
1185
+ getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params }),
1186
+ /**
1187
+ * Adds BYOK providers and/or models to the session's registry at runtime, extending the additive registry built from the session's `providers`/`models` options. Both fields are optional, so a call may add providers only, models only, or both. Within a single call providers are registered before models, so a model may reference a provider added in the same call; across calls a model may reference any provider already registered (from session creation or a prior add). A model whose referenced provider is not registered by the end of the call is rejected. Newly added models become selectable via `model.list` / `model.switchTo` and are inherited by sub-agents spawned afterwards.
1188
+ *
1189
+ * @param params BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
1190
+ *
1191
+ * @returns The selectable model entries synthesized for the models added by this call.
1192
+ */
1193
+ add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params })
1125
1194
  },
1126
1195
  /** @experimental */
1127
1196
  options: {
@@ -1804,7 +1873,7 @@ function createInternalSessionRpc(connection, sessionId) {
1804
1873
  /** @experimental */
1805
1874
  oauth: {
1806
1875
  /**
1807
- * Responds to a pending MCP OAuth provider request. Marked internal because the `provider` argument is an in-process OAuthClientProvider instance that cannot be carried over the wire; the public OAuth surface will route the response through a wire-clean handshake once the CLI moves on top of the SDK.
1876
+ * Responds to a pending MCP OAuth request with an in-process provider. This internal CLI-only API accepts a live OAuthClientProvider instance and cannot be used over the SDK JSON-RPC boundary. Use session.mcp.oauth.handlePendingRequest instead for the public SDK-safe response path.
1808
1877
  *
1809
1878
  * @param params MCP OAuth request id and optional provider response.
1810
1879
  *
@@ -1816,6 +1885,11 @@ function createInternalSessionRpc(connection, sessionId) {
1816
1885
  };
1817
1886
  }
1818
1887
  function registerClientSessionApiHandlers(connection, getHandlers) {
1888
+ connection.onRequest("providerToken.getToken", async (params) => {
1889
+ const handler = getHandlers(params.sessionId).providerToken;
1890
+ if (!handler) throw new Error(`No providerToken handler registered for session: ${params.sessionId}`);
1891
+ return handler.getToken(params);
1892
+ });
1819
1893
  connection.onRequest("sessionFs.readFile", async (params) => {
1820
1894
  const handler = getHandlers(params.sessionId).sessionFs;
1821
1895
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
@@ -1892,10 +1966,23 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
1892
1966
  return handler.invoke(params);
1893
1967
  });
1894
1968
  }
1969
+ function registerClientGlobalApiHandlers(connection, handlers) {
1970
+ connection.onRequest("llmInference.httpRequestStart", async (params) => {
1971
+ const handler = handlers.llmInference;
1972
+ if (!handler) throw new Error("No llmInference client-global handler registered");
1973
+ return handler.httpRequestStart(params);
1974
+ });
1975
+ connection.onRequest("llmInference.httpRequestChunk", async (params) => {
1976
+ const handler = handlers.llmInference;
1977
+ if (!handler) throw new Error("No llmInference client-global handler registered");
1978
+ return handler.httpRequestChunk(params);
1979
+ });
1980
+ }
1895
1981
  export {
1896
1982
  createInternalServerRpc,
1897
1983
  createInternalSessionRpc,
1898
1984
  createServerRpc,
1899
1985
  createSessionRpc,
1986
+ registerClientGlobalApiHandlers,
1900
1987
  registerClientSessionApiHandlers
1901
1988
  };