@github/copilot-sdk 1.0.15 → 1.0.16

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.
@@ -28,6 +28,60 @@ __export(rpc_exports, {
28
28
  module.exports = __toCommonJS(rpc_exports);
29
29
  function createServerRpc(connection) {
30
30
  return {
31
+ /** @experimental */
32
+ environments: {
33
+ /**
34
+ * Lists GitHub Mission Control environments visible to the authenticated identity. Does not require a running host and excludes host relay credentials.
35
+ *
36
+ * @param params Optional discovery filters supported by GitHub Mission Control.
37
+ *
38
+ * @returns Environments visible to the authenticated caller and matching the supplied filters.
39
+ */
40
+ list: async (params) => connection.sendRequest("environments.list", params),
41
+ /**
42
+ * Gets safe discovery information for a GitHub Mission Control environment without requiring a running host.
43
+ *
44
+ * @param params Identify a Mission Control environment to retrieve.
45
+ *
46
+ * @returns Safe discovery information for the requested environment.
47
+ */
48
+ get: async (params) => connection.sendRequest("environments.get", params),
49
+ /**
50
+ * Deletes a user-managed GitHub Mission Control environment. GitHub-managed environments cannot be deleted. Does not stop a running host, which may register again.
51
+ *
52
+ * @param params Identify a user-managed Mission Control environment to delete.
53
+ *
54
+ * @returns Acknowledgement that the requested environment was deleted.
55
+ */
56
+ delete: async (params) => connection.sendRequest("environments.delete", params)
57
+ },
58
+ /** @experimental */
59
+ host: {
60
+ /**
61
+ * Publishes an attached resident session for this listener's lifetime without copying it.
62
+ *
63
+ * @param params Publishes a resident session attached to the listener's owning connection.
64
+ *
65
+ * @returns The existing runtime identity and its resource on the listener.
66
+ */
67
+ publishSession: async (params) => connection.sendRequest("host.publishSession", params),
68
+ /**
69
+ * Starts a connection-owned AHP host with explicit localServer and/or githubEnvironment transports as a supervised SDK participant.
70
+ *
71
+ * @param params Starts a supervised AHP host with at least one explicitly selected transport.
72
+ *
73
+ * @returns Listener readiness, returned only after binding and the supervised participant's SDK handshake.
74
+ */
75
+ start: async (params) => connection.sendRequest("host.start", params),
76
+ /**
77
+ * Stops a listener owned by this SDK connection and joins its cleanup without deleting sessions.
78
+ *
79
+ * @param params Stops a connection-owned listener and joins its teardown.
80
+ *
81
+ * @returns Empty acknowledgement for a completed host lifecycle operation.
82
+ */
83
+ dispose: async (params) => connection.sendRequest("host.dispose", params)
84
+ },
31
85
  /**
32
86
  * Checks server responsiveness and returns protocol information.
33
87
  *
@@ -860,6 +914,45 @@ function createServerRpc(connection) {
860
914
  }
861
915
  function createInternalServerRpc(connection) {
862
916
  return {
917
+ /** @experimental */
918
+ host: {
919
+ /**
920
+ * Requests app-owned materialization over the owning SDK participant.
921
+ *
922
+ * @param params One application-owned session handoff, requested by the supervised hosting participant.
923
+ *
924
+ * @returns The resident session the application has materialized on its own connection.
925
+ */
926
+ createSession: async (params) => connection.sendRequest("host.createSession", params),
927
+ /**
928
+ * Releases app ownership retention after AHP detaches.
929
+ *
930
+ * @param params Ends one participation, not the application's session lifetime.
931
+ *
932
+ * @returns Empty acknowledgement for a completed host lifecycle operation.
933
+ */
934
+ releaseSession: async (params) => connection.sendRequest("host.releaseSession", params),
935
+ /**
936
+ * Resolves current authenticated credentials and remote-control policy only for the runtime-owned Mission Control hosting participant.
937
+ *
938
+ * @returns Private credentials delivered only to a runtime-owned Mission Control hosting participant.
939
+ */
940
+ getEnvironmentCredentials: async () => connection.sendRequest("host.getEnvironmentCredentials", {}),
941
+ /**
942
+ * Returns listener settings only to the supervised hosting participant over its SDK connection.
943
+ *
944
+ * @returns Normalized listener settings delivered only to the supervised hosting participant.
945
+ */
946
+ getConfiguration: async () => connection.sendRequest("host.getConfiguration", {}),
947
+ /**
948
+ * Reports a supervised hosting participant's bound AHP endpoint after its SDK handshake.
949
+ *
950
+ * @param params Readiness reported by the supervised hosting participant on its own SDK connection.
951
+ *
952
+ * @returns Empty acknowledgement for a completed host lifecycle operation.
953
+ */
954
+ ready: async (params) => connection.sendRequest("host.ready", params)
955
+ },
863
956
  /**
864
957
  * Performs the SDK server connection handshake and validates the optional connection token. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
865
958
  *
@@ -981,7 +1074,15 @@ function createSessionRpc(connection, sessionId) {
981
1074
  *
982
1075
  * @returns Result of attempting to disable sandboxing for the current session.
983
1076
  */
984
- disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params })
1077
+ disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params }),
1078
+ /**
1079
+ * Adds the path offered by a pending sandbox escalation permission request's sandboxPathGrant to the session's sandbox policy and approves the request, so the blocked operation re-runs inside the sandbox rather than outside it. The request is rejected unless the exact request is still pending, carries a sandboxPathGrant, and the grant still takes effect under the current managed policy. Does not persist the path; hosts that store sandbox settings save it themselves.
1080
+ *
1081
+ * @param params Request to accept the sandbox path grant offered on an active sandbox escalation permission prompt.
1082
+ *
1083
+ * @returns Result of accepting a sandbox path grant.
1084
+ */
1085
+ grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { sessionId, ...params })
985
1086
  },
986
1087
  /**
987
1088
  * Aborts the current agent turn.
@@ -2189,7 +2290,15 @@ function createSessionRpc(connection, sessionId) {
2189
2290
  *
2190
2291
  * @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
2191
2292
  */
2192
- sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params })
2293
+ sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params }),
2294
+ /**
2295
+ * Withdraws named host-managed models from the session's BYOK registry, leaving every other entry untouched. The scoped counterpart to `provider.sync`: a snapshot can only describe entries the caller knows about, so using it to remove one model silently withdraws rows registered by another source, such as a plugin calling `provider.add` at runtime. Naming what to remove leaves unrelated entries alone. Selection ids that are not registered are ignored, so withdrawal is idempotent. A provider is removed only when one of the withdrawn models was the last entry referencing it; a provider that simply has no models, which is the normal state while its rows are supplied by catalog discovery, is left in place.
2296
+ *
2297
+ * @param params Host-managed model selection ids to withdraw from the session's BYOK registry.
2298
+ *
2299
+ * @returns What the withdrawal actually removed from the registry.
2300
+ */
2301
+ withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { sessionId, ...params })
2193
2302
  },
2194
2303
  /** @experimental */
2195
2304
  options: {
@@ -3442,6 +3551,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
3442
3551
  });
3443
3552
  }
3444
3553
  function registerClientGlobalApiHandlers(connection, handlers) {
3554
+ connection.onNotification("host.exited", async (params) => {
3555
+ const handler = handlers.host;
3556
+ if (!handler) return;
3557
+ await handler.exited(params);
3558
+ });
3445
3559
  connection.onRequest("extensionLaunchProvider.resolve", async (params) => {
3446
3560
  const handler = handlers.extensionLaunchProvider;
3447
3561
  if (!handler) throw new Error("No extensionLaunchProvider client-global handler registered");
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var host_exports = {};
20
+ __export(host_exports, {
21
+ AhpHost: () => AhpHost
22
+ });
23
+ module.exports = __toCommonJS(host_exports);
24
+ class AhpHost {
25
+ /** @internal */
26
+ constructor(info, disposeHost, publishHostSession) {
27
+ this.disposeHost = disposeHost;
28
+ this.publishHostSession = publishHostSession;
29
+ this.hostId = info.hostId;
30
+ this.url = info.url;
31
+ this.environmentId = info.environmentId;
32
+ this.token = info.token;
33
+ this.pid = info.pid;
34
+ }
35
+ disposeHost;
36
+ publishHostSession;
37
+ hostId;
38
+ /** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
39
+ url;
40
+ /** Mission Control environment ID, when GitHub hosting is enabled. */
41
+ environmentId;
42
+ /** Connection token, when required by the listener. Treat this value as a secret. */
43
+ token;
44
+ /** Legacy separate host process ID. Absent for in-process listeners; use dispose() to stop. */
45
+ pid;
46
+ /** Ask the runtime to stop the listener and await its cleanup, on every call. */
47
+ dispose() {
48
+ return this.disposeHost();
49
+ }
50
+ /** Publish an existing session attached to this client, until this listener stops. */
51
+ publishSession(sessionId) {
52
+ return this.publishHostSession(sessionId);
53
+ }
54
+ async [Symbol.asyncDispose]() {
55
+ await this.dispose();
56
+ }
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ AhpHost
61
+ });
package/dist/cjs/index.js CHANGED
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var index_exports = {};
20
20
  __export(index_exports, {
21
+ AhpHost: () => import_host.AhpHost,
21
22
  BuiltInTools: () => import_toolSet.BuiltInTools,
22
23
  Canvas: () => import_canvas.Canvas,
23
24
  CanvasError: () => import_canvas.CanvasError,
@@ -44,6 +45,7 @@ __export(index_exports, {
44
45
  });
45
46
  module.exports = __toCommonJS(index_exports);
46
47
  var import_client = require("./client.js");
48
+ var import_host = require("./host.js");
47
49
  var import_types = require("./types.js");
48
50
  var import_toolSet = require("./toolSet.js");
49
51
  var import_session = require("./session.js");
@@ -52,6 +54,7 @@ var import_canvas = require("./canvas.js");
52
54
  var import_types2 = require("./types.js");
53
55
  // Annotate the CommonJS export names for ESM import in node:
54
56
  0 && (module.exports = {
57
+ AhpHost,
55
58
  BuiltInTools,
56
59
  Canvas,
57
60
  CanvasError,
@@ -1,2 +1,2 @@
1
- export declare const COPILOT_CLI_VERSION = "1.0.89";
1
+ export declare const COPILOT_CLI_VERSION = "1.0.90";
2
2
  export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
@@ -1,4 +1,4 @@
1
- const COPILOT_CLI_VERSION = "1.0.89";
1
+ const COPILOT_CLI_VERSION = "1.0.90";
2
2
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
3
3
  export {
4
4
  COPILOT_CLI_USE_NPM_PACKAGE,
package/dist/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createServerRpc } from "./generated/rpc.js";
2
2
  import { CopilotSession } from "./session.js";
3
+ import { AhpHost, type AhpHostOptions } from "./host.js";
3
4
  import type { CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse, ModelInfo, ResumeSessionConfig, SessionConfig, SessionLifecycleEventType, SessionLifecycleHandler, SessionListFilter, SessionMetadata, TypedSessionLifecycleHandler } from "./types.js";
4
5
  export declare class CopilotClient {
5
6
  private cliStartTimeout;
@@ -16,6 +17,9 @@ export declare class CopilotClient {
16
17
  /** Shared in-flight start; concurrent callers await it instead of spawning another CLI. */
17
18
  private startPromise;
18
19
  private sessions;
20
+ private hostExitCallbacks;
21
+ private hostSessionFactories;
22
+ private hostHandoffs;
19
23
  private stderrBuffer;
20
24
  /** Resolved connection mode chosen in the constructor. */
21
25
  private connectionConfig;
@@ -135,7 +139,8 @@ export declare class CopilotClient {
135
139
  * 1. Closes all active sessions (releases in-memory resources)
136
140
  * 2. Requests runtime shutdown for SDK-owned CLI processes
137
141
  * 3. Closes the JSON-RPC connection
138
- * 4. Terminates the CLI server process (if spawned by this client)
142
+ * 4. Signals EOF to an owned stdio process and waits for host cleanup, then
143
+ * terminates the process if it does not exit within the shutdown timeout
139
144
  *
140
145
  * Note: session data on disk is preserved, so sessions can be resumed later.
141
146
  * To permanently remove session data before stopping, call
@@ -242,6 +247,27 @@ export declare class CopilotClient {
242
247
  */
243
248
  resumeSession(sessionId: string, config: ResumeSessionConfig): Promise<CopilotSession>;
244
249
  private resumeSessionInternal;
250
+ /**
251
+ * Start a complete AHP listener hosted in-process by this runtime.
252
+ *
253
+ * This connection owns the host. Disposing it or disconnecting the client
254
+ * stops the listener without deleting sessions. The host uses a separate
255
+ * SDK connection to the same runtime, not another runtime process.
256
+ * Only one AHP host may own the catalog in an effective Copilot home
257
+ * at a time. Other SDK clients and sessions remain usable in that home.
258
+ * Select localServer, githubEnvironment, or both. An empty localServer
259
+ * selects 127.0.0.1 on an available port. `onExit` runs at most once; owner disconnection cannot
260
+ * acknowledge listener cleanup over the disconnected transport.
261
+ *
262
+ * @experimental
263
+ */
264
+ startAhpHost(options: AhpHostOptions): Promise<AhpHost>;
265
+ private handleHostExit;
266
+ private disconnectHosts;
267
+ private releaseHostSessions;
268
+ private releaseHostSession;
269
+ private notifyHostSessionReleased;
270
+ private createHostSession;
245
271
  /**
246
272
  * Sends a ping request to the server to verify connectivity.
247
273
  *