Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@github/copilot

Package Overview
Dependencies
Maintainers
22
Versions
721
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@github/copilot - npm Package Compare versions

Comparing version
1.0.53
to
1.0.54
+163
copilot-sdk/canvas.d.ts
/**
* Extension-owned canvases declared via
* `joinSession({ canvases: [createCanvas({...})] })`.
*
* The runtime sends provider callbacks directly as `canvas.open`,
* `canvas.close`, and `canvas.action.invoke` JSON-RPC requests. The SDK
* routes those requests by `canvasId` to the in-process handlers bound by
* `createCanvas`. Re-opening with an existing `instanceId` is how the host
* focuses an existing panel; reload is a renderer-only concern.
*/
/** JSON Schema object used for canvas inputs. */
export type CanvasJsonSchema = Record<string, unknown>;
/**
* A single agent-callable action contributed by a canvas. The metadata
* (`name`, `description`, `inputSchema`) is serialized over the wire on
* `session.create` / `session.resume`; the `handler` closure is stripped
* before the declaration is sent and dispatched in-process by the SDK.
*
* Names MUST NOT start with `canvas.` — that prefix is reserved for
* lifecycle verbs.
*/
export interface CanvasAction {
/** Action identifier, unique within the canvas. */
name: string;
/** Description shown to the model when picking an action. */
description?: string;
/** Optional JSON Schema for the action's `input` payload. */
inputSchema?: CanvasJsonSchema;
/** Required per-action dispatch handler. */
handler: (ctx: CanvasActionContext) => Promise<unknown> | unknown;
}
/**
* Declarative metadata for a single canvas, serialized over the wire on
* `session.create` / `session.resume`.
*/
export interface CanvasDeclaration {
/** Canvas id, unique within the declaring connection. */
id: string;
/** Human-readable label shown in discovery and host UI chrome. */
displayName: string;
/** Short, single-sentence description shown to the agent in canvas catalogs. */
description: string;
/** Optional JSON Schema for the `input` payload accepted by `canvas.open`. */
inputSchema?: CanvasJsonSchema;
/** Agent-invocable actions exposed via `invoke_canvas_action`. */
actions?: Omit<CanvasAction, "handler">[];
}
/** Response returned from `open`. */
export interface CanvasOpenResponse {
/** URL the host should render. Optional for native canvases. */
url?: string;
/** Provider-supplied title shown in host chrome. */
title?: string;
/** Provider-supplied status text shown in host chrome. */
status?: string;
}
/** Host capabilities passed to canvas callbacks. */
export interface CanvasHostContext {
capabilities?: {
canvases?: boolean;
};
}
/** Context handed to a canvas's `open` handler. */
export interface CanvasOpenContext {
/** Session that requested the canvas. */
sessionId: string;
/** Extension id that owns the canvas. */
extensionId: string;
/** Canvas id (matches the declaring `CanvasDeclaration.id`). */
canvasId: string;
/** Stable instance id supplied by the runtime. */
instanceId: string;
/** Validated `input` payload, shaped by `CanvasDeclaration.inputSchema`. */
input: unknown;
/** Host capabilities supplied by the runtime. */
host?: CanvasHostContext;
}
/** Context handed to a canvas action handler. */
export interface CanvasActionContext {
/** Session that invoked the action. */
sessionId: string;
/** Extension id that owns the canvas. */
extensionId: string;
/** Canvas id targeted by the action. */
canvasId: string;
/** Instance id targeted by the action. */
instanceId: string;
/** Action name from `CanvasAction.name`. */
actionName: string;
/** Validated `input` payload, shaped by the action's `inputSchema`. */
input: unknown;
/** Host capabilities supplied by the runtime. */
host?: CanvasHostContext;
}
/** Context handed to a canvas's `onClose` handler. */
export interface CanvasLifecycleContext {
/** Session owning the canvas instance. */
sessionId: string;
/** Extension id that owns the canvas. */
extensionId: string;
/** Canvas id (matches the declaring `CanvasDeclaration.id`). */
canvasId: string;
/** Instance id this lifecycle event applies to. */
instanceId: string;
/** Host capabilities supplied by the runtime. */
host?: CanvasHostContext;
}
/** Structured error returned from canvas handlers. */
export declare class CanvasError extends Error {
readonly code: string;
constructor(code: string, message: string);
/** Default error when an action is declared but no `handler` is wired. */
static noHandler(): CanvasError;
}
/**
* Options accepted by {@link createCanvas}. Combines the declarative
* {@link CanvasDeclaration} fields with the in-process handler closures.
*/
export interface CanvasOptions {
/** @see CanvasDeclaration.id */
id: string;
/** @see CanvasDeclaration.displayName */
displayName: string;
/** @see CanvasDeclaration.description */
description: string;
/** @see CanvasDeclaration.inputSchema */
inputSchema?: CanvasJsonSchema;
/**
* Agent-invocable actions exposed via `invoke_canvas_action`. Each action
* carries its own required `handler`; the action's wire metadata
* (`name`, `description`, `inputSchema`) is what reaches the runtime.
*/
actions?: CanvasAction[];
/** Required. Open a new canvas instance. */
open: (ctx: CanvasOpenContext) => Promise<CanvasOpenResponse> | CanvasOpenResponse;
/**
* Optional. Notified when a canvas instance is closed by the user, the
* agent, or the host. Fire-and-forget: the return value is ignored and
* errors are logged but not surfaced to the runtime.
*/
onClose?: (ctx: CanvasLifecycleContext) => Promise<void> | void;
}
/** A registered canvas: declarative metadata + in-process handler closures.
*
* Node intentionally uses a per-canvas factory pattern (mirroring
* {@link https://github.com/github/copilot-sdk | `DefineTool`}'s co-location
* ergonomics) where other SDKs (Rust, Python, Go, .NET) expose a single
* `CanvasHandler` per session that switches on `canvasId`. Both shapes target
* the same JSON-RPC wire protocol; the divergence is API ergonomics only.
*/
export declare class Canvas {
readonly declaration: CanvasDeclaration;
readonly open: NonNullable<CanvasOptions["open"]>;
readonly onClose?: CanvasOptions["onClose"];
}
/** Create a canvas declaration with bound in-process handlers.
*
* Node intentionally uses this per-canvas factory pattern (mirroring
* `DefineTool`'s co-location ergonomics) where other SDKs (Rust, Python, Go,
* .NET) expose a single `CanvasHandler` per session that switches on
* `canvasId`. Both shapes target the same JSON-RPC wire protocol.
*/
export declare function createCanvas(options: CanvasOptions): Canvas;
+3
-26
import { createServerRpc } from "./generated/rpc.js";
import { CopilotSession } from "./session.js";
import type { ConnectionState, CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse, ModelInfo, ResumeSessionConfig, SessionConfig, SessionLifecycleEventType, SessionLifecycleHandler, SessionListFilter, SessionMetadata, TypedSessionLifecycleHandler } from "./types.js";
import type { CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse, ModelInfo, ResumeSessionConfig, SessionConfig, SessionLifecycleEventType, SessionLifecycleHandler, SessionListFilter, SessionMetadata, TypedSessionLifecycleHandler } from "./types.js";
/**

@@ -248,15 +248,2 @@ * Main client for interacting with the Copilot CLI.

/**
* Gets the current connection state of the client.
*
* @returns The current connection state: "disconnected", "connecting", "connected", or "error"
*
* @example
* ```typescript
* if (client.getState() === "connected") {
* const session = await client.createSession({ onPermissionRequest: approveAll });
* }
* ```
*/
getState(): ConnectionState;
/**
* Sends a ping request to the server to verify connectivity.

@@ -484,14 +471,4 @@ *

private handleSystemMessageTransform;
/**
* Handles a v2-style tool.call RPC request from the server.
* Looks up the session and tool handler, executes it, and returns the result
* in the v2 response format.
*/
private handleToolCallRequestV2;
/**
* Handles a v2-style permission.request RPC request from the server.
*/
private handlePermissionRequestV2;
private normalizeToolResultV2;
private isToolResultObject;
private handleCanvasProviderRequest;
private handleCanvasActionInvokeRequest;
}
import type { CopilotSession } from "./session.js";
import { type PermissionHandler, type ResumeSessionConfig } from "./types.js";
import { type ExtensionInfo, type PermissionHandler, type ResumeSessionConfig } from "./types.js";
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";
export type JoinSessionConfig = Omit<ResumeSessionConfig, "onPermissionRequest"> & {
onPermissionRequest?: PermissionHandler;
};
export type { ExtensionInfo };
/**

@@ -7,0 +9,0 @@ * Joins the current foreground session.

@@ -9,4 +9,5 @@ /**

export { CopilotSession, type AssistantMessageEvent } from "./session.js";
export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_PROMPT_SECTIONS, } from "./types.js";
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";
export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
export type * from "./generated/session-events.js";
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";
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";
import { createSessionRpc } from "./generated/rpc.js";
import type { OpenCanvasInstance } from "./generated/rpc.js";
import type { MessageOptions, ReasoningEffort, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";

@@ -39,2 +40,3 @@ /** Assistant message event - the final response from the assistant. */

private toolHandlers;
private canvases;
private commandHandlers;

@@ -51,2 +53,3 @@ private permissionHandler?;

private _capabilities;
private openCanvasInstances;
/**

@@ -171,2 +174,9 @@ * Typed session-scoped RPC methods.

on(handler: SessionEventHandler): () => void;
/**
* Snapshot of canvas instances that were already open when the session was
* resumed. Populated from the `session.resume` response; empty for freshly
* created sessions. Returns a defensive copy — mutating the returned array
* has no effect on the session.
*/
get openCanvases(): OpenCanvasInstance[];
private assertElicitation;

@@ -173,0 +183,0 @@ private _elicitation;

/**
* Type definitions for the Copilot SDK
*/
import type { Canvas } from "./canvas.js";
import type { SessionFsProvider } from "./sessionFsProvider.js";

@@ -8,2 +9,3 @@ import type { SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";

import type { RemoteSessionMode } from "./generated/rpc.js";
import type { OpenCanvasInstance } from "./generated/rpc.js";
export type { RemoteSessionMode } from "./generated/rpc.js";

@@ -393,2 +395,4 @@ export type SessionEvent = GeneratedSessionEvent;

elicitation?: boolean;
/** Whether the host supports canvas rendering. */
canvases?: boolean;
};

@@ -571,8 +575,8 @@ }

/**
* Known system prompt section identifiers for the "customize" mode.
* Known system message section identifiers for the "customize" mode.
* Each section corresponds to a distinct part of the system prompt.
*/
export type SystemPromptSection = "identity" | "tone" | "tool_efficiency" | "environment_context" | "code_change_rules" | "guidelines" | "safety" | "tool_instructions" | "custom_instructions" | "last_instructions";
export type SystemMessageSection = "identity" | "tone" | "tool_efficiency" | "environment_context" | "code_change_rules" | "guidelines" | "safety" | "tool_instructions" | "custom_instructions" | "runtime_instructions" | "last_instructions";
/** Section metadata for documentation and tooling. */
export declare const SYSTEM_PROMPT_SECTIONS: Record<SystemPromptSection, {
export declare const SYSTEM_MESSAGE_SECTIONS: Record<SystemMessageSection, {
description: string;

@@ -595,3 +599,3 @@ }>;

/**
* Override operation for a single system prompt section.
* Override operation for a single system message section.
*/

@@ -645,3 +649,3 @@ export interface SectionOverride {

*/
sections?: Partial<Record<SystemPromptSection, SectionOverride>>;
sections?: Partial<Record<SystemMessageSection, SectionOverride>>;
/**

@@ -1117,2 +1121,11 @@ * Additional content appended after all sections.

/**
* Stable extension identity for session participants that provide canvases.
*/
export interface ExtensionInfo {
/** Extension namespace/source, e.g. "github-app". */
source: string;
/** Stable provider name within the source namespace. */
name: string;
}
/**
* Shared configuration fields used by both {@link SessionConfig} (for

@@ -1163,2 +1176,30 @@ * creating a new session) and {@link ResumeSessionConfig} (for resuming

/**
* Canvases contributed by this session participant. The declaring
* connection becomes the live provider for `canvas.open|focus|close|reload`
* and `canvas.action.invoke` dispatches targeting each canvas's `id` for
* the lifetime of the connection. Re-declaring the same id on resume
* replaces the prior declaration.
*/
canvases?: Canvas[];
/**
* Renderer-side opt-in: when true, the runtime surfaces canvas agent tools
* (`list_canvas_capabilities`, `open_canvas`, `invoke_canvas_action`) to
* the model for this connection. Default off so SDK callers that cannot
* display canvases stay clean.
*/
requestCanvasRenderer?: boolean;
/**
* Extension surface opt-in: when true, the runtime wires extension
* management tools and per-extension tool dispatch onto the session for
* this connection. Default off so callers that do not expose extensions
* stay clean.
*/
requestExtensions?: boolean;
/**
* Stable extension identity for canvas providers on this connection. When
* set, the runtime uses `${source}:${name}` as the agent-facing extension
* id instead of a reconnect-specific connection id.
*/
extensionInfo?: ExtensionInfo;
/**
* Slash commands registered for this session.

@@ -1364,2 +1405,8 @@ * When the CLI has a TUI, each command appears as `/name` for the user to invoke.

continuePendingWork?: boolean;
/**
* Snapshot of canvases that were already open when the session was suspended.
* When provided on resume, the runtime can rehydrate canvas state so consumers
* do not need to re-open canvases that were active before the previous shutdown.
*/
openCanvases?: OpenCanvasInstance[];
}

@@ -1502,6 +1549,2 @@ /**

/**
* Connection state
*/
export type ConnectionState = "disconnected" | "connecting" | "connected" | "error";
/**
* Working directory context for a session

@@ -1508,0 +1551,0 @@ */

{
"name": "@github/copilot",
"description": "GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal.",
"version": "1.0.53",
"version": "1.0.54",
"license": "SEE LICENSE IN LICENSE.md",

@@ -73,14 +73,14 @@ "type": "module",

"buildMetadata": {
"gitCommit": "9cac7a2"
"gitCommit": "d1896a6"
},
"optionalDependencies": {
"@github/copilot-linux-x64": "1.0.53",
"@github/copilot-linux-arm64": "1.0.53",
"@github/copilot-linuxmusl-x64": "1.0.53",
"@github/copilot-linuxmusl-arm64": "1.0.53",
"@github/copilot-darwin-x64": "1.0.53",
"@github/copilot-darwin-arm64": "1.0.53",
"@github/copilot-win32-x64": "1.0.53",
"@github/copilot-win32-arm64": "1.0.53"
"@github/copilot-linux-x64": "1.0.54",
"@github/copilot-linux-arm64": "1.0.54",
"@github/copilot-linuxmusl-x64": "1.0.54",
"@github/copilot-linuxmusl-arm64": "1.0.54",
"@github/copilot-darwin-x64": "1.0.54",
"@github/copilot-darwin-arm64": "1.0.54",
"@github/copilot-win32-x64": "1.0.54",
"@github/copilot-win32-arm64": "1.0.54"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display