@github/copilot-sdk 1.0.0-beta.9 → 1.0.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.
- package/README.md +13 -9
- package/dist/canvas.d.ts +26 -3
- package/dist/cjs/client.js +118 -40
- package/dist/cjs/extension.js +3 -1
- package/dist/cjs/generated/rpc.js +405 -43
- package/dist/cjs/session.js +46 -5
- package/dist/client.js +118 -40
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +3 -1
- package/dist/generated/rpc.d.ts +3268 -712
- package/dist/generated/rpc.js +404 -43
- package/dist/generated/session-events.d.ts +199 -28
- package/dist/index.d.ts +2 -2
- package/dist/session.d.ts +11 -5
- package/dist/session.js +46 -5
- package/dist/types.d.ts +172 -2
- package/docs/examples.md +7 -4
- package/package.json +4 -4
|
@@ -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 | AutopilotObjectiveChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | PermissionsChangedEvent | 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 | HookProgressEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | CustomNotificationEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | McpAppToolCallCompleteEvent;
|
|
8
|
+
export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | AutopilotObjectiveChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | PermissionsChangedEvent | 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 | HookProgressEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | CustomNotificationEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
|
|
9
9
|
/**
|
|
10
10
|
* Hosting platform type of the repository (github or ado)
|
|
11
11
|
*/
|
|
@@ -14,6 +14,14 @@ export type WorkingDirectoryContextHostType =
|
|
|
14
14
|
"github"
|
|
15
15
|
/** Repository is hosted on Azure DevOps. */
|
|
16
16
|
| "ado";
|
|
17
|
+
/**
|
|
18
|
+
* Allowed values for the `ContextTier` enumeration.
|
|
19
|
+
*/
|
|
20
|
+
export type ContextTier =
|
|
21
|
+
/** Default context tier with standard context window size. */
|
|
22
|
+
"default"
|
|
23
|
+
/** Extended context tier with a larger context window. */
|
|
24
|
+
| "long_context";
|
|
17
25
|
/**
|
|
18
26
|
* Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
|
|
19
27
|
*/
|
|
@@ -103,13 +111,13 @@ export type UserMessageAgentMode =
|
|
|
103
111
|
/** The agent is in shell-focused UI mode. */
|
|
104
112
|
| "shell";
|
|
105
113
|
/**
|
|
106
|
-
* A user message attachment — a file, directory, code selection, blob, or
|
|
114
|
+
* A user message attachment — a file, directory, code selection, blob, GitHub reference, or extension-supplied context payload
|
|
107
115
|
*/
|
|
108
|
-
export type
|
|
116
|
+
export type Attachment = AttachmentFile | AttachmentDirectory | AttachmentSelection | AttachmentGitHubReference | AttachmentBlob | AttachmentExtensionContext;
|
|
109
117
|
/**
|
|
110
118
|
* Type of GitHub reference
|
|
111
119
|
*/
|
|
112
|
-
export type
|
|
120
|
+
export type AttachmentGitHubReferenceType =
|
|
113
121
|
/** GitHub issue reference. */
|
|
114
122
|
"issue"
|
|
115
123
|
/** GitHub pull request reference. */
|
|
@@ -427,6 +435,10 @@ export interface StartData {
|
|
|
427
435
|
*/
|
|
428
436
|
alreadyInUse?: boolean;
|
|
429
437
|
context?: WorkingDirectoryContext;
|
|
438
|
+
/**
|
|
439
|
+
* Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
|
|
440
|
+
*/
|
|
441
|
+
contextTier?: ContextTier | null;
|
|
430
442
|
/**
|
|
431
443
|
* Version string of the Copilot application
|
|
432
444
|
*/
|
|
@@ -538,6 +550,10 @@ export interface ResumeData {
|
|
|
538
550
|
*/
|
|
539
551
|
alreadyInUse?: boolean;
|
|
540
552
|
context?: WorkingDirectoryContext;
|
|
553
|
+
/**
|
|
554
|
+
* Context tier currently selected at resume time; null when no tier is active
|
|
555
|
+
*/
|
|
556
|
+
contextTier?: ContextTier | null;
|
|
541
557
|
/**
|
|
542
558
|
* 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.
|
|
543
559
|
*/
|
|
@@ -546,6 +562,10 @@ export interface ResumeData {
|
|
|
546
562
|
* Total number of persisted events in the session at the time of resume
|
|
547
563
|
*/
|
|
548
564
|
eventCount: number;
|
|
565
|
+
/**
|
|
566
|
+
* On-disk byte size of the session's persisted events.jsonl file at resume time; omitted when the file does not exist or cannot be stat'd
|
|
567
|
+
*/
|
|
568
|
+
eventsFileSizeBytes?: number;
|
|
549
569
|
/**
|
|
550
570
|
* Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
|
|
551
571
|
*/
|
|
@@ -679,7 +699,7 @@ export interface ErrorData {
|
|
|
679
699
|
url?: string;
|
|
680
700
|
}
|
|
681
701
|
/**
|
|
682
|
-
* Session event "session.idle". Payload indicating the session is idle with no background agents in flight
|
|
702
|
+
* Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
|
|
683
703
|
*/
|
|
684
704
|
export interface IdleEvent {
|
|
685
705
|
/**
|
|
@@ -709,7 +729,7 @@ export interface IdleEvent {
|
|
|
709
729
|
type: "session.idle";
|
|
710
730
|
}
|
|
711
731
|
/**
|
|
712
|
-
* Payload indicating the session is idle with no background agents in flight
|
|
732
|
+
* Payload indicating the session is idle with no background agents or attached shell commands in flight
|
|
713
733
|
*/
|
|
714
734
|
export interface IdleData {
|
|
715
735
|
/**
|
|
@@ -790,6 +810,14 @@ export interface ScheduleCreatedEvent {
|
|
|
790
810
|
* Scheduled prompt registered via /every or /after
|
|
791
811
|
*/
|
|
792
812
|
export interface ScheduleCreatedData {
|
|
813
|
+
/**
|
|
814
|
+
* Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
|
|
815
|
+
*/
|
|
816
|
+
at?: number;
|
|
817
|
+
/**
|
|
818
|
+
* 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
|
|
819
|
+
*/
|
|
820
|
+
cron?: string;
|
|
793
821
|
/**
|
|
794
822
|
* Optional user-facing label shown in the timeline instead of the actual prompt (e.g. `/skill-name args` when the prompt is a skill invocation expansion)
|
|
795
823
|
*/
|
|
@@ -799,9 +827,9 @@ export interface ScheduleCreatedData {
|
|
|
799
827
|
*/
|
|
800
828
|
id: number;
|
|
801
829
|
/**
|
|
802
|
-
* Interval between ticks in milliseconds
|
|
830
|
+
* Interval between ticks in milliseconds (relative-interval schedules)
|
|
803
831
|
*/
|
|
804
|
-
intervalMs
|
|
832
|
+
intervalMs?: number;
|
|
805
833
|
/**
|
|
806
834
|
* Prompt text that gets enqueued on every tick
|
|
807
835
|
*/
|
|
@@ -810,6 +838,10 @@ export interface ScheduleCreatedData {
|
|
|
810
838
|
* Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
|
|
811
839
|
*/
|
|
812
840
|
recurring?: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* IANA timezone the `cron` expression is evaluated in
|
|
843
|
+
*/
|
|
844
|
+
tz?: string;
|
|
813
845
|
}
|
|
814
846
|
/**
|
|
815
847
|
* Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
|
|
@@ -1030,9 +1062,7 @@ export interface ModelChangeData {
|
|
|
1030
1062
|
/**
|
|
1031
1063
|
* Context tier after the model change; null explicitly clears a previously selected tier
|
|
1032
1064
|
*/
|
|
1033
|
-
contextTier?:
|
|
1034
|
-
/** Extended context tier with a larger context window. */
|
|
1035
|
-
| "long_context" | null;
|
|
1065
|
+
contextTier?: ContextTier | null;
|
|
1036
1066
|
/**
|
|
1037
1067
|
* Newly selected model identifier
|
|
1038
1068
|
*/
|
|
@@ -1443,6 +1473,10 @@ export interface ShutdownData {
|
|
|
1443
1473
|
* Error description when shutdownType is "error"
|
|
1444
1474
|
*/
|
|
1445
1475
|
errorReason?: string;
|
|
1476
|
+
/**
|
|
1477
|
+
* On-disk byte size of the session's persisted events.jsonl file at shutdown time; omitted when the file does not exist or cannot be stat'd
|
|
1478
|
+
*/
|
|
1479
|
+
eventsFileSizeBytes?: number;
|
|
1446
1480
|
/**
|
|
1447
1481
|
* Per-model usage breakdown, keyed by model identifier
|
|
1448
1482
|
*/
|
|
@@ -1946,7 +1980,7 @@ export interface UserMessageData {
|
|
|
1946
1980
|
/**
|
|
1947
1981
|
* Files, selections, or GitHub references attached to the message
|
|
1948
1982
|
*/
|
|
1949
|
-
attachments?:
|
|
1983
|
+
attachments?: Attachment[];
|
|
1950
1984
|
/**
|
|
1951
1985
|
* The user's message text as displayed in the timeline
|
|
1952
1986
|
*/
|
|
@@ -1983,12 +2017,12 @@ export interface UserMessageData {
|
|
|
1983
2017
|
/**
|
|
1984
2018
|
* File attachment
|
|
1985
2019
|
*/
|
|
1986
|
-
export interface
|
|
2020
|
+
export interface AttachmentFile {
|
|
1987
2021
|
/**
|
|
1988
2022
|
* User-facing display name for the attachment
|
|
1989
2023
|
*/
|
|
1990
2024
|
displayName: string;
|
|
1991
|
-
lineRange?:
|
|
2025
|
+
lineRange?: AttachmentFileLineRange;
|
|
1992
2026
|
/**
|
|
1993
2027
|
* Absolute file path
|
|
1994
2028
|
*/
|
|
@@ -2001,7 +2035,7 @@ export interface UserMessageAttachmentFile {
|
|
|
2001
2035
|
/**
|
|
2002
2036
|
* Optional line range to scope the attachment to a specific section of the file
|
|
2003
2037
|
*/
|
|
2004
|
-
export interface
|
|
2038
|
+
export interface AttachmentFileLineRange {
|
|
2005
2039
|
/**
|
|
2006
2040
|
* End line number (1-based, inclusive)
|
|
2007
2041
|
*/
|
|
@@ -2014,7 +2048,7 @@ export interface UserMessageAttachmentFileLineRange {
|
|
|
2014
2048
|
/**
|
|
2015
2049
|
* Directory attachment
|
|
2016
2050
|
*/
|
|
2017
|
-
export interface
|
|
2051
|
+
export interface AttachmentDirectory {
|
|
2018
2052
|
/**
|
|
2019
2053
|
* User-facing display name for the attachment
|
|
2020
2054
|
*/
|
|
@@ -2031,7 +2065,7 @@ export interface UserMessageAttachmentDirectory {
|
|
|
2031
2065
|
/**
|
|
2032
2066
|
* Code selection attachment from an editor
|
|
2033
2067
|
*/
|
|
2034
|
-
export interface
|
|
2068
|
+
export interface AttachmentSelection {
|
|
2035
2069
|
/**
|
|
2036
2070
|
* User-facing display name for the selection
|
|
2037
2071
|
*/
|
|
@@ -2040,7 +2074,7 @@ export interface UserMessageAttachmentSelection {
|
|
|
2040
2074
|
* Absolute path to the file containing the selection
|
|
2041
2075
|
*/
|
|
2042
2076
|
filePath: string;
|
|
2043
|
-
selection:
|
|
2077
|
+
selection: AttachmentSelectionDetails;
|
|
2044
2078
|
/**
|
|
2045
2079
|
* The selected text content
|
|
2046
2080
|
*/
|
|
@@ -2053,14 +2087,14 @@ export interface UserMessageAttachmentSelection {
|
|
|
2053
2087
|
/**
|
|
2054
2088
|
* Position range of the selection within the file
|
|
2055
2089
|
*/
|
|
2056
|
-
export interface
|
|
2057
|
-
end:
|
|
2058
|
-
start:
|
|
2090
|
+
export interface AttachmentSelectionDetails {
|
|
2091
|
+
end: AttachmentSelectionDetailsEnd;
|
|
2092
|
+
start: AttachmentSelectionDetailsStart;
|
|
2059
2093
|
}
|
|
2060
2094
|
/**
|
|
2061
2095
|
* End position of the selection
|
|
2062
2096
|
*/
|
|
2063
|
-
export interface
|
|
2097
|
+
export interface AttachmentSelectionDetailsEnd {
|
|
2064
2098
|
/**
|
|
2065
2099
|
* End character offset within the line (0-based)
|
|
2066
2100
|
*/
|
|
@@ -2073,7 +2107,7 @@ export interface UserMessageAttachmentSelectionDetailsEnd {
|
|
|
2073
2107
|
/**
|
|
2074
2108
|
* Start position of the selection
|
|
2075
2109
|
*/
|
|
2076
|
-
export interface
|
|
2110
|
+
export interface AttachmentSelectionDetailsStart {
|
|
2077
2111
|
/**
|
|
2078
2112
|
* Start character offset within the line (0-based)
|
|
2079
2113
|
*/
|
|
@@ -2086,12 +2120,12 @@ export interface UserMessageAttachmentSelectionDetailsStart {
|
|
|
2086
2120
|
/**
|
|
2087
2121
|
* GitHub issue, pull request, or discussion reference
|
|
2088
2122
|
*/
|
|
2089
|
-
export interface
|
|
2123
|
+
export interface AttachmentGitHubReference {
|
|
2090
2124
|
/**
|
|
2091
2125
|
* Issue, pull request, or discussion number
|
|
2092
2126
|
*/
|
|
2093
2127
|
number: number;
|
|
2094
|
-
referenceType:
|
|
2128
|
+
referenceType: AttachmentGitHubReferenceType;
|
|
2095
2129
|
/**
|
|
2096
2130
|
* Current state of the referenced item (e.g., open, closed, merged)
|
|
2097
2131
|
*/
|
|
@@ -2112,7 +2146,7 @@ export interface UserMessageAttachmentGithubReference {
|
|
|
2112
2146
|
/**
|
|
2113
2147
|
* Blob attachment with inline base64-encoded data
|
|
2114
2148
|
*/
|
|
2115
|
-
export interface
|
|
2149
|
+
export interface AttachmentBlob {
|
|
2116
2150
|
/**
|
|
2117
2151
|
* Base64-encoded content
|
|
2118
2152
|
*/
|
|
@@ -2130,6 +2164,41 @@ export interface UserMessageAttachmentBlob {
|
|
|
2130
2164
|
*/
|
|
2131
2165
|
type: "blob";
|
|
2132
2166
|
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Structured context contributed by an extension. Composer pills displayed in the host are forwarded back through session.send.attachments, then rendered into the model prompt as an <extension_context> XML block.
|
|
2169
|
+
*/
|
|
2170
|
+
export interface AttachmentExtensionContext {
|
|
2171
|
+
/**
|
|
2172
|
+
* Provider-local canvas identifier when the push was bound to a canvas instance
|
|
2173
|
+
*/
|
|
2174
|
+
canvasId?: string;
|
|
2175
|
+
/**
|
|
2176
|
+
* ISO 8601 timestamp captured by the runtime when the push was accepted
|
|
2177
|
+
*/
|
|
2178
|
+
capturedAt: string;
|
|
2179
|
+
/**
|
|
2180
|
+
* Owning extension identifier. Runtime-derived from the caller's connection when produced via session.extensions.sendAttachmentsToMessage; preserved verbatim on subsequent transports.
|
|
2181
|
+
*/
|
|
2182
|
+
extensionId: string;
|
|
2183
|
+
/**
|
|
2184
|
+
* Open canvas instance identifier when the push was bound to a canvas instance
|
|
2185
|
+
*/
|
|
2186
|
+
instanceId?: string;
|
|
2187
|
+
/**
|
|
2188
|
+
* Caller-supplied JSON payload
|
|
2189
|
+
*/
|
|
2190
|
+
payload?: {
|
|
2191
|
+
[k: string]: unknown | undefined;
|
|
2192
|
+
};
|
|
2193
|
+
/**
|
|
2194
|
+
* Human-readable composer pill label
|
|
2195
|
+
*/
|
|
2196
|
+
title: string;
|
|
2197
|
+
/**
|
|
2198
|
+
* Attachment type discriminator
|
|
2199
|
+
*/
|
|
2200
|
+
type: "extension_context";
|
|
2201
|
+
}
|
|
2133
2202
|
/**
|
|
2134
2203
|
* Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
|
|
2135
2204
|
*/
|
|
@@ -2418,6 +2487,10 @@ export interface AssistantMessageData {
|
|
|
2418
2487
|
* @experimental
|
|
2419
2488
|
*/
|
|
2420
2489
|
anthropicAdvisorModel?: string;
|
|
2490
|
+
/**
|
|
2491
|
+
* Provider's completion / response identifier; shared across all chunks of a single API call. Used to group multi-chunk assistant utterances.
|
|
2492
|
+
*/
|
|
2493
|
+
apiCallId?: string;
|
|
2421
2494
|
/**
|
|
2422
2495
|
* The assistant's text response content
|
|
2423
2496
|
*/
|
|
@@ -2971,6 +3044,10 @@ export interface ToolExecutionStartData {
|
|
|
2971
3044
|
* Original tool name on the MCP server, when the tool is an MCP tool
|
|
2972
3045
|
*/
|
|
2973
3046
|
mcpToolName?: string;
|
|
3047
|
+
/**
|
|
3048
|
+
* Model identifier that generated this tool call
|
|
3049
|
+
*/
|
|
3050
|
+
model?: string;
|
|
2974
3051
|
/**
|
|
2975
3052
|
* @deprecated
|
|
2976
3053
|
* Tool call ID of the parent tool invocation when this event originates from a sub-agent
|
|
@@ -3577,7 +3654,7 @@ export interface SubagentStartedData {
|
|
|
3577
3654
|
*/
|
|
3578
3655
|
agentName: string;
|
|
3579
3656
|
/**
|
|
3580
|
-
* Model the sub-agent will run with, when known at start.
|
|
3657
|
+
* Model the sub-agent will run with, when known at start.
|
|
3581
3658
|
*/
|
|
3582
3659
|
model?: string;
|
|
3583
3660
|
/**
|
|
@@ -3699,7 +3776,7 @@ export interface SubagentFailedData {
|
|
|
3699
3776
|
*/
|
|
3700
3777
|
error: string;
|
|
3701
3778
|
/**
|
|
3702
|
-
* Model
|
|
3779
|
+
* Model selected for the sub-agent, when known
|
|
3703
3780
|
*/
|
|
3704
3781
|
model?: string;
|
|
3705
3782
|
/**
|
|
@@ -3908,6 +3985,10 @@ export interface HookEndError {
|
|
|
3908
3985
|
* Human-readable error message
|
|
3909
3986
|
*/
|
|
3910
3987
|
message: string;
|
|
3988
|
+
/**
|
|
3989
|
+
* Source label of the hook that errored (e.g. the plugin it was loaded from), when known
|
|
3990
|
+
*/
|
|
3991
|
+
source?: string;
|
|
3911
3992
|
/**
|
|
3912
3993
|
* Error stack trace, when available
|
|
3913
3994
|
*/
|
|
@@ -3951,6 +4032,10 @@ export interface HookProgressData {
|
|
|
3951
4032
|
* Human-readable progress message from the hook process
|
|
3952
4033
|
*/
|
|
3953
4034
|
message: string;
|
|
4035
|
+
/**
|
|
4036
|
+
* When true, this status message replaces the previous temporary one instead of accumulating
|
|
4037
|
+
*/
|
|
4038
|
+
temporary?: boolean;
|
|
3954
4039
|
}
|
|
3955
4040
|
/**
|
|
3956
4041
|
* Session event "system.message". System/developer instruction content with role and optional template metadata
|
|
@@ -6646,6 +6731,92 @@ export interface CanvasRegistryChangedCanvasAction {
|
|
|
6646
6731
|
*/
|
|
6647
6732
|
name: string;
|
|
6648
6733
|
}
|
|
6734
|
+
/**
|
|
6735
|
+
* Session event "session.canvas.closed".
|
|
6736
|
+
*/
|
|
6737
|
+
export interface CanvasClosedEvent {
|
|
6738
|
+
/**
|
|
6739
|
+
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
|
6740
|
+
*/
|
|
6741
|
+
agentId?: string;
|
|
6742
|
+
data: CanvasClosedData;
|
|
6743
|
+
/**
|
|
6744
|
+
* Always true for events that are transient and not persisted to the session event log on disk.
|
|
6745
|
+
*/
|
|
6746
|
+
ephemeral: true;
|
|
6747
|
+
/**
|
|
6748
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
6749
|
+
*/
|
|
6750
|
+
id: string;
|
|
6751
|
+
/**
|
|
6752
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
6753
|
+
*/
|
|
6754
|
+
parentId: string | null;
|
|
6755
|
+
/**
|
|
6756
|
+
* ISO 8601 timestamp when the event was created
|
|
6757
|
+
*/
|
|
6758
|
+
timestamp: string;
|
|
6759
|
+
/**
|
|
6760
|
+
* Type discriminator. Always "session.canvas.closed".
|
|
6761
|
+
*/
|
|
6762
|
+
type: "session.canvas.closed";
|
|
6763
|
+
}
|
|
6764
|
+
/**
|
|
6765
|
+
* Schema for the `CanvasClosedData` type.
|
|
6766
|
+
*/
|
|
6767
|
+
export interface CanvasClosedData {
|
|
6768
|
+
/**
|
|
6769
|
+
* Provider-local canvas identifier
|
|
6770
|
+
*/
|
|
6771
|
+
canvasId: string;
|
|
6772
|
+
/**
|
|
6773
|
+
* Owning provider identifier
|
|
6774
|
+
*/
|
|
6775
|
+
extensionId: string;
|
|
6776
|
+
/**
|
|
6777
|
+
* Stable caller-supplied identifier of the canvas instance that was closed
|
|
6778
|
+
*/
|
|
6779
|
+
instanceId: string;
|
|
6780
|
+
}
|
|
6781
|
+
/**
|
|
6782
|
+
* Session event "session.extensions.attachments_pushed".
|
|
6783
|
+
*/
|
|
6784
|
+
export interface ExtensionsAttachmentsPushedEvent {
|
|
6785
|
+
/**
|
|
6786
|
+
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
|
6787
|
+
*/
|
|
6788
|
+
agentId?: string;
|
|
6789
|
+
data: ExtensionsAttachmentsPushedData;
|
|
6790
|
+
/**
|
|
6791
|
+
* Always true for events that are transient and not persisted to the session event log on disk.
|
|
6792
|
+
*/
|
|
6793
|
+
ephemeral: true;
|
|
6794
|
+
/**
|
|
6795
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
6796
|
+
*/
|
|
6797
|
+
id: string;
|
|
6798
|
+
/**
|
|
6799
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
6800
|
+
*/
|
|
6801
|
+
parentId: string | null;
|
|
6802
|
+
/**
|
|
6803
|
+
* ISO 8601 timestamp when the event was created
|
|
6804
|
+
*/
|
|
6805
|
+
timestamp: string;
|
|
6806
|
+
/**
|
|
6807
|
+
* Type discriminator. Always "session.extensions.attachments_pushed".
|
|
6808
|
+
*/
|
|
6809
|
+
type: "session.extensions.attachments_pushed";
|
|
6810
|
+
}
|
|
6811
|
+
/**
|
|
6812
|
+
* Schema for the `ExtensionsAttachmentsPushedData` type.
|
|
6813
|
+
*/
|
|
6814
|
+
export interface ExtensionsAttachmentsPushedData {
|
|
6815
|
+
/**
|
|
6816
|
+
* Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
|
|
6817
|
+
*/
|
|
6818
|
+
attachments: Attachment[];
|
|
6819
|
+
}
|
|
6649
6820
|
/**
|
|
6650
6821
|
* Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
|
|
6651
6822
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { CopilotClient } from "./client.js";
|
|
|
7
7
|
export { RuntimeConnection } from "./types.js";
|
|
8
8
|
export { BuiltInTools, ToolSet } from "./toolSet.js";
|
|
9
9
|
export { CopilotSession, type AssistantMessageEvent } from "./session.js";
|
|
10
|
-
export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
|
|
10
|
+
export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
|
|
11
11
|
export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
|
|
12
12
|
export type * from "./generated/session-events.js";
|
|
13
|
-
export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, CopilotClientMode, CopilotClientOptions, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolTelemetry, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
|
13
|
+
export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, CopilotClientMode, CopilotClientOptions, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, LargeToolOutputConfig, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolTelemetry, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
package/dist/session.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createSessionRpc } from "./generated/rpc.js";
|
|
2
2
|
import type { OpenCanvasInstance } from "./generated/rpc.js";
|
|
3
|
-
import type { MessageOptions, ReasoningEffort, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
|
|
3
|
+
import type { MessageOptions, ContextTier, ReasoningEffort, ReasoningSummary, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
|
|
4
4
|
/** Assistant message event - the final response from the assistant. */
|
|
5
5
|
export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
6
6
|
type: "assistant.message";
|
|
@@ -169,11 +169,15 @@ export declare class CopilotSession {
|
|
|
169
169
|
* ```
|
|
170
170
|
*/
|
|
171
171
|
on(handler: SessionEventHandler): () => void;
|
|
172
|
+
private upsertOpenCanvasFromEvent;
|
|
173
|
+
private removeOpenCanvasFromEvent;
|
|
174
|
+
private removeOpenCanvas;
|
|
175
|
+
private upsertOpenCanvas;
|
|
172
176
|
/**
|
|
173
|
-
* Snapshot of canvas instances
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* has no effect on the session.
|
|
177
|
+
* Snapshot of canvas instances currently known to be open for this session.
|
|
178
|
+
* Populated from the `session.resume` response and live `session.canvas.opened`
|
|
179
|
+
* and `session.canvas.closed` events. Returns a defensive copy — mutating the
|
|
180
|
+
* returned array has no effect on the session.
|
|
177
181
|
*/
|
|
178
182
|
get openCanvases(): OpenCanvasInstance[];
|
|
179
183
|
private assertElicitation;
|
|
@@ -261,6 +265,8 @@ export declare class CopilotSession {
|
|
|
261
265
|
*/
|
|
262
266
|
setModel(model: string, options?: {
|
|
263
267
|
reasoningEffort?: ReasoningEffort;
|
|
268
|
+
reasoningSummary?: ReasoningSummary;
|
|
269
|
+
contextTier?: ContextTier;
|
|
264
270
|
modelCapabilities?: ModelCapabilitiesOverride;
|
|
265
271
|
}): Promise<void>;
|
|
266
272
|
/**
|
package/dist/session.js
CHANGED
|
@@ -10,6 +10,13 @@ function deserializeHookInput(raw) {
|
|
|
10
10
|
const { cwd, ...rest } = obj;
|
|
11
11
|
return { ...rest, timestamp: new Date(obj.timestamp), workingDirectory: cwd };
|
|
12
12
|
}
|
|
13
|
+
function isOpenCanvasInstance(value) {
|
|
14
|
+
if (!value || typeof value !== "object") {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const instance = value;
|
|
18
|
+
return typeof instance.instanceId === "string" && instance.instanceId.length > 0 && typeof instance.extensionId === "string" && instance.extensionId.length > 0 && typeof instance.canvasId === "string" && instance.canvasId.length > 0 && typeof instance.reopen === "boolean" && (instance.availability === "ready" || instance.availability === "stale");
|
|
19
|
+
}
|
|
13
20
|
class CopilotSession {
|
|
14
21
|
/**
|
|
15
22
|
* Creates a new CopilotSession instance.
|
|
@@ -94,6 +101,7 @@ class CopilotSession {
|
|
|
94
101
|
...await getTraceContext(this.traceContextProvider),
|
|
95
102
|
sessionId: this.sessionId,
|
|
96
103
|
prompt: options.prompt,
|
|
104
|
+
displayPrompt: options.displayPrompt,
|
|
97
105
|
attachments: options.attachments,
|
|
98
106
|
mode: options.mode,
|
|
99
107
|
agentMode: options.agentMode,
|
|
@@ -243,6 +251,39 @@ class CopilotSession {
|
|
|
243
251
|
}
|
|
244
252
|
} else if (event.type === "capabilities.changed") {
|
|
245
253
|
this._capabilities = { ...this._capabilities, ...event.data };
|
|
254
|
+
} else if (event.type === "session.canvas.opened") {
|
|
255
|
+
this.upsertOpenCanvasFromEvent(event.data);
|
|
256
|
+
} else if (event.type === "session.canvas.closed") {
|
|
257
|
+
this.removeOpenCanvasFromEvent(event.data);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
upsertOpenCanvasFromEvent(data) {
|
|
261
|
+
if (!isOpenCanvasInstance(data)) {
|
|
262
|
+
console.warn("failed to deserialize session.canvas.opened payload");
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.upsertOpenCanvas(data);
|
|
266
|
+
}
|
|
267
|
+
removeOpenCanvasFromEvent(data) {
|
|
268
|
+
if (!data || typeof data !== "object" || typeof data.instanceId !== "string" || data.instanceId.length === 0) {
|
|
269
|
+
console.warn("failed to deserialize session.canvas.closed payload");
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
this.removeOpenCanvas(data.instanceId);
|
|
273
|
+
}
|
|
274
|
+
removeOpenCanvas(instanceId) {
|
|
275
|
+
this.openCanvasInstances = this.openCanvasInstances.filter(
|
|
276
|
+
(open) => open.instanceId !== instanceId
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
upsertOpenCanvas(instance) {
|
|
280
|
+
const index = this.openCanvasInstances.findIndex(
|
|
281
|
+
(open) => open.instanceId === instance.instanceId
|
|
282
|
+
);
|
|
283
|
+
if (index >= 0) {
|
|
284
|
+
this.openCanvasInstances[index] = instance;
|
|
285
|
+
} else {
|
|
286
|
+
this.openCanvasInstances.push(instance);
|
|
246
287
|
}
|
|
247
288
|
}
|
|
248
289
|
/**
|
|
@@ -409,7 +450,7 @@ class CopilotSession {
|
|
|
409
450
|
throw toCanvasRpcError(error);
|
|
410
451
|
}
|
|
411
452
|
},
|
|
412
|
-
async
|
|
453
|
+
async invoke(params) {
|
|
413
454
|
const canvas = self.canvases.get(params.canvasId);
|
|
414
455
|
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
415
456
|
const handler = canvas.actionHandlers.get(params.actionName);
|
|
@@ -524,10 +565,10 @@ class CopilotSession {
|
|
|
524
565
|
this._capabilities = capabilities ?? {};
|
|
525
566
|
}
|
|
526
567
|
/**
|
|
527
|
-
* Snapshot of canvas instances
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* has no effect on the session.
|
|
568
|
+
* Snapshot of canvas instances currently known to be open for this session.
|
|
569
|
+
* Populated from the `session.resume` response and live `session.canvas.opened`
|
|
570
|
+
* and `session.canvas.closed` events. Returns a defensive copy — mutating the
|
|
571
|
+
* returned array has no effect on the session.
|
|
531
572
|
*/
|
|
532
573
|
get openCanvases() {
|
|
533
574
|
return [...this.openCanvasInstances];
|