@github/copilot-sdk 1.0.0-beta.7 → 1.0.0-beta.8
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/canvas.d.ts +10 -70
- package/dist/canvas.js +1 -44
- package/dist/cjs/canvas.js +2 -46
- package/dist/cjs/client.js +0 -43
- package/dist/cjs/generated/rpc.js +25 -2
- package/dist/cjs/session.js +48 -11
- package/dist/client.d.ts +0 -2
- package/dist/client.js +0 -45
- package/dist/extension.d.ts +1 -1
- package/dist/generated/rpc.d.ts +322 -11
- package/dist/generated/rpc.js +25 -2
- package/dist/index.d.ts +1 -1
- package/dist/session.js +49 -12
- package/package.json +2 -2
package/dist/canvas.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import type { CanvasJsonSchema, CanvasProviderCloseRequest, CanvasProviderInvokeActionRequest, CanvasProviderOpenRequest, CanvasProviderOpenResult } from "./generated/rpc.js";
|
|
2
|
+
export type { CanvasJsonSchema, CanvasHostContext } from "./generated/rpc.js";
|
|
1
3
|
/**
|
|
2
4
|
* Extension-owned canvases declared via
|
|
3
5
|
* `joinSession({ canvases: [createCanvas({...})] })`.
|
|
4
6
|
*
|
|
5
|
-
* The runtime sends provider callbacks
|
|
6
|
-
* `canvas.
|
|
7
|
-
* routes those requests by `canvasId` to the in-process
|
|
8
|
-
* `createCanvas`. Re-opening with an existing `instanceId`
|
|
9
|
-
* focuses an existing panel; reload is a renderer-only concern.
|
|
7
|
+
* The runtime sends provider callbacks as `canvas.open`, `canvas.close`, and
|
|
8
|
+
* `canvas.invokeAction` JSON-RPC requests via the codegen client session API
|
|
9
|
+
* pipeline. The SDK routes those requests by `canvasId` to the in-process
|
|
10
|
+
* handlers bound by `createCanvas`. Re-opening with an existing `instanceId`
|
|
11
|
+
* is how the host focuses an existing panel; reload is a renderer-only concern.
|
|
10
12
|
*/
|
|
11
|
-
/** JSON Schema object used for canvas inputs. */
|
|
12
|
-
export type CanvasJsonSchema = Record<string, unknown>;
|
|
13
13
|
/**
|
|
14
14
|
* A single agent-callable action contributed by a canvas. The metadata
|
|
15
15
|
* (`name`, `description`, `inputSchema`) is serialized over the wire on
|
|
@@ -27,7 +27,7 @@ export interface CanvasAction {
|
|
|
27
27
|
/** Optional JSON Schema for the action's `input` payload. */
|
|
28
28
|
inputSchema?: CanvasJsonSchema;
|
|
29
29
|
/** Required per-action dispatch handler. */
|
|
30
|
-
handler: (ctx:
|
|
30
|
+
handler: (ctx: CanvasProviderInvokeActionRequest) => Promise<unknown> | unknown;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Declarative metadata for a single canvas, serialized over the wire on
|
|
@@ -45,66 +45,6 @@ export interface CanvasDeclaration {
|
|
|
45
45
|
/** Agent-invocable actions exposed via `invoke_canvas_action`. */
|
|
46
46
|
actions?: Omit<CanvasAction, "handler">[];
|
|
47
47
|
}
|
|
48
|
-
/** Response returned from `open`. */
|
|
49
|
-
export interface CanvasOpenResponse {
|
|
50
|
-
/** URL the host should render. Optional for native canvases. */
|
|
51
|
-
url?: string;
|
|
52
|
-
/** Provider-supplied title shown in host chrome. */
|
|
53
|
-
title?: string;
|
|
54
|
-
/** Provider-supplied status text shown in host chrome. */
|
|
55
|
-
status?: string;
|
|
56
|
-
}
|
|
57
|
-
/** Host capabilities passed to canvas callbacks. */
|
|
58
|
-
export interface CanvasHostContext {
|
|
59
|
-
capabilities?: {
|
|
60
|
-
canvases?: boolean;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/** Context handed to a canvas's `open` handler. */
|
|
64
|
-
export interface CanvasOpenContext {
|
|
65
|
-
/** Session that requested the canvas. */
|
|
66
|
-
sessionId: string;
|
|
67
|
-
/** Extension id that owns the canvas. */
|
|
68
|
-
extensionId: string;
|
|
69
|
-
/** Canvas id (matches the declaring `CanvasDeclaration.id`). */
|
|
70
|
-
canvasId: string;
|
|
71
|
-
/** Stable instance id supplied by the runtime. */
|
|
72
|
-
instanceId: string;
|
|
73
|
-
/** Validated `input` payload, shaped by `CanvasDeclaration.inputSchema`. */
|
|
74
|
-
input: unknown;
|
|
75
|
-
/** Host capabilities supplied by the runtime. */
|
|
76
|
-
host?: CanvasHostContext;
|
|
77
|
-
}
|
|
78
|
-
/** Context handed to a canvas action handler. */
|
|
79
|
-
export interface CanvasActionContext {
|
|
80
|
-
/** Session that invoked the action. */
|
|
81
|
-
sessionId: string;
|
|
82
|
-
/** Extension id that owns the canvas. */
|
|
83
|
-
extensionId: string;
|
|
84
|
-
/** Canvas id targeted by the action. */
|
|
85
|
-
canvasId: string;
|
|
86
|
-
/** Instance id targeted by the action. */
|
|
87
|
-
instanceId: string;
|
|
88
|
-
/** Action name from `CanvasAction.name`. */
|
|
89
|
-
actionName: string;
|
|
90
|
-
/** Validated `input` payload, shaped by the action's `inputSchema`. */
|
|
91
|
-
input: unknown;
|
|
92
|
-
/** Host capabilities supplied by the runtime. */
|
|
93
|
-
host?: CanvasHostContext;
|
|
94
|
-
}
|
|
95
|
-
/** Context handed to a canvas's `onClose` handler. */
|
|
96
|
-
export interface CanvasLifecycleContext {
|
|
97
|
-
/** Session owning the canvas instance. */
|
|
98
|
-
sessionId: string;
|
|
99
|
-
/** Extension id that owns the canvas. */
|
|
100
|
-
extensionId: string;
|
|
101
|
-
/** Canvas id (matches the declaring `CanvasDeclaration.id`). */
|
|
102
|
-
canvasId: string;
|
|
103
|
-
/** Instance id this lifecycle event applies to. */
|
|
104
|
-
instanceId: string;
|
|
105
|
-
/** Host capabilities supplied by the runtime. */
|
|
106
|
-
host?: CanvasHostContext;
|
|
107
|
-
}
|
|
108
48
|
/** Structured error returned from canvas handlers. */
|
|
109
49
|
export declare class CanvasError extends Error {
|
|
110
50
|
readonly code: string;
|
|
@@ -132,13 +72,13 @@ export interface CanvasOptions {
|
|
|
132
72
|
*/
|
|
133
73
|
actions?: CanvasAction[];
|
|
134
74
|
/** Required. Open a new canvas instance. */
|
|
135
|
-
open: (ctx:
|
|
75
|
+
open: (ctx: CanvasProviderOpenRequest) => Promise<CanvasProviderOpenResult> | CanvasProviderOpenResult;
|
|
136
76
|
/**
|
|
137
77
|
* Optional. Notified when a canvas instance is closed by the user, the
|
|
138
78
|
* agent, or the host. Fire-and-forget: the return value is ignored and
|
|
139
79
|
* errors are logged but not surfaced to the runtime.
|
|
140
80
|
*/
|
|
141
|
-
onClose?: (ctx:
|
|
81
|
+
onClose?: (ctx: CanvasProviderCloseRequest) => Promise<void> | void;
|
|
142
82
|
}
|
|
143
83
|
/** A registered canvas: declarative metadata + in-process handler closures.
|
|
144
84
|
*
|
package/dist/canvas.js
CHANGED
|
@@ -42,51 +42,8 @@ class Canvas {
|
|
|
42
42
|
function createCanvas(options) {
|
|
43
43
|
return new Canvas(options);
|
|
44
44
|
}
|
|
45
|
-
async function dispatchCanvasProviderRequest(canvas, actionName, params) {
|
|
46
|
-
switch (actionName) {
|
|
47
|
-
case "canvas.open": {
|
|
48
|
-
const result = await canvas.open({
|
|
49
|
-
sessionId: params.sessionId,
|
|
50
|
-
extensionId: params.extensionId,
|
|
51
|
-
canvasId: params.canvasId,
|
|
52
|
-
instanceId: params.instanceId,
|
|
53
|
-
input: params.input,
|
|
54
|
-
host: params.host
|
|
55
|
-
});
|
|
56
|
-
return result ?? {};
|
|
57
|
-
}
|
|
58
|
-
case "canvas.close": {
|
|
59
|
-
if (canvas.onClose) {
|
|
60
|
-
await canvas.onClose({
|
|
61
|
-
sessionId: params.sessionId,
|
|
62
|
-
extensionId: params.extensionId,
|
|
63
|
-
canvasId: params.canvasId,
|
|
64
|
-
instanceId: params.instanceId,
|
|
65
|
-
host: params.host
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return void 0;
|
|
69
|
-
}
|
|
70
|
-
default: {
|
|
71
|
-
const perAction = canvas.actionHandlers.get(actionName);
|
|
72
|
-
if (!perAction) {
|
|
73
|
-
throw CanvasError.noHandler();
|
|
74
|
-
}
|
|
75
|
-
return perAction({
|
|
76
|
-
sessionId: params.sessionId,
|
|
77
|
-
extensionId: params.extensionId,
|
|
78
|
-
canvasId: params.canvasId,
|
|
79
|
-
instanceId: params.instanceId,
|
|
80
|
-
actionName,
|
|
81
|
-
input: params.input,
|
|
82
|
-
host: params.host
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
45
|
export {
|
|
88
46
|
Canvas,
|
|
89
47
|
CanvasError,
|
|
90
|
-
createCanvas
|
|
91
|
-
dispatchCanvasProviderRequest
|
|
48
|
+
createCanvas
|
|
92
49
|
};
|
package/dist/cjs/canvas.js
CHANGED
|
@@ -20,8 +20,7 @@ var canvas_exports = {};
|
|
|
20
20
|
__export(canvas_exports, {
|
|
21
21
|
Canvas: () => Canvas,
|
|
22
22
|
CanvasError: () => CanvasError,
|
|
23
|
-
createCanvas: () => createCanvas
|
|
24
|
-
dispatchCanvasProviderRequest: () => dispatchCanvasProviderRequest
|
|
23
|
+
createCanvas: () => createCanvas
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(canvas_exports);
|
|
27
26
|
class CanvasError extends Error {
|
|
@@ -68,52 +67,9 @@ class Canvas {
|
|
|
68
67
|
function createCanvas(options) {
|
|
69
68
|
return new Canvas(options);
|
|
70
69
|
}
|
|
71
|
-
async function dispatchCanvasProviderRequest(canvas, actionName, params) {
|
|
72
|
-
switch (actionName) {
|
|
73
|
-
case "canvas.open": {
|
|
74
|
-
const result = await canvas.open({
|
|
75
|
-
sessionId: params.sessionId,
|
|
76
|
-
extensionId: params.extensionId,
|
|
77
|
-
canvasId: params.canvasId,
|
|
78
|
-
instanceId: params.instanceId,
|
|
79
|
-
input: params.input,
|
|
80
|
-
host: params.host
|
|
81
|
-
});
|
|
82
|
-
return result ?? {};
|
|
83
|
-
}
|
|
84
|
-
case "canvas.close": {
|
|
85
|
-
if (canvas.onClose) {
|
|
86
|
-
await canvas.onClose({
|
|
87
|
-
sessionId: params.sessionId,
|
|
88
|
-
extensionId: params.extensionId,
|
|
89
|
-
canvasId: params.canvasId,
|
|
90
|
-
instanceId: params.instanceId,
|
|
91
|
-
host: params.host
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return void 0;
|
|
95
|
-
}
|
|
96
|
-
default: {
|
|
97
|
-
const perAction = canvas.actionHandlers.get(actionName);
|
|
98
|
-
if (!perAction) {
|
|
99
|
-
throw CanvasError.noHandler();
|
|
100
|
-
}
|
|
101
|
-
return perAction({
|
|
102
|
-
sessionId: params.sessionId,
|
|
103
|
-
extensionId: params.extensionId,
|
|
104
|
-
canvasId: params.canvasId,
|
|
105
|
-
instanceId: params.instanceId,
|
|
106
|
-
actionName,
|
|
107
|
-
input: params.input,
|
|
108
|
-
host: params.host
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
114
71
|
0 && (module.exports = {
|
|
115
72
|
Canvas,
|
|
116
73
|
CanvasError,
|
|
117
|
-
createCanvas
|
|
118
|
-
dispatchCanvasProviderRequest
|
|
74
|
+
createCanvas
|
|
119
75
|
});
|
package/dist/cjs/client.js
CHANGED
|
@@ -30,7 +30,6 @@ var import_node_path = require("node:path");
|
|
|
30
30
|
var import_node_url = require("node:url");
|
|
31
31
|
var import_node = require("vscode-jsonrpc/node.js");
|
|
32
32
|
var import_rpc = require("./generated/rpc.js");
|
|
33
|
-
var import_canvas = require("./canvas.js");
|
|
34
33
|
var import_sdkProtocolVersion = require("./sdkProtocolVersion.js");
|
|
35
34
|
var import_session = require("./session.js");
|
|
36
35
|
var import_sessionFsProvider = require("./sessionFsProvider.js");
|
|
@@ -68,16 +67,6 @@ function toWireCustomAgents(agents) {
|
|
|
68
67
|
return { ...rest, mcpServers: toWireMcpServers(mcpServers) };
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
|
-
function isCanvasProviderRequestParams(params) {
|
|
72
|
-
if (!params || typeof params !== "object") {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
const request = params;
|
|
76
|
-
return typeof request.sessionId === "string" && typeof request.extensionId === "string" && typeof request.canvasId === "string" && typeof request.instanceId === "string";
|
|
77
|
-
}
|
|
78
|
-
function isCanvasActionInvokeParams(params) {
|
|
79
|
-
return isCanvasProviderRequestParams(params) && typeof params.actionName === "string";
|
|
80
|
-
}
|
|
81
70
|
function extractTransformCallbacks(systemMessage) {
|
|
82
71
|
if (!systemMessage || systemMessage.mode !== "customize" || !systemMessage.sections) {
|
|
83
72
|
return { wirePayload: systemMessage, transformCallbacks: void 0 };
|
|
@@ -1409,18 +1398,6 @@ stderr: ${stderrOutput}`
|
|
|
1409
1398
|
"systemMessage.transform",
|
|
1410
1399
|
async (params) => await this.handleSystemMessageTransform(params)
|
|
1411
1400
|
);
|
|
1412
|
-
this.connection.onRequest(
|
|
1413
|
-
"canvas.open",
|
|
1414
|
-
async (params) => this.handleCanvasProviderRequest("canvas.open", params)
|
|
1415
|
-
);
|
|
1416
|
-
this.connection.onRequest(
|
|
1417
|
-
"canvas.close",
|
|
1418
|
-
async (params) => this.handleCanvasProviderRequest("canvas.close", params)
|
|
1419
|
-
);
|
|
1420
|
-
this.connection.onRequest(
|
|
1421
|
-
"canvas.action.invoke",
|
|
1422
|
-
async (params) => this.handleCanvasActionInvokeRequest(params)
|
|
1423
|
-
);
|
|
1424
1401
|
const sessions = this.sessions;
|
|
1425
1402
|
(0, import_rpc.registerClientSessionApiHandlers)(this.connection, (sessionId) => {
|
|
1426
1403
|
const session = sessions.get(sessionId);
|
|
@@ -1542,26 +1519,6 @@ stderr: ${stderrOutput}`
|
|
|
1542
1519
|
}
|
|
1543
1520
|
return await session._handleSystemMessageTransform(params.sections);
|
|
1544
1521
|
}
|
|
1545
|
-
async handleCanvasProviderRequest(actionName, params) {
|
|
1546
|
-
if (!isCanvasProviderRequestParams(params)) {
|
|
1547
|
-
throw new Error("Invalid canvas provider request payload");
|
|
1548
|
-
}
|
|
1549
|
-
const session = this.sessions.get(params.sessionId);
|
|
1550
|
-
if (!session) {
|
|
1551
|
-
throw new Error(`Session not found: ${params.sessionId}`);
|
|
1552
|
-
}
|
|
1553
|
-
const canvas = session.getCanvas(params.canvasId);
|
|
1554
|
-
if (!canvas) {
|
|
1555
|
-
throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
1556
|
-
}
|
|
1557
|
-
return (0, import_canvas.dispatchCanvasProviderRequest)(canvas, actionName, params);
|
|
1558
|
-
}
|
|
1559
|
-
async handleCanvasActionInvokeRequest(params) {
|
|
1560
|
-
if (!isCanvasActionInvokeParams(params)) {
|
|
1561
|
-
throw new Error("Invalid canvas provider request payload");
|
|
1562
|
-
}
|
|
1563
|
-
return this.handleCanvasProviderRequest(params.actionName, params);
|
|
1564
|
-
}
|
|
1565
1522
|
}
|
|
1566
1523
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1567
1524
|
0 && (module.exports = {
|
|
@@ -275,7 +275,7 @@ function createServerRpc(connection) {
|
|
|
275
275
|
*
|
|
276
276
|
* @param params Session metadata records to enrich with summary and context information.
|
|
277
277
|
*
|
|
278
|
-
* @returns The
|
|
278
|
+
* @returns The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
|
|
279
279
|
*/
|
|
280
280
|
enrichMetadata: async (params) => connection.sendRequest("sessions.enrichMetadata", params),
|
|
281
281
|
/**
|
|
@@ -538,7 +538,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
538
538
|
*
|
|
539
539
|
* @returns Descriptor for the saved paste file, or null when the workspace is unavailable.
|
|
540
540
|
*/
|
|
541
|
-
saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params })
|
|
541
|
+
saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
|
|
542
|
+
/**
|
|
543
|
+
* Computes a diff for the session workspace.
|
|
544
|
+
*
|
|
545
|
+
* @param params Parameters for computing a workspace diff.
|
|
546
|
+
*
|
|
547
|
+
* @returns Workspace diff result for the requested mode.
|
|
548
|
+
*/
|
|
549
|
+
diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
|
|
542
550
|
},
|
|
543
551
|
/** @experimental */
|
|
544
552
|
instructions: {
|
|
@@ -1458,6 +1466,21 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
1458
1466
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
1459
1467
|
return handler.sqliteExists(params);
|
|
1460
1468
|
});
|
|
1469
|
+
connection.onRequest("canvas.open", async (params) => {
|
|
1470
|
+
const handler = getHandlers(params.sessionId).canvas;
|
|
1471
|
+
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1472
|
+
return handler.open(params);
|
|
1473
|
+
});
|
|
1474
|
+
connection.onRequest("canvas.close", async (params) => {
|
|
1475
|
+
const handler = getHandlers(params.sessionId).canvas;
|
|
1476
|
+
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1477
|
+
return handler.close(params);
|
|
1478
|
+
});
|
|
1479
|
+
connection.onRequest("canvas.invokeAction", async (params) => {
|
|
1480
|
+
const handler = getHandlers(params.sessionId).canvas;
|
|
1481
|
+
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1482
|
+
return handler.invokeAction(params);
|
|
1483
|
+
});
|
|
1461
1484
|
}
|
|
1462
1485
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1463
1486
|
0 && (module.exports = {
|
package/dist/cjs/session.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(session_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(session_exports);
|
|
24
24
|
var import_node = require("vscode-jsonrpc/node.js");
|
|
25
25
|
var import_rpc = require("./generated/rpc.js");
|
|
26
|
+
var import_canvas = require("./canvas.js");
|
|
26
27
|
var import_telemetry = require("./telemetry.js");
|
|
27
28
|
function deserializeHookInput(raw) {
|
|
28
29
|
if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
|
|
@@ -401,22 +402,52 @@ class CopilotSession {
|
|
|
401
402
|
*/
|
|
402
403
|
registerCanvases(canvases) {
|
|
403
404
|
this.canvases.clear();
|
|
404
|
-
if (!canvases) {
|
|
405
|
+
if (!canvases || canvases.length === 0) {
|
|
406
|
+
delete this.clientSessionApis.canvas;
|
|
405
407
|
return;
|
|
406
408
|
}
|
|
407
409
|
for (const canvas of canvases) {
|
|
408
410
|
this.canvases.set(canvas.declaration.id, canvas);
|
|
409
411
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
412
|
+
const self = this;
|
|
413
|
+
this.clientSessionApis.canvas = {
|
|
414
|
+
async open(params) {
|
|
415
|
+
const canvas = self.canvases.get(params.canvasId);
|
|
416
|
+
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
417
|
+
try {
|
|
418
|
+
return await canvas.open(params) ?? {};
|
|
419
|
+
} catch (error) {
|
|
420
|
+
throw toCanvasRpcError(error);
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
async close(params) {
|
|
424
|
+
const canvas = self.canvases.get(params.canvasId);
|
|
425
|
+
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
426
|
+
try {
|
|
427
|
+
if (canvas.onClose) {
|
|
428
|
+
await canvas.onClose(params);
|
|
429
|
+
}
|
|
430
|
+
} catch (error) {
|
|
431
|
+
throw toCanvasRpcError(error);
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
async invokeAction(params) {
|
|
435
|
+
const canvas = self.canvases.get(params.canvasId);
|
|
436
|
+
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
437
|
+
const handler = canvas.actionHandlers.get(params.actionName);
|
|
438
|
+
if (!handler) {
|
|
439
|
+
throw new import_canvas.CanvasError(
|
|
440
|
+
"canvas_action_no_handler",
|
|
441
|
+
"No handler implemented for this canvas action"
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
try {
|
|
445
|
+
return await handler(params);
|
|
446
|
+
} catch (error) {
|
|
447
|
+
throw toCanvasRpcError(error);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
};
|
|
420
451
|
}
|
|
421
452
|
/**
|
|
422
453
|
* Registers command handlers for this session.
|
|
@@ -867,6 +898,12 @@ function isToolResultObject(value) {
|
|
|
867
898
|
];
|
|
868
899
|
return allowedResultTypes.includes(value.resultType);
|
|
869
900
|
}
|
|
901
|
+
function toCanvasRpcError(error) {
|
|
902
|
+
if (error instanceof import_node.ResponseError) return error;
|
|
903
|
+
const code = error instanceof import_canvas.CanvasError ? error.code : "canvas_handler_error";
|
|
904
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
905
|
+
return new import_node.ResponseError(import_node.ErrorCodes.InternalError, message, { code, message });
|
|
906
|
+
}
|
|
870
907
|
// Annotate the CommonJS export names for ESM import in node:
|
|
871
908
|
0 && (module.exports = {
|
|
872
909
|
CopilotSession
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -17,9 +17,6 @@ import {
|
|
|
17
17
|
createInternalServerRpc,
|
|
18
18
|
registerClientSessionApiHandlers
|
|
19
19
|
} from "./generated/rpc.js";
|
|
20
|
-
import {
|
|
21
|
-
dispatchCanvasProviderRequest
|
|
22
|
-
} from "./canvas.js";
|
|
23
20
|
import { getSdkProtocolVersion } from "./sdkProtocolVersion.js";
|
|
24
21
|
import { CopilotSession } from "./session.js";
|
|
25
22
|
import { createSessionFsAdapter } from "./sessionFsProvider.js";
|
|
@@ -56,16 +53,6 @@ function toWireCustomAgents(agents) {
|
|
|
56
53
|
return { ...rest, mcpServers: toWireMcpServers(mcpServers) };
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
|
-
function isCanvasProviderRequestParams(params) {
|
|
60
|
-
if (!params || typeof params !== "object") {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
const request = params;
|
|
64
|
-
return typeof request.sessionId === "string" && typeof request.extensionId === "string" && typeof request.canvasId === "string" && typeof request.instanceId === "string";
|
|
65
|
-
}
|
|
66
|
-
function isCanvasActionInvokeParams(params) {
|
|
67
|
-
return isCanvasProviderRequestParams(params) && typeof params.actionName === "string";
|
|
68
|
-
}
|
|
69
56
|
function extractTransformCallbacks(systemMessage) {
|
|
70
57
|
if (!systemMessage || systemMessage.mode !== "customize" || !systemMessage.sections) {
|
|
71
58
|
return { wirePayload: systemMessage, transformCallbacks: void 0 };
|
|
@@ -1397,18 +1384,6 @@ stderr: ${stderrOutput}`
|
|
|
1397
1384
|
"systemMessage.transform",
|
|
1398
1385
|
async (params) => await this.handleSystemMessageTransform(params)
|
|
1399
1386
|
);
|
|
1400
|
-
this.connection.onRequest(
|
|
1401
|
-
"canvas.open",
|
|
1402
|
-
async (params) => this.handleCanvasProviderRequest("canvas.open", params)
|
|
1403
|
-
);
|
|
1404
|
-
this.connection.onRequest(
|
|
1405
|
-
"canvas.close",
|
|
1406
|
-
async (params) => this.handleCanvasProviderRequest("canvas.close", params)
|
|
1407
|
-
);
|
|
1408
|
-
this.connection.onRequest(
|
|
1409
|
-
"canvas.action.invoke",
|
|
1410
|
-
async (params) => this.handleCanvasActionInvokeRequest(params)
|
|
1411
|
-
);
|
|
1412
1387
|
const sessions = this.sessions;
|
|
1413
1388
|
registerClientSessionApiHandlers(this.connection, (sessionId) => {
|
|
1414
1389
|
const session = sessions.get(sessionId);
|
|
@@ -1530,26 +1505,6 @@ stderr: ${stderrOutput}`
|
|
|
1530
1505
|
}
|
|
1531
1506
|
return await session._handleSystemMessageTransform(params.sections);
|
|
1532
1507
|
}
|
|
1533
|
-
async handleCanvasProviderRequest(actionName, params) {
|
|
1534
|
-
if (!isCanvasProviderRequestParams(params)) {
|
|
1535
|
-
throw new Error("Invalid canvas provider request payload");
|
|
1536
|
-
}
|
|
1537
|
-
const session = this.sessions.get(params.sessionId);
|
|
1538
|
-
if (!session) {
|
|
1539
|
-
throw new Error(`Session not found: ${params.sessionId}`);
|
|
1540
|
-
}
|
|
1541
|
-
const canvas = session.getCanvas(params.canvasId);
|
|
1542
|
-
if (!canvas) {
|
|
1543
|
-
throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
1544
|
-
}
|
|
1545
|
-
return dispatchCanvasProviderRequest(canvas, actionName, params);
|
|
1546
|
-
}
|
|
1547
|
-
async handleCanvasActionInvokeRequest(params) {
|
|
1548
|
-
if (!isCanvasActionInvokeParams(params)) {
|
|
1549
|
-
throw new Error("Invalid canvas provider request payload");
|
|
1550
|
-
}
|
|
1551
|
-
return this.handleCanvasProviderRequest(params.actionName, params);
|
|
1552
|
-
}
|
|
1553
1508
|
}
|
|
1554
1509
|
export {
|
|
1555
1510
|
CopilotClient
|
package/dist/extension.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CopilotSession } from "./session.js";
|
|
2
2
|
import { type ExtensionInfo, type PermissionHandler, type ResumeSessionConfig } from "./types.js";
|
|
3
|
-
export { Canvas, CanvasError, createCanvas, type CanvasAction, type
|
|
3
|
+
export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
|
|
4
4
|
export type JoinSessionConfig = Omit<ResumeSessionConfig, "onPermissionRequest"> & {
|
|
5
5
|
onPermissionRequest?: PermissionHandler;
|
|
6
6
|
};
|
package/dist/generated/rpc.d.ts
CHANGED
|
@@ -428,6 +428,24 @@ export type McpAppsSetHostContextDetailsPlatform =
|
|
|
428
428
|
* via the `definition` "McpServerConfig".
|
|
429
429
|
*/
|
|
430
430
|
export type McpServerConfig = McpServerConfigStdio | McpServerConfigHttp;
|
|
431
|
+
/**
|
|
432
|
+
* OIDC token configuration. When truthy, a token is automatically gathered.
|
|
433
|
+
*
|
|
434
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
435
|
+
* via the `definition` "McpServerConfigStdioOidc".
|
|
436
|
+
*/
|
|
437
|
+
export type McpServerConfigStdioOidc = boolean | {
|
|
438
|
+
[k: string]: unknown | undefined;
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* Authentication configuration for this server.
|
|
442
|
+
*
|
|
443
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
444
|
+
* via the `definition` "McpServerConfigStdioAuth".
|
|
445
|
+
*/
|
|
446
|
+
export type McpServerConfigStdioAuth = boolean | {
|
|
447
|
+
[k: string]: unknown | undefined;
|
|
448
|
+
};
|
|
431
449
|
/**
|
|
432
450
|
* Remote transport type. Defaults to "http" when omitted.
|
|
433
451
|
*
|
|
@@ -439,6 +457,15 @@ export type McpServerConfigHttpType =
|
|
|
439
457
|
"http"
|
|
440
458
|
/** Server-Sent Events transport. */
|
|
441
459
|
| "sse";
|
|
460
|
+
/**
|
|
461
|
+
* OIDC token configuration. When truthy, a token is automatically gathered.
|
|
462
|
+
*
|
|
463
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
464
|
+
* via the `definition` "McpServerConfigHttpOidc".
|
|
465
|
+
*/
|
|
466
|
+
export type McpServerConfigHttpOidc = boolean | {
|
|
467
|
+
[k: string]: unknown | undefined;
|
|
468
|
+
};
|
|
442
469
|
/**
|
|
443
470
|
* OAuth grant type to use when authenticating to the remote MCP server.
|
|
444
471
|
*
|
|
@@ -790,6 +817,7 @@ export type SessionContextHostType =
|
|
|
790
817
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
791
818
|
* via the `definition` "SessionFsErrorCode".
|
|
792
819
|
*/
|
|
820
|
+
/** @experimental */
|
|
793
821
|
export type SessionFsErrorCode =
|
|
794
822
|
/** The requested path does not exist. */
|
|
795
823
|
"ENOENT"
|
|
@@ -801,6 +829,7 @@ export type SessionFsErrorCode =
|
|
|
801
829
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
802
830
|
* via the `definition` "SessionFsReaddirWithTypesEntryType".
|
|
803
831
|
*/
|
|
832
|
+
/** @experimental */
|
|
804
833
|
export type SessionFsReaddirWithTypesEntryType =
|
|
805
834
|
/** The entry is a file. */
|
|
806
835
|
"file"
|
|
@@ -823,6 +852,7 @@ export type SessionFsSetProviderConventions =
|
|
|
823
852
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
824
853
|
* via the `definition` "SessionFsSqliteQueryType".
|
|
825
854
|
*/
|
|
855
|
+
/** @experimental */
|
|
826
856
|
export type SessionFsSqliteQueryType =
|
|
827
857
|
/** Execute DDL or multi-statement SQL without returning rows. */
|
|
828
858
|
"exec"
|
|
@@ -1060,6 +1090,34 @@ export type UIExitPlanModeAction =
|
|
|
1060
1090
|
| "autopilot"
|
|
1061
1091
|
/** Exit plan mode and continue in autopilot mode with parallel subagent execution. */
|
|
1062
1092
|
| "autopilot_fleet";
|
|
1093
|
+
/**
|
|
1094
|
+
* Type of change represented by this file diff.
|
|
1095
|
+
*
|
|
1096
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1097
|
+
* via the `definition` "WorkspaceDiffFileChangeType".
|
|
1098
|
+
*/
|
|
1099
|
+
/** @experimental */
|
|
1100
|
+
export type WorkspaceDiffFileChangeType =
|
|
1101
|
+
/** The file was added. */
|
|
1102
|
+
"added"
|
|
1103
|
+
/** The file was modified. */
|
|
1104
|
+
| "modified"
|
|
1105
|
+
/** The file was deleted. */
|
|
1106
|
+
| "deleted"
|
|
1107
|
+
/** The file was renamed. */
|
|
1108
|
+
| "renamed";
|
|
1109
|
+
/**
|
|
1110
|
+
* Diff mode requested by the client.
|
|
1111
|
+
*
|
|
1112
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1113
|
+
* via the `definition` "WorkspaceDiffMode".
|
|
1114
|
+
*/
|
|
1115
|
+
/** @experimental */
|
|
1116
|
+
export type WorkspaceDiffMode =
|
|
1117
|
+
/** Return staged, unstaged, and untracked working tree changes. */
|
|
1118
|
+
"unstaged"
|
|
1119
|
+
/** Return changes compared with the default branch. */
|
|
1120
|
+
| "branch";
|
|
1063
1121
|
/**
|
|
1064
1122
|
* Allowed values for the `WorkspacesWorkspaceDetailsHostType` enumeration.
|
|
1065
1123
|
*
|
|
@@ -1629,6 +1687,29 @@ export interface CanvasCloseRequest {
|
|
|
1629
1687
|
*/
|
|
1630
1688
|
instanceId: string;
|
|
1631
1689
|
}
|
|
1690
|
+
/**
|
|
1691
|
+
* Host context supplied by the runtime.
|
|
1692
|
+
*
|
|
1693
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1694
|
+
* via the `definition` "CanvasHostContext".
|
|
1695
|
+
*/
|
|
1696
|
+
/** @experimental */
|
|
1697
|
+
export interface CanvasHostContext {
|
|
1698
|
+
capabilities?: CanvasHostContextCapabilities;
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Host capabilities
|
|
1702
|
+
*
|
|
1703
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1704
|
+
* via the `definition` "CanvasHostContextCapabilities".
|
|
1705
|
+
*/
|
|
1706
|
+
/** @experimental */
|
|
1707
|
+
export interface CanvasHostContextCapabilities {
|
|
1708
|
+
/**
|
|
1709
|
+
* Whether canvas rendering is supported
|
|
1710
|
+
*/
|
|
1711
|
+
canvases?: boolean;
|
|
1712
|
+
}
|
|
1632
1713
|
/**
|
|
1633
1714
|
* Canvas action invocation parameters.
|
|
1634
1715
|
*
|
|
@@ -1653,19 +1734,14 @@ export interface CanvasInvokeActionRequest {
|
|
|
1653
1734
|
};
|
|
1654
1735
|
}
|
|
1655
1736
|
/**
|
|
1656
|
-
*
|
|
1737
|
+
* Provider-supplied action result.
|
|
1657
1738
|
*
|
|
1658
1739
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1659
1740
|
* via the `definition` "CanvasInvokeActionResult".
|
|
1660
1741
|
*/
|
|
1661
1742
|
/** @experimental */
|
|
1662
1743
|
export interface CanvasInvokeActionResult {
|
|
1663
|
-
|
|
1664
|
-
* Provider-supplied action result
|
|
1665
|
-
*/
|
|
1666
|
-
result?: {
|
|
1667
|
-
[k: string]: unknown | undefined;
|
|
1668
|
-
};
|
|
1744
|
+
[k: string]: unknown | undefined;
|
|
1669
1745
|
}
|
|
1670
1746
|
/**
|
|
1671
1747
|
* Declared canvases available in this session.
|
|
@@ -1802,6 +1878,121 @@ export interface CanvasOpenRequest {
|
|
|
1802
1878
|
[k: string]: unknown | undefined;
|
|
1803
1879
|
};
|
|
1804
1880
|
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Canvas close parameters sent to the provider.
|
|
1883
|
+
*
|
|
1884
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1885
|
+
* via the `definition` "CanvasProviderCloseRequest".
|
|
1886
|
+
*/
|
|
1887
|
+
/** @experimental */
|
|
1888
|
+
export interface CanvasProviderCloseRequest {
|
|
1889
|
+
/**
|
|
1890
|
+
* Target session identifier
|
|
1891
|
+
*/
|
|
1892
|
+
sessionId: string;
|
|
1893
|
+
/**
|
|
1894
|
+
* Owning provider identifier
|
|
1895
|
+
*/
|
|
1896
|
+
extensionId: string;
|
|
1897
|
+
/**
|
|
1898
|
+
* Provider-local canvas identifier
|
|
1899
|
+
*/
|
|
1900
|
+
canvasId: string;
|
|
1901
|
+
/**
|
|
1902
|
+
* Canvas instance identifier
|
|
1903
|
+
*/
|
|
1904
|
+
instanceId: string;
|
|
1905
|
+
host?: CanvasHostContext;
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Canvas action invocation parameters sent to the provider.
|
|
1909
|
+
*
|
|
1910
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1911
|
+
* via the `definition` "CanvasProviderInvokeActionRequest".
|
|
1912
|
+
*/
|
|
1913
|
+
/** @experimental */
|
|
1914
|
+
export interface CanvasProviderInvokeActionRequest {
|
|
1915
|
+
/**
|
|
1916
|
+
* Target session identifier
|
|
1917
|
+
*/
|
|
1918
|
+
sessionId: string;
|
|
1919
|
+
/**
|
|
1920
|
+
* Owning provider identifier
|
|
1921
|
+
*/
|
|
1922
|
+
extensionId: string;
|
|
1923
|
+
/**
|
|
1924
|
+
* Provider-local canvas identifier
|
|
1925
|
+
*/
|
|
1926
|
+
canvasId: string;
|
|
1927
|
+
/**
|
|
1928
|
+
* Canvas instance identifier
|
|
1929
|
+
*/
|
|
1930
|
+
instanceId: string;
|
|
1931
|
+
/**
|
|
1932
|
+
* Action name to invoke
|
|
1933
|
+
*/
|
|
1934
|
+
actionName: string;
|
|
1935
|
+
/**
|
|
1936
|
+
* Action input
|
|
1937
|
+
*/
|
|
1938
|
+
input?: {
|
|
1939
|
+
[k: string]: unknown | undefined;
|
|
1940
|
+
};
|
|
1941
|
+
host?: CanvasHostContext;
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
* Canvas open parameters sent to the provider.
|
|
1945
|
+
*
|
|
1946
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1947
|
+
* via the `definition` "CanvasProviderOpenRequest".
|
|
1948
|
+
*/
|
|
1949
|
+
/** @experimental */
|
|
1950
|
+
export interface CanvasProviderOpenRequest {
|
|
1951
|
+
/**
|
|
1952
|
+
* Target session identifier
|
|
1953
|
+
*/
|
|
1954
|
+
sessionId: string;
|
|
1955
|
+
/**
|
|
1956
|
+
* Owning provider identifier
|
|
1957
|
+
*/
|
|
1958
|
+
extensionId: string;
|
|
1959
|
+
/**
|
|
1960
|
+
* Provider-local canvas identifier
|
|
1961
|
+
*/
|
|
1962
|
+
canvasId: string;
|
|
1963
|
+
/**
|
|
1964
|
+
* Stable caller-supplied canvas instance identifier
|
|
1965
|
+
*/
|
|
1966
|
+
instanceId: string;
|
|
1967
|
+
/**
|
|
1968
|
+
* Canvas open input
|
|
1969
|
+
*/
|
|
1970
|
+
input?: {
|
|
1971
|
+
[k: string]: unknown | undefined;
|
|
1972
|
+
};
|
|
1973
|
+
host?: CanvasHostContext;
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Canvas open result returned by the provider.
|
|
1977
|
+
*
|
|
1978
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
1979
|
+
* via the `definition` "CanvasProviderOpenResult".
|
|
1980
|
+
*/
|
|
1981
|
+
/** @experimental */
|
|
1982
|
+
export interface CanvasProviderOpenResult {
|
|
1983
|
+
/**
|
|
1984
|
+
* URL for web-rendered canvases
|
|
1985
|
+
*/
|
|
1986
|
+
url?: string;
|
|
1987
|
+
/**
|
|
1988
|
+
* Provider-supplied title
|
|
1989
|
+
*/
|
|
1990
|
+
title?: string;
|
|
1991
|
+
/**
|
|
1992
|
+
* Provider-supplied status text
|
|
1993
|
+
*/
|
|
1994
|
+
status?: string;
|
|
1995
|
+
}
|
|
1805
1996
|
/**
|
|
1806
1997
|
* Slash commands available in the session, after applying any include/exclude filters.
|
|
1807
1998
|
*
|
|
@@ -3283,6 +3474,8 @@ export interface McpServerConfigStdio {
|
|
|
3283
3474
|
* Timeout in milliseconds for tool calls to this server.
|
|
3284
3475
|
*/
|
|
3285
3476
|
timeout?: number;
|
|
3477
|
+
oidc?: McpServerConfigStdioOidc;
|
|
3478
|
+
auth?: McpServerConfigStdioAuth;
|
|
3286
3479
|
/**
|
|
3287
3480
|
* Executable command used to start the Stdio MCP server process.
|
|
3288
3481
|
*/
|
|
@@ -3323,6 +3516,8 @@ export interface McpServerConfigHttp {
|
|
|
3323
3516
|
* Timeout in milliseconds for tool calls to this server.
|
|
3324
3517
|
*/
|
|
3325
3518
|
timeout?: number;
|
|
3519
|
+
oidc?: McpServerConfigHttpOidc;
|
|
3520
|
+
auth?: McpServerConfigHttpAuth;
|
|
3326
3521
|
/**
|
|
3327
3522
|
* URL of the remote MCP server endpoint.
|
|
3328
3523
|
*/
|
|
@@ -3342,7 +3537,6 @@ export interface McpServerConfigHttp {
|
|
|
3342
3537
|
*/
|
|
3343
3538
|
oauthPublicClient?: boolean;
|
|
3344
3539
|
oauthGrantType?: McpServerConfigHttpOauthGrantType;
|
|
3345
|
-
auth?: McpServerConfigHttpAuth;
|
|
3346
3540
|
}
|
|
3347
3541
|
/**
|
|
3348
3542
|
* Additional authentication configuration for this server.
|
|
@@ -3355,6 +3549,7 @@ export interface McpServerConfigHttpAuth {
|
|
|
3355
3549
|
* Fixed port for the OAuth redirect callback server.
|
|
3356
3550
|
*/
|
|
3357
3551
|
redirectPort?: number;
|
|
3552
|
+
[k: string]: unknown | undefined;
|
|
3358
3553
|
}
|
|
3359
3554
|
/**
|
|
3360
3555
|
* MCP server names to disable for new sessions.
|
|
@@ -6211,7 +6406,7 @@ export interface SessionContext {
|
|
|
6211
6406
|
branch?: string;
|
|
6212
6407
|
}
|
|
6213
6408
|
/**
|
|
6214
|
-
* The
|
|
6409
|
+
* The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
|
|
6215
6410
|
*
|
|
6216
6411
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6217
6412
|
* via the `definition` "SessionEnrichMetadataResult".
|
|
@@ -6219,7 +6414,7 @@ export interface SessionContext {
|
|
|
6219
6414
|
/** @experimental */
|
|
6220
6415
|
export interface SessionEnrichMetadataResult {
|
|
6221
6416
|
/**
|
|
6222
|
-
*
|
|
6417
|
+
* Enriched records, with summary and context backfilled. Sessions confirmed empty and unnamed may be omitted.
|
|
6223
6418
|
*/
|
|
6224
6419
|
sessions: SessionMetadata[];
|
|
6225
6420
|
}
|
|
@@ -6267,6 +6462,7 @@ export interface SessionMetadata {
|
|
|
6267
6462
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6268
6463
|
* via the `definition` "SessionFsAppendFileRequest".
|
|
6269
6464
|
*/
|
|
6465
|
+
/** @experimental */
|
|
6270
6466
|
export interface SessionFsAppendFileRequest {
|
|
6271
6467
|
/**
|
|
6272
6468
|
* Target session identifier
|
|
@@ -6291,6 +6487,7 @@ export interface SessionFsAppendFileRequest {
|
|
|
6291
6487
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6292
6488
|
* via the `definition` "SessionFsError".
|
|
6293
6489
|
*/
|
|
6490
|
+
/** @experimental */
|
|
6294
6491
|
export interface SessionFsError {
|
|
6295
6492
|
code: SessionFsErrorCode;
|
|
6296
6493
|
/**
|
|
@@ -6304,6 +6501,7 @@ export interface SessionFsError {
|
|
|
6304
6501
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6305
6502
|
* via the `definition` "SessionFsExistsRequest".
|
|
6306
6503
|
*/
|
|
6504
|
+
/** @experimental */
|
|
6307
6505
|
export interface SessionFsExistsRequest {
|
|
6308
6506
|
/**
|
|
6309
6507
|
* Target session identifier
|
|
@@ -6320,6 +6518,7 @@ export interface SessionFsExistsRequest {
|
|
|
6320
6518
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6321
6519
|
* via the `definition` "SessionFsExistsResult".
|
|
6322
6520
|
*/
|
|
6521
|
+
/** @experimental */
|
|
6323
6522
|
export interface SessionFsExistsResult {
|
|
6324
6523
|
/**
|
|
6325
6524
|
* Whether the path exists
|
|
@@ -6332,6 +6531,7 @@ export interface SessionFsExistsResult {
|
|
|
6332
6531
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6333
6532
|
* via the `definition` "SessionFsMkdirRequest".
|
|
6334
6533
|
*/
|
|
6534
|
+
/** @experimental */
|
|
6335
6535
|
export interface SessionFsMkdirRequest {
|
|
6336
6536
|
/**
|
|
6337
6537
|
* Target session identifier
|
|
@@ -6356,6 +6556,7 @@ export interface SessionFsMkdirRequest {
|
|
|
6356
6556
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6357
6557
|
* via the `definition` "SessionFsReaddirRequest".
|
|
6358
6558
|
*/
|
|
6559
|
+
/** @experimental */
|
|
6359
6560
|
export interface SessionFsReaddirRequest {
|
|
6360
6561
|
/**
|
|
6361
6562
|
* Target session identifier
|
|
@@ -6372,6 +6573,7 @@ export interface SessionFsReaddirRequest {
|
|
|
6372
6573
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6373
6574
|
* via the `definition` "SessionFsReaddirResult".
|
|
6374
6575
|
*/
|
|
6576
|
+
/** @experimental */
|
|
6375
6577
|
export interface SessionFsReaddirResult {
|
|
6376
6578
|
/**
|
|
6377
6579
|
* Entry names in the directory
|
|
@@ -6385,6 +6587,7 @@ export interface SessionFsReaddirResult {
|
|
|
6385
6587
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6386
6588
|
* via the `definition` "SessionFsReaddirWithTypesEntry".
|
|
6387
6589
|
*/
|
|
6590
|
+
/** @experimental */
|
|
6388
6591
|
export interface SessionFsReaddirWithTypesEntry {
|
|
6389
6592
|
/**
|
|
6390
6593
|
* Entry name
|
|
@@ -6398,6 +6601,7 @@ export interface SessionFsReaddirWithTypesEntry {
|
|
|
6398
6601
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6399
6602
|
* via the `definition` "SessionFsReaddirWithTypesRequest".
|
|
6400
6603
|
*/
|
|
6604
|
+
/** @experimental */
|
|
6401
6605
|
export interface SessionFsReaddirWithTypesRequest {
|
|
6402
6606
|
/**
|
|
6403
6607
|
* Target session identifier
|
|
@@ -6414,6 +6618,7 @@ export interface SessionFsReaddirWithTypesRequest {
|
|
|
6414
6618
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6415
6619
|
* via the `definition` "SessionFsReaddirWithTypesResult".
|
|
6416
6620
|
*/
|
|
6621
|
+
/** @experimental */
|
|
6417
6622
|
export interface SessionFsReaddirWithTypesResult {
|
|
6418
6623
|
/**
|
|
6419
6624
|
* Directory entries with type information
|
|
@@ -6427,6 +6632,7 @@ export interface SessionFsReaddirWithTypesResult {
|
|
|
6427
6632
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6428
6633
|
* via the `definition` "SessionFsReadFileRequest".
|
|
6429
6634
|
*/
|
|
6635
|
+
/** @experimental */
|
|
6430
6636
|
export interface SessionFsReadFileRequest {
|
|
6431
6637
|
/**
|
|
6432
6638
|
* Target session identifier
|
|
@@ -6443,6 +6649,7 @@ export interface SessionFsReadFileRequest {
|
|
|
6443
6649
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6444
6650
|
* via the `definition` "SessionFsReadFileResult".
|
|
6445
6651
|
*/
|
|
6652
|
+
/** @experimental */
|
|
6446
6653
|
export interface SessionFsReadFileResult {
|
|
6447
6654
|
/**
|
|
6448
6655
|
* File content as UTF-8 string
|
|
@@ -6456,6 +6663,7 @@ export interface SessionFsReadFileResult {
|
|
|
6456
6663
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6457
6664
|
* via the `definition` "SessionFsRenameRequest".
|
|
6458
6665
|
*/
|
|
6666
|
+
/** @experimental */
|
|
6459
6667
|
export interface SessionFsRenameRequest {
|
|
6460
6668
|
/**
|
|
6461
6669
|
* Target session identifier
|
|
@@ -6476,6 +6684,7 @@ export interface SessionFsRenameRequest {
|
|
|
6476
6684
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6477
6685
|
* via the `definition` "SessionFsRmRequest".
|
|
6478
6686
|
*/
|
|
6687
|
+
/** @experimental */
|
|
6479
6688
|
export interface SessionFsRmRequest {
|
|
6480
6689
|
/**
|
|
6481
6690
|
* Target session identifier
|
|
@@ -6542,6 +6751,7 @@ export interface SessionFsSetProviderResult {
|
|
|
6542
6751
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6543
6752
|
* via the `definition` "SessionFsSqliteExistsResult".
|
|
6544
6753
|
*/
|
|
6754
|
+
/** @experimental */
|
|
6545
6755
|
export interface SessionFsSqliteExistsResult {
|
|
6546
6756
|
/**
|
|
6547
6757
|
* Whether the session database already exists
|
|
@@ -6554,6 +6764,7 @@ export interface SessionFsSqliteExistsResult {
|
|
|
6554
6764
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6555
6765
|
* via the `definition` "SessionFsSqliteQueryRequest".
|
|
6556
6766
|
*/
|
|
6767
|
+
/** @experimental */
|
|
6557
6768
|
export interface SessionFsSqliteQueryRequest {
|
|
6558
6769
|
/**
|
|
6559
6770
|
* Target session identifier
|
|
@@ -6577,6 +6788,7 @@ export interface SessionFsSqliteQueryRequest {
|
|
|
6577
6788
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6578
6789
|
* via the `definition` "SessionFsSqliteQueryResult".
|
|
6579
6790
|
*/
|
|
6791
|
+
/** @experimental */
|
|
6580
6792
|
export interface SessionFsSqliteQueryResult {
|
|
6581
6793
|
/**
|
|
6582
6794
|
* For SELECT: array of row objects. For others: empty array.
|
|
@@ -6604,6 +6816,7 @@ export interface SessionFsSqliteQueryResult {
|
|
|
6604
6816
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6605
6817
|
* via the `definition` "SessionFsStatRequest".
|
|
6606
6818
|
*/
|
|
6819
|
+
/** @experimental */
|
|
6607
6820
|
export interface SessionFsStatRequest {
|
|
6608
6821
|
/**
|
|
6609
6822
|
* Target session identifier
|
|
@@ -6620,6 +6833,7 @@ export interface SessionFsStatRequest {
|
|
|
6620
6833
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6621
6834
|
* via the `definition` "SessionFsStatResult".
|
|
6622
6835
|
*/
|
|
6836
|
+
/** @experimental */
|
|
6623
6837
|
export interface SessionFsStatResult {
|
|
6624
6838
|
/**
|
|
6625
6839
|
* Whether the path is a file
|
|
@@ -6649,6 +6863,7 @@ export interface SessionFsStatResult {
|
|
|
6649
6863
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
6650
6864
|
* via the `definition` "SessionFsWriteFileRequest".
|
|
6651
6865
|
*/
|
|
6866
|
+
/** @experimental */
|
|
6652
6867
|
export interface SessionFsWriteFileRequest {
|
|
6653
6868
|
/**
|
|
6654
6869
|
* Target session identifier
|
|
@@ -9035,6 +9250,55 @@ export interface UsageMetricsModelMetricTokenDetail {
|
|
|
9035
9250
|
*/
|
|
9036
9251
|
tokenCount: number;
|
|
9037
9252
|
}
|
|
9253
|
+
/**
|
|
9254
|
+
* A single changed file and its unified diff.
|
|
9255
|
+
*
|
|
9256
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
9257
|
+
* via the `definition` "WorkspaceDiffFileChange".
|
|
9258
|
+
*/
|
|
9259
|
+
/** @experimental */
|
|
9260
|
+
export interface WorkspaceDiffFileChange {
|
|
9261
|
+
/**
|
|
9262
|
+
* Path to the changed file, relative to the workspace root.
|
|
9263
|
+
*/
|
|
9264
|
+
path: string;
|
|
9265
|
+
/**
|
|
9266
|
+
* Unified diff content for the file. Empty when the diff was truncated.
|
|
9267
|
+
*/
|
|
9268
|
+
diff: string;
|
|
9269
|
+
changeType: WorkspaceDiffFileChangeType;
|
|
9270
|
+
/**
|
|
9271
|
+
* Original file path for renamed files.
|
|
9272
|
+
*/
|
|
9273
|
+
oldPath?: string;
|
|
9274
|
+
/**
|
|
9275
|
+
* Whether the diff content was omitted because it exceeded the per-file size limit.
|
|
9276
|
+
*/
|
|
9277
|
+
isTruncated?: boolean;
|
|
9278
|
+
}
|
|
9279
|
+
/**
|
|
9280
|
+
* Workspace diff result for the requested mode.
|
|
9281
|
+
*
|
|
9282
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
9283
|
+
* via the `definition` "WorkspaceDiffResult".
|
|
9284
|
+
*/
|
|
9285
|
+
/** @experimental */
|
|
9286
|
+
export interface WorkspaceDiffResult {
|
|
9287
|
+
requestedMode: WorkspaceDiffMode;
|
|
9288
|
+
mode: WorkspaceDiffMode;
|
|
9289
|
+
/**
|
|
9290
|
+
* Changed files and their unified diffs.
|
|
9291
|
+
*/
|
|
9292
|
+
changes: WorkspaceDiffFileChange[];
|
|
9293
|
+
/**
|
|
9294
|
+
* Default branch used for a branch diff, when branch mode was requested.
|
|
9295
|
+
*/
|
|
9296
|
+
baseBranch?: string;
|
|
9297
|
+
/**
|
|
9298
|
+
* Whether a requested branch diff fell back to unstaged changes because branch diff failed.
|
|
9299
|
+
*/
|
|
9300
|
+
isFallback: boolean;
|
|
9301
|
+
}
|
|
9038
9302
|
/**
|
|
9039
9303
|
* Schema for the `WorkspacesCheckpoints` type.
|
|
9040
9304
|
*
|
|
@@ -9073,6 +9337,16 @@ export interface WorkspacesCreateFileRequest {
|
|
|
9073
9337
|
*/
|
|
9074
9338
|
content: string;
|
|
9075
9339
|
}
|
|
9340
|
+
/**
|
|
9341
|
+
* Parameters for computing a workspace diff.
|
|
9342
|
+
*
|
|
9343
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
9344
|
+
* via the `definition` "WorkspacesDiffRequest".
|
|
9345
|
+
*/
|
|
9346
|
+
/** @experimental */
|
|
9347
|
+
export interface WorkspacesDiffRequest {
|
|
9348
|
+
mode: WorkspaceDiffMode;
|
|
9349
|
+
}
|
|
9076
9350
|
/**
|
|
9077
9351
|
* Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
9078
9352
|
*
|
|
@@ -9240,6 +9514,7 @@ export interface SessionMcpAppsCallToolResult {
|
|
|
9240
9514
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
9241
9515
|
* via the `definition` "SessionFsSqliteExistsRequest".
|
|
9242
9516
|
*/
|
|
9517
|
+
/** @experimental */
|
|
9243
9518
|
export interface SessionFsSqliteExistsRequest {
|
|
9244
9519
|
/**
|
|
9245
9520
|
* Target session identifier
|
|
@@ -9497,7 +9772,7 @@ export declare function createServerRpc(connection: MessageConnection): {
|
|
|
9497
9772
|
*
|
|
9498
9773
|
* @param params Session metadata records to enrich with summary and context information.
|
|
9499
9774
|
*
|
|
9500
|
-
* @returns The
|
|
9775
|
+
* @returns The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
|
|
9501
9776
|
*/
|
|
9502
9777
|
enrichMetadata: (params: SessionsEnrichMetadataRequest) => Promise<SessionEnrichMetadataResult>;
|
|
9503
9778
|
/**
|
|
@@ -9748,6 +10023,14 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
|
|
|
9748
10023
|
* @returns Descriptor for the saved paste file, or null when the workspace is unavailable.
|
|
9749
10024
|
*/
|
|
9750
10025
|
saveLargePaste: (params: WorkspacesSaveLargePasteRequest) => Promise<WorkspacesSaveLargePasteResult>;
|
|
10026
|
+
/**
|
|
10027
|
+
* Computes a diff for the session workspace.
|
|
10028
|
+
*
|
|
10029
|
+
* @param params Parameters for computing a workspace diff.
|
|
10030
|
+
*
|
|
10031
|
+
* @returns Workspace diff result for the requested mode.
|
|
10032
|
+
*/
|
|
10033
|
+
diff: (params: WorkspacesDiffRequest) => Promise<WorkspaceDiffResult>;
|
|
9751
10034
|
};
|
|
9752
10035
|
/** @experimental */
|
|
9753
10036
|
instructions: {
|
|
@@ -10606,6 +10889,7 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
|
|
|
10606
10889
|
};
|
|
10607
10890
|
};
|
|
10608
10891
|
/** Handler for `sessionFs` client session API methods. */
|
|
10892
|
+
/** @experimental */
|
|
10609
10893
|
export interface SessionFsHandler {
|
|
10610
10894
|
/**
|
|
10611
10895
|
* Reads a file from the client-provided session filesystem.
|
|
@@ -10704,9 +10988,36 @@ export interface SessionFsHandler {
|
|
|
10704
10988
|
*/
|
|
10705
10989
|
sqliteExists(params: SessionFsSqliteExistsRequest): Promise<SessionFsSqliteExistsResult>;
|
|
10706
10990
|
}
|
|
10991
|
+
/** Handler for `canvas` client session API methods. */
|
|
10992
|
+
/** @experimental */
|
|
10993
|
+
export interface CanvasHandler {
|
|
10994
|
+
/**
|
|
10995
|
+
* Opens a canvas instance on the provider.
|
|
10996
|
+
*
|
|
10997
|
+
* @param params Canvas open parameters sent to the provider.
|
|
10998
|
+
*
|
|
10999
|
+
* @returns Canvas open result returned by the provider.
|
|
11000
|
+
*/
|
|
11001
|
+
open(params: CanvasProviderOpenRequest): Promise<CanvasProviderOpenResult>;
|
|
11002
|
+
/**
|
|
11003
|
+
* Closes a canvas instance on the provider.
|
|
11004
|
+
*
|
|
11005
|
+
* @param params Canvas close parameters sent to the provider.
|
|
11006
|
+
*/
|
|
11007
|
+
close(params: CanvasProviderCloseRequest): Promise<void>;
|
|
11008
|
+
/**
|
|
11009
|
+
* Invokes an action on an open canvas instance via the provider.
|
|
11010
|
+
*
|
|
11011
|
+
* @param params Canvas action invocation parameters sent to the provider.
|
|
11012
|
+
*
|
|
11013
|
+
* @returns Provider-supplied action result.
|
|
11014
|
+
*/
|
|
11015
|
+
invokeAction(params: CanvasProviderInvokeActionRequest): Promise<CanvasInvokeActionResult>;
|
|
11016
|
+
}
|
|
10707
11017
|
/** All client session API handler groups. */
|
|
10708
11018
|
export interface ClientSessionApiHandlers {
|
|
10709
11019
|
sessionFs?: SessionFsHandler;
|
|
11020
|
+
canvas?: CanvasHandler;
|
|
10710
11021
|
}
|
|
10711
11022
|
/**
|
|
10712
11023
|
* Register client session API handlers on a JSON-RPC connection.
|
package/dist/generated/rpc.js
CHANGED
|
@@ -249,7 +249,7 @@ function createServerRpc(connection) {
|
|
|
249
249
|
*
|
|
250
250
|
* @param params Session metadata records to enrich with summary and context information.
|
|
251
251
|
*
|
|
252
|
-
* @returns The
|
|
252
|
+
* @returns The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
|
|
253
253
|
*/
|
|
254
254
|
enrichMetadata: async (params) => connection.sendRequest("sessions.enrichMetadata", params),
|
|
255
255
|
/**
|
|
@@ -512,7 +512,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
512
512
|
*
|
|
513
513
|
* @returns Descriptor for the saved paste file, or null when the workspace is unavailable.
|
|
514
514
|
*/
|
|
515
|
-
saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params })
|
|
515
|
+
saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
|
|
516
|
+
/**
|
|
517
|
+
* Computes a diff for the session workspace.
|
|
518
|
+
*
|
|
519
|
+
* @param params Parameters for computing a workspace diff.
|
|
520
|
+
*
|
|
521
|
+
* @returns Workspace diff result for the requested mode.
|
|
522
|
+
*/
|
|
523
|
+
diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
|
|
516
524
|
},
|
|
517
525
|
/** @experimental */
|
|
518
526
|
instructions: {
|
|
@@ -1432,6 +1440,21 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
1432
1440
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
1433
1441
|
return handler.sqliteExists(params);
|
|
1434
1442
|
});
|
|
1443
|
+
connection.onRequest("canvas.open", async (params) => {
|
|
1444
|
+
const handler = getHandlers(params.sessionId).canvas;
|
|
1445
|
+
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1446
|
+
return handler.open(params);
|
|
1447
|
+
});
|
|
1448
|
+
connection.onRequest("canvas.close", async (params) => {
|
|
1449
|
+
const handler = getHandlers(params.sessionId).canvas;
|
|
1450
|
+
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1451
|
+
return handler.close(params);
|
|
1452
|
+
});
|
|
1453
|
+
connection.onRequest("canvas.invokeAction", async (params) => {
|
|
1454
|
+
const handler = getHandlers(params.sessionId).canvas;
|
|
1455
|
+
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1456
|
+
return handler.invokeAction(params);
|
|
1457
|
+
});
|
|
1435
1458
|
}
|
|
1436
1459
|
export {
|
|
1437
1460
|
createInternalServerRpc,
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +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 { Canvas, CanvasError, createCanvas, type CanvasAction, type
|
|
9
|
+
export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
|
|
10
10
|
export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
|
|
11
11
|
export type * from "./generated/session-events.js";
|
|
12
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/session.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ConnectionError, ResponseError } from "vscode-jsonrpc/node.js";
|
|
1
|
+
import { ConnectionError, ErrorCodes, ResponseError } from "vscode-jsonrpc/node.js";
|
|
2
2
|
import { createSessionRpc } from "./generated/rpc.js";
|
|
3
|
+
import { CanvasError } from "./canvas.js";
|
|
3
4
|
import { getTraceContext } from "./telemetry.js";
|
|
4
5
|
function deserializeHookInput(raw) {
|
|
5
6
|
if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
|
|
@@ -378,22 +379,52 @@ class CopilotSession {
|
|
|
378
379
|
*/
|
|
379
380
|
registerCanvases(canvases) {
|
|
380
381
|
this.canvases.clear();
|
|
381
|
-
if (!canvases) {
|
|
382
|
+
if (!canvases || canvases.length === 0) {
|
|
383
|
+
delete this.clientSessionApis.canvas;
|
|
382
384
|
return;
|
|
383
385
|
}
|
|
384
386
|
for (const canvas of canvases) {
|
|
385
387
|
this.canvases.set(canvas.declaration.id, canvas);
|
|
386
388
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
389
|
+
const self = this;
|
|
390
|
+
this.clientSessionApis.canvas = {
|
|
391
|
+
async open(params) {
|
|
392
|
+
const canvas = self.canvases.get(params.canvasId);
|
|
393
|
+
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
394
|
+
try {
|
|
395
|
+
return await canvas.open(params) ?? {};
|
|
396
|
+
} catch (error) {
|
|
397
|
+
throw toCanvasRpcError(error);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
async close(params) {
|
|
401
|
+
const canvas = self.canvases.get(params.canvasId);
|
|
402
|
+
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
403
|
+
try {
|
|
404
|
+
if (canvas.onClose) {
|
|
405
|
+
await canvas.onClose(params);
|
|
406
|
+
}
|
|
407
|
+
} catch (error) {
|
|
408
|
+
throw toCanvasRpcError(error);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
async invokeAction(params) {
|
|
412
|
+
const canvas = self.canvases.get(params.canvasId);
|
|
413
|
+
if (!canvas) throw new Error(`No canvas registered with id "${params.canvasId}"`);
|
|
414
|
+
const handler = canvas.actionHandlers.get(params.actionName);
|
|
415
|
+
if (!handler) {
|
|
416
|
+
throw new CanvasError(
|
|
417
|
+
"canvas_action_no_handler",
|
|
418
|
+
"No handler implemented for this canvas action"
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
try {
|
|
422
|
+
return await handler(params);
|
|
423
|
+
} catch (error) {
|
|
424
|
+
throw toCanvasRpcError(error);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
397
428
|
}
|
|
398
429
|
/**
|
|
399
430
|
* Registers command handlers for this session.
|
|
@@ -844,6 +875,12 @@ function isToolResultObject(value) {
|
|
|
844
875
|
];
|
|
845
876
|
return allowedResultTypes.includes(value.resultType);
|
|
846
877
|
}
|
|
878
|
+
function toCanvasRpcError(error) {
|
|
879
|
+
if (error instanceof ResponseError) return error;
|
|
880
|
+
const code = error instanceof CanvasError ? error.code : "canvas_handler_error";
|
|
881
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
882
|
+
return new ResponseError(ErrorCodes.InternalError, message, { code, message });
|
|
883
|
+
}
|
|
847
884
|
export {
|
|
848
885
|
CopilotSession
|
|
849
886
|
};
|
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.
|
|
7
|
+
"version": "1.0.0-beta.8",
|
|
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.
|
|
59
|
+
"@github/copilot": "^1.0.55-1",
|
|
60
60
|
"vscode-jsonrpc": "^8.2.1",
|
|
61
61
|
"zod": "^4.3.6"
|
|
62
62
|
},
|