@github/copilot-sdk 1.0.0-beta.6 → 1.0.0-beta.7

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/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  export { CopilotClient } from "./client.js";
7
7
  export { RuntimeConnection } from "./types.js";
8
8
  export { CopilotSession, type AssistantMessageEvent } from "./session.js";
9
- export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_PROMPT_SECTIONS, } from "./types.js";
9
+ export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasActionContext, type CanvasDeclaration, type CanvasHostContext, type CanvasJsonSchema, type CanvasLifecycleContext, type CanvasOpenContext, type CanvasOpenResponse, type CanvasOptions, } from "./canvas.js";
10
+ export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
10
11
  export type * from "./generated/session-events.js";
11
- export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, ConnectionState, CopilotClientOptions, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, 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, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolTelemetry, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
12
+ export type { CommandContext, CommandDefinition, CommandHandler, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, 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";
package/dist/index.js CHANGED
@@ -1,20 +1,28 @@
1
1
  import { CopilotClient } from "./client.js";
2
2
  import { RuntimeConnection } from "./types.js";
3
3
  import { CopilotSession } from "./session.js";
4
+ import {
5
+ Canvas,
6
+ CanvasError,
7
+ createCanvas
8
+ } from "./canvas.js";
4
9
  import {
5
10
  defineTool,
6
11
  approveAll,
7
12
  convertMcpCallToolResult,
8
13
  createSessionFsAdapter,
9
- SYSTEM_PROMPT_SECTIONS
14
+ SYSTEM_MESSAGE_SECTIONS
10
15
  } from "./types.js";
11
16
  export {
17
+ Canvas,
18
+ CanvasError,
12
19
  CopilotClient,
13
20
  CopilotSession,
14
21
  RuntimeConnection,
15
- SYSTEM_PROMPT_SECTIONS,
22
+ SYSTEM_MESSAGE_SECTIONS,
16
23
  approveAll,
17
24
  convertMcpCallToolResult,
25
+ createCanvas,
18
26
  createSessionFsAdapter,
19
27
  defineTool
20
28
  };
package/dist/session.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createSessionRpc } from "./generated/rpc.js";
2
+ import type { OpenCanvasInstance } from "./generated/rpc.js";
2
3
  import type { MessageOptions, ReasoningEffort, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
3
4
  /** Assistant message event - the final response from the assistant. */
4
5
  export type AssistantMessageEvent = Extract<SessionEvent, {
@@ -36,6 +37,7 @@ export declare class CopilotSession {
36
37
  private eventHandlers;
37
38
  private typedEventHandlers;
38
39
  private toolHandlers;
40
+ private canvases;
39
41
  private commandHandlers;
40
42
  private permissionHandler?;
41
43
  private userInputHandler?;
@@ -47,6 +49,7 @@ export declare class CopilotSession {
47
49
  private _rpc;
48
50
  private traceContextProvider?;
49
51
  private _capabilities;
52
+ private openCanvasInstances;
50
53
  /**
51
54
  * Typed session-scoped RPC methods.
52
55
  */
@@ -166,6 +169,13 @@ export declare class CopilotSession {
166
169
  * ```
167
170
  */
168
171
  on(handler: SessionEventHandler): () => void;
172
+ /**
173
+ * Snapshot of canvas instances that were already open when the session was
174
+ * resumed. Populated from the `session.resume` response; empty for freshly
175
+ * created sessions. Returns a defensive copy — mutating the returned array
176
+ * has no effect on the session.
177
+ */
178
+ get openCanvases(): OpenCanvasInstance[];
169
179
  private assertElicitation;
170
180
  private _elicitation;
171
181
  private _confirm;
package/dist/session.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { ConnectionError, ResponseError } from "vscode-jsonrpc/node.js";
2
2
  import { createSessionRpc } from "./generated/rpc.js";
3
3
  import { getTraceContext } from "./telemetry.js";
4
- const NO_RESULT_PERMISSION_V2_ERROR = "Permission handlers cannot return 'no-result' when connected to a protocol v2 server.";
5
4
  function deserializeHookInput(raw) {
6
5
  if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
7
6
  return raw;
@@ -29,6 +28,7 @@ class CopilotSession {
29
28
  eventHandlers = /* @__PURE__ */ new Set();
30
29
  typedEventHandlers = /* @__PURE__ */ new Map();
31
30
  toolHandlers = /* @__PURE__ */ new Map();
31
+ canvases = /* @__PURE__ */ new Map();
32
32
  commandHandlers = /* @__PURE__ */ new Map();
33
33
  permissionHandler;
34
34
  userInputHandler;
@@ -40,6 +40,7 @@ class CopilotSession {
40
40
  _rpc = null;
41
41
  traceContextProvider;
42
42
  _capabilities = {};
43
+ openCanvasInstances = [];
43
44
  /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
44
45
  clientSessionApis = {};
45
46
  /**
@@ -369,6 +370,31 @@ class CopilotSession {
369
370
  getToolHandler(name) {
370
371
  return this.toolHandlers.get(name);
371
372
  }
373
+ /**
374
+ * Registers canvas declarations and handlers for this session.
375
+ *
376
+ * @param canvases - Canvases created via `createCanvas`, or undefined to clear all canvases
377
+ * @internal Called by the SDK when creating/resuming a session with `canvases`.
378
+ */
379
+ registerCanvases(canvases) {
380
+ this.canvases.clear();
381
+ if (!canvases) {
382
+ return;
383
+ }
384
+ for (const canvas of canvases) {
385
+ this.canvases.set(canvas.declaration.id, canvas);
386
+ }
387
+ }
388
+ /**
389
+ * Retrieves a registered canvas by id.
390
+ *
391
+ * @param canvasId - The id of the canvas to retrieve
392
+ * @returns The registered Canvas if found, or undefined
393
+ * @internal Used by the SDK's direct `canvas.*` dispatcher.
394
+ */
395
+ getCanvas(canvasId) {
396
+ return this.canvases.get(canvasId);
397
+ }
372
398
  /**
373
399
  * Registers command handlers for this session.
374
400
  *
@@ -465,6 +491,24 @@ class CopilotSession {
465
491
  setCapabilities(capabilities) {
466
492
  this._capabilities = capabilities ?? {};
467
493
  }
494
+ /**
495
+ * Snapshot of canvas instances that were already open when the session was
496
+ * resumed. Populated from the `session.resume` response; empty for freshly
497
+ * created sessions. Returns a defensive copy — mutating the returned array
498
+ * has no effect on the session.
499
+ */
500
+ get openCanvases() {
501
+ return [...this.openCanvasInstances];
502
+ }
503
+ /**
504
+ * Sets the open-canvas snapshot for this session.
505
+ *
506
+ * @param instances - The `openCanvases` array from the `session.resume` response.
507
+ * @internal This method is typically called internally when resuming a session.
508
+ */
509
+ setOpenCanvases(instances) {
510
+ this.openCanvasInstances = [...instances];
511
+ }
468
512
  assertElicitation() {
469
513
  if (!this._capabilities.ui?.elicitation) {
470
514
  throw new Error(
@@ -604,33 +648,6 @@ class CopilotSession {
604
648
  }
605
649
  return { sections: result };
606
650
  }
607
- /**
608
- * Handles a permission request in the v2 protocol format (synchronous RPC).
609
- * Used as a back-compat adapter when connected to a v2 server.
610
- *
611
- * @param request - The permission request data from the CLI
612
- * @returns A promise that resolves with the permission decision
613
- * @internal This method is for internal use by the SDK.
614
- */
615
- async _handlePermissionRequestV2(request) {
616
- if (!this.permissionHandler) {
617
- return { kind: "user-not-available" };
618
- }
619
- try {
620
- const result = await this.permissionHandler(request, {
621
- sessionId: this.sessionId
622
- });
623
- if (result.kind === "no-result") {
624
- throw new Error(NO_RESULT_PERMISSION_V2_ERROR);
625
- }
626
- return result;
627
- } catch (error) {
628
- if (error instanceof Error && error.message === NO_RESULT_PERMISSION_V2_ERROR) {
629
- throw error;
630
- }
631
- return { kind: "user-not-available" };
632
- }
633
- }
634
651
  /**
635
652
  * Handles a user input request from the Copilot CLI.
636
653
  *
@@ -828,6 +845,5 @@ function isToolResultObject(value) {
828
845
  return allowedResultTypes.includes(value.resultType);
829
846
  }
830
847
  export {
831
- CopilotSession,
832
- NO_RESULT_PERMISSION_V2_ERROR
848
+ CopilotSession
833
849
  };
package/dist/types.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * Type definitions for the Copilot SDK
3
3
  */
4
+ import type { Canvas } from "./canvas.js";
4
5
  import type { SessionFsProvider } from "./sessionFsProvider.js";
5
6
  import type { SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
6
7
  import type { CopilotSession } from "./session.js";
7
8
  import type { RemoteSessionMode } from "./generated/rpc.js";
9
+ import type { OpenCanvasInstance } from "./generated/rpc.js";
8
10
  export type { RemoteSessionMode } from "./generated/rpc.js";
9
11
  export type SessionEvent = GeneratedSessionEvent;
10
12
  export type { SessionFsProvider } from "./sessionFsProvider.js";
@@ -389,6 +391,8 @@ export interface SessionCapabilities {
389
391
  ui?: {
390
392
  /** Whether the host supports interactive elicitation dialogs. */
391
393
  elicitation?: boolean;
394
+ /** Whether the host supports canvas rendering. */
395
+ canvases?: boolean;
392
396
  };
393
397
  }
394
398
  /**
@@ -566,12 +570,12 @@ export interface ToolCallResponsePayload {
566
570
  result: ToolResult;
567
571
  }
568
572
  /**
569
- * Known system prompt section identifiers for the "customize" mode.
573
+ * Known system message section identifiers for the "customize" mode.
570
574
  * Each section corresponds to a distinct part of the system prompt.
571
575
  */
572
- export type SystemPromptSection = "identity" | "tone" | "tool_efficiency" | "environment_context" | "code_change_rules" | "guidelines" | "safety" | "tool_instructions" | "custom_instructions" | "last_instructions";
576
+ export type SystemMessageSection = "identity" | "tone" | "tool_efficiency" | "environment_context" | "code_change_rules" | "guidelines" | "safety" | "tool_instructions" | "custom_instructions" | "runtime_instructions" | "last_instructions";
573
577
  /** Section metadata for documentation and tooling. */
574
- export declare const SYSTEM_PROMPT_SECTIONS: Record<SystemPromptSection, {
578
+ export declare const SYSTEM_MESSAGE_SECTIONS: Record<SystemMessageSection, {
575
579
  description: string;
576
580
  }>;
577
581
  /**
@@ -589,7 +593,7 @@ export type SectionTransformFn = (currentContent: string) => string | Promise<st
589
593
  */
590
594
  export type SectionOverrideAction = "replace" | "remove" | "append" | "prepend" | SectionTransformFn;
591
595
  /**
592
- * Override operation for a single system prompt section.
596
+ * Override operation for a single system message section.
593
597
  */
594
598
  export interface SectionOverride {
595
599
  /**
@@ -638,7 +642,7 @@ export interface SystemMessageCustomizeConfig {
638
642
  * Unknown section IDs gracefully fall back: content-bearing overrides are appended
639
643
  * to additional instructions, and "remove" on unknown sections is a silent no-op.
640
644
  */
641
- sections?: Partial<Record<SystemPromptSection, SectionOverride>>;
645
+ sections?: Partial<Record<SystemMessageSection, SectionOverride>>;
642
646
  /**
643
647
  * Additional content appended after all sections.
644
648
  * Equivalent to append mode's content field — provided for convenience.
@@ -1108,6 +1112,15 @@ export interface InfiniteSessionConfig {
1108
1112
  * Valid reasoning effort levels for models that support it.
1109
1113
  */
1110
1114
  export type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
1115
+ /**
1116
+ * Stable extension identity for session participants that provide canvases.
1117
+ */
1118
+ export interface ExtensionInfo {
1119
+ /** Extension namespace/source, e.g. "github-app". */
1120
+ source: string;
1121
+ /** Stable provider name within the source namespace. */
1122
+ name: string;
1123
+ }
1111
1124
  /**
1112
1125
  * Shared configuration fields used by both {@link SessionConfig} (for
1113
1126
  * creating a new session) and {@link ResumeSessionConfig} (for resuming
@@ -1153,6 +1166,34 @@ export interface SessionConfigBase {
1153
1166
  * and must be resolved by the consumer via pending external tool request RPCs.
1154
1167
  */
1155
1168
  tools?: Tool<any>[];
1169
+ /**
1170
+ * Canvases contributed by this session participant. The declaring
1171
+ * connection becomes the live provider for `canvas.open|focus|close|reload`
1172
+ * and `canvas.action.invoke` dispatches targeting each canvas's `id` for
1173
+ * the lifetime of the connection. Re-declaring the same id on resume
1174
+ * replaces the prior declaration.
1175
+ */
1176
+ canvases?: Canvas[];
1177
+ /**
1178
+ * Renderer-side opt-in: when true, the runtime surfaces canvas agent tools
1179
+ * (`list_canvas_capabilities`, `open_canvas`, `invoke_canvas_action`) to
1180
+ * the model for this connection. Default off so SDK callers that cannot
1181
+ * display canvases stay clean.
1182
+ */
1183
+ requestCanvasRenderer?: boolean;
1184
+ /**
1185
+ * Extension surface opt-in: when true, the runtime wires extension
1186
+ * management tools and per-extension tool dispatch onto the session for
1187
+ * this connection. Default off so callers that do not expose extensions
1188
+ * stay clean.
1189
+ */
1190
+ requestExtensions?: boolean;
1191
+ /**
1192
+ * Stable extension identity for canvas providers on this connection. When
1193
+ * set, the runtime uses `${source}:${name}` as the agent-facing extension
1194
+ * id instead of a reconnect-specific connection id.
1195
+ */
1196
+ extensionInfo?: ExtensionInfo;
1156
1197
  /**
1157
1198
  * Slash commands registered for this session.
1158
1199
  * When the CLI has a TUI, each command appears as `/name` for the user to invoke.
@@ -1354,6 +1395,12 @@ export interface ResumeSessionConfig extends SessionConfigBase {
1354
1395
  * @default false
1355
1396
  */
1356
1397
  continuePendingWork?: boolean;
1398
+ /**
1399
+ * Snapshot of canvases that were already open when the session was suspended.
1400
+ * When provided on resume, the runtime can rehydrate canvas state so consumers
1401
+ * do not need to re-open canvases that were active before the previous shutdown.
1402
+ */
1403
+ openCanvases?: OpenCanvasInstance[];
1357
1404
  }
1358
1405
  /**
1359
1406
  * Configuration for a custom API provider.
@@ -1490,10 +1537,6 @@ export type TypedSessionEventHandler<T extends SessionEventType> = (event: Sessi
1490
1537
  * Event handler callback type (for all events)
1491
1538
  */
1492
1539
  export type SessionEventHandler = (event: SessionEvent) => void;
1493
- /**
1494
- * Connection state
1495
- */
1496
- export type ConnectionState = "disconnected" | "connecting" | "connected" | "error";
1497
1540
  /**
1498
1541
  * Working directory context for a session
1499
1542
  */
package/dist/types.js CHANGED
@@ -72,7 +72,7 @@ function convertMcpCallToolResult(callResult) {
72
72
  function defineTool(name, config) {
73
73
  return { name, ...config };
74
74
  }
75
- const SYSTEM_PROMPT_SECTIONS = {
75
+ const SYSTEM_MESSAGE_SECTIONS = {
76
76
  identity: { description: "Agent identity preamble and mode statement" },
77
77
  tone: { description: "Response style, conciseness rules, output formatting preferences" },
78
78
  tool_efficiency: { description: "Tool usage patterns, parallel calling, batching guidelines" },
@@ -82,6 +82,9 @@ const SYSTEM_PROMPT_SECTIONS = {
82
82
  safety: { description: "Environment limitations, prohibited actions, security policies" },
83
83
  tool_instructions: { description: "Per-tool usage instructions" },
84
84
  custom_instructions: { description: "Repository and organization custom instructions" },
85
+ runtime_instructions: {
86
+ description: "Runtime-provided context and instructions (e.g. system notifications, memories, workspace context, mode-specific instructions, content-exclusion policy)"
87
+ },
85
88
  last_instructions: {
86
89
  description: "End-of-prompt instructions: parallel tool calling, persistence, task completion"
87
90
  }
@@ -92,7 +95,7 @@ const defaultJoinSessionPermissionHandler = () => ({
92
95
  });
93
96
  export {
94
97
  RuntimeConnection,
95
- SYSTEM_PROMPT_SECTIONS,
98
+ SYSTEM_MESSAGE_SECTIONS,
96
99
  approveAll,
97
100
  convertMcpCallToolResult,
98
101
  createSessionFsAdapter,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.0-beta.6",
7
+ "version": "1.0.0-beta.7",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.52-1",
59
+ "@github/copilot": "^1.0.53-2",
60
60
  "vscode-jsonrpc": "^8.2.1",
61
61
  "zod": "^4.3.6"
62
62
  },