@github/copilot-sdk 1.0.5 → 1.0.6-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -280,7 +280,8 @@ class CopilotClient {
280
280
  /** Connection-level session filesystem config, set via constructor option. */
281
281
  sessionFsConfig = null;
282
282
  requestHandler = null;
283
- llmInferenceHandlers = {};
283
+ onGitHubTelemetry;
284
+ clientGlobalHandlers = {};
284
285
  /**
285
286
  * Typed server-scoped RPC methods.
286
287
  * @throws Error if the client is not connected
@@ -381,7 +382,8 @@ class CopilotClient {
381
382
  this.onGetTraceContext = options.onGetTraceContext;
382
383
  this.sessionFsConfig = options.sessionFs ?? null;
383
384
  this.requestHandler = options.requestHandler ?? null;
384
- this.setupLlmInference();
385
+ this.onGitHubTelemetry = options.onGitHubTelemetry;
386
+ this.setupClientGlobalHandlers();
385
387
  const effectiveEnv = options.env ?? process.env;
386
388
  this.resolvedEnv = effectiveEnv;
387
389
  this.resolvedCliPath = conn.kind === "stdio" || conn.kind === "tcp" ? conn.path ?? effectiveEnv.COPILOT_CLI_PATH ?? getBundledCliPath() : void 0;
@@ -461,19 +463,29 @@ class CopilotClient {
461
463
  }
462
464
  session.clientSessionApis.sessionFs = (0, import_sessionFsProvider.createSessionFsAdapter)(provider);
463
465
  }
464
- setupLlmInference() {
465
- if (!this.requestHandler) {
466
- return;
467
- }
468
- this.llmInferenceHandlers = {
469
- llmInference: (0, import_copilotRequestHandler.createCopilotRequestAdapter)(this.requestHandler, () => {
466
+ setupClientGlobalHandlers() {
467
+ const handlers = {};
468
+ if (this.requestHandler) {
469
+ handlers.llmInference = (0, import_copilotRequestHandler.createCopilotRequestAdapter)(this.requestHandler, () => {
470
470
  if (!this.connection) {
471
471
  return void 0;
472
472
  }
473
473
  this._rpc ??= (0, import_rpc.createServerRpc)(this.connection);
474
474
  return this._rpc;
475
- })
476
- };
475
+ });
476
+ }
477
+ if (this.onGitHubTelemetry) {
478
+ const onGitHubTelemetry = this.onGitHubTelemetry;
479
+ handlers.gitHubTelemetry = {
480
+ event: async (notification) => {
481
+ try {
482
+ await onGitHubTelemetry(notification);
483
+ } catch {
484
+ }
485
+ }
486
+ };
487
+ }
488
+ this.clientGlobalHandlers = handlers;
477
489
  }
478
490
  /**
479
491
  * Starts the CLI server and establishes a connection.
@@ -1017,6 +1029,7 @@ class CopilotClient {
1017
1029
  workingDirectory: config.workingDirectory,
1018
1030
  streaming: config.streaming,
1019
1031
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
1032
+ ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
1020
1033
  mcpServers: toWireMcpServers(config.mcpServers),
1021
1034
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
1022
1035
  envValueMode: "direct",
@@ -1214,6 +1227,7 @@ class CopilotClient {
1214
1227
  enableSkills: config.enableSkills,
1215
1228
  streaming: config.streaming,
1216
1229
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
1230
+ ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
1217
1231
  mcpServers: toWireMcpServers(config.mcpServers),
1218
1232
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
1219
1233
  envValueMode: "direct",
@@ -1879,7 +1893,7 @@ stderr: ${stderrOutput}`
1879
1893
  if (!session) throw new Error(`No session found for sessionId: ${sessionId}`);
1880
1894
  return session.clientSessionApis;
1881
1895
  });
1882
- (0, import_rpc.registerClientGlobalApiHandlers)(this.connection, this.llmInferenceHandlers);
1896
+ (0, import_rpc.registerClientGlobalApiHandlers)(this.connection, this.clientGlobalHandlers);
1883
1897
  this.connection.onClose(() => {
1884
1898
  this.state = "disconnected";
1885
1899
  });
@@ -621,14 +621,6 @@ function createInternalServerRpc(connection) {
621
621
  * @returns Dynamic-context board entry count, when available.
622
622
  */
623
623
  getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
624
- /**
625
- * Cursor-based long-poll for sessions spawned by the runtime (e.g. in response to a Mission Control `start_session` command). The cursor is an opaque token; pass it back to receive only spawn events that occurred AFTER the cursor was issued. Omit the cursor on the first call to receive any events buffered since the runtime started. Internal: this is a CLI background-daemon plumbing primitive. SDK consumers that need to react to runtime-spawned sessions should subscribe to a higher-level event stream rather than driving a long-poll loop.
626
- *
627
- * @param params Cursor and optional long-poll wait for polling runtime-spawned sessions.
628
- *
629
- * @returns Batch of spawn events plus a cursor for follow-up polls.
630
- */
631
- pollSpawnedSessions: async (params) => connection.sendRequest("sessions.pollSpawnedSessions", params),
632
624
  /**
633
625
  * Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
634
626
  *
@@ -1718,6 +1710,20 @@ function createSessionRpc(connection, sessionId) {
1718
1710
  * @returns Token breakdown for the session's current context window, or null if uninitialized.
1719
1711
  */
1720
1712
  contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { sessionId, ...params }),
1713
+ /**
1714
+ * Returns the experimental per-source attribution breakdown of the session's current context window as a flat list of entries (skills, subagents, MCP servers, built-in tools, plugin rollups, system/tool-definition costs, with nesting via parentId), plus the successful compaction count. The heaviest individual messages are available separately via `metadata.getContextHeaviestMessages`. Returns null until the session has initialized its system prompt and tool metadata.
1715
+ *
1716
+ * @returns Per-source attribution breakdown for the session's current context window, or null if uninitialized.
1717
+ */
1718
+ getContextAttribution: async () => connection.sendRequest("session.metadata.getContextAttribution", { sessionId }),
1719
+ /**
1720
+ * Returns the largest individual messages currently in the session's context window, most-expensive first. Companion to `metadata.getContextAttribution`. Returns an empty list until the session has initialized.
1721
+ *
1722
+ * @param params Parameters for the heaviest-messages query.
1723
+ *
1724
+ * @returns The heaviest individual messages in the session's context window, most-expensive first.
1725
+ */
1726
+ getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { sessionId, ...params }),
1721
1727
  /**
1722
1728
  * Records a working-directory/git context change and emits a `session.context_changed` event.
1723
1729
  *
@@ -2086,10 +2092,10 @@ function registerClientGlobalApiHandlers(connection, handlers) {
2086
2092
  if (!handler) throw new Error("No llmInference client-global handler registered");
2087
2093
  return handler.httpRequestChunk(params);
2088
2094
  });
2089
- connection.onRequest("gitHubTelemetry.event", async (params) => {
2095
+ connection.onNotification("gitHubTelemetry.event", async (params) => {
2090
2096
  const handler = handlers.gitHubTelemetry;
2091
- if (!handler) throw new Error("No gitHubTelemetry client-global handler registered");
2092
- return handler.event(params);
2097
+ if (!handler) return;
2098
+ await handler.event(params);
2093
2099
  });
2094
2100
  }
2095
2101
  // Annotate the CommonJS export names for ESM import in node:
package/dist/client.d.ts CHANGED
@@ -36,7 +36,8 @@ export declare class CopilotClient {
36
36
  /** Connection-level session filesystem config, set via constructor option. */
37
37
  private sessionFsConfig;
38
38
  private requestHandler;
39
- private llmInferenceHandlers;
39
+ private onGitHubTelemetry?;
40
+ private clientGlobalHandlers;
40
41
  /**
41
42
  * Typed server-scoped RPC methods.
42
43
  * @throws Error if the client is not connected
@@ -80,7 +81,7 @@ export declare class CopilotClient {
80
81
  private parseCliUrl;
81
82
  private validateSessionFsConfig;
82
83
  private setupSessionFs;
83
- private setupLlmInference;
84
+ private setupClientGlobalHandlers;
84
85
  /**
85
86
  * Starts the CLI server and establishes a connection.
86
87
  *
package/dist/client.js CHANGED
@@ -267,7 +267,8 @@ class CopilotClient {
267
267
  /** Connection-level session filesystem config, set via constructor option. */
268
268
  sessionFsConfig = null;
269
269
  requestHandler = null;
270
- llmInferenceHandlers = {};
270
+ onGitHubTelemetry;
271
+ clientGlobalHandlers = {};
271
272
  /**
272
273
  * Typed server-scoped RPC methods.
273
274
  * @throws Error if the client is not connected
@@ -368,7 +369,8 @@ class CopilotClient {
368
369
  this.onGetTraceContext = options.onGetTraceContext;
369
370
  this.sessionFsConfig = options.sessionFs ?? null;
370
371
  this.requestHandler = options.requestHandler ?? null;
371
- this.setupLlmInference();
372
+ this.onGitHubTelemetry = options.onGitHubTelemetry;
373
+ this.setupClientGlobalHandlers();
372
374
  const effectiveEnv = options.env ?? process.env;
373
375
  this.resolvedEnv = effectiveEnv;
374
376
  this.resolvedCliPath = conn.kind === "stdio" || conn.kind === "tcp" ? conn.path ?? effectiveEnv.COPILOT_CLI_PATH ?? getBundledCliPath() : void 0;
@@ -448,19 +450,29 @@ class CopilotClient {
448
450
  }
449
451
  session.clientSessionApis.sessionFs = createSessionFsAdapter(provider);
450
452
  }
451
- setupLlmInference() {
452
- if (!this.requestHandler) {
453
- return;
454
- }
455
- this.llmInferenceHandlers = {
456
- llmInference: createCopilotRequestAdapter(this.requestHandler, () => {
453
+ setupClientGlobalHandlers() {
454
+ const handlers = {};
455
+ if (this.requestHandler) {
456
+ handlers.llmInference = createCopilotRequestAdapter(this.requestHandler, () => {
457
457
  if (!this.connection) {
458
458
  return void 0;
459
459
  }
460
460
  this._rpc ??= createServerRpc(this.connection);
461
461
  return this._rpc;
462
- })
463
- };
462
+ });
463
+ }
464
+ if (this.onGitHubTelemetry) {
465
+ const onGitHubTelemetry = this.onGitHubTelemetry;
466
+ handlers.gitHubTelemetry = {
467
+ event: async (notification) => {
468
+ try {
469
+ await onGitHubTelemetry(notification);
470
+ } catch {
471
+ }
472
+ }
473
+ };
474
+ }
475
+ this.clientGlobalHandlers = handlers;
464
476
  }
465
477
  /**
466
478
  * Starts the CLI server and establishes a connection.
@@ -1004,6 +1016,7 @@ class CopilotClient {
1004
1016
  workingDirectory: config.workingDirectory,
1005
1017
  streaming: config.streaming,
1006
1018
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
1019
+ ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
1007
1020
  mcpServers: toWireMcpServers(config.mcpServers),
1008
1021
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
1009
1022
  envValueMode: "direct",
@@ -1201,6 +1214,7 @@ class CopilotClient {
1201
1214
  enableSkills: config.enableSkills,
1202
1215
  streaming: config.streaming,
1203
1216
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
1217
+ ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
1204
1218
  mcpServers: toWireMcpServers(config.mcpServers),
1205
1219
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
1206
1220
  envValueMode: "direct",
@@ -1866,7 +1880,7 @@ stderr: ${stderrOutput}`
1866
1880
  if (!session) throw new Error(`No session found for sessionId: ${sessionId}`);
1867
1881
  return session.clientSessionApis;
1868
1882
  });
1869
- registerClientGlobalApiHandlers(this.connection, this.llmInferenceHandlers);
1883
+ registerClientGlobalApiHandlers(this.connection, this.clientGlobalHandlers);
1870
1884
  this.connection.onClose(() => {
1871
1885
  this.state = "disconnected";
1872
1886
  });
@@ -756,6 +756,59 @@ export type McpSetEnvValueModeDetails =
756
756
  "direct"
757
757
  /** Treat MCP server environment values as host-side references to resolve before launch. */
758
758
  | "indirect";
759
+ /**
760
+ * Per-source context-window attribution, or null if the session has not yet been initialized (no system prompt or tool metadata cached).
761
+ *
762
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
763
+ * via the `definition` "SessionContextAttribution".
764
+ */
765
+ /** @experimental */
766
+ export type SessionContextAttribution = {
767
+ /**
768
+ * Total token count of the current context window the entries are measured against (system message + conversation messages + tool definitions — the same total reported by /context). Divide an entry's `tokens` by this to derive its share.
769
+ */
770
+ totalTokens: number;
771
+ /**
772
+ * Flat list of per-source attribution entries. Group by `kind` and render unrecognized kinds generically. Nesting and rollups are expressed via `parentId`.
773
+ */
774
+ entries: {
775
+ /**
776
+ * Source category for this entry. Not a closed set — tolerate unknown values. Known values today: `skill`, `subagent`, `mcpServer`, `tool`, `system`, `toolDefinition`, `plugin`.
777
+ */
778
+ kind: string;
779
+ /**
780
+ * Identifier for this entry, formed by joining its `kind` and source name (e.g. `tool:bash`, `skill:tmux`, `toolDefinition:bash`); unique within the snapshot. Use it to match the same entry across snapshots, to correlate with other APIs (skill/agent/MCP registries), and as the `parentId` target for nesting. Distinct from the human-facing `label`.
781
+ */
782
+ id: string;
783
+ /**
784
+ * Human-readable display label, e.g. `bash` or `skill: tmux`. Presentation-only; may be localized/reformatted without notice — do not key off it.
785
+ */
786
+ label: string;
787
+ /**
788
+ * Token count currently in context attributable to this entry.
789
+ */
790
+ tokens: number;
791
+ /**
792
+ * Optional `id` of the parent entry: e.g. a `plugin` entry parenting its `skill`/`mcpServer` entries, or the `system` entry parenting `toolDefinition` entries. Omitted for top-level entries.
793
+ */
794
+ parentId?: string;
795
+ /**
796
+ * Supplementary per-entry metadata (e.g. `messageCount`, `role`, `evictable`, `pluginSource`). Values are stringified; parse as needed and ignore unrecognized keys.
797
+ */
798
+ attributes?: {
799
+ [k: string]: string | undefined;
800
+ };
801
+ }[];
802
+ /**
803
+ * Successful compaction history for the session.
804
+ */
805
+ compactions: {
806
+ /**
807
+ * Number of successful compactions in this session.
808
+ */
809
+ count: number;
810
+ };
811
+ } | null;
759
812
  /**
760
813
  * Token breakdown for the current context window, or null if the session has not yet been initialized (no system prompt or tool metadata cached).
761
814
  *
@@ -3148,6 +3201,10 @@ export interface SlashCommandInput {
3148
3201
  * Hint to display when command input has not been provided
3149
3202
  */
3150
3203
  hint: string;
3204
+ /**
3205
+ * Optional literal choices the input accepts, each with a human-facing description; clients may render these as selectable options
3206
+ */
3207
+ choices?: SlashCommandInputChoice[];
3151
3208
  /**
3152
3209
  * When true, the command requires non-empty input; clients should render the input hint as required
3153
3210
  */
@@ -3158,6 +3215,23 @@ export interface SlashCommandInput {
3158
3215
  */
3159
3216
  preserveMultilineInput?: boolean;
3160
3217
  }
3218
+ /**
3219
+ * A literal choice the command input accepts, with a human-facing description
3220
+ *
3221
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
3222
+ * via the `definition` "SlashCommandInputChoice".
3223
+ */
3224
+ /** @experimental */
3225
+ export interface SlashCommandInputChoice {
3226
+ /**
3227
+ * The literal choice value (e.g. 'on', 'off', 'show')
3228
+ */
3229
+ name: string;
3230
+ /**
3231
+ * Human-readable description shown alongside the choice
3232
+ */
3233
+ description: string;
3234
+ }
3161
3235
  /**
3162
3236
  * Pending command request ID and an optional error if the client handler failed.
3163
3237
  *
@@ -3436,6 +3510,31 @@ export interface ConnectRemoteSessionParams {
3436
3510
  */
3437
3511
  sessionId: string;
3438
3512
  }
3513
+ /**
3514
+ * A single large message currently in context.
3515
+ *
3516
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
3517
+ * via the `definition` "ContextHeaviestMessage".
3518
+ */
3519
+ /** @experimental */
3520
+ export interface ContextHeaviestMessage {
3521
+ /**
3522
+ * Stable identifier for this message within the snapshot.
3523
+ */
3524
+ id: string;
3525
+ /**
3526
+ * Human-readable source label, e.g. `tool: bash` or `skill: tmux`. Presentation-only.
3527
+ */
3528
+ label: string;
3529
+ /**
3530
+ * Role of the chat message (`user`, `assistant`, or `tool`).
3531
+ */
3532
+ role: string;
3533
+ /**
3534
+ * Token count currently in context for this individual message.
3535
+ */
3536
+ tokens: number;
3537
+ }
3439
3538
  /**
3440
3539
  * 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.
3441
3540
  *
@@ -3770,6 +3869,10 @@ export interface ExternalToolTextResultForLlm {
3770
3869
  * Structured content blocks from the tool
3771
3870
  */
3772
3871
  contents?: ExternalToolTextResultForLlmContent[];
3872
+ /**
3873
+ * Tool references returned by a tool-search override: names of deferred tools to surface to the model. When set, the tool result is materialized as `tool_reference` content blocks (rather than plain text) so the model knows which deferred tools are now available.
3874
+ */
3875
+ toolReferences?: string[];
3773
3876
  }
3774
3877
  /**
3775
3878
  * Binary result returned by a tool for the model
@@ -6050,6 +6153,49 @@ export interface MemoryConfiguration {
6050
6153
  */
6051
6154
  enabled: boolean;
6052
6155
  }
6156
+ /**
6157
+ * Per-source attribution breakdown for the session's current context window, or null if uninitialized.
6158
+ *
6159
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
6160
+ * via the `definition` "MetadataContextAttributionResult".
6161
+ */
6162
+ /** @experimental */
6163
+ export interface MetadataContextAttributionResult {
6164
+ /**
6165
+ * Per-source context-window attribution, or null if the session has not yet been initialized (no system prompt or tool metadata cached).
6166
+ */
6167
+ contextAttribution?: SessionContextAttribution | null;
6168
+ }
6169
+ /**
6170
+ * Parameters for the heaviest-messages query.
6171
+ *
6172
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
6173
+ * via the `definition` "MetadataContextHeaviestMessagesRequest".
6174
+ */
6175
+ /** @experimental */
6176
+ export interface MetadataContextHeaviestMessagesRequest {
6177
+ /**
6178
+ * Maximum number of messages to return, most-expensive first. Omit for the server default.
6179
+ */
6180
+ limit?: number;
6181
+ }
6182
+ /**
6183
+ * The heaviest individual messages in the session's context window, most-expensive first.
6184
+ *
6185
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
6186
+ * via the `definition` "MetadataContextHeaviestMessagesResult".
6187
+ */
6188
+ /** @experimental */
6189
+ export interface MetadataContextHeaviestMessagesResult {
6190
+ /**
6191
+ * Total token count of the current context window, so callers can compute each message's share without a second call.
6192
+ */
6193
+ totalTokens: number;
6194
+ /**
6195
+ * Heaviest messages, most-expensive first.
6196
+ */
6197
+ messages: ContextHeaviestMessage[];
6198
+ }
6053
6199
  /**
6054
6200
  * Model identifier and token limits used to compute the context-info breakdown.
6055
6201
  *
@@ -8523,36 +8669,6 @@ export interface PluginUpdateResult {
8523
8669
  */
8524
8670
  skillsInstalled: number;
8525
8671
  }
8526
- /**
8527
- * Batch of spawn events plus a cursor for follow-up polls.
8528
- *
8529
- * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
8530
- * via the `definition` "PollSpawnedSessionsResult".
8531
- */
8532
- /** @experimental */
8533
- export interface PollSpawnedSessionsResult {
8534
- /**
8535
- * Spawn events emitted since the supplied cursor.
8536
- */
8537
- events: SessionsPollSpawnedSessionsEvent[];
8538
- /**
8539
- * Opaque cursor to pass back to receive only events after this batch.
8540
- */
8541
- cursor: string;
8542
- }
8543
- /**
8544
- * Schema for the `SessionsPollSpawnedSessionsEvent` type.
8545
- *
8546
- * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
8547
- * via the `definition` "SessionsPollSpawnedSessionsEvent".
8548
- */
8549
- /** @experimental */
8550
- export interface SessionsPollSpawnedSessionsEvent {
8551
- /**
8552
- * Session id of the newly-spawned session.
8553
- */
8554
- sessionId: string;
8555
- }
8556
8672
  /**
8557
8673
  * BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
8558
8674
  *
@@ -11558,17 +11674,6 @@ export interface SessionsLoadDeferredRepoHooksRequest {
11558
11674
  */
11559
11675
  sessionId: string;
11560
11676
  }
11561
- /** @experimental */
11562
- export interface SessionsPollSpawnedSessionsRequest {
11563
- /**
11564
- * Opaque cursor returned by a previous poll. Omit on the first call to receive any spawn events buffered since the runtime started.
11565
- */
11566
- cursor?: string;
11567
- /**
11568
- * Milliseconds to wait for new spawn events when the cursor is at the tail. 0 (default) returns immediately even if no events are buffered. Capped at 60000ms.
11569
- */
11570
- waitMs?: number;
11571
- }
11572
11677
  /**
11573
11678
  * Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
11574
11679
  *
@@ -15778,6 +15883,20 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
15778
15883
  * @returns Token breakdown for the session's current context window, or null if uninitialized.
15779
15884
  */
15780
15885
  contextInfo: (params: MetadataContextInfoRequest) => Promise<MetadataContextInfoResult>;
15886
+ /**
15887
+ * Returns the experimental per-source attribution breakdown of the session's current context window as a flat list of entries (skills, subagents, MCP servers, built-in tools, plugin rollups, system/tool-definition costs, with nesting via parentId), plus the successful compaction count. The heaviest individual messages are available separately via `metadata.getContextHeaviestMessages`. Returns null until the session has initialized its system prompt and tool metadata.
15888
+ *
15889
+ * @returns Per-source attribution breakdown for the session's current context window, or null if uninitialized.
15890
+ */
15891
+ getContextAttribution: () => Promise<MetadataContextAttributionResult>;
15892
+ /**
15893
+ * Returns the largest individual messages currently in the session's context window, most-expensive first. Companion to `metadata.getContextAttribution`. Returns an empty list until the session has initialized.
15894
+ *
15895
+ * @param params Parameters for the heaviest-messages query.
15896
+ *
15897
+ * @returns The heaviest individual messages in the session's context window, most-expensive first.
15898
+ */
15899
+ getContextHeaviestMessages: (params: MetadataContextHeaviestMessagesRequest) => Promise<MetadataContextHeaviestMessagesResult>;
15781
15900
  /**
15782
15901
  * Records a working-directory/git context change and emits a `session.context_changed` event.
15783
15902
  *
@@ -593,14 +593,6 @@ function createInternalServerRpc(connection) {
593
593
  * @returns Dynamic-context board entry count, when available.
594
594
  */
595
595
  getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
596
- /**
597
- * Cursor-based long-poll for sessions spawned by the runtime (e.g. in response to a Mission Control `start_session` command). The cursor is an opaque token; pass it back to receive only spawn events that occurred AFTER the cursor was issued. Omit the cursor on the first call to receive any events buffered since the runtime started. Internal: this is a CLI background-daemon plumbing primitive. SDK consumers that need to react to runtime-spawned sessions should subscribe to a higher-level event stream rather than driving a long-poll loop.
598
- *
599
- * @param params Cursor and optional long-poll wait for polling runtime-spawned sessions.
600
- *
601
- * @returns Batch of spawn events plus a cursor for follow-up polls.
602
- */
603
- pollSpawnedSessions: async (params) => connection.sendRequest("sessions.pollSpawnedSessions", params),
604
596
  /**
605
597
  * Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
606
598
  *
@@ -1690,6 +1682,20 @@ function createSessionRpc(connection, sessionId) {
1690
1682
  * @returns Token breakdown for the session's current context window, or null if uninitialized.
1691
1683
  */
1692
1684
  contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { sessionId, ...params }),
1685
+ /**
1686
+ * Returns the experimental per-source attribution breakdown of the session's current context window as a flat list of entries (skills, subagents, MCP servers, built-in tools, plugin rollups, system/tool-definition costs, with nesting via parentId), plus the successful compaction count. The heaviest individual messages are available separately via `metadata.getContextHeaviestMessages`. Returns null until the session has initialized its system prompt and tool metadata.
1687
+ *
1688
+ * @returns Per-source attribution breakdown for the session's current context window, or null if uninitialized.
1689
+ */
1690
+ getContextAttribution: async () => connection.sendRequest("session.metadata.getContextAttribution", { sessionId }),
1691
+ /**
1692
+ * Returns the largest individual messages currently in the session's context window, most-expensive first. Companion to `metadata.getContextAttribution`. Returns an empty list until the session has initialized.
1693
+ *
1694
+ * @param params Parameters for the heaviest-messages query.
1695
+ *
1696
+ * @returns The heaviest individual messages in the session's context window, most-expensive first.
1697
+ */
1698
+ getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { sessionId, ...params }),
1693
1699
  /**
1694
1700
  * Records a working-directory/git context change and emits a `session.context_changed` event.
1695
1701
  *
@@ -2058,10 +2064,10 @@ function registerClientGlobalApiHandlers(connection, handlers) {
2058
2064
  if (!handler) throw new Error("No llmInference client-global handler registered");
2059
2065
  return handler.httpRequestChunk(params);
2060
2066
  });
2061
- connection.onRequest("gitHubTelemetry.event", async (params) => {
2067
+ connection.onNotification("gitHubTelemetry.event", async (params) => {
2062
2068
  const handler = handlers.gitHubTelemetry;
2063
- if (!handler) throw new Error("No gitHubTelemetry client-global handler registered");
2064
- return handler.event(params);
2069
+ if (!handler) return;
2070
+ await handler.event(params);
2065
2071
  });
2066
2072
  }
2067
2073
  export {
package/dist/index.d.ts CHANGED
@@ -10,4 +10,4 @@ export { CopilotSession, type AssistantMessageEvent } from "./session.js";
10
10
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
11
11
  export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
12
12
  export type * from "./generated/session-events.js";
13
- export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, CopilotClientMode, CopilotClientOptions, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolTelemetry, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
13
+ export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, CopilotClientMode, CopilotClientOptions, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolTelemetry, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
package/dist/types.d.ts CHANGED
@@ -6,9 +6,10 @@ import type { SessionFsProvider } from "./sessionFsProvider.js";
6
6
  import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
7
7
  import type { ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
8
8
  import type { CopilotSession } from "./session.js";
9
- import type { ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode } from "./generated/rpc.js";
9
+ import type { GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode } from "./generated/rpc.js";
10
10
  import type { ToolSet } from "./toolSet.js";
11
11
  export type { RemoteSessionMode } from "./generated/rpc.js";
12
+ export type { GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, } from "./generated/rpc.js";
12
13
  export type { ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, } from "./generated/rpc.js";
13
14
  export type SessionEvent = GeneratedSessionEvent;
14
15
  export type { ReasoningSummary } from "./generated/session-events.js";
@@ -270,6 +271,17 @@ export interface CopilotClientOptions {
270
271
  * @experimental
271
272
  */
272
273
  requestHandler?: CopilotRequestHandler;
274
+ /**
275
+ * Experimental. Receives GitHub telemetry events the runtime forwards to
276
+ * this connection. When set, the client opts each session it creates or
277
+ * resumes into telemetry forwarding and dispatches each
278
+ * `gitHubTelemetry.event` notification to this connection-global handler;
279
+ * each {@link GitHubTelemetryNotification} carries its originating
280
+ * `sessionId`.
281
+ *
282
+ * @experimental
283
+ */
284
+ onGitHubTelemetry?: (notification: GitHubTelemetryNotification) => void | Promise<void>;
273
285
  /**
274
286
  * Server-wide idle timeout for sessions in seconds.
275
287
  * Sessions without activity for this duration are automatically cleaned up.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.5",
7
+ "version": "1.0.6-preview.1",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.67",
59
+ "@github/copilot": "^1.0.69-0",
60
60
  "vscode-jsonrpc": "^8.2.1",
61
61
  "zod": "^4.3.6"
62
62
  },