@github/copilot-sdk 1.0.29-preview.5 → 1.0.29-preview.6

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
@@ -469,6 +469,8 @@ List all available sessions. Optionally filter by working directory context.
469
469
  - `summary?: string` - Optional session summary
470
470
  - `isRemote: boolean` - Whether the session is remote
471
471
  - `context?: SessionContext` - Working directory context from session creation
472
+ - `clientName?: string` - Client that created the session (for example `github/cli`)
473
+ - `lastClientName?: string` - Client that most recently ran the session: the client that created it, or a client that resumed it and then ran it. Resuming a session only to observe it does not change it. Omitted when unknown, such as for sessions persisted before this field existed.
472
474
 
473
475
  **SessionContext:**
474
476
 
@@ -620,6 +622,10 @@ sends do not inherit it. Ordinary immediate steering inherits the active schema
620
622
  and originating message ID, even when it arrives too late for the current model
621
623
  request and is promoted into a follow-up run. Specifying a schema with
622
624
  `mode: "immediate"` is rejected, even while idle.
625
+ Provider schema restrictions still apply, and schemas are not rewritten. Strict
626
+ OpenAI output needs an object root with every property listed in `required`.
627
+ Zod leaves `.optional()` properties out of `required`, so use `.nullable()` for a
628
+ field the model may leave empty.
623
629
  The generated `session.rpc.send` and `session.rpc.sendMessages` wrappers expose
624
630
  the full `responseFormat` contract when you need to set its name, description,
625
631
  or strict option rather than using the convenience defaults (`name: "response"`,
@@ -788,10 +794,6 @@ Capabilities may update during the session. For example, when another client joi
788
794
 
789
795
  Interactive UI methods for showing dialogs to the user. Only available when the CLI host supports elicitation (`session.capabilities.ui?.elicitation === true`). See [UI Elicitation](#ui-elicitation) for full details.
790
796
 
791
- ##### `destroy(): Promise<void>` _(deprecated)_
792
-
793
- Deprecated — use `disconnect()` instead.
794
-
795
797
  ---
796
798
 
797
799
  ## Event Types
@@ -1746,6 +1748,17 @@ Callbacks receive optional derived prompt context as `invocation.promptRequest`.
1746
1748
 
1747
1749
  Use the built-in `approveAll` helper when managed settings are disabled:
1748
1750
 
1751
+ <!-- docs-validate: strict -->
1752
+ <!-- docs-validate: hidden -->
1753
+ ```typescript
1754
+ import { approveAll } from "@github/copilot-sdk";
1755
+
1756
+ const session = await client.createSession({
1757
+ model: "gpt-5",
1758
+ onPermissionRequest: approveAll,
1759
+ });
1760
+ ```
1761
+ <!-- /docs-validate: hidden -->
1749
1762
  ```typescript
1750
1763
  import { CopilotClient, approveAll } from "@github/copilot-sdk";
1751
1764
 
@@ -1761,6 +1774,7 @@ When `enableManagedSettings` is true for the session, `approveAll` throws. Use a
1761
1774
 
1762
1775
  Provide your own function to inspect each request and apply custom logic. Check `managedApprovalRequired` before any automatic approval:
1763
1776
 
1777
+ <!-- docs-validate: strict -->
1764
1778
  ```typescript
1765
1779
  import type { PermissionRequest, PermissionRequestResult } from "@github/copilot-sdk";
1766
1780
 
@@ -1834,6 +1848,26 @@ Recheck requires session opt-in through `enableManagedSettings: true`.
1834
1848
  Treat helper text as untrusted plain text, keep `diagnostic` secondary,
1835
1849
  and sanitize `helpLink` before navigation.
1836
1850
 
1851
+ <!-- docs-validate: strict -->
1852
+ <!-- docs-validate: hidden -->
1853
+ ```typescript
1854
+ import type { CopilotSession } from "@github/copilot-sdk";
1855
+
1856
+ declare const session: CopilotSession;
1857
+
1858
+ const snapshot = await session.rpc.managedSettings.get();
1859
+
1860
+ if (snapshot.policyHelperFailure) {
1861
+ console.warn(snapshot.policyHelperFailure.message);
1862
+ }
1863
+
1864
+ if (snapshot.policyHelperCapabilities?.recheck === true) {
1865
+ const refreshed = await session.rpc.managedSettings.recheckPolicyHelper();
1866
+ // Only a current capable snapshot without policyHelperFailure establishes recovery.
1867
+ console.log(refreshed.policyHelperFailure ?? "Policy Helper recovered");
1868
+ }
1869
+ ```
1870
+ <!-- /docs-validate: hidden -->
1837
1871
  ```typescript
1838
1872
  const snapshot = await session.rpc.managedSettings.get();
1839
1873
 
@@ -1872,6 +1906,16 @@ The handler must return one of the `PermissionDecision` shapes (or `{ kind: "no-
1872
1906
 
1873
1907
  You may pass `onPermissionRequest` when resuming a session too:
1874
1908
 
1909
+ <!-- docs-validate: strict -->
1910
+ <!-- docs-validate: hidden -->
1911
+ ```typescript
1912
+ import { approveAll } from "@github/copilot-sdk";
1913
+
1914
+ const session = await client.resumeSession("session-id", {
1915
+ onPermissionRequest: approveAll,
1916
+ });
1917
+ ```
1918
+ <!-- /docs-validate: hidden -->
1875
1919
  ```typescript
1876
1920
  const session = await client.resumeSession("session-id", {
1877
1921
  onPermissionRequest: approveAll,
@@ -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.106-6";
25
+ const COPILOT_CLI_VERSION = "1.0.106-7";
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 = {
@@ -54,6 +54,19 @@ var import_types = require("./types.js");
54
54
  const MIN_PROTOCOL_VERSION = 3;
55
55
  const RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
56
56
  const CLOUD_SESSION_CLEANUP_TIMEOUT_MS = 1e4;
57
+ const messageEncodeErrors = /* @__PURE__ */ new WeakSet();
58
+ const jsonMessageEncoder = {
59
+ name: "application/json",
60
+ encode: (msg, options) => {
61
+ try {
62
+ return Promise.resolve(Buffer.from(JSON.stringify(msg), options.charset));
63
+ } catch (thrown) {
64
+ const error = thrown instanceof Error ? thrown : new Error(String(thrown));
65
+ messageEncodeErrors.add(error);
66
+ return Promise.reject(error);
67
+ }
68
+ }
69
+ };
57
70
  function createMessageConnection(reader, writer) {
58
71
  let dispatch;
59
72
  let finishDrain;
@@ -290,6 +303,9 @@ function getBundledRuntimePath() {
290
303
  }
291
304
  class TeardownResilientStreamMessageWriter extends import_node.StreamMessageWriter {
292
305
  suppressWriteErrors = false;
306
+ constructor(writable) {
307
+ super(writable, { contentTypeEncoder: jsonMessageEncoder });
308
+ }
293
309
  async write(msg) {
294
310
  try {
295
311
  await super.write(msg);
@@ -2315,7 +2331,9 @@ class CopilotClient {
2315
2331
  gitRoot: context.gitRoot,
2316
2332
  repository: context.repository,
2317
2333
  branch: context.branch
2318
- } : void 0
2334
+ } : void 0,
2335
+ clientName: raw.clientName,
2336
+ lastClientName: raw.lastClientName
2319
2337
  };
2320
2338
  }
2321
2339
  /**
@@ -2972,7 +2990,10 @@ stderr: ${stderrOutput}` : ""}`
2972
2990
  exitFallback.unref?.();
2973
2991
  });
2974
2992
  }
2975
- this.connection.onError(() => {
2993
+ this.connection.onError(([error]) => {
2994
+ if (messageEncodeErrors.has(error)) {
2995
+ return;
2996
+ }
2976
2997
  if (connectionEpoch === this.connectionEpoch && this.connection === connection) {
2977
2998
  this.state = "disconnected";
2978
2999
  }
@@ -1817,7 +1817,23 @@ function createInternalServerRpc(connection) {
1817
1817
  *
1818
1818
  * @returns The environment variable supplying a classic personal access token, when one is set.
1819
1819
  */
1820
- getTokenEnvVar: async () => connection.sendRequest("account.getTokenEnvVar", {})
1820
+ getTokenEnvVar: async () => connection.sendRequest("account.getTokenEnvVar", {}),
1821
+ /**
1822
+ * Enrolls the supplied identity in Copilot Free. A host offers this when a signed-in user has no Copilot subscription, so that signing up does not mean leaving for a browser. The runtime resolves the identity's credential itself, so the caller sends none. Read `kind` before `status`: an identity whose credential cannot be resolved answers `no-token` rather than failing the call, because that asks the user to sign in again rather than reporting that enrollment broke. Enrolling an already-enrolled account succeeds and reports `already_subscribed`. This does not refresh the caller's cached account state; a host that shows subscription status should re-read it afterwards.
1823
+ *
1824
+ * @param params The authentication identity to enroll in Copilot Free.
1825
+ *
1826
+ * @returns What came of a Copilot Free enrollment attempt.
1827
+ */
1828
+ subscribeCopilotFree: async (params) => connection.sendRequest("account.subscribeCopilotFree", params),
1829
+ /**
1830
+ * Resolves the base URL of the GitHub host from its configured names, normalizing a bare hostname into an `https://` URL and falling back to the public github.com host when neither name is set. Unlike `account.getWebUrl` this needs no identity, so a host can reach it before anyone has signed in -- which is when an enterprise instance must already be known.
1831
+ *
1832
+ * @param params Configured names of the GitHub host to resolve.
1833
+ *
1834
+ * @returns Absolute base URL of the GitHub host.
1835
+ */
1836
+ getHostUrl: async (params) => connection.sendRequest("account.getHostUrl", params)
1821
1837
  },
1822
1838
  /** @experimental */
1823
1839
  mcp: {
@@ -2009,7 +2025,23 @@ function createInternalServerRpc(connection) {
2009
2025
  *
2010
2026
  * @returns The GitHub repository that owns the requested path, when the selected remote (`origin`, else the first) is on a GitHub host.
2011
2027
  */
2012
- atPath: async (params) => connection.sendRequest("gitHubRepository.atPath", params)
2028
+ atPath: async (params) => connection.sendRequest("gitHubRepository.atPath", params),
2029
+ /**
2030
+ * Resolves the owner and name of a GitHub repository from its numeric repository id, by asking the GitHub API under the supplied credential. Returns a null `repository` when the id names nothing the credential can see, which the API reports as a 404, so a caller can tell 'no such visible repository' apart from a request that failed. The host queried is derived from `authInfo` rather than supplied separately, so the lookup always runs against the account's own GitHub host.
2031
+ *
2032
+ * @param params Selects a GitHub repository by its numeric repository id, and the credential to look it up under.
2033
+ *
2034
+ * @returns The repository the requested id names, when the credential can see one.
2035
+ */
2036
+ getById: async (params) => connection.sendRequest("gitHubRepository.getById", params),
2037
+ /**
2038
+ * Finds the pull request a branch is open against, searching every repository in `baseRepositories` so a fork's branch finds the pull request it opened upstream. A candidate is discarded unless `headOwner` owns its head branch, because a branch name alone is ambiguous across forks. `status` separates 'not authenticated', 'no such pull request' and 'the search failed', so a caller can tell a conclusive absence apart from an unknown one. The host queried is derived from `authInfo` rather than supplied separately, so the lookup always runs against the account's own GitHub host.
2039
+ *
2040
+ * @param params Selects the pull request a branch is open against, and the credential to look it up under. The branch is searched across every repository in `baseRepositories`, which lets a fork's branch find the pull request it opened against upstream.
2041
+ *
2042
+ * @returns Outcome of a branch pull-request lookup. `status` carries why, because 'not authenticated', 'no pull request' and 'the search failed' are three different answers and only the first two are conclusive.
2043
+ */
2044
+ lookupBranchPullRequest: async (params) => connection.sendRequest("gitHubRepository.lookupBranchPullRequest", params)
2013
2045
  },
2014
2046
  /** @experimental */
2015
2047
  gitHubOwners: {
@@ -2177,6 +2209,194 @@ function createInternalServerRpc(connection) {
2177
2209
  * @returns Live agent metadata without connection credentials.
2178
2210
  */
2179
2211
  listEntries: async (params) => connection.sendRequest("agentRegistry.listEntries", params)
2212
+ },
2213
+ /** @experimental */
2214
+ gitHubFetch: {
2215
+ /**
2216
+ * Registers one authenticated GitHub API request before it starts, so cancellation can name the operation. Each request claims its id once. Refused for extensions.
2217
+ *
2218
+ * @returns One registered GitHub request, shared by execution and cancellation.
2219
+ */
2220
+ allocateRequestId: async () => connection.sendRequest("gitHubFetch.allocateRequestId", {}),
2221
+ /**
2222
+ * Calls the GitHub API with session credentials, or process credentials when sessionId is absent. A bound host can select its existing auth handle with authOwnerId. The URL must match that identity's API origin or the runtime's explicit debug API origin. Retries and eligible redirects resolve the current credential again. Explicit caller Authorization remains unchanged; cross-origin redirects discard credentials without restoring them on later hops. Release asset bodies require gitHubRelease.downloadAsset. JSON asset metadata and other response bodies remain supported. The runtime supplies a default User-Agent and records request diagnostics. Extensions cannot use this method.
2223
+ *
2224
+ * @param params A GitHub API request without caller-supplied auth identity or credential fields.
2225
+ *
2226
+ * @returns The HTTP response or a classified request failure.
2227
+ */
2228
+ request: async (params) => connection.sendRequest("gitHubFetch.request", params),
2229
+ /**
2230
+ * Executes a named GitHub or Copilot job operation. The runtime derives its URL, headers, retry policy, and credential. sessionId selects session auth; omission selects process auth. A bound host connection can select its existing auth handle with authOwnerId. Retries and eligible redirects resolve the current credential again. Cross-origin redirects discard credentials without restoring them on later hops. Non-success HTTP responses include the formatted error for the host. Extensions cannot use this method.
2231
+ *
2232
+ * @param params Arguments for a named authenticated operation.
2233
+ *
2234
+ * @returns The HTTP response or a classified request failure.
2235
+ */
2236
+ executeOperation: async (params) => connection.sendRequest("gitHubFetch.executeOperation", params),
2237
+ /**
2238
+ * Cancels a registered GitHub request. False means the id is no longer registered. Uses the same runtime request registry as request and executeOperation. Refused for extensions.
2239
+ *
2240
+ * @param params One registered GitHub request, shared by execution and cancellation.
2241
+ *
2242
+ * @returns Whether cancellation reached a registered GitHub request.
2243
+ */
2244
+ cancel: async (params) => connection.sendRequest("gitHubFetch.cancel", params)
2245
+ },
2246
+ /** @experimental */
2247
+ gitHubRelease: {
2248
+ /**
2249
+ * Allocates a connection-owned request id before a release lookup, snapshot, or asset download starts. Use the id to cancel that operation. A snapshot retains its allocation until disposal or connection close.
2250
+ *
2251
+ * @returns A freshly registered request id. Registering it before the work starts is what lets a cancel that races the request still find something to cancel.
2252
+ */
2253
+ allocateRequestId: async () => connection.sendRequest("gitHubRelease.allocateRequestId", {}),
2254
+ /**
2255
+ * Retires an unused allocation that this caller will never dispatch. Only an unclaimed id on this connection with no active guard is eligible. Active, foreign, unknown and previously retired ids return abandoned: false. Ordinary cancellation still preserves the first canceled claim. This cleanup remains available during shutdown and is refused for extensions.
2256
+ *
2257
+ * @param params An unused release allocation that this caller will never dispatch. This is separate from cancellation before a request arrives.
2258
+ *
2259
+ * @returns Whether the runtime retired an unused allocation without affecting active work.
2260
+ */
2261
+ abandonRequest: async (params) => connection.sendRequest("gitHubRelease.abandonRequest", params),
2262
+ /**
2263
+ * Looks up a published release or release list. A bound host connection uses its original auth source. Other SDK callers keep the existing authInfo path. The runtime resolves credentials for each request and redirect. Public releases also permit anonymous access. The kind field distinguishes a result, a missing tag, no release, a rate limit, and failure. This raw lookup does not return a shared snapshot.
2264
+ *
2265
+ * @param params Which release to look up, the credential to look it up under, and the request id that makes the lookup cancellable.
2266
+ *
2267
+ * @returns Outcome of a release lookup. `releaseJson` is present only for `found`, and `message` only for the kinds that carry an explanation.
2268
+ */
2269
+ lookup: async (params) => connection.sendRequest("gitHubRelease.lookup", params),
2270
+ /**
2271
+ * Loads one immutable release snapshot for an update client or SDK host. The runtime retains the original credential source and resolves it for each request. Calls with the same allocated request id and options share one lookup and result. A dropped waiter does not cancel that lookup. Use gitHubRelease.cancel to dispose the operation. The runtime admits one failure report before it publishes a failed result. Extensions cannot use this method.
2272
+ *
2273
+ * @param params Immutable options for one connection-owned release snapshot.
2274
+ *
2275
+ * @returns The shared release result with its original lookup duration. Runtime worker faults remain RPC errors.
2276
+ */
2277
+ getSnapshot: async (params) => connection.sendRequest("gitHubRelease.getSnapshot", params),
2278
+ /**
2279
+ * Cancels an allocated operation on this connection. For a snapshot, disposal also waits for its owned lookup and retires its credential authority. It does not delete completed caller-owned downloads. An unknown or foreign id returns canceled: false. A completed download still returns its owned file, which the caller must dispose.
2280
+ *
2281
+ * @param params The release lookup or asset download to abandon.
2282
+ *
2283
+ * @returns Whether the cancel reached live work.
2284
+ */
2285
+ cancel: async (params) => connection.sendRequest("gitHubRelease.cancel", params),
2286
+ /**
2287
+ * Streams a published Copilot release asset to a private file and computes its SHA-256. The URL must name an HTTPS release download in a supported repository. A snapshotRequestId retains that snapshot's original credential source. Otherwise, a bound host uses its original owner, and other SDK callers keep the authInfo path. Each request and redirect resolves credentials again. Revocation fails without an auth fallback. Ordinary credential rejection and transport fallback keep their existing behavior. A digest mismatch removes the file. The result contains file metadata, not archive bytes. The caller must dispose the completed file after use. The download's own requestId controls progress and cancellation. Extensions cannot use this method.
2288
+ *
2289
+ * @param params Which release asset to download, the credential to download it under, and the request id that makes the download cancellable.
2290
+ *
2291
+ * @returns Outcome of an asset download. Each field is present only for the kinds its description names.
2292
+ */
2293
+ downloadAsset: async (params) => connection.sendRequest("gitHubRelease.downloadAsset", params),
2294
+ /**
2295
+ * Reports how many bytes a running `gitHubRelease.downloadAsset` has written, for a progress display. The runtime sends no progress notification for a download, so a host polls this while the download runs. An id with no running download reports zero bytes and no total, which is the normal answer before the body starts and after the download ends.
2296
+ *
2297
+ * @param params The download whose progress to report.
2298
+ *
2299
+ * @returns Byte progress of a running download.
2300
+ */
2301
+ getDownloadProgress: async (params) => connection.sendRequest("gitHubRelease.getDownloadProgress", params)
2302
+ },
2303
+ /** @experimental */
2304
+ cloudTasks: {
2305
+ /**
2306
+ * Starts a cloud coding-agent task, the remote run whose record `cloudTasks.get` later reads. Answered above any session because the task it creates is not a background task inside one. Hosts other than the CLI want this: a GitHub App or an SDK consumer that hands work to a cloud agent creates the same task under the same credential, and resolving it here keeps one credential, endpoint and validation path. Target the task either by repository, supplying both `repositoryOwner` and `repositoryName`, or by `owner` alone for an account-level run. The result separates a rejected request from a failed one: when `ok` is false, `reason` categorises the rejection and `message` carries the explanation to show, while `failure` describes the HTTP call itself and is present only when one was actually made.
2307
+ *
2308
+ * @param params Describes the cloud coding-agent task to start and the credential to start it under. Target it either by repository, supplying both `repositoryOwner` and `repositoryName`, or by `owner` alone for an account-level run.
2309
+ *
2310
+ * @returns The outcome of starting a cloud task. A rejected request and a failed one are reported separately: `reason` and `message` describe a request the service declined, while `statusCode` and `errorMessage` describe the HTTP call itself and appear only when one was actually made.
2311
+ */
2312
+ create: async (params) => connection.sendRequest("cloudTasks.create", params),
2313
+ /**
2314
+ * Deletes one cloud coding-agent task, the remote run `cloudTasks.create` started. The deletion is a soft one: the service withdraws the task from its listings rather than destroying the record, so a host removing a run from its own UI is the intended caller. Answered above any session for the same reason as `cloudTasks.get` -- the task is remote and has no local counterpart. Hosts other than the CLI want this: a GitHub App or an SDK consumer that manages cloud agent runs withdraws the same record under the same credential, and resolving it here keeps one credential-resolution and endpoint path. The runtime resolves each token from `authInfo` or `authContextId`. A host may preserve an explicit `baseUrl`; omission derives the endpoint from `authInfo`. The result is the HTTP outcome rather than a bare success flag: the call returns no body, so `ok` alone describes a success, while a failure is reported through `statusCode`, `errorMessage` and `errorPayloadJson` instead of being raised as an error.
2315
+ *
2316
+ * @param params Identifies one cloud coding-agent task to delete, and the credential to delete it under.
2317
+ *
2318
+ * @returns The HTTP outcome of deleting a cloud task. The deletion returns no body, so a successful call carries nothing beyond `ok`; a failed one is described by the remaining fields rather than raised as an error, so a caller can surface the service's own explanation.
2319
+ */
2320
+ delete: async (params) => connection.sendRequest("cloudTasks.delete", params),
2321
+ /**
2322
+ * Reads one cloud coding-agent task from the Copilot API. This is the task a cloud agent runs on a host's behalf, not a background task inside a session, so it is answered above any session and the `tasks` group does not cover it. Hosts other than the CLI want this: a GitHub App or an SDK consumer that shows the state of a cloud agent run must read the same task record, and resolving it here keeps one credential-resolution, task-URL and circuit-breaker path instead of each host rebuilding them. The result is the HTTP outcome rather than the task itself: a caller must read `ok` and `statusCode` before `payloadJson`, because a 404 is reported as a non-ok result rather than an error, which is what lets a caller tell "no such task" apart from "the API call failed".
2323
+ *
2324
+ * @param params Identifies one cloud coding-agent task and the credential to read it under.
2325
+ *
2326
+ * @returns The HTTP outcome of reading a cloud task, rather than the task alone. A 404 arrives here as a non-ok result with `statusCode` 404, not as an error, so a caller can tell an absent task apart from a failed call.
2327
+ */
2328
+ get: async (params) => connection.sendRequest("cloudTasks.get", params),
2329
+ /**
2330
+ * Reads the logs a cloud coding-agent session produced, from the Copilot API. Answered above any session, for the same reason as `cloudTasks.get`: the session being asked about runs remotely and has no local counterpart. Read `resolved` first. It is false when no Copilot API URL could be resolved for the credential, which is a different outcome from a request that was made and failed, and a caller that treats the two alike will report a transport error for an account that simply has no API endpoint. When `resolved` is true, `debugMessages` carries the diagnostics the fetch produced and should be logged whatever the outcome, `errorString` reports a retrieval fault, and only then do `ok` and `statusCode` describe the HTTP result.
2331
+ *
2332
+ * @param params Identifies one cloud coding-agent session whose logs are to be read, and the credential to read them under.
2333
+ *
2334
+ * @returns The outcome of reading a cloud session's logs. `resolved` distinguishes "this credential has no Copilot API endpoint" from "the request was made and failed"; every other field describes a request that was actually attempted.
2335
+ */
2336
+ getSessionLogs: async (params) => connection.sendRequest("cloudTasks.getSessionLogs", params),
2337
+ /**
2338
+ * Reconstructs the session a cloud coding-agent task recorded, by reading that task's events and ordering them for replay. Answered above any session, for the same reason as `cloudTasks.get`: the session being rebuilt ran remotely and has no local counterpart. Hosts other than the CLI want this: an SDK consumer attaching to a run in progress, an ACP client resuming one, or a GitHub App rendering a task's transcript all rebuild the same history from the same events, and resolving it here keeps one credential, endpoint, ordering and anchor-detection path. A newly created task has no events yet, so this polls for them and fails once they do not arrive. Read `preStart` before either list: when it is true the session has not started, `replayEventsJson` is deliberately empty because there is no history to reconstruct, and only `observedEventsJson` is meaningful.
2339
+ *
2340
+ * @param params Identifies one cloud coding-agent task whose recorded session is to be replayed, and the credential to read it under.
2341
+ *
2342
+ * @returns A cloud task's recorded events, ordered for replay. Read `preStart` first: it selects which of the two event lists a caller should use, and they differ deliberately.
2343
+ */
2344
+ getSessionReplay: async (params) => connection.sendRequest("cloudTasks.getSessionReplay", params),
2345
+ /**
2346
+ * Reads whether one cloud coding-agent task is shared, from the Mission Control service. Answered above any session, for the same reason as `cloudTasks.get`: the task is a remote record with no local counterpart. Hosts other than the CLI want this: an SDK consumer or a GitHub App that offers a "share this run" affordance must read the same flag from the same service, and resolving it here keeps one credential-resolution and endpoint path. The credential is resolved from `authInfo` inside the runtime rather than being carried across the door, so no caller handles a raw token. Read `credentialResolved` first: it is false when the account has no usable credential, in which case no request was made at all, which a caller must not report as a failed request.
2347
+ *
2348
+ * @param params Identifies one cloud coding-agent task whose sharing status is to be read, and the credential to read it under.
2349
+ *
2350
+ * @returns The sharing status a cloud task carries after the call. Read `credentialResolved` first: when it is false no request was attempted at all, which is a different outcome from a request the service declined.
2351
+ */
2352
+ getSharingStatus: async (params) => connection.sendRequest("cloudTasks.getSharingStatus", params),
2353
+ /**
2354
+ * Changes whether one cloud coding-agent task is shared, through the Mission Control service, and reports the status the task carries afterwards. The companion to `cloudTasks.getSharingStatus` and answered above any session for the same reason. The status is sent verbatim and is not narrowed to a closed set, because the service owns these values. The credential is resolved from `authInfo` inside the runtime rather than being carried across the door. Read `credentialResolved` first: it is false when the account has no usable credential, in which case nothing was changed and no request was made.
2355
+ *
2356
+ * @param params Identifies one cloud coding-agent task whose sharing status is to be changed, the status to set, and the credential to change it under.
2357
+ *
2358
+ * @returns The sharing status a cloud task carries after the call. Read `credentialResolved` first: when it is false no request was attempted at all, which is a different outcome from a request the service declined.
2359
+ */
2360
+ setSharingStatus: async (params) => connection.sendRequest("cloudTasks.setSharingStatus", params),
2361
+ /**
2362
+ * Finds the session a caller should open for one cloud coding-agent task. A task identifier alone does not say what to open: the run may already exist locally, it may exist only in the cloud, or it may be a task that cannot be resumed at all. Resolving that needs a local session scan and a Mission Control lookup that agree on identity, which is why it is answered here rather than left to each host. Hosts other than the CLI want it: an IDE or a GitHub App that opens a run from a task link faces the same three outcomes. Read `kind` before any other field. `local-session` carries `sessionId`, `remote-session` carries `metadataJson`, `unresumable-task` means the task exists but cannot be continued, and `none` means no session matched. A failed service call is reported as `error` rather than raised, so a caller can surface the service's own message. Pass every local session identifier already rejected in `ignoredLocalSessionIds` and call again to get the next candidate; that is how a host skips a local session it could not load.
2363
+ *
2364
+ * @param params Identifies one cloud coding-agent task to resolve to an openable session, the credential to resolve it under, and the local candidates the caller has already rejected.
2365
+ *
2366
+ * @returns What a caller should open for the task. The four outcomes are distinct and carry different payloads, so read `kind` before any other field.
2367
+ */
2368
+ resolveTaskId: async (params) => connection.sendRequest("cloudTasks.resolveTaskId", params)
2369
+ },
2370
+ /** @experimental */
2371
+ cafeMetrics: {
2372
+ /**
2373
+ * Starts anonymous CAFE metrics for this process. The runtime selects the endpoint from COPILOT_CAFE_METRICS_URL or this connection's original auth owner. Offline and unsupported platforms refuse startup. Release eligibility must resolve before samples are sent. Requires the private trusted CLI host capability.
2374
+ *
2375
+ * @param params Versions and provider configuration for CAFE.
2376
+ *
2377
+ * @returns CAFE startup result.
2378
+ */
2379
+ start: async (params) => connection.sendRequest("cafeMetrics.start", params),
2380
+ /**
2381
+ * Resolves release eligibility once from the immutable release lookup shared with auto-update. Requires the private trusted CLI host capability.
2382
+ *
2383
+ * @param params Immutable release lookup result.
2384
+ *
2385
+ * @returns Admission result.
2386
+ */
2387
+ resolveAdmission: async (params) => connection.sendRequest("cafeMetrics.resolveAdmission", params),
2388
+ /**
2389
+ * Records one terminal resume result. Does nothing before startup. Requires the private trusted CLI host capability.
2390
+ *
2391
+ * @param params Terminal result of one resume attempt.
2392
+ */
2393
+ recordResumeResult: async (params) => connection.sendRequest("cafeMetrics.recordResumeResult", params),
2394
+ /**
2395
+ * Stops recording and drains within one 1.5-second deadline. flushOnly sends at most one batch without stopping recording. Requires the private trusted CLI host capability.
2396
+ *
2397
+ * @param params Preliminary flush or final disposal.
2398
+ */
2399
+ shutdown: async (params) => connection.sendRequest("cafeMetrics.shutdown", params)
2180
2400
  }
2181
2401
  };
2182
2402
  }
@@ -4912,6 +5132,17 @@ function createInternalSessionRpc(connection, sessionId) {
4912
5132
  * @returns Result of registering or re-arming a scheduled prompt.
4913
5133
  */
4914
5134
  rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { ...params, sessionId })
5135
+ },
5136
+ /** @experimental */
5137
+ cafeMetrics: {
5138
+ /**
5139
+ * Records live model-call events, including subagents, and root compaction events. Replaces any earlier recorder. Requires the private trusted CLI host capability.
5140
+ */
5141
+ attach: async () => connection.sendRequest("session.cafeMetrics.attach", { sessionId }),
5142
+ /**
5143
+ * Stops recording this session. Does nothing if it has no recorder. Requires the private trusted CLI host capability.
5144
+ */
5145
+ detach: async () => connection.sendRequest("session.cafeMetrics.detach", { sessionId })
4915
5146
  }
4916
5147
  };
4917
5148
  }
@@ -1,2 +1,2 @@
1
- export declare const COPILOT_CLI_VERSION = "1.0.106-6";
1
+ export declare const COPILOT_CLI_VERSION = "1.0.106-7";
2
2
  export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
@@ -1,4 +1,4 @@
1
- const COPILOT_CLI_VERSION = "1.0.106-6";
1
+ const COPILOT_CLI_VERSION = "1.0.106-7";
2
2
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
3
3
  export {
4
4
  COPILOT_CLI_USE_NPM_PACKAGE,
package/dist/client.js CHANGED
@@ -36,6 +36,19 @@ import { defaultJoinSessionPermissionHandler } from "./types.js";
36
36
  const MIN_PROTOCOL_VERSION = 3;
37
37
  const RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
38
38
  const CLOUD_SESSION_CLEANUP_TIMEOUT_MS = 1e4;
39
+ const messageEncodeErrors = /* @__PURE__ */ new WeakSet();
40
+ const jsonMessageEncoder = {
41
+ name: "application/json",
42
+ encode: (msg, options) => {
43
+ try {
44
+ return Promise.resolve(Buffer.from(JSON.stringify(msg), options.charset));
45
+ } catch (thrown) {
46
+ const error = thrown instanceof Error ? thrown : new Error(String(thrown));
47
+ messageEncodeErrors.add(error);
48
+ return Promise.reject(error);
49
+ }
50
+ }
51
+ };
39
52
  function createMessageConnection(reader, writer) {
40
53
  let dispatch;
41
54
  let finishDrain;
@@ -272,6 +285,9 @@ function getBundledRuntimePath() {
272
285
  }
273
286
  class TeardownResilientStreamMessageWriter extends StreamMessageWriter {
274
287
  suppressWriteErrors = false;
288
+ constructor(writable) {
289
+ super(writable, { contentTypeEncoder: jsonMessageEncoder });
290
+ }
275
291
  async write(msg) {
276
292
  try {
277
293
  await super.write(msg);
@@ -2297,7 +2313,9 @@ class CopilotClient {
2297
2313
  gitRoot: context.gitRoot,
2298
2314
  repository: context.repository,
2299
2315
  branch: context.branch
2300
- } : void 0
2316
+ } : void 0,
2317
+ clientName: raw.clientName,
2318
+ lastClientName: raw.lastClientName
2301
2319
  };
2302
2320
  }
2303
2321
  /**
@@ -2954,7 +2972,10 @@ stderr: ${stderrOutput}` : ""}`
2954
2972
  exitFallback.unref?.();
2955
2973
  });
2956
2974
  }
2957
- this.connection.onError(() => {
2975
+ this.connection.onError(([error]) => {
2976
+ if (messageEncodeErrors.has(error)) {
2977
+ return;
2978
+ }
2958
2979
  if (connectionEpoch === this.connectionEpoch && this.connection === connection) {
2959
2980
  this.state = "disconnected";
2960
2981
  }
@@ -15119,6 +15119,40 @@ export interface FolderTrustCheckResult {
15119
15119
  */
15120
15120
  trusted: boolean;
15121
15121
  }
15122
+ /**
15123
+ * A pre-resolved address for a GitHub request.
15124
+ *
15125
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
15126
+ * via the `definition` "GitHubFetchPinnedAddress".
15127
+ */
15128
+ /** @experimental */
15129
+ export interface GitHubFetchPinnedAddress {
15130
+ /**
15131
+ * Address the network transport must use.
15132
+ */
15133
+ address: string;
15134
+ }
15135
+ /**
15136
+ * Proxy environment for one authenticated GitHub request.
15137
+ *
15138
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
15139
+ * via the `definition` "GitHubFetchProxyEnvironment".
15140
+ */
15141
+ /** @experimental */
15142
+ export interface GitHubFetchProxyEnvironment {
15143
+ /**
15144
+ * Proxy for HTTP requests.
15145
+ */
15146
+ httpProxy?: string;
15147
+ /**
15148
+ * Proxy for HTTPS requests.
15149
+ */
15150
+ httpsProxy?: string;
15151
+ /**
15152
+ * Hosts that bypass the proxy.
15153
+ */
15154
+ noProxy?: string;
15155
+ }
15122
15156
  /**
15123
15157
  * Owner, name, and host of a GitHub repository, as resolved from a git remote URL.
15124
15158
  *
@@ -17557,7 +17591,7 @@ export interface LocalSessionMetadataValue {
17557
17591
  */
17558
17592
  name?: string;
17559
17593
  /**
17560
- * Runtime client name that created/last resumed this session
17594
+ * Runtime client name that created this session
17561
17595
  */
17562
17596
  clientName?: string;
17563
17597
  /**
@@ -17576,6 +17610,10 @@ export interface LocalSessionMetadataValue {
17576
17610
  * GitHub task ID, when this local session is bound to one. Only present for local sessions exported to remote control.
17577
17611
  */
17578
17612
  mcTaskId?: string;
17613
+ /**
17614
+ * Runtime client name that most recently ran this session: the client that created it, or a client that resumed it and then ran it. Resuming a session only to observe it does not change this. Omitted when unknown, such as for sessions persisted before this field existed.
17615
+ */
17616
+ lastClientName?: string;
17579
17617
  }
17580
17618
  /**
17581
17619
  * Pre-resolved working-directory context for session startup.
@@ -18214,6 +18252,10 @@ export interface MarketplaceInfo {
18214
18252
  * Whether the managed marketplace currently resolved into the runtime marketplace registry. Set to false when the desired managed entry is retained for governance visibility after loading or reconciliation failed.
18215
18253
  */
18216
18254
  available?: boolean;
18255
+ /**
18256
+ * True when the signed-in account's GitHub Team provides this marketplace and no user, repository, or default entry of the same name exists. Team marketplaces are not persisted, so they cannot be removed.
18257
+ */
18258
+ team?: boolean;
18217
18259
  }
18218
18260
  /**
18219
18261
  * All registered marketplaces, including built-in defaults.
@@ -1789,7 +1789,23 @@ function createInternalServerRpc(connection) {
1789
1789
  *
1790
1790
  * @returns The environment variable supplying a classic personal access token, when one is set.
1791
1791
  */
1792
- getTokenEnvVar: async () => connection.sendRequest("account.getTokenEnvVar", {})
1792
+ getTokenEnvVar: async () => connection.sendRequest("account.getTokenEnvVar", {}),
1793
+ /**
1794
+ * Enrolls the supplied identity in Copilot Free. A host offers this when a signed-in user has no Copilot subscription, so that signing up does not mean leaving for a browser. The runtime resolves the identity's credential itself, so the caller sends none. Read `kind` before `status`: an identity whose credential cannot be resolved answers `no-token` rather than failing the call, because that asks the user to sign in again rather than reporting that enrollment broke. Enrolling an already-enrolled account succeeds and reports `already_subscribed`. This does not refresh the caller's cached account state; a host that shows subscription status should re-read it afterwards.
1795
+ *
1796
+ * @param params The authentication identity to enroll in Copilot Free.
1797
+ *
1798
+ * @returns What came of a Copilot Free enrollment attempt.
1799
+ */
1800
+ subscribeCopilotFree: async (params) => connection.sendRequest("account.subscribeCopilotFree", params),
1801
+ /**
1802
+ * Resolves the base URL of the GitHub host from its configured names, normalizing a bare hostname into an `https://` URL and falling back to the public github.com host when neither name is set. Unlike `account.getWebUrl` this needs no identity, so a host can reach it before anyone has signed in -- which is when an enterprise instance must already be known.
1803
+ *
1804
+ * @param params Configured names of the GitHub host to resolve.
1805
+ *
1806
+ * @returns Absolute base URL of the GitHub host.
1807
+ */
1808
+ getHostUrl: async (params) => connection.sendRequest("account.getHostUrl", params)
1793
1809
  },
1794
1810
  /** @experimental */
1795
1811
  mcp: {
@@ -1981,7 +1997,23 @@ function createInternalServerRpc(connection) {
1981
1997
  *
1982
1998
  * @returns The GitHub repository that owns the requested path, when the selected remote (`origin`, else the first) is on a GitHub host.
1983
1999
  */
1984
- atPath: async (params) => connection.sendRequest("gitHubRepository.atPath", params)
2000
+ atPath: async (params) => connection.sendRequest("gitHubRepository.atPath", params),
2001
+ /**
2002
+ * Resolves the owner and name of a GitHub repository from its numeric repository id, by asking the GitHub API under the supplied credential. Returns a null `repository` when the id names nothing the credential can see, which the API reports as a 404, so a caller can tell 'no such visible repository' apart from a request that failed. The host queried is derived from `authInfo` rather than supplied separately, so the lookup always runs against the account's own GitHub host.
2003
+ *
2004
+ * @param params Selects a GitHub repository by its numeric repository id, and the credential to look it up under.
2005
+ *
2006
+ * @returns The repository the requested id names, when the credential can see one.
2007
+ */
2008
+ getById: async (params) => connection.sendRequest("gitHubRepository.getById", params),
2009
+ /**
2010
+ * Finds the pull request a branch is open against, searching every repository in `baseRepositories` so a fork's branch finds the pull request it opened upstream. A candidate is discarded unless `headOwner` owns its head branch, because a branch name alone is ambiguous across forks. `status` separates 'not authenticated', 'no such pull request' and 'the search failed', so a caller can tell a conclusive absence apart from an unknown one. The host queried is derived from `authInfo` rather than supplied separately, so the lookup always runs against the account's own GitHub host.
2011
+ *
2012
+ * @param params Selects the pull request a branch is open against, and the credential to look it up under. The branch is searched across every repository in `baseRepositories`, which lets a fork's branch find the pull request it opened against upstream.
2013
+ *
2014
+ * @returns Outcome of a branch pull-request lookup. `status` carries why, because 'not authenticated', 'no pull request' and 'the search failed' are three different answers and only the first two are conclusive.
2015
+ */
2016
+ lookupBranchPullRequest: async (params) => connection.sendRequest("gitHubRepository.lookupBranchPullRequest", params)
1985
2017
  },
1986
2018
  /** @experimental */
1987
2019
  gitHubOwners: {
@@ -2149,6 +2181,194 @@ function createInternalServerRpc(connection) {
2149
2181
  * @returns Live agent metadata without connection credentials.
2150
2182
  */
2151
2183
  listEntries: async (params) => connection.sendRequest("agentRegistry.listEntries", params)
2184
+ },
2185
+ /** @experimental */
2186
+ gitHubFetch: {
2187
+ /**
2188
+ * Registers one authenticated GitHub API request before it starts, so cancellation can name the operation. Each request claims its id once. Refused for extensions.
2189
+ *
2190
+ * @returns One registered GitHub request, shared by execution and cancellation.
2191
+ */
2192
+ allocateRequestId: async () => connection.sendRequest("gitHubFetch.allocateRequestId", {}),
2193
+ /**
2194
+ * Calls the GitHub API with session credentials, or process credentials when sessionId is absent. A bound host can select its existing auth handle with authOwnerId. The URL must match that identity's API origin or the runtime's explicit debug API origin. Retries and eligible redirects resolve the current credential again. Explicit caller Authorization remains unchanged; cross-origin redirects discard credentials without restoring them on later hops. Release asset bodies require gitHubRelease.downloadAsset. JSON asset metadata and other response bodies remain supported. The runtime supplies a default User-Agent and records request diagnostics. Extensions cannot use this method.
2195
+ *
2196
+ * @param params A GitHub API request without caller-supplied auth identity or credential fields.
2197
+ *
2198
+ * @returns The HTTP response or a classified request failure.
2199
+ */
2200
+ request: async (params) => connection.sendRequest("gitHubFetch.request", params),
2201
+ /**
2202
+ * Executes a named GitHub or Copilot job operation. The runtime derives its URL, headers, retry policy, and credential. sessionId selects session auth; omission selects process auth. A bound host connection can select its existing auth handle with authOwnerId. Retries and eligible redirects resolve the current credential again. Cross-origin redirects discard credentials without restoring them on later hops. Non-success HTTP responses include the formatted error for the host. Extensions cannot use this method.
2203
+ *
2204
+ * @param params Arguments for a named authenticated operation.
2205
+ *
2206
+ * @returns The HTTP response or a classified request failure.
2207
+ */
2208
+ executeOperation: async (params) => connection.sendRequest("gitHubFetch.executeOperation", params),
2209
+ /**
2210
+ * Cancels a registered GitHub request. False means the id is no longer registered. Uses the same runtime request registry as request and executeOperation. Refused for extensions.
2211
+ *
2212
+ * @param params One registered GitHub request, shared by execution and cancellation.
2213
+ *
2214
+ * @returns Whether cancellation reached a registered GitHub request.
2215
+ */
2216
+ cancel: async (params) => connection.sendRequest("gitHubFetch.cancel", params)
2217
+ },
2218
+ /** @experimental */
2219
+ gitHubRelease: {
2220
+ /**
2221
+ * Allocates a connection-owned request id before a release lookup, snapshot, or asset download starts. Use the id to cancel that operation. A snapshot retains its allocation until disposal or connection close.
2222
+ *
2223
+ * @returns A freshly registered request id. Registering it before the work starts is what lets a cancel that races the request still find something to cancel.
2224
+ */
2225
+ allocateRequestId: async () => connection.sendRequest("gitHubRelease.allocateRequestId", {}),
2226
+ /**
2227
+ * Retires an unused allocation that this caller will never dispatch. Only an unclaimed id on this connection with no active guard is eligible. Active, foreign, unknown and previously retired ids return abandoned: false. Ordinary cancellation still preserves the first canceled claim. This cleanup remains available during shutdown and is refused for extensions.
2228
+ *
2229
+ * @param params An unused release allocation that this caller will never dispatch. This is separate from cancellation before a request arrives.
2230
+ *
2231
+ * @returns Whether the runtime retired an unused allocation without affecting active work.
2232
+ */
2233
+ abandonRequest: async (params) => connection.sendRequest("gitHubRelease.abandonRequest", params),
2234
+ /**
2235
+ * Looks up a published release or release list. A bound host connection uses its original auth source. Other SDK callers keep the existing authInfo path. The runtime resolves credentials for each request and redirect. Public releases also permit anonymous access. The kind field distinguishes a result, a missing tag, no release, a rate limit, and failure. This raw lookup does not return a shared snapshot.
2236
+ *
2237
+ * @param params Which release to look up, the credential to look it up under, and the request id that makes the lookup cancellable.
2238
+ *
2239
+ * @returns Outcome of a release lookup. `releaseJson` is present only for `found`, and `message` only for the kinds that carry an explanation.
2240
+ */
2241
+ lookup: async (params) => connection.sendRequest("gitHubRelease.lookup", params),
2242
+ /**
2243
+ * Loads one immutable release snapshot for an update client or SDK host. The runtime retains the original credential source and resolves it for each request. Calls with the same allocated request id and options share one lookup and result. A dropped waiter does not cancel that lookup. Use gitHubRelease.cancel to dispose the operation. The runtime admits one failure report before it publishes a failed result. Extensions cannot use this method.
2244
+ *
2245
+ * @param params Immutable options for one connection-owned release snapshot.
2246
+ *
2247
+ * @returns The shared release result with its original lookup duration. Runtime worker faults remain RPC errors.
2248
+ */
2249
+ getSnapshot: async (params) => connection.sendRequest("gitHubRelease.getSnapshot", params),
2250
+ /**
2251
+ * Cancels an allocated operation on this connection. For a snapshot, disposal also waits for its owned lookup and retires its credential authority. It does not delete completed caller-owned downloads. An unknown or foreign id returns canceled: false. A completed download still returns its owned file, which the caller must dispose.
2252
+ *
2253
+ * @param params The release lookup or asset download to abandon.
2254
+ *
2255
+ * @returns Whether the cancel reached live work.
2256
+ */
2257
+ cancel: async (params) => connection.sendRequest("gitHubRelease.cancel", params),
2258
+ /**
2259
+ * Streams a published Copilot release asset to a private file and computes its SHA-256. The URL must name an HTTPS release download in a supported repository. A snapshotRequestId retains that snapshot's original credential source. Otherwise, a bound host uses its original owner, and other SDK callers keep the authInfo path. Each request and redirect resolves credentials again. Revocation fails without an auth fallback. Ordinary credential rejection and transport fallback keep their existing behavior. A digest mismatch removes the file. The result contains file metadata, not archive bytes. The caller must dispose the completed file after use. The download's own requestId controls progress and cancellation. Extensions cannot use this method.
2260
+ *
2261
+ * @param params Which release asset to download, the credential to download it under, and the request id that makes the download cancellable.
2262
+ *
2263
+ * @returns Outcome of an asset download. Each field is present only for the kinds its description names.
2264
+ */
2265
+ downloadAsset: async (params) => connection.sendRequest("gitHubRelease.downloadAsset", params),
2266
+ /**
2267
+ * Reports how many bytes a running `gitHubRelease.downloadAsset` has written, for a progress display. The runtime sends no progress notification for a download, so a host polls this while the download runs. An id with no running download reports zero bytes and no total, which is the normal answer before the body starts and after the download ends.
2268
+ *
2269
+ * @param params The download whose progress to report.
2270
+ *
2271
+ * @returns Byte progress of a running download.
2272
+ */
2273
+ getDownloadProgress: async (params) => connection.sendRequest("gitHubRelease.getDownloadProgress", params)
2274
+ },
2275
+ /** @experimental */
2276
+ cloudTasks: {
2277
+ /**
2278
+ * Starts a cloud coding-agent task, the remote run whose record `cloudTasks.get` later reads. Answered above any session because the task it creates is not a background task inside one. Hosts other than the CLI want this: a GitHub App or an SDK consumer that hands work to a cloud agent creates the same task under the same credential, and resolving it here keeps one credential, endpoint and validation path. Target the task either by repository, supplying both `repositoryOwner` and `repositoryName`, or by `owner` alone for an account-level run. The result separates a rejected request from a failed one: when `ok` is false, `reason` categorises the rejection and `message` carries the explanation to show, while `failure` describes the HTTP call itself and is present only when one was actually made.
2279
+ *
2280
+ * @param params Describes the cloud coding-agent task to start and the credential to start it under. Target it either by repository, supplying both `repositoryOwner` and `repositoryName`, or by `owner` alone for an account-level run.
2281
+ *
2282
+ * @returns The outcome of starting a cloud task. A rejected request and a failed one are reported separately: `reason` and `message` describe a request the service declined, while `statusCode` and `errorMessage` describe the HTTP call itself and appear only when one was actually made.
2283
+ */
2284
+ create: async (params) => connection.sendRequest("cloudTasks.create", params),
2285
+ /**
2286
+ * Deletes one cloud coding-agent task, the remote run `cloudTasks.create` started. The deletion is a soft one: the service withdraws the task from its listings rather than destroying the record, so a host removing a run from its own UI is the intended caller. Answered above any session for the same reason as `cloudTasks.get` -- the task is remote and has no local counterpart. Hosts other than the CLI want this: a GitHub App or an SDK consumer that manages cloud agent runs withdraws the same record under the same credential, and resolving it here keeps one credential-resolution and endpoint path. The runtime resolves each token from `authInfo` or `authContextId`. A host may preserve an explicit `baseUrl`; omission derives the endpoint from `authInfo`. The result is the HTTP outcome rather than a bare success flag: the call returns no body, so `ok` alone describes a success, while a failure is reported through `statusCode`, `errorMessage` and `errorPayloadJson` instead of being raised as an error.
2287
+ *
2288
+ * @param params Identifies one cloud coding-agent task to delete, and the credential to delete it under.
2289
+ *
2290
+ * @returns The HTTP outcome of deleting a cloud task. The deletion returns no body, so a successful call carries nothing beyond `ok`; a failed one is described by the remaining fields rather than raised as an error, so a caller can surface the service's own explanation.
2291
+ */
2292
+ delete: async (params) => connection.sendRequest("cloudTasks.delete", params),
2293
+ /**
2294
+ * Reads one cloud coding-agent task from the Copilot API. This is the task a cloud agent runs on a host's behalf, not a background task inside a session, so it is answered above any session and the `tasks` group does not cover it. Hosts other than the CLI want this: a GitHub App or an SDK consumer that shows the state of a cloud agent run must read the same task record, and resolving it here keeps one credential-resolution, task-URL and circuit-breaker path instead of each host rebuilding them. The result is the HTTP outcome rather than the task itself: a caller must read `ok` and `statusCode` before `payloadJson`, because a 404 is reported as a non-ok result rather than an error, which is what lets a caller tell "no such task" apart from "the API call failed".
2295
+ *
2296
+ * @param params Identifies one cloud coding-agent task and the credential to read it under.
2297
+ *
2298
+ * @returns The HTTP outcome of reading a cloud task, rather than the task alone. A 404 arrives here as a non-ok result with `statusCode` 404, not as an error, so a caller can tell an absent task apart from a failed call.
2299
+ */
2300
+ get: async (params) => connection.sendRequest("cloudTasks.get", params),
2301
+ /**
2302
+ * Reads the logs a cloud coding-agent session produced, from the Copilot API. Answered above any session, for the same reason as `cloudTasks.get`: the session being asked about runs remotely and has no local counterpart. Read `resolved` first. It is false when no Copilot API URL could be resolved for the credential, which is a different outcome from a request that was made and failed, and a caller that treats the two alike will report a transport error for an account that simply has no API endpoint. When `resolved` is true, `debugMessages` carries the diagnostics the fetch produced and should be logged whatever the outcome, `errorString` reports a retrieval fault, and only then do `ok` and `statusCode` describe the HTTP result.
2303
+ *
2304
+ * @param params Identifies one cloud coding-agent session whose logs are to be read, and the credential to read them under.
2305
+ *
2306
+ * @returns The outcome of reading a cloud session's logs. `resolved` distinguishes "this credential has no Copilot API endpoint" from "the request was made and failed"; every other field describes a request that was actually attempted.
2307
+ */
2308
+ getSessionLogs: async (params) => connection.sendRequest("cloudTasks.getSessionLogs", params),
2309
+ /**
2310
+ * Reconstructs the session a cloud coding-agent task recorded, by reading that task's events and ordering them for replay. Answered above any session, for the same reason as `cloudTasks.get`: the session being rebuilt ran remotely and has no local counterpart. Hosts other than the CLI want this: an SDK consumer attaching to a run in progress, an ACP client resuming one, or a GitHub App rendering a task's transcript all rebuild the same history from the same events, and resolving it here keeps one credential, endpoint, ordering and anchor-detection path. A newly created task has no events yet, so this polls for them and fails once they do not arrive. Read `preStart` before either list: when it is true the session has not started, `replayEventsJson` is deliberately empty because there is no history to reconstruct, and only `observedEventsJson` is meaningful.
2311
+ *
2312
+ * @param params Identifies one cloud coding-agent task whose recorded session is to be replayed, and the credential to read it under.
2313
+ *
2314
+ * @returns A cloud task's recorded events, ordered for replay. Read `preStart` first: it selects which of the two event lists a caller should use, and they differ deliberately.
2315
+ */
2316
+ getSessionReplay: async (params) => connection.sendRequest("cloudTasks.getSessionReplay", params),
2317
+ /**
2318
+ * Reads whether one cloud coding-agent task is shared, from the Mission Control service. Answered above any session, for the same reason as `cloudTasks.get`: the task is a remote record with no local counterpart. Hosts other than the CLI want this: an SDK consumer or a GitHub App that offers a "share this run" affordance must read the same flag from the same service, and resolving it here keeps one credential-resolution and endpoint path. The credential is resolved from `authInfo` inside the runtime rather than being carried across the door, so no caller handles a raw token. Read `credentialResolved` first: it is false when the account has no usable credential, in which case no request was made at all, which a caller must not report as a failed request.
2319
+ *
2320
+ * @param params Identifies one cloud coding-agent task whose sharing status is to be read, and the credential to read it under.
2321
+ *
2322
+ * @returns The sharing status a cloud task carries after the call. Read `credentialResolved` first: when it is false no request was attempted at all, which is a different outcome from a request the service declined.
2323
+ */
2324
+ getSharingStatus: async (params) => connection.sendRequest("cloudTasks.getSharingStatus", params),
2325
+ /**
2326
+ * Changes whether one cloud coding-agent task is shared, through the Mission Control service, and reports the status the task carries afterwards. The companion to `cloudTasks.getSharingStatus` and answered above any session for the same reason. The status is sent verbatim and is not narrowed to a closed set, because the service owns these values. The credential is resolved from `authInfo` inside the runtime rather than being carried across the door. Read `credentialResolved` first: it is false when the account has no usable credential, in which case nothing was changed and no request was made.
2327
+ *
2328
+ * @param params Identifies one cloud coding-agent task whose sharing status is to be changed, the status to set, and the credential to change it under.
2329
+ *
2330
+ * @returns The sharing status a cloud task carries after the call. Read `credentialResolved` first: when it is false no request was attempted at all, which is a different outcome from a request the service declined.
2331
+ */
2332
+ setSharingStatus: async (params) => connection.sendRequest("cloudTasks.setSharingStatus", params),
2333
+ /**
2334
+ * Finds the session a caller should open for one cloud coding-agent task. A task identifier alone does not say what to open: the run may already exist locally, it may exist only in the cloud, or it may be a task that cannot be resumed at all. Resolving that needs a local session scan and a Mission Control lookup that agree on identity, which is why it is answered here rather than left to each host. Hosts other than the CLI want it: an IDE or a GitHub App that opens a run from a task link faces the same three outcomes. Read `kind` before any other field. `local-session` carries `sessionId`, `remote-session` carries `metadataJson`, `unresumable-task` means the task exists but cannot be continued, and `none` means no session matched. A failed service call is reported as `error` rather than raised, so a caller can surface the service's own message. Pass every local session identifier already rejected in `ignoredLocalSessionIds` and call again to get the next candidate; that is how a host skips a local session it could not load.
2335
+ *
2336
+ * @param params Identifies one cloud coding-agent task to resolve to an openable session, the credential to resolve it under, and the local candidates the caller has already rejected.
2337
+ *
2338
+ * @returns What a caller should open for the task. The four outcomes are distinct and carry different payloads, so read `kind` before any other field.
2339
+ */
2340
+ resolveTaskId: async (params) => connection.sendRequest("cloudTasks.resolveTaskId", params)
2341
+ },
2342
+ /** @experimental */
2343
+ cafeMetrics: {
2344
+ /**
2345
+ * Starts anonymous CAFE metrics for this process. The runtime selects the endpoint from COPILOT_CAFE_METRICS_URL or this connection's original auth owner. Offline and unsupported platforms refuse startup. Release eligibility must resolve before samples are sent. Requires the private trusted CLI host capability.
2346
+ *
2347
+ * @param params Versions and provider configuration for CAFE.
2348
+ *
2349
+ * @returns CAFE startup result.
2350
+ */
2351
+ start: async (params) => connection.sendRequest("cafeMetrics.start", params),
2352
+ /**
2353
+ * Resolves release eligibility once from the immutable release lookup shared with auto-update. Requires the private trusted CLI host capability.
2354
+ *
2355
+ * @param params Immutable release lookup result.
2356
+ *
2357
+ * @returns Admission result.
2358
+ */
2359
+ resolveAdmission: async (params) => connection.sendRequest("cafeMetrics.resolveAdmission", params),
2360
+ /**
2361
+ * Records one terminal resume result. Does nothing before startup. Requires the private trusted CLI host capability.
2362
+ *
2363
+ * @param params Terminal result of one resume attempt.
2364
+ */
2365
+ recordResumeResult: async (params) => connection.sendRequest("cafeMetrics.recordResumeResult", params),
2366
+ /**
2367
+ * Stops recording and drains within one 1.5-second deadline. flushOnly sends at most one batch without stopping recording. Requires the private trusted CLI host capability.
2368
+ *
2369
+ * @param params Preliminary flush or final disposal.
2370
+ */
2371
+ shutdown: async (params) => connection.sendRequest("cafeMetrics.shutdown", params)
2152
2372
  }
2153
2373
  };
2154
2374
  }
@@ -4884,6 +5104,17 @@ function createInternalSessionRpc(connection, sessionId) {
4884
5104
  * @returns Result of registering or re-arming a scheduled prompt.
4885
5105
  */
4886
5106
  rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { ...params, sessionId })
5107
+ },
5108
+ /** @experimental */
5109
+ cafeMetrics: {
5110
+ /**
5111
+ * Records live model-call events, including subagents, and root compaction events. Replaces any earlier recorder. Requires the private trusted CLI host capability.
5112
+ */
5113
+ attach: async () => connection.sendRequest("session.cafeMetrics.attach", { sessionId }),
5114
+ /**
5115
+ * Stops recording this session. Does nothing if it has no recorder. Requires the private trusted CLI host capability.
5116
+ */
5117
+ detach: async () => connection.sendRequest("session.cafeMetrics.detach", { sessionId })
4887
5118
  }
4888
5119
  };
4889
5120
  }
@@ -5802,6 +5802,10 @@ export interface UserMessageData {
5802
5802
  * Files, selections, or GitHub references attached to the message
5803
5803
  */
5804
5804
  attachments?: Attachment[];
5805
+ /**
5806
+ * IDs of accepted assistant messages that caused this delivered inter-agent prompt, referring to assistant.message.data.messageId across the agent tree. Captured when sending and retained through queued or immediate delivery. An empty list means no model-produced dependency; absence means provenance is unavailable.
5807
+ */
5808
+ causalDependencies?: string[];
5805
5809
  /**
5806
5810
  * The user's message text as displayed in the timeline
5807
5811
  */
@@ -8986,6 +8990,10 @@ export interface ToolExecutionCompleteEvent {
8986
8990
  * Tool execution completion results including success status, detailed output, and error information
8987
8991
  */
8988
8992
  export interface ToolExecutionCompleteData {
8993
+ /**
8994
+ * IDs of accepted assistant messages whose output this tool result consumed, referring to assistant.message.data.messageId across the agent tree. Captured from the returned snapshot, including partial agent reads. An empty list means no model-produced dependency; absence means provenance is unavailable.
8995
+ */
8996
+ causalDependencies?: string[];
8989
8997
  /**
8990
8998
  * Error details when the tool execution failed
8991
8999
  */
@@ -10772,6 +10780,10 @@ export interface SystemNotificationEvent {
10772
10780
  * System-generated notification for runtime events like background task completion
10773
10781
  */
10774
10782
  export interface SystemNotificationData {
10783
+ /**
10784
+ * IDs of accepted assistant messages whose output this notification consumed, referring to assistant.message.data.messageId across the agent tree. Captured from the delivered snapshot, not the sender's later state. An empty list means no model-produced dependency; absence means provenance is unavailable.
10785
+ */
10786
+ causalDependencies?: string[];
10775
10787
  /**
10776
10788
  * The notification text, typically wrapped in <system_notification> XML tags
10777
10789
  */
package/dist/session.d.ts CHANGED
@@ -159,6 +159,7 @@ export declare class CopilotSession {
159
159
  * Events are still delivered to handlers registered via {@link on} while waiting.
160
160
  * Sub-agent events with a non-empty `agentId` do not complete the wait or supply its reply.
161
161
  * With a schema as the second argument, returns its parsed, validated result.
162
+ * Provider schema restrictions apply to that schema; see {@link MessageOptions.responseSchema}.
162
163
  * Structured waits select only root-agent output originating from this send;
163
164
  * other queued work may delay session.idle but cannot replace the result.
164
165
  *
package/dist/types.d.ts CHANGED
@@ -3285,6 +3285,9 @@ export interface MessageOptions {
3285
3285
  * sendAndWait still returns an assistant message event. For a typed result, pass a
3286
3286
  * Zod-compatible schema as sendAndWait's second argument instead.
3287
3287
  * Streaming events remain text and may include intermediate messages.
3288
+ * Sent with strict: true and not rewritten, so provider schema restrictions apply: strict
3289
+ * OpenAI output needs an object root with every property required (use Zod's .nullable()
3290
+ * rather than .optional()).
3288
3291
  * Use rpc.send's responseFormat for provider-specific name, description and strict options.
3289
3292
  */
3290
3293
  responseSchema?: ZodSchema | Record<string, unknown>;
@@ -3383,6 +3386,18 @@ export interface SessionMetadata {
3383
3386
  isRemote: boolean;
3384
3387
  /** Working directory context (working directory, git info) from session creation */
3385
3388
  context?: SessionContext;
3389
+ /**
3390
+ * Name of the client that created the session (for example `github/cli`). Omitted when
3391
+ * unknown.
3392
+ */
3393
+ clientName?: string;
3394
+ /**
3395
+ * Name of the client that most recently ran the session: the client that created it, or a
3396
+ * client that resumed it and then ran it. Resuming a session only to observe it does not
3397
+ * change this. Omitted when unknown, such as for sessions persisted before this field
3398
+ * existed.
3399
+ */
3400
+ lastClientName?: string;
3386
3401
  }
3387
3402
  /**
3388
3403
  * Response from status.get
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "url": "https://github.com/github/copilot-agent-runtime.git",
6
6
  "directory": "src/sdk/nodejs"
7
7
  },
8
- "version": "1.0.29-preview.5",
9
- "copilotCliVersion": "1.0.106-6",
8
+ "version": "1.0.29-preview.6",
9
+ "copilotCliVersion": "1.0.106-7",
10
10
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
11
11
  "main": "./dist/cjs/index.js",
12
12
  "types": "./dist/index.d.ts",
@@ -117,18 +117,18 @@
117
117
  "README.md"
118
118
  ],
119
119
  "copilotRuntime": {
120
- "sourceSha": "499e74e4fa51da808a2c3c6c6c27ba946167e27a",
121
- "version": "1.0.106-6",
120
+ "sourceSha": "231e2021c92dbec223006702f867d8c29cae2f54",
121
+ "version": "1.0.106-7",
122
122
  "visibility": "public"
123
123
  },
124
124
  "optionalDependencies": {
125
- "@github/copilot-sdk-darwin-arm64": "1.0.29-preview.5",
126
- "@github/copilot-sdk-darwin-x64": "1.0.29-preview.5",
127
- "@github/copilot-sdk-linux-arm64": "1.0.29-preview.5",
128
- "@github/copilot-sdk-linux-x64": "1.0.29-preview.5",
129
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.29-preview.5",
130
- "@github/copilot-sdk-linuxmusl-x64": "1.0.29-preview.5",
131
- "@github/copilot-sdk-win32-arm64": "1.0.29-preview.5",
132
- "@github/copilot-sdk-win32-x64": "1.0.29-preview.5"
125
+ "@github/copilot-sdk-darwin-arm64": "1.0.29-preview.6",
126
+ "@github/copilot-sdk-darwin-x64": "1.0.29-preview.6",
127
+ "@github/copilot-sdk-linux-arm64": "1.0.29-preview.6",
128
+ "@github/copilot-sdk-linux-x64": "1.0.29-preview.6",
129
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.29-preview.6",
130
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.29-preview.6",
131
+ "@github/copilot-sdk-win32-arm64": "1.0.29-preview.6",
132
+ "@github/copilot-sdk-win32-x64": "1.0.29-preview.6"
133
133
  }
134
134
  }