🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@github/copilot-sdk

Package Overview
Dependencies
Maintainers
21
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@github/copilot-sdk - npm Package Compare versions

Comparing version
0.1.17
to
0.1.18
+6
-5
dist/client.js

@@ -325,6 +325,7 @@ import { spawn } from "node:child_process";

skillDirectories: config.skillDirectories,
disabledSkills: config.disabledSkills
disabledSkills: config.disabledSkills,
infiniteSessions: config.infiniteSessions
});
const sessionId = response.sessionId;
const session = new CopilotSession(sessionId, this.connection);
const { sessionId, workspacePath } = response;
const session = new CopilotSession(sessionId, this.connection, workspacePath);
session.registerTools(config.tools);

@@ -383,4 +384,4 @@ if (config.onPermissionRequest) {

});
const resumedSessionId = response.sessionId;
const session = new CopilotSession(resumedSessionId, this.connection);
const { sessionId: resumedSessionId, workspacePath } = response;
const session = new CopilotSession(resumedSessionId, this.connection, workspacePath);
session.registerTools(config.tools);

@@ -387,0 +388,0 @@ if (config.onPermissionRequest) {

@@ -9,2 +9,2 @@ /**

export { defineTool } from "./types.js";
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";
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";

@@ -39,2 +39,3 @@ /**

private connection;
private readonly _workspacePath?;
private eventHandlers;

@@ -48,6 +49,13 @@ private toolHandlers;

* @param connection - The JSON-RPC message connection to the Copilot CLI
* @param workspacePath - Path to the session workspace directory (when infinite sessions enabled)
* @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
*/
constructor(sessionId: string, connection: MessageConnection);
constructor(sessionId: string, connection: MessageConnection, _workspacePath?: string | undefined);
/**
* Path to the session workspace directory when infinite sessions are enabled.
* Contains checkpoints/, plan.md, and files/ subdirectories.
* Undefined if infinite sessions are disabled.
*/
get workspacePath(): string | undefined;
/**
* Sends a message to this session and waits for the response.

@@ -54,0 +62,0 @@ *

@@ -7,7 +7,9 @@ class CopilotSession {

* @param connection - The JSON-RPC message connection to the Copilot CLI
* @param workspacePath - Path to the session workspace directory (when infinite sessions enabled)
* @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
*/
constructor(sessionId, connection) {
constructor(sessionId, connection, _workspacePath) {
this.sessionId = sessionId;
this.connection = connection;
this._workspacePath = _workspacePath;
}

@@ -18,2 +20,10 @@ eventHandlers = /* @__PURE__ */ new Set();

/**
* Path to the session workspace directory when infinite sessions are enabled.
* Contains checkpoints/, plan.md, and files/ subdirectories.
* Undefined if infinite sessions are disabled.
*/
get workspacePath() {
return this._workspacePath;
}
/**
* Sends a message to this session and waits for the response.

@@ -20,0 +30,0 @@ *

@@ -253,2 +253,26 @@ /**

}
/**
* Configuration for infinite sessions with automatic context compaction and workspace persistence.
* When enabled, sessions automatically manage context window limits through background compaction
* and persist state to a workspace directory.
*/
export interface InfiniteSessionConfig {
/**
* Whether infinite sessions are enabled.
* @default true
*/
enabled?: boolean;
/**
* Context utilization threshold (0.0-1.0) at which background compaction starts.
* Compaction runs asynchronously, allowing the session to continue processing.
* @default 0.80
*/
backgroundCompactionThreshold?: number;
/**
* Context utilization threshold (0.0-1.0) at which the session blocks until compaction completes.
* This prevents context overflow when compaction hasn't finished in time.
* @default 0.95
*/
bufferExhaustionThreshold?: number;
}
export interface SessionConfig {

@@ -316,2 +340,8 @@ /**

disabledSkills?: string[];
/**
* Infinite session configuration for persistent workspaces and automatic compaction.
* When enabled (default), sessions automatically manage context limits and persist state.
* Set to `{ enabled: false }` to disable.
*/
infiniteSessions?: InfiniteSessionConfig;
}

@@ -318,0 +348,0 @@ /**

@@ -7,3 +7,3 @@ {

},
"version": "0.1.17",
"version": "0.1.18",
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",

@@ -44,3 +44,3 @@ "main": "./dist/index.js",

"dependencies": {
"@github/copilot": "^0.0.389",
"@github/copilot": "^0.0.394",
"vscode-jsonrpc": "^8.2.1",

@@ -47,0 +47,0 @@ "zod": "^4.3.5"

@@ -92,6 +92,7 @@ # Copilot SDK for Node.js/TypeScript

- `systemMessage?: SystemMessageConfig` - System message customization (see below)
- `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
##### `resumeSession(sessionId: string, config?: ResumeSessionConfig): Promise<CopilotSession>`
Resume an existing session.
Resume an existing session. Returns the session with `workspacePath` populated if infinite sessions were enabled.

@@ -120,2 +121,12 @@ ##### `ping(message?: string): Promise<{ message: string; timestamp: number }>`

#### Properties
##### `sessionId: string`
The unique identifier for this session.
##### `workspacePath?: string`
Path to the session workspace directory when infinite sessions are enabled. Contains `checkpoints/`, `plan.md`, and `files/` subdirectories. Undefined if infinite sessions are disabled.
#### Methods

@@ -332,2 +343,36 @@

### Infinite Sessions
By default, sessions use **infinite sessions** which automatically manage context window limits through background compaction and persist state to a workspace directory.
```typescript
// Default: infinite sessions enabled with default thresholds
const session = await client.createSession({ model: "gpt-5" });
// Access the workspace path for checkpoints and files
console.log(session.workspacePath);
// => ~/.copilot/session-state/{sessionId}/
// Custom thresholds
const session = await client.createSession({
model: "gpt-5",
infiniteSessions: {
enabled: true,
backgroundCompactionThreshold: 0.80, // Start compacting at 80% context usage
bufferExhaustionThreshold: 0.95, // Block at 95% until compaction completes
},
});
// Disable infinite sessions
const session = await client.createSession({
model: "gpt-5",
infiniteSessions: { enabled: false },
});
```
When enabled, sessions emit compaction events:
- `session.compaction_start` - Background compaction started
- `session.compaction_complete` - Compaction finished (includes token counts)
### Multiple Sessions

@@ -334,0 +379,0 @@