@github/copilot-sdk 1.0.28 → 1.0.29-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/README.md CHANGED
@@ -41,6 +41,24 @@ verify all eight platforms.
41
41
  npm install @github/copilot-sdk
42
42
  ```
43
43
 
44
+ ## Model provider metadata
45
+
46
+ `client.listModels()` and `client.rpc.models.list()` preserve the runtime's optional
47
+ `provider` reference on each model: `{ id, kind, label }`. The existing `Model`,
48
+ `ModelInfo`, and `ModelProviderRef` types are available from the package root.
49
+ Native kinds remain `copilot` and `loki`; `id` is opaque and `label` is display text.
50
+ Configured BYOK and older, unattributed rows omit `provider`; do not infer Copilot
51
+ branding from a model ID or fill it from the active account. This metadata identifies
52
+ the model source, not the agent harness, an account, or a new routing/selection API.
53
+
54
+ ## Kerberos authentication callback
55
+
56
+ Provide `kerberosAuth: { mode, callback }` in `CopilotClientOptions` when Kerberos tickets must be obtained by the SDK host, for example from Windows when the runtime runs in WSL. The runtime currently uses it for proxy authentication. The callback receives `{ spn }`, a service principal in the platform-independent `service/host[@REALM]` form, and returns a fresh base64 SPNEGO token without the `Negotiate ` prefix, or `undefined` when credentials are unavailable. The callback should validate the principal before issuing credentials. Its second argument is an `AbortSignal` that fires when the runtime stops waiting (it cancels the request, for example after its timeout, or the connection closes); the SDK then stops awaiting the callback and ignores any later result.
57
+
58
+ With `mode: "fallback"`, native credential acquisition (including the first token) is tried first; only failure invokes the callback. With `mode: "always"`, native credential lookup is never attempted. Without this option, behavior is unchanged. Registration happens during `start()`, before sessions can be created.
59
+
60
+ By default the callback authenticates only requests made for sessions this client creates or resumes. With `scope: "runtime"` it also authenticates the runtime's shared background traffic, such as catalog refreshes and telemetry; only one connection at a time can hold that scope, so startup fails if another client holds it. The registration ends when the connection closes. In `fallback` mode, if the callback cannot supply a valid token, the native credential error is reported. In `always` mode, a disconnected, throwing, or empty callback fails authentication. The runtime waits at most 30 seconds for the callback (less when the request's own deadline is sooner) and treats a timeout as a callback failure. Tokens are not cached and must not be logged or persisted. The callback supplies the initial SPNEGO token only; exchanges requiring continuation tokens still need native negotiation.
61
+
44
62
  ## Runtime-supervised AHP host (experimental)
45
63
 
46
64
  `startAhpHost()` requires `authentication`: `github`, or direct-only `none` / `custom`
@@ -275,16 +293,15 @@ new CopilotClient(options?: CopilotClientOptions)
275
293
  - `logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all"` - Log level. When omitted, the runtime uses its own default (currently `"info"`).
276
294
  - `env?: Record<string, string | undefined>` - Environment variables for the runtime process. When omitted, inherits `process.env`.
277
295
 
278
- For the native standalone runtime, set `COPILOT_GITHUB_TELEMETRY_DISABLED=true`
279
- before startup to disable direct GitHub telemetry uploads for the entire host,
280
- including session and sessionless events. Authentication, SDK
281
- `onGitHubTelemetry` forwarding, and user-configured OpenTelemetry export remain
282
- unchanged. The value must be exactly `"true"` and is read at startup; changing
283
- it requires a runtime restart. With `RuntimeConnection.forInProcess()`, set it
284
- in the host process environment; per-client `env` is rejected for that
285
- transport. This is separate from `enableSessionTelemetry: false`, which
286
- disables only a session's telemetry pipeline. The Node CLI host does not use
287
- this environment variable.
296
+ Set `COPILOT_TELEMETRY_DISABLED=true` before startup to disable Copilot-owned
297
+ GitHub and Entra authentication telemetry process-wide, including sessionless
298
+ events. Authentication, SDK `onGitHubTelemetry` forwarding, and user-configured
299
+ OpenTelemetry remain unchanged. The value must be exactly `"true"`; restart
300
+ the process to change it. With `RuntimeConnection.forInProcess()`, set the host
301
+ process environment; per-client `env` is rejected. `enableSessionTelemetry: false`
302
+ affects only the session pipeline. The existing native-runtime-only
303
+ `COPILOT_GITHUB_TELEMETRY_DISABLED=true` remains GitHub-only; the Node CLI host
304
+ uses the general variable or `--disable-client-telemetry` instead.
288
305
 
289
306
  - `gitHubToken?: string` - GitHub token for authentication. When provided, takes priority over other auth methods.
290
307
  - `useLoggedInUser?: boolean` - Whether to use logged-in user for authentication (default: true, but false when `gitHubToken` is provided). Cannot be used with `RuntimeConnection.forUri`.
@@ -372,7 +389,7 @@ Retirement releases session-owned tool, hook, auth/input, provider, workflow, ca
372
389
  and transform registrations without changing caller-owned configuration. Late
373
390
  registration and callback dispatch are rejected; callbacks already admitted may finish.
374
391
 
375
- ##### `createSession(config?: SessionConfig): Promise<CopilotSession>`
392
+ ##### `createSession(config: SessionConfig): Promise<CopilotSession>`
376
393
 
377
394
  Create a new conversation session.
378
395
 
@@ -389,6 +406,7 @@ Create a new conversation session.
389
406
  - `trustWorkingDirectory?: "session" | "user"` - Grant trust to the canonical working directory during session creation. `"session"` trusts it only for this session; `"user"` persists trust for later sessions. Omit to leave trust unchanged. Not available on resume.
390
407
  - `refreshCustomInstructions?: boolean` - Invalidates the process-wide custom-instruction discovery cache before creating this session, so instruction-file edits made in the same runtime are read again. Defaults to `false` (cache reuse). Other sessions in this runtime may observe updated instructions on later turns or discovery. This does not watch files or enable disabled instruction loading. Available on `SessionConfig`, not `ResumeSessionConfig`.
391
408
  - `enableSessionStore?: boolean` - Enables the cross-session store for search and retrieval across sessions. When unset in `"copilot-cli"` mode, the runtime default applies (enabled). In `"empty"` mode, defaults to disabled.
409
+ - `enableSessionTelemetry?: boolean` - Disables internal session telemetry only when set to `false`. Omission or `true` enables it for eligible GitHub-authenticated sessions, including custom-provider (BYOK) sessions. Host and account policies still control uploads; this is separate from OpenTelemetry configuration.
392
410
  - `gitHubTokenProvider?: GitHubTokenProvider` - Acquires rotating, session-scoped GitHub tokens. Token results require a positive `expiresIn` value in seconds remaining when the callback completes; production tokens typically last eight hours. Cannot be combined with `gitHubToken`.
393
411
  - `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section.
394
412
  - `onPermissionRequest?: PermissionHandler` - Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `approveAll` approves requests when managed settings are disabled and throws when `enableManagedSettings` is true. Custom handlers can inspect `managedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section.
@@ -411,7 +429,7 @@ const session = await client.createSession({
411
429
 
412
430
  Initial acquisition runs during session creation or resume. Cancellation, provider errors, and invalid token responses reject that operation instead of falling back to ambient authentication. Idle sessions refresh only before their next credential-consuming operation; there is no background refresh timer.
413
431
 
414
- ##### `resumeSession(sessionId: string, config?: ResumeSessionConfig): Promise<CopilotSession>`
432
+ ##### `resumeSession(sessionId: string, config: ResumeSessionConfig): Promise<CopilotSession>`
415
433
 
416
434
  Both create and resume accept experimental `autopilot: AutopilotOptions`, and
417
435
  `session.rpc.options.update({ autopilot: ... })` patches the same policy.
@@ -816,7 +834,7 @@ await session.send({
816
834
  });
817
835
  ```
818
836
 
819
- Supported image formats include JPG, PNG, GIF, and other common image types. The agent's `view` tool can also read images directly from the filesystem, so you can also ask questions like:
837
+ Supported image formats are PNG, JPEG, WebP, and GIF. Images in other formats, such as BMP or TIFF, are not sent to the model. The agent's `view` tool can also read images directly from the filesystem, so you can also ask questions like:
820
838
 
821
839
  ```typescript
822
840
  await session.send({ prompt: "What does the most recent jpg in this directory portray?" });
@@ -1475,6 +1493,33 @@ security checks, user permissions, or sandbox policy. `permissions.limitTo` neit
1475
1493
  enables the sandbox nor changes `sandbox.userPolicy.network`; configure sandbox
1476
1494
  network restrictions explicitly.
1477
1495
 
1496
+ ### Policy Helper failures and scoped recheck
1497
+
1498
+ Snapshots may expose `policyHelperFailure` and `policyHelperCapabilities`.
1499
+ Recheck requires session opt-in through `enableManagedSettings: true`.
1500
+ Treat helper text as untrusted plain text, keep `diagnostic` secondary,
1501
+ and sanitize `helpLink` before navigation.
1502
+
1503
+ ```typescript
1504
+ const snapshot = await session.rpc.managedSettings.get();
1505
+
1506
+ if (snapshot.policyHelperFailure) {
1507
+ console.warn(snapshot.policyHelperFailure.message);
1508
+ }
1509
+
1510
+ if (snapshot.policyHelperCapabilities?.recheck === true) {
1511
+ const refreshed = await session.rpc.managedSettings.recheckPolicyHelper();
1512
+ // Only a current capable snapshot without policyHelperFailure establishes recovery.
1513
+ console.log(refreshed.policyHelperFailure ?? "Policy Helper recovered");
1514
+ }
1515
+ ```
1516
+
1517
+ Older runtimes omit `policyHelperCapabilities`. Do not infer support or recovery
1518
+ only because `policyHelperFailure` is absent. Only applicable `session.create` and
1519
+ `session.resume` failures attach it to `error.data.policyHelperFailure`, retaining
1520
+ the primary code/message. Activation callers read
1521
+ `managedSettings.resolve(...).resolved.policyHelperFailure` instead.
1522
+
1478
1523
  ### Permission Result Kinds
1479
1524
 
1480
1525
  The handler must return one of the `PermissionDecision` shapes (or `{ kind: "no-result" }`). Approval scopes are present-tense — they describe the decision to apply, not the outcome reported back on session events:
@@ -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.105";
25
+ const COPILOT_CLI_VERSION = "1.0.106-2";
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 = {
@@ -36,7 +36,7 @@ var import_node_crypto = require("node:crypto");
36
36
  var import_node_fs = require("node:fs");
37
37
  var import_node_net = require("node:net");
38
38
  var import_node_path = require("node:path");
39
- var import_node = require("vscode-jsonrpc/node.js");
39
+ var import_node = require("vscode-jsonrpc/node");
40
40
  var import_rpc = require("./generated/rpc.js");
41
41
  var import_sdkProtocolVersion = require("./sdkProtocolVersion.js");
42
42
  var import_session = require("./session.js");
@@ -46,6 +46,7 @@ var import_cliVersion = require("./cliVersion.js");
46
46
  var import_sessionFsProvider = require("./sessionFsProvider.js");
47
47
  var import_copilotRequestHandler = require("./copilotRequestHandler.js");
48
48
  var import_installationConfirmation = require("./installationConfirmation.js");
49
+ var import_entra = require("./entra.js");
49
50
  var import_telemetry = require("./telemetry.js");
50
51
  var import_schema = require("./schema.js");
51
52
  var import_toolSet = require("./toolSet.js");
@@ -148,6 +149,30 @@ async function waitForChildExit(child, timeoutMs) {
148
149
  }
149
150
  });
150
151
  }
152
+ async function acquireKerberosToken(connection, callback, request, token) {
153
+ const ended = () => token.isCancellationRequested ? new import_node.ResponseError(-32800, "Kerberos auth request cancelled") : new Error("Kerberos auth connection closed");
154
+ if (token.isCancellationRequested) {
155
+ throw ended();
156
+ }
157
+ const controller = new AbortController();
158
+ const abandoned = new Promise((_resolve, reject) => {
159
+ controller.signal.addEventListener("abort", () => reject(ended()), { once: true });
160
+ });
161
+ const abort = () => controller.abort();
162
+ const subscriptions = [
163
+ token.onCancellationRequested(abort),
164
+ connection.onClose(abort),
165
+ connection.onDispose(abort)
166
+ ];
167
+ try {
168
+ const lookup = Promise.resolve().then(() => callback(request, controller.signal));
169
+ return { token: await Promise.race([lookup, abandoned]) };
170
+ } finally {
171
+ for (const subscription of subscriptions) {
172
+ subscription.dispose();
173
+ }
174
+ }
175
+ }
151
176
  const DEFAULT_PROVIDER_NAME = "default";
152
177
  function extractBearerTokenProviders(provider, providers) {
153
178
  const callbacks = /* @__PURE__ */ new Map();
@@ -325,6 +350,7 @@ class CopilotClient {
325
350
  sessionFsConfig = null;
326
351
  requestHandler = null;
327
352
  extensionLaunchProvider;
353
+ kerberosAuth;
328
354
  installationConfirmationHandler;
329
355
  builtinPluginDirectories = [];
330
356
  onGitHubTelemetry;
@@ -484,6 +510,7 @@ class CopilotClient {
484
510
  this.sessionFsConfig = options.sessionFs ?? null;
485
511
  this.requestHandler = options.requestHandler ?? null;
486
512
  this.extensionLaunchProvider = options.extensionLaunchProvider;
513
+ this.kerberosAuth = options.kerberosAuth;
487
514
  this.installationConfirmationHandler = options.installationConfirmationHandler;
488
515
  this.onGitHubTelemetry = options.onGitHubTelemetry;
489
516
  this.setupClientGlobalHandlers();
@@ -499,7 +526,7 @@ class CopilotClient {
499
526
  const connArgs = conn.kind === "stdio" || conn.kind === "tcp" ? conn.args ?? [] : [];
500
527
  this.connectionExtraArgs = [...connArgs];
501
528
  this.options = {
502
- entra: options.entra ? { ...options.entra } : void 0,
529
+ entra: options.entra ? { ...options.entra, tokenProvider: options.entra.tokenProvider } : void 0,
503
530
  workingDirectory: options.workingDirectory ?? process.cwd(),
504
531
  logLevel: options.logLevel,
505
532
  gitHubToken: options.gitHubToken,
@@ -588,6 +615,11 @@ class CopilotClient {
588
615
  "SessionFsConfig declares capabilities.binary but the provider does not implement readFileBytes and writeFileBytes."
589
616
  );
590
617
  }
618
+ if (this.sessionFsConfig.capabilities?.readFileRange && !provider.readFileRange) {
619
+ throw new Error(
620
+ "SessionFsConfig declares capabilities.readFileRange but the provider does not implement readFileRange."
621
+ );
622
+ }
591
623
  session.clientSessionApis.sessionFs = (0, import_sessionFsProvider.createSessionFsAdapter)(provider);
592
624
  }
593
625
  setupClientGlobalHandlers() {
@@ -722,6 +754,10 @@ class CopilotClient {
722
754
  }
723
755
  await this.connectToServer();
724
756
  await this.verifyProtocolVersion();
757
+ if (this.kerberosAuth) {
758
+ const { mode, scope } = this.kerberosAuth;
759
+ await this.rpc.kerberosAuth.setProvider(scope ? { mode, scope } : { mode });
760
+ }
725
761
  if (this.extensionLaunchProvider) {
726
762
  await this.rpc.registerExtensionLaunchProvider();
727
763
  }
@@ -1236,7 +1272,7 @@ class CopilotClient {
1236
1272
  if (config.cloud != null && config.skillProvider) {
1237
1273
  throw new Error("Skill providers are not supported for cloud sessions.");
1238
1274
  }
1239
- if (!this.connection) {
1275
+ if (!this.connection || this.startPromise) {
1240
1276
  await this.start();
1241
1277
  }
1242
1278
  const modeDefaults = this.configDefaultsForMode();
@@ -1390,6 +1426,7 @@ class CopilotClient {
1390
1426
  ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
1391
1427
  mcpServers: toWireMcpServers(config.mcpServers),
1392
1428
  ...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
1429
+ ...config.lifecycleDiagnostics !== void 0 ? { lifecycleDiagnostics: config.lifecycleDiagnostics } : {},
1393
1430
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
1394
1431
  authClientIdMetadataUrl: config.authClientIdMetadataUrl,
1395
1432
  envValueMode: "direct",
@@ -1527,7 +1564,7 @@ class CopilotClient {
1527
1564
  if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
1528
1565
  throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
1529
1566
  }
1530
- if (!this.connection) {
1567
+ if (!this.connection || this.startPromise) {
1531
1568
  await this.start();
1532
1569
  }
1533
1570
  const session = new import_session.CopilotSession(
@@ -1675,6 +1712,7 @@ class CopilotClient {
1675
1712
  ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
1676
1713
  mcpServers: toWireMcpServers(config.mcpServers),
1677
1714
  ...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
1715
+ ...config.lifecycleDiagnostics !== void 0 ? { lifecycleDiagnostics: config.lifecycleDiagnostics } : {},
1678
1716
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
1679
1717
  authClientIdMetadataUrl: config.authClientIdMetadataUrl,
1680
1718
  envValueMode: "direct",
@@ -2105,7 +2143,11 @@ class CopilotClient {
2105
2143
  let serverVersion;
2106
2144
  try {
2107
2145
  const connectParams = {
2108
- entra: this.options.entra,
2146
+ entra: this.options.entra && {
2147
+ clientId: this.options.entra.clientId,
2148
+ matsAppName: this.options.entra.matsAppName
2149
+ },
2150
+ entraTokenProvider: this.options.entra?.tokenProvider ? true : void 0,
2109
2151
  token: this.effectiveConnectionToken,
2110
2152
  supportedTaskKinds: ["agent", "client", "shell"]
2111
2153
  };
@@ -2117,6 +2159,9 @@ class CopilotClient {
2117
2159
  connectParams.clientInfo = clientInfo;
2118
2160
  }
2119
2161
  const result = await raceAgainstExit(this.internalRpc.connect(connectParams));
2162
+ if (this.options.entra?.tokenProvider && result.entraTokenProvider !== true) {
2163
+ throw new Error("This runtime does not support host-owned Entra token providers.");
2164
+ }
2120
2165
  serverVersion = result.protocolVersion;
2121
2166
  } catch (err) {
2122
2167
  if (err instanceof import_node.ResponseError && (err.code === import_node.ErrorCodes.MethodNotFound || err.message === "Unhandled method connect")) {
@@ -2373,8 +2418,10 @@ class CopilotClient {
2373
2418
  if (t.filePath !== void 0) env.COPILOT_OTEL_FILE_EXPORTER_PATH = t.filePath;
2374
2419
  if (t.exporterType !== void 0) env.COPILOT_OTEL_EXPORTER_TYPE = t.exporterType;
2375
2420
  if (t.sourceName !== void 0) env.COPILOT_OTEL_SOURCE_NAME = t.sourceName;
2376
- if (t.captureContent !== void 0)
2421
+ if (t.captureContent !== void 0) {
2422
+ env.OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT = t.captureContent ? "SPAN_ONLY" : "NO_CONTENT";
2377
2423
  env.OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = String(t.captureContent);
2424
+ }
2378
2425
  }
2379
2426
  return env;
2380
2427
  }
@@ -2755,6 +2802,9 @@ stderr: ${stderrOutput}` : ""}`
2755
2802
  return session.clientSessionApis;
2756
2803
  });
2757
2804
  (0, import_rpc.registerClientGlobalApiHandlers)(this.connection, this.clientGlobalHandlers);
2805
+ if (this.options.entra?.tokenProvider) {
2806
+ (0, import_entra.registerEntraTokenProvider)(this.connection, this.options.entra.tokenProvider);
2807
+ }
2758
2808
  if (this.installationConfirmationHandler) {
2759
2809
  const confirmation = (0, import_installationConfirmation.createInstallationConfirmationAdapter)(
2760
2810
  this.connection,
@@ -2765,6 +2815,14 @@ stderr: ${stderrOutput}` : ""}`
2765
2815
  (params, token) => confirmation.confirm(params, token)
2766
2816
  );
2767
2817
  }
2818
+ if (this.kerberosAuth) {
2819
+ const { callback } = this.kerberosAuth;
2820
+ const connection2 = this.connection;
2821
+ this.connection.onRequest(
2822
+ "kerberosAuth.acquire",
2823
+ (params, token) => acquireKerberosToken(connection2, callback, params, token)
2824
+ );
2825
+ }
2768
2826
  this.connection.onRequest(
2769
2827
  "host.materializeSession",
2770
2828
  (params) => this.createHostSession(params)
@@ -0,0 +1,83 @@
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 entra_exports = {};
20
+ __export(entra_exports, {
21
+ registerEntraTokenProvider: () => registerEntraTokenProvider
22
+ });
23
+ module.exports = __toCommonJS(entra_exports);
24
+ var import_node = require("vscode-jsonrpc/node");
25
+ function registerEntraTokenProvider(connection, provider) {
26
+ const closed = new import_node.CancellationTokenSource();
27
+ const connectionClosed = closed.token;
28
+ const close = connection.onClose(() => closed.cancel());
29
+ const dispose = connection.onDispose(() => {
30
+ closed.cancel();
31
+ closed.dispose();
32
+ close.dispose();
33
+ dispose.dispose();
34
+ });
35
+ connection.onRequest(
36
+ "entraToken.getToken",
37
+ async ({ request }, token) => {
38
+ const combined = new import_node.CancellationTokenSource();
39
+ const subscriptions = [];
40
+ const checkCancellation = () => {
41
+ if (connectionClosed.isCancellationRequested || token.isCancellationRequested) {
42
+ combined.cancel();
43
+ throw new import_node.ResponseError(-32800, "Entra token acquisition cancelled");
44
+ }
45
+ };
46
+ try {
47
+ const cancelled = new Promise((_resolve, reject) => {
48
+ const cancel = () => {
49
+ combined.cancel();
50
+ reject(new import_node.ResponseError(-32800, "Entra token acquisition cancelled"));
51
+ };
52
+ subscriptions.push(
53
+ token.onCancellationRequested(cancel),
54
+ connectionClosed.onCancellationRequested(cancel)
55
+ );
56
+ });
57
+ checkCancellation();
58
+ const result = await Promise.race([
59
+ Promise.resolve().then(() => {
60
+ checkCancellation();
61
+ return provider(request, combined.token);
62
+ }),
63
+ cancelled
64
+ ]);
65
+ checkCancellation();
66
+ if (result === void 0 || result === null) {
67
+ throw new import_node.ResponseError(-32603, "Entra token provider failed");
68
+ }
69
+ return result;
70
+ } catch {
71
+ checkCancellation();
72
+ throw new import_node.ResponseError(-32603, "Entra token provider failed");
73
+ } finally {
74
+ for (const subscription of subscriptions) subscription.dispose();
75
+ combined.dispose();
76
+ }
77
+ }
78
+ );
79
+ }
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ registerEntraTokenProvider
83
+ });
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var lifecycle_diagnostics_exports = {};
16
+ module.exports = __toCommonJS(lifecycle_diagnostics_exports);