@github/copilot-sdk-linuxmusl-x64 1.0.14-preview.1 → 1.0.14

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.
@@ -3318,7 +3318,7 @@ var require_empty_npm_package = __commonJS({
3318
3318
  }
3319
3319
  });
3320
3320
 
3321
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/ffiRuntimeHost.js
3321
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/ffiRuntimeHost.js
3322
3322
  var ffiRuntimeHost_exports = {};
3323
3323
  __export(ffiRuntimeHost_exports, {
3324
3324
  FfiRuntimeHost: () => FfiRuntimeHost
@@ -3391,12 +3391,13 @@ function buildEnvJson(environment) {
3391
3391
  }
3392
3392
  return Buffer.from(JSON.stringify(obj), "utf8");
3393
3393
  }
3394
- var import_koffi, SYMBOL_PREFIX, KEEP_ALIVE_INTERVAL_MS, loadedLibraryPath, loadedLibrary, FfiRuntimeHost;
3394
+ var import_koffi, SYMBOL_PREFIX, KEEP_ALIVE_INTERVAL_MS, CLEANUP_RETRY_INTERVAL_MS, loadedLibraryPath, loadedLibrary, FfiRuntimeHost;
3395
3395
  var init_ffiRuntimeHost = __esm({
3396
- "node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/ffiRuntimeHost.js"() {
3396
+ "node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/ffiRuntimeHost.js"() {
3397
3397
  import_koffi = __toESM(require_empty_npm_package(), 1);
3398
3398
  SYMBOL_PREFIX = "copilot_runtime_";
3399
3399
  KEEP_ALIVE_INTERVAL_MS = 1 << 30;
3400
+ CLEANUP_RETRY_INTERVAL_MS = 100;
3400
3401
  FfiRuntimeHost = class _FfiRuntimeHost {
3401
3402
  constructor(libraryPath, cliEntrypoint, environment, args) {
3402
3403
  this.libraryPath = libraryPath;
@@ -3422,12 +3423,16 @@ var init_ffiRuntimeHost = __esm({
3422
3423
  cliEntrypoint;
3423
3424
  environment;
3424
3425
  args;
3426
+ static quarantinedHosts = /* @__PURE__ */ new Set();
3425
3427
  lib;
3426
3428
  serverId = 0;
3427
3429
  connectionId = 0;
3428
3430
  disposed = false;
3431
+ starting = false;
3429
3432
  outboundCallback;
3430
3433
  keepAliveTimer;
3434
+ cleanupRetryTimer;
3435
+ cleanupInProgress = false;
3431
3436
  /** The stream JSON-RPC reads server→client frames from. */
3432
3437
  receiveStream;
3433
3438
  /** The stream JSON-RPC writes client→server frames to. */
@@ -3449,49 +3454,65 @@ var init_ffiRuntimeHost = __esm({
3449
3454
  }
3450
3455
  /** Starts the in-process Rust runtime and opens the FFI JSON-RPC connection. */
3451
3456
  async start() {
3457
+ if (this.disposed) {
3458
+ throw new Error("The in-process runtime host is disposed.");
3459
+ }
3460
+ this.starting = true;
3452
3461
  const argvJson = buildArgvJson(this.cliEntrypoint, this.args);
3453
3462
  const envJson = buildEnvJson(this.environment);
3454
- this.serverId = await new Promise((resolvePromise, rejectPromise) => {
3455
- this.lib.hostStart.async(
3456
- argvJson,
3457
- argvJson.length,
3458
- envJson,
3459
- envJson ? envJson.length : 0,
3460
- (error, result) => {
3461
- if (error) {
3462
- rejectPromise(error);
3463
- } else {
3464
- resolvePromise(result);
3463
+ try {
3464
+ this.serverId = await new Promise((resolvePromise, rejectPromise) => {
3465
+ this.lib.hostStart.async(
3466
+ argvJson,
3467
+ argvJson.length,
3468
+ envJson,
3469
+ envJson ? envJson.length : 0,
3470
+ (error, result) => {
3471
+ if (error) {
3472
+ rejectPromise(error);
3473
+ } else {
3474
+ resolvePromise(result);
3475
+ }
3465
3476
  }
3466
- }
3477
+ );
3478
+ });
3479
+ if (!this.serverId) {
3480
+ throw new Error(
3481
+ `copilot_runtime_host_start failed (library '${this.libraryPath}').`
3482
+ );
3483
+ }
3484
+ if (this.disposed) {
3485
+ throw new Error("The in-process runtime host was disposed during startup.");
3486
+ }
3487
+ this.outboundCallback = import_koffi.default.register(
3488
+ (_userData, bytesPtr, bytesLen) => this.feedInbound(bytesPtr, bytesLen),
3489
+ this.lib.outboundCallbackType
3467
3490
  );
3468
- });
3469
- if (!this.serverId) {
3470
- throw new Error(`copilot_runtime_host_start failed (library '${this.libraryPath}').`);
3471
- }
3472
- this.outboundCallback = import_koffi.default.register(
3473
- (_userData, bytesPtr, bytesLen) => this.feedInbound(bytesPtr, bytesLen),
3474
- this.lib.outboundCallbackType
3475
- );
3476
- this.connectionId = this.lib.connectionOpen(
3477
- this.serverId,
3478
- this.outboundCallback,
3479
- null,
3480
- null,
3481
- 0,
3482
- null,
3483
- 0,
3484
- null,
3485
- 0
3486
- );
3487
- if (!this.connectionId) {
3488
- this.unregisterCallback();
3489
- this.lib.hostShutdown(this.serverId);
3490
- this.serverId = 0;
3491
- throw new Error("copilot_runtime_connection_open failed.");
3491
+ this.connectionId = this.lib.connectionOpen(
3492
+ this.serverId,
3493
+ this.outboundCallback,
3494
+ null,
3495
+ null,
3496
+ 0,
3497
+ null,
3498
+ 0,
3499
+ null,
3500
+ 0
3501
+ );
3502
+ if (!this.connectionId) {
3503
+ this.unregisterCallback();
3504
+ this.lib.hostShutdown(this.serverId);
3505
+ this.serverId = 0;
3506
+ throw new Error("copilot_runtime_connection_open failed.");
3507
+ }
3508
+ this.keepAliveTimer = setInterval(() => {
3509
+ }, KEEP_ALIVE_INTERVAL_MS);
3510
+ } finally {
3511
+ this.starting = false;
3512
+ if (this.disposed) {
3513
+ void this.tryFinalizeCleanup();
3514
+ }
3492
3515
  }
3493
- this.keepAliveTimer = setInterval(() => {
3494
- }, KEEP_ALIVE_INTERVAL_MS);
3495
3516
  }
3496
3517
  writeFrame(frame) {
3497
3518
  if (this.disposed || !this.connectionId) {
@@ -3530,57 +3551,119 @@ var init_ffiRuntimeHost = __esm({
3530
3551
  }
3531
3552
  unregisterCallback() {
3532
3553
  if (this.outboundCallback === void 0) {
3533
- return;
3554
+ return true;
3534
3555
  }
3535
3556
  const callback = this.outboundCallback;
3536
- this.outboundCallback = void 0;
3537
3557
  try {
3538
3558
  import_koffi.default.unregister(callback);
3539
- } catch {
3559
+ this.outboundCallback = void 0;
3560
+ return true;
3561
+ } catch (error) {
3562
+ console.error(
3563
+ `Failed to unregister in-process FFI callback: ${error instanceof Error ? error.stack ?? error.message : String(error)}`
3564
+ );
3565
+ _FfiRuntimeHost.quarantinedHosts.add(this);
3566
+ return false;
3540
3567
  }
3541
3568
  }
3542
- /** Closes the FFI connection, shuts down the native host, and releases resources. */
3543
- dispose() {
3544
- if (this.disposed) {
3569
+ scheduleCleanupRetry() {
3570
+ if (this.cleanupRetryTimer !== void 0) {
3545
3571
  return;
3546
3572
  }
3547
- this.disposed = true;
3548
- if (this.keepAliveTimer !== void 0) {
3549
- clearInterval(this.keepAliveTimer);
3550
- this.keepAliveTimer = void 0;
3573
+ this.cleanupRetryTimer = setTimeout(() => {
3574
+ this.cleanupRetryTimer = void 0;
3575
+ void this.tryFinalizeCleanup();
3576
+ }, CLEANUP_RETRY_INTERVAL_MS);
3577
+ }
3578
+ async tryFinalizeCleanup() {
3579
+ if (this.cleanupInProgress) {
3580
+ this.scheduleCleanupRetry();
3581
+ return;
3551
3582
  }
3583
+ this.cleanupInProgress = true;
3552
3584
  try {
3553
3585
  if (this.connectionId) {
3554
- this.lib.connectionClose(this.connectionId);
3586
+ let closed = false;
3587
+ try {
3588
+ closed = await new Promise((resolvePromise, rejectPromise) => {
3589
+ this.lib.connectionClose.async(
3590
+ this.connectionId,
3591
+ (error, result) => {
3592
+ if (error) {
3593
+ rejectPromise(error);
3594
+ } else {
3595
+ resolvePromise(result);
3596
+ }
3597
+ }
3598
+ );
3599
+ });
3600
+ } catch (error) {
3601
+ console.error(
3602
+ `Failed to close in-process FFI connection: ${error instanceof Error ? error.stack ?? error.message : String(error)}`
3603
+ );
3604
+ _FfiRuntimeHost.quarantinedHosts.add(this);
3605
+ if (this.keepAliveTimer !== void 0) {
3606
+ clearInterval(this.keepAliveTimer);
3607
+ this.keepAliveTimer = void 0;
3608
+ }
3609
+ return;
3610
+ }
3611
+ if (!closed) {
3612
+ this.scheduleCleanupRetry();
3613
+ return;
3614
+ }
3555
3615
  this.connectionId = 0;
3556
3616
  }
3557
- } catch {
3558
- }
3559
- try {
3617
+ const callbackUnregistered = this.unregisterCallback();
3618
+ if (this.keepAliveTimer !== void 0) {
3619
+ clearInterval(this.keepAliveTimer);
3620
+ this.keepAliveTimer = void 0;
3621
+ }
3560
3622
  if (this.serverId) {
3561
- this.lib.hostShutdown(this.serverId);
3623
+ try {
3624
+ if (!this.lib.hostShutdown(this.serverId)) {
3625
+ console.error(
3626
+ `In-process FFI host shutdown did not recognize server ${this.serverId}.`
3627
+ );
3628
+ }
3629
+ } catch (error) {
3630
+ console.error(
3631
+ `Failed to shut down in-process FFI host: ${error instanceof Error ? error.stack ?? error.message : String(error)}`
3632
+ );
3633
+ }
3562
3634
  this.serverId = 0;
3563
3635
  }
3564
- } catch {
3636
+ if (callbackUnregistered) {
3637
+ _FfiRuntimeHost.quarantinedHosts.delete(this);
3638
+ }
3639
+ } finally {
3640
+ this.cleanupInProgress = false;
3641
+ }
3642
+ }
3643
+ /** Awaits the initial cleanup attempt; a non-quiescent close is retried in the background. */
3644
+ async dispose() {
3645
+ if (this.disposed) {
3646
+ return;
3565
3647
  }
3648
+ this.disposed = true;
3566
3649
  this.receiveStream.end();
3567
- this.unregisterCallback();
3650
+ if (!this.starting) {
3651
+ await this.tryFinalizeCleanup();
3652
+ }
3568
3653
  }
3569
3654
  };
3570
3655
  }
3571
3656
  });
3572
3657
 
3573
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/client.js
3658
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/client.js
3574
3659
  var import_node2 = __toESM(require_node(), 1);
3575
3660
  import { spawn } from "node:child_process";
3576
3661
  import { randomUUID } from "node:crypto";
3577
3662
  import { existsSync as existsSync3 } from "node:fs";
3578
- import { createRequire } from "node:module";
3579
- import { Socket } from "node:net";
3663
+ import { isIPv6, Socket } from "node:net";
3580
3664
  import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve2 } from "node:path";
3581
- import { fileURLToPath } from "node:url";
3582
3665
 
3583
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/generated/rpc.js
3666
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/generated/rpc.js
3584
3667
  function createServerRpc(connection) {
3585
3668
  return {
3586
3669
  /**
@@ -3594,6 +3677,17 @@ function createServerRpc(connection) {
3594
3677
  */
3595
3678
  ping: async (params) => connection.sendRequest("ping", params),
3596
3679
  /** @experimental */
3680
+ hooks: {
3681
+ /**
3682
+ * Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
3683
+ *
3684
+ * @param params Optional project paths and host-exclusion behavior for server-scoped hook discovery.
3685
+ *
3686
+ * @returns Server-discovered hook actions and partial-load diagnostics from user, repository, plugin, and managed-policy sources. Concrete sessions may include additional session-specific hook sources.
3687
+ */
3688
+ discover: async (params) => connection.sendRequest("hooks.discover", params)
3689
+ },
3690
+ /** @experimental */
3597
3691
  models: {
3598
3692
  /**
3599
3693
  * Lists Copilot models available to the authenticated user.
@@ -3810,13 +3904,13 @@ function createServerRpc(connection) {
3810
3904
  /**
3811
3905
  * Enables installed plugins for new sessions.
3812
3906
  *
3813
- * @param params Plugin names (or specs) to enable.
3907
+ * @param params Plugin names (or specs) to enable, plus the optional working directory the repository-controlled guard is evaluated against.
3814
3908
  */
3815
3909
  enable: async (params) => connection.sendRequest("plugins.enable", params),
3816
3910
  /**
3817
3911
  * Disables installed plugins for new sessions.
3818
3912
  *
3819
- * @param params Plugin names (or specs) to disable.
3913
+ * @param params Plugin names (or specs) to disable, plus the optional working directory the repository-controlled guard is evaluated against.
3820
3914
  */
3821
3915
  disable: async (params) => connection.sendRequest("plugins.disable", params),
3822
3916
  /** @experimental */
@@ -3982,7 +4076,11 @@ function createServerRpc(connection) {
3982
4076
  *
3983
4077
  * @returns Validated device-managed settings discovered before a session exists.
3984
4078
  */
3985
- read: async () => connection.sendRequest("managedSettings.read", {})
4079
+ read: async () => connection.sendRequest("managedSettings.read", {}),
4080
+ /**
4081
+ * Force-refreshes enterprise managed settings for every account: wipes the persistent server-policy cache (the whole `<cacheHome>/managed-settings` directory) and drops this runtime process's in-memory retained server policy. It does not itself fetch policy — the effect is that the next time a session resolves managed settings for an account, that resolution re-fetches the account's org policy from the network instead of serving a cached response. Note that `managedSettings.read` returns only device/MDM settings and never triggers the account server-policy fetch, so a host implementing "sync account policy" should start a fresh session resolution rather than treat a subsequent `managedSettings.read` as the refreshed org policy. Mirrors the invalidation a sign-out performs, broadened from the one signing-out account to all of them; device/MDM layers describe the machine, not the account, and are left untouched. Rejects if the on-disk cache cannot be removed.
4082
+ */
4083
+ clearCache: async () => connection.sendRequest("managedSettings.clearCache", {})
3986
4084
  },
3987
4085
  /** @experimental */
3988
4086
  runtime: {
@@ -4061,6 +4159,22 @@ function createServerRpc(connection) {
4061
4159
  * @returns Sessions matching the filter, ordered most-recently-modified first.
4062
4160
  */
4063
4161
  list: async (params) => connection.sendRequest("sessions.list", params),
4162
+ /**
4163
+ * Reads client-owned metadata for multiple persisted local sessions without opening them. Results preserve request order and report missing, corrupt, unsupported, or temporarily unavailable sessions independently.
4164
+ *
4165
+ * @param params Bounded batch request for client-owned metadata from persisted local sessions.
4166
+ *
4167
+ * @returns Ordered client metadata outcomes for the requested local sessions.
4168
+ */
4169
+ getClientMetadata: async (params) => connection.sendRequest("sessions.getClientMetadata", params),
4170
+ /**
4171
+ * Reads a page of durable events directly from a local session's persisted journal without creating, resuming, or activating the session. The first read pins the currently opened journal generation and its byte-length boundary; opaque cursor continuations remain on that generation across runtime-owned compaction, truncation, and rewrite operations, which replace the live path atomically, and events appended after the boundary are excluded. For cold hydration, await the first successful page before activation and establish lossless live-event buffering before resume; merge subsequent live events by ID, preserving persisted order and letting live payloads win. Continuations are process-local, single-use capabilities bound to the originating session and storage context and must be paged sequentially; concurrent or repeated use of the same cursor expires that duplicate read rather than reading the generation twice. A complete snapshot has cursorStatus 'ok' and hasMore false. Snapshots expire after five idle minutes, with at most eight retained per process and idle-only eviction under pressure; completion and cancelled-worker exit release their handles. No transcript copy is created, but retained handles may keep replaced files' disk blocks alive until release. Pages have a soft 1 MiB serialized event-array budget including resolved binary assets; one oversized event is returned alone to guarantee progress. Working memory also includes a record/lookahead and asset resolution; resolving the first binary reference may scan the full pinned generation to build a bounded offset index. If the snapshot expires, is evicted, is cancelled before a continuation is established, or becomes unreadable after an observable unsupported in-place shortening, the continuation returns cursorStatus 'expired' with an empty terminal page and never falls back to a different generation. A missing or initially unreadable journal is an RPC error. Persisted history excludes ephemeral events and may omit payloads that are reconstructed only for an active session; use the active session event stream for post-resume live events.
4172
+ *
4173
+ * @param params Pagination options for reading an inactive or active local session's persisted event journal.
4174
+ *
4175
+ * @returns Batch of session events returned by a read, with cursor and continuation metadata.
4176
+ */
4177
+ readPersistedEvents: async (params) => connection.sendRequest("sessions.readPersistedEvents", params),
4064
4178
  /**
4065
4179
  * Finds the local session bound to a GitHub task ID, if any.
4066
4180
  *
@@ -4335,7 +4449,15 @@ function createSessionRpc(connection, sessionId) {
4335
4449
  *
4336
4450
  * @returns Managed sandbox enforcement state for a session.
4337
4451
  */
4338
- getEnforcementStatus: async () => connection.sendRequest("session.sandbox.getEnforcementStatus", { sessionId })
4452
+ getEnforcementStatus: async () => connection.sendRequest("session.sandbox.getEnforcementStatus", { sessionId }),
4453
+ /**
4454
+ * Disables sandboxing for the remainder of the current session and approves the referenced pending sandbox-bypass permission request. The request is rejected unless the exact request is still pending and the effective sandbox policy permits bypass.
4455
+ *
4456
+ * @param params Request to disable sandboxing for the current session while resolving an active sandbox-bypass permission prompt.
4457
+ *
4458
+ * @returns Result of attempting to disable sandboxing for the current session.
4459
+ */
4460
+ disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params })
4339
4461
  },
4340
4462
  /**
4341
4463
  * Aborts the current agent turn.
@@ -4499,6 +4621,14 @@ function createSessionRpc(connection, sessionId) {
4499
4621
  * @returns Complete current or terminal factory run envelope.
4500
4622
  */
4501
4623
  cancel: async (params) => connection.sendRequest("session.factory.cancel", { sessionId, ...params }),
4624
+ /**
4625
+ * Pauses a running factory and returns its settled run envelope.
4626
+ *
4627
+ * @param params Parameters for pausing a running factory.
4628
+ *
4629
+ * @returns Complete current or terminal factory run envelope.
4630
+ */
4631
+ pause: async (params) => connection.sendRequest("session.factory.pause", { sessionId, ...params }),
4502
4632
  /**
4503
4633
  * Records a batch of ordered factory progress lines.
4504
4634
  *
@@ -4538,9 +4668,9 @@ function createSessionRpc(connection, sessionId) {
4538
4668
  /** @experimental */
4539
4669
  model: {
4540
4670
  /**
4541
- * Gets the currently selected model for the session.
4671
+ * Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
4542
4672
  *
4543
- * @returns The currently selected model, reasoning effort, and context tier for the session. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
4673
+ * @returns The session's authoritative model snapshot. Auto preference fields are configuration for the virtual `auto` model and do not change the selected model identifier. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
4544
4674
  */
4545
4675
  getCurrent: async () => connection.sendRequest("session.model.getCurrent", { sessionId }),
4546
4676
  /**
@@ -4551,6 +4681,22 @@ function createSessionRpc(connection, sessionId) {
4551
4681
  * @returns The model identifier active on the session after the switch.
4552
4682
  */
4553
4683
  switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params }),
4684
+ /**
4685
+ * Requests an Auto preference change without changing the session's selected model. The latest unclaimed request wins; the runtime commits it only after a later prompt using the `auto` model mints a usable model and token pair. A `pending` response confirms that the request was accepted, not that it committed. Observe eventual success through `session.model_change`, failure through the ephemeral `session.auto_tier_switch_failed` event, or current unclaimed state through `session.model.getCurrent`.
4686
+ *
4687
+ * @param params An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
4688
+ *
4689
+ * @returns Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
4690
+ */
4691
+ switchAutoTier: async (params) => connection.sendRequest("session.model.switchAutoTier", { sessionId, ...params }),
4692
+ /**
4693
+ * Replaces or clears the host-supplied model allowlist for a running session.
4694
+ *
4695
+ * @param params Host-supplied exact model selection IDs to allow for this running session. CAPI IDs are intersected with repository `.github/allowed_models.txt` policy; provider-qualified IDs remain exempt from repository-only policy but are restricted by this host list. Omit or pass null to clear the host restriction; an explicit empty or disjoint list is rejected. Validation and pre-selection fallback failures preserve the previous restriction. Failures after a fallback selection commits retain the new restriction and selected model; callers should inspect current session state after such an error.
4696
+ *
4697
+ * @returns The applied host allowlist and effective session model policy after intersection.
4698
+ */
4699
+ setAllowedModels: async (params) => connection.sendRequest("session.model.setAllowedModels", { sessionId, ...params }),
4554
4700
  /**
4555
4701
  * Updates the session's reasoning effort without changing the selected model.
4556
4702
  *
@@ -4757,6 +4903,15 @@ function createSessionRpc(connection, sessionId) {
4757
4903
  diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
4758
4904
  },
4759
4905
  /** @experimental */
4906
+ autopilotObjective: {
4907
+ /**
4908
+ * Reads the current canonical autopilot objective state for this session.
4909
+ *
4910
+ * @returns Canonical runtime state for the session's current autopilot objective.
4911
+ */
4912
+ getState: async () => connection.sendRequest("session.autopilotObjective.getState", { sessionId })
4913
+ },
4914
+ /** @experimental */
4760
4915
  completions: {
4761
4916
  /**
4762
4917
  * Gets the characters that should trigger host-driven completions for the session. Empty disables host-driven completions (e.g. local sessions, or a relay host that does not advertise them).
@@ -4787,7 +4942,7 @@ function createSessionRpc(connection, sessionId) {
4787
4942
  /**
4788
4943
  * Starts fleet mode by submitting the fleet orchestration prompt to the session.
4789
4944
  *
4790
- * @param params Optional user prompt to combine with the fleet orchestration instructions.
4945
+ * @param params Parameters for starting fleet orchestration: an optional user prompt combined with the fleet instructions, plus the send options forwarded to the resulting turn.
4791
4946
  *
4792
4947
  * @returns Indicates whether fleet mode was successfully activated.
4793
4948
  */
@@ -4850,6 +5005,22 @@ function createSessionRpc(connection, sessionId) {
4850
5005
  * @returns Background tasks currently tracked by the session.
4851
5006
  */
4852
5007
  list: async () => connection.sendRequest("session.tasks.list", { sessionId }),
5008
+ /**
5009
+ * Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
5010
+ *
5011
+ * @param params Registers or reclaims a client-owned task.
5012
+ *
5013
+ * @returns Result of registering or reclaiming a client-owned task.
5014
+ */
5015
+ register: async (params) => connection.sendRequest("session.tasks.register", { sessionId, ...params }),
5016
+ /**
5017
+ * Publishes generic progress or a terminal outcome for a client-owned task.
5018
+ *
5019
+ * @param params Updates a client-owned task.
5020
+ *
5021
+ * @returns Result of publishing a client-owned task update.
5022
+ */
5023
+ update: async (params) => connection.sendRequest("session.tasks.update", { sessionId, ...params }),
4853
5024
  /**
4854
5025
  * Refreshes metadata for any detached background shells the runtime knows about.
4855
5026
  *
@@ -5313,7 +5484,7 @@ function createSessionRpc(connection, sessionId) {
5313
5484
  */
5314
5485
  set: async (params) => connection.sendRequest("session.tools.set", { sessionId, ...params }),
5315
5486
  /**
5316
- * Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
5487
+ * Sets the current session's live subagent settings override, which takes precedence over persisted user settings until cleared. Persisted user settings remain the source of truth for future sessions.
5317
5488
  *
5318
5489
  * @param params Subagent settings to apply to the current session
5319
5490
  *
@@ -5663,6 +5834,20 @@ function createSessionRpc(connection, sessionId) {
5663
5834
  * @returns Point-in-time snapshot of slow-changing session identifier and state fields
5664
5835
  */
5665
5836
  snapshot: async () => connection.sendRequest("session.metadata.snapshot", { sessionId }),
5837
+ /**
5838
+ * Returns the client-owned string metadata persisted with this local session. The metadata is not included in model context, events, telemetry, snapshots, or remote exports.
5839
+ *
5840
+ * @returns Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
5841
+ */
5842
+ getClientMetadata: async () => connection.sendRequest("session.metadata.getClientMetadata", { sessionId }),
5843
+ /**
5844
+ * Atomically patches the client-owned string metadata persisted with this local session and returns the committed bag.
5845
+ *
5846
+ * @param params Atomic patch for client-owned session metadata. Operations apply in clear, remove, then set order. The resulting bag must satisfy the ClientMetadata entry and serialized-size limits. Local storage coordinates concurrent runtime processes; custom SessionFs providers must serialize writers that access the same session from multiple processes.
5847
+ *
5848
+ * @returns Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
5849
+ */
5850
+ updateClientMetadata: async (params) => connection.sendRequest("session.metadata.updateClientMetadata", { sessionId, ...params }),
5666
5851
  /**
5667
5852
  * Reports whether the local session is currently processing user/agent messages.
5668
5853
  *
@@ -6020,6 +6205,294 @@ function createSessionRpc(connection, sessionId) {
6020
6205
  }
6021
6206
  };
6022
6207
  }
6208
+ function createInternalSessionRpc(connection, sessionId) {
6209
+ return {
6210
+ /**
6211
+ * Queues or sends an internal system notification to the session according to its passive policy.
6212
+ *
6213
+ * @param params Internal request for sending a system notification.
6214
+ *
6215
+ * @experimental
6216
+ */
6217
+ sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { sessionId, ...params }),
6218
+ /** @experimental */
6219
+ gitHubAuth: {
6220
+ /**
6221
+ * Gets the current authentication information for internal session hosts.
6222
+ *
6223
+ * @returns Current authentication information, or null when no authentication is active.
6224
+ */
6225
+ getCurrentAuthInfo: async () => connection.sendRequest("session.gitHubAuth.getCurrentAuthInfo", { sessionId }),
6226
+ /**
6227
+ * Gets all authentication accounts available to the internal session host.
6228
+ *
6229
+ * @returns Authentication accounts available to the internal session host.
6230
+ */
6231
+ getAllAuthAvailable: async () => connection.sendRequest("session.gitHubAuth.getAllAuthAvailable", { sessionId }),
6232
+ /**
6233
+ * Refreshes Copilot account metadata for the current authentication.
6234
+ *
6235
+ * @returns Current authentication information, or null when no authentication is active.
6236
+ */
6237
+ refreshCopilotUser: async () => connection.sendRequest("session.gitHubAuth.refreshCopilotUser", { sessionId }),
6238
+ /**
6239
+ * Logs in a GitHub user through the internal session host.
6240
+ *
6241
+ * @param params Internal GitHub login parameters.
6242
+ *
6243
+ * @returns Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
6244
+ */
6245
+ login: async (params) => connection.sendRequest("session.gitHubAuth.login", { sessionId, ...params }),
6246
+ /**
6247
+ * Switches the session to another available authentication.
6248
+ *
6249
+ * @param params Parameters for switching the session's active authentication.
6250
+ */
6251
+ switchToAuth: async (params) => connection.sendRequest("session.gitHubAuth.switchToAuth", { sessionId, ...params }),
6252
+ /**
6253
+ * Logs out the session's current GitHub authentication.
6254
+ *
6255
+ * @returns Whether the current authentication was logged out.
6256
+ */
6257
+ logout: async () => connection.sendRequest("session.gitHubAuth.logout", { sessionId }),
6258
+ /**
6259
+ * Logs out a specific GitHub authentication.
6260
+ *
6261
+ * @param params Parameters identifying a GitHub authentication to log out.
6262
+ *
6263
+ * @returns Whether the requested authentication was logged out.
6264
+ */
6265
+ logoutUser: async (params) => connection.sendRequest("session.gitHubAuth.logoutUser", { sessionId, ...params }),
6266
+ /**
6267
+ * Gets validation errors from the most recent authentication attempt.
6268
+ *
6269
+ * @returns Validation errors from the most recent authentication attempt.
6270
+ */
6271
+ lastAuthErrors: async () => connection.sendRequest("session.gitHubAuth.lastAuthErrors", { sessionId })
6272
+ },
6273
+ /** @experimental */
6274
+ canvas: {
6275
+ /** @experimental */
6276
+ provider: {
6277
+ /**
6278
+ * Registers an internal canvas provider connection and its contributions.
6279
+ *
6280
+ * @param params Internal canvas provider registration parameters.
6281
+ */
6282
+ register: async (params) => connection.sendRequest("session.canvas.provider.register", { sessionId, ...params }),
6283
+ /**
6284
+ * Unregisters an internal canvas provider connection.
6285
+ *
6286
+ * @param params Internal canvas provider unregistration parameters.
6287
+ */
6288
+ unregister: async (params) => connection.sendRequest("session.canvas.provider.unregister", { sessionId, ...params })
6289
+ }
6290
+ },
6291
+ /** @experimental */
6292
+ factory: {
6293
+ /**
6294
+ * Internal tool-originated factory invocation.
6295
+ *
6296
+ * @param params Internal parameters for invoking a registered factory from a tool.
6297
+ *
6298
+ * @returns Complete current or terminal factory run envelope.
6299
+ */
6300
+ runFromTool: async (params) => connection.sendRequest("session.factory.runFromTool", { sessionId, ...params }),
6301
+ /**
6302
+ * Internal tool-originated factory resume.
6303
+ *
6304
+ * @param params Internal parameters for resuming a factory run from a tool.
6305
+ *
6306
+ * @returns Resolved persisted factory identity and resumed run envelope.
6307
+ */
6308
+ resumeFromTool: async (params) => connection.sendRequest("session.factory.resumeFromTool", { sessionId, ...params }),
6309
+ /**
6310
+ * Atomically pauses an owned factory attempt at a durable checkpoint.
6311
+ *
6312
+ * @param params Parameters for an owned durable pause checkpoint.
6313
+ */
6314
+ pauseAtCheckpoint: async (params) => connection.sendRequest("session.factory.pauseAtCheckpoint", { sessionId, ...params })
6315
+ },
6316
+ /** @experimental */
6317
+ model: {
6318
+ /**
6319
+ * Resolves and applies organization-managed and repository model overlays.
6320
+ *
6321
+ * @param params Managed, repository, and CLI model overrides to overlay onto the session at startup.
6322
+ *
6323
+ * @returns The model identifier active on the session after the switch.
6324
+ */
6325
+ applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { sessionId, ...params })
6326
+ },
6327
+ /** @experimental */
6328
+ mcp: {
6329
+ /**
6330
+ * Reloads MCP server connections for the session with an explicit host-provided configuration.
6331
+ *
6332
+ * @param params Opaque MCP reload configuration.
6333
+ *
6334
+ * @returns MCP server startup filtering result.
6335
+ */
6336
+ reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { sessionId, ...params }),
6337
+ /**
6338
+ * Configures the built-in GitHub MCP server for the session's current auth context.
6339
+ *
6340
+ * @param params Credential-free authentication identity used to configure GitHub MCP.
6341
+ *
6342
+ * @returns Result of configuring GitHub MCP.
6343
+ */
6344
+ configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { sessionId, ...params }),
6345
+ /**
6346
+ * Registers a pre-connected external MCP client (e.g. IDE) on the session's host. The caller retains lifecycle ownership of the client and transport. Marked internal because the `client` and `transport` arguments are in-process MCP SDK instances that cannot be serialized across the JSON-RPC boundary; once the CLI moves on top of the SDK, external clients will be expressed as transport configs the runtime can construct itself.
6347
+ *
6348
+ * @param params Registration parameters for an external MCP client.
6349
+ */
6350
+ registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { sessionId, ...params }),
6351
+ /**
6352
+ * Unregisters a previously registered external MCP client by server name. Marked internal as the paired companion of `registerExternalClient`: only in-process callers that registered a client this way can meaningfully unregister it. Disappears alongside `registerExternalClient`: once external clients are described to the runtime as config rather than handed in as instances, lifecycle (including deregistration) is owned entirely by the runtime.
6353
+ *
6354
+ * @param params Server name identifying the external client to remove.
6355
+ */
6356
+ unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
6357
+ },
6358
+ /** @experimental */
6359
+ commands: {
6360
+ /**
6361
+ * Finalizes persistence associated with a client-applied slash-command effect.
6362
+ *
6363
+ * @param params The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
6364
+ *
6365
+ * @returns Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
6366
+ */
6367
+ finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { sessionId, ...params })
6368
+ },
6369
+ /** @experimental */
6370
+ settings: {
6371
+ /**
6372
+ * Returns a redacted snapshot of session runtime settings, with secrets and raw feature flags excluded. Internal: the runtime settings shape is a runtime-internal surface and is deliberately kept out of the public SDK, because consumers should not depend on the runtime's internal settings layout. It remains callable in-process and is expected to be reworked as the runtime internals are consolidated.
6373
+ *
6374
+ * @returns Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
6375
+ */
6376
+ snapshot: async () => connection.sendRequest("session.settings.snapshot", { sessionId }),
6377
+ /**
6378
+ * Evaluates a named Rust-owned settings predicate without exposing raw feature flags. Internal: the raw feature-flag names and composition are runtime-internal, so this predicate-evaluation helper is kept out of the public SDK surface and is callable in-process only.
6379
+ *
6380
+ * @param params Named Rust-owned settings predicate to evaluate for this session.
6381
+ *
6382
+ * @returns Result of evaluating a Rust-owned settings predicate.
6383
+ */
6384
+ evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { sessionId, ...params })
6385
+ },
6386
+ /** @experimental */
6387
+ queue: {
6388
+ /**
6389
+ * Returns the internal native queue snapshot for in-process session orchestration.
6390
+ *
6391
+ * @returns Internal snapshot of native queue state for local session orchestration.
6392
+ */
6393
+ snapshot: async () => connection.sendRequest("session.queue.snapshot", { sessionId }),
6394
+ /**
6395
+ * Reports whether the local session has native queued work pending.
6396
+ *
6397
+ * @returns Whether the native queue has pending work.
6398
+ */
6399
+ hasPending: async () => connection.sendRequest("session.queue.hasPending", { sessionId }),
6400
+ /**
6401
+ * Begins a native deferred-idle drain when background work has quiesced.
6402
+ *
6403
+ * @param params Inputs for starting a deferred-idle drain.
6404
+ *
6405
+ * @returns Whether a deferred-idle drain should run.
6406
+ */
6407
+ beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { sessionId, ...params }),
6408
+ /**
6409
+ * Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
6410
+ *
6411
+ * @param params Inputs for completing a deferred-idle drain.
6412
+ *
6413
+ * @returns Action selected by the native deferred-idle drain.
6414
+ */
6415
+ finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { sessionId, ...params }),
6416
+ /**
6417
+ * Marks session.idle as deferred by native background work state.
6418
+ *
6419
+ * @param params Inputs for marking session.idle deferred in native state.
6420
+ */
6421
+ deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { sessionId, ...params }),
6422
+ /**
6423
+ * Consumes queued native system notifications matching an internal filter.
6424
+ *
6425
+ * @param params Internal filter for consuming queued system notifications.
6426
+ *
6427
+ * @returns Indicates whether a user-facing pending item was removed.
6428
+ */
6429
+ consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { sessionId, ...params }),
6430
+ /**
6431
+ * Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
6432
+ *
6433
+ * @returns Result of enqueueing the resume-pending wake item.
6434
+ */
6435
+ enqueueResumePending: async () => connection.sendRequest("session.queue.enqueueResumePending", { sessionId }),
6436
+ /**
6437
+ * Drains the native local-session work queue for in-process session orchestration.
6438
+ */
6439
+ process: async () => connection.sendRequest("session.queue.process", { sessionId })
6440
+ },
6441
+ /** @experimental */
6442
+ schedule: {
6443
+ /**
6444
+ * Hydrates the native schedule registry from persisted session events.
6445
+ */
6446
+ hydrate: async () => connection.sendRequest("session.schedule.hydrate", { sessionId }),
6447
+ /**
6448
+ * Reports whether the session has an active self-paced scheduled prompt.
6449
+ *
6450
+ * @returns Whether the session currently has an active self-paced schedule.
6451
+ */
6452
+ hasSelfPaced: async () => connection.sendRequest("session.schedule.hasSelfPaced", { sessionId }),
6453
+ /**
6454
+ * Registers a relative-interval scheduled prompt.
6455
+ *
6456
+ * @param params Register a relative-interval scheduled prompt.
6457
+ *
6458
+ * @returns Result of registering or re-arming a scheduled prompt.
6459
+ */
6460
+ add: async (params) => connection.sendRequest("session.schedule.add", { sessionId, ...params }),
6461
+ /**
6462
+ * Registers a recurring cron scheduled prompt.
6463
+ *
6464
+ * @param params Register a cron scheduled prompt.
6465
+ *
6466
+ * @returns Result of registering or re-arming a scheduled prompt.
6467
+ */
6468
+ addCron: async (params) => connection.sendRequest("session.schedule.addCron", { sessionId, ...params }),
6469
+ /**
6470
+ * Registers an absolute-time scheduled prompt.
6471
+ *
6472
+ * @param params Register an absolute-time scheduled prompt.
6473
+ *
6474
+ * @returns Result of registering or re-arming a scheduled prompt.
6475
+ */
6476
+ addAt: async (params) => connection.sendRequest("session.schedule.addAt", { sessionId, ...params }),
6477
+ /**
6478
+ * Registers a self-paced scheduled prompt.
6479
+ *
6480
+ * @param params Register a self-paced scheduled prompt.
6481
+ *
6482
+ * @returns Result of registering or re-arming a scheduled prompt.
6483
+ */
6484
+ addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { sessionId, ...params }),
6485
+ /**
6486
+ * Re-arms an active self-paced scheduled prompt.
6487
+ *
6488
+ * @param params Re-arm a self-paced scheduled prompt.
6489
+ *
6490
+ * @returns Result of registering or re-arming a scheduled prompt.
6491
+ */
6492
+ rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { sessionId, ...params })
6493
+ }
6494
+ };
6495
+ }
6023
6496
  function registerClientSessionApiHandlers(connection, getHandlers) {
6024
6497
  connection.onRequest("providerToken.getToken", async (params) => {
6025
6498
  const handler = getHandlers(params.sessionId).providerToken;
@@ -6036,6 +6509,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
6036
6509
  if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
6037
6510
  return handler.abort(params);
6038
6511
  });
6512
+ connection.onRequest("tasks.cancel", async (params) => {
6513
+ const handler = getHandlers(params.sessionId).tasks;
6514
+ if (!handler) throw new Error(`No tasks handler registered for session: ${params.sessionId}`);
6515
+ return handler.cancel(params);
6516
+ });
6039
6517
  connection.onRequest("sessionFs.readFile", async (params) => {
6040
6518
  const handler = getHandlers(params.sessionId).sessionFs;
6041
6519
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
@@ -6145,17 +6623,17 @@ function registerClientGlobalApiHandlers(connection, handlers) {
6145
6623
  });
6146
6624
  }
6147
6625
 
6148
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/sdkProtocolVersion.js
6626
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/sdkProtocolVersion.js
6149
6627
  var SDK_PROTOCOL_VERSION = 3;
6150
6628
  function getSdkProtocolVersion() {
6151
6629
  return SDK_PROTOCOL_VERSION;
6152
6630
  }
6153
6631
 
6154
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/session.js
6632
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/session.js
6155
6633
  var import_node = __toESM(require_node(), 1);
6156
6634
  import { AsyncLocalStorage } from "node:async_hooks";
6157
6635
 
6158
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/canvas.js
6636
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/canvas.js
6159
6637
  var CanvasError = class _CanvasError extends Error {
6160
6638
  constructor(code, message) {
6161
6639
  super(message);
@@ -6202,7 +6680,7 @@ function createCanvas(options) {
6202
6680
  return new Canvas(options);
6203
6681
  }
6204
6682
 
6205
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/telemetry.js
6683
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/telemetry.js
6206
6684
  async function getTraceContext(provider) {
6207
6685
  if (!provider) return {};
6208
6686
  try {
@@ -6212,7 +6690,7 @@ async function getTraceContext(provider) {
6212
6690
  }
6213
6691
  }
6214
6692
 
6215
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/sessionFsProvider.js
6693
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/sessionFsProvider.js
6216
6694
  var SessionFsSqliteTransactionFailure = class extends Error {
6217
6695
  /** Failure classification reported to the runtime. */
6218
6696
  errorClass;
@@ -6383,7 +6861,7 @@ function toSqliteTransactionError(err) {
6383
6861
  };
6384
6862
  }
6385
6863
 
6386
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/copilotRequestHandler.js
6864
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/copilotRequestHandler.js
6387
6865
  var sharedTextDecoder = new TextDecoder("utf-8", { fatal: false });
6388
6866
  var sharedTextEncoder = new TextEncoder();
6389
6867
  var kBridge = /* @__PURE__ */ Symbol("copilotWebSocketResponseBridge");
@@ -6988,7 +7466,7 @@ var CopilotWebSocketResponseBridge = class {
6988
7466
  }
6989
7467
  };
6990
7468
 
6991
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/types.js
7469
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/types.js
6992
7470
  function isAttributedPermissionResult(result) {
6993
7471
  return result.kind === "attributed";
6994
7472
  }
@@ -6996,10 +7474,11 @@ var defaultJoinSessionPermissionHandler = () => ({
6996
7474
  kind: "no-result"
6997
7475
  });
6998
7476
 
6999
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/factory.js
7477
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/factory.js
7000
7478
  var FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
7001
7479
  "completed",
7002
7480
  "halted",
7481
+ "paused",
7003
7482
  "cancelled",
7004
7483
  "error"
7005
7484
  ]);
@@ -7096,7 +7575,7 @@ function getFactoryDefinition(handle) {
7096
7575
  return definition;
7097
7576
  }
7098
7577
 
7099
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/session.js
7578
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/session.js
7100
7579
  function isFactoryResumeErrorCode(value) {
7101
7580
  return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "factory_already_running" || value === "factory_limits_invalid" || value === "factory_session_disposed" || value === "factory_storage_unavailable" || value === "factory_storage_corrupt";
7102
7581
  }
@@ -7110,10 +7589,14 @@ var factoryExecutionStore = new AsyncLocalStorage();
7110
7589
  function throwIfFactoryExecutionIsActive() {
7111
7590
  if (factoryExecutionStore.getStore()?.active) {
7112
7591
  throw new Error(
7113
- "factory.run and factory.resume are not allowed while a factory body is running on this call path."
7592
+ "factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
7114
7593
  );
7115
7594
  }
7116
7595
  }
7596
+ function runInFactoryHelperScope(helperScope, callback) {
7597
+ const current = factoryExecutionStore.getStore();
7598
+ return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
7599
+ }
7117
7600
  function deserializeHookInput(raw) {
7118
7601
  if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
7119
7602
  return raw;
@@ -7157,7 +7640,7 @@ async function runFactoryParallel(thunks) {
7157
7640
  }
7158
7641
  return Promise.all(
7159
7642
  thunks.map(
7160
- (thunk) => Promise.resolve().then(() => thunk()).catch((error) => {
7643
+ (thunk) => Promise.resolve().then(() => runInFactoryHelperScope("parallel", thunk)).catch((error) => {
7161
7644
  if (isFactoryFatalError(error)) {
7162
7645
  throw error;
7163
7646
  }
@@ -7176,7 +7659,10 @@ async function runFactoryPipeline(items, ...stages) {
7176
7659
  let previous = item;
7177
7660
  for (const stage of stages) {
7178
7661
  try {
7179
- previous = await stage(previous, item, index);
7662
+ previous = await runInFactoryHelperScope(
7663
+ "pipeline",
7664
+ () => stage(previous, item, index)
7665
+ );
7180
7666
  } catch (error) {
7181
7667
  if (isFactoryFatalError(error)) {
7182
7668
  throw error;
@@ -7318,6 +7804,7 @@ var CopilotSession = class {
7318
7804
  eventHandlers = /* @__PURE__ */ new Set();
7319
7805
  typedEventHandlers = /* @__PURE__ */ new Map();
7320
7806
  toolHandlers = /* @__PURE__ */ new Map();
7807
+ pendingExternalTools = /* @__PURE__ */ new Map();
7321
7808
  canvases = /* @__PURE__ */ new Map();
7322
7809
  bearerTokenProviders = /* @__PURE__ */ new Map();
7323
7810
  commandHandlers = /* @__PURE__ */ new Map();
@@ -7332,11 +7819,13 @@ var CopilotSession = class {
7332
7819
  hooks;
7333
7820
  transformCallbacks;
7334
7821
  _rpc = null;
7822
+ _internalRpc = null;
7335
7823
  traceContextProvider;
7336
7824
  managedSettingsEnabled;
7337
7825
  _capabilities = {};
7338
7826
  openCanvasInstances = [];
7339
7827
  disconnected = false;
7828
+ disconnecting = false;
7340
7829
  onDisconnected;
7341
7830
  /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
7342
7831
  clientSessionApis = {};
@@ -7397,6 +7886,10 @@ var CopilotSession = class {
7397
7886
  }),
7398
7887
  getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
7399
7888
  getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
7889
+ pause: async (runId) => {
7890
+ throwIfFactoryExecutionIsActive();
7891
+ return this.rpc.factory.pause({ runId });
7892
+ },
7400
7893
  cancel: async (runId) => this.rpc.factory.cancel({ runId })
7401
7894
  };
7402
7895
  /**
@@ -7495,6 +7988,13 @@ var CopilotSession = class {
7495
7988
  }
7496
7989
  return this._rpc;
7497
7990
  }
7991
+ /** @internal */
7992
+ get internalRpc() {
7993
+ if (!this._internalRpc) {
7994
+ this._internalRpc = createInternalSessionRpc(this.connection, this.sessionId);
7995
+ }
7996
+ return this._internalRpc;
7997
+ }
7498
7998
  /**
7499
7999
  * Path to the session workspace directory when infinite sessions are enabled.
7500
8000
  * Contains checkpoints/, plan.md, and files/ subdirectories.
@@ -7536,6 +8036,7 @@ var CopilotSession = class {
7536
8036
  ...await getTraceContext(this.traceContextProvider),
7537
8037
  sessionId: this.sessionId,
7538
8038
  prompt: options.prompt,
8039
+ source: options.source,
7539
8040
  displayPrompt: options.displayPrompt,
7540
8041
  attachments: options.attachments,
7541
8042
  mode: options.mode,
@@ -7594,6 +8095,10 @@ var CopilotSession = class {
7594
8095
  return;
7595
8096
  }
7596
8097
  this.disconnected = true;
8098
+ for (const controller of this.pendingExternalTools.values()) {
8099
+ controller.abort();
8100
+ }
8101
+ this.pendingExternalTools.clear();
7597
8102
  this._runOnDisconnected();
7598
8103
  this.eventHandlers.clear();
7599
8104
  this.typedEventHandlers.clear();
@@ -7697,6 +8202,15 @@ var CopilotSession = class {
7697
8202
  tracestate
7698
8203
  );
7699
8204
  }
8205
+ } else if (event.type === "external_tool.completed") {
8206
+ const { requestId } = event.data;
8207
+ if (requestId) {
8208
+ const controller = this.pendingExternalTools.get(requestId);
8209
+ if (controller) {
8210
+ this.pendingExternalTools.delete(requestId);
8211
+ controller.abort();
8212
+ }
8213
+ }
7700
8214
  } else if (event.type === "permission.requested") {
7701
8215
  const { requestId, permissionRequest, resolvedByHook } = event.data;
7702
8216
  if (resolvedByHook) {
@@ -7777,16 +8291,35 @@ var CopilotSession = class {
7777
8291
  * @internal
7778
8292
  */
7779
8293
  async _executeToolAndRespond(requestId, toolName, toolCallId, args, handler, traceparent, tracestate) {
8294
+ const controller = new AbortController();
8295
+ if (this.disconnected || this.pendingExternalTools.has(requestId)) {
8296
+ return;
8297
+ }
8298
+ this.pendingExternalTools.set(requestId, controller);
7780
8299
  try {
7781
8300
  let availableTools;
7782
8301
  if (toolName === TOOL_SEARCH_TOOL_NAME) {
8302
+ if (controller.signal.aborted) {
8303
+ return;
8304
+ }
8305
+ const aborted = new Promise((resolve3) => {
8306
+ controller.signal.addEventListener("abort", () => resolve3(void 0), {
8307
+ once: true
8308
+ });
8309
+ });
7783
8310
  try {
7784
- const metadata = await this.rpc.tools.getCurrentMetadata();
7785
- availableTools = metadata.tools ?? void 0;
8311
+ const metadata = await Promise.race([
8312
+ this.rpc.tools.getCurrentMetadata(),
8313
+ aborted
8314
+ ]);
8315
+ availableTools = metadata?.tools ?? void 0;
7786
8316
  } catch {
7787
8317
  availableTools = void 0;
7788
8318
  }
7789
8319
  }
8320
+ if (controller.signal.aborted) {
8321
+ return;
8322
+ }
7790
8323
  const rawResult = await handler(args, {
7791
8324
  sessionId: this.sessionId,
7792
8325
  toolCallId,
@@ -7794,7 +8327,8 @@ var CopilotSession = class {
7794
8327
  arguments: args,
7795
8328
  availableTools,
7796
8329
  traceparent,
7797
- tracestate
8330
+ tracestate,
8331
+ signal: controller.signal
7798
8332
  });
7799
8333
  let result;
7800
8334
  if (rawResult == null) {
@@ -7806,12 +8340,12 @@ var CopilotSession = class {
7806
8340
  } else {
7807
8341
  result = JSON.stringify(rawResult);
7808
8342
  }
7809
- if (this.disconnected) {
8343
+ if (!this._claimExternalTool(requestId, controller)) {
7810
8344
  return;
7811
8345
  }
7812
8346
  await this.rpc.tools.handlePendingToolCall({ requestId, result });
7813
8347
  } catch (error) {
7814
- if (this.disconnected) {
8348
+ if (!this._claimExternalTool(requestId, controller)) {
7815
8349
  return;
7816
8350
  }
7817
8351
  const message = error instanceof Error ? error.message : String(error);
@@ -7822,8 +8356,20 @@ var CopilotSession = class {
7822
8356
  throw rpcError;
7823
8357
  }
7824
8358
  }
8359
+ } finally {
8360
+ if (this.pendingExternalTools.get(requestId) === controller) {
8361
+ this.pendingExternalTools.delete(requestId);
8362
+ }
8363
+ controller.abort();
7825
8364
  }
7826
8365
  }
8366
+ _claimExternalTool(requestId, controller) {
8367
+ if (this.disconnected || this.pendingExternalTools.get(requestId) !== controller) {
8368
+ return false;
8369
+ }
8370
+ this.pendingExternalTools.delete(requestId);
8371
+ return true;
8372
+ }
7827
8373
  /**
7828
8374
  * Executes a permission handler and sends the result back via RPC.
7829
8375
  * @internal
@@ -8131,6 +8677,36 @@ var CopilotSession = class {
8131
8677
  );
8132
8678
  return result2;
8133
8679
  },
8680
+ pause: async (key) => {
8681
+ if (typeof key !== "string" || key.length === 0) {
8682
+ throw new Error("Factory pause checkpoint key must not be empty");
8683
+ }
8684
+ const helperScope = factoryExecutionStore.getStore()?.helperScope;
8685
+ if (helperScope !== void 0) {
8686
+ throw new Error(
8687
+ `Factory pause checkpoints are not allowed inside ${helperScope}() branches`
8688
+ );
8689
+ }
8690
+ await progress.flush();
8691
+ const response = await awaitFactoryOperation(
8692
+ () => self.internalRpc.factory.pauseAtCheckpoint({
8693
+ runId: params.runId,
8694
+ executionToken: params.executionToken,
8695
+ key
8696
+ }),
8697
+ controller.signal
8698
+ );
8699
+ switch (response.action) {
8700
+ case "continue":
8701
+ return;
8702
+ case "pause":
8703
+ await awaitFactoryOperation(
8704
+ () => new Promise(() => {
8705
+ }),
8706
+ controller.signal
8707
+ );
8708
+ }
8709
+ },
8134
8710
  parallel: runFactoryParallel,
8135
8711
  pipeline: runFactoryPipeline,
8136
8712
  factory: async () => {
@@ -8166,11 +8742,9 @@ var CopilotSession = class {
8166
8742
  },
8167
8743
  async abort(params) {
8168
8744
  const controllersForRun = self.factoryAbortControllers.get(params.runId);
8169
- if (controllersForRun !== void 0) {
8170
- const reason = new DOMException("Factory run was aborted", "AbortError");
8171
- for (const controller of controllersForRun.values()) {
8172
- controller.abort(reason);
8173
- }
8745
+ const controller = controllersForRun?.get(params.executionToken);
8746
+ if (controller !== void 0) {
8747
+ controller.abort(new DOMException("Factory run was aborted", "AbortError"));
8174
8748
  }
8175
8749
  return {};
8176
8750
  }
@@ -8576,13 +9150,27 @@ var CopilotSession = class {
8576
9150
  * ```
8577
9151
  */
8578
9152
  async disconnect() {
8579
- if (this.disconnected) {
9153
+ if (this.disconnected || this.disconnecting) {
8580
9154
  return;
8581
9155
  }
8582
- await this.connection.sendRequest("session.destroy", {
8583
- sessionId: this.sessionId
8584
- });
8585
- this._markDisconnected();
9156
+ this.disconnecting = true;
9157
+ try {
9158
+ let response = { success: false };
9159
+ for (let attempt = 0; attempt < 2 && !response.success; attempt++) {
9160
+ response = await this.connection.sendRequest("session.detach", {
9161
+ sessionId: this.sessionId
9162
+ });
9163
+ }
9164
+ if (!response.success) {
9165
+ throw new Error(
9166
+ `Failed to disconnect session ${this.sessionId}: ${response.error || "Unknown error"}`
9167
+ );
9168
+ }
9169
+ this._markDisconnected();
9170
+ } catch (error) {
9171
+ this.disconnecting = false;
9172
+ throw error;
9173
+ }
8586
9174
  }
8587
9175
  /** Enables `await using session = ...` syntax for automatic cleanup. */
8588
9176
  async [Symbol.asyncDispose]() {
@@ -8624,11 +9212,48 @@ var CopilotSession = class {
8624
9212
  * ```typescript
8625
9213
  * await session.setModel("gpt-5.4");
8626
9214
  * await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
9215
+ *
9216
+ * // Select the Auto model and its routing preference in one call.
9217
+ * await session.setModel("auto", { autoTier: "intelligence" });
8627
9218
  * ```
8628
9219
  */
8629
9220
  async setModel(model, options) {
8630
9221
  await this.rpc.model.switchTo({ modelId: model, ...options });
8631
9222
  }
9223
+ /**
9224
+ * Change the Auto routing preference without changing the selected model.
9225
+ *
9226
+ * The runtime does not apply the preference immediately. It records the
9227
+ * request and commits it only when a later user turn using the `auto` model
9228
+ * successfully obtains a usable model from the provider. A `pending` status
9229
+ * therefore confirms that the request was accepted, not that it took effect.
9230
+ *
9231
+ * Watch for the outcome through the `session.model_change` event on success,
9232
+ * or the ephemeral `session.auto_tier_switch_failed` event on failure. You
9233
+ * can also read the current committed and in-flight state at any time with
9234
+ * `session.rpc.model.getCurrent()`.
9235
+ *
9236
+ * Only the most recent request survives: issuing a new request replaces any
9237
+ * earlier one that has not yet been claimed by a turn.
9238
+ *
9239
+ * @param autoTier - Routing preference to activate, or `null` to return to
9240
+ * the provider's default Auto routing
9241
+ * @returns The runtime's immediate acknowledgement and Auto preference snapshot
9242
+ *
9243
+ * @experimental Part of an experimental Auto routing surface and may change
9244
+ * or be removed in a future release.
9245
+ *
9246
+ * @example
9247
+ * ```typescript
9248
+ * const result = await session.setAutoTier("intelligence");
9249
+ * if (result.status === "pending") {
9250
+ * // Takes effect on a later turn that uses the `auto` model.
9251
+ * }
9252
+ * ```
9253
+ */
9254
+ async setAutoTier(autoTier) {
9255
+ return await this.rpc.model.switchAutoTier({ autoTier });
9256
+ }
8632
9257
  /**
8633
9258
  * Log a message to the session timeline.
8634
9259
  * The message appears in the session event stream and is visible to SDK consumers
@@ -8820,8 +9445,7 @@ function assertFactoryStepResult(value, key) {
8820
9445
  });
8821
9446
  }
8822
9447
 
8823
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/runtimeArtifacts.js
8824
- import { createHash } from "node:crypto";
9448
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/runtimeArtifacts.js
8825
9449
  import {
8826
9450
  chmodSync,
8827
9451
  copyFileSync,
@@ -8834,26 +9458,32 @@ import {
8834
9458
  rmSync,
8835
9459
  statSync
8836
9460
  } from "node:fs";
9461
+ import { createHash } from "node:crypto";
9462
+ import { createRequire } from "node:module";
8837
9463
  import { homedir } from "node:os";
8838
9464
  import { dirname, join, relative, sep } from "node:path";
9465
+
9466
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/cliVersion.js
9467
+ var COPILOT_CLI_VERSION = "1.0.84-5";
9468
+ var COPILOT_CLI_USE_NPM_PACKAGE = false;
9469
+
9470
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/runtimeArtifacts.js
9471
+ var require2 = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
8839
9472
  var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
8840
9473
  "app.js",
8841
9474
  "assets",
8842
9475
  "changelog.json",
8843
9476
  "copilot",
8844
9477
  "copilot.exe",
8845
- "copilot-sdk",
8846
9478
  "foundry-local-sdk",
8847
9479
  "index.js",
8848
9480
  "LICENSE.md",
8849
9481
  "napi-oop-runtime",
8850
9482
  "npm-loader.js",
8851
9483
  "package.json",
8852
- "preloads",
8853
9484
  "pvrecorder",
8854
9485
  "queries",
8855
9486
  "README.md",
8856
- "sdk",
8857
9487
  "sea-loader.js",
8858
9488
  "webview"
8859
9489
  ]);
@@ -8892,14 +9522,12 @@ function collectRuntimeAssets(sources) {
8892
9522
  continue;
8893
9523
  }
8894
9524
  const parts = sourceRelative.split(sep);
8895
- let relativePath = sourceRelative;
8896
9525
  if (parts[0] === "prebuilds") {
8897
9526
  if (parts[1] !== sources.platform || parts.length < 3) {
8898
9527
  continue;
8899
9528
  }
8900
- relativePath = parts.slice(2).join(sep);
8901
9529
  }
8902
- assets.push({ source, relativePath });
9530
+ assets.push({ source, relativePath: sourceRelative });
8903
9531
  }
8904
9532
  };
8905
9533
  visit(sources.packageRoot);
@@ -8927,15 +9555,20 @@ function defaultRuntimeCacheRoot(platform = process.platform, home = homedir(),
8927
9555
  const cacheDirectory = platform === "win32" ? environment.LOCALAPPDATA ?? join(home, "AppData", "Local") : platform === "darwin" ? join(home, "Library", "Caches") : environment.XDG_CACHE_HOME ?? join(home, ".cache");
8928
9556
  return join(cacheDirectory, "github-copilot-sdk", "runtime");
8929
9557
  }
8930
- function materializeRuntimeBundle(sources, cacheRoot = defaultRuntimeCacheRoot()) {
9558
+ function materializeRuntimeBundle(sources, cacheRoot = defaultRuntimeCacheRoot(), cacheKey = `${sources.platform}-${sourceFingerprint(collectRuntimeAssets(sources))}`) {
8931
9559
  const assets = collectRuntimeAssets(sources);
8932
- const wrapperName = process.platform === "win32" ? "copilot-runtime.exe" : "copilot-runtime";
8933
- const sourceWrapper = assets.find((asset) => asset.relativePath === wrapperName)?.source;
8934
- const sourceRuntimeNode = assets.find((asset) => asset.relativePath === "runtime.node")?.source;
9560
+ const wrapperName = sources.platform.startsWith("win32") ? "copilot-runtime.exe" : "copilot-runtime";
9561
+ const prebuildDir = join("prebuilds", sources.platform);
9562
+ const wrapperRelative = join(prebuildDir, wrapperName);
9563
+ const runtimeNodeRelative = join(prebuildDir, "runtime.node");
9564
+ const sourceWrapper = assets.find((asset) => asset.relativePath === wrapperRelative)?.source;
9565
+ const sourceRuntimeNode = assets.find(
9566
+ (asset) => asset.relativePath === runtimeNodeRelative
9567
+ )?.source;
8935
9568
  validateRuntimeBundle(sourceWrapper ?? "", sourceRuntimeNode ?? "");
8936
- const installDir = join(cacheRoot, `${sources.platform}-${sourceFingerprint(assets)}`);
8937
- const installedWrapper = join(installDir, wrapperName);
8938
- const installedRuntimeNode = join(installDir, "runtime.node");
9569
+ const installDir = join(cacheRoot, cacheKey);
9570
+ const installedWrapper = join(installDir, wrapperRelative);
9571
+ const installedRuntimeNode = join(installDir, runtimeNodeRelative);
8939
9572
  if (existsSync(installDir)) {
8940
9573
  validateRuntimeBundle(installedWrapper, installedRuntimeNode);
8941
9574
  makeExecutable(installedWrapper);
@@ -8949,7 +9582,7 @@ function materializeRuntimeBundle(sources, cacheRoot = defaultRuntimeCacheRoot()
8949
9582
  mkdirSync(dirname(destination), { recursive: true });
8950
9583
  copyFileSync(asset.source, destination);
8951
9584
  }
8952
- const stagedWrapper = join(stagingDir, wrapperName);
9585
+ const stagedWrapper = join(stagingDir, wrapperRelative);
8953
9586
  makeExecutable(stagedWrapper);
8954
9587
  renameSync(stagingDir, installDir);
8955
9588
  } catch (error) {
@@ -8962,8 +9595,72 @@ function materializeRuntimeBundle(sources, cacheRoot = defaultRuntimeCacheRoot()
8962
9595
  }
8963
9596
  return installedWrapper;
8964
9597
  }
9598
+ function isMusl() {
9599
+ if (process.platform !== "linux") {
9600
+ return false;
9601
+ }
9602
+ const report = process.report?.getReport();
9603
+ return report?.header?.glibcVersionRuntime === void 0;
9604
+ }
9605
+ function getRuntimePlatform(platform = process.platform, arch = process.arch, musl = isMusl()) {
9606
+ if (arch !== "x64" && arch !== "arm64") {
9607
+ throw new Error(`Unsupported Copilot CLI architecture: ${arch}.`);
9608
+ }
9609
+ if (platform === "linux") {
9610
+ return `${musl ? "linuxmusl" : "linux"}-${arch}`;
9611
+ }
9612
+ if (platform === "darwin" || platform === "win32") {
9613
+ return `${platform}-${arch}`;
9614
+ }
9615
+ throw new Error(`Unsupported Copilot CLI platform: ${platform}-${arch}.`);
9616
+ }
9617
+ function getRuntimePackageName(platform) {
9618
+ return `@github/copilot-sdk-${platform}`;
9619
+ }
9620
+ function resolvePackageRoot(packageName, searchPaths = require2.resolve.paths(packageName) ?? []) {
9621
+ return searchPaths.map((base) => join(base, ...packageName.split("/"))).find((candidate) => existsSync(join(candidate, "package.json")));
9622
+ }
9623
+ async function ensureRuntimeBundle(version, options = {}) {
9624
+ const platform = options.platform ?? getRuntimePlatform();
9625
+ if (COPILOT_CLI_USE_NPM_PACKAGE) {
9626
+ const packageName2 = `@github/copilot-${platform}`;
9627
+ const packageRoot2 = resolvePackageRoot(packageName2, options.packageSearchPaths);
9628
+ if (!packageRoot2) {
9629
+ throw new Error(`Could not resolve ${packageName2} for Copilot CLI ${version}.`);
9630
+ }
9631
+ validateFile(
9632
+ join(packageRoot2, "prebuilds", platform, "runtime.node"),
9633
+ "Copilot runtime.node"
9634
+ );
9635
+ return materializeRuntimeBundle(
9636
+ { packageRoot: packageRoot2, platform },
9637
+ options.cacheRoot,
9638
+ `${version}-${platform}`
9639
+ );
9640
+ }
9641
+ const packageName = getRuntimePackageName(platform);
9642
+ const packageRoot = resolvePackageRoot(packageName, options.packageSearchPaths);
9643
+ if (!packageRoot) {
9644
+ throw new Error(
9645
+ `Could not resolve ${packageName}. Reinstall @github/copilot-sdk so its platform package is installed.`
9646
+ );
9647
+ }
9648
+ const wrapperName = platform.startsWith("win32") ? "copilot-runtime.exe" : "copilot-runtime";
9649
+ const prebuildDir = join(packageRoot, "prebuilds", platform);
9650
+ const wrapper = join(prebuildDir, wrapperName);
9651
+ try {
9652
+ validateRuntimeBundle(wrapper, join(prebuildDir, "runtime.node"));
9653
+ } catch (error) {
9654
+ throw new Error(
9655
+ `${packageName} is missing required Copilot CLI runtime files. Reinstall @github/copilot-sdk.`,
9656
+ { cause: error }
9657
+ );
9658
+ }
9659
+ makeExecutable(wrapper);
9660
+ return wrapper;
9661
+ }
8965
9662
 
8966
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/toolSet.js
9663
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/toolSet.js
8967
9664
  var VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
8968
9665
  function validateName(kind, name) {
8969
9666
  if (name === "*") {
@@ -9018,7 +9715,7 @@ var ToolSet = class {
9018
9715
  }
9019
9716
  };
9020
9717
 
9021
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/client.js
9718
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/client.js
9022
9719
  var MIN_PROTOCOL_VERSION = 3;
9023
9720
  var RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
9024
9721
  function isZodSchema(value) {
@@ -9121,6 +9818,15 @@ function toWireCustomAgents(agents) {
9121
9818
  return { ...rest, mcpServers: toWireMcpServers(mcpServers) };
9122
9819
  });
9123
9820
  }
9821
+ function clientInfoToWire(info) {
9822
+ if (info == null) return void 0;
9823
+ const wire = {};
9824
+ if (info.applicationName) wire.editorName = info.applicationName;
9825
+ if (info.applicationVersion) wire.editorVersion = info.applicationVersion;
9826
+ if (info.integrationName) wire.extensionName = info.integrationName;
9827
+ if (info.integrationVersion) wire.extensionVersion = info.integrationVersion;
9828
+ return Object.keys(wire).length > 0 ? wire : void 0;
9829
+ }
9124
9830
  function toWireLargeOutput(config) {
9125
9831
  if (!config) return void 0;
9126
9832
  const { outputDirectory, ...rest } = config;
@@ -9178,53 +9884,8 @@ function getNodeExecPath() {
9178
9884
  }
9179
9885
  return process.execPath;
9180
9886
  }
9181
- function getCliPlatformPackageNames() {
9182
- const arch = process.arch;
9183
- const variants = process.platform === "linux" ? ["linux", "linuxmusl"] : [process.platform];
9184
- return variants.map((variant) => `@github/copilot-${variant}-${arch}`);
9185
- }
9186
- function getBundledCliPackage() {
9187
- const packageNames = getCliPlatformPackageNames();
9188
- if (typeof import.meta.resolve === "function") {
9189
- for (const packageName of packageNames) {
9190
- try {
9191
- const packageEntryUrl = import.meta.resolve(packageName);
9192
- const packageEntryPath = fileURLToPath(packageEntryUrl);
9193
- return {
9194
- root: dirname2(packageEntryPath),
9195
- platform: packageName.slice("@github/copilot-".length)
9196
- };
9197
- } catch {
9198
- }
9199
- }
9200
- throw new Error(
9201
- `Could not resolve a @github/copilot platform package (tried ${packageNames.join(", ")}). Ensure @github/copilot is installed, or pass cliPath/cliUrl to CopilotClient.`
9202
- );
9203
- }
9204
- const req = createRequire(__filename);
9205
- const searchPaths = req.resolve.paths("@github/copilot") ?? [];
9206
- for (const base of searchPaths) {
9207
- for (const packageName of packageNames) {
9208
- const root = join2(base, ...packageName.split("/"));
9209
- const candidate = join2(root, "index.js");
9210
- if (existsSync3(candidate)) {
9211
- return {
9212
- root,
9213
- platform: packageName.slice("@github/copilot-".length)
9214
- };
9215
- }
9216
- }
9217
- }
9218
- throw new Error(
9219
- `Could not find a @github/copilot platform package (tried ${packageNames.join(", ")}). Searched ${searchPaths.length} paths. Ensure @github/copilot is installed, or pass cliPath/cliUrl to CopilotClient.`
9220
- );
9221
- }
9222
9887
  function getBundledRuntimePath() {
9223
- const bundled = getBundledCliPackage();
9224
- return materializeRuntimeBundle({
9225
- packageRoot: bundled.root,
9226
- platform: bundled.platform
9227
- });
9888
+ return ensureRuntimeBundle(COPILOT_CLI_VERSION);
9228
9889
  }
9229
9890
  var TeardownResilientStreamMessageWriter = class extends import_node2.StreamMessageWriter {
9230
9891
  suppressWriteErrors = false;
@@ -9244,10 +9905,13 @@ var CopilotClient = class _CopilotClient {
9244
9905
  ffiHost = null;
9245
9906
  connection = null;
9246
9907
  messageWriter = null;
9908
+ connectionClosed = false;
9247
9909
  socket = null;
9248
9910
  runtimePort = null;
9249
9911
  actualHost = "localhost";
9250
9912
  state = "disconnected";
9913
+ /** Shared in-flight start; concurrent callers await it instead of spawning another CLI. */
9914
+ startPromise = null;
9251
9915
  sessions = /* @__PURE__ */ new Map();
9252
9916
  stderrBuffer = "";
9253
9917
  // Captures CLI stderr for error messages
@@ -9443,8 +10107,6 @@ var CopilotClient = class _CopilotClient {
9443
10107
  const explicitCliPath = conn.path ?? effectiveEnv.COPILOT_CLI_PATH;
9444
10108
  if (explicitCliPath) {
9445
10109
  this.resolvedCliPath = explicitCliPath;
9446
- } else {
9447
- this.resolvedCliPath = getBundledRuntimePath();
9448
10110
  }
9449
10111
  }
9450
10112
  const connArgs = conn.kind === "stdio" || conn.kind === "tcp" ? conn.args ?? [] : [];
@@ -9459,7 +10121,8 @@ var CopilotClient = class _CopilotClient {
9459
10121
  baseDirectory: options.baseDirectory,
9460
10122
  sessionIdleTimeoutSeconds: options.sessionIdleTimeoutSeconds ?? 0,
9461
10123
  enableRemoteSessions: options.enableRemoteSessions ?? false,
9462
- mode: options.mode ?? "copilot-cli"
10124
+ mode: options.mode ?? "copilot-cli",
10125
+ clientInfo: options.clientInfo
9463
10126
  };
9464
10127
  if (this.options.mode === "empty") {
9465
10128
  const hasPersistence = this.options.baseDirectory !== void 0 || this.sessionFsConfig !== null || // External runtimes manage their own persistence layer; the SDK
@@ -9475,17 +10138,29 @@ var CopilotClient = class _CopilotClient {
9475
10138
  connectionExtraArgs = [];
9476
10139
  /**
9477
10140
  * Parse CLI URL into host and port
9478
- * Supports formats: "host:port", "http://host:port", "https://host:port", or just "port"
10141
+ * Supports formats: "host:port", "[ipv6]:port", "http://host:port", "https://host:port", or just "port"
9479
10142
  */
9480
10143
  parseCliUrl(url) {
9481
- let cleanUrl = url.replace(/^https?:\/\//, "");
10144
+ const cleanUrl = url.replace(/^https?:\/\//, "");
9482
10145
  if (/^\d+$/.test(cleanUrl)) {
9483
10146
  return { host: "localhost", port: parseInt(cleanUrl, 10) };
9484
10147
  }
10148
+ const ipv6Match = cleanUrl.match(/^\[([^\]]+)\]:(\d+)$/);
10149
+ if (ipv6Match) {
10150
+ const host2 = ipv6Match[1];
10151
+ if (!isIPv6(host2)) {
10152
+ throw new Error(`Invalid cliUrl format: ${url}`);
10153
+ }
10154
+ const port2 = parseInt(ipv6Match[2], 10);
10155
+ if (isNaN(port2) || port2 <= 0 || port2 > 65535) {
10156
+ throw new Error(`Invalid port in cliUrl: ${url}`);
10157
+ }
10158
+ return { host: host2, port: port2 };
10159
+ }
9485
10160
  const parts = cleanUrl.split(":");
9486
10161
  if (parts.length !== 2) {
9487
10162
  throw new Error(
9488
- `Invalid cliUrl format: ${url}. Expected "host:port", "http://host:port", or "port"`
10163
+ `Invalid cliUrl format: ${url}. Expected "host:port", "[ipv6]:port", "http://host:port", or "port"`
9489
10164
  );
9490
10165
  }
9491
10166
  const host = parts[0] || "localhost";
@@ -9614,7 +10289,19 @@ var CopilotClient = class _CopilotClient {
9614
10289
  if (this.state === "connected") {
9615
10290
  return;
9616
10291
  }
10292
+ if (this.startPromise) {
10293
+ return this.startPromise;
10294
+ }
10295
+ this.startPromise = this.doStart();
10296
+ try {
10297
+ await this.startPromise;
10298
+ } finally {
10299
+ this.startPromise = null;
10300
+ }
10301
+ }
10302
+ async doStart() {
9617
10303
  this.forceStopping = false;
10304
+ this.connectionClosed = false;
9618
10305
  this.processTransportError = null;
9619
10306
  this.state = "connecting";
9620
10307
  try {
@@ -9713,7 +10400,7 @@ var CopilotClient = class _CopilotClient {
9713
10400
  }
9714
10401
  this.sessions.clear();
9715
10402
  this.githubTokenProviders.clear();
9716
- if (this.connection && (this.cliProcess || this.ffiHost) && !this.isExternalServer) {
10403
+ if (this.connection && !this.connectionClosed && (this.cliProcess || this.ffiHost) && !this.isExternalServer) {
9717
10404
  const runtimeShutdownStart = Date.now();
9718
10405
  const shutdownPromise = this.rpc.runtime.shutdown();
9719
10406
  void shutdownPromise.catch(() => void 0);
@@ -9802,7 +10489,7 @@ var CopilotClient = class _CopilotClient {
9802
10489
  const host = this.ffiHost;
9803
10490
  this.ffiHost = null;
9804
10491
  try {
9805
- host.dispose();
10492
+ await host.dispose();
9806
10493
  } catch (error) {
9807
10494
  errors.push(
9808
10495
  new Error(
@@ -9897,11 +10584,12 @@ var CopilotClient = class _CopilotClient {
9897
10584
  this.cliProcess = null;
9898
10585
  }
9899
10586
  if (this.ffiHost) {
10587
+ const host = this.ffiHost;
10588
+ this.ffiHost = null;
9900
10589
  try {
9901
- this.ffiHost.dispose();
10590
+ await host.dispose();
9902
10591
  } catch {
9903
10592
  }
9904
- this.ffiHost = null;
9905
10593
  }
9906
10594
  if (this.cliStartTimeout) {
9907
10595
  clearTimeout(this.cliStartTimeout);
@@ -10218,6 +10906,7 @@ var CopilotClient = class _CopilotClient {
10218
10906
  ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
10219
10907
  mcpServers: toWireMcpServers(config.mcpServers),
10220
10908
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
10909
+ authClientIdMetadataUrl: config.authClientIdMetadataUrl,
10221
10910
  envValueMode: "direct",
10222
10911
  customAgents: toWireCustomAgents(config.customAgents),
10223
10912
  customAgentsLocalOnly: config.customAgentsLocalOnly,
@@ -10244,6 +10933,7 @@ var CopilotClient = class _CopilotClient {
10244
10933
  gitHubTokenProviderRegistrationId,
10245
10934
  remoteSession: config.remoteSession,
10246
10935
  cloud: config.cloud,
10936
+ featureFlags: config.featureFlags,
10247
10937
  expAssignments: config.expAssignments,
10248
10938
  enableManagedSettings: config.enableManagedSettings,
10249
10939
  managedSettings: config.managedSettings
@@ -10277,6 +10967,7 @@ var CopilotClient = class _CopilotClient {
10277
10967
  await this.updateSessionOptionsForMode(session, config);
10278
10968
  this.commitGitHubTokenProvider(returnedSessionId, gitHubTokenProviderRegistrationId);
10279
10969
  } catch (e) {
10970
+ session?._markDisconnected();
10280
10971
  if (registeredId !== void 0) {
10281
10972
  this.sessions.delete(registeredId);
10282
10973
  }
@@ -10461,6 +11152,7 @@ var CopilotClient = class _CopilotClient {
10461
11152
  ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
10462
11153
  mcpServers: toWireMcpServers(config.mcpServers),
10463
11154
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
11155
+ authClientIdMetadataUrl: config.authClientIdMetadataUrl,
10464
11156
  envValueMode: "direct",
10465
11157
  customAgents: toWireCustomAgents(config.customAgents),
10466
11158
  customAgentsLocalOnly: config.customAgentsLocalOnly,
@@ -10479,6 +11171,7 @@ var CopilotClient = class _CopilotClient {
10479
11171
  gitHubTokenProviderRegistrationId,
10480
11172
  remoteSession: config.remoteSession,
10481
11173
  openCanvases: config.openCanvases,
11174
+ featureFlags: config.featureFlags,
10482
11175
  expAssignments: config.expAssignments,
10483
11176
  enableManagedSettings: config.enableManagedSettings,
10484
11177
  managedSettings: config.managedSettings,
@@ -10508,6 +11201,7 @@ var CopilotClient = class _CopilotClient {
10508
11201
  await this.updateSessionOptionsForMode(session, config);
10509
11202
  this.commitGitHubTokenProvider(sessionId, gitHubTokenProviderRegistrationId);
10510
11203
  } catch (e) {
11204
+ session._markDisconnected();
10511
11205
  this.sessions.delete(sessionId);
10512
11206
  if (gitHubTokenProviderRegistrationId !== void 0) {
10513
11207
  this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
@@ -10623,10 +11317,17 @@ var CopilotClient = class _CopilotClient {
10623
11317
  const raceAgainstExit = (p) => this.processExitPromise ? Promise.race([p, this.processExitPromise]) : p;
10624
11318
  let serverVersion;
10625
11319
  try {
10626
- const connectParams = { token: this.effectiveConnectionToken };
11320
+ const connectParams = {
11321
+ token: this.effectiveConnectionToken,
11322
+ supportedTaskKinds: ["agent", "client", "shell"]
11323
+ };
10627
11324
  if (this.onGitHubTelemetry != null) {
10628
11325
  connectParams.enableGitHubTelemetryForwarding = true;
10629
11326
  }
11327
+ const clientInfo = clientInfoToWire(this.options.clientInfo);
11328
+ if (clientInfo != null) {
11329
+ connectParams.clientInfo = clientInfo;
11330
+ }
10630
11331
  const result = await raceAgainstExit(this.internalRpc.connect(connectParams));
10631
11332
  serverVersion = result.protocolVersion;
10632
11333
  } catch (err) {
@@ -10887,6 +11588,7 @@ var CopilotClient = class _CopilotClient {
10887
11588
  * Start the CLI server process
10888
11589
  */
10889
11590
  async startCLIServer() {
11591
+ this.resolvedCliPath ??= await getBundledRuntimePath();
10890
11592
  return new Promise((resolve22, reject) => {
10891
11593
  this.stderrBuffer = "";
10892
11594
  const args = [...this.connectionExtraArgs, "--headless", "--no-auto-update"];
@@ -10924,7 +11626,7 @@ var CopilotClient = class _CopilotClient {
10924
11626
  }
10925
11627
  if (!existsSync3(this.resolvedCliPath)) {
10926
11628
  throw new Error(
10927
- `Copilot CLI not found at ${this.resolvedCliPath}. Ensure @github/copilot is installed.`
11629
+ `Copilot CLI not found at ${this.resolvedCliPath}. Set COPILOT_CLI_PATH to use a custom installation.`
10928
11630
  );
10929
11631
  }
10930
11632
  const stdioConfig = this.connectionConfig.kind === "stdio" ? ["pipe", "pipe", "pipe"] : ["ignore", "pipe", "pipe"];
@@ -11051,12 +11753,19 @@ stderr: ${stderrOutput}`
11051
11753
  /** Starts the in-process FFI runtime with SDK-managed typed options. */
11052
11754
  async startInProcessFfi() {
11053
11755
  const explicitEntrypoint = this.resolvedEnv.COPILOT_CLI_PATH;
11054
- const runtimeLibrary = explicitEntrypoint ? join2(
11055
- dirname2(resolve2(explicitEntrypoint)),
11056
- "prebuilds",
11057
- _CopilotClient.getNapiPrebuildsFolder(explicitEntrypoint),
11058
- "runtime.node"
11059
- ) : join2(dirname2(getBundledRuntimePath()), "runtime.node");
11756
+ let runtimeLibrary;
11757
+ if (explicitEntrypoint) {
11758
+ const entrypointDirectory = dirname2(resolve2(explicitEntrypoint));
11759
+ const adjacentRuntime = join2(entrypointDirectory, "runtime.node");
11760
+ runtimeLibrary = existsSync3(adjacentRuntime) ? adjacentRuntime : join2(
11761
+ entrypointDirectory,
11762
+ "prebuilds",
11763
+ _CopilotClient.getNapiPrebuildsFolder(explicitEntrypoint),
11764
+ "runtime.node"
11765
+ );
11766
+ } else {
11767
+ runtimeLibrary = join2(dirname2(await getBundledRuntimePath()), "runtime.node");
11768
+ }
11060
11769
  const { FfiRuntimeHost: FfiRuntimeHost2 } = await Promise.resolve().then(() => (init_ffiRuntimeHost(), ffiRuntimeHost_exports));
11061
11770
  const environment = {};
11062
11771
  if (this.options.gitHubToken) {
@@ -11242,12 +11951,24 @@ stderr: ${stderrOutput}` : ""}`
11242
11951
  return await this.handleHooksInvoke(params);
11243
11952
  }
11244
11953
  );
11245
- this.connection.onClose(() => {
11954
+ const connection = this.connection;
11955
+ const markDisconnected = () => {
11956
+ if (this.connection !== connection) {
11957
+ return;
11958
+ }
11959
+ this.connectionClosed = true;
11246
11960
  this.state = "disconnected";
11961
+ for (const session of this.sessions.values()) {
11962
+ session._markDisconnected();
11963
+ }
11964
+ this.sessions.clear();
11247
11965
  this.githubTokenProviders.clear();
11248
- });
11249
- this.connection.onError((_error) => {
11250
- this.state = "disconnected";
11966
+ };
11967
+ this.connection.onClose(markDisconnected);
11968
+ this.connection.onError(() => {
11969
+ if (this.connection === connection) {
11970
+ this.state = "disconnected";
11971
+ }
11251
11972
  });
11252
11973
  }
11253
11974
  handleSessionEventNotification(notification) {
@@ -11361,7 +12082,7 @@ stderr: ${stderrOutput}` : ""}`
11361
12082
  }
11362
12083
  };
11363
12084
 
11364
- // node_modules/.pnpm/@github+copilot-sdk@1.0.13-preview.4/node_modules/@github/copilot-sdk/dist/extension.js
12085
+ // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/extension.js
11365
12086
  async function joinSession(config = {}) {
11366
12087
  const sessionId = process.env.SESSION_ID;
11367
12088
  if (!sessionId) {