@github/copilot-sdk 1.0.0 → 1.0.2-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -5
- package/dist/canvas.js +1 -0
- package/dist/cjs/canvas.js +1 -0
- package/dist/cjs/client.js +107 -11
- package/dist/cjs/generated/rpc.js +401 -29
- package/dist/cjs/session.js +19 -2
- package/dist/client.d.ts +4 -2
- package/dist/client.js +107 -11
- package/dist/generated/rpc.d.ts +3763 -805
- package/dist/generated/rpc.js +400 -29
- package/dist/generated/session-events.d.ts +399 -20
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +4 -2
- package/dist/session.js +19 -2
- package/dist/types.d.ts +29 -2
- package/package.json +4 -4
package/dist/session.js
CHANGED
|
@@ -33,6 +33,9 @@ class CopilotSession {
|
|
|
33
33
|
this._workspacePath = _workspacePath;
|
|
34
34
|
this.traceContextProvider = traceContextProvider;
|
|
35
35
|
}
|
|
36
|
+
sessionId;
|
|
37
|
+
connection;
|
|
38
|
+
_workspacePath;
|
|
36
39
|
eventHandlers = /* @__PURE__ */ new Set();
|
|
37
40
|
typedEventHandlers = /* @__PURE__ */ new Map();
|
|
38
41
|
toolHandlers = /* @__PURE__ */ new Map();
|
|
@@ -253,6 +256,8 @@ class CopilotSession {
|
|
|
253
256
|
this._capabilities = { ...this._capabilities, ...event.data };
|
|
254
257
|
} else if (event.type === "session.canvas.opened") {
|
|
255
258
|
this.upsertOpenCanvasFromEvent(event.data);
|
|
259
|
+
} else if (event.type === "session.canvas.closed") {
|
|
260
|
+
this.removeOpenCanvasFromEvent(event.data);
|
|
256
261
|
}
|
|
257
262
|
}
|
|
258
263
|
upsertOpenCanvasFromEvent(data) {
|
|
@@ -262,6 +267,18 @@ class CopilotSession {
|
|
|
262
267
|
}
|
|
263
268
|
this.upsertOpenCanvas(data);
|
|
264
269
|
}
|
|
270
|
+
removeOpenCanvasFromEvent(data) {
|
|
271
|
+
if (!data || typeof data !== "object" || typeof data.instanceId !== "string" || data.instanceId.length === 0) {
|
|
272
|
+
console.warn("failed to deserialize session.canvas.closed payload");
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
this.removeOpenCanvas(data.instanceId);
|
|
276
|
+
}
|
|
277
|
+
removeOpenCanvas(instanceId) {
|
|
278
|
+
this.openCanvasInstances = this.openCanvasInstances.filter(
|
|
279
|
+
(open) => open.instanceId !== instanceId
|
|
280
|
+
);
|
|
281
|
+
}
|
|
265
282
|
upsertOpenCanvas(instance) {
|
|
266
283
|
const index = this.openCanvasInstances.findIndex(
|
|
267
284
|
(open) => open.instanceId === instance.instanceId
|
|
@@ -553,8 +570,8 @@ class CopilotSession {
|
|
|
553
570
|
/**
|
|
554
571
|
* Snapshot of canvas instances currently known to be open for this session.
|
|
555
572
|
* Populated from the `session.resume` response and live `session.canvas.opened`
|
|
556
|
-
* events. Returns a defensive copy — mutating the
|
|
557
|
-
* on the session.
|
|
573
|
+
* and `session.canvas.closed` events. Returns a defensive copy — mutating the
|
|
574
|
+
* returned array has no effect on the session.
|
|
558
575
|
*/
|
|
559
576
|
get openCanvases() {
|
|
560
577
|
return [...this.openCanvasInstances];
|
package/dist/types.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ import type { Canvas } from "./canvas.js";
|
|
|
5
5
|
import type { SessionFsProvider } from "./sessionFsProvider.js";
|
|
6
6
|
import type { ReasoningSummary, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
7
7
|
import type { CopilotSession } from "./session.js";
|
|
8
|
-
import type { RemoteSessionMode } from "./generated/rpc.js";
|
|
9
|
-
import type { OpenCanvasInstance } from "./generated/rpc.js";
|
|
8
|
+
import type { ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode } from "./generated/rpc.js";
|
|
10
9
|
import type { ToolSet } from "./toolSet.js";
|
|
11
10
|
export type { RemoteSessionMode } from "./generated/rpc.js";
|
|
11
|
+
export type { ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, } from "./generated/rpc.js";
|
|
12
12
|
export type SessionEvent = GeneratedSessionEvent;
|
|
13
13
|
export type { ReasoningSummary } from "./generated/session-events.js";
|
|
14
14
|
export type { SessionFsProvider } from "./sessionFsProvider.js";
|
|
@@ -43,6 +43,8 @@ export type TraceContextProvider = () => TraceContext | Promise<TraceContext>;
|
|
|
43
43
|
export interface TelemetryConfig {
|
|
44
44
|
/** OTLP HTTP endpoint URL for trace/metric export. Sets OTEL_EXPORTER_OTLP_ENDPOINT. */
|
|
45
45
|
otlpEndpoint?: string;
|
|
46
|
+
/** OTLP HTTP protocol for all signals. Sets OTEL_EXPORTER_OTLP_PROTOCOL. */
|
|
47
|
+
otlpProtocol?: "http/json" | "http/protobuf";
|
|
46
48
|
/** File path for JSON-lines trace output. Sets COPILOT_OTEL_FILE_EXPORTER_PATH. */
|
|
47
49
|
filePath?: string;
|
|
48
50
|
/** Exporter backend type: "otlp-http" or "file". Sets COPILOT_OTEL_EXPORTER_TYPE. */
|
|
@@ -370,6 +372,13 @@ export interface Tool<TArgs = unknown> {
|
|
|
370
372
|
* When true, the tool can execute without a permission prompt.
|
|
371
373
|
*/
|
|
372
374
|
skipPermission?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Controls whether the tool may be deferred (loaded lazily via tool search)
|
|
377
|
+
* rather than always pre-loaded. When `"auto"`, the tool can be deferred and
|
|
378
|
+
* surfaced through tool search. When `"never"`, the tool is always pre-loaded.
|
|
379
|
+
* Optional; defaults to `"auto"`.
|
|
380
|
+
*/
|
|
381
|
+
defer?: "auto" | "never";
|
|
373
382
|
}
|
|
374
383
|
/**
|
|
375
384
|
* Helper to define a tool with Zod schema and get type inference for the handler.
|
|
@@ -381,6 +390,7 @@ export declare function defineTool<T = unknown>(name: string, config: {
|
|
|
381
390
|
handler?: ToolHandler<T>;
|
|
382
391
|
overridesBuiltInTool?: boolean;
|
|
383
392
|
skipPermission?: boolean;
|
|
393
|
+
defer?: "auto" | "never";
|
|
384
394
|
}): Tool<T>;
|
|
385
395
|
/**
|
|
386
396
|
* Context passed to a command handler when a command is executed.
|
|
@@ -1199,6 +1209,16 @@ export interface InfiniteSessionConfig {
|
|
|
1199
1209
|
*/
|
|
1200
1210
|
bufferExhaustionThreshold?: number;
|
|
1201
1211
|
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Configuration for the memory feature, which lets the agent persist and recall
|
|
1214
|
+
* information across turns.
|
|
1215
|
+
*/
|
|
1216
|
+
export interface MemoryConfiguration {
|
|
1217
|
+
/**
|
|
1218
|
+
* Whether the memory feature is enabled for this session.
|
|
1219
|
+
*/
|
|
1220
|
+
enabled: boolean;
|
|
1221
|
+
}
|
|
1202
1222
|
/**
|
|
1203
1223
|
* Configuration for handling large tool outputs.
|
|
1204
1224
|
*
|
|
@@ -1566,6 +1586,10 @@ export interface SessionConfigBase {
|
|
|
1566
1586
|
* Set to `{ enabled: false }` to disable.
|
|
1567
1587
|
*/
|
|
1568
1588
|
infiniteSessions?: InfiniteSessionConfig;
|
|
1589
|
+
/**
|
|
1590
|
+
* Memory configuration for the session. When omitted, the runtime default applies.
|
|
1591
|
+
*/
|
|
1592
|
+
memory?: MemoryConfiguration;
|
|
1569
1593
|
/**
|
|
1570
1594
|
* GitHub token for per-session authentication.
|
|
1571
1595
|
* When provided, the runtime resolves this token into a full GitHub identity
|
|
@@ -1964,7 +1988,10 @@ export interface ModelPolicy {
|
|
|
1964
1988
|
* Model billing information
|
|
1965
1989
|
*/
|
|
1966
1990
|
export interface ModelBilling {
|
|
1991
|
+
/** Billing cost multiplier relative to the base rate */
|
|
1967
1992
|
multiplier?: number;
|
|
1993
|
+
/** Token-level pricing information for this model */
|
|
1994
|
+
tokenPrices?: ModelBillingTokenPrices;
|
|
1968
1995
|
}
|
|
1969
1996
|
/**
|
|
1970
1997
|
* Information about an available model
|
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",
|
|
7
|
+
"version": "1.0.2-preview.0",
|
|
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.64-0",
|
|
60
60
|
"vscode-jsonrpc": "^8.2.1",
|
|
61
61
|
"zod": "^4.3.6"
|
|
62
62
|
},
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/node": "^25.2.0",
|
|
66
66
|
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
67
67
|
"@typescript-eslint/parser": "^8.54.0",
|
|
68
|
-
"esbuild": "^0.
|
|
68
|
+
"esbuild": "^0.28.1",
|
|
69
69
|
"eslint": "^9.0.0",
|
|
70
70
|
"glob": "^13.0.1",
|
|
71
71
|
"json-schema": "^0.4.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"vitest": "^4.0.18"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
|
-
"node": "
|
|
82
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
83
83
|
},
|
|
84
84
|
"files": [
|
|
85
85
|
"dist/**/*",
|