@github/copilot-sdk 1.0.30-preview.0 → 1.0.30-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.
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
22
22
  COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
23
23
  });
24
24
  module.exports = __toCommonJS(cliVersion_exports);
25
- const COPILOT_CLI_VERSION = "1.0.108-0";
25
+ const COPILOT_CLI_VERSION = "1.0.108-1";
26
26
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
27
27
  // Annotate the CommonJS export names for ESM import in node:
28
28
  0 && (module.exports = {
@@ -1055,7 +1055,7 @@ class CopilotClient {
1055
1055
  }
1056
1056
  }
1057
1057
  clearTimeout(detachDeadlineTimer);
1058
- for (const session of activeSessions) {
1058
+ for (const session of /* @__PURE__ */ new Set([...activeSessions, ...this.sessions.values()])) {
1059
1059
  session._markDisconnected();
1060
1060
  }
1061
1061
  this.sessions.clear();
@@ -1612,6 +1612,7 @@ class CopilotClient {
1612
1612
  const { wirePayload: wireSystemMessage, transformCallbacks } = extractTransformCallbacks(
1613
1613
  config.systemMessage
1614
1614
  );
1615
+ let replacedSession;
1615
1616
  const initializeSession = (sessionId) => {
1616
1617
  const s = new import_session.CopilotSession(sessionId, connection, void 0, this.onGetTraceContext, {
1617
1618
  mcpAuthHandler: config.onMcpAuthRequest,
@@ -1652,6 +1653,7 @@ class CopilotClient {
1652
1653
  }
1653
1654
  this.setupSessionFs(s, config);
1654
1655
  signal.throwIfAborted();
1656
+ replacedSession = this.sessions.get(sessionId);
1655
1657
  this.sessions.set(sessionId, s);
1656
1658
  return s;
1657
1659
  };
@@ -1834,8 +1836,17 @@ class CopilotClient {
1834
1836
  this.commitGitHubTokenProvider(returnedSessionId, gitHubTokenProviderRegistrationId);
1835
1837
  } catch (e) {
1836
1838
  session?._markDisconnected();
1837
- if (registeredId !== void 0 && this.sessions.get(registeredId) === session) {
1838
- this.sessions.delete(registeredId);
1839
+ if (registeredId !== void 0 && session !== void 0) {
1840
+ const current = this.sessions.get(registeredId);
1841
+ if (current === session) {
1842
+ if (replacedSession && !replacedSession._isDisconnected()) {
1843
+ this.sessions.set(registeredId, replacedSession);
1844
+ } else {
1845
+ this.sessions.delete(registeredId);
1846
+ }
1847
+ } else if (current === void 0) {
1848
+ replacedSession?._markDisconnected();
1849
+ }
1839
1850
  }
1840
1851
  if (gitHubTokenProviderRegistrationId !== void 0) {
1841
1852
  this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
@@ -1866,6 +1877,11 @@ class CopilotClient {
1866
1877
  } finally {
1867
1878
  releaseCloudInitialization?.();
1868
1879
  }
1880
+ if (session._isDisconnected()) {
1881
+ this.forgetSession(session);
1882
+ } else {
1883
+ session._setReleaseFromClient(this.forgetSession.bind(this, session));
1884
+ }
1869
1885
  for (const entry of this.hostHandoffs.values()) {
1870
1886
  if (entry.requestedSessionId === session.sessionId) {
1871
1887
  entry.configs.set(session, config);
@@ -2215,12 +2231,15 @@ class CopilotClient {
2215
2231
  if (!keepResumedSessionOnRecoveryRejection) {
2216
2232
  session._markDisconnected();
2217
2233
  }
2218
- if (this.sessions.get(sessionId) === session) {
2219
- if (replacedSession && !keepResumedSessionOnRecoveryRejection) {
2234
+ const current = this.sessions.get(sessionId);
2235
+ if (current === session) {
2236
+ if (replacedSession && !replacedSession._isDisconnected() && !keepResumedSessionOnRecoveryRejection) {
2220
2237
  this.sessions.set(sessionId, replacedSession);
2221
2238
  } else if (!keepResumedSessionOnRecoveryRejection) {
2222
2239
  this.sessions.delete(sessionId);
2223
2240
  }
2241
+ } else if (current === void 0) {
2242
+ replacedSession?._markDisconnected();
2224
2243
  }
2225
2244
  if (gitHubTokenProviderRegistrationId !== void 0) {
2226
2245
  if (keepResumedSessionOnRecoveryRejection) {
@@ -2236,6 +2255,11 @@ class CopilotClient {
2236
2255
  }
2237
2256
  releaseCanonicalInitialization?.();
2238
2257
  }
2258
+ if (session._isDisconnected()) {
2259
+ this.forgetSession(session);
2260
+ } else {
2261
+ session._setReleaseFromClient(this.forgetSession.bind(this, session));
2262
+ }
2239
2263
  for (const entry of this.hostHandoffs.values()) {
2240
2264
  if (entry.requestedSessionId === session.sessionId) {
2241
2265
  entry.configs.set(session, { ...config, sessionId });
@@ -2742,8 +2766,7 @@ class CopilotClient {
2742
2766
  signal.throwIfAborted();
2743
2767
  if (this.sessions.get(sessionId) === session) {
2744
2768
  this.sessions.delete(sessionId);
2745
- session?._clearMemoryStore();
2746
- session?._runOnDisconnected();
2769
+ session?._markDisconnected();
2747
2770
  }
2748
2771
  } finally {
2749
2772
  release();
@@ -2761,6 +2784,12 @@ class CopilotClient {
2761
2784
  throw new Error(`Failed to delete session ${sessionId}: ${error || "Unknown error"}`);
2762
2785
  }
2763
2786
  }
2787
+ /** Stops tracking a disconnected session unless a later create or resume replaced it. */
2788
+ forgetSession(session) {
2789
+ if (this.sessions.get(session.sessionId) === session) {
2790
+ this.sessions.delete(session.sessionId);
2791
+ }
2792
+ }
2764
2793
  /**
2765
2794
  * List all available sessions.
2766
2795
  *
@@ -332,6 +332,7 @@ class CopilotSession {
332
332
  completionRpcUnsupported = false;
333
333
  disconnecting = false;
334
334
  onDisconnected;
335
+ releaseFromClient;
335
336
  /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
336
337
  clientSessionApis = {};
337
338
  /**
@@ -915,6 +916,7 @@ class CopilotSession {
915
916
  return;
916
917
  }
917
918
  this.disconnected = true;
919
+ this.releaseFromClient = void 0;
918
920
  for (const fail of this.pendingResponseWaits) {
919
921
  fail(new Error("Session disconnected while waiting for a response"));
920
922
  }
@@ -974,6 +976,17 @@ class CopilotSession {
974
976
  this.assertConnected();
975
977
  this.onDisconnected = callback;
976
978
  }
979
+ /**
980
+ * @internal Lets the owning client stop tracking this session once `disconnect()`
981
+ * succeeds. Failed create/resume paths unregister the session themselves.
982
+ */
983
+ _setReleaseFromClient(callback) {
984
+ this.releaseFromClient = callback;
985
+ }
986
+ /** @internal */
987
+ _isDisconnected() {
988
+ return this.disconnected;
989
+ }
977
990
  on(eventTypeOrHandler, handler) {
978
991
  if (this.disconnected) {
979
992
  throw new Error("Session is disconnected");
@@ -2242,7 +2255,9 @@ class CopilotSession {
2242
2255
  `Failed to disconnect session ${this.sessionId}: ${response.error || "Unknown error"}`
2243
2256
  );
2244
2257
  }
2258
+ const release = this.releaseFromClient;
2245
2259
  this._markDisconnected();
2260
+ release?.();
2246
2261
  } catch (error) {
2247
2262
  this.disconnecting = false;
2248
2263
  throw error;
@@ -1,2 +1,2 @@
1
- export declare const COPILOT_CLI_VERSION = "1.0.108-0";
1
+ export declare const COPILOT_CLI_VERSION = "1.0.108-1";
2
2
  export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
@@ -1,4 +1,4 @@
1
- const COPILOT_CLI_VERSION = "1.0.108-0";
1
+ const COPILOT_CLI_VERSION = "1.0.108-1";
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
@@ -390,6 +390,8 @@ export declare class CopilotClient {
390
390
  */
391
391
  deleteSession(sessionId: string): Promise<void>;
392
392
  private requestSessionDeletion;
393
+ /** Stops tracking a disconnected session unless a later create or resume replaced it. */
394
+ private forgetSession;
393
395
  /**
394
396
  * List all available sessions.
395
397
  *
package/dist/client.js CHANGED
@@ -1039,7 +1039,7 @@ class CopilotClient {
1039
1039
  }
1040
1040
  }
1041
1041
  clearTimeout(detachDeadlineTimer);
1042
- for (const session of activeSessions) {
1042
+ for (const session of /* @__PURE__ */ new Set([...activeSessions, ...this.sessions.values()])) {
1043
1043
  session._markDisconnected();
1044
1044
  }
1045
1045
  this.sessions.clear();
@@ -1596,6 +1596,7 @@ class CopilotClient {
1596
1596
  const { wirePayload: wireSystemMessage, transformCallbacks } = extractTransformCallbacks(
1597
1597
  config.systemMessage
1598
1598
  );
1599
+ let replacedSession;
1599
1600
  const initializeSession = (sessionId) => {
1600
1601
  const s = new CopilotSession(sessionId, connection, void 0, this.onGetTraceContext, {
1601
1602
  mcpAuthHandler: config.onMcpAuthRequest,
@@ -1636,6 +1637,7 @@ class CopilotClient {
1636
1637
  }
1637
1638
  this.setupSessionFs(s, config);
1638
1639
  signal.throwIfAborted();
1640
+ replacedSession = this.sessions.get(sessionId);
1639
1641
  this.sessions.set(sessionId, s);
1640
1642
  return s;
1641
1643
  };
@@ -1818,8 +1820,17 @@ class CopilotClient {
1818
1820
  this.commitGitHubTokenProvider(returnedSessionId, gitHubTokenProviderRegistrationId);
1819
1821
  } catch (e) {
1820
1822
  session?._markDisconnected();
1821
- if (registeredId !== void 0 && this.sessions.get(registeredId) === session) {
1822
- this.sessions.delete(registeredId);
1823
+ if (registeredId !== void 0 && session !== void 0) {
1824
+ const current = this.sessions.get(registeredId);
1825
+ if (current === session) {
1826
+ if (replacedSession && !replacedSession._isDisconnected()) {
1827
+ this.sessions.set(registeredId, replacedSession);
1828
+ } else {
1829
+ this.sessions.delete(registeredId);
1830
+ }
1831
+ } else if (current === void 0) {
1832
+ replacedSession?._markDisconnected();
1833
+ }
1823
1834
  }
1824
1835
  if (gitHubTokenProviderRegistrationId !== void 0) {
1825
1836
  this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
@@ -1850,6 +1861,11 @@ class CopilotClient {
1850
1861
  } finally {
1851
1862
  releaseCloudInitialization?.();
1852
1863
  }
1864
+ if (session._isDisconnected()) {
1865
+ this.forgetSession(session);
1866
+ } else {
1867
+ session._setReleaseFromClient(this.forgetSession.bind(this, session));
1868
+ }
1853
1869
  for (const entry of this.hostHandoffs.values()) {
1854
1870
  if (entry.requestedSessionId === session.sessionId) {
1855
1871
  entry.configs.set(session, config);
@@ -2199,12 +2215,15 @@ class CopilotClient {
2199
2215
  if (!keepResumedSessionOnRecoveryRejection) {
2200
2216
  session._markDisconnected();
2201
2217
  }
2202
- if (this.sessions.get(sessionId) === session) {
2203
- if (replacedSession && !keepResumedSessionOnRecoveryRejection) {
2218
+ const current = this.sessions.get(sessionId);
2219
+ if (current === session) {
2220
+ if (replacedSession && !replacedSession._isDisconnected() && !keepResumedSessionOnRecoveryRejection) {
2204
2221
  this.sessions.set(sessionId, replacedSession);
2205
2222
  } else if (!keepResumedSessionOnRecoveryRejection) {
2206
2223
  this.sessions.delete(sessionId);
2207
2224
  }
2225
+ } else if (current === void 0) {
2226
+ replacedSession?._markDisconnected();
2208
2227
  }
2209
2228
  if (gitHubTokenProviderRegistrationId !== void 0) {
2210
2229
  if (keepResumedSessionOnRecoveryRejection) {
@@ -2220,6 +2239,11 @@ class CopilotClient {
2220
2239
  }
2221
2240
  releaseCanonicalInitialization?.();
2222
2241
  }
2242
+ if (session._isDisconnected()) {
2243
+ this.forgetSession(session);
2244
+ } else {
2245
+ session._setReleaseFromClient(this.forgetSession.bind(this, session));
2246
+ }
2223
2247
  for (const entry of this.hostHandoffs.values()) {
2224
2248
  if (entry.requestedSessionId === session.sessionId) {
2225
2249
  entry.configs.set(session, { ...config, sessionId });
@@ -2726,8 +2750,7 @@ class CopilotClient {
2726
2750
  signal.throwIfAborted();
2727
2751
  if (this.sessions.get(sessionId) === session) {
2728
2752
  this.sessions.delete(sessionId);
2729
- session?._clearMemoryStore();
2730
- session?._runOnDisconnected();
2753
+ session?._markDisconnected();
2731
2754
  }
2732
2755
  } finally {
2733
2756
  release();
@@ -2745,6 +2768,12 @@ class CopilotClient {
2745
2768
  throw new Error(`Failed to delete session ${sessionId}: ${error || "Unknown error"}`);
2746
2769
  }
2747
2770
  }
2771
+ /** Stops tracking a disconnected session unless a later create or resume replaced it. */
2772
+ forgetSession(session) {
2773
+ if (this.sessions.get(session.sessionId) === session) {
2774
+ this.sessions.delete(session.sessionId);
2775
+ }
2776
+ }
2748
2777
  /**
2749
2778
  * List all available sessions.
2750
2779
  *
@@ -8520,7 +8520,7 @@ export interface AgentGetCurrentResult {
8520
8520
  /**
8521
8521
  * Currently selected custom agent, or null if using the default agent
8522
8522
  */
8523
- agent?: AgentInfo | null;
8523
+ agent: AgentInfo | null;
8524
8524
  }
8525
8525
  /**
8526
8526
  * Agent metadata, including identifiers, display details, source, tools, model, models, reasoning effort, MCP servers, skills, and file path.
@@ -22861,7 +22861,7 @@ export interface NamedProviderConfig {
22861
22861
  [k: string]: string | undefined;
22862
22862
  };
22863
22863
  /**
22864
- * The product serving the provider's models, reported in telemetry as `model_provider`. Besides telemetry, `azure_openai` makes OpenAI Responses requests omit explicit `prompt_cache_breakpoint` markers, which limit cross-turn cache reuse on Azure.
22864
+ * The product serving the provider's models, reported in telemetry as `model_provider`. Only affects telemetry.
22865
22865
  */
22866
22866
  modelProvider?: ProviderConfigModelProvider;
22867
22867
  /**
@@ -26420,7 +26420,7 @@ export interface ProviderConfig {
26420
26420
  */
26421
26421
  providerName?: string;
26422
26422
  /**
26423
- * The product serving the model, reported in telemetry as `model_provider`. Set it when `type` alone cannot identify the product, such as Ollama or LM Studio behind an OpenAI-compatible endpoint, or a proxy or custom domain in front of Azure OpenAI. Besides telemetry, `azure_openai` makes OpenAI Responses requests omit explicit `prompt_cache_breakpoint` markers, which limit cross-turn cache reuse on Azure.
26423
+ * The product serving the model, reported in telemetry as `model_provider`. Set it when `type` alone cannot identify the product, such as Ollama or LM Studio behind an OpenAI-compatible endpoint. Only affects telemetry.
26424
26424
  */
26425
26425
  modelProvider?: ProviderConfigModelProvider;
26426
26426
  /**
package/dist/session.d.ts CHANGED
@@ -78,6 +78,7 @@ export declare class CopilotSession {
78
78
  private completionRpcUnsupported;
79
79
  private disconnecting;
80
80
  private onDisconnected?;
81
+ private releaseFromClient?;
81
82
  /**
82
83
  * Friendly workflow API for running registered workflows by name or handle.
83
84
  *
package/dist/session.js CHANGED
@@ -319,6 +319,7 @@ class CopilotSession {
319
319
  completionRpcUnsupported = false;
320
320
  disconnecting = false;
321
321
  onDisconnected;
322
+ releaseFromClient;
322
323
  /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
323
324
  clientSessionApis = {};
324
325
  /**
@@ -902,6 +903,7 @@ class CopilotSession {
902
903
  return;
903
904
  }
904
905
  this.disconnected = true;
906
+ this.releaseFromClient = void 0;
905
907
  for (const fail of this.pendingResponseWaits) {
906
908
  fail(new Error("Session disconnected while waiting for a response"));
907
909
  }
@@ -961,6 +963,17 @@ class CopilotSession {
961
963
  this.assertConnected();
962
964
  this.onDisconnected = callback;
963
965
  }
966
+ /**
967
+ * @internal Lets the owning client stop tracking this session once `disconnect()`
968
+ * succeeds. Failed create/resume paths unregister the session themselves.
969
+ */
970
+ _setReleaseFromClient(callback) {
971
+ this.releaseFromClient = callback;
972
+ }
973
+ /** @internal */
974
+ _isDisconnected() {
975
+ return this.disconnected;
976
+ }
964
977
  on(eventTypeOrHandler, handler) {
965
978
  if (this.disconnected) {
966
979
  throw new Error("Session is disconnected");
@@ -2229,7 +2242,9 @@ class CopilotSession {
2229
2242
  `Failed to disconnect session ${this.sessionId}: ${response.error || "Unknown error"}`
2230
2243
  );
2231
2244
  }
2245
+ const release = this.releaseFromClient;
2232
2246
  this._markDisconnected();
2247
+ release?.();
2233
2248
  } catch (error) {
2234
2249
  this.disconnecting = false;
2235
2250
  throw error;
package/dist/types.d.ts CHANGED
@@ -3102,9 +3102,7 @@ export interface ProviderConfig {
3102
3102
  transport?: "http" | "websockets";
3103
3103
  /**
3104
3104
  * Product serving the model, such as "ollama" or "lm_studio", reported in
3105
- * telemetry as `model_provider`. "azure_openai" also omits explicit
3106
- * prompt-cache breakpoints, which limit cross-turn cache reuse on Azure; set
3107
- * it for a proxy or custom domain in front of Azure OpenAI.
3105
+ * telemetry as `model_provider`. Only affects telemetry.
3108
3106
  */
3109
3107
  modelProvider?: ProviderConfigModelProvider;
3110
3108
  /**
@@ -3208,9 +3206,7 @@ export interface NamedProviderConfig {
3208
3206
  wireApi?: "completions" | "responses";
3209
3207
  /**
3210
3208
  * Product serving this provider's models, such as "ollama" or "lm_studio",
3211
- * reported in telemetry as `model_provider`. "azure_openai" also omits
3212
- * explicit prompt-cache breakpoints, which limit cross-turn cache reuse on
3213
- * Azure; set it for a proxy or custom domain in front of Azure OpenAI.
3209
+ * reported in telemetry as `model_provider`. Only affects telemetry.
3214
3210
  */
3215
3211
  modelProvider?: ProviderConfigModelProvider;
3216
3212
  /**
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "url": "https://github.com/github/copilot-agent-runtime.git",
6
6
  "directory": "src/sdk/nodejs"
7
7
  },
8
- "version": "1.0.30-preview.0",
9
- "copilotCliVersion": "1.0.108-0",
8
+ "version": "1.0.30-preview.1",
9
+ "copilotCliVersion": "1.0.108-1",
10
10
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
11
11
  "main": "./dist/cjs/index.js",
12
12
  "types": "./dist/index.d.ts",
@@ -52,6 +52,7 @@
52
52
  "lint:fix": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\"",
53
53
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
54
54
  "generate": "cd ../scripts/codegen && npm run generate",
55
+ "generate:java-compat-fixtures": "tsx test/generate-java-compat-fixtures.ts",
55
56
  "set:cli-version": "node scripts/set-cli-version.js",
56
57
  "update:protocol-version": "tsx scripts/update-protocol-version.ts",
57
58
  "vendor:tools": "tsx scripts/vendor-build-tools.ts",
@@ -103,7 +104,7 @@
103
104
  "overrides": {
104
105
  "file-entry-cache": "$file-entry-cache",
105
106
  "glob": "$glob",
106
- "minimatch": "^11.0.4",
107
+ "minimatch": "11.0.2",
107
108
  "prettier": "$prettier",
108
109
  "vite": "$vite"
109
110
  },
@@ -117,18 +118,18 @@
117
118
  "README.md"
118
119
  ],
119
120
  "copilotRuntime": {
120
- "sourceSha": "0b6fd711aceb7d1b08736913111176774483cce6",
121
- "version": "1.0.108-0",
121
+ "sourceSha": "b4db2d4d6e538963777bfe225a166511699de1e7",
122
+ "version": "1.0.108-1",
122
123
  "visibility": "public"
123
124
  },
124
125
  "optionalDependencies": {
125
- "@github/copilot-sdk-darwin-arm64": "1.0.30-preview.0",
126
- "@github/copilot-sdk-darwin-x64": "1.0.30-preview.0",
127
- "@github/copilot-sdk-linux-arm64": "1.0.30-preview.0",
128
- "@github/copilot-sdk-linux-x64": "1.0.30-preview.0",
129
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.30-preview.0",
130
- "@github/copilot-sdk-linuxmusl-x64": "1.0.30-preview.0",
131
- "@github/copilot-sdk-win32-arm64": "1.0.30-preview.0",
132
- "@github/copilot-sdk-win32-x64": "1.0.30-preview.0"
126
+ "@github/copilot-sdk-darwin-arm64": "1.0.30-preview.1",
127
+ "@github/copilot-sdk-darwin-x64": "1.0.30-preview.1",
128
+ "@github/copilot-sdk-linux-arm64": "1.0.30-preview.1",
129
+ "@github/copilot-sdk-linux-x64": "1.0.30-preview.1",
130
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.30-preview.1",
131
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.30-preview.1",
132
+ "@github/copilot-sdk-win32-arm64": "1.0.30-preview.1",
133
+ "@github/copilot-sdk-win32-x64": "1.0.30-preview.1"
133
134
  }
134
135
  }