@github/copilot-sdk 1.0.0-beta.9 → 1.0.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.
- package/README.md +12 -8
- 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 +57 -16
- package/dist/cjs/session.js +32 -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 +513 -297
- package/dist/generated/rpc.js +57 -16
- package/dist/generated/session-events.d.ts +114 -22
- package/dist/index.d.ts +2 -2
- package/dist/session.d.ts +9 -5
- package/dist/session.js +32 -5
- package/dist/types.d.ts +172 -2
- package/docs/examples.md +7 -4
- package/package.json +3 -3
package/dist/generated/rpc.js
CHANGED
|
@@ -85,7 +85,11 @@ function createServerRpc(connection) {
|
|
|
85
85
|
*
|
|
86
86
|
* @param params MCP server names to disable for new sessions.
|
|
87
87
|
*/
|
|
88
|
-
disable: async (params) => connection.sendRequest("mcp.config.disable", params)
|
|
88
|
+
disable: async (params) => connection.sendRequest("mcp.config.disable", params),
|
|
89
|
+
/**
|
|
90
|
+
* Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
|
|
91
|
+
*/
|
|
92
|
+
reload: async () => connection.sendRequest("mcp.config.reload", {})
|
|
89
93
|
},
|
|
90
94
|
/**
|
|
91
95
|
* Discovers MCP servers from user, workspace, plugin, and builtin sources.
|
|
@@ -114,6 +118,20 @@ function createServerRpc(connection) {
|
|
|
114
118
|
*/
|
|
115
119
|
discover: async (params) => connection.sendRequest("skills.discover", params)
|
|
116
120
|
},
|
|
121
|
+
user: {
|
|
122
|
+
settings: {
|
|
123
|
+
/**
|
|
124
|
+
* Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
|
|
125
|
+
*/
|
|
126
|
+
reload: async () => connection.sendRequest("user.settings.reload", {})
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
runtime: {
|
|
130
|
+
/**
|
|
131
|
+
* Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
|
|
132
|
+
*/
|
|
133
|
+
shutdown: async () => connection.sendRequest("runtime.shutdown", {})
|
|
134
|
+
},
|
|
117
135
|
sessionFs: {
|
|
118
136
|
/**
|
|
119
137
|
* Registers an SDK client as the session filesystem provider.
|
|
@@ -383,27 +401,30 @@ function createSessionRpc(connection, sessionId) {
|
|
|
383
401
|
* @param params Canvas close parameters.
|
|
384
402
|
*/
|
|
385
403
|
close: async (params) => connection.sendRequest("session.canvas.close", { sessionId, ...params }),
|
|
386
|
-
/**
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
404
|
+
/** @experimental */
|
|
405
|
+
action: {
|
|
406
|
+
/**
|
|
407
|
+
* Invokes an action on an open canvas instance.
|
|
408
|
+
*
|
|
409
|
+
* @param params Canvas action invocation parameters.
|
|
410
|
+
*
|
|
411
|
+
* @returns Canvas action invocation result.
|
|
412
|
+
*/
|
|
413
|
+
invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { sessionId, ...params })
|
|
414
|
+
}
|
|
394
415
|
},
|
|
395
416
|
/** @experimental */
|
|
396
417
|
model: {
|
|
397
418
|
/**
|
|
398
419
|
* Gets the currently selected model for the session.
|
|
399
420
|
*
|
|
400
|
-
* @returns The currently selected model
|
|
421
|
+
* @returns The currently selected model, reasoning effort, and context tier for the session. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
|
|
401
422
|
*/
|
|
402
423
|
getCurrent: async () => connection.sendRequest("session.model.getCurrent", { sessionId }),
|
|
403
424
|
/**
|
|
404
425
|
* Switches the session to a model and optional reasoning configuration.
|
|
405
426
|
*
|
|
406
|
-
* @param params Target model identifier and optional reasoning effort, summary, and
|
|
427
|
+
* @param params Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
|
|
407
428
|
*
|
|
408
429
|
* @returns The model identifier active on the session after the switch.
|
|
409
430
|
*/
|
|
@@ -415,7 +436,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
415
436
|
*
|
|
416
437
|
* @returns Update the session's reasoning effort without changing the selected model. Use `switchTo` instead when you also need to change the model. The runtime stores the effort on the session and applies it to subsequent turns.
|
|
417
438
|
*/
|
|
418
|
-
setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params })
|
|
439
|
+
setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params }),
|
|
440
|
+
/**
|
|
441
|
+
* Lists models available to this session using its own auth and integration context. Connected hosts (CLI TUI, GitHub App) should call this through the session client so remote sessions return the remote CLI's available models rather than the caller's.
|
|
442
|
+
*
|
|
443
|
+
* @param params Optional listing options.
|
|
444
|
+
*
|
|
445
|
+
* @returns The list of models available to this session.
|
|
446
|
+
*/
|
|
447
|
+
list: async (params) => connection.sendRequest("session.model.list", { sessionId, ...params })
|
|
419
448
|
},
|
|
420
449
|
/** @experimental */
|
|
421
450
|
mode: {
|
|
@@ -869,7 +898,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
869
898
|
/**
|
|
870
899
|
* Reloads extension definitions and processes for the session.
|
|
871
900
|
*/
|
|
872
|
-
reload: async () => connection.sendRequest("session.extensions.reload", { sessionId })
|
|
901
|
+
reload: async () => connection.sendRequest("session.extensions.reload", { sessionId }),
|
|
902
|
+
/**
|
|
903
|
+
* Push attachments into the next user-message turn from an extension. The host should surface them as composer pills and forward them via the next session.send call. Callable only by extension-owned connections.
|
|
904
|
+
*
|
|
905
|
+
* @param params Parameters for session.extensions.sendAttachmentsToMessage.
|
|
906
|
+
*/
|
|
907
|
+
sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { sessionId, ...params })
|
|
873
908
|
},
|
|
874
909
|
/** @experimental */
|
|
875
910
|
tools: {
|
|
@@ -886,7 +921,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
886
921
|
*
|
|
887
922
|
* @returns Resolve, build, and validate the runtime tool list for this session. Subagent sessions and consumer flows that need an initialized tool set before `send` invoke this. Default base-class implementation is a no-op for sessions that don't support tool validation.
|
|
888
923
|
*/
|
|
889
|
-
initializeAndValidate: async () => connection.sendRequest("session.tools.initializeAndValidate", { sessionId })
|
|
924
|
+
initializeAndValidate: async () => connection.sendRequest("session.tools.initializeAndValidate", { sessionId }),
|
|
925
|
+
/**
|
|
926
|
+
* Returns lightweight metadata for the session's currently initialized tools.
|
|
927
|
+
*
|
|
928
|
+
* @returns Current lightweight tool metadata snapshot for the session.
|
|
929
|
+
*/
|
|
930
|
+
getCurrentMetadata: async () => connection.sendRequest("session.tools.getCurrentMetadata", { sessionId })
|
|
890
931
|
},
|
|
891
932
|
/** @experimental */
|
|
892
933
|
commands: {
|
|
@@ -1475,10 +1516,10 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
1475
1516
|
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1476
1517
|
return handler.close(params);
|
|
1477
1518
|
});
|
|
1478
|
-
connection.onRequest("canvas.
|
|
1519
|
+
connection.onRequest("canvas.action.invoke", async (params) => {
|
|
1479
1520
|
const handler = getHandlers(params.sessionId).canvas;
|
|
1480
1521
|
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1481
|
-
return handler.
|
|
1522
|
+
return handler.invoke(params);
|
|
1482
1523
|
});
|
|
1483
1524
|
}
|
|
1484
1525
|
export {
|
|
@@ -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 | 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
|
*/
|
|
@@ -1030,9 +1046,7 @@ export interface ModelChangeData {
|
|
|
1030
1046
|
/**
|
|
1031
1047
|
* Context tier after the model change; null explicitly clears a previously selected tier
|
|
1032
1048
|
*/
|
|
1033
|
-
contextTier?:
|
|
1034
|
-
/** Extended context tier with a larger context window. */
|
|
1035
|
-
| "long_context" | null;
|
|
1049
|
+
contextTier?: ContextTier | null;
|
|
1036
1050
|
/**
|
|
1037
1051
|
* Newly selected model identifier
|
|
1038
1052
|
*/
|
|
@@ -1946,7 +1960,7 @@ export interface UserMessageData {
|
|
|
1946
1960
|
/**
|
|
1947
1961
|
* Files, selections, or GitHub references attached to the message
|
|
1948
1962
|
*/
|
|
1949
|
-
attachments?:
|
|
1963
|
+
attachments?: Attachment[];
|
|
1950
1964
|
/**
|
|
1951
1965
|
* The user's message text as displayed in the timeline
|
|
1952
1966
|
*/
|
|
@@ -1983,12 +1997,12 @@ export interface UserMessageData {
|
|
|
1983
1997
|
/**
|
|
1984
1998
|
* File attachment
|
|
1985
1999
|
*/
|
|
1986
|
-
export interface
|
|
2000
|
+
export interface AttachmentFile {
|
|
1987
2001
|
/**
|
|
1988
2002
|
* User-facing display name for the attachment
|
|
1989
2003
|
*/
|
|
1990
2004
|
displayName: string;
|
|
1991
|
-
lineRange?:
|
|
2005
|
+
lineRange?: AttachmentFileLineRange;
|
|
1992
2006
|
/**
|
|
1993
2007
|
* Absolute file path
|
|
1994
2008
|
*/
|
|
@@ -2001,7 +2015,7 @@ export interface UserMessageAttachmentFile {
|
|
|
2001
2015
|
/**
|
|
2002
2016
|
* Optional line range to scope the attachment to a specific section of the file
|
|
2003
2017
|
*/
|
|
2004
|
-
export interface
|
|
2018
|
+
export interface AttachmentFileLineRange {
|
|
2005
2019
|
/**
|
|
2006
2020
|
* End line number (1-based, inclusive)
|
|
2007
2021
|
*/
|
|
@@ -2014,7 +2028,7 @@ export interface UserMessageAttachmentFileLineRange {
|
|
|
2014
2028
|
/**
|
|
2015
2029
|
* Directory attachment
|
|
2016
2030
|
*/
|
|
2017
|
-
export interface
|
|
2031
|
+
export interface AttachmentDirectory {
|
|
2018
2032
|
/**
|
|
2019
2033
|
* User-facing display name for the attachment
|
|
2020
2034
|
*/
|
|
@@ -2031,7 +2045,7 @@ export interface UserMessageAttachmentDirectory {
|
|
|
2031
2045
|
/**
|
|
2032
2046
|
* Code selection attachment from an editor
|
|
2033
2047
|
*/
|
|
2034
|
-
export interface
|
|
2048
|
+
export interface AttachmentSelection {
|
|
2035
2049
|
/**
|
|
2036
2050
|
* User-facing display name for the selection
|
|
2037
2051
|
*/
|
|
@@ -2040,7 +2054,7 @@ export interface UserMessageAttachmentSelection {
|
|
|
2040
2054
|
* Absolute path to the file containing the selection
|
|
2041
2055
|
*/
|
|
2042
2056
|
filePath: string;
|
|
2043
|
-
selection:
|
|
2057
|
+
selection: AttachmentSelectionDetails;
|
|
2044
2058
|
/**
|
|
2045
2059
|
* The selected text content
|
|
2046
2060
|
*/
|
|
@@ -2053,14 +2067,14 @@ export interface UserMessageAttachmentSelection {
|
|
|
2053
2067
|
/**
|
|
2054
2068
|
* Position range of the selection within the file
|
|
2055
2069
|
*/
|
|
2056
|
-
export interface
|
|
2057
|
-
end:
|
|
2058
|
-
start:
|
|
2070
|
+
export interface AttachmentSelectionDetails {
|
|
2071
|
+
end: AttachmentSelectionDetailsEnd;
|
|
2072
|
+
start: AttachmentSelectionDetailsStart;
|
|
2059
2073
|
}
|
|
2060
2074
|
/**
|
|
2061
2075
|
* End position of the selection
|
|
2062
2076
|
*/
|
|
2063
|
-
export interface
|
|
2077
|
+
export interface AttachmentSelectionDetailsEnd {
|
|
2064
2078
|
/**
|
|
2065
2079
|
* End character offset within the line (0-based)
|
|
2066
2080
|
*/
|
|
@@ -2073,7 +2087,7 @@ export interface UserMessageAttachmentSelectionDetailsEnd {
|
|
|
2073
2087
|
/**
|
|
2074
2088
|
* Start position of the selection
|
|
2075
2089
|
*/
|
|
2076
|
-
export interface
|
|
2090
|
+
export interface AttachmentSelectionDetailsStart {
|
|
2077
2091
|
/**
|
|
2078
2092
|
* Start character offset within the line (0-based)
|
|
2079
2093
|
*/
|
|
@@ -2086,12 +2100,12 @@ export interface UserMessageAttachmentSelectionDetailsStart {
|
|
|
2086
2100
|
/**
|
|
2087
2101
|
* GitHub issue, pull request, or discussion reference
|
|
2088
2102
|
*/
|
|
2089
|
-
export interface
|
|
2103
|
+
export interface AttachmentGitHubReference {
|
|
2090
2104
|
/**
|
|
2091
2105
|
* Issue, pull request, or discussion number
|
|
2092
2106
|
*/
|
|
2093
2107
|
number: number;
|
|
2094
|
-
referenceType:
|
|
2108
|
+
referenceType: AttachmentGitHubReferenceType;
|
|
2095
2109
|
/**
|
|
2096
2110
|
* Current state of the referenced item (e.g., open, closed, merged)
|
|
2097
2111
|
*/
|
|
@@ -2112,7 +2126,7 @@ export interface UserMessageAttachmentGithubReference {
|
|
|
2112
2126
|
/**
|
|
2113
2127
|
* Blob attachment with inline base64-encoded data
|
|
2114
2128
|
*/
|
|
2115
|
-
export interface
|
|
2129
|
+
export interface AttachmentBlob {
|
|
2116
2130
|
/**
|
|
2117
2131
|
* Base64-encoded content
|
|
2118
2132
|
*/
|
|
@@ -2130,6 +2144,41 @@ export interface UserMessageAttachmentBlob {
|
|
|
2130
2144
|
*/
|
|
2131
2145
|
type: "blob";
|
|
2132
2146
|
}
|
|
2147
|
+
/**
|
|
2148
|
+
* 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.
|
|
2149
|
+
*/
|
|
2150
|
+
export interface AttachmentExtensionContext {
|
|
2151
|
+
/**
|
|
2152
|
+
* Provider-local canvas identifier when the push was bound to a canvas instance
|
|
2153
|
+
*/
|
|
2154
|
+
canvasId?: string;
|
|
2155
|
+
/**
|
|
2156
|
+
* ISO 8601 timestamp captured by the runtime when the push was accepted
|
|
2157
|
+
*/
|
|
2158
|
+
capturedAt: string;
|
|
2159
|
+
/**
|
|
2160
|
+
* Owning extension identifier. Runtime-derived from the caller's connection when produced via session.extensions.sendAttachmentsToMessage; preserved verbatim on subsequent transports.
|
|
2161
|
+
*/
|
|
2162
|
+
extensionId: string;
|
|
2163
|
+
/**
|
|
2164
|
+
* Open canvas instance identifier when the push was bound to a canvas instance
|
|
2165
|
+
*/
|
|
2166
|
+
instanceId?: string;
|
|
2167
|
+
/**
|
|
2168
|
+
* Caller-supplied JSON payload
|
|
2169
|
+
*/
|
|
2170
|
+
payload?: {
|
|
2171
|
+
[k: string]: unknown | undefined;
|
|
2172
|
+
};
|
|
2173
|
+
/**
|
|
2174
|
+
* Human-readable composer pill label
|
|
2175
|
+
*/
|
|
2176
|
+
title: string;
|
|
2177
|
+
/**
|
|
2178
|
+
* Attachment type discriminator
|
|
2179
|
+
*/
|
|
2180
|
+
type: "extension_context";
|
|
2181
|
+
}
|
|
2133
2182
|
/**
|
|
2134
2183
|
* Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
|
|
2135
2184
|
*/
|
|
@@ -2971,6 +3020,10 @@ export interface ToolExecutionStartData {
|
|
|
2971
3020
|
* Original tool name on the MCP server, when the tool is an MCP tool
|
|
2972
3021
|
*/
|
|
2973
3022
|
mcpToolName?: string;
|
|
3023
|
+
/**
|
|
3024
|
+
* Model identifier that generated this tool call
|
|
3025
|
+
*/
|
|
3026
|
+
model?: string;
|
|
2974
3027
|
/**
|
|
2975
3028
|
* @deprecated
|
|
2976
3029
|
* Tool call ID of the parent tool invocation when this event originates from a sub-agent
|
|
@@ -6646,6 +6699,45 @@ export interface CanvasRegistryChangedCanvasAction {
|
|
|
6646
6699
|
*/
|
|
6647
6700
|
name: string;
|
|
6648
6701
|
}
|
|
6702
|
+
/**
|
|
6703
|
+
* Session event "session.extensions.attachments_pushed".
|
|
6704
|
+
*/
|
|
6705
|
+
export interface ExtensionsAttachmentsPushedEvent {
|
|
6706
|
+
/**
|
|
6707
|
+
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
|
6708
|
+
*/
|
|
6709
|
+
agentId?: string;
|
|
6710
|
+
data: ExtensionsAttachmentsPushedData;
|
|
6711
|
+
/**
|
|
6712
|
+
* Always true for events that are transient and not persisted to the session event log on disk.
|
|
6713
|
+
*/
|
|
6714
|
+
ephemeral: true;
|
|
6715
|
+
/**
|
|
6716
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
6717
|
+
*/
|
|
6718
|
+
id: string;
|
|
6719
|
+
/**
|
|
6720
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
6721
|
+
*/
|
|
6722
|
+
parentId: string | null;
|
|
6723
|
+
/**
|
|
6724
|
+
* ISO 8601 timestamp when the event was created
|
|
6725
|
+
*/
|
|
6726
|
+
timestamp: string;
|
|
6727
|
+
/**
|
|
6728
|
+
* Type discriminator. Always "session.extensions.attachments_pushed".
|
|
6729
|
+
*/
|
|
6730
|
+
type: "session.extensions.attachments_pushed";
|
|
6731
|
+
}
|
|
6732
|
+
/**
|
|
6733
|
+
* Schema for the `ExtensionsAttachmentsPushedData` type.
|
|
6734
|
+
*/
|
|
6735
|
+
export interface ExtensionsAttachmentsPushedData {
|
|
6736
|
+
/**
|
|
6737
|
+
* Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
|
|
6738
|
+
*/
|
|
6739
|
+
attachments: Attachment[];
|
|
6740
|
+
}
|
|
6649
6741
|
/**
|
|
6650
6742
|
* Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
|
|
6651
6743
|
*/
|
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,13 @@ export declare class CopilotSession {
|
|
|
169
169
|
* ```
|
|
170
170
|
*/
|
|
171
171
|
on(handler: SessionEventHandler): () => void;
|
|
172
|
+
private upsertOpenCanvasFromEvent;
|
|
173
|
+
private upsertOpenCanvas;
|
|
172
174
|
/**
|
|
173
|
-
* Snapshot of canvas instances
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
175
|
+
* Snapshot of canvas instances currently known to be open for this session.
|
|
176
|
+
* Populated from the `session.resume` response and live `session.canvas.opened`
|
|
177
|
+
* events. Returns a defensive copy — mutating the returned array has no effect
|
|
178
|
+
* on the session.
|
|
177
179
|
*/
|
|
178
180
|
get openCanvases(): OpenCanvasInstance[];
|
|
179
181
|
private assertElicitation;
|
|
@@ -261,6 +263,8 @@ export declare class CopilotSession {
|
|
|
261
263
|
*/
|
|
262
264
|
setModel(model: string, options?: {
|
|
263
265
|
reasoningEffort?: ReasoningEffort;
|
|
266
|
+
reasoningSummary?: ReasoningSummary;
|
|
267
|
+
contextTier?: ContextTier;
|
|
264
268
|
modelCapabilities?: ModelCapabilitiesOverride;
|
|
265
269
|
}): Promise<void>;
|
|
266
270
|
/**
|
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,25 @@ 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
|
+
}
|
|
257
|
+
}
|
|
258
|
+
upsertOpenCanvasFromEvent(data) {
|
|
259
|
+
if (!isOpenCanvasInstance(data)) {
|
|
260
|
+
console.warn("failed to deserialize session.canvas.opened payload");
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
this.upsertOpenCanvas(data);
|
|
264
|
+
}
|
|
265
|
+
upsertOpenCanvas(instance) {
|
|
266
|
+
const index = this.openCanvasInstances.findIndex(
|
|
267
|
+
(open) => open.instanceId === instance.instanceId
|
|
268
|
+
);
|
|
269
|
+
if (index >= 0) {
|
|
270
|
+
this.openCanvasInstances[index] = instance;
|
|
271
|
+
} else {
|
|
272
|
+
this.openCanvasInstances.push(instance);
|
|
246
273
|
}
|
|
247
274
|
}
|
|
248
275
|
/**
|
|
@@ -409,7 +436,7 @@ class CopilotSession {
|
|
|
409
436
|
throw toCanvasRpcError(error);
|
|
410
437
|
}
|
|
411
438
|
},
|
|
412
|
-
async
|
|
439
|
+
async invoke(params) {
|
|
413
440
|
const canvas = self.canvases.get(params.canvasId);
|
|
414
441
|
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
415
442
|
const handler = canvas.actionHandlers.get(params.actionName);
|
|
@@ -524,10 +551,10 @@ class CopilotSession {
|
|
|
524
551
|
this._capabilities = capabilities ?? {};
|
|
525
552
|
}
|
|
526
553
|
/**
|
|
527
|
-
* Snapshot of canvas instances
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
554
|
+
* Snapshot of canvas instances currently known to be open for this session.
|
|
555
|
+
* Populated from the `session.resume` response and live `session.canvas.opened`
|
|
556
|
+
* events. Returns a defensive copy — mutating the returned array has no effect
|
|
557
|
+
* on the session.
|
|
531
558
|
*/
|
|
532
559
|
get openCanvases() {
|
|
533
560
|
return [...this.openCanvasInstances];
|