@github/copilot-sdk 1.0.8-preview.0 → 1.0.9-preview.0

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.
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Union of all session event variants emitted by the Copilot CLI runtime.
7
7
  */
8
- export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ContextChangedEvent | UsageInfoEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantTurnRetryEvent | AssistantIntentEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallStartEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
8
+ export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ContextChangedEvent | UsageInfoEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantTurnRetryEvent | AssistantIntentEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallStartEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | FactoryRunUpdatedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
9
9
  /**
10
10
  * Hosting platform type of the repository (github or ado)
11
11
  */
@@ -42,6 +42,14 @@ export type Verbosity =
42
42
  | "medium"
43
43
  /** A more detailed response was requested. */
44
44
  | "high";
45
+ /**
46
+ * Who created the schedule: `user` (an explicit user action such as `/every` or `/after`) or `model` (the agent via the `manage_schedule` tool). Gates whether a scheduled skill that opted out of model invocation may fire: only user-created schedules may.
47
+ */
48
+ export type ScheduleOrigin =
49
+ /** The schedule was created by an explicit user action, such as `/every` or `/after`. */
50
+ "user"
51
+ /** The schedule was created by the agent via the `manage_schedule` tool. */
52
+ | "model";
45
53
  /**
46
54
  * The type of operation performed on the autopilot objective state file
47
55
  */
@@ -119,6 +127,30 @@ export type ShutdownType =
119
127
  "routine"
120
128
  /** The session ended because of a crash or fatal error. */
121
129
  | "error";
130
+ /**
131
+ * What initiated a conversation compaction
132
+ */
133
+ export type CompactionTrigger =
134
+ /** Background compaction started automatically because context utilization crossed the background threshold. */
135
+ "threshold"
136
+ /** Compaction forced by a context-limit model response (e.g. HTTP 413) before retrying the request. */
137
+ | "context_limit_retry"
138
+ /** User-requested compaction, e.g. the /compact command or the history.compact API. */
139
+ | "manual"
140
+ /** Emergency compaction triggered by high process memory usage. */
141
+ | "memory_pressure"
142
+ /** Compaction requested while switching to a model with a smaller context window. */
143
+ | "model_switch";
144
+ /**
145
+ * Semantic result of evaluating a task completion request
146
+ */
147
+ export type TaskCompletionOutcome =
148
+ /** The completion request was accepted and the objective is complete. */
149
+ "completed"
150
+ /** The completion request was rejected because more work or validation remains. */
151
+ | "continue"
152
+ /** Completion cannot proceed without intervention; the active objective is paused when one is identified. */
153
+ | "blocked";
122
154
  /**
123
155
  * The agent mode that was active when this message was sent
124
156
  */
@@ -333,7 +365,7 @@ export type SystemMessageRole =
333
365
  /**
334
366
  * Structured metadata identifying what triggered this notification
335
367
  */
336
- export type SystemNotification = SystemNotificationAgentCompleted | SystemNotificationAgentIdle | SystemNotificationNewInboxMessage | SystemNotificationShellCompleted | SystemNotificationShellDetachedCompleted | SystemNotificationInstructionDiscovered;
368
+ export type SystemNotification = SystemNotificationAgentCompleted | SystemNotificationAgentIdle | SystemNotificationNewInboxMessage | SystemNotificationShellCompleted | SystemNotificationShellDetachedCompleted | SystemNotificationInstructionDiscovered | SystemNotificationUnclassified;
337
369
  /**
338
370
  * Whether the agent completed successfully or failed
339
371
  */
@@ -366,6 +398,21 @@ export type PermissionRequestMemoryDirection =
366
398
  * Derived user-facing permission prompt details for UI consumers
367
399
  */
368
400
  export type PermissionPromptRequest = PermissionPromptRequestCommands | PermissionPromptRequestWrite | PermissionPromptRequestRead | PermissionPromptRequestMcp | PermissionPromptRequestUrl | PermissionPromptRequestMemory | PermissionPromptRequestCustomTool | PermissionPromptRequestPath | PermissionPromptRequestHook | PermissionPromptRequestExtensionManagement | PermissionPromptRequestExtensionPermissionAccess;
401
+ /**
402
+ * Why the auto-approval judge produced no usable recommendation. Present only alongside an `error` recommendation, where the human-readable reason is a fixed string and therefore cannot distinguish these cases. Intended to make a judge failure reportable by a consumer that has no access to the host's logs.
403
+ */
404
+ /** @experimental */
405
+ export type AutoApprovalJudgeFailureReason =
406
+ /** The judge model call exceeded its deadline. */
407
+ "timeout"
408
+ /** The judge model call was cancelled before it returned. */
409
+ | "abort"
410
+ /** The judge model call completed but returned no content. */
411
+ | "empty_response"
412
+ /** The judge model call failed (for example a transport, authentication, or rate-limit error). */
413
+ | "model_error"
414
+ /** The judge model replied, but the reply carried no ALLOW/DENY verdict. */
415
+ | "parse_error";
369
416
  /**
370
417
  * Outcome of the auto-approval safety judge for a permission request. Present only when auto mode is enabled; its absence means the judge did not evaluate the request (auto mode was off).
371
418
  */
@@ -719,6 +766,10 @@ export interface WorkingDirectoryContext {
719
766
  */
720
767
  headCommit?: string;
721
768
  hostType?: WorkingDirectoryContextHostType;
769
+ /**
770
+ * Set on the immediate preliminary event of a working-directory change, before the git context is resolved. A settled follow-up event (enriched with git context, or cwd-only for a non-repository) is always emitted afterward, so observers may defer to it. Absent on standalone/final events (e.g. relay context changes).
771
+ */
772
+ pendingGitContext?: boolean;
722
773
  /**
723
774
  * Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
724
775
  */
@@ -781,7 +832,7 @@ export interface ResumeData {
781
832
  */
782
833
  contextTier?: ContextTier | null;
783
834
  /**
784
- * 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.
835
+ * 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 or omitted, pending work is normally marked as interrupted unless the resume passively joined live work owned by another client; sessionWasActive distinguishes that case.
785
836
  */
786
837
  continuePendingWork?: boolean;
787
838
  /**
@@ -814,7 +865,7 @@ export interface ResumeData {
814
865
  */
815
866
  sessionLimits?: SessionLimitsConfig | null;
816
867
  /**
817
- * 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.
868
+ * True when this resume passively joined a session that already had live work running in the runtime - an agent turn, a native queue run, a queued resume continuation, or an in-flight send (for example, an extension joining a session another client was actively driving). False (or omitted) when the session had no live work or when the resume explicitly abandoned pending work, including cold resumes and suspended sessions that remain resident in memory.
818
869
  */
819
870
  sessionWasActive?: boolean;
820
871
  verbosity?: Verbosity;
@@ -1061,6 +1112,7 @@ export interface ScheduleCreatedData {
1061
1112
  * Interval between ticks in milliseconds (relative-interval schedules)
1062
1113
  */
1063
1114
  intervalMs?: number;
1115
+ origin?: ScheduleOrigin;
1064
1116
  /**
1065
1117
  * Prompt text that gets enqueued on every tick
1066
1118
  */
@@ -2145,6 +2197,10 @@ export interface CompactionStartData {
2145
2197
  * Token count from non-system messages (user, assistant, tool) at compaction start
2146
2198
  */
2147
2199
  conversationTokens?: number;
2200
+ /**
2201
+ * Total context tokens (system + conversation + tool definitions) at compaction start, when known
2202
+ */
2203
+ currentTokens?: number;
2148
2204
  /**
2149
2205
  * Model identifier used for compaction, when known
2150
2206
  */
@@ -2153,10 +2209,15 @@ export interface CompactionStartData {
2153
2209
  * Token count from system message(s) at compaction start
2154
2210
  */
2155
2211
  systemTokens?: number;
2212
+ /**
2213
+ * Model context window token limit the compaction is targeting, when known
2214
+ */
2215
+ tokenLimit?: number;
2156
2216
  /**
2157
2217
  * Token count from tool definitions at compaction start
2158
2218
  */
2159
2219
  toolDefinitionsTokens?: number;
2220
+ trigger?: CompactionTrigger;
2160
2221
  }
2161
2222
  /**
2162
2223
  * Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
@@ -2253,6 +2314,10 @@ export interface CompactionCompleteData {
2253
2314
  * Token count from system message(s) after compaction
2254
2315
  */
2255
2316
  systemTokens?: number;
2317
+ /**
2318
+ * Model context window token limit the compaction was targeting, when known
2319
+ */
2320
+ tokenLimit?: number;
2256
2321
  /**
2257
2322
  * Number of tokens removed during compaction
2258
2323
  */
@@ -2261,6 +2326,7 @@ export interface CompactionCompleteData {
2261
2326
  * Token count from tool definitions after compaction
2262
2327
  */
2263
2328
  toolDefinitionsTokens?: number;
2329
+ trigger?: CompactionTrigger;
2264
2330
  }
2265
2331
  /**
2266
2332
  * Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
@@ -2347,7 +2413,16 @@ export interface TaskCompleteEvent {
2347
2413
  */
2348
2414
  export interface TaskCompleteData {
2349
2415
  /**
2350
- * Whether the tool call succeeded. False when validation failed (e.g., invalid arguments)
2416
+ * Active autopilot objective ID evaluated by the completion reviewer
2417
+ */
2418
+ objectiveId?: number;
2419
+ outcome?: TaskCompletionOutcome;
2420
+ /**
2421
+ * Label-safe runtime rationale for the completion decision (e.g. a cancellation or pause/resume downgrade), when one applies. Reviewer-authored rationale is intentionally omitted here because this event has no IFC label channel; the reviewer's findings remain available through its own labeled sub-agent events
2422
+ */
2423
+ reason?: string;
2424
+ /**
2425
+ * Whether the task was accepted as complete. False when validation failed or completion was rejected or blocked by the reviewer
2351
2426
  */
2352
2427
  success?: boolean;
2353
2428
  /**
@@ -2416,7 +2491,7 @@ export interface UserMessageData {
2416
2491
  */
2417
2492
  parentAgentTaskId?: string;
2418
2493
  /**
2419
- * Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected messages that should be hidden from the user)
2494
+ * Origin of this message, used for timeline filtering and attribution (e.g., `skill-pdf` for hidden skill injection or `agent-<agent-id>` for an inter-agent prompt)
2420
2495
  */
2421
2496
  source?: string;
2422
2497
  /**
@@ -3095,6 +3170,7 @@ export interface AssistantReasoningData {
3095
3170
  * Unique identifier for this reasoning block
3096
3171
  */
3097
3172
  reasoningId: string;
3173
+ rte?: boolean;
3098
3174
  }
3099
3175
  /**
3100
3176
  * Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
@@ -3323,6 +3399,7 @@ export interface AssistantMessageData {
3323
3399
  * GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
3324
3400
  */
3325
3401
  requestId?: string;
3402
+ rte?: boolean;
3326
3403
  serverTools?: AssistantMessageServerTools;
3327
3404
  /**
3328
3405
  * Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
@@ -3767,6 +3844,10 @@ export interface AssistantUsageData {
3767
3844
  * Number of input tokens consumed
3768
3845
  */
3769
3846
  inputTokens?: number;
3847
+ /**
3848
+ * Coarse classification of the interaction that produced this call, mirroring the session's per-request agent context (e.g. `conversation-agent`, `conversation-subagent`, `conversation-sampling`, `conversation-background`, `conversation-compaction`, `conversation-user`). Non-billing; lets consumers attribute a model call to a call class (e.g. sub-agent/sidekick) independently of the billing initiator. Absent when the runtime did not classify the request.
3849
+ */
3850
+ interactionType?: string;
3770
3851
  /**
3771
3852
  * Average inter-token latency in milliseconds. Only available for streaming requests
3772
3853
  */
@@ -3796,6 +3877,7 @@ export interface AssistantUsageData {
3796
3877
  * Number of output tokens used for reasoning (e.g., chain-of-thought)
3797
3878
  */
3798
3879
  reasoningTokens?: number;
3880
+ rte?: boolean;
3799
3881
  /**
3800
3882
  * Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3801
3883
  */
@@ -3925,6 +4007,7 @@ export interface ModelCallFailureData {
3925
4007
  */
3926
4008
  reasoningEffort?: string;
3927
4009
  requestFingerprint?: ModelCallFailureRequestFingerprint;
4010
+ rte?: boolean;
3928
4011
  /**
3929
4012
  * Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3930
4013
  */
@@ -4128,6 +4211,7 @@ export interface ToolExecutionStartData {
4128
4211
  * Tool call ID of the parent tool invocation when this event originates from a sub-agent
4129
4212
  */
4130
4213
  parentToolCallId?: string;
4214
+ rte?: boolean;
4131
4215
  shellToolInfo?: ToolExecutionStartShellToolInfo;
4132
4216
  /**
4133
4217
  * Unique identifier for this tool call
@@ -4336,6 +4420,7 @@ export interface ToolExecutionCompleteData {
4336
4420
  */
4337
4421
  parentToolCallId?: string;
4338
4422
  result?: ToolExecutionCompleteResult;
4423
+ rte?: boolean;
4339
4424
  /**
4340
4425
  * Whether this tool execution ran inside a sandbox container
4341
4426
  */
@@ -5473,6 +5558,10 @@ export interface SystemMessageData {
5473
5558
  * The system or developer prompt text sent as model input
5474
5559
  */
5475
5560
  content: string;
5561
+ /**
5562
+ * Logical interaction identifier for the model run receiving this prompt
5563
+ */
5564
+ interactionId?: string;
5476
5565
  metadata?: SystemMessageMetadata;
5477
5566
  /**
5478
5567
  * Optional name identifier for the message source
@@ -5670,6 +5759,21 @@ export interface SystemNotificationInstructionDiscovered {
5670
5759
  */
5671
5760
  type: "instruction_discovered";
5672
5761
  }
5762
+ /**
5763
+ * System notification metadata from an external host that does not match a runtime-owned notification kind.
5764
+ */
5765
+ export interface SystemNotificationUnclassified {
5766
+ /**
5767
+ * Opaque metadata supplied by the external host, when present.
5768
+ */
5769
+ metadata?: {
5770
+ [k: string]: unknown | undefined;
5771
+ };
5772
+ /**
5773
+ * Type discriminator. Always "unclassified".
5774
+ */
5775
+ type: "unclassified";
5776
+ }
5673
5777
  /**
5674
5778
  * Session event "permission.requested". Permission request notification requiring client approval with request details
5675
5779
  */
@@ -5714,6 +5818,12 @@ export interface PermissionRequestedData {
5714
5818
  * When true, this permission was already resolved by a permissionRequest hook and requires no client action
5715
5819
  */
5716
5820
  resolvedByHook?: boolean;
5821
+ /**
5822
+ * Neutral risk metadata supplied by the tool host. Consumers may display this value but must not use it to bypass the permission decision.
5823
+ */
5824
+ riskAssessment?: {
5825
+ [k: string]: unknown | undefined;
5826
+ };
5717
5827
  }
5718
5828
  /**
5719
5829
  * Shell command permission request
@@ -5727,6 +5837,10 @@ export interface PermissionRequestShell {
5727
5837
  * Parsed command identifiers found in the command text
5728
5838
  */
5729
5839
  commands: PermissionRequestShellCommand[];
5840
+ /**
5841
+ * Parsed command segments, including arguments, used for managed policy matching
5842
+ */
5843
+ commandSegments?: PermissionRequestShellCommandSegment[];
5730
5844
  /**
5731
5845
  * The complete shell command text to be executed
5732
5846
  */
@@ -5743,6 +5857,10 @@ export interface PermissionRequestShell {
5743
5857
  * Permission kind discriminator
5744
5858
  */
5745
5859
  kind: "shell";
5860
+ /**
5861
+ * Whether managed policy requires a human response and forbids host auto-approval
5862
+ */
5863
+ managedApprovalRequired?: boolean;
5746
5864
  /**
5747
5865
  * File paths that may be read or written by the command
5748
5866
  */
@@ -5781,6 +5899,19 @@ export interface PermissionRequestShellCommand {
5781
5899
  */
5782
5900
  readOnly: boolean;
5783
5901
  }
5902
+ /**
5903
+ * A parsed shell command segment used for argument-aware managed policy matching.
5904
+ */
5905
+ export interface PermissionRequestShellCommandSegment {
5906
+ /**
5907
+ * Full text of this command segment, including arguments
5908
+ */
5909
+ fullCommandText: string;
5910
+ /**
5911
+ * Command identifier (e.g., executable name)
5912
+ */
5913
+ identifier: string;
5914
+ }
5784
5915
  /**
5785
5916
  * A URL that may be accessed by a command in a shell permission request.
5786
5917
  */
@@ -5814,6 +5945,10 @@ export interface PermissionRequestWrite {
5814
5945
  * Permission kind discriminator
5815
5946
  */
5816
5947
  kind: "write";
5948
+ /**
5949
+ * Whether managed policy requires a human response and forbids host auto-approval
5950
+ */
5951
+ managedApprovalRequired?: boolean;
5817
5952
  /**
5818
5953
  * Complete new file contents for newly created files
5819
5954
  */
@@ -5843,6 +5978,10 @@ export interface PermissionRequestRead {
5843
5978
  * Permission kind discriminator
5844
5979
  */
5845
5980
  kind: "read";
5981
+ /**
5982
+ * Whether managed policy requires a human response and forbids host auto-approval
5983
+ */
5984
+ managedApprovalRequired?: boolean;
5846
5985
  /**
5847
5986
  * Path of the file or directory being read
5848
5987
  */
@@ -5907,6 +6046,14 @@ export interface PermissionRequestUrl {
5907
6046
  * Permission kind discriminator
5908
6047
  */
5909
6048
  kind: "url";
6049
+ /**
6050
+ * Whether managed policy requires a human response and forbids host auto-approval
6051
+ */
6052
+ managedApprovalRequired?: boolean;
6053
+ /**
6054
+ * Immediately preceding URL when this request is for a redirect target
6055
+ */
6056
+ redirectedFrom?: string;
5910
6057
  /**
5911
6058
  * True when this URL fetch is requesting to bypass the sandbox network policy: either the model set requestSandboxBypass: true, or the tool re-issued the request as an interactive bypass after the network policy denied the approved URL (host opted in via sandbox.allowBypass). This is a request, not a grant: the fetch runs only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
5912
6059
  */
@@ -6081,6 +6228,10 @@ export interface PermissionPromptRequestCommands {
6081
6228
  * Prompt kind discriminator
6082
6229
  */
6083
6230
  kind: "commands";
6231
+ /**
6232
+ * Whether managed policy requires a human response and forbids host auto-approval
6233
+ */
6234
+ managedApprovalRequired?: boolean;
6084
6235
  /**
6085
6236
  * Tool call ID that triggered this permission request
6086
6237
  */
@@ -6095,6 +6246,11 @@ export interface PermissionPromptRequestCommands {
6095
6246
  */
6096
6247
  /** @experimental */
6097
6248
  export interface PermissionAutoApproval {
6249
+ failureReason?: AutoApprovalJudgeFailureReason;
6250
+ /**
6251
+ * Model id that produced the recommendation, when the judge was consulted and reported one. Absent for `excluded` (the judge was not consulted) and for failures that occurred before a model was selected.
6252
+ */
6253
+ model?: string;
6098
6254
  /**
6099
6255
  * Human-readable reason for the judge's recommendation, when available.
6100
6256
  */
@@ -6131,6 +6287,10 @@ export interface PermissionPromptRequestWrite {
6131
6287
  * Prompt kind discriminator
6132
6288
  */
6133
6289
  kind: "write";
6290
+ /**
6291
+ * Whether managed policy requires a human response and forbids host auto-approval
6292
+ */
6293
+ managedApprovalRequired?: boolean;
6134
6294
  /**
6135
6295
  * Complete new file contents for newly created files
6136
6296
  */
@@ -6158,6 +6318,10 @@ export interface PermissionPromptRequestRead {
6158
6318
  * Prompt kind discriminator
6159
6319
  */
6160
6320
  kind: "read";
6321
+ /**
6322
+ * Whether managed policy requires a human response and forbids host auto-approval
6323
+ */
6324
+ managedApprovalRequired?: boolean;
6161
6325
  /**
6162
6326
  * Path of the file or directory being read
6163
6327
  */
@@ -6222,6 +6386,14 @@ export interface PermissionPromptRequestUrl {
6222
6386
  * Prompt kind discriminator
6223
6387
  */
6224
6388
  kind: "url";
6389
+ /**
6390
+ * Whether managed policy requires a human response and forbids host auto-approval
6391
+ */
6392
+ managedApprovalRequired?: boolean;
6393
+ /**
6394
+ * Immediately preceding URL when this prompt is for a redirect target
6395
+ */
6396
+ redirectedFrom?: string;
6225
6397
  /**
6226
6398
  * True when this URL fetch is requesting to bypass the sandbox network policy: either the model set requestSandboxBypass: true, or the tool re-issued the request as an interactive bypass after the network policy denied the approved URL (host opted in via sandbox.allowBypass). This is a request, not a grant: the fetch runs only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
6227
6399
  */
@@ -7787,6 +7959,10 @@ export interface AutoModeResolvedEvent {
7787
7959
  */
7788
7960
  /** @experimental */
7789
7961
  export interface AutoModeResolvedData {
7962
+ /**
7963
+ * Models offered to the router for this resolution
7964
+ */
7965
+ availableModels?: string[];
7790
7966
  /**
7791
7967
  * Ordered candidate model list the router returned, when not a fallback
7792
7968
  */
@@ -7801,15 +7977,47 @@ export interface AutoModeResolvedData {
7801
7977
  * The concrete model the session will use after any intent refinement
7802
7978
  */
7803
7979
  chosenModel: string;
7980
+ /**
7981
+ * The chosen model's score shortfall relative to the top candidate
7982
+ */
7983
+ chosenShortfall?: number;
7804
7984
  /**
7805
7985
  * Classifier confidence for the predicted label, when available
7806
7986
  */
7807
7987
  confidence?: number;
7988
+ /**
7989
+ * End-to-end client wait time for the router request in milliseconds
7990
+ */
7991
+ endToEndLatencyMs?: number;
7992
+ /**
7993
+ * Whether the router fell back to the standard Auto selection
7994
+ */
7995
+ fallback?: boolean;
7996
+ /**
7997
+ * Server-provided reason for falling back, when available
7998
+ */
7999
+ fallbackReason?: string;
8000
+ /**
8001
+ * Whether the routed prompt contained an image
8002
+ */
8003
+ hasImage?: boolean;
7808
8004
  /**
7809
8005
  * The predicted classifier label (e.g. `needs_reasoning`), when available
7810
8006
  */
7811
8007
  predictedLabel?: string;
7812
8008
  reasoningBucket?: AutoModeResolvedReasoningBucket;
8009
+ /**
8010
+ * Server-reported router processing time in milliseconds
8011
+ */
8012
+ routerLatencyMs?: number;
8013
+ /**
8014
+ * The routing method the server applied, when Auto Intent ran
8015
+ */
8016
+ routingMethod?: string;
8017
+ /**
8018
+ * Whether a sticky model choice overrode the router result
8019
+ */
8020
+ stickyOverride?: boolean;
7813
8021
  }
7814
8022
  /**
7815
8023
  * Session event "session.managed_settings_resolved". Enterprise managed-settings resolution: the effective managed settings the session applied and where they came from, so SDK clients can show users what is enterprise-managed and by which authority. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted; for a session-independent pull, use the SDK `getManagedSettings()` API, which returns the identical payload. Managed settings have a single authoritative source, so the highest-authority present layer (server > device) wins wholesale; `bypassPermissionsDisabled` is deny-wins across layers. Marked experimental while the managed-settings surface stabilizes.
@@ -7863,6 +8071,10 @@ export interface ManagedSettingsResolvedData {
7863
8071
  * The setting keys under enterprise management in the effective managed settings (e.g. `model`, `enabledPlugins`, `permissions`). Empty when no managed settings are in force.
7864
8072
  */
7865
8073
  managedKeys: string[];
8074
+ /**
8075
+ * Whether server and device each supplied a permission allowlist, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
8076
+ */
8077
+ permissionsAllowIntersected?: boolean;
7866
8078
  /**
7867
8079
  * Whether the server (account/org) managed-settings layer was present
7868
8080
  */
@@ -8209,6 +8421,48 @@ export interface BackgroundTasksChangedEvent {
8209
8421
  */
8210
8422
  export interface BackgroundTasksChangedData {
8211
8423
  }
8424
+ /**
8425
+ * Session event "factory.run_updated". Ephemeral invalidation signal for a changed factory run.
8426
+ */
8427
+ /** @experimental */
8428
+ export interface FactoryRunUpdatedEvent {
8429
+ /**
8430
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
8431
+ */
8432
+ agentId?: string;
8433
+ data: FactoryRunUpdatedData;
8434
+ /**
8435
+ * Always true for events that are transient and not persisted to the session event log on disk.
8436
+ */
8437
+ ephemeral: true;
8438
+ /**
8439
+ * Unique event identifier (UUID v4), generated when the event is emitted
8440
+ */
8441
+ id: string;
8442
+ /**
8443
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
8444
+ */
8445
+ parentId: string | null;
8446
+ /**
8447
+ * ISO 8601 timestamp when the event was created
8448
+ */
8449
+ timestamp: string;
8450
+ /**
8451
+ * Type discriminator. Always "factory.run_updated".
8452
+ */
8453
+ type: "factory.run_updated";
8454
+ }
8455
+ /**
8456
+ * Ephemeral invalidation signal for a changed factory run.
8457
+ */
8458
+ /** @experimental */
8459
+ export interface FactoryRunUpdatedData {
8460
+ /**
8461
+ * Monotonic revision now available for the run.
8462
+ */
8463
+ revision: number;
8464
+ runId: string;
8465
+ }
8212
8466
  /**
8213
8467
  * Session event "session.skills_loaded". Payload of `session.skills_loaded` listing resolved skill metadata.
8214
8468
  */
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@ export { RuntimeConnection } from "./types.js";
8
8
  export { BuiltInTools, ToolSet } from "./toolSet.js";
9
9
  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
- export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
11
+ export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
12
12
  export type * from "./generated/session-events.js";
13
- export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, 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, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
13
+ export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, 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, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  CopilotWebSocketHandler,
17
17
  CopilotWebSocketCloseStatus,
18
18
  CopilotWebSocketForwarder,
19
+ SessionFsSqliteTransactionFailure,
19
20
  SYSTEM_MESSAGE_SECTIONS
20
21
  } from "./types.js";
21
22
  export {
@@ -30,6 +31,7 @@ export {
30
31
  CopilotWebSocketHandler,
31
32
  RuntimeConnection,
32
33
  SYSTEM_MESSAGE_SECTIONS,
34
+ SessionFsSqliteTransactionFailure,
33
35
  ToolSet,
34
36
  approveAll,
35
37
  convertMcpCallToolResult,
package/dist/session.js CHANGED
@@ -7,8 +7,13 @@ function deserializeHookInput(raw) {
7
7
  return raw;
8
8
  }
9
9
  const obj = raw;
10
- const { cwd, ...rest } = obj;
11
- return { ...rest, timestamp: new Date(obj.timestamp), workingDirectory: cwd };
10
+ const { cwd, stop_hook_active, ...rest } = obj;
11
+ return {
12
+ ...rest,
13
+ timestamp: new Date(obj.timestamp),
14
+ workingDirectory: cwd,
15
+ ...stop_hook_active === void 0 ? {} : { stopHookActive: stop_hook_active }
16
+ };
12
17
  }
13
18
  function isOpenCanvasInstance(value) {
14
19
  if (!value || typeof value !== "object") {
@@ -891,7 +896,8 @@ class CopilotSession {
891
896
  userPromptSubmitted: this.hooks.onUserPromptSubmitted,
892
897
  sessionStart: this.hooks.onSessionStart,
893
898
  sessionEnd: this.hooks.onSessionEnd,
894
- errorOccurred: this.hooks.onErrorOccurred
899
+ errorOccurred: this.hooks.onErrorOccurred,
900
+ agentStop: this.hooks.onAgentStop
895
901
  };
896
902
  const handler = handlerMap[hookType];
897
903
  if (!handler) {
@@ -1,5 +1,5 @@
1
- import type { SessionFsHandler, SessionFsStatResult, SessionFsReaddirWithTypesEntry, SessionFsSqliteQueryResult as GeneratedSqliteQueryResult, SessionFsSqliteQueryType } from "./generated/rpc.js";
2
- export type { SessionFsSqliteQueryType };
1
+ import type { SessionFsHandler, SessionFsStatResult, SessionFsReaddirWithTypesEntry, SessionFsSqliteQueryResult as GeneratedSqliteQueryResult, SessionFsSqliteTransactionErrorClass, SessionFsSqliteQueryType } from "./generated/rpc.js";
2
+ export type { SessionFsSqliteQueryType, SessionFsSqliteTransactionErrorClass };
3
3
  /**
4
4
  * File metadata returned by {@link SessionFsProvider.stat}.
5
5
  * Same shape as the generated {@link SessionFsStatResult} but without the
@@ -12,6 +12,31 @@ export type SessionFsFileInfo = Omit<SessionFsStatResult, "error">;
12
12
  * `error` field, since providers signal errors by throwing.
13
13
  */
14
14
  export type SessionFsSqliteQueryResult = Omit<GeneratedSqliteQueryResult, "error">;
15
+ /**
16
+ * One statement in an atomic SQLite transaction passed to
17
+ * {@link SessionFsSqliteProvider.transaction}.
18
+ */
19
+ export interface SessionFsSqliteStatement {
20
+ /** How to execute: `"exec"` for DDL/multi-statement, `"query"` for SELECT, `"run"` for INSERT/UPDATE/DELETE. */
21
+ queryType: SessionFsSqliteQueryType;
22
+ /** SQL statement to execute. */
23
+ query: string;
24
+ /** Optional named bind parameters. */
25
+ params?: Record<string, string | number | null>;
26
+ }
27
+ /**
28
+ * Error thrown by {@link SessionFsSqliteProvider.transaction} to classify a
29
+ * transaction failure for the runtime.
30
+ *
31
+ * Any other thrown value is reported as `"fatal"`. Throw this with
32
+ * `"busyOrLocked"` when SQLite reported BUSY/LOCKED before commit and the
33
+ * transaction was rolled back, so the runtime knows the call is safe to retry.
34
+ */
35
+ export declare class SessionFsSqliteTransactionFailure extends Error {
36
+ /** Failure classification reported to the runtime. */
37
+ readonly errorClass: SessionFsSqliteTransactionErrorClass;
38
+ constructor(message: string, errorClass?: SessionFsSqliteTransactionErrorClass);
39
+ }
15
40
  /**
16
41
  * SQLite operations for the per-session database.
17
42
  * Implementers provide query execution and existence checking.
@@ -25,6 +50,17 @@ export interface SessionFsSqliteProvider {
25
50
  * @param params - Optional named bind parameters.
26
51
  */
27
52
  query(queryType: SessionFsSqliteQueryType, query: string, params?: Record<string, string | number | null>): Promise<SessionFsSqliteQueryResult | undefined>;
53
+ /**
54
+ * Execute `statements` atomically against the per-session database.
55
+ *
56
+ * Apply busy handling to every statement and roll back the whole batch if
57
+ * any statement fails. Throw {@link SessionFsSqliteTransactionFailure} to
58
+ * classify the failure; any other thrown value is reported as `"fatal"`.
59
+ *
60
+ * @param statements - Statements to execute in order inside a single transaction.
61
+ * @returns One result per statement, in the same order.
62
+ */
63
+ transaction?(statements: SessionFsSqliteStatement[]): Promise<SessionFsSqliteQueryResult[]>;
28
64
  /**
29
65
  * Check whether the per-session database already exists, without creating it.
30
66
  */