@github/copilot-sdk 1.0.15-preview.0 → 1.0.15-preview.2

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.
@@ -1807,6 +1807,77 @@ function createSessionRpc(connection, sessionId) {
1807
1807
  }
1808
1808
  },
1809
1809
  /** @experimental */
1810
+ connectors: {
1811
+ /**
1812
+ * Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
1813
+ *
1814
+ * @returns Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
1815
+ */
1816
+ getCapabilities: async () => connection.sendRequest("session.connectors.getCapabilities", { sessionId }),
1817
+ /**
1818
+ * Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
1819
+ *
1820
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
1821
+ */
1822
+ getStatus: async () => connection.sendRequest("session.connectors.getStatus", { sessionId }),
1823
+ /**
1824
+ * Returns the cached Connector catalog for the pinned opaque account selection, fetching it only when this session has no cached catalog.
1825
+ *
1826
+ * @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
1827
+ *
1828
+ * @returns Validated Connector catalog snapshot cached by the session.
1829
+ */
1830
+ list: async (params) => connection.sendRequest("session.connectors.list", { sessionId, ...params }),
1831
+ /**
1832
+ * Refreshes and validates the Connector catalog for the pinned opaque account selection.
1833
+ *
1834
+ * @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
1835
+ *
1836
+ * @returns Validated Connector catalog snapshot cached by the session.
1837
+ */
1838
+ refresh: async (params) => connection.sendRequest("session.connectors.refresh", { sessionId, ...params }),
1839
+ /**
1840
+ * Initiates an idempotent Connector connection request without opening a browser. Returns connected when the service is immediately authoritative, consent_required with a validated URL, or pending with an opaque continuation ID.
1841
+ *
1842
+ * @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
1843
+ *
1844
+ * @returns Typed result of initiating or continuing a Connector connection.
1845
+ */
1846
+ connect: async (params) => connection.sendRequest("session.connectors.connect", { sessionId, ...params }),
1847
+ /**
1848
+ * Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
1849
+ *
1850
+ * @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
1851
+ *
1852
+ * @returns Typed result of initiating or continuing a Connector connection.
1853
+ */
1854
+ reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { sessionId, ...params }),
1855
+ /**
1856
+ * Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
1857
+ *
1858
+ * @param params Explicitly bounded continuation of a pending Connector connection.
1859
+ *
1860
+ * @returns Typed result of initiating or continuing a Connector connection.
1861
+ */
1862
+ continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { sessionId, ...params }),
1863
+ /**
1864
+ * Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
1865
+ *
1866
+ * @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
1867
+ *
1868
+ * @returns Authoritative result after disconnect and MCP reconciliation.
1869
+ */
1870
+ disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { sessionId, ...params }),
1871
+ /**
1872
+ * Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
1873
+ *
1874
+ * @param params Requests authoritative Connector-to-MCP reconciliation for the pinned account.
1875
+ *
1876
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
1877
+ */
1878
+ reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { sessionId, ...params })
1879
+ },
1880
+ /** @experimental */
1810
1881
  managedSettings: {
1811
1882
  /**
1812
1883
  * Waits for the live session's in-flight managed-settings application, then returns the retained effective snapshot used by runtime enforcement and by `session.managed_settings_resolved`. It does not perform another account, device, or server resolution, and rejects when resolution has not produced a snapshot.
@@ -1922,7 +1993,15 @@ function createSessionRpc(connection, sessionId) {
1922
1993
  *
1923
1994
  * @returns The selectable model entries synthesized for the models added by this call.
1924
1995
  */
1925
- add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params })
1996
+ add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params }),
1997
+ /**
1998
+ * Atomically updates the session's BYOK provider and model registry by applying the supplied snapshot, replacing existing entries, updating models, or removing entries absent from the snapshot.
1999
+ *
2000
+ * @param params Authoritative BYOK provider and model registry snapshot to apply atomically to the session.
2001
+ *
2002
+ * @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
2003
+ */
2004
+ sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params })
1926
2005
  },
1927
2006
  /** @experimental */
1928
2007
  options: {
@@ -2248,9 +2327,9 @@ function createSessionRpc(connection, sessionId) {
2248
2327
  */
2249
2328
  setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
2250
2329
  /**
2251
- * Clears session-scoped tool permission approvals.
2330
+ * Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
2252
2331
  *
2253
- * @param params Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
2332
+ * @param params Clears session-scoped tool approvals and optionally clears location-scoped approvals and exact session-approved paths.
2254
2333
  *
2255
2334
  * @returns Indicates whether the operation succeeded.
2256
2335
  */
@@ -2266,9 +2345,9 @@ function createSessionRpc(connection, sessionId) {
2266
2345
  /** @experimental */
2267
2346
  paths: {
2268
2347
  /**
2269
- * Returns the session's allowed directories and primary working directory.
2348
+ * Returns the session's recursive directory grants, exact session-approved paths, and primary working directory.
2270
2349
  *
2271
- * @returns Snapshot of the session's allow-listed directories and primary working directory.
2350
+ * @returns Snapshot of the session's recursive directory grants, exact session-approved paths, and primary working directory.
2272
2351
  */
2273
2352
  list: async () => connection.sendRequest("session.permissions.paths.list", { sessionId }),
2274
2353
  /**
@@ -2943,6 +3022,23 @@ function createInternalSessionRpc(connection, sessionId) {
2943
3022
  unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
2944
3023
  },
2945
3024
  /** @experimental */
3025
+ connectors: {
3026
+ /**
3027
+ * Reconciles the authoritative Connector catalog into the session MCP projection during startup with a bounded deadline and fail-closed cleanup.
3028
+ *
3029
+ * @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
3030
+ *
3031
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
3032
+ */
3033
+ reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { sessionId, ...params }),
3034
+ /**
3035
+ * Removes the runtime-owned Connector MCP projection without changing service-side connections.
3036
+ *
3037
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
3038
+ */
3039
+ withdrawProjection: async () => connection.sendRequest("session.connectors.withdrawProjection", { sessionId })
3040
+ },
3041
+ /** @experimental */
2946
3042
  commands: {
2947
3043
  /**
2948
3044
  * Finalizes persistence associated with a client-applied slash-command effect.
@@ -9,7 +9,7 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
9
9
  /**
10
10
  * Union of all session event variants emitted by the Copilot CLI runtime.
11
11
  */
12
- export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | IndexedSearchEvent | WarningEvent | ModelChangeEvent | AutoTierRecommendationEvent | AutoTierSwitchFailedEvent | ModeChangedEvent | ModeNoticeDeliveredEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ContextChangedEvent | UsageInfoEvent | ContextClearedEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | CompletionReceiptEvent | FusionRouteStartedEvent | FusionRouteFailedEvent | FusionResolvedEvent | FusionCompletedEvent | PermissionRecoveryEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantFusionPhaseStartedEvent | AssistantFusionPhaseActivityEvent | AssistantFusionPhaseCompletedEvent | AssistantFusionPhaseFailedEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallFinishedEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentConfiguredEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | PermissionCarriedForwardEvent | PermissionMessageAuthorizationEvent | PermissionMessageAuthorizationReadEvent | PermissionMessageAuthorizationDegradedEvent | PermissionAssentDetectedEvent | PermissionContextualAuthorizationEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | UIEphemeralQueryEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | FactoryRunUpdatedEvent | FactoryRunStartedEvent | FactoryRunSettledEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpServerRemovedEvent | McpServerNeedsReconnectEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
12
+ export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | IndexedSearchEvent | WarningEvent | ModelChangeEvent | ModelDeselectedEvent | AutoTierRecommendationEvent | AutoTierSwitchFailedEvent | ModeChangedEvent | ModeNoticeDeliveredEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ContextChangedEvent | UsageInfoEvent | ContextClearedEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | CompletionReceiptEvent | FusionRouteStartedEvent | FusionRouteFailedEvent | FusionResolvedEvent | FusionCompletedEvent | PermissionRecoveryEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantFusionPhaseStartedEvent | AssistantFusionPhaseActivityEvent | AssistantFusionPhaseCompletedEvent | AssistantFusionPhaseFailedEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallFinishedEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentConfiguredEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | PermissionCarriedForwardEvent | PermissionMessageAuthorizationEvent | PermissionMessageAuthorizationReadEvent | PermissionMessageAuthorizationDegradedEvent | PermissionAssentDetectedEvent | PermissionContextualAuthorizationEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | UIEphemeralQueryEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | FactoryRunUpdatedEvent | FactoryRunStartedEvent | FactoryRunSettledEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpServerRemovedEvent | McpServerNeedsReconnectEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
13
13
  /**
14
14
  * Routing preference used when the session model is `auto`. `fast` is an integrator-only latency preset and is not a first-party GitHub Copilot product preference.
15
15
  */
@@ -299,6 +299,12 @@ export type ModelChangeSource =
299
299
  | "changeboarding_shortcut"
300
300
  /** An SDK or RPC caller selected the model. */
301
301
  | "sdk";
302
+ /**
303
+ * Why the session no longer has an explicitly selected model.
304
+ */
305
+ export type ModelDeselectedReason =
306
+ /** A host-managed provider snapshot no longer publishes the selected model. */
307
+ "provider_withdrawn";
302
308
  /**
303
309
  * Auto preferences that Copilot API can recommend.
304
310
  */
@@ -2102,6 +2108,46 @@ export interface ModelChangeData {
2102
2108
  source?: ModelChangeSource;
2103
2109
  verbosity?: Verbosity;
2104
2110
  }
2111
+ /**
2112
+ * Session event "session.model_deselected". The model the user had explicitly selected is no longer available, because the host that published it withdrew it, so the session no longer has an explicit selection. The next turn resolves a default as though the user had never chosen a model. Clients should stop presenting the previous model as selected. This event is durable because resume rebuilds the selected model from the event log; without it a resumed session would restore a model its provider no longer serves. Reasoning effort, verbosity, and other session-level preferences are deliberately unchanged, because they belong to the session rather than to the model.
2113
+ */
2114
+ export interface ModelDeselectedEvent {
2115
+ /**
2116
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
2117
+ */
2118
+ agentId?: string;
2119
+ data: ModelDeselectedData;
2120
+ /**
2121
+ * When true, the event is transient and not persisted to the session event log on disk
2122
+ */
2123
+ ephemeral?: boolean;
2124
+ /**
2125
+ * Unique event identifier (UUID v4), generated when the event is emitted
2126
+ */
2127
+ id: string;
2128
+ /**
2129
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
2130
+ */
2131
+ parentId: string | null;
2132
+ /**
2133
+ * ISO 8601 timestamp when the event was created
2134
+ */
2135
+ timestamp: string;
2136
+ /**
2137
+ * Type discriminator. Always "session.model_deselected".
2138
+ */
2139
+ type: "session.model_deselected";
2140
+ }
2141
+ /**
2142
+ * The model the user had explicitly selected is no longer available, because the host that published it withdrew it, so the session no longer has an explicit selection. The next turn resolves a default as though the user had never chosen a model. Clients should stop presenting the previous model as selected. This event is durable because resume rebuilds the selected model from the event log; without it a resumed session would restore a model its provider no longer serves. Reasoning effort, verbosity, and other session-level preferences are deliberately unchanged, because they belong to the session rather than to the model.
2143
+ */
2144
+ export interface ModelDeselectedData {
2145
+ /**
2146
+ * Model that was selected before the host withdrew it.
2147
+ */
2148
+ previousModel: string;
2149
+ reason: ModelDeselectedReason;
2150
+ }
2105
2151
  /**
2106
2152
  * Session event "session.auto_tier_recommendation". Live-only Auto preference recommendation from Copilot API after a successful Auto model call.
2107
2153
  */
@@ -3657,6 +3703,12 @@ export interface FusionResolvedData {
3657
3703
  * Stable identifier for the resolved HydraFusion turn.
3658
3704
  */
3659
3705
  fusionId: string;
3706
+ /**
3707
+ * Short human-readable summary of the selected workflow, suitable for immediate client display after routing. May be absent in older durable events; omit the explanation or derive one from pattern and phasePlan. Display text, not a stable machine-readable value.
3708
+ *
3709
+ * @experimental
3710
+ */
3711
+ hint?: string;
3660
3712
  /**
3661
3713
  * Version of the executable model universe used for selection.
3662
3714
  */
@@ -6196,6 +6248,10 @@ export interface ToolExecutionStartData {
6196
6248
  * Name of the tool being executed
6197
6249
  */
6198
6250
  toolName: string;
6251
+ /**
6252
+ * Human-readable display title for the tool, when the selected tool descriptor has a non-empty title.
6253
+ */
6254
+ toolTitle?: string;
6199
6255
  /**
6200
6256
  * Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
6201
6257
  */
@@ -7719,6 +7775,10 @@ export interface SystemMessageData {
7719
7775
  * The system or developer prompt text sent as model input
7720
7776
  */
7721
7777
  content: string;
7778
+ /**
7779
+ * Optional ordered structured blocks corresponding to content, retained for prompt-cache layout restoration.
7780
+ */
7781
+ contentBlocks?: SystemMessageContentBlock[];
7722
7782
  /**
7723
7783
  * Logical interaction identifier for the model run receiving this prompt
7724
7784
  */
@@ -7730,12 +7790,29 @@ export interface SystemMessageData {
7730
7790
  name?: string;
7731
7791
  role: SystemMessageRole;
7732
7792
  }
7793
+ /**
7794
+ * One persisted structured system-message block and its cache intent
7795
+ */
7796
+ export interface SystemMessageContentBlock {
7797
+ /**
7798
+ * Explicit prompt-cache intent. True places a breakpoint after this block, false suppresses one, and absence preserves the provider's legacy default.
7799
+ */
7800
+ cacheBreakpoint?: boolean;
7801
+ /**
7802
+ * Text content for this system-message block.
7803
+ */
7804
+ content: string;
7805
+ /**
7806
+ * Diagnostic classification indicating whether the block is stable across equivalent sessions.
7807
+ */
7808
+ isStatic?: boolean;
7809
+ }
7733
7810
  /**
7734
7811
  * Metadata about the prompt template and its construction
7735
7812
  */
7736
7813
  export interface SystemMessageMetadata {
7737
7814
  /**
7738
- * Version identifier of the prompt template used
7815
+ * Version identifier of the prompt template or structured prompt layout used
7739
7816
  */
7740
7817
  promptVersion?: string;
7741
7818
  /**
package/dist/index.d.ts CHANGED
@@ -8,8 +8,10 @@ export { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
8
8
  export { BuiltInTools, ToolSet } from "./toolSet.js";
9
9
  export { CopilotSession, type AssistantMessageEvent } from "./session.js";
10
10
  export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./factory.js";
11
+ export { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./workflow.js";
11
12
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
12
13
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
13
14
  export type * from "./generated/session-events.js";
14
15
  export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, 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";
15
16
  export type { RunOptions, ResumeOptions, FactoryLimitOverrides, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryListRunsOptions, FactoryRunsPage, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
17
+ export type { WorkflowRunOptions, WorkflowResumeOptions, WorkflowLimitOverrides, WorkflowResumeErrorCode, SessionWorkflowApi, WorkflowAgentOptions, WorkflowContext, WorkflowDefinition, WorkflowHandle, WorkflowJsonSchema, WorkflowLimits, WorkflowMeta, WorkflowPipelineStage, WorkflowStepOptions, WorkflowRunResult, WorkflowRunStatus, WorkflowRunSummary, WorkflowListRunsOptions, WorkflowRunsPage, WorkflowRunDetail, WorkflowProgressPage, WorkflowProgressLine, WorkflowPhaseObservation, WorkflowPhaseStatus, WorkflowAgentSummary, } from "./workflow.js";
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
3
3
  import { BuiltInTools, ToolSet } from "./toolSet.js";
4
4
  import { CopilotSession } from "./session.js";
5
5
  import { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./factory.js";
6
+ import { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./workflow.js";
6
7
  import {
7
8
  Canvas,
8
9
  CanvasError,
@@ -37,6 +38,7 @@ export {
37
38
  SYSTEM_MESSAGE_SECTIONS,
38
39
  SessionFsSqliteTransactionFailure,
39
40
  ToolSet,
41
+ WorkflowResumeError,
40
42
  approveAll,
41
43
  convertMcpCallToolResult,
42
44
  createAttributedPermissionResult,
@@ -44,5 +46,7 @@ export {
44
46
  createSessionFsAdapter,
45
47
  defineFactory,
46
48
  defineTool,
47
- isFactoryRunTerminal
49
+ defineWorkflow,
50
+ isFactoryRunTerminal,
51
+ isWorkflowRunTerminal
48
52
  };
package/dist/session.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { ModelSwitchAutoTierResult } from "./generated/rpc.js";
3
3
  import type { OpenCanvasInstance } from "./generated/rpc.js";
4
4
  import type { MessageOptions, ResponseSchema, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
5
5
  import { type SessionFactoryApi } from "./factory.js";
6
+ import { type SessionWorkflowApi } from "./workflow.js";
6
7
  /** Assistant message event - the final response from the assistant. */
7
8
  export type AssistantMessageEvent = Extract<SessionEvent, {
8
9
  type: "assistant.message";
@@ -50,6 +51,8 @@ export declare class CopilotSession {
50
51
  private commandHandlers;
51
52
  private factories;
52
53
  private factoryAbortControllers;
54
+ private workflows;
55
+ private workflowAbortControllers;
53
56
  private permissionHandler?;
54
57
  private mcpAuthHandler?;
55
58
  private userInputHandler?;
@@ -75,6 +78,7 @@ export declare class CopilotSession {
75
78
  * change or be removed in future SDK or CLI releases.
76
79
  */
77
80
  readonly factory: SessionFactoryApi;
81
+ readonly workflow: SessionWorkflowApi;
78
82
  /**
79
83
  * Resolve a start/resume envelope into the terminal envelope callers expect.
80
84
  *
@@ -94,6 +98,18 @@ export declare class CopilotSession {
94
98
  * dropped invalidation from leaving the wait pending forever.
95
99
  */
96
100
  private waitForFactoryRun;
101
+ private settleWorkflowRun;
102
+ /**
103
+ * Resolve when a workflow run reaches a terminal status.
104
+ *
105
+ * The subscription is installed *before* the first read so a transition
106
+ * landing between the two cannot be missed, and re-reads are serialized so
107
+ * overlapping invalidation events cannot interleave — the run's revision
108
+ * advances once per operation, so a burst of events is common and must
109
+ * collapse into a single in-flight read. A bounded periodic re-read keeps a
110
+ * dropped invalidation from leaving the wait pending forever.
111
+ */
112
+ private waitForWorkflowRun;
97
113
  /**
98
114
  * Typed session-scoped RPC methods.
99
115
  */