@github/copilot-sdk 0.1.17 → 0.1.18
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 +46 -1
- package/dist/client.js +6 -5
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +9 -1
- package/dist/session.js +11 -1
- package/dist/types.d.ts +30 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,10 +89,11 @@ Create a new conversation session.
|
|
|
89
89
|
- `model?: string` - Model to use ("gpt-5", "claude-sonnet-4.5", etc.)
|
|
90
90
|
- `tools?: Tool[]` - Custom tools exposed to the CLI
|
|
91
91
|
- `systemMessage?: SystemMessageConfig` - System message customization (see below)
|
|
92
|
+
- `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
|
|
92
93
|
|
|
93
94
|
##### `resumeSession(sessionId: string, config?: ResumeSessionConfig): Promise<CopilotSession>`
|
|
94
95
|
|
|
95
|
-
Resume an existing session.
|
|
96
|
+
Resume an existing session. Returns the session with `workspacePath` populated if infinite sessions were enabled.
|
|
96
97
|
|
|
97
98
|
##### `ping(message?: string): Promise<{ message: string; timestamp: number }>`
|
|
98
99
|
|
|
@@ -116,6 +117,16 @@ Delete a session and its data from disk.
|
|
|
116
117
|
|
|
117
118
|
Represents a single conversation session.
|
|
118
119
|
|
|
120
|
+
#### Properties
|
|
121
|
+
|
|
122
|
+
##### `sessionId: string`
|
|
123
|
+
|
|
124
|
+
The unique identifier for this session.
|
|
125
|
+
|
|
126
|
+
##### `workspacePath?: string`
|
|
127
|
+
|
|
128
|
+
Path to the session workspace directory when infinite sessions are enabled. Contains `checkpoints/`, `plan.md`, and `files/` subdirectories. Undefined if infinite sessions are disabled.
|
|
129
|
+
|
|
119
130
|
#### Methods
|
|
120
131
|
|
|
121
132
|
##### `send(options: MessageOptions): Promise<string>`
|
|
@@ -327,6 +338,40 @@ const session = await client.createSession({
|
|
|
327
338
|
});
|
|
328
339
|
```
|
|
329
340
|
|
|
341
|
+
### Infinite Sessions
|
|
342
|
+
|
|
343
|
+
By default, sessions use **infinite sessions** which automatically manage context window limits through background compaction and persist state to a workspace directory.
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
// Default: infinite sessions enabled with default thresholds
|
|
347
|
+
const session = await client.createSession({ model: "gpt-5" });
|
|
348
|
+
|
|
349
|
+
// Access the workspace path for checkpoints and files
|
|
350
|
+
console.log(session.workspacePath);
|
|
351
|
+
// => ~/.copilot/session-state/{sessionId}/
|
|
352
|
+
|
|
353
|
+
// Custom thresholds
|
|
354
|
+
const session = await client.createSession({
|
|
355
|
+
model: "gpt-5",
|
|
356
|
+
infiniteSessions: {
|
|
357
|
+
enabled: true,
|
|
358
|
+
backgroundCompactionThreshold: 0.80, // Start compacting at 80% context usage
|
|
359
|
+
bufferExhaustionThreshold: 0.95, // Block at 95% until compaction completes
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Disable infinite sessions
|
|
364
|
+
const session = await client.createSession({
|
|
365
|
+
model: "gpt-5",
|
|
366
|
+
infiniteSessions: { enabled: false },
|
|
367
|
+
});
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
When enabled, sessions emit compaction events:
|
|
371
|
+
|
|
372
|
+
- `session.compaction_start` - Background compaction started
|
|
373
|
+
- `session.compaction_complete` - Compaction finished (includes token counts)
|
|
374
|
+
|
|
330
375
|
### Multiple Sessions
|
|
331
376
|
|
|
332
377
|
```typescript
|
package/dist/client.js
CHANGED
|
@@ -322,10 +322,11 @@ class CopilotClient {
|
|
|
322
322
|
customAgents: config.customAgents,
|
|
323
323
|
configDir: config.configDir,
|
|
324
324
|
skillDirectories: config.skillDirectories,
|
|
325
|
-
disabledSkills: config.disabledSkills
|
|
325
|
+
disabledSkills: config.disabledSkills,
|
|
326
|
+
infiniteSessions: config.infiniteSessions
|
|
326
327
|
});
|
|
327
|
-
const sessionId = response
|
|
328
|
-
const session = new CopilotSession(sessionId, this.connection);
|
|
328
|
+
const { sessionId, workspacePath } = response;
|
|
329
|
+
const session = new CopilotSession(sessionId, this.connection, workspacePath);
|
|
329
330
|
session.registerTools(config.tools);
|
|
330
331
|
if (config.onPermissionRequest) {
|
|
331
332
|
session.registerPermissionHandler(config.onPermissionRequest);
|
|
@@ -379,8 +380,8 @@ class CopilotClient {
|
|
|
379
380
|
skillDirectories: config.skillDirectories,
|
|
380
381
|
disabledSkills: config.disabledSkills
|
|
381
382
|
});
|
|
382
|
-
const resumedSessionId = response
|
|
383
|
-
const session = new CopilotSession(resumedSessionId, this.connection);
|
|
383
|
+
const { sessionId: resumedSessionId, workspacePath } = response;
|
|
384
|
+
const session = new CopilotSession(resumedSessionId, this.connection, workspacePath);
|
|
384
385
|
session.registerTools(config.tools);
|
|
385
386
|
if (config.onPermissionRequest) {
|
|
386
387
|
session.registerPermissionHandler(config.onPermissionRequest);
|
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, GetAuthStatusResponse, GetStatusResponse, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SessionConfig, SessionEvent, SessionEventHandler, SessionMetadata, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageReplaceConfig, Tool, ToolHandler, ToolInvocation, ToolResultObject, ZodSchema, } from "./types.js";
|
|
9
|
+
export type { ConnectionState, CopilotClientOptions, CustomAgentConfig, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SessionConfig, SessionEvent, SessionEventHandler, SessionMetadata, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageReplaceConfig, Tool, ToolHandler, ToolInvocation, ToolResultObject, ZodSchema, } from "./types.js";
|
package/dist/session.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
|
36
36
|
export declare class CopilotSession {
|
|
37
37
|
readonly sessionId: string;
|
|
38
38
|
private connection;
|
|
39
|
+
private readonly _workspacePath?;
|
|
39
40
|
private eventHandlers;
|
|
40
41
|
private toolHandlers;
|
|
41
42
|
private permissionHandler?;
|
|
@@ -44,9 +45,16 @@ export declare class CopilotSession {
|
|
|
44
45
|
*
|
|
45
46
|
* @param sessionId - The unique identifier for this session
|
|
46
47
|
* @param connection - The JSON-RPC message connection to the Copilot CLI
|
|
48
|
+
* @param workspacePath - Path to the session workspace directory (when infinite sessions enabled)
|
|
47
49
|
* @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
|
|
48
50
|
*/
|
|
49
|
-
constructor(sessionId: string, connection: MessageConnection);
|
|
51
|
+
constructor(sessionId: string, connection: MessageConnection, _workspacePath?: string | undefined);
|
|
52
|
+
/**
|
|
53
|
+
* Path to the session workspace directory when infinite sessions are enabled.
|
|
54
|
+
* Contains checkpoints/, plan.md, and files/ subdirectories.
|
|
55
|
+
* Undefined if infinite sessions are disabled.
|
|
56
|
+
*/
|
|
57
|
+
get workspacePath(): string | undefined;
|
|
50
58
|
/**
|
|
51
59
|
* Sends a message to this session and waits for the response.
|
|
52
60
|
*
|
package/dist/session.js
CHANGED
|
@@ -4,15 +4,25 @@ class CopilotSession {
|
|
|
4
4
|
*
|
|
5
5
|
* @param sessionId - The unique identifier for this session
|
|
6
6
|
* @param connection - The JSON-RPC message connection to the Copilot CLI
|
|
7
|
+
* @param workspacePath - Path to the session workspace directory (when infinite sessions enabled)
|
|
7
8
|
* @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
|
|
8
9
|
*/
|
|
9
|
-
constructor(sessionId, connection) {
|
|
10
|
+
constructor(sessionId, connection, _workspacePath) {
|
|
10
11
|
this.sessionId = sessionId;
|
|
11
12
|
this.connection = connection;
|
|
13
|
+
this._workspacePath = _workspacePath;
|
|
12
14
|
}
|
|
13
15
|
eventHandlers = /* @__PURE__ */ new Set();
|
|
14
16
|
toolHandlers = /* @__PURE__ */ new Map();
|
|
15
17
|
permissionHandler;
|
|
18
|
+
/**
|
|
19
|
+
* Path to the session workspace directory when infinite sessions are enabled.
|
|
20
|
+
* Contains checkpoints/, plan.md, and files/ subdirectories.
|
|
21
|
+
* Undefined if infinite sessions are disabled.
|
|
22
|
+
*/
|
|
23
|
+
get workspacePath() {
|
|
24
|
+
return this._workspacePath;
|
|
25
|
+
}
|
|
16
26
|
/**
|
|
17
27
|
* Sends a message to this session and waits for the response.
|
|
18
28
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -250,6 +250,30 @@ export interface CustomAgentConfig {
|
|
|
250
250
|
*/
|
|
251
251
|
infer?: boolean;
|
|
252
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Configuration for infinite sessions with automatic context compaction and workspace persistence.
|
|
255
|
+
* When enabled, sessions automatically manage context window limits through background compaction
|
|
256
|
+
* and persist state to a workspace directory.
|
|
257
|
+
*/
|
|
258
|
+
export interface InfiniteSessionConfig {
|
|
259
|
+
/**
|
|
260
|
+
* Whether infinite sessions are enabled.
|
|
261
|
+
* @default true
|
|
262
|
+
*/
|
|
263
|
+
enabled?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Context utilization threshold (0.0-1.0) at which background compaction starts.
|
|
266
|
+
* Compaction runs asynchronously, allowing the session to continue processing.
|
|
267
|
+
* @default 0.80
|
|
268
|
+
*/
|
|
269
|
+
backgroundCompactionThreshold?: number;
|
|
270
|
+
/**
|
|
271
|
+
* Context utilization threshold (0.0-1.0) at which the session blocks until compaction completes.
|
|
272
|
+
* This prevents context overflow when compaction hasn't finished in time.
|
|
273
|
+
* @default 0.95
|
|
274
|
+
*/
|
|
275
|
+
bufferExhaustionThreshold?: number;
|
|
276
|
+
}
|
|
253
277
|
export interface SessionConfig {
|
|
254
278
|
/**
|
|
255
279
|
* Optional custom session ID
|
|
@@ -312,6 +336,12 @@ export interface SessionConfig {
|
|
|
312
336
|
* List of skill names to disable.
|
|
313
337
|
*/
|
|
314
338
|
disabledSkills?: string[];
|
|
339
|
+
/**
|
|
340
|
+
* Infinite session configuration for persistent workspaces and automatic compaction.
|
|
341
|
+
* When enabled (default), sessions automatically manage context limits and persist state.
|
|
342
|
+
* Set to `{ enabled: false }` to disable.
|
|
343
|
+
*/
|
|
344
|
+
infiniteSessions?: InfiniteSessionConfig;
|
|
315
345
|
}
|
|
316
346
|
/**
|
|
317
347
|
* Configuration for resuming a session
|
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.
|
|
7
|
+
"version": "0.1.18",
|
|
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",
|
|
@@ -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.394",
|
|
44
44
|
"vscode-jsonrpc": "^8.2.1",
|
|
45
45
|
"zod": "^4.3.5"
|
|
46
46
|
},
|