@ai-sdk/harness-github-copilot 0.0.0 → 1.0.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/CHANGELOG.md +20 -0
- package/LICENSE +13 -0
- package/README.md +41 -3
- package/dist/index.d.ts +11566 -0
- package/dist/index.js +420 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -11
- package/src/bridge/package.json +9 -0
- package/src/bridge/pnpm-lock.yaml +116 -0
- package/src/bridge/pnpm-workspace.yaml +2 -0
- package/src/github-copilot-harness.ts +467 -0
- package/src/index.ts +15 -0
- package/src/version.ts +5 -0
- package/index.js +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
lockfileVersion: '9.0'
|
|
2
|
+
|
|
3
|
+
settings:
|
|
4
|
+
autoInstallPeers: true
|
|
5
|
+
excludeLinksFromLockfile: false
|
|
6
|
+
|
|
7
|
+
importers:
|
|
8
|
+
|
|
9
|
+
.:
|
|
10
|
+
dependencies:
|
|
11
|
+
'@github/copilot':
|
|
12
|
+
specifier: 1.0.82
|
|
13
|
+
version: 1.0.82
|
|
14
|
+
|
|
15
|
+
packages:
|
|
16
|
+
|
|
17
|
+
'@github/copilot-darwin-arm64@1.0.82':
|
|
18
|
+
resolution: {integrity: sha512-UpVSFA0COmlIakAr7/6WJqJlabtKgY8y5en6La3IxGxXsLlbkGoeevSqyfXvqJyHxaGn0YGpOC1oEPL379JfCw==}
|
|
19
|
+
cpu: [arm64]
|
|
20
|
+
os: [darwin]
|
|
21
|
+
hasBin: true
|
|
22
|
+
|
|
23
|
+
'@github/copilot-darwin-x64@1.0.82':
|
|
24
|
+
resolution: {integrity: sha512-wMKbxK8fpKsbATjn9dE31Pae67H1xu6dmaCuyXpXjXLsNPVjeLFszJZ30MAOwxRWz4dmA8VvEJZmLgJekojo2Q==}
|
|
25
|
+
cpu: [x64]
|
|
26
|
+
os: [darwin]
|
|
27
|
+
hasBin: true
|
|
28
|
+
|
|
29
|
+
'@github/copilot-linux-arm64@1.0.82':
|
|
30
|
+
resolution: {integrity: sha512-YDQmh0F+GzWORPmNNxQdcjHcXHxcy08dhMhbAhu4cqtMeA2sZWQqhfk9mJhHppMm9U0uR7h0KAB6nsgw/8Bsuw==}
|
|
31
|
+
cpu: [arm64]
|
|
32
|
+
os: [linux]
|
|
33
|
+
libc: [glibc]
|
|
34
|
+
hasBin: true
|
|
35
|
+
|
|
36
|
+
'@github/copilot-linux-x64@1.0.82':
|
|
37
|
+
resolution: {integrity: sha512-vqmG9665ktgLHAkGKMjp4uVMdHqLxi8uS9zL+g2pMwZUPoM7JxkaSfOoeyYr99caF7J6VIJTWv4LdRNQyG5jrQ==}
|
|
38
|
+
cpu: [x64]
|
|
39
|
+
os: [linux]
|
|
40
|
+
libc: [glibc]
|
|
41
|
+
hasBin: true
|
|
42
|
+
|
|
43
|
+
'@github/copilot-linuxmusl-arm64@1.0.82':
|
|
44
|
+
resolution: {integrity: sha512-14dWfa4rBME55bKmF+Z8V+WzZNgPQZKFFBQX+EOiAgLVV/arQCnQ1m7wwa5oXjQeCIgkS/L9J8uM8jNm6cZbOA==}
|
|
45
|
+
cpu: [arm64]
|
|
46
|
+
os: [linux]
|
|
47
|
+
libc: [musl]
|
|
48
|
+
hasBin: true
|
|
49
|
+
|
|
50
|
+
'@github/copilot-linuxmusl-x64@1.0.82':
|
|
51
|
+
resolution: {integrity: sha512-Mauqa2TBjtB8W/1KXF/jJ4MbtwnLvoEQNHYoSyoX+s+nIpttmixmYBJDwKV89ZlQRdjOCuxOgraRLQ9hjjXvNQ==}
|
|
52
|
+
cpu: [x64]
|
|
53
|
+
os: [linux]
|
|
54
|
+
libc: [musl]
|
|
55
|
+
hasBin: true
|
|
56
|
+
|
|
57
|
+
'@github/copilot-win32-arm64@1.0.82':
|
|
58
|
+
resolution: {integrity: sha512-PaW9s0GTgM+svtDkB583dZRrhLrO4o10y2ozMmQ0Hi5eB11C24UdC5U81nFlvKPED7+GlnBJIFQ+oHaxHrnp3A==}
|
|
59
|
+
cpu: [arm64]
|
|
60
|
+
os: [win32]
|
|
61
|
+
hasBin: true
|
|
62
|
+
|
|
63
|
+
'@github/copilot-win32-x64@1.0.82':
|
|
64
|
+
resolution: {integrity: sha512-m4iSROOMEPp1yRIQQwbnO0CDfwB4syESyHoeSLLFuynMR4/ApghAdyBrBQQcTKGsUu3R5rOE64RYlVmyKmuA9A==}
|
|
65
|
+
cpu: [x64]
|
|
66
|
+
os: [win32]
|
|
67
|
+
hasBin: true
|
|
68
|
+
|
|
69
|
+
'@github/copilot@1.0.82':
|
|
70
|
+
resolution: {integrity: sha512-+mDIwBO3dCpL3k2rVLc4+1tFzqcVBTJNA/0co+okEpmCgcHjaz91Cqq7++pJKN5yJQuGC6bKangm7PSoheI1Xw==}
|
|
71
|
+
hasBin: true
|
|
72
|
+
|
|
73
|
+
detect-libc@2.1.2:
|
|
74
|
+
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
|
|
75
|
+
engines: {node: '>=8'}
|
|
76
|
+
|
|
77
|
+
snapshots:
|
|
78
|
+
|
|
79
|
+
'@github/copilot-darwin-arm64@1.0.82':
|
|
80
|
+
optional: true
|
|
81
|
+
|
|
82
|
+
'@github/copilot-darwin-x64@1.0.82':
|
|
83
|
+
optional: true
|
|
84
|
+
|
|
85
|
+
'@github/copilot-linux-arm64@1.0.82':
|
|
86
|
+
optional: true
|
|
87
|
+
|
|
88
|
+
'@github/copilot-linux-x64@1.0.82':
|
|
89
|
+
optional: true
|
|
90
|
+
|
|
91
|
+
'@github/copilot-linuxmusl-arm64@1.0.82':
|
|
92
|
+
optional: true
|
|
93
|
+
|
|
94
|
+
'@github/copilot-linuxmusl-x64@1.0.82':
|
|
95
|
+
optional: true
|
|
96
|
+
|
|
97
|
+
'@github/copilot-win32-arm64@1.0.82':
|
|
98
|
+
optional: true
|
|
99
|
+
|
|
100
|
+
'@github/copilot-win32-x64@1.0.82':
|
|
101
|
+
optional: true
|
|
102
|
+
|
|
103
|
+
'@github/copilot@1.0.82':
|
|
104
|
+
dependencies:
|
|
105
|
+
detect-libc: 2.1.2
|
|
106
|
+
optionalDependencies:
|
|
107
|
+
'@github/copilot-darwin-arm64': 1.0.82
|
|
108
|
+
'@github/copilot-darwin-x64': 1.0.82
|
|
109
|
+
'@github/copilot-linux-arm64': 1.0.82
|
|
110
|
+
'@github/copilot-linux-x64': 1.0.82
|
|
111
|
+
'@github/copilot-linuxmusl-arm64': 1.0.82
|
|
112
|
+
'@github/copilot-linuxmusl-x64': 1.0.82
|
|
113
|
+
'@github/copilot-win32-arm64': 1.0.82
|
|
114
|
+
'@github/copilot-win32-x64': 1.0.82
|
|
115
|
+
|
|
116
|
+
detect-libc@2.1.2: {}
|
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import {
|
|
2
|
+
commonTool,
|
|
3
|
+
type HarnessV1,
|
|
4
|
+
type HarnessV1BuiltinTool,
|
|
5
|
+
type HarnessV1CredentialForwarding,
|
|
6
|
+
type HarnessV1PortEndpoint,
|
|
7
|
+
type HarnessV1RequestTransformation,
|
|
8
|
+
} from '@ai-sdk/harness';
|
|
9
|
+
import { createCredentialRequestTransformation } from '@ai-sdk/harness/utils';
|
|
10
|
+
import { createACP, type ACPAuthenticationMode } from '@ai-sdk/harness-acp';
|
|
11
|
+
import { tool } from '@ai-sdk/provider-utils';
|
|
12
|
+
import { z } from 'zod/v4';
|
|
13
|
+
import { VERSION } from './version';
|
|
14
|
+
|
|
15
|
+
declare const __GITHUB_COPILOT_IMPLEMENTATION_PACKAGE_JSON__: string;
|
|
16
|
+
declare const __GITHUB_COPILOT_IMPLEMENTATION_PNPM_LOCK_YAML__: string;
|
|
17
|
+
declare const __GITHUB_COPILOT_IMPLEMENTATION_PNPM_WORKSPACE_YAML__: string;
|
|
18
|
+
|
|
19
|
+
const GITHUB_COPILOT_CLIENT_APP = {
|
|
20
|
+
name: 'ai-sdk/harness-github-copilot',
|
|
21
|
+
version: VERSION,
|
|
22
|
+
} as const;
|
|
23
|
+
const GITHUB_COPILOT_IMPLEMENTATION_PACKAGE_JSON =
|
|
24
|
+
__GITHUB_COPILOT_IMPLEMENTATION_PACKAGE_JSON__;
|
|
25
|
+
const GITHUB_COPILOT_IMPLEMENTATION_PNPM_LOCK =
|
|
26
|
+
__GITHUB_COPILOT_IMPLEMENTATION_PNPM_LOCK_YAML__;
|
|
27
|
+
const GITHUB_COPILOT_IMPLEMENTATION_PNPM_WORKSPACE =
|
|
28
|
+
__GITHUB_COPILOT_IMPLEMENTATION_PNPM_WORKSPACE_YAML__;
|
|
29
|
+
|
|
30
|
+
export type GitHubCopilotAuthenticationMode = ACPAuthenticationMode;
|
|
31
|
+
|
|
32
|
+
export type GitHubCopilotHarnessSettings = {
|
|
33
|
+
readonly auth?: GitHubCopilotAuthenticationMode;
|
|
34
|
+
readonly credentialForwarding?: HarnessV1CredentialForwarding;
|
|
35
|
+
readonly reasoningEffort?:
|
|
36
|
+
| 'none'
|
|
37
|
+
| 'minimal'
|
|
38
|
+
| 'low'
|
|
39
|
+
| 'medium'
|
|
40
|
+
| 'high'
|
|
41
|
+
| 'xhigh'
|
|
42
|
+
| 'max';
|
|
43
|
+
readonly mcpServers?: Record<string, unknown>;
|
|
44
|
+
readonly port?: number;
|
|
45
|
+
readonly portEndpoint?: HarnessV1PortEndpoint;
|
|
46
|
+
readonly startupTimeoutMs?: number;
|
|
47
|
+
readonly mintBridgeToken?: (sandboxId: string) => string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* This catalog reflects the stable, non-MCP tool surface emitted by GitHub
|
|
52
|
+
* Copilot CLI 1.0.82. Loose object schemas preserve compatibility when the
|
|
53
|
+
* CLI adds fields without changing the established inputs.
|
|
54
|
+
*/
|
|
55
|
+
const GITHUB_COPILOT_BUILTIN_TOOLS = {
|
|
56
|
+
bash: {
|
|
57
|
+
...commonTool('bash', {
|
|
58
|
+
nativeName: 'bash',
|
|
59
|
+
toolUseKind: 'bash',
|
|
60
|
+
inputSchema: z.looseObject({
|
|
61
|
+
command: z.string(),
|
|
62
|
+
description: z.string().optional(),
|
|
63
|
+
shellId: z.string().optional(),
|
|
64
|
+
mode: z.enum(['sync', 'async']).optional(),
|
|
65
|
+
detach: z.boolean().optional(),
|
|
66
|
+
initial_wait: z.number().optional(),
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
read_bash: {
|
|
71
|
+
...tool({
|
|
72
|
+
title: 'Reading shell output',
|
|
73
|
+
inputSchema: z.looseObject({
|
|
74
|
+
shellId: z.string(),
|
|
75
|
+
delay: z.number(),
|
|
76
|
+
}),
|
|
77
|
+
}),
|
|
78
|
+
toolUseKind: 'readonly',
|
|
79
|
+
},
|
|
80
|
+
stop_bash: {
|
|
81
|
+
...tool({
|
|
82
|
+
title: 'Stopping shell session',
|
|
83
|
+
inputSchema: z.looseObject({ shellId: z.string() }),
|
|
84
|
+
}),
|
|
85
|
+
toolUseKind: 'bash',
|
|
86
|
+
},
|
|
87
|
+
list_bash: {
|
|
88
|
+
...tool({
|
|
89
|
+
title: 'list_bash',
|
|
90
|
+
inputSchema: z.looseObject({}),
|
|
91
|
+
}),
|
|
92
|
+
toolUseKind: 'readonly',
|
|
93
|
+
},
|
|
94
|
+
view: {
|
|
95
|
+
...tool({
|
|
96
|
+
title: 'Viewing ',
|
|
97
|
+
inputSchema: z.looseObject({
|
|
98
|
+
path: z.string(),
|
|
99
|
+
view_range: z.array(z.number()).optional(),
|
|
100
|
+
forceReadLargeFiles: z.boolean().optional(),
|
|
101
|
+
}),
|
|
102
|
+
}),
|
|
103
|
+
toolUseKind: 'readonly',
|
|
104
|
+
},
|
|
105
|
+
create: {
|
|
106
|
+
...tool({
|
|
107
|
+
title: 'Creating ',
|
|
108
|
+
inputSchema: z.looseObject({
|
|
109
|
+
path: z.string(),
|
|
110
|
+
file_text: z.string(),
|
|
111
|
+
}),
|
|
112
|
+
}),
|
|
113
|
+
toolUseKind: 'edit',
|
|
114
|
+
},
|
|
115
|
+
edit: {
|
|
116
|
+
...tool({
|
|
117
|
+
title: 'Editing ',
|
|
118
|
+
inputSchema: z.looseObject({
|
|
119
|
+
path: z.string(),
|
|
120
|
+
old_str: z.string().optional(),
|
|
121
|
+
new_str: z.string(),
|
|
122
|
+
}),
|
|
123
|
+
}),
|
|
124
|
+
toolUseKind: 'edit',
|
|
125
|
+
},
|
|
126
|
+
web_fetch: {
|
|
127
|
+
...tool({
|
|
128
|
+
title: 'Fetching ',
|
|
129
|
+
inputSchema: z.looseObject({
|
|
130
|
+
url: z.string(),
|
|
131
|
+
max_length: z.number().optional(),
|
|
132
|
+
start_index: z.number().optional(),
|
|
133
|
+
raw: z.boolean().optional(),
|
|
134
|
+
}),
|
|
135
|
+
}),
|
|
136
|
+
toolUseKind: 'readonly',
|
|
137
|
+
},
|
|
138
|
+
skill: tool({
|
|
139
|
+
title: 'Using skill: ',
|
|
140
|
+
inputSchema: z.looseObject({ skill: z.string() }),
|
|
141
|
+
}),
|
|
142
|
+
sql: tool({
|
|
143
|
+
inputSchema: z.looseObject({
|
|
144
|
+
description: z.string(),
|
|
145
|
+
query: z.string(),
|
|
146
|
+
database: z.enum(['session', 'session_store']).optional(),
|
|
147
|
+
}),
|
|
148
|
+
}),
|
|
149
|
+
read_agent: {
|
|
150
|
+
...tool({
|
|
151
|
+
title: 'read_agent',
|
|
152
|
+
inputSchema: z.looseObject({
|
|
153
|
+
agent_id: z.string(),
|
|
154
|
+
wait: z.boolean().optional(),
|
|
155
|
+
timeout: z.number().optional(),
|
|
156
|
+
since_turn: z.number().int().nonnegative().optional(),
|
|
157
|
+
}),
|
|
158
|
+
}),
|
|
159
|
+
toolUseKind: 'readonly',
|
|
160
|
+
},
|
|
161
|
+
list_agents: {
|
|
162
|
+
...tool({
|
|
163
|
+
title: 'list_agents',
|
|
164
|
+
inputSchema: z.looseObject({
|
|
165
|
+
include_completed: z.boolean().optional(),
|
|
166
|
+
scope: z.enum(['siblings', 'children', 'all']).optional(),
|
|
167
|
+
}),
|
|
168
|
+
}),
|
|
169
|
+
toolUseKind: 'readonly',
|
|
170
|
+
},
|
|
171
|
+
write_agent: tool({
|
|
172
|
+
title: 'write_agent',
|
|
173
|
+
inputSchema: z.looseObject({
|
|
174
|
+
message: z.string(),
|
|
175
|
+
agent_id: z.string().optional(),
|
|
176
|
+
agent_ids: z.array(z.string()).optional(),
|
|
177
|
+
scope: z.enum(['siblings', 'children']).optional(),
|
|
178
|
+
}),
|
|
179
|
+
}),
|
|
180
|
+
grep: {
|
|
181
|
+
...commonTool('grep', {
|
|
182
|
+
nativeName: 'grep',
|
|
183
|
+
toolUseKind: 'readonly',
|
|
184
|
+
inputSchema: z.looseObject({
|
|
185
|
+
pattern: z.string(),
|
|
186
|
+
path: z.string().optional(),
|
|
187
|
+
paths: z.array(z.string()).optional(),
|
|
188
|
+
glob: z.string().optional(),
|
|
189
|
+
output_mode: z
|
|
190
|
+
.enum(['content', 'files_with_matches', 'count'])
|
|
191
|
+
.optional(),
|
|
192
|
+
case_insensitive: z.boolean().optional(),
|
|
193
|
+
multiline: z.boolean().optional(),
|
|
194
|
+
head_limit: z.number().optional(),
|
|
195
|
+
context: z.number().optional(),
|
|
196
|
+
before_context: z.number().optional(),
|
|
197
|
+
after_context: z.number().optional(),
|
|
198
|
+
}),
|
|
199
|
+
}),
|
|
200
|
+
title: 'Searching for ',
|
|
201
|
+
},
|
|
202
|
+
glob: {
|
|
203
|
+
...commonTool('glob', {
|
|
204
|
+
nativeName: 'glob',
|
|
205
|
+
toolUseKind: 'readonly',
|
|
206
|
+
inputSchema: z.looseObject({
|
|
207
|
+
pattern: z.string(),
|
|
208
|
+
paths: z.array(z.string()).optional(),
|
|
209
|
+
}),
|
|
210
|
+
}),
|
|
211
|
+
title: 'Finding files matching ',
|
|
212
|
+
},
|
|
213
|
+
task: tool({
|
|
214
|
+
inputSchema: z.looseObject({
|
|
215
|
+
name: z.string(),
|
|
216
|
+
prompt: z.string(),
|
|
217
|
+
agent_type: z.enum([
|
|
218
|
+
'explore',
|
|
219
|
+
'task',
|
|
220
|
+
'general-purpose',
|
|
221
|
+
'code-review',
|
|
222
|
+
'research',
|
|
223
|
+
'security-review',
|
|
224
|
+
]),
|
|
225
|
+
description: z.string(),
|
|
226
|
+
model: z.string().optional(),
|
|
227
|
+
context_tier: z.enum(['default', 'long_context']).optional(),
|
|
228
|
+
mode: z.enum(['sync', 'background']).optional(),
|
|
229
|
+
}),
|
|
230
|
+
}),
|
|
231
|
+
} as const satisfies Record<string, HarnessV1BuiltinTool<any, any>>;
|
|
232
|
+
|
|
233
|
+
export type GitHubCopilotBuiltinTools = typeof GITHUB_COPILOT_BUILTIN_TOOLS;
|
|
234
|
+
|
|
235
|
+
export function createGitHubCopilot(
|
|
236
|
+
settings: GitHubCopilotHarnessSettings = {},
|
|
237
|
+
): HarnessV1<GitHubCopilotBuiltinTools> {
|
|
238
|
+
const mcpToolTitlePrefixes = [
|
|
239
|
+
'github-mcp-server-',
|
|
240
|
+
...Object.keys(settings.mcpServers ?? {}).map(name => `${name}-`),
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
return createACP({
|
|
244
|
+
version: 'v1',
|
|
245
|
+
harnessId: 'github-copilot',
|
|
246
|
+
clientApp: GITHUB_COPILOT_CLIENT_APP,
|
|
247
|
+
source: {
|
|
248
|
+
type: 'npm-locked',
|
|
249
|
+
packageJson: GITHUB_COPILOT_IMPLEMENTATION_PACKAGE_JSON,
|
|
250
|
+
pnpmLockYaml: GITHUB_COPILOT_IMPLEMENTATION_PNPM_LOCK,
|
|
251
|
+
pnpmWorkspaceYaml: GITHUB_COPILOT_IMPLEMENTATION_PNPM_WORKSPACE,
|
|
252
|
+
},
|
|
253
|
+
executable: 'copilot',
|
|
254
|
+
args: [
|
|
255
|
+
'--acp',
|
|
256
|
+
'--stdio',
|
|
257
|
+
'--no-auto-update',
|
|
258
|
+
...(settings.reasoningEffort == null
|
|
259
|
+
? []
|
|
260
|
+
: [`--reasoning-effort=${settings.reasoningEffort}`]),
|
|
261
|
+
],
|
|
262
|
+
auth: settings.auth,
|
|
263
|
+
/*
|
|
264
|
+
* The Copilot CLI drops every MCP server that a client passes in ACP
|
|
265
|
+
* `session/new` unless it is declared with the `http` or `sse` transport,
|
|
266
|
+
* so host tools must be exposed over the bridge's HTTP MCP endpoint.
|
|
267
|
+
*/
|
|
268
|
+
hostToolMcpTransport: 'http',
|
|
269
|
+
forwardEnv: ['COPILOT_GH_HOST', 'GH_HOST'],
|
|
270
|
+
credentialEnv: ['COPILOT_GITHUB_TOKEN', 'GH_TOKEN', 'GITHUB_TOKEN'],
|
|
271
|
+
credentialBrokering: ({ env, sandboxEnv, headers }) => {
|
|
272
|
+
const transformations: HarnessV1RequestTransformation[] = [];
|
|
273
|
+
const githubHost = normalizeGitHubHost(
|
|
274
|
+
env.COPILOT_GH_HOST ?? env.GH_HOST ?? 'github.com',
|
|
275
|
+
);
|
|
276
|
+
const githubHosts = [
|
|
277
|
+
githubHost,
|
|
278
|
+
`*.${githubHost}`,
|
|
279
|
+
...(githubHost === 'github.com'
|
|
280
|
+
? ['githubcopilot.com', '*.githubcopilot.com']
|
|
281
|
+
: []),
|
|
282
|
+
];
|
|
283
|
+
|
|
284
|
+
for (const host of githubHosts) {
|
|
285
|
+
if (env.COPILOT_GITHUB_TOKEN && sandboxEnv?.COPILOT_GITHUB_TOKEN) {
|
|
286
|
+
transformations.push(
|
|
287
|
+
{
|
|
288
|
+
match: {
|
|
289
|
+
host,
|
|
290
|
+
headers: [
|
|
291
|
+
{
|
|
292
|
+
key: { exact: 'Authorization' },
|
|
293
|
+
value: {
|
|
294
|
+
exact: `Bearer ${sandboxEnv.COPILOT_GITHUB_TOKEN}`,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
transform: {
|
|
300
|
+
headers: {
|
|
301
|
+
Authorization: `Bearer ${env.COPILOT_GITHUB_TOKEN}`,
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
match: {
|
|
307
|
+
host,
|
|
308
|
+
headers: [
|
|
309
|
+
{
|
|
310
|
+
key: { exact: 'Authorization' },
|
|
311
|
+
value: {
|
|
312
|
+
exact: `token ${sandboxEnv.COPILOT_GITHUB_TOKEN}`,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
transform: {
|
|
318
|
+
headers: {
|
|
319
|
+
Authorization: `token ${env.COPILOT_GITHUB_TOKEN}`,
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (env.GH_TOKEN && sandboxEnv?.GH_TOKEN) {
|
|
327
|
+
transformations.push(
|
|
328
|
+
{
|
|
329
|
+
match: {
|
|
330
|
+
host,
|
|
331
|
+
headers: [
|
|
332
|
+
{
|
|
333
|
+
key: { exact: 'Authorization' },
|
|
334
|
+
value: { exact: `Bearer ${sandboxEnv.GH_TOKEN}` },
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
transform: {
|
|
339
|
+
headers: { Authorization: `Bearer ${env.GH_TOKEN}` },
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
match: {
|
|
344
|
+
host,
|
|
345
|
+
headers: [
|
|
346
|
+
{
|
|
347
|
+
key: { exact: 'Authorization' },
|
|
348
|
+
value: { exact: `token ${sandboxEnv.GH_TOKEN}` },
|
|
349
|
+
},
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
transform: {
|
|
353
|
+
headers: { Authorization: `token ${env.GH_TOKEN}` },
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (env.GITHUB_TOKEN && sandboxEnv?.GITHUB_TOKEN) {
|
|
360
|
+
transformations.push(
|
|
361
|
+
{
|
|
362
|
+
match: {
|
|
363
|
+
host,
|
|
364
|
+
headers: [
|
|
365
|
+
{
|
|
366
|
+
key: { exact: 'Authorization' },
|
|
367
|
+
value: { exact: `Bearer ${sandboxEnv.GITHUB_TOKEN}` },
|
|
368
|
+
},
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
transform: {
|
|
372
|
+
headers: { Authorization: `Bearer ${env.GITHUB_TOKEN}` },
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
match: {
|
|
377
|
+
host,
|
|
378
|
+
headers: [
|
|
379
|
+
{
|
|
380
|
+
key: { exact: 'Authorization' },
|
|
381
|
+
value: { exact: `token ${sandboxEnv.GITHUB_TOKEN}` },
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
},
|
|
385
|
+
transform: {
|
|
386
|
+
headers: { Authorization: `token ${env.GITHUB_TOKEN}` },
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const providerCredential = env.COPILOT_PROVIDER_API_KEY;
|
|
394
|
+
const sandboxProviderCredential = sandboxEnv?.COPILOT_PROVIDER_API_KEY;
|
|
395
|
+
const providerBaseUrl = env.COPILOT_PROVIDER_BASE_URL;
|
|
396
|
+
if (providerCredential && sandboxProviderCredential && providerBaseUrl) {
|
|
397
|
+
transformations.push(
|
|
398
|
+
createCredentialRequestTransformation({
|
|
399
|
+
matchUrl: providerBaseUrl,
|
|
400
|
+
matchHeaders: {
|
|
401
|
+
Authorization: `Bearer ${sandboxProviderCredential}`,
|
|
402
|
+
},
|
|
403
|
+
transformHeaders: {
|
|
404
|
+
...headers,
|
|
405
|
+
Authorization: `Bearer ${providerCredential}`,
|
|
406
|
+
},
|
|
407
|
+
}),
|
|
408
|
+
);
|
|
409
|
+
} else if (headers != null) {
|
|
410
|
+
const copilotHosts =
|
|
411
|
+
githubHost === 'github.com'
|
|
412
|
+
? ['githubcopilot.com', '*.githubcopilot.com']
|
|
413
|
+
: [githubHost, `*.${githubHost}`];
|
|
414
|
+
for (const host of copilotHosts) {
|
|
415
|
+
transformations.push({
|
|
416
|
+
match: { host },
|
|
417
|
+
transform: { headers },
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return transformations;
|
|
423
|
+
},
|
|
424
|
+
credentialForwarding: settings.credentialForwarding,
|
|
425
|
+
providerAuthentication: {
|
|
426
|
+
gateway: {
|
|
427
|
+
env: {
|
|
428
|
+
COPILOT_PROVIDER_BASE_URL: {
|
|
429
|
+
$source: 'gateway-base-url',
|
|
430
|
+
ensureSuffix: '/v1',
|
|
431
|
+
},
|
|
432
|
+
COPILOT_PROVIDER_TYPE: 'openai',
|
|
433
|
+
COPILOT_PROVIDER_API_KEY: {
|
|
434
|
+
$source: 'gateway-api-key',
|
|
435
|
+
},
|
|
436
|
+
COPILOT_PROVIDER_WIRE_API: 'responses',
|
|
437
|
+
COPILOT_MODEL: 'openai/gpt-5.5',
|
|
438
|
+
COPILOT_PROVIDER_HEADERS: {
|
|
439
|
+
$source: 'client-app',
|
|
440
|
+
prefix: 'x-client-app: ',
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
modelMapping: {
|
|
446
|
+
type: 'session-config-option',
|
|
447
|
+
path: 'model',
|
|
448
|
+
},
|
|
449
|
+
skillsDirectory: '.copilot/skills',
|
|
450
|
+
instructionMapping: {
|
|
451
|
+
type: 'filesystem',
|
|
452
|
+
path: '.copilot/copilot-instructions.md',
|
|
453
|
+
},
|
|
454
|
+
builtinTools: GITHUB_COPILOT_BUILTIN_TOOLS,
|
|
455
|
+
mcpServers: settings.mcpServers,
|
|
456
|
+
isMcpToolCall: toolCall =>
|
|
457
|
+
mcpToolTitlePrefixes.some(prefix => toolCall.title.startsWith(prefix)),
|
|
458
|
+
port: settings.port,
|
|
459
|
+
portEndpoint: settings.portEndpoint,
|
|
460
|
+
startupTimeoutMs: settings.startupTimeoutMs,
|
|
461
|
+
mintBridgeToken: settings.mintBridgeToken,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function normalizeGitHubHost(host: string): string {
|
|
466
|
+
return new URL(host.includes('://') ? host : `https://${host}`).hostname;
|
|
467
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createGitHubCopilot } from './github-copilot-harness';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default GitHub Copilot harness instance. Equivalent to
|
|
5
|
+
* `createGitHubCopilot()`.
|
|
6
|
+
*/
|
|
7
|
+
export const githubCopilot = createGitHubCopilot();
|
|
8
|
+
|
|
9
|
+
export { createGitHubCopilot } from './github-copilot-harness';
|
|
10
|
+
export type {
|
|
11
|
+
GitHubCopilotAuthenticationMode,
|
|
12
|
+
GitHubCopilotBuiltinTools,
|
|
13
|
+
GitHubCopilotHarnessSettings,
|
|
14
|
+
} from './github-copilot-harness';
|
|
15
|
+
export { VERSION } from './version';
|
package/src/version.ts
ADDED
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|