@github/copilot-sdk 0.1.25 → 0.1.26-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/dist/client.js +11 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/types.d.ts +7 -1
- package/dist/types.js +2 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -21,6 +21,12 @@ function toJsonSchema(parameters) {
|
|
|
21
21
|
}
|
|
22
22
|
return parameters;
|
|
23
23
|
}
|
|
24
|
+
function getNodeExecPath() {
|
|
25
|
+
if (process.versions.bun) {
|
|
26
|
+
return "node";
|
|
27
|
+
}
|
|
28
|
+
return process.execPath;
|
|
29
|
+
}
|
|
24
30
|
function getBundledCliPath() {
|
|
25
31
|
const sdkUrl = import.meta.resolve("@github/copilot/sdk");
|
|
26
32
|
const sdkPath = fileURLToPath(sdkUrl);
|
|
@@ -354,6 +360,7 @@ class CopilotClient {
|
|
|
354
360
|
const response = await this.connection.sendRequest("session.create", {
|
|
355
361
|
model: config.model,
|
|
356
362
|
sessionId: config.sessionId,
|
|
363
|
+
clientName: config.clientName,
|
|
357
364
|
reasoningEffort: config.reasoningEffort,
|
|
358
365
|
tools: config.tools?.map((tool) => ({
|
|
359
366
|
name: tool.name,
|
|
@@ -364,7 +371,7 @@ class CopilotClient {
|
|
|
364
371
|
availableTools: config.availableTools,
|
|
365
372
|
excludedTools: config.excludedTools,
|
|
366
373
|
provider: config.provider,
|
|
367
|
-
requestPermission:
|
|
374
|
+
requestPermission: true,
|
|
368
375
|
requestUserInput: !!config.onUserInputRequest,
|
|
369
376
|
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
|
|
370
377
|
workingDirectory: config.workingDirectory,
|
|
@@ -425,6 +432,7 @@ class CopilotClient {
|
|
|
425
432
|
}
|
|
426
433
|
const response = await this.connection.sendRequest("session.resume", {
|
|
427
434
|
sessionId,
|
|
435
|
+
clientName: config.clientName,
|
|
428
436
|
model: config.model,
|
|
429
437
|
reasoningEffort: config.reasoningEffort,
|
|
430
438
|
systemMessage: config.systemMessage,
|
|
@@ -436,7 +444,7 @@ class CopilotClient {
|
|
|
436
444
|
parameters: toJsonSchema(tool.parameters)
|
|
437
445
|
})),
|
|
438
446
|
provider: config.provider,
|
|
439
|
-
requestPermission:
|
|
447
|
+
requestPermission: true,
|
|
440
448
|
requestUserInput: !!config.onUserInputRequest,
|
|
441
449
|
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
|
|
442
450
|
workingDirectory: config.workingDirectory,
|
|
@@ -761,7 +769,7 @@ class CopilotClient {
|
|
|
761
769
|
const stdioConfig = this.options.useStdio ? ["pipe", "pipe", "pipe"] : ["ignore", "pipe", "pipe"];
|
|
762
770
|
const isJsFile = this.options.cliPath.endsWith(".js");
|
|
763
771
|
if (isJsFile) {
|
|
764
|
-
this.cliProcess = spawn(
|
|
772
|
+
this.cliProcess = spawn(getNodeExecPath(), [this.options.cliPath, ...args], {
|
|
765
773
|
stdio: stdioConfig,
|
|
766
774
|
cwd: this.options.cwd,
|
|
767
775
|
env: envWithoutNodeDebug,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { CopilotClient } from "./client.js";
|
|
7
7
|
export { CopilotSession, type AssistantMessageEvent } from "./session.js";
|
|
8
|
-
export { defineTool } from "./types.js";
|
|
8
|
+
export { defineTool, approveAll } from "./types.js";
|
|
9
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/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CopilotClient } from "./client.js";
|
|
2
2
|
import { CopilotSession } from "./session.js";
|
|
3
|
-
import { defineTool } from "./types.js";
|
|
3
|
+
import { defineTool, approveAll } from "./types.js";
|
|
4
4
|
export {
|
|
5
5
|
CopilotClient,
|
|
6
6
|
CopilotSession,
|
|
7
|
+
approveAll,
|
|
7
8
|
defineTool
|
|
8
9
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -179,6 +179,7 @@ export interface PermissionRequestResult {
|
|
|
179
179
|
export type PermissionHandler = (request: PermissionRequest, invocation: {
|
|
180
180
|
sessionId: string;
|
|
181
181
|
}) => Promise<PermissionRequestResult> | PermissionRequestResult;
|
|
182
|
+
export declare const approveAll: PermissionHandler;
|
|
182
183
|
/**
|
|
183
184
|
* Request for user input from the agent (enables ask_user tool)
|
|
184
185
|
*/
|
|
@@ -500,6 +501,11 @@ export interface SessionConfig {
|
|
|
500
501
|
* If not provided, server will generate one
|
|
501
502
|
*/
|
|
502
503
|
sessionId?: string;
|
|
504
|
+
/**
|
|
505
|
+
* Client name to identify the application using the SDK.
|
|
506
|
+
* Included in the User-Agent header for API requests.
|
|
507
|
+
*/
|
|
508
|
+
clientName?: string;
|
|
503
509
|
/**
|
|
504
510
|
* Model to use for this session
|
|
505
511
|
*/
|
|
@@ -587,7 +593,7 @@ export interface SessionConfig {
|
|
|
587
593
|
/**
|
|
588
594
|
* Configuration for resuming a session
|
|
589
595
|
*/
|
|
590
|
-
export type ResumeSessionConfig = Pick<SessionConfig, "model" | "tools" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "streaming" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "hooks" | "workingDirectory" | "configDir" | "mcpServers" | "customAgents" | "skillDirectories" | "disabledSkills" | "infiniteSessions"> & {
|
|
596
|
+
export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "streaming" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "hooks" | "workingDirectory" | "configDir" | "mcpServers" | "customAgents" | "skillDirectories" | "disabledSkills" | "infiniteSessions"> & {
|
|
591
597
|
/**
|
|
592
598
|
* When true, skips emitting the session.resume event.
|
|
593
599
|
* Useful for reconnecting to a session without triggering resume-related side effects.
|
package/dist/types.js
CHANGED
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.26-preview.0",
|
|
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",
|