@github/copilot-sdk 1.0.0-beta.5 → 1.0.0-beta.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.
@@ -1027,11 +1027,11 @@ export interface AccountQuotaSnapshot {
1027
1027
  */
1028
1028
  remainingPercentage: number;
1029
1029
  /**
1030
- * Number of overage requests made this period
1030
+ * Number of additional usage requests made this period
1031
1031
  */
1032
1032
  overage: number;
1033
1033
  /**
1034
- * Whether overage is allowed when quota is exhausted
1034
+ * Whether additional usage is allowed when quota is exhausted
1035
1035
  */
1036
1036
  overageAllowedWithExhaustedQuota: boolean;
1037
1037
  /**
@@ -1097,7 +1097,9 @@ export interface AgentInfo {
1097
1097
  * MCP server configurations attached to this agent, keyed by server name. Server config shape mirrors the MCP `mcpServers` schema.
1098
1098
  */
1099
1099
  mcpServers?: {
1100
- [k: string]: unknown | undefined;
1100
+ [k: string]: {
1101
+ [k: string]: unknown | undefined;
1102
+ } | undefined;
1101
1103
  };
1102
1104
  /**
1103
1105
  * Skill names preloaded into this agent's context. Omitted means none.
@@ -1738,40 +1740,6 @@ export interface ConnectRemoteSessionParams {
1738
1740
  */
1739
1741
  sessionId: string;
1740
1742
  }
1741
- /**
1742
- * Optional connection token presented by the SDK client during the handshake.
1743
- *
1744
- * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
1745
- * via the `definition` "ConnectRequest".
1746
- */
1747
- /** @internal */
1748
- export interface ConnectRequest {
1749
- /**
1750
- * Connection token; required when the server was started with COPILOT_CONNECTION_TOKEN
1751
- */
1752
- token?: string;
1753
- }
1754
- /**
1755
- * Handshake result reporting the server's protocol version and package version on success.
1756
- *
1757
- * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
1758
- * via the `definition` "ConnectResult".
1759
- */
1760
- /** @internal */
1761
- export interface ConnectResult {
1762
- /**
1763
- * Always true on success
1764
- */
1765
- ok: true;
1766
- /**
1767
- * Server protocol version number
1768
- */
1769
- protocolVersion: number;
1770
- /**
1771
- * Server package version
1772
- */
1773
- version: string;
1774
- }
1775
1743
  /**
1776
1744
  * The currently selected model and reasoning effort for the session.
1777
1745
  *
@@ -2024,7 +1992,9 @@ export interface ExternalToolTextResultForLlm {
2024
1992
  * Optional tool-specific telemetry
2025
1993
  */
2026
1994
  toolTelemetry?: {
2027
- [k: string]: unknown | undefined;
1995
+ [k: string]: {
1996
+ [k: string]: unknown | undefined;
1997
+ } | undefined;
2028
1998
  };
2029
1999
  /**
2030
2000
  * Base64-encoded binary results returned to the model
@@ -2374,6 +2344,19 @@ export interface HistoryCompactContextWindow {
2374
2344
  */
2375
2345
  toolDefinitionsTokens?: number;
2376
2346
  }
2347
+ /**
2348
+ * Optional compaction parameters.
2349
+ *
2350
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
2351
+ * via the `definition` "HistoryCompactRequest".
2352
+ */
2353
+ /** @experimental */
2354
+ export interface HistoryCompactRequest {
2355
+ /**
2356
+ * Optional user-provided instructions to focus the compaction summary
2357
+ */
2358
+ customInstructions?: string;
2359
+ }
2377
2360
  /**
2378
2361
  * Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
2379
2362
  *
@@ -5200,6 +5183,30 @@ export interface ScheduleStopRequest {
5200
5183
  export interface ScheduleStopResult {
5201
5184
  entry?: ScheduleEntry;
5202
5185
  }
5186
+ /**
5187
+ * Secret values to add to the redaction filter.
5188
+ *
5189
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
5190
+ * via the `definition` "SecretsAddFilterValuesRequest".
5191
+ */
5192
+ export interface SecretsAddFilterValuesRequest {
5193
+ /**
5194
+ * Raw secret values to register for redaction
5195
+ */
5196
+ values: string[];
5197
+ }
5198
+ /**
5199
+ * Confirmation that the secret values were registered.
5200
+ *
5201
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
5202
+ * via the `definition` "SecretsAddFilterValuesResult".
5203
+ */
5204
+ export interface SecretsAddFilterValuesResult {
5205
+ /**
5206
+ * Whether the values were successfully registered
5207
+ */
5208
+ ok: true;
5209
+ }
5203
5210
  /**
5204
5211
  * File attachment
5205
5212
  *
@@ -5946,7 +5953,9 @@ export interface SessionFsSqliteQueryResult {
5946
5953
  * For SELECT: array of row objects. For others: empty array.
5947
5954
  */
5948
5955
  rows: {
5949
- [k: string]: unknown | undefined;
5956
+ [k: string]: {
5957
+ [k: string]: unknown | undefined;
5958
+ } | undefined;
5950
5959
  }[];
5951
5960
  /**
5952
5961
  * Column names from the result set
@@ -6821,7 +6830,9 @@ export interface SessionUpdateOptionsParams {
6821
6830
  /**
6822
6831
  * Additional content-exclusion policies to merge into the session's policy set. Opaque shape; see `ContentExclusionApiResponse` in the runtime.
6823
6832
  */
6824
- additionalContentExclusionPolicies?: unknown[];
6833
+ additionalContentExclusionPolicies?: {
6834
+ [k: string]: unknown | undefined;
6835
+ }[];
6825
6836
  /**
6826
6837
  * Whether to expose the `manage_schedule` tool to the agent. The runtime always owns the per-session schedule registry; this flag only controls tool exposure (typically gated to staff users).
6827
6838
  */
@@ -7656,7 +7667,9 @@ export interface Tool {
7656
7667
  * JSON Schema for the tool's input parameters
7657
7668
  */
7658
7669
  parameters?: {
7659
- [k: string]: unknown | undefined;
7670
+ [k: string]: {
7671
+ [k: string]: unknown | undefined;
7672
+ } | undefined;
7660
7673
  };
7661
7674
  /**
7662
7675
  * Optional instructions for how to use this tool effectively
@@ -8634,6 +8647,16 @@ export declare function createServerRpc(connection: MessageConnection): {
8634
8647
  */
8635
8648
  getQuota: (params: AccountGetQuotaRequest) => Promise<AccountGetQuotaResult>;
8636
8649
  };
8650
+ secrets: {
8651
+ /**
8652
+ * Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
8653
+ *
8654
+ * @param params Secret values to add to the redaction filter.
8655
+ *
8656
+ * @returns Confirmation that the secret values were registered.
8657
+ */
8658
+ addFilterValues: (params: SecretsAddFilterValuesRequest) => Promise<SecretsAddFilterValuesResult>;
8659
+ };
8637
8660
  mcp: {
8638
8661
  config: {
8639
8662
  /**
@@ -8864,21 +8887,6 @@ export declare function createServerRpc(connection: MessageConnection): {
8864
8887
  setAdditionalPlugins: (params: SessionsSetAdditionalPluginsRequest) => Promise<SessionsSetAdditionalPluginsResult>;
8865
8888
  };
8866
8889
  };
8867
- /**
8868
- * Create typed server-scoped RPC methods that are part of the SDK's internal
8869
- * surface (e.g. handshake helpers). Not exported on the public client API.
8870
- * @internal
8871
- */
8872
- export declare function createInternalServerRpc(connection: MessageConnection): {
8873
- /**
8874
- * Performs the SDK server connection handshake and validates the optional connection token.
8875
- *
8876
- * @param params Optional connection token presented by the SDK client during the handshake.
8877
- *
8878
- * @returns Handshake result reporting the server's protocol version and package version on success.
8879
- */
8880
- connect: (params: ConnectRequest) => Promise<ConnectResult>;
8881
- };
8882
8890
  /** Create typed session-scoped RPC methods. */
8883
8891
  export declare function createSessionRpc(connection: MessageConnection, sessionId: string): {
8884
8892
  /**
@@ -9740,9 +9748,11 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
9740
9748
  /**
9741
9749
  * Compacts the session history to reduce context usage.
9742
9750
  *
9751
+ * @param params Optional compaction parameters.
9752
+ *
9743
9753
  * @returns Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
9744
9754
  */
9745
- compact: () => Promise<HistoryCompactResult>;
9755
+ compact: (params?: HistoryCompactRequest) => Promise<HistoryCompactResult>;
9746
9756
  /**
9747
9757
  * Truncates persisted session history to a specific event.
9748
9758
  *
@@ -38,6 +38,16 @@ function createServerRpc(connection) {
38
38
  */
39
39
  getQuota: async (params) => connection.sendRequest("account.getQuota", params)
40
40
  },
41
+ secrets: {
42
+ /**
43
+ * Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
44
+ *
45
+ * @param params Secret values to add to the redaction filter.
46
+ *
47
+ * @returns Confirmation that the secret values were registered.
48
+ */
49
+ addFilterValues: async (params) => connection.sendRequest("secrets.addFilterValues", params)
50
+ },
41
51
  mcp: {
42
52
  config: {
43
53
  /**
@@ -1142,9 +1152,11 @@ function createSessionRpc(connection, sessionId) {
1142
1152
  /**
1143
1153
  * Compacts the session history to reduce context usage.
1144
1154
  *
1155
+ * @param params Optional compaction parameters.
1156
+ *
1145
1157
  * @returns Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
1146
1158
  */
1147
- compact: async () => connection.sendRequest("session.history.compact", { sessionId }),
1159
+ compact: async (params) => connection.sendRequest("session.history.compact", { sessionId, ...params }),
1148
1160
  /**
1149
1161
  * Truncates persisted session history to a specific event.
1150
1162
  *
@@ -1325,7 +1325,7 @@ export interface ShutdownData {
1325
1325
  /**
1326
1326
  * Total number of premium API requests used during the session
1327
1327
  */
1328
- totalPremiumRequests: number;
1328
+ totalPremiumRequests?: number;
1329
1329
  }
1330
1330
  /**
1331
1331
  * Aggregate code change metrics for the session
@@ -1368,11 +1368,11 @@ export interface ShutdownModelMetricRequests {
1368
1368
  /**
1369
1369
  * Cumulative cost multiplier for requests to this model
1370
1370
  */
1371
- cost: number;
1371
+ cost?: number;
1372
1372
  /**
1373
1373
  * Total number of API requests made to this model
1374
1374
  */
1375
- count: number;
1375
+ count?: number;
1376
1376
  }
1377
1377
  /**
1378
1378
  * Schema for the `ShutdownModelMetricTokenDetail` type.
@@ -1604,6 +1604,10 @@ export interface CompactionCompleteData {
1604
1604
  * Token count from non-system messages (user, assistant, tool) after compaction
1605
1605
  */
1606
1606
  conversationTokens?: number;
1607
+ /**
1608
+ * User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
1609
+ */
1610
+ customInstructions?: string;
1607
1611
  /**
1608
1612
  * Error message if compaction failed
1609
1613
  */
@@ -2257,7 +2261,9 @@ export interface AssistantMessageData {
2257
2261
  /**
2258
2262
  * Raw Anthropic content array with advisor blocks (server_tool_use, advisor_tool_result) for verbatim round-tripping
2259
2263
  */
2260
- anthropicAdvisorBlocks?: unknown[];
2264
+ anthropicAdvisorBlocks?: {
2265
+ [k: string]: unknown | undefined;
2266
+ }[];
2261
2267
  /**
2262
2268
  * Anthropic advisor model ID used for this response, for timeline display on replay
2263
2269
  */
@@ -2633,11 +2639,11 @@ export interface AssistantUsageQuotaSnapshot {
2633
2639
  */
2634
2640
  isUnlimitedEntitlement: boolean;
2635
2641
  /**
2636
- * Number of requests over the entitlement limit
2642
+ * Number of additional usage requests made this period
2637
2643
  */
2638
2644
  overage: number;
2639
2645
  /**
2640
- * Whether overage is allowed when quota is exhausted
2646
+ * Whether additional usage is allowed when quota is exhausted
2641
2647
  */
2642
2648
  overageAllowedWithExhaustedQuota: boolean;
2643
2649
  /**
@@ -3011,6 +3017,10 @@ export interface ToolExecutionCompleteData {
3011
3017
  */
3012
3018
  parentToolCallId?: string;
3013
3019
  result?: ToolExecutionCompleteResult;
3020
+ /**
3021
+ * Whether this tool execution ran inside a sandbox container
3022
+ */
3023
+ sandboxed?: boolean;
3014
3024
  /**
3015
3025
  * Whether the tool execution completed successfully
3016
3026
  */
@@ -3023,7 +3033,9 @@ export interface ToolExecutionCompleteData {
3023
3033
  * Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
3024
3034
  */
3025
3035
  toolTelemetry?: {
3026
- [k: string]: unknown | undefined;
3036
+ [k: string]: {
3037
+ [k: string]: unknown | undefined;
3038
+ } | undefined;
3027
3039
  };
3028
3040
  /**
3029
3041
  * Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
@@ -3730,7 +3742,9 @@ export interface SystemMessageMetadata {
3730
3742
  * Template variables used when constructing the prompt
3731
3743
  */
3732
3744
  variables?: {
3733
- [k: string]: unknown | undefined;
3745
+ [k: string]: {
3746
+ [k: string]: unknown | undefined;
3747
+ } | undefined;
3734
3748
  };
3735
3749
  }
3736
3750
  /**
@@ -4976,7 +4990,9 @@ export interface ElicitationRequestedSchema {
4976
4990
  * Form field definitions, keyed by field name
4977
4991
  */
4978
4992
  properties: {
4979
- [k: string]: unknown | undefined;
4993
+ [k: string]: {
4994
+ [k: string]: unknown | undefined;
4995
+ } | undefined;
4980
4996
  };
4981
4997
  /**
4982
4998
  * List of required field names
package/dist/index.d.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  * JSON-RPC based SDK for programmatic control of GitHub Copilot CLI
5
5
  */
6
6
  export { CopilotClient } from "./client.js";
7
+ export { RuntimeConnection } from "./types.js";
7
8
  export { CopilotSession, type AssistantMessageEvent } from "./session.js";
8
9
  export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_PROMPT_SECTIONS, } from "./types.js";
9
10
  export type * from "./generated/session-events.js";
10
- export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, ConnectionState, CopilotClientOptions, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, InputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
11
+ export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, ConnectionState, CopilotClientOptions, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, 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, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolTelemetry, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CopilotClient } from "./client.js";
2
+ import { RuntimeConnection } from "./types.js";
2
3
  import { CopilotSession } from "./session.js";
3
4
  import {
4
5
  defineTool,
@@ -10,6 +11,7 @@ import {
10
11
  export {
11
12
  CopilotClient,
12
13
  CopilotSession,
14
+ RuntimeConnection,
13
15
  SYSTEM_PROMPT_SECTIONS,
14
16
  approveAll,
15
17
  convertMcpCallToolResult,
package/dist/session.d.ts CHANGED
@@ -1,12 +1,5 @@
1
- /**
2
- * Copilot Session - represents a single conversation session with the Copilot CLI.
3
- * @module session
4
- */
5
- import type { MessageConnection } from "vscode-jsonrpc/node.js";
6
1
  import { createSessionRpc } from "./generated/rpc.js";
7
- import type { ClientSessionApiHandlers } from "./generated/rpc.js";
8
- import type { CommandHandler, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, ElicitationHandler, ElicitationContext, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, MessageOptions, PermissionHandler, PermissionRequestResult, ReasoningEffort, ModelCapabilitiesOverride, SectionTransformFn, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionHooks, SessionUiApi, Tool, ToolHandler, TraceContextProvider, TypedSessionEventHandler, UserInputHandler, UserInputResponse } from "./types.js";
9
- export declare const NO_RESULT_PERMISSION_V2_ERROR = "Permission handlers cannot return 'no-result' when connected to a protocol v2 server.";
2
+ import type { MessageOptions, ReasoningEffort, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
10
3
  /** Assistant message event - the final response from the assistant. */
11
4
  export type AssistantMessageEvent = Extract<SessionEvent, {
12
5
  type: "assistant.message";
@@ -54,18 +47,6 @@ export declare class CopilotSession {
54
47
  private _rpc;
55
48
  private traceContextProvider?;
56
49
  private _capabilities;
57
- /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
58
- clientSessionApis: ClientSessionApiHandlers;
59
- /**
60
- * Creates a new CopilotSession instance.
61
- *
62
- * @param sessionId - The unique identifier for this session
63
- * @param connection - The JSON-RPC message connection to the Copilot CLI
64
- * @param workspacePath - Path to the session workspace directory (when infinite sessions enabled)
65
- * @param traceContextProvider - Optional callback to get W3C Trace Context for outbound RPCs
66
- * @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
67
- */
68
- constructor(sessionId: string, connection: MessageConnection, _workspacePath?: string | undefined, traceContextProvider?: TraceContextProvider);
69
50
  /**
70
51
  * Typed session-scoped RPC methods.
71
52
  */
@@ -112,6 +93,7 @@ export declare class CopilotSession {
112
93
  * });
113
94
  * ```
114
95
  */
96
+ send(prompt: string): Promise<string>;
115
97
  send(options: MessageOptions): Promise<string>;
116
98
  /**
117
99
  * Sends a message to this session and waits until the session becomes idle.
@@ -136,6 +118,7 @@ export declare class CopilotSession {
136
118
  * console.log(response?.data.content); // "4"
137
119
  * ```
138
120
  */
121
+ sendAndWait(prompt: string, timeout?: number): Promise<AssistantMessageEvent | undefined>;
139
122
  sendAndWait(options: MessageOptions, timeout?: number): Promise<AssistantMessageEvent | undefined>;
140
123
  /**
141
124
  * Subscribes to events from this session.
@@ -183,191 +166,11 @@ export declare class CopilotSession {
183
166
  * ```
184
167
  */
185
168
  on(handler: SessionEventHandler): () => void;
186
- /**
187
- * Dispatches an event to all registered handlers.
188
- * Also handles broadcast request events internally (external tool calls, permissions).
189
- *
190
- * @param event - The session event to dispatch
191
- * @internal This method is for internal use by the SDK.
192
- */
193
- _dispatchEvent(event: SessionEvent): void;
194
- /**
195
- * Handles broadcast request events by executing local handlers and responding via RPC.
196
- * Handlers are dispatched as fire-and-forget — rejections propagate as unhandled promise
197
- * rejections, consistent with standard EventEmitter / event handler semantics.
198
- * @internal
199
- */
200
- private _handleBroadcastEvent;
201
- /**
202
- * Executes a tool handler and sends the result back via RPC.
203
- * @internal
204
- */
205
- private _executeToolAndRespond;
206
- /**
207
- * Executes a permission handler and sends the result back via RPC.
208
- * @internal
209
- */
210
- private _executePermissionAndRespond;
211
- /**
212
- * Executes a command handler and sends the result back via RPC.
213
- * @internal
214
- */
215
- private _executeCommandAndRespond;
216
- /**
217
- * Registers custom tool handlers for this session.
218
- *
219
- * Tools with handlers allow the assistant to execute custom functions automatically.
220
- * Declaration-only tools are surfaced as events and left pending for the consumer.
221
- *
222
- * @param tools - An array of tool definitions with their handlers, or undefined to clear all tools
223
- * @internal This method is typically called internally when creating a session with tools.
224
- */
225
- registerTools(tools?: Tool[]): void;
226
- /**
227
- * Retrieves a registered tool handler by name.
228
- *
229
- * @param name - The name of the tool to retrieve
230
- * @returns The tool handler if found, or undefined
231
- * @internal This method is for internal use by the SDK.
232
- */
233
- getToolHandler(name: string): ToolHandler | undefined;
234
- /**
235
- * Registers command handlers for this session.
236
- *
237
- * @param commands - An array of command definitions with handlers, or undefined to clear
238
- * @internal This method is typically called internally when creating/resuming a session.
239
- */
240
- registerCommands(commands?: {
241
- name: string;
242
- handler: CommandHandler;
243
- }[]): void;
244
- /**
245
- * Registers the elicitation handler for this session.
246
- *
247
- * @param handler - The handler to invoke when the server dispatches an elicitation request
248
- * @internal This method is typically called internally when creating/resuming a session.
249
- */
250
- registerElicitationHandler(handler?: ElicitationHandler): void;
251
- /**
252
- * Registers the exit-plan-mode handler for this session.
253
- *
254
- * @param handler - The handler to invoke when the server dispatches an exit-plan-mode request
255
- * @internal This method is typically called internally when creating/resuming a session.
256
- */
257
- registerExitPlanModeHandler(handler?: ExitPlanModeHandler): void;
258
- /**
259
- * Registers the auto-mode-switch handler for this session.
260
- *
261
- * @param handler - The handler to invoke when the server dispatches an auto-mode-switch request
262
- * @internal This method is typically called internally when creating/resuming a session.
263
- */
264
- registerAutoModeSwitchHandler(handler?: AutoModeSwitchHandler): void;
265
- /**
266
- * Handles an elicitation.requested broadcast event.
267
- * Invokes the registered handler and responds via handlePendingElicitation RPC.
268
- * @internal
269
- */
270
- _handleElicitationRequest(context: ElicitationContext, requestId: string): Promise<void>;
271
- /**
272
- * Handles an exitPlanMode.request callback from the runtime.
273
- * @internal
274
- */
275
- _handleExitPlanModeRequest(request: ExitPlanModeRequest): Promise<ExitPlanModeResult>;
276
- /**
277
- * Handles an autoModeSwitch.request callback from the runtime.
278
- * @internal
279
- */
280
- _handleAutoModeSwitchRequest(request: AutoModeSwitchRequest): Promise<AutoModeSwitchResponse>;
281
- /**
282
- * Sets the host capabilities for this session.
283
- *
284
- * @param capabilities - The capabilities object from the create/resume response
285
- * @internal This method is typically called internally when creating/resuming a session.
286
- */
287
- setCapabilities(capabilities?: SessionCapabilities): void;
288
169
  private assertElicitation;
289
170
  private _elicitation;
290
171
  private _confirm;
291
172
  private _select;
292
173
  private _input;
293
- /**
294
- * Registers a handler for permission requests.
295
- *
296
- * When the assistant needs permission to perform certain actions (e.g., file operations),
297
- * this handler is called to approve or deny the request.
298
- *
299
- * @param handler - The permission handler function, or undefined to remove the handler
300
- * @internal This method is typically called internally when creating a session.
301
- */
302
- registerPermissionHandler(handler?: PermissionHandler): void;
303
- /**
304
- * Registers a user input handler for ask_user requests.
305
- *
306
- * When the agent needs input from the user (via ask_user tool),
307
- * this handler is called to provide the response.
308
- *
309
- * @param handler - The user input handler function, or undefined to remove the handler
310
- * @internal This method is typically called internally when creating a session.
311
- */
312
- registerUserInputHandler(handler?: UserInputHandler): void;
313
- /**
314
- * Registers hook handlers for session lifecycle events.
315
- *
316
- * Hooks allow custom logic to be executed at various points during
317
- * the session lifecycle (before/after tool use, session start/end, etc.).
318
- *
319
- * @param hooks - The hook handlers object, or undefined to remove all hooks
320
- * @internal This method is typically called internally when creating a session.
321
- */
322
- registerHooks(hooks?: SessionHooks): void;
323
- /**
324
- * Registers transform callbacks for system message sections.
325
- *
326
- * @param callbacks - Map of section ID to transform callback, or undefined to clear
327
- * @internal This method is typically called internally when creating a session.
328
- */
329
- registerTransformCallbacks(callbacks?: Map<string, SectionTransformFn>): void;
330
- /**
331
- * Handles a systemMessage.transform request from the runtime.
332
- * Dispatches each section to its registered transform callback.
333
- *
334
- * @param sections - Map of section IDs to their current rendered content
335
- * @returns A promise that resolves with the transformed sections
336
- * @internal This method is for internal use by the SDK.
337
- */
338
- _handleSystemMessageTransform(sections: Record<string, {
339
- content: string;
340
- }>): Promise<{
341
- sections: Record<string, {
342
- content: string;
343
- }>;
344
- }>;
345
- /**
346
- * Handles a permission request in the v2 protocol format (synchronous RPC).
347
- * Used as a back-compat adapter when connected to a v2 server.
348
- *
349
- * @param request - The permission request data from the CLI
350
- * @returns A promise that resolves with the permission decision
351
- * @internal This method is for internal use by the SDK.
352
- */
353
- _handlePermissionRequestV2(request: unknown): Promise<PermissionRequestResult>;
354
- /**
355
- * Handles a user input request from the Copilot CLI.
356
- *
357
- * @param request - The user input request data from the CLI
358
- * @returns A promise that resolves with the user's response
359
- * @internal This method is for internal use by the SDK.
360
- */
361
- _handleUserInputRequest(request: unknown): Promise<UserInputResponse>;
362
- /**
363
- * Handles a hooks invocation from the Copilot CLI.
364
- *
365
- * @param hookType - The type of hook being invoked
366
- * @param input - The input data for the hook
367
- * @returns A promise that resolves with the hook output, or undefined
368
- * @internal This method is for internal use by the SDK.
369
- */
370
- _handleHooksInvoke(hookType: string, input: unknown): Promise<unknown>;
371
174
  /**
372
175
  * Retrieves all events and messages from this session's history.
373
176
  *
@@ -379,7 +182,7 @@ export declare class CopilotSession {
379
182
  *
380
183
  * @example
381
184
  * ```typescript
382
- * const events = await session.getMessages();
185
+ * const events = await session.getEvents();
383
186
  * for (const event of events) {
384
187
  * if (event.type === "assistant.message") {
385
188
  * console.log("Assistant:", event.data.content);
@@ -387,7 +190,7 @@ export declare class CopilotSession {
387
190
  * }
388
191
  * ```
389
192
  */
390
- getMessages(): Promise<SessionEvent[]>;
193
+ getEvents(): Promise<SessionEvent[]>;
391
194
  /**
392
195
  * Disconnects this session and releases all in-memory resources (event handlers,
393
196
  * tool handlers, permission handlers).
@@ -410,16 +213,6 @@ export declare class CopilotSession {
410
213
  * ```
411
214
  */
412
215
  disconnect(): Promise<void>;
413
- /**
414
- * @deprecated Use {@link disconnect} instead. This method will be removed in a future release.
415
- *
416
- * Disconnects this session and releases all in-memory resources.
417
- * Session data on disk is preserved for later resumption.
418
- *
419
- * @returns A promise that resolves when the session is disconnected
420
- * @throws Error if the connection fails
421
- */
422
- destroy(): Promise<void>;
423
216
  /** Enables `await using session = ...` syntax for automatic cleanup. */
424
217
  [Symbol.asyncDispose](): Promise<void>;
425
218
  /**