@github/copilot-sdk 0.1.24-preview.0 → 0.1.24
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 +18 -2
- package/dist/client.d.ts +16 -12
- package/dist/client.js +32 -15
- package/dist/generated/rpc.d.ts +185 -0
- package/dist/generated/rpc.js +26 -0
- package/dist/generated/session-events.d.ts +86 -8
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +6 -0
- package/dist/session.js +11 -0
- package/dist/types.d.ts +28 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -108,9 +108,25 @@ Ping the server to check connectivity.
|
|
|
108
108
|
|
|
109
109
|
Get current connection state.
|
|
110
110
|
|
|
111
|
-
##### `listSessions(): Promise<SessionMetadata[]>`
|
|
111
|
+
##### `listSessions(filter?: SessionListFilter): Promise<SessionMetadata[]>`
|
|
112
112
|
|
|
113
|
-
List all available sessions.
|
|
113
|
+
List all available sessions. Optionally filter by working directory context.
|
|
114
|
+
|
|
115
|
+
**SessionMetadata:**
|
|
116
|
+
|
|
117
|
+
- `sessionId: string` - Unique session identifier
|
|
118
|
+
- `startTime: Date` - When the session was created
|
|
119
|
+
- `modifiedTime: Date` - When the session was last modified
|
|
120
|
+
- `summary?: string` - Optional session summary
|
|
121
|
+
- `isRemote: boolean` - Whether the session is remote
|
|
122
|
+
- `context?: SessionContext` - Working directory context from session creation
|
|
123
|
+
|
|
124
|
+
**SessionContext:**
|
|
125
|
+
|
|
126
|
+
- `cwd: string` - Working directory where the session was created
|
|
127
|
+
- `gitRoot?: string` - Git repository root (if in a git repo)
|
|
128
|
+
- `repository?: string` - GitHub repository in "owner/repo" format
|
|
129
|
+
- `branch?: string` - Current git branch
|
|
114
130
|
|
|
115
131
|
##### `deleteSession(sessionId: string): Promise<void>`
|
|
116
132
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { createServerRpc } from "./generated/rpc.js";
|
|
1
2
|
import { CopilotSession } from "./session.js";
|
|
2
|
-
import type { ConnectionState, CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse, ModelInfo, ResumeSessionConfig, SessionConfig, SessionLifecycleEventType, SessionLifecycleHandler, SessionMetadata, TypedSessionLifecycleHandler } from "./types.js";
|
|
3
|
+
import type { ConnectionState, CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse, ModelInfo, ResumeSessionConfig, SessionConfig, SessionLifecycleEventType, SessionLifecycleHandler, SessionListFilter, SessionMetadata, TypedSessionLifecycleHandler } from "./types.js";
|
|
3
4
|
export declare class CopilotClient {
|
|
4
5
|
private cliProcess;
|
|
5
6
|
private connection;
|
|
@@ -15,6 +16,12 @@ export declare class CopilotClient {
|
|
|
15
16
|
private modelsCacheLock;
|
|
16
17
|
private sessionLifecycleHandlers;
|
|
17
18
|
private typedLifecycleHandlers;
|
|
19
|
+
private _rpc;
|
|
20
|
+
/**
|
|
21
|
+
* Typed server-scoped RPC methods.
|
|
22
|
+
* @throws Error if the client is not connected
|
|
23
|
+
*/
|
|
24
|
+
get rpc(): ReturnType<typeof createServerRpc>;
|
|
18
25
|
/**
|
|
19
26
|
* Creates a new CopilotClient instance.
|
|
20
27
|
*
|
|
@@ -247,22 +254,19 @@ export declare class CopilotClient {
|
|
|
247
254
|
*/
|
|
248
255
|
deleteSession(sessionId: string): Promise<void>;
|
|
249
256
|
/**
|
|
250
|
-
*
|
|
257
|
+
* List all available sessions.
|
|
251
258
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* @returns A promise that resolves with an array of session metadata
|
|
255
|
-
* @throws Error if the client is not connected
|
|
259
|
+
* @param filter - Optional filter to limit returned sessions by context fields
|
|
256
260
|
*
|
|
257
261
|
* @example
|
|
258
|
-
*
|
|
262
|
+
* // List all sessions
|
|
259
263
|
* const sessions = await client.listSessions();
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* // List sessions for a specific repository
|
|
267
|
+
* const sessions = await client.listSessions({ repository: "owner/repo" });
|
|
264
268
|
*/
|
|
265
|
-
listSessions(): Promise<SessionMetadata[]>;
|
|
269
|
+
listSessions(filter?: SessionListFilter): Promise<SessionMetadata[]>;
|
|
266
270
|
/**
|
|
267
271
|
* Gets the foreground session ID in TUI+server mode.
|
|
268
272
|
*
|
package/dist/client.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
StreamMessageReader,
|
|
9
9
|
StreamMessageWriter
|
|
10
10
|
} from "vscode-jsonrpc/node.js";
|
|
11
|
+
import { createServerRpc } from "./generated/rpc.js";
|
|
11
12
|
import { getSdkProtocolVersion } from "./sdkProtocolVersion.js";
|
|
12
13
|
import { CopilotSession } from "./session.js";
|
|
13
14
|
function isZodSchema(value) {
|
|
@@ -40,6 +41,20 @@ class CopilotClient {
|
|
|
40
41
|
modelsCacheLock = Promise.resolve();
|
|
41
42
|
sessionLifecycleHandlers = /* @__PURE__ */ new Set();
|
|
42
43
|
typedLifecycleHandlers = /* @__PURE__ */ new Map();
|
|
44
|
+
_rpc = null;
|
|
45
|
+
/**
|
|
46
|
+
* Typed server-scoped RPC methods.
|
|
47
|
+
* @throws Error if the client is not connected
|
|
48
|
+
*/
|
|
49
|
+
get rpc() {
|
|
50
|
+
if (!this.connection) {
|
|
51
|
+
throw new Error("Client is not connected. Call start() first.");
|
|
52
|
+
}
|
|
53
|
+
if (!this._rpc) {
|
|
54
|
+
this._rpc = createServerRpc(this.connection);
|
|
55
|
+
}
|
|
56
|
+
return this._rpc;
|
|
57
|
+
}
|
|
43
58
|
/**
|
|
44
59
|
* Creates a new CopilotClient instance.
|
|
45
60
|
*
|
|
@@ -207,6 +222,7 @@ class CopilotClient {
|
|
|
207
222
|
);
|
|
208
223
|
}
|
|
209
224
|
this.connection = null;
|
|
225
|
+
this._rpc = null;
|
|
210
226
|
}
|
|
211
227
|
this.modelsCache = null;
|
|
212
228
|
if (this.socket) {
|
|
@@ -271,6 +287,7 @@ class CopilotClient {
|
|
|
271
287
|
} catch {
|
|
272
288
|
}
|
|
273
289
|
this.connection = null;
|
|
290
|
+
this._rpc = null;
|
|
274
291
|
}
|
|
275
292
|
this.modelsCache = null;
|
|
276
293
|
if (this.socket) {
|
|
@@ -594,33 +611,31 @@ class CopilotClient {
|
|
|
594
611
|
this.sessions.delete(sessionId);
|
|
595
612
|
}
|
|
596
613
|
/**
|
|
597
|
-
*
|
|
614
|
+
* List all available sessions.
|
|
598
615
|
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
* @returns A promise that resolves with an array of session metadata
|
|
602
|
-
* @throws Error if the client is not connected
|
|
616
|
+
* @param filter - Optional filter to limit returned sessions by context fields
|
|
603
617
|
*
|
|
604
618
|
* @example
|
|
605
|
-
*
|
|
619
|
+
* // List all sessions
|
|
606
620
|
* const sessions = await client.listSessions();
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* // List sessions for a specific repository
|
|
624
|
+
* const sessions = await client.listSessions({ repository: "owner/repo" });
|
|
611
625
|
*/
|
|
612
|
-
async listSessions() {
|
|
626
|
+
async listSessions(filter) {
|
|
613
627
|
if (!this.connection) {
|
|
614
628
|
throw new Error("Client not connected");
|
|
615
629
|
}
|
|
616
|
-
const response = await this.connection.sendRequest("session.list", {});
|
|
630
|
+
const response = await this.connection.sendRequest("session.list", { filter });
|
|
617
631
|
const { sessions } = response;
|
|
618
632
|
return sessions.map((s) => ({
|
|
619
633
|
sessionId: s.sessionId,
|
|
620
634
|
startTime: new Date(s.startTime),
|
|
621
635
|
modifiedTime: new Date(s.modifiedTime),
|
|
622
636
|
summary: s.summary,
|
|
623
|
-
isRemote: s.isRemote
|
|
637
|
+
isRemote: s.isRemote,
|
|
638
|
+
context: s.context
|
|
624
639
|
}));
|
|
625
640
|
}
|
|
626
641
|
/**
|
|
@@ -733,13 +748,15 @@ class CopilotClient {
|
|
|
733
748
|
this.cliProcess = spawn(process.execPath, [this.options.cliPath, ...args], {
|
|
734
749
|
stdio: stdioConfig,
|
|
735
750
|
cwd: this.options.cwd,
|
|
736
|
-
env: envWithoutNodeDebug
|
|
751
|
+
env: envWithoutNodeDebug,
|
|
752
|
+
windowsHide: true
|
|
737
753
|
});
|
|
738
754
|
} else {
|
|
739
755
|
this.cliProcess = spawn(this.options.cliPath, args, {
|
|
740
756
|
stdio: stdioConfig,
|
|
741
757
|
cwd: this.options.cwd,
|
|
742
|
-
env: envWithoutNodeDebug
|
|
758
|
+
env: envWithoutNodeDebug,
|
|
759
|
+
windowsHide: true
|
|
743
760
|
});
|
|
744
761
|
}
|
|
745
762
|
let stdout = "";
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
+
* Generated from: api.schema.json
|
|
4
|
+
*/
|
|
5
|
+
import type { MessageConnection } from "vscode-jsonrpc/node.js";
|
|
6
|
+
export interface PingResult {
|
|
7
|
+
/**
|
|
8
|
+
* Echoed message (or default greeting)
|
|
9
|
+
*/
|
|
10
|
+
message: string;
|
|
11
|
+
/**
|
|
12
|
+
* Server timestamp in milliseconds
|
|
13
|
+
*/
|
|
14
|
+
timestamp: number;
|
|
15
|
+
/**
|
|
16
|
+
* Server protocol version number
|
|
17
|
+
*/
|
|
18
|
+
protocolVersion: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PingParams {
|
|
21
|
+
/**
|
|
22
|
+
* Optional message to echo back
|
|
23
|
+
*/
|
|
24
|
+
message?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ModelsListResult {
|
|
27
|
+
/**
|
|
28
|
+
* List of available models with full metadata
|
|
29
|
+
*/
|
|
30
|
+
models: {
|
|
31
|
+
/**
|
|
32
|
+
* Model identifier (e.g., "claude-sonnet-4.5")
|
|
33
|
+
*/
|
|
34
|
+
id: string;
|
|
35
|
+
/**
|
|
36
|
+
* Display name
|
|
37
|
+
*/
|
|
38
|
+
name: string;
|
|
39
|
+
/**
|
|
40
|
+
* Model capabilities and limits
|
|
41
|
+
*/
|
|
42
|
+
capabilities: {
|
|
43
|
+
supports: {
|
|
44
|
+
vision: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether this model supports reasoning effort configuration
|
|
47
|
+
*/
|
|
48
|
+
reasoningEffort: boolean;
|
|
49
|
+
};
|
|
50
|
+
limits: {
|
|
51
|
+
max_prompt_tokens?: number;
|
|
52
|
+
max_output_tokens?: number;
|
|
53
|
+
max_context_window_tokens: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Policy state (if applicable)
|
|
58
|
+
*/
|
|
59
|
+
policy?: {
|
|
60
|
+
state: string;
|
|
61
|
+
terms: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Billing information
|
|
65
|
+
*/
|
|
66
|
+
billing?: {
|
|
67
|
+
multiplier: number;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Supported reasoning effort levels (only present if model supports reasoning effort)
|
|
71
|
+
*/
|
|
72
|
+
supportedReasoningEfforts?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Default reasoning effort level (only present if model supports reasoning effort)
|
|
75
|
+
*/
|
|
76
|
+
defaultReasoningEffort?: string;
|
|
77
|
+
}[];
|
|
78
|
+
}
|
|
79
|
+
export interface ToolsListResult {
|
|
80
|
+
/**
|
|
81
|
+
* List of available built-in tools with metadata
|
|
82
|
+
*/
|
|
83
|
+
tools: {
|
|
84
|
+
/**
|
|
85
|
+
* Tool identifier (e.g., "bash", "grep", "str_replace_editor")
|
|
86
|
+
*/
|
|
87
|
+
name: string;
|
|
88
|
+
/**
|
|
89
|
+
* Optional namespaced name for declarative filtering (e.g., "playwright/navigate" for MCP tools)
|
|
90
|
+
*/
|
|
91
|
+
namespacedName?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Description of what the tool does
|
|
94
|
+
*/
|
|
95
|
+
description: string;
|
|
96
|
+
/**
|
|
97
|
+
* JSON Schema for the tool's input parameters
|
|
98
|
+
*/
|
|
99
|
+
parameters?: {
|
|
100
|
+
[k: string]: unknown;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Optional instructions for how to use this tool effectively
|
|
104
|
+
*/
|
|
105
|
+
instructions?: string;
|
|
106
|
+
}[];
|
|
107
|
+
}
|
|
108
|
+
export interface ToolsListParams {
|
|
109
|
+
/**
|
|
110
|
+
* Optional model ID — when provided, the returned tool list reflects model-specific overrides
|
|
111
|
+
*/
|
|
112
|
+
model?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface AccountGetQuotaResult {
|
|
115
|
+
/**
|
|
116
|
+
* Quota snapshots keyed by type (e.g., chat, completions, premium_interactions)
|
|
117
|
+
*/
|
|
118
|
+
quotaSnapshots: {
|
|
119
|
+
[k: string]: {
|
|
120
|
+
/**
|
|
121
|
+
* Number of requests included in the entitlement
|
|
122
|
+
*/
|
|
123
|
+
entitlementRequests: number;
|
|
124
|
+
/**
|
|
125
|
+
* Number of requests used so far this period
|
|
126
|
+
*/
|
|
127
|
+
usedRequests: number;
|
|
128
|
+
/**
|
|
129
|
+
* Percentage of entitlement remaining
|
|
130
|
+
*/
|
|
131
|
+
remainingPercentage: number;
|
|
132
|
+
/**
|
|
133
|
+
* Number of overage requests made this period
|
|
134
|
+
*/
|
|
135
|
+
overage: number;
|
|
136
|
+
/**
|
|
137
|
+
* Whether pay-per-request usage is allowed when quota is exhausted
|
|
138
|
+
*/
|
|
139
|
+
overageAllowedWithExhaustedQuota: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Date when the quota resets (ISO 8601)
|
|
142
|
+
*/
|
|
143
|
+
resetDate?: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export interface SessionModelGetCurrentResult {
|
|
148
|
+
modelId?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface SessionModelGetCurrentParams {
|
|
151
|
+
/**
|
|
152
|
+
* Target session identifier
|
|
153
|
+
*/
|
|
154
|
+
sessionId: string;
|
|
155
|
+
}
|
|
156
|
+
export interface SessionModelSwitchToResult {
|
|
157
|
+
modelId?: string;
|
|
158
|
+
}
|
|
159
|
+
export interface SessionModelSwitchToParams {
|
|
160
|
+
/**
|
|
161
|
+
* Target session identifier
|
|
162
|
+
*/
|
|
163
|
+
sessionId: string;
|
|
164
|
+
modelId: string;
|
|
165
|
+
}
|
|
166
|
+
/** Create typed server-scoped RPC methods (no session required). */
|
|
167
|
+
export declare function createServerRpc(connection: MessageConnection): {
|
|
168
|
+
ping: (params: PingParams) => Promise<PingResult>;
|
|
169
|
+
models: {
|
|
170
|
+
list: () => Promise<ModelsListResult>;
|
|
171
|
+
};
|
|
172
|
+
tools: {
|
|
173
|
+
list: (params: ToolsListParams) => Promise<ToolsListResult>;
|
|
174
|
+
};
|
|
175
|
+
account: {
|
|
176
|
+
getQuota: () => Promise<AccountGetQuotaResult>;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
/** Create typed session-scoped RPC methods. */
|
|
180
|
+
export declare function createSessionRpc(connection: MessageConnection, sessionId: string): {
|
|
181
|
+
model: {
|
|
182
|
+
getCurrent: () => Promise<SessionModelGetCurrentResult>;
|
|
183
|
+
switchTo: (params: Omit<SessionModelSwitchToParams, "sessionId">) => Promise<SessionModelSwitchToResult>;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function createServerRpc(connection) {
|
|
2
|
+
return {
|
|
3
|
+
ping: async (params) => connection.sendRequest("ping", params),
|
|
4
|
+
models: {
|
|
5
|
+
list: async () => connection.sendRequest("models.list", {})
|
|
6
|
+
},
|
|
7
|
+
tools: {
|
|
8
|
+
list: async (params) => connection.sendRequest("tools.list", params)
|
|
9
|
+
},
|
|
10
|
+
account: {
|
|
11
|
+
getQuota: async () => connection.sendRequest("account.getQuota", {})
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function createSessionRpc(connection, sessionId) {
|
|
16
|
+
return {
|
|
17
|
+
model: {
|
|
18
|
+
getCurrent: async () => connection.sendRequest("session.model.getCurrent", { sessionId }),
|
|
19
|
+
switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params })
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
createServerRpc,
|
|
25
|
+
createSessionRpc
|
|
26
|
+
};
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* Generated from: @github/copilot/session-events.schema.json
|
|
5
|
-
* Generated by: scripts/generate-session-types.ts
|
|
6
|
-
* Generated at: 2026-02-06T20:38:23.139Z
|
|
7
|
-
*
|
|
8
|
-
* To update these types:
|
|
9
|
-
* 1. Update the schema in copilot-agent-runtime
|
|
10
|
-
* 2. Run: npm run generate:session-types
|
|
3
|
+
* Generated from: session-events.schema.json
|
|
11
4
|
*/
|
|
12
5
|
export type SessionEvent = {
|
|
13
6
|
id: string;
|
|
@@ -65,6 +58,15 @@ export type SessionEvent = {
|
|
|
65
58
|
ephemeral: true;
|
|
66
59
|
type: "session.idle";
|
|
67
60
|
data: {};
|
|
61
|
+
} | {
|
|
62
|
+
id: string;
|
|
63
|
+
timestamp: string;
|
|
64
|
+
parentId: string | null;
|
|
65
|
+
ephemeral: true;
|
|
66
|
+
type: "session.title_changed";
|
|
67
|
+
data: {
|
|
68
|
+
title: string;
|
|
69
|
+
};
|
|
68
70
|
} | {
|
|
69
71
|
id: string;
|
|
70
72
|
timestamp: string;
|
|
@@ -75,6 +77,16 @@ export type SessionEvent = {
|
|
|
75
77
|
infoType: string;
|
|
76
78
|
message: string;
|
|
77
79
|
};
|
|
80
|
+
} | {
|
|
81
|
+
id: string;
|
|
82
|
+
timestamp: string;
|
|
83
|
+
parentId: string | null;
|
|
84
|
+
ephemeral?: boolean;
|
|
85
|
+
type: "session.warning";
|
|
86
|
+
data: {
|
|
87
|
+
warningType: string;
|
|
88
|
+
message: string;
|
|
89
|
+
};
|
|
78
90
|
} | {
|
|
79
91
|
id: string;
|
|
80
92
|
timestamp: string;
|
|
@@ -162,6 +174,18 @@ export type SessionEvent = {
|
|
|
162
174
|
};
|
|
163
175
|
currentModel?: string;
|
|
164
176
|
};
|
|
177
|
+
} | {
|
|
178
|
+
id: string;
|
|
179
|
+
timestamp: string;
|
|
180
|
+
parentId: string | null;
|
|
181
|
+
ephemeral?: boolean;
|
|
182
|
+
type: "session.context_changed";
|
|
183
|
+
data: {
|
|
184
|
+
cwd: string;
|
|
185
|
+
gitRoot?: string;
|
|
186
|
+
repository?: string;
|
|
187
|
+
branch?: string;
|
|
188
|
+
};
|
|
165
189
|
} | {
|
|
166
190
|
id: string;
|
|
167
191
|
timestamp: string;
|
|
@@ -217,10 +241,18 @@ export type SessionEvent = {
|
|
|
217
241
|
type: "file";
|
|
218
242
|
path: string;
|
|
219
243
|
displayName: string;
|
|
244
|
+
lineRange?: {
|
|
245
|
+
start: number;
|
|
246
|
+
end: number;
|
|
247
|
+
};
|
|
220
248
|
} | {
|
|
221
249
|
type: "directory";
|
|
222
250
|
path: string;
|
|
223
251
|
displayName: string;
|
|
252
|
+
lineRange?: {
|
|
253
|
+
start: number;
|
|
254
|
+
end: number;
|
|
255
|
+
};
|
|
224
256
|
} | {
|
|
225
257
|
type: "selection";
|
|
226
258
|
filePath: string;
|
|
@@ -238,6 +270,7 @@ export type SessionEvent = {
|
|
|
238
270
|
};
|
|
239
271
|
})[];
|
|
240
272
|
source?: string;
|
|
273
|
+
agentMode?: "interactive" | "plan" | "autopilot" | "shell";
|
|
241
274
|
};
|
|
242
275
|
} | {
|
|
243
276
|
id: string;
|
|
@@ -302,6 +335,7 @@ export type SessionEvent = {
|
|
|
302
335
|
reasoningOpaque?: string;
|
|
303
336
|
reasoningText?: string;
|
|
304
337
|
encryptedContent?: string;
|
|
338
|
+
phase?: string;
|
|
305
339
|
parentToolCallId?: string;
|
|
306
340
|
};
|
|
307
341
|
} | {
|
|
@@ -423,6 +457,48 @@ export type SessionEvent = {
|
|
|
423
457
|
result?: {
|
|
424
458
|
content: string;
|
|
425
459
|
detailedContent?: string;
|
|
460
|
+
contents?: ({
|
|
461
|
+
type: "text";
|
|
462
|
+
text: string;
|
|
463
|
+
} | {
|
|
464
|
+
type: "terminal";
|
|
465
|
+
text: string;
|
|
466
|
+
exitCode?: number;
|
|
467
|
+
cwd?: string;
|
|
468
|
+
} | {
|
|
469
|
+
type: "image";
|
|
470
|
+
data: string;
|
|
471
|
+
mimeType: string;
|
|
472
|
+
} | {
|
|
473
|
+
type: "audio";
|
|
474
|
+
data: string;
|
|
475
|
+
mimeType: string;
|
|
476
|
+
} | {
|
|
477
|
+
icons?: {
|
|
478
|
+
src: string;
|
|
479
|
+
mimeType?: string;
|
|
480
|
+
sizes?: string[];
|
|
481
|
+
theme?: "light" | "dark";
|
|
482
|
+
}[];
|
|
483
|
+
name: string;
|
|
484
|
+
title?: string;
|
|
485
|
+
uri: string;
|
|
486
|
+
description?: string;
|
|
487
|
+
mimeType?: string;
|
|
488
|
+
size?: number;
|
|
489
|
+
type: "resource_link";
|
|
490
|
+
} | {
|
|
491
|
+
type: "resource";
|
|
492
|
+
resource: {
|
|
493
|
+
uri: string;
|
|
494
|
+
mimeType?: string;
|
|
495
|
+
text: string;
|
|
496
|
+
} | {
|
|
497
|
+
uri: string;
|
|
498
|
+
mimeType?: string;
|
|
499
|
+
blob: string;
|
|
500
|
+
};
|
|
501
|
+
})[];
|
|
426
502
|
};
|
|
427
503
|
error?: {
|
|
428
504
|
message: string;
|
|
@@ -466,6 +542,7 @@ export type SessionEvent = {
|
|
|
466
542
|
data: {
|
|
467
543
|
toolCallId: string;
|
|
468
544
|
agentName: string;
|
|
545
|
+
agentDisplayName: string;
|
|
469
546
|
};
|
|
470
547
|
} | {
|
|
471
548
|
id: string;
|
|
@@ -476,6 +553,7 @@ export type SessionEvent = {
|
|
|
476
553
|
data: {
|
|
477
554
|
toolCallId: string;
|
|
478
555
|
agentName: string;
|
|
556
|
+
agentDisplayName: string;
|
|
479
557
|
error: string;
|
|
480
558
|
};
|
|
481
559
|
} | {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
export { CopilotClient } from "./client.js";
|
|
7
7
|
export { CopilotSession, type AssistantMessageEvent } from "./session.js";
|
|
8
8
|
export { defineTool } from "./types.js";
|
|
9
|
-
export type { ConnectionState, CopilotClientOptions, CustomAgentConfig, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionMetadata, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageReplaceConfig, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
|
9
|
+
export type { ConnectionState, CopilotClientOptions, CustomAgentConfig, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageReplaceConfig, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
package/dist/session.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @module session
|
|
4
4
|
*/
|
|
5
5
|
import type { MessageConnection } from "vscode-jsonrpc/node";
|
|
6
|
+
import { createSessionRpc } from "./generated/rpc.js";
|
|
6
7
|
import type { MessageOptions, PermissionHandler, PermissionRequestResult, SessionEvent, SessionEventHandler, SessionEventType, SessionHooks, Tool, ToolHandler, TypedSessionEventHandler, UserInputHandler, UserInputResponse } from "./types.js";
|
|
7
8
|
/** Assistant message event - the final response from the assistant. */
|
|
8
9
|
export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
@@ -43,6 +44,7 @@ export declare class CopilotSession {
|
|
|
43
44
|
private permissionHandler?;
|
|
44
45
|
private userInputHandler?;
|
|
45
46
|
private hooks?;
|
|
47
|
+
private _rpc;
|
|
46
48
|
/**
|
|
47
49
|
* Creates a new CopilotSession instance.
|
|
48
50
|
*
|
|
@@ -52,6 +54,10 @@ export declare class CopilotSession {
|
|
|
52
54
|
* @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
|
|
53
55
|
*/
|
|
54
56
|
constructor(sessionId: string, connection: MessageConnection, _workspacePath?: string | undefined);
|
|
57
|
+
/**
|
|
58
|
+
* Typed session-scoped RPC methods.
|
|
59
|
+
*/
|
|
60
|
+
get rpc(): ReturnType<typeof createSessionRpc>;
|
|
55
61
|
/**
|
|
56
62
|
* Path to the session workspace directory when infinite sessions are enabled.
|
|
57
63
|
* Contains checkpoints/, plan.md, and files/ subdirectories.
|
package/dist/session.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createSessionRpc } from "./generated/rpc.js";
|
|
1
2
|
class CopilotSession {
|
|
2
3
|
/**
|
|
3
4
|
* Creates a new CopilotSession instance.
|
|
@@ -18,6 +19,16 @@ class CopilotSession {
|
|
|
18
19
|
permissionHandler;
|
|
19
20
|
userInputHandler;
|
|
20
21
|
hooks;
|
|
22
|
+
_rpc = null;
|
|
23
|
+
/**
|
|
24
|
+
* Typed session-scoped RPC methods.
|
|
25
|
+
*/
|
|
26
|
+
get rpc() {
|
|
27
|
+
if (!this._rpc) {
|
|
28
|
+
this._rpc = createSessionRpc(this.connection, this.sessionId);
|
|
29
|
+
}
|
|
30
|
+
return this._rpc;
|
|
31
|
+
}
|
|
21
32
|
/**
|
|
22
33
|
* Path to the session workspace directory when infinite sessions are enabled.
|
|
23
34
|
* Contains checkpoints/, plan.md, and files/ subdirectories.
|
package/dist/types.d.ts
CHANGED
|
@@ -695,6 +695,32 @@ export type SessionEventHandler = (event: SessionEvent) => void;
|
|
|
695
695
|
* Connection state
|
|
696
696
|
*/
|
|
697
697
|
export type ConnectionState = "disconnected" | "connecting" | "connected" | "error";
|
|
698
|
+
/**
|
|
699
|
+
* Working directory context for a session
|
|
700
|
+
*/
|
|
701
|
+
export interface SessionContext {
|
|
702
|
+
/** Working directory where the session was created */
|
|
703
|
+
cwd: string;
|
|
704
|
+
/** Git repository root (if in a git repo) */
|
|
705
|
+
gitRoot?: string;
|
|
706
|
+
/** GitHub repository in "owner/repo" format */
|
|
707
|
+
repository?: string;
|
|
708
|
+
/** Current git branch */
|
|
709
|
+
branch?: string;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Filter options for listing sessions
|
|
713
|
+
*/
|
|
714
|
+
export interface SessionListFilter {
|
|
715
|
+
/** Filter by exact cwd match */
|
|
716
|
+
cwd?: string;
|
|
717
|
+
/** Filter by git root */
|
|
718
|
+
gitRoot?: string;
|
|
719
|
+
/** Filter by repository (owner/repo format) */
|
|
720
|
+
repository?: string;
|
|
721
|
+
/** Filter by branch */
|
|
722
|
+
branch?: string;
|
|
723
|
+
}
|
|
698
724
|
/**
|
|
699
725
|
* Metadata about a session
|
|
700
726
|
*/
|
|
@@ -704,6 +730,8 @@ export interface SessionMetadata {
|
|
|
704
730
|
modifiedTime: Date;
|
|
705
731
|
summary?: string;
|
|
706
732
|
isRemote: boolean;
|
|
733
|
+
/** Working directory context (cwd, git info) from session creation */
|
|
734
|
+
context?: SessionContext;
|
|
707
735
|
}
|
|
708
736
|
/**
|
|
709
737
|
* Response from status.get
|
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": "0.1.24
|
|
7
|
+
"version": "0.1.24",
|
|
8
8
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
26
26
|
"lint:fix": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
27
27
|
"typecheck": "tsc --noEmit",
|
|
28
|
-
"generate
|
|
28
|
+
"generate": "cd ../scripts/codegen && npm run generate",
|
|
29
29
|
"update:protocol-version": "tsx scripts/update-protocol-version.ts",
|
|
30
30
|
"prepublishOnly": "npm run build",
|
|
31
31
|
"package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.1.0 --no-git-tag-version --allow-same-version"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"author": "GitHub",
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@github/copilot": "^0.0.
|
|
43
|
+
"@github/copilot": "^0.0.409",
|
|
44
44
|
"vscode-jsonrpc": "^8.2.1",
|
|
45
45
|
"zod": "^4.3.6"
|
|
46
46
|
},
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "^4.0.18"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
|
-
"node": ">=
|
|
65
|
+
"node": ">=20.0.0"
|
|
66
66
|
},
|
|
67
67
|
"files": [
|
|
68
68
|
"dist/**/*",
|