@github/copilot-sdk 0.3.0-preview.1 → 1.0.0-beta.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.
@@ -36,8 +36,14 @@ function createServerRpc(connection) {
36
36
  }
37
37
  };
38
38
  }
39
+ function createInternalServerRpc(connection) {
40
+ return {
41
+ connect: async (params) => connection.sendRequest("connect", params)
42
+ };
43
+ }
39
44
  function createSessionRpc(connection, sessionId) {
40
45
  return {
46
+ suspend: async () => connection.sendRequest("session.suspend", { sessionId }),
41
47
  auth: {
42
48
  getStatus: async () => connection.sendRequest("session.auth.getStatus", { sessionId })
43
49
  },
@@ -80,6 +86,14 @@ function createSessionRpc(connection, sessionId) {
80
86
  reload: async () => connection.sendRequest("session.agent.reload", { sessionId })
81
87
  },
82
88
  /** @experimental */
89
+ tasks: {
90
+ startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { sessionId, ...params }),
91
+ list: async () => connection.sendRequest("session.tasks.list", { sessionId }),
92
+ promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { sessionId, ...params }),
93
+ cancel: async (params) => connection.sendRequest("session.tasks.cancel", { sessionId, ...params }),
94
+ remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params })
95
+ },
96
+ /** @experimental */
83
97
  skills: {
84
98
  list: async () => connection.sendRequest("session.skills.list", { sessionId }),
85
99
  enable: async (params) => connection.sendRequest("session.skills.enable", { sessionId, ...params }),
@@ -192,6 +206,7 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
192
206
  });
193
207
  }
194
208
  export {
209
+ createInternalServerRpc,
195
210
  createServerRpc,
196
211
  createSessionRpc,
197
212
  registerClientSessionApiHandlers
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED FILE - DO NOT EDIT
3
3
  * Generated from: session-events.schema.json
4
4
  */
5
- export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | PlanChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | ContextChangedEvent | UsageInfoEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantUsageEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent;
5
+ export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | PlanChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | ContextChangedEvent | UsageInfoEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantUsageEvent | ModelCallFailureEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent;
6
6
  /**
7
7
  * Hosting platform type of the repository (github or ado)
8
8
  */
@@ -39,6 +39,10 @@ export type UserMessageAttachmentGithubReferenceType = "issue" | "pr" | "discuss
39
39
  * Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
40
40
  */
41
41
  export type AssistantMessageToolRequestType = "function" | "custom";
42
+ /**
43
+ * Where the failed model call originated
44
+ */
45
+ export type ModelCallFailureSource = "top_level" | "subagent" | "mcp_sampling";
42
46
  /**
43
47
  * A content block within a tool result, which may be text, terminal output, image, audio, or a resource
44
48
  */
@@ -58,7 +62,7 @@ export type SystemMessageRole = "system" | "developer";
58
62
  /**
59
63
  * Structured metadata identifying what triggered this notification
60
64
  */
61
- export type SystemNotification = SystemNotificationAgentCompleted | SystemNotificationAgentIdle | SystemNotificationNewInboxMessage | SystemNotificationShellCompleted | SystemNotificationShellDetachedCompleted;
65
+ export type SystemNotification = SystemNotificationAgentCompleted | SystemNotificationAgentIdle | SystemNotificationNewInboxMessage | SystemNotificationShellCompleted | SystemNotificationShellDetachedCompleted | SystemNotificationInstructionDiscovered;
62
66
  /**
63
67
  * Whether the agent completed successfully or failed
64
68
  */
@@ -92,9 +96,13 @@ export type PermissionPromptRequestMemoryDirection = "upvote" | "downvote";
92
96
  */
93
97
  export type PermissionPromptRequestPathAccessKind = "read" | "shell" | "write";
94
98
  /**
95
- * The outcome of the permission request
99
+ * The result of the permission request
100
+ */
101
+ export type PermissionResult = PermissionApproved | PermissionApprovedForSession | PermissionApprovedForLocation | PermissionCancelled | PermissionDeniedByRules | PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser | PermissionDeniedInteractivelyByUser | PermissionDeniedByContentExclusionPolicy | PermissionDeniedByPermissionRequestHook;
102
+ /**
103
+ * The approval to add as a session-scoped rule
96
104
  */
97
- export type PermissionCompletedKind = "approved" | "approved-for-session" | "approved-for-location" | "denied-by-rules" | "denied-no-approval-rule-and-could-not-request-from-user" | "denied-interactively-by-user" | "denied-by-content-exclusion-policy" | "denied-by-permission-request-hook";
105
+ export type UserToolSessionApproval = UserToolSessionApprovalCommands | UserToolSessionApprovalRead | UserToolSessionApprovalWrite | UserToolSessionApprovalMcp | UserToolSessionApprovalMemory | UserToolSessionApprovalCustomTool;
98
106
  /**
99
107
  * Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
100
108
  */
@@ -253,6 +261,10 @@ export interface ResumeData {
253
261
  */
254
262
  alreadyInUse?: boolean;
255
263
  context?: WorkingDirectoryContext;
264
+ /**
265
+ * When true, tool calls and permission requests left in flight by the previous session lifetime remain pending after resume and the agentic loop awaits their results. User sends are queued behind the pending work until all such requests reach a terminal state. When false (the default), any such tool calls and permission requests are immediately marked as interrupted on resume.
266
+ */
267
+ continuePendingWork?: boolean;
256
268
  /**
257
269
  * Total number of persisted events in the session at the time of resume
258
270
  */
@@ -273,6 +285,10 @@ export interface ResumeData {
273
285
  * Model currently selected at resume time
274
286
  */
275
287
  selectedModel?: string;
288
+ /**
289
+ * True when this resume attached to a session that the runtime already had running in-memory (for example, an extension joining a session another client was actively driving). False (or omitted) for cold resumes — the runtime had to reconstitute the session from its persisted event log.
290
+ */
291
+ sessionWasActive?: boolean;
276
292
  }
277
293
  export interface RemoteSteerableChangedEvent {
278
294
  /**
@@ -335,6 +351,14 @@ export interface ErrorEvent {
335
351
  * Error details for timeline display including message and optional diagnostic information
336
352
  */
337
353
  export interface ErrorData {
354
+ /**
355
+ * Only set on `errorType: "rate_limit"`. When `true`, the runtime will follow this error with an `auto_mode_switch.requested` event (or silently switch if `continueOnAutoMode` is enabled). UI clients can use this flag to suppress duplicate rendering of the rate-limit error when they show their own auto-mode-switch prompt.
356
+ */
357
+ eligibleForAutoSwitch?: boolean;
358
+ /**
359
+ * Fine-grained error code from the upstream provider, when available. For `errorType: "rate_limit"`, this is one of the `RateLimitErrorCode` values (e.g., `"user_weekly_rate_limited"`, `"user_global_rate_limited"`, `"rate_limited"`, `"user_model_rate_limited"`, `"integration_rate_limited"`).
360
+ */
361
+ errorCode?: string;
338
362
  /**
339
363
  * Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
340
364
  */
@@ -456,6 +480,10 @@ export interface InfoData {
456
480
  * Human-readable informational message for display in the timeline
457
481
  */
458
482
  message: string;
483
+ /**
484
+ * Optional actionable tip displayed with this message
485
+ */
486
+ tip?: string;
459
487
  /**
460
488
  * Optional URL associated with this message that the user can open in a browser
461
489
  */
@@ -530,6 +558,10 @@ export interface ModelChangeEvent {
530
558
  * Model change details including previous and new model identifiers
531
559
  */
532
560
  export interface ModelChangeData {
561
+ /**
562
+ * Reason the change happened, when not user-initiated. Currently `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path. UI clients can use this to render contextual copy.
563
+ */
564
+ cause?: string;
533
565
  /**
534
566
  * Newly selected model identifier
535
567
  */
@@ -871,6 +903,12 @@ export interface ShutdownData {
871
903
  * System message token count at shutdown
872
904
  */
873
905
  systemTokens?: number;
906
+ /**
907
+ * Session-wide per-token-type accumulated token counts
908
+ */
909
+ tokenDetails?: {
910
+ [k: string]: ShutdownTokenDetail;
911
+ };
874
912
  /**
875
913
  * Tool definitions token count at shutdown
876
914
  */
@@ -879,6 +917,10 @@ export interface ShutdownData {
879
917
  * Cumulative time spent in API calls during the session, in milliseconds
880
918
  */
881
919
  totalApiDurationMs: number;
920
+ /**
921
+ * Session-wide accumulated nano-AI units cost
922
+ */
923
+ totalNanoAiu?: number;
882
924
  /**
883
925
  * Total number of premium API requests used during the session
884
926
  */
@@ -903,6 +945,16 @@ export interface ShutdownCodeChanges {
903
945
  }
904
946
  export interface ShutdownModelMetric {
905
947
  requests: ShutdownModelMetricRequests;
948
+ /**
949
+ * Token count details per type
950
+ */
951
+ tokenDetails?: {
952
+ [k: string]: ShutdownModelMetricTokenDetail;
953
+ };
954
+ /**
955
+ * Accumulated nano-AI units cost for this model
956
+ */
957
+ totalNanoAiu?: number;
906
958
  usage: ShutdownModelMetricUsage;
907
959
  }
908
960
  /**
@@ -918,6 +970,12 @@ export interface ShutdownModelMetricRequests {
918
970
  */
919
971
  count: number;
920
972
  }
973
+ export interface ShutdownModelMetricTokenDetail {
974
+ /**
975
+ * Accumulated token count for this token type
976
+ */
977
+ tokenCount: number;
978
+ }
921
979
  /**
922
980
  * Token usage breakdown
923
981
  */
@@ -943,6 +1001,12 @@ export interface ShutdownModelMetricUsage {
943
1001
  */
944
1002
  reasoningTokens?: number;
945
1003
  }
1004
+ export interface ShutdownTokenDetail {
1005
+ /**
1006
+ * Accumulated token count for this token type
1007
+ */
1008
+ tokenCount: number;
1009
+ }
946
1010
  export interface ContextChangedEvent {
947
1011
  /**
948
1012
  * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
@@ -1187,7 +1251,7 @@ export interface CompactionCompleteCompactionTokensUsedCopilotUsage {
1187
1251
  */
1188
1252
  tokenDetails: CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail[];
1189
1253
  /**
1190
- * Total cost in nano-AIU (AI Units) for this request
1254
+ * Total cost in nano-AI units for this request
1191
1255
  */
1192
1256
  totalNanoAiu: number;
1193
1257
  }
@@ -1291,6 +1355,10 @@ export interface UserMessageData {
1291
1355
  * Path-backed native document attachments that stayed on the tagged_files path flow because native upload would exceed the request size limit
1292
1356
  */
1293
1357
  nativeDocumentPathFallbackPaths?: string[];
1358
+ /**
1359
+ * Parent agent task ID for background telemetry correlated to this user turn
1360
+ */
1361
+ parentAgentTaskId?: string;
1294
1362
  /**
1295
1363
  * Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected messages that should be hidden from the user)
1296
1364
  */
@@ -1721,6 +1789,10 @@ export interface AssistantMessageData {
1721
1789
  * Tool invocations requested by the assistant in this message
1722
1790
  */
1723
1791
  toolRequests?: AssistantMessageToolRequest[];
1792
+ /**
1793
+ * Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
1794
+ */
1795
+ turnId?: string;
1724
1796
  }
1725
1797
  /**
1726
1798
  * A tool invocation request from the assistant
@@ -1754,6 +1826,40 @@ export interface AssistantMessageToolRequest {
1754
1826
  toolTitle?: string;
1755
1827
  type?: AssistantMessageToolRequestType;
1756
1828
  }
1829
+ export interface AssistantMessageStartEvent {
1830
+ /**
1831
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
1832
+ */
1833
+ agentId?: string;
1834
+ data: AssistantMessageStartData;
1835
+ ephemeral: true;
1836
+ /**
1837
+ * Unique event identifier (UUID v4), generated when the event is emitted
1838
+ */
1839
+ id: string;
1840
+ /**
1841
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
1842
+ */
1843
+ parentId: string | null;
1844
+ /**
1845
+ * ISO 8601 timestamp when the event was created
1846
+ */
1847
+ timestamp: string;
1848
+ type: "assistant.message_start";
1849
+ }
1850
+ /**
1851
+ * Streaming assistant message start metadata
1852
+ */
1853
+ export interface AssistantMessageStartData {
1854
+ /**
1855
+ * Message ID this start event belongs to, matching subsequent deltas and assistant.message
1856
+ */
1857
+ messageId: string;
1858
+ /**
1859
+ * Generation phase this message belongs to for phased-output models
1860
+ */
1861
+ phase?: string;
1862
+ }
1757
1863
  export interface AssistantMessageDeltaEvent {
1758
1864
  /**
1759
1865
  * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
@@ -1929,7 +2035,7 @@ export interface AssistantUsageCopilotUsage {
1929
2035
  */
1930
2036
  tokenDetails: AssistantUsageCopilotUsageTokenDetail[];
1931
2037
  /**
1932
- * Total cost in nano-AIU (AI Units) for this request
2038
+ * Total cost in nano-AI units for this request
1933
2039
  */
1934
2040
  totalNanoAiu: number;
1935
2041
  }
@@ -1988,6 +2094,61 @@ export interface AssistantUsageQuotaSnapshot {
1988
2094
  */
1989
2095
  usedRequests: number;
1990
2096
  }
2097
+ export interface ModelCallFailureEvent {
2098
+ /**
2099
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
2100
+ */
2101
+ agentId?: string;
2102
+ data: ModelCallFailureData;
2103
+ ephemeral: true;
2104
+ /**
2105
+ * Unique event identifier (UUID v4), generated when the event is emitted
2106
+ */
2107
+ id: string;
2108
+ /**
2109
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
2110
+ */
2111
+ parentId: string | null;
2112
+ /**
2113
+ * ISO 8601 timestamp when the event was created
2114
+ */
2115
+ timestamp: string;
2116
+ type: "model.call_failure";
2117
+ }
2118
+ /**
2119
+ * Failed LLM API call metadata for telemetry
2120
+ */
2121
+ export interface ModelCallFailureData {
2122
+ /**
2123
+ * Completion ID from the model provider (e.g., chatcmpl-abc123)
2124
+ */
2125
+ apiCallId?: string;
2126
+ /**
2127
+ * Duration of the failed API call in milliseconds
2128
+ */
2129
+ durationMs?: number;
2130
+ /**
2131
+ * Raw provider/runtime error message for restricted telemetry
2132
+ */
2133
+ errorMessage?: string;
2134
+ /**
2135
+ * What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
2136
+ */
2137
+ initiator?: string;
2138
+ /**
2139
+ * Model identifier used for the failed API call
2140
+ */
2141
+ model?: string;
2142
+ /**
2143
+ * GitHub request tracing ID (x-github-request-id header) for server-side log correlation
2144
+ */
2145
+ providerCallId?: string;
2146
+ source: ModelCallFailureSource;
2147
+ /**
2148
+ * HTTP status code from the failed request
2149
+ */
2150
+ statusCode?: number;
2151
+ }
1991
2152
  export interface AbortEvent {
1992
2153
  /**
1993
2154
  * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
@@ -2119,6 +2280,10 @@ export interface ToolExecutionStartData {
2119
2280
  * Name of the tool being executed
2120
2281
  */
2121
2282
  toolName: string;
2283
+ /**
2284
+ * Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
2285
+ */
2286
+ turnId?: string;
2122
2287
  }
2123
2288
  export interface ToolExecutionPartialResultEvent {
2124
2289
  /**
@@ -2249,6 +2414,10 @@ export interface ToolExecutionCompleteData {
2249
2414
  toolTelemetry?: {
2250
2415
  [k: string]: unknown;
2251
2416
  };
2417
+ /**
2418
+ * Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
2419
+ */
2420
+ turnId?: string;
2252
2421
  }
2253
2422
  /**
2254
2423
  * Error details when the tool execution failed
@@ -2968,7 +3137,7 @@ export interface SystemNotificationNewInboxMessage {
2968
3137
  */
2969
3138
  senderName: string;
2970
3139
  /**
2971
- * Category of the sender (e.g., ambient-agent, plugin, hook)
3140
+ * Category of the sender (e.g., sidekick-agent, plugin, hook)
2972
3141
  */
2973
3142
  senderType: string;
2974
3143
  /**
@@ -3003,13 +3172,35 @@ export interface SystemNotificationShellDetachedCompleted {
3003
3172
  shellId: string;
3004
3173
  type: "shell_detached_completed";
3005
3174
  }
3175
+ export interface SystemNotificationInstructionDiscovered {
3176
+ /**
3177
+ * Human-readable label for the timeline (e.g., 'AGENTS.md from packages/billing/')
3178
+ */
3179
+ description?: string;
3180
+ /**
3181
+ * Relative path to the discovered instruction file
3182
+ */
3183
+ sourcePath: string;
3184
+ /**
3185
+ * Path of the file access that triggered discovery
3186
+ */
3187
+ triggerFile: string;
3188
+ /**
3189
+ * Tool command that triggered discovery (currently always 'view')
3190
+ */
3191
+ triggerTool: string;
3192
+ type: "instruction_discovered";
3193
+ }
3006
3194
  export interface PermissionRequestedEvent {
3007
3195
  /**
3008
3196
  * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
3009
3197
  */
3010
3198
  agentId?: string;
3011
3199
  data: PermissionRequestedData;
3012
- ephemeral: true;
3200
+ /**
3201
+ * When true, the event is transient and not persisted to the session event log on disk
3202
+ */
3203
+ ephemeral?: boolean;
3013
3204
  /**
3014
3205
  * Unique event identifier (UUID v4), generated when the event is emitted
3015
3206
  */
@@ -3538,7 +3729,10 @@ export interface PermissionCompletedEvent {
3538
3729
  */
3539
3730
  agentId?: string;
3540
3731
  data: PermissionCompletedData;
3541
- ephemeral: true;
3732
+ /**
3733
+ * When true, the event is transient and not persisted to the session event log on disk
3734
+ */
3735
+ ephemeral?: boolean;
3542
3736
  /**
3543
3737
  * Unique event identifier (UUID v4), generated when the event is emitted
3544
3738
  */
@@ -3561,17 +3755,165 @@ export interface PermissionCompletedData {
3561
3755
  * Request ID of the resolved permission request; clients should dismiss any UI for this request
3562
3756
  */
3563
3757
  requestId: string;
3564
- result: PermissionCompletedResult;
3758
+ result: PermissionResult;
3565
3759
  /**
3566
3760
  * Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
3567
3761
  */
3568
3762
  toolCallId?: string;
3569
3763
  }
3570
- /**
3571
- * The result of the permission request
3572
- */
3573
- export interface PermissionCompletedResult {
3574
- kind: PermissionCompletedKind;
3764
+ export interface PermissionApproved {
3765
+ /**
3766
+ * The permission request was approved
3767
+ */
3768
+ kind: "approved";
3769
+ }
3770
+ export interface PermissionApprovedForSession {
3771
+ approval: UserToolSessionApproval;
3772
+ /**
3773
+ * Approved and remembered for the rest of the session
3774
+ */
3775
+ kind: "approved-for-session";
3776
+ }
3777
+ export interface UserToolSessionApprovalCommands {
3778
+ /**
3779
+ * Command identifiers approved by the user
3780
+ */
3781
+ commandIdentifiers: string[];
3782
+ /**
3783
+ * Command approval kind
3784
+ */
3785
+ kind: "commands";
3786
+ }
3787
+ export interface UserToolSessionApprovalRead {
3788
+ /**
3789
+ * Read approval kind
3790
+ */
3791
+ kind: "read";
3792
+ }
3793
+ export interface UserToolSessionApprovalWrite {
3794
+ /**
3795
+ * Write approval kind
3796
+ */
3797
+ kind: "write";
3798
+ }
3799
+ export interface UserToolSessionApprovalMcp {
3800
+ /**
3801
+ * MCP tool approval kind
3802
+ */
3803
+ kind: "mcp";
3804
+ /**
3805
+ * MCP server name
3806
+ */
3807
+ serverName: string;
3808
+ /**
3809
+ * Optional MCP tool name, or null for all tools on the server
3810
+ */
3811
+ toolName: string | null;
3812
+ }
3813
+ export interface UserToolSessionApprovalMemory {
3814
+ /**
3815
+ * Memory approval kind
3816
+ */
3817
+ kind: "memory";
3818
+ }
3819
+ export interface UserToolSessionApprovalCustomTool {
3820
+ /**
3821
+ * Custom tool approval kind
3822
+ */
3823
+ kind: "custom-tool";
3824
+ /**
3825
+ * Custom tool name
3826
+ */
3827
+ toolName: string;
3828
+ }
3829
+ export interface PermissionApprovedForLocation {
3830
+ approval: UserToolSessionApproval;
3831
+ /**
3832
+ * Approved and persisted for this project location
3833
+ */
3834
+ kind: "approved-for-location";
3835
+ /**
3836
+ * The location key (git root or cwd) to persist the approval to
3837
+ */
3838
+ locationKey: string;
3839
+ }
3840
+ export interface PermissionCancelled {
3841
+ /**
3842
+ * The permission request was cancelled before a response was used
3843
+ */
3844
+ kind: "cancelled";
3845
+ /**
3846
+ * Optional explanation of why the request was cancelled
3847
+ */
3848
+ reason?: string;
3849
+ }
3850
+ export interface PermissionDeniedByRules {
3851
+ /**
3852
+ * Denied because approval rules explicitly blocked it
3853
+ */
3854
+ kind: "denied-by-rules";
3855
+ /**
3856
+ * Rules that denied the request
3857
+ */
3858
+ rules: PermissionRule[];
3859
+ }
3860
+ export interface PermissionRule {
3861
+ /**
3862
+ * Optional rule argument matched against the request
3863
+ */
3864
+ argument: string | null;
3865
+ /**
3866
+ * The rule kind, such as Shell or GitHubMCP
3867
+ */
3868
+ kind: string;
3869
+ }
3870
+ export interface PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
3871
+ /**
3872
+ * Denied because no approval rule matched and user confirmation was unavailable
3873
+ */
3874
+ kind: "denied-no-approval-rule-and-could-not-request-from-user";
3875
+ }
3876
+ export interface PermissionDeniedInteractivelyByUser {
3877
+ /**
3878
+ * Optional feedback from the user explaining the denial
3879
+ */
3880
+ feedback?: string;
3881
+ /**
3882
+ * Whether to force-reject the current agent turn
3883
+ */
3884
+ forceReject?: boolean;
3885
+ /**
3886
+ * Denied by the user during an interactive prompt
3887
+ */
3888
+ kind: "denied-interactively-by-user";
3889
+ }
3890
+ export interface PermissionDeniedByContentExclusionPolicy {
3891
+ /**
3892
+ * Denied by the organization's content exclusion policy
3893
+ */
3894
+ kind: "denied-by-content-exclusion-policy";
3895
+ /**
3896
+ * Human-readable explanation of why the path was excluded
3897
+ */
3898
+ message: string;
3899
+ /**
3900
+ * File path that triggered the exclusion
3901
+ */
3902
+ path: string;
3903
+ }
3904
+ export interface PermissionDeniedByPermissionRequestHook {
3905
+ /**
3906
+ * Whether to interrupt the current agent turn
3907
+ */
3908
+ interrupt?: boolean;
3909
+ /**
3910
+ * Denied by a permission request hook registered by an extension or plugin
3911
+ */
3912
+ kind: "denied-by-permission-request-hook";
3913
+ /**
3914
+ * Optional message from the hook explaining the denial
3915
+ */
3916
+ message?: string;
3575
3917
  }
3576
3918
  export interface UserInputRequestedEvent {
3577
3919
  /**
@@ -3878,6 +4220,10 @@ export interface McpOauthRequiredStaticClientConfig {
3878
4220
  * OAuth client ID for the server
3879
4221
  */
3880
4222
  clientId: string;
4223
+ /**
4224
+ * Optional non-default OAuth grant type. When set to 'client_credentials', the OAuth flow runs headlessly using the client_id + keychain-stored secret (no browser, no callback server).
4225
+ */
4226
+ grantType?: "client_credentials";
3881
4227
  /**
3882
4228
  * Whether this is a public OAuth client
3883
4229
  */
@@ -3919,7 +4265,10 @@ export interface ExternalToolRequestedEvent {
3919
4265
  */
3920
4266
  agentId?: string;
3921
4267
  data: ExternalToolRequestedData;
3922
- ephemeral: true;
4268
+ /**
4269
+ * When true, the event is transient and not persisted to the session event log on disk
4270
+ */
4271
+ ephemeral?: boolean;
3923
4272
  /**
3924
4273
  * Unique event identifier (UUID v4), generated when the event is emitted
3925
4274
  */
@@ -3975,7 +4324,7 @@ export interface ExternalToolCompletedEvent {
3975
4324
  */
3976
4325
  agentId?: string;
3977
4326
  data: ExternalToolCompletedData;
3978
- ephemeral: true;
4327
+ ephemeral?: true;
3979
4328
  /**
3980
4329
  * Unique event identifier (UUID v4), generated when the event is emitted
3981
4330
  */
@@ -4138,6 +4487,10 @@ export interface AutoModeSwitchRequestedData {
4138
4487
  * Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
4139
4488
  */
4140
4489
  requestId: string;
4490
+ /**
4491
+ * Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
4492
+ */
4493
+ retryAfterSeconds?: number;
4141
4494
  }
4142
4495
  export interface AutoModeSwitchCompletedEvent {
4143
4496
  /**