@github/copilot-sdk 0.3.0-preview.0 → 0.3.0-preview.1
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 +2 -2
- package/dist/cjs/client.js +21 -12
- package/dist/cjs/generated/rpc.js +16 -5
- package/dist/cjs/session.js +3 -3
- package/dist/cjs/types.js +1 -1
- package/dist/client.js +21 -12
- package/dist/generated/rpc.d.ts +222 -65
- package/dist/generated/rpc.js +16 -5
- package/dist/generated/session-events.d.ts +379 -6
- package/dist/session.js +3 -3
- package/dist/types.d.ts +24 -4
- package/dist/types.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -86,8 +86,8 @@ new CopilotClient(options?: CopilotClientOptions)
|
|
|
86
86
|
- `useStdio?: boolean` - Use stdio transport instead of TCP (default: true)
|
|
87
87
|
- `logLevel?: string` - Log level (default: "info")
|
|
88
88
|
- `autoStart?: boolean` - Auto-start server (default: true)
|
|
89
|
-
- `
|
|
90
|
-
- `useLoggedInUser?: boolean` - Whether to use logged-in user for authentication (default: true, but false when `
|
|
89
|
+
- `gitHubToken?: string` - GitHub token for authentication. When provided, takes priority over other auth methods.
|
|
90
|
+
- `useLoggedInUser?: boolean` - Whether to use logged-in user for authentication (default: true, but false when `gitHubToken` is provided). Cannot be used with `cliUrl`.
|
|
91
91
|
- `telemetry?: TelemetryConfig` - OpenTelemetry configuration for the CLI process. Providing this object enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.
|
|
92
92
|
- `onGetTraceContext?: TraceContextProvider` - Advanced: callback for linking your application's own OpenTelemetry spans into the same distributed trace as the CLI's spans. Not needed for normal telemetry collection. See [Telemetry](#telemetry) below.
|
|
93
93
|
|
package/dist/cjs/client.js
CHANGED
|
@@ -164,9 +164,9 @@ class CopilotClient {
|
|
|
164
164
|
"isChildProcess must be used in conjunction with useStdio and not with cliUrl"
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
|
-
if (options.cliUrl && (options.
|
|
167
|
+
if (options.cliUrl && (options.gitHubToken || options.useLoggedInUser !== void 0)) {
|
|
168
168
|
throw new Error(
|
|
169
|
-
"
|
|
169
|
+
"gitHubToken and useLoggedInUser cannot be used with cliUrl (external server manages its own auth)"
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
if (options.sessionFs) {
|
|
@@ -198,10 +198,11 @@ class CopilotClient {
|
|
|
198
198
|
autoStart: options.autoStart ?? true,
|
|
199
199
|
autoRestart: false,
|
|
200
200
|
env: effectiveEnv,
|
|
201
|
-
|
|
202
|
-
// Default useLoggedInUser to false when
|
|
203
|
-
useLoggedInUser: options.useLoggedInUser ?? (options.
|
|
204
|
-
telemetry: options.telemetry
|
|
201
|
+
gitHubToken: options.gitHubToken,
|
|
202
|
+
// Default useLoggedInUser to false when gitHubToken is provided, otherwise true
|
|
203
|
+
useLoggedInUser: options.useLoggedInUser ?? (options.gitHubToken ? false : true),
|
|
204
|
+
telemetry: options.telemetry,
|
|
205
|
+
sessionIdleTimeoutSeconds: options.sessionIdleTimeoutSeconds ?? 0
|
|
205
206
|
};
|
|
206
207
|
}
|
|
207
208
|
/**
|
|
@@ -558,7 +559,8 @@ class CopilotClient {
|
|
|
558
559
|
enableConfigDiscovery: config.enableConfigDiscovery,
|
|
559
560
|
skillDirectories: config.skillDirectories,
|
|
560
561
|
disabledSkills: config.disabledSkills,
|
|
561
|
-
infiniteSessions: config.infiniteSessions
|
|
562
|
+
infiniteSessions: config.infiniteSessions,
|
|
563
|
+
gitHubToken: config.gitHubToken
|
|
562
564
|
});
|
|
563
565
|
const { workspacePath, capabilities } = response;
|
|
564
566
|
session["_workspacePath"] = workspacePath;
|
|
@@ -685,7 +687,8 @@ class CopilotClient {
|
|
|
685
687
|
skillDirectories: config.skillDirectories,
|
|
686
688
|
disabledSkills: config.disabledSkills,
|
|
687
689
|
infiniteSessions: config.infiniteSessions,
|
|
688
|
-
disableResume: config.disableResume
|
|
690
|
+
disableResume: config.disableResume,
|
|
691
|
+
gitHubToken: config.gitHubToken
|
|
689
692
|
});
|
|
690
693
|
const { workspacePath, capabilities } = response;
|
|
691
694
|
session["_workspacePath"] = workspacePath;
|
|
@@ -1035,16 +1038,22 @@ class CopilotClient {
|
|
|
1035
1038
|
} else if (this.options.port > 0) {
|
|
1036
1039
|
args.push("--port", this.options.port.toString());
|
|
1037
1040
|
}
|
|
1038
|
-
if (this.options.
|
|
1041
|
+
if (this.options.gitHubToken) {
|
|
1039
1042
|
args.push("--auth-token-env", "COPILOT_SDK_AUTH_TOKEN");
|
|
1040
1043
|
}
|
|
1041
1044
|
if (!this.options.useLoggedInUser) {
|
|
1042
1045
|
args.push("--no-auto-login");
|
|
1043
1046
|
}
|
|
1047
|
+
if (this.options.sessionIdleTimeoutSeconds !== void 0 && this.options.sessionIdleTimeoutSeconds > 0) {
|
|
1048
|
+
args.push(
|
|
1049
|
+
"--session-idle-timeout",
|
|
1050
|
+
this.options.sessionIdleTimeoutSeconds.toString()
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1044
1053
|
const envWithoutNodeDebug = { ...this.options.env };
|
|
1045
1054
|
delete envWithoutNodeDebug.NODE_DEBUG;
|
|
1046
|
-
if (this.options.
|
|
1047
|
-
envWithoutNodeDebug.COPILOT_SDK_AUTH_TOKEN = this.options.
|
|
1055
|
+
if (this.options.gitHubToken) {
|
|
1056
|
+
envWithoutNodeDebug.COPILOT_SDK_AUTH_TOKEN = this.options.gitHubToken;
|
|
1048
1057
|
}
|
|
1049
1058
|
if (!this.options.cliPath) {
|
|
1050
1059
|
throw new Error(
|
|
@@ -1425,7 +1434,7 @@ stderr: ${stderrOutput}`
|
|
|
1425
1434
|
}
|
|
1426
1435
|
return {
|
|
1427
1436
|
result: {
|
|
1428
|
-
kind: "
|
|
1437
|
+
kind: "user-not-available"
|
|
1429
1438
|
}
|
|
1430
1439
|
};
|
|
1431
1440
|
}
|
|
@@ -27,20 +27,22 @@ function createServerRpc(connection) {
|
|
|
27
27
|
return {
|
|
28
28
|
ping: async (params) => connection.sendRequest("ping", params),
|
|
29
29
|
models: {
|
|
30
|
-
list: async () => connection.sendRequest("models.list",
|
|
30
|
+
list: async (params) => connection.sendRequest("models.list", params)
|
|
31
31
|
},
|
|
32
32
|
tools: {
|
|
33
33
|
list: async (params) => connection.sendRequest("tools.list", params)
|
|
34
34
|
},
|
|
35
35
|
account: {
|
|
36
|
-
getQuota: async () => connection.sendRequest("account.getQuota",
|
|
36
|
+
getQuota: async (params) => connection.sendRequest("account.getQuota", params)
|
|
37
37
|
},
|
|
38
38
|
mcp: {
|
|
39
39
|
config: {
|
|
40
40
|
list: async () => connection.sendRequest("mcp.config.list", {}),
|
|
41
41
|
add: async (params) => connection.sendRequest("mcp.config.add", params),
|
|
42
42
|
update: async (params) => connection.sendRequest("mcp.config.update", params),
|
|
43
|
-
remove: async (params) => connection.sendRequest("mcp.config.remove", params)
|
|
43
|
+
remove: async (params) => connection.sendRequest("mcp.config.remove", params),
|
|
44
|
+
enable: async (params) => connection.sendRequest("mcp.config.enable", params),
|
|
45
|
+
disable: async (params) => connection.sendRequest("mcp.config.disable", params)
|
|
44
46
|
},
|
|
45
47
|
discover: async (params) => connection.sendRequest("mcp.discover", params)
|
|
46
48
|
},
|
|
@@ -61,6 +63,9 @@ function createServerRpc(connection) {
|
|
|
61
63
|
}
|
|
62
64
|
function createSessionRpc(connection, sessionId) {
|
|
63
65
|
return {
|
|
66
|
+
auth: {
|
|
67
|
+
getStatus: async () => connection.sendRequest("session.auth.getStatus", { sessionId })
|
|
68
|
+
},
|
|
64
69
|
model: {
|
|
65
70
|
getCurrent: async () => connection.sendRequest("session.model.getCurrent", { sessionId }),
|
|
66
71
|
switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params })
|
|
@@ -111,7 +116,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
111
116
|
list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
|
|
112
117
|
enable: async (params) => connection.sendRequest("session.mcp.enable", { sessionId, ...params }),
|
|
113
118
|
disable: async (params) => connection.sendRequest("session.mcp.disable", { sessionId, ...params }),
|
|
114
|
-
reload: async () => connection.sendRequest("session.mcp.reload", { sessionId })
|
|
119
|
+
reload: async () => connection.sendRequest("session.mcp.reload", { sessionId }),
|
|
120
|
+
/** @experimental */
|
|
121
|
+
oauth: {
|
|
122
|
+
login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params })
|
|
123
|
+
}
|
|
115
124
|
},
|
|
116
125
|
/** @experimental */
|
|
117
126
|
plugins: {
|
|
@@ -135,7 +144,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
135
144
|
handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params })
|
|
136
145
|
},
|
|
137
146
|
permissions: {
|
|
138
|
-
handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params })
|
|
147
|
+
handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params }),
|
|
148
|
+
setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { sessionId, ...params }),
|
|
149
|
+
resetSessionApprovals: async () => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId })
|
|
139
150
|
},
|
|
140
151
|
log: async (params) => connection.sendRequest("session.log", { sessionId, ...params }),
|
|
141
152
|
shell: {
|
package/dist/cjs/session.js
CHANGED
|
@@ -349,7 +349,7 @@ class CopilotSession {
|
|
|
349
349
|
await this.rpc.permissions.handlePendingPermissionRequest({
|
|
350
350
|
requestId,
|
|
351
351
|
result: {
|
|
352
|
-
kind: "
|
|
352
|
+
kind: "user-not-available"
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
} catch (rpcError) {
|
|
@@ -627,7 +627,7 @@ class CopilotSession {
|
|
|
627
627
|
*/
|
|
628
628
|
async _handlePermissionRequestV2(request) {
|
|
629
629
|
if (!this.permissionHandler) {
|
|
630
|
-
return { kind: "
|
|
630
|
+
return { kind: "user-not-available" };
|
|
631
631
|
}
|
|
632
632
|
try {
|
|
633
633
|
const result = await this.permissionHandler(request, {
|
|
@@ -641,7 +641,7 @@ class CopilotSession {
|
|
|
641
641
|
if (error instanceof Error && error.message === NO_RESULT_PERMISSION_V2_ERROR) {
|
|
642
642
|
throw error;
|
|
643
643
|
}
|
|
644
|
-
return { kind: "
|
|
644
|
+
return { kind: "user-not-available" };
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
/**
|
package/dist/cjs/types.js
CHANGED
|
@@ -85,7 +85,7 @@ const SYSTEM_PROMPT_SECTIONS = {
|
|
|
85
85
|
description: "End-of-prompt instructions: parallel tool calling, persistence, task completion"
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
const approveAll = () => ({ kind: "
|
|
88
|
+
const approveAll = () => ({ kind: "approve-once" });
|
|
89
89
|
const defaultJoinSessionPermissionHandler = () => ({
|
|
90
90
|
kind: "no-result"
|
|
91
91
|
});
|
package/dist/client.js
CHANGED
|
@@ -144,9 +144,9 @@ class CopilotClient {
|
|
|
144
144
|
"isChildProcess must be used in conjunction with useStdio and not with cliUrl"
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
|
-
if (options.cliUrl && (options.
|
|
147
|
+
if (options.cliUrl && (options.gitHubToken || options.useLoggedInUser !== void 0)) {
|
|
148
148
|
throw new Error(
|
|
149
|
-
"
|
|
149
|
+
"gitHubToken and useLoggedInUser cannot be used with cliUrl (external server manages its own auth)"
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
if (options.sessionFs) {
|
|
@@ -178,10 +178,11 @@ class CopilotClient {
|
|
|
178
178
|
autoStart: options.autoStart ?? true,
|
|
179
179
|
autoRestart: false,
|
|
180
180
|
env: effectiveEnv,
|
|
181
|
-
|
|
182
|
-
// Default useLoggedInUser to false when
|
|
183
|
-
useLoggedInUser: options.useLoggedInUser ?? (options.
|
|
184
|
-
telemetry: options.telemetry
|
|
181
|
+
gitHubToken: options.gitHubToken,
|
|
182
|
+
// Default useLoggedInUser to false when gitHubToken is provided, otherwise true
|
|
183
|
+
useLoggedInUser: options.useLoggedInUser ?? (options.gitHubToken ? false : true),
|
|
184
|
+
telemetry: options.telemetry,
|
|
185
|
+
sessionIdleTimeoutSeconds: options.sessionIdleTimeoutSeconds ?? 0
|
|
185
186
|
};
|
|
186
187
|
}
|
|
187
188
|
/**
|
|
@@ -538,7 +539,8 @@ class CopilotClient {
|
|
|
538
539
|
enableConfigDiscovery: config.enableConfigDiscovery,
|
|
539
540
|
skillDirectories: config.skillDirectories,
|
|
540
541
|
disabledSkills: config.disabledSkills,
|
|
541
|
-
infiniteSessions: config.infiniteSessions
|
|
542
|
+
infiniteSessions: config.infiniteSessions,
|
|
543
|
+
gitHubToken: config.gitHubToken
|
|
542
544
|
});
|
|
543
545
|
const { workspacePath, capabilities } = response;
|
|
544
546
|
session["_workspacePath"] = workspacePath;
|
|
@@ -665,7 +667,8 @@ class CopilotClient {
|
|
|
665
667
|
skillDirectories: config.skillDirectories,
|
|
666
668
|
disabledSkills: config.disabledSkills,
|
|
667
669
|
infiniteSessions: config.infiniteSessions,
|
|
668
|
-
disableResume: config.disableResume
|
|
670
|
+
disableResume: config.disableResume,
|
|
671
|
+
gitHubToken: config.gitHubToken
|
|
669
672
|
});
|
|
670
673
|
const { workspacePath, capabilities } = response;
|
|
671
674
|
session["_workspacePath"] = workspacePath;
|
|
@@ -1015,16 +1018,22 @@ class CopilotClient {
|
|
|
1015
1018
|
} else if (this.options.port > 0) {
|
|
1016
1019
|
args.push("--port", this.options.port.toString());
|
|
1017
1020
|
}
|
|
1018
|
-
if (this.options.
|
|
1021
|
+
if (this.options.gitHubToken) {
|
|
1019
1022
|
args.push("--auth-token-env", "COPILOT_SDK_AUTH_TOKEN");
|
|
1020
1023
|
}
|
|
1021
1024
|
if (!this.options.useLoggedInUser) {
|
|
1022
1025
|
args.push("--no-auto-login");
|
|
1023
1026
|
}
|
|
1027
|
+
if (this.options.sessionIdleTimeoutSeconds !== void 0 && this.options.sessionIdleTimeoutSeconds > 0) {
|
|
1028
|
+
args.push(
|
|
1029
|
+
"--session-idle-timeout",
|
|
1030
|
+
this.options.sessionIdleTimeoutSeconds.toString()
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1024
1033
|
const envWithoutNodeDebug = { ...this.options.env };
|
|
1025
1034
|
delete envWithoutNodeDebug.NODE_DEBUG;
|
|
1026
|
-
if (this.options.
|
|
1027
|
-
envWithoutNodeDebug.COPILOT_SDK_AUTH_TOKEN = this.options.
|
|
1035
|
+
if (this.options.gitHubToken) {
|
|
1036
|
+
envWithoutNodeDebug.COPILOT_SDK_AUTH_TOKEN = this.options.gitHubToken;
|
|
1028
1037
|
}
|
|
1029
1038
|
if (!this.options.cliPath) {
|
|
1030
1039
|
throw new Error(
|
|
@@ -1405,7 +1414,7 @@ stderr: ${stderrOutput}`
|
|
|
1405
1414
|
}
|
|
1406
1415
|
return {
|
|
1407
1416
|
result: {
|
|
1408
|
-
kind: "
|
|
1417
|
+
kind: "user-not-available"
|
|
1409
1418
|
}
|
|
1410
1419
|
};
|
|
1411
1420
|
}
|