@ai-sdk/harness-opencode 1.0.93 → 1.0.95
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 +24 -0
- package/README.md +24 -0
- package/dist/bridge/index.mjs +51 -7
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/bridge/package.json +2 -2
- package/dist/bridge/pnpm-lock.yaml +59 -59
- package/dist/bridge/pnpm-workspace.yaml +1 -1
- package/dist/index.d.ts +13 -32
- package/dist/index.js +73 -103
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/bridge/index.ts +25 -3
- package/src/bridge/package.json +2 -2
- package/src/bridge/pnpm-lock.yaml +59 -59
- package/src/bridge/pnpm-workspace.yaml +1 -1
- package/src/index.ts +1 -4
- package/src/opencode-auth.ts +36 -129
- package/src/opencode-bridge-protocol.ts +2 -0
- package/src/opencode-harness.ts +58 -37
|
@@ -12,11 +12,11 @@ importers:
|
|
|
12
12
|
specifier: 1.29.0
|
|
13
13
|
version: 1.29.0(zod@3.25.76)
|
|
14
14
|
'@opencode-ai/sdk':
|
|
15
|
-
specifier: 1.18.
|
|
16
|
-
version: 1.18.
|
|
15
|
+
specifier: 1.18.23
|
|
16
|
+
version: 1.18.23
|
|
17
17
|
opencode-ai:
|
|
18
|
-
specifier: 1.18.
|
|
19
|
-
version: 1.18.
|
|
18
|
+
specifier: 1.18.23
|
|
19
|
+
version: 1.18.23
|
|
20
20
|
ws:
|
|
21
21
|
specifier: 8.21.0
|
|
22
22
|
version: 8.21.0
|
|
@@ -42,8 +42,8 @@ packages:
|
|
|
42
42
|
'@cfworker/json-schema':
|
|
43
43
|
optional: true
|
|
44
44
|
|
|
45
|
-
'@opencode-ai/sdk@1.18.
|
|
46
|
-
resolution: {integrity: sha512-
|
|
45
|
+
'@opencode-ai/sdk@1.18.23':
|
|
46
|
+
resolution: {integrity: sha512-VouYbL8O2ynLq0atr5fjzCv8YLtFi/zKLQ/uYkCvTJ4CmUdA01XwPn8om+u3TvxnGEfQsBfmThGU141vt3sg5w==}
|
|
47
47
|
|
|
48
48
|
accepts@2.0.0:
|
|
49
49
|
resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==}
|
|
@@ -286,72 +286,72 @@ packages:
|
|
|
286
286
|
once@1.4.0:
|
|
287
287
|
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
|
288
288
|
|
|
289
|
-
opencode-ai@1.18.
|
|
290
|
-
resolution: {integrity: sha512-
|
|
289
|
+
opencode-ai@1.18.23:
|
|
290
|
+
resolution: {integrity: sha512-3NkT0XINL7d0HYkTyGV1SPChHXhvRgKqNaTgKRTGb0TXUWszXA7MW/y3zMZw29y1AQuUDAzRvVYmQ9KGRQhroA==}
|
|
291
291
|
cpu: [arm64, x64]
|
|
292
292
|
os: [darwin, linux, win32]
|
|
293
293
|
hasBin: true
|
|
294
294
|
|
|
295
|
-
opencode-darwin-arm64@1.18.
|
|
296
|
-
resolution: {integrity: sha512-
|
|
295
|
+
opencode-darwin-arm64@1.18.23:
|
|
296
|
+
resolution: {integrity: sha512-QP9PjwpHtZoLVXw2WvUmPZecz7mWbQkT4t3K36B//fCaDG+zWa+SsztIeaW5azujNwwtUemLA5icE/zINng48Q==}
|
|
297
297
|
cpu: [arm64]
|
|
298
298
|
os: [darwin]
|
|
299
299
|
|
|
300
|
-
opencode-darwin-x64-baseline@1.18.
|
|
301
|
-
resolution: {integrity: sha512-
|
|
300
|
+
opencode-darwin-x64-baseline@1.18.23:
|
|
301
|
+
resolution: {integrity: sha512-QGx6I/nFYur7qJ/Nx2L3fC4XYQt44cyDsm7p8twNA+cdjGX3ndnPbMdAl5ikdZyAfSMUGYK8VWY2JMxv0rmfjw==}
|
|
302
302
|
cpu: [x64]
|
|
303
303
|
os: [darwin]
|
|
304
304
|
|
|
305
|
-
opencode-darwin-x64@1.18.
|
|
306
|
-
resolution: {integrity: sha512-
|
|
305
|
+
opencode-darwin-x64@1.18.23:
|
|
306
|
+
resolution: {integrity: sha512-R9nWP3edz/0FnEfwmuxtiWBB7bS4NtZCyCffJyiMlrbwdDC+bIXYrWxWXVrzaP1mJujs6g2MAwTCUSx/qpBhDw==}
|
|
307
307
|
cpu: [x64]
|
|
308
308
|
os: [darwin]
|
|
309
309
|
|
|
310
|
-
opencode-linux-arm64-musl@1.18.
|
|
311
|
-
resolution: {integrity: sha512-
|
|
310
|
+
opencode-linux-arm64-musl@1.18.23:
|
|
311
|
+
resolution: {integrity: sha512-VyDkzUJfJgkx9h9RhazTW9xeTgSXBmVFPblsbPGBW9tR612f6gjQxfOfu4cpHnQHK1qjuW9ClzLKHWqv3EcJTA==}
|
|
312
312
|
cpu: [arm64]
|
|
313
313
|
os: [linux]
|
|
314
314
|
libc: [musl]
|
|
315
315
|
|
|
316
|
-
opencode-linux-arm64@1.18.
|
|
317
|
-
resolution: {integrity: sha512-
|
|
316
|
+
opencode-linux-arm64@1.18.23:
|
|
317
|
+
resolution: {integrity: sha512-g1zDFhuE9FOYwjSGderlu69wfd4GQzS0xsDiIY11QUciuBmM6DrHqLvmhlLFsUVHYVnCPY1YeN1pq5ewE3x72Q==}
|
|
318
318
|
cpu: [arm64]
|
|
319
319
|
os: [linux]
|
|
320
320
|
|
|
321
|
-
opencode-linux-x64-baseline-musl@1.18.
|
|
322
|
-
resolution: {integrity: sha512-
|
|
321
|
+
opencode-linux-x64-baseline-musl@1.18.23:
|
|
322
|
+
resolution: {integrity: sha512-c1DPxauhzAurlIBhJBr/rokDpc65l084T4qTl36gDDT9Xzc/Nk5Q5yMDaPm1DDI3WeHKDt11MDlxT5AjQW5gtw==}
|
|
323
323
|
cpu: [x64]
|
|
324
324
|
os: [linux]
|
|
325
325
|
libc: [musl]
|
|
326
326
|
|
|
327
|
-
opencode-linux-x64-baseline@1.18.
|
|
328
|
-
resolution: {integrity: sha512-
|
|
327
|
+
opencode-linux-x64-baseline@1.18.23:
|
|
328
|
+
resolution: {integrity: sha512-yUhBOXfTQour2JCdAkwD3DDqSnyxB0grefwdPqEhYmJHIkYxfJIIzyy6V//pyouvkE0XMouFtiuZXw8S6Wo0iQ==}
|
|
329
329
|
cpu: [x64]
|
|
330
330
|
os: [linux]
|
|
331
331
|
|
|
332
|
-
opencode-linux-x64-musl@1.18.
|
|
333
|
-
resolution: {integrity: sha512-
|
|
332
|
+
opencode-linux-x64-musl@1.18.23:
|
|
333
|
+
resolution: {integrity: sha512-t/5mlnTBZKdZpqKHwdwxlWqGakntauvMSmXtyJc17M7XJRmZaaGHtNSaSefbbYFIL4agoQCXTvIkhhyxOvr7zQ==}
|
|
334
334
|
cpu: [x64]
|
|
335
335
|
os: [linux]
|
|
336
336
|
libc: [musl]
|
|
337
337
|
|
|
338
|
-
opencode-linux-x64@1.18.
|
|
339
|
-
resolution: {integrity: sha512-
|
|
338
|
+
opencode-linux-x64@1.18.23:
|
|
339
|
+
resolution: {integrity: sha512-5x9d1Cm/YtqzR6lAlNbgVprTQ3R3hx7qGTWCzm5l5u6lBNkhYTrhy2s8k25dxKKuxqZ9Kngqz9JYWvSVHy2Lmw==}
|
|
340
340
|
cpu: [x64]
|
|
341
341
|
os: [linux]
|
|
342
342
|
|
|
343
|
-
opencode-windows-arm64@1.18.
|
|
344
|
-
resolution: {integrity: sha512-
|
|
343
|
+
opencode-windows-arm64@1.18.23:
|
|
344
|
+
resolution: {integrity: sha512-QtJQcLU0yPz6on3jjks3f/EHgZuIDFw7FvAKu3wsHhL09NYDh7GczfRXDPRHa3NgqnU8dkB8p9mhqgaPRPogoQ==}
|
|
345
345
|
cpu: [arm64]
|
|
346
346
|
os: [win32]
|
|
347
347
|
|
|
348
|
-
opencode-windows-x64-baseline@1.18.
|
|
349
|
-
resolution: {integrity: sha512
|
|
348
|
+
opencode-windows-x64-baseline@1.18.23:
|
|
349
|
+
resolution: {integrity: sha512-AqXsTKaPcDx3rrid5bLUwJbQ/3vr9rJ6fvOStIznTzwrbOgP8wy5G4jCoIzu6KB/WxGx/d1MrV4cGaJ73qnjBA==}
|
|
350
350
|
cpu: [x64]
|
|
351
351
|
os: [win32]
|
|
352
352
|
|
|
353
|
-
opencode-windows-x64@1.18.
|
|
354
|
-
resolution: {integrity: sha512-
|
|
353
|
+
opencode-windows-x64@1.18.23:
|
|
354
|
+
resolution: {integrity: sha512-mMaIITuXzkNfjdcYL8uZaZuMDjulFyH/UCq9bxblam2mUZf9uWisoi5J6CXFsS/mkN7CZfTAt6PttSp4n3PH4g==}
|
|
355
355
|
cpu: [x64]
|
|
356
356
|
os: [win32]
|
|
357
357
|
|
|
@@ -508,7 +508,7 @@ snapshots:
|
|
|
508
508
|
transitivePeerDependencies:
|
|
509
509
|
- supports-color
|
|
510
510
|
|
|
511
|
-
'@opencode-ai/sdk@1.18.
|
|
511
|
+
'@opencode-ai/sdk@1.18.23':
|
|
512
512
|
dependencies:
|
|
513
513
|
cross-spawn: 7.0.6
|
|
514
514
|
|
|
@@ -752,55 +752,55 @@ snapshots:
|
|
|
752
752
|
dependencies:
|
|
753
753
|
wrappy: 1.0.2
|
|
754
754
|
|
|
755
|
-
opencode-ai@1.18.
|
|
755
|
+
opencode-ai@1.18.23:
|
|
756
756
|
optionalDependencies:
|
|
757
|
-
opencode-darwin-arm64: 1.18.
|
|
758
|
-
opencode-darwin-x64: 1.18.
|
|
759
|
-
opencode-darwin-x64-baseline: 1.18.
|
|
760
|
-
opencode-linux-arm64: 1.18.
|
|
761
|
-
opencode-linux-arm64-musl: 1.18.
|
|
762
|
-
opencode-linux-x64: 1.18.
|
|
763
|
-
opencode-linux-x64-baseline: 1.18.
|
|
764
|
-
opencode-linux-x64-baseline-musl: 1.18.
|
|
765
|
-
opencode-linux-x64-musl: 1.18.
|
|
766
|
-
opencode-windows-arm64: 1.18.
|
|
767
|
-
opencode-windows-x64: 1.18.
|
|
768
|
-
opencode-windows-x64-baseline: 1.18.
|
|
769
|
-
|
|
770
|
-
opencode-darwin-arm64@1.18.
|
|
757
|
+
opencode-darwin-arm64: 1.18.23
|
|
758
|
+
opencode-darwin-x64: 1.18.23
|
|
759
|
+
opencode-darwin-x64-baseline: 1.18.23
|
|
760
|
+
opencode-linux-arm64: 1.18.23
|
|
761
|
+
opencode-linux-arm64-musl: 1.18.23
|
|
762
|
+
opencode-linux-x64: 1.18.23
|
|
763
|
+
opencode-linux-x64-baseline: 1.18.23
|
|
764
|
+
opencode-linux-x64-baseline-musl: 1.18.23
|
|
765
|
+
opencode-linux-x64-musl: 1.18.23
|
|
766
|
+
opencode-windows-arm64: 1.18.23
|
|
767
|
+
opencode-windows-x64: 1.18.23
|
|
768
|
+
opencode-windows-x64-baseline: 1.18.23
|
|
769
|
+
|
|
770
|
+
opencode-darwin-arm64@1.18.23:
|
|
771
771
|
optional: true
|
|
772
772
|
|
|
773
|
-
opencode-darwin-x64-baseline@1.18.
|
|
773
|
+
opencode-darwin-x64-baseline@1.18.23:
|
|
774
774
|
optional: true
|
|
775
775
|
|
|
776
|
-
opencode-darwin-x64@1.18.
|
|
776
|
+
opencode-darwin-x64@1.18.23:
|
|
777
777
|
optional: true
|
|
778
778
|
|
|
779
|
-
opencode-linux-arm64-musl@1.18.
|
|
779
|
+
opencode-linux-arm64-musl@1.18.23:
|
|
780
780
|
optional: true
|
|
781
781
|
|
|
782
|
-
opencode-linux-arm64@1.18.
|
|
782
|
+
opencode-linux-arm64@1.18.23:
|
|
783
783
|
optional: true
|
|
784
784
|
|
|
785
|
-
opencode-linux-x64-baseline-musl@1.18.
|
|
785
|
+
opencode-linux-x64-baseline-musl@1.18.23:
|
|
786
786
|
optional: true
|
|
787
787
|
|
|
788
|
-
opencode-linux-x64-baseline@1.18.
|
|
788
|
+
opencode-linux-x64-baseline@1.18.23:
|
|
789
789
|
optional: true
|
|
790
790
|
|
|
791
|
-
opencode-linux-x64-musl@1.18.
|
|
791
|
+
opencode-linux-x64-musl@1.18.23:
|
|
792
792
|
optional: true
|
|
793
793
|
|
|
794
|
-
opencode-linux-x64@1.18.
|
|
794
|
+
opencode-linux-x64@1.18.23:
|
|
795
795
|
optional: true
|
|
796
796
|
|
|
797
|
-
opencode-windows-arm64@1.18.
|
|
797
|
+
opencode-windows-arm64@1.18.23:
|
|
798
798
|
optional: true
|
|
799
799
|
|
|
800
|
-
opencode-windows-x64-baseline@1.18.
|
|
800
|
+
opencode-windows-x64-baseline@1.18.23:
|
|
801
801
|
optional: true
|
|
802
802
|
|
|
803
|
-
opencode-windows-x64@1.18.
|
|
803
|
+
opencode-windows-x64@1.18.23:
|
|
804
804
|
optional: true
|
|
805
805
|
|
|
806
806
|
parseurl@1.3.3: {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
allowBuilds:
|
|
2
|
-
'opencode-ai@1.18.
|
|
2
|
+
'opencode-ai@1.18.23': true
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,4 @@ export const openCode = createOpenCode();
|
|
|
9
9
|
export { createOpenCode } from './opencode-harness';
|
|
10
10
|
export { VERSION } from './version';
|
|
11
11
|
export type { OpenCodeHarnessSettings } from './opencode-harness';
|
|
12
|
-
export type {
|
|
13
|
-
OpenCodeAuthenticationMode,
|
|
14
|
-
OpenCodeAuthOptions,
|
|
15
|
-
} from './opencode-auth';
|
|
12
|
+
export type { OpenCodeAuthenticationMode } from './opencode-auth';
|
package/src/opencode-auth.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
HarnessV1Authentication,
|
|
2
3
|
HarnessV1RequestTransformation,
|
|
3
4
|
HarnessV1RequestTransformationSources,
|
|
4
5
|
} from '@ai-sdk/harness';
|
|
5
6
|
import {
|
|
6
7
|
createCredentialRequestTransformation,
|
|
7
8
|
getAiGatewayAuthFromEnv,
|
|
9
|
+
isHarnessAuthenticationEnvironment,
|
|
8
10
|
} from '@ai-sdk/harness/utils';
|
|
9
11
|
|
|
10
12
|
export const OPENCODE_CREDENTIAL_ENVIRONMENT_VARIABLES = [
|
|
@@ -108,40 +110,9 @@ export type OpenCodeResolvedAuthenticationMode =
|
|
|
108
110
|
| 'openai'
|
|
109
111
|
| 'ai-gateway';
|
|
110
112
|
|
|
111
|
-
export type OpenCodeAuthenticationMode =
|
|
112
|
-
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @deprecated Passing an object to auth options is deprecated. Use an `OpenCodeAuthenticationMode` string value ("auto" | "anthropic" | "openai" | "ai-gateway") instead, and pass credentials via environment variables.
|
|
117
|
-
*/
|
|
118
|
-
export type LegacyOpenCodeAuthOptions = {
|
|
119
|
-
readonly gateway?: {
|
|
120
|
-
readonly apiKey?: string;
|
|
121
|
-
readonly baseUrl?: string;
|
|
122
|
-
};
|
|
123
|
-
readonly anthropic?: {
|
|
124
|
-
readonly apiKey?: string;
|
|
125
|
-
readonly authToken?: string;
|
|
126
|
-
readonly baseUrl?: string;
|
|
127
|
-
};
|
|
128
|
-
readonly openai?: {
|
|
129
|
-
readonly apiKey?: string;
|
|
130
|
-
readonly baseUrl?: string;
|
|
131
|
-
readonly organization?: string;
|
|
132
|
-
readonly project?: string;
|
|
133
|
-
};
|
|
134
|
-
readonly openaiCompatible?: {
|
|
135
|
-
readonly apiKey?: string;
|
|
136
|
-
readonly baseUrl?: string;
|
|
137
|
-
readonly name?: string;
|
|
138
|
-
readonly queryParams?: Record<string, string>;
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export type OpenCodeAuthOptions =
|
|
143
|
-
| OpenCodeAuthenticationMode
|
|
144
|
-
| LegacyOpenCodeAuthOptions;
|
|
113
|
+
export type OpenCodeAuthenticationMode = HarnessV1Authentication<
|
|
114
|
+
'anthropic' | 'openai'
|
|
115
|
+
>;
|
|
145
116
|
|
|
146
117
|
export function resolveOpenCodeProvider({
|
|
147
118
|
model,
|
|
@@ -188,37 +159,30 @@ export function resolveOpenCodeEnv({
|
|
|
188
159
|
provider,
|
|
189
160
|
processEnv = process.env,
|
|
190
161
|
}: {
|
|
191
|
-
auth:
|
|
162
|
+
auth: OpenCodeAuthenticationMode | undefined;
|
|
192
163
|
model?: string;
|
|
193
164
|
provider?: string;
|
|
194
165
|
processEnv?: Record<string, string | undefined>;
|
|
195
166
|
}): Record<string, string> {
|
|
196
|
-
const
|
|
167
|
+
const suppliedEnvironment = isHarnessAuthenticationEnvironment(auth);
|
|
168
|
+
const authenticationEnvironment = suppliedEnvironment ? auth : processEnv;
|
|
197
169
|
const selectedProvider = resolveOpenCodeProvider({ model, provider });
|
|
198
|
-
if (
|
|
199
|
-
return
|
|
170
|
+
if (selectedProvider === 'openai' && auth === 'openai') {
|
|
171
|
+
return pickOpenAI({ processEnv: authenticationEnvironment });
|
|
200
172
|
}
|
|
201
|
-
if (selectedProvider === '
|
|
202
|
-
|
|
203
|
-
return pickOpenAI({ explicit: normalizedAuth.openai, processEnv });
|
|
204
|
-
}
|
|
205
|
-
} else if (normalizedAuth?.anthropic) {
|
|
206
|
-
return pickAnthropic({ explicit: normalizedAuth.anthropic, processEnv });
|
|
173
|
+
if (selectedProvider === 'anthropic' && auth === 'anthropic') {
|
|
174
|
+
return pickAnthropic({ processEnv: authenticationEnvironment });
|
|
207
175
|
}
|
|
208
176
|
|
|
209
|
-
const gatewayAuthFromEnv = getAiGatewayAuthFromEnv({
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
if (gatewayAuthFromEnv.apiKey) {
|
|
217
|
-
return pickGateway({ explicit: {}, gatewayAuthFromEnv });
|
|
177
|
+
const gatewayAuthFromEnv = getAiGatewayAuthFromEnv({
|
|
178
|
+
env: authenticationEnvironment,
|
|
179
|
+
});
|
|
180
|
+
if (auth === 'ai-gateway' || gatewayAuthFromEnv.apiKey) {
|
|
181
|
+
return pickGateway({ gatewayAuthFromEnv });
|
|
218
182
|
}
|
|
219
183
|
return selectedProvider === 'openai'
|
|
220
|
-
? pickOpenAI({ processEnv })
|
|
221
|
-
: pickAnthropic({ processEnv });
|
|
184
|
+
? pickOpenAI({ processEnv: authenticationEnvironment })
|
|
185
|
+
: pickAnthropic({ processEnv: authenticationEnvironment });
|
|
222
186
|
}
|
|
223
187
|
|
|
224
188
|
export function resolveOpenCodeAuthenticationMode({
|
|
@@ -227,29 +191,24 @@ export function resolveOpenCodeAuthenticationMode({
|
|
|
227
191
|
provider,
|
|
228
192
|
processEnv = process.env,
|
|
229
193
|
}: {
|
|
230
|
-
auth:
|
|
194
|
+
auth: OpenCodeAuthenticationMode | undefined;
|
|
231
195
|
model?: string;
|
|
232
196
|
provider?: string;
|
|
233
197
|
processEnv?: Record<string, string | undefined>;
|
|
234
198
|
}): OpenCodeResolvedAuthenticationMode {
|
|
235
|
-
if (
|
|
236
|
-
return
|
|
199
|
+
if (isHarnessAuthenticationEnvironment(auth)) {
|
|
200
|
+
return getAiGatewayAuthFromEnv({ env: auth }).apiKey
|
|
201
|
+
? 'ai-gateway'
|
|
202
|
+
: resolveOpenCodeProvider({ model, provider });
|
|
237
203
|
}
|
|
238
|
-
|
|
239
204
|
const selectedProvider = resolveOpenCodeProvider({ model, provider });
|
|
240
|
-
if (
|
|
241
|
-
selectedProvider === 'openai' &&
|
|
242
|
-
(auth === 'openai' || (typeof auth !== 'string' && auth?.openai))
|
|
243
|
-
) {
|
|
205
|
+
if (selectedProvider === 'openai' && auth === 'openai') {
|
|
244
206
|
return 'openai';
|
|
245
207
|
}
|
|
246
|
-
if (
|
|
247
|
-
selectedProvider === 'anthropic' &&
|
|
248
|
-
(auth === 'anthropic' || (typeof auth !== 'string' && auth?.anthropic))
|
|
249
|
-
) {
|
|
208
|
+
if (selectedProvider === 'anthropic' && auth === 'anthropic') {
|
|
250
209
|
return 'anthropic';
|
|
251
210
|
}
|
|
252
|
-
if (auth === 'ai-gateway'
|
|
211
|
+
if (auth === 'ai-gateway') {
|
|
253
212
|
return 'ai-gateway';
|
|
254
213
|
}
|
|
255
214
|
if (getAiGatewayAuthFromEnv({ env: processEnv }).apiKey) {
|
|
@@ -258,99 +217,47 @@ export function resolveOpenCodeAuthenticationMode({
|
|
|
258
217
|
return selectedProvider;
|
|
259
218
|
}
|
|
260
219
|
|
|
261
|
-
function normalizeOpenCodeAuthToLegacyAuth(
|
|
262
|
-
auth: OpenCodeAuthOptions | undefined,
|
|
263
|
-
): LegacyOpenCodeAuthOptions | undefined {
|
|
264
|
-
if (auth == null || auth === 'auto') {
|
|
265
|
-
return undefined;
|
|
266
|
-
}
|
|
267
|
-
if (typeof auth === 'string') {
|
|
268
|
-
switch (auth) {
|
|
269
|
-
case 'anthropic':
|
|
270
|
-
return { anthropic: {} };
|
|
271
|
-
case 'openai':
|
|
272
|
-
return { openai: {} };
|
|
273
|
-
case 'ai-gateway':
|
|
274
|
-
return { gateway: {} };
|
|
275
|
-
default:
|
|
276
|
-
return undefined;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
console.warn(
|
|
281
|
-
'[opencode] Passing an object to auth options is deprecated. Use a string mode ("auto" | "anthropic" | "openai" | "ai-gateway") instead, and pass credentials via environment variables.',
|
|
282
|
-
);
|
|
283
|
-
return auth;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function pickOpenAICompatible(
|
|
287
|
-
explicit: NonNullable<LegacyOpenCodeAuthOptions['openaiCompatible']>,
|
|
288
|
-
processEnv: Record<string, string | undefined>,
|
|
289
|
-
): Record<string, string> {
|
|
290
|
-
const env: Record<string, string> = {};
|
|
291
|
-
const apiKey = explicit.apiKey ?? processEnv.OPENAI_API_KEY;
|
|
292
|
-
if (apiKey) env.OPENAI_API_KEY = apiKey;
|
|
293
|
-
const baseUrl = explicit.baseUrl ?? processEnv.OPENAI_BASE_URL;
|
|
294
|
-
if (baseUrl) env.OPENAI_BASE_URL = baseUrl;
|
|
295
|
-
const name = explicit.name ?? processEnv.OPENAI_NAME;
|
|
296
|
-
if (name) env.OPENAI_NAME = name;
|
|
297
|
-
if (explicit.queryParams && Object.keys(explicit.queryParams).length > 0) {
|
|
298
|
-
env.OPENAI_QUERY_PARAMS_JSON = JSON.stringify(explicit.queryParams);
|
|
299
|
-
} else if (processEnv.OPENAI_QUERY_PARAMS_JSON) {
|
|
300
|
-
env.OPENAI_QUERY_PARAMS_JSON = processEnv.OPENAI_QUERY_PARAMS_JSON;
|
|
301
|
-
}
|
|
302
|
-
return env;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
220
|
function pickOpenAI({
|
|
306
|
-
explicit,
|
|
307
221
|
processEnv,
|
|
308
222
|
}: {
|
|
309
|
-
explicit?: NonNullable<LegacyOpenCodeAuthOptions['openai']>;
|
|
310
223
|
processEnv: Record<string, string | undefined>;
|
|
311
224
|
}): Record<string, string> {
|
|
312
225
|
const env: Record<string, string> = {};
|
|
313
|
-
const apiKey =
|
|
226
|
+
const apiKey = processEnv.OPENAI_API_KEY;
|
|
314
227
|
if (apiKey) env.OPENAI_API_KEY = apiKey;
|
|
315
|
-
const baseUrl =
|
|
228
|
+
const baseUrl = processEnv.OPENAI_BASE_URL;
|
|
316
229
|
if (baseUrl) env.OPENAI_BASE_URL = baseUrl;
|
|
317
|
-
const organization =
|
|
230
|
+
const organization = processEnv.OPENAI_ORGANIZATION;
|
|
318
231
|
if (organization) env.OPENAI_ORGANIZATION = organization;
|
|
319
|
-
const project =
|
|
232
|
+
const project = processEnv.OPENAI_PROJECT;
|
|
320
233
|
if (project) env.OPENAI_PROJECT = project;
|
|
321
234
|
return env;
|
|
322
235
|
}
|
|
323
236
|
|
|
324
237
|
function pickAnthropic({
|
|
325
|
-
explicit,
|
|
326
238
|
processEnv,
|
|
327
239
|
}: {
|
|
328
|
-
explicit?: NonNullable<LegacyOpenCodeAuthOptions['anthropic']>;
|
|
329
240
|
processEnv: Record<string, string | undefined>;
|
|
330
241
|
}): Record<string, string> {
|
|
331
242
|
const env: Record<string, string> = {};
|
|
332
|
-
const apiKey =
|
|
243
|
+
const apiKey = processEnv.ANTHROPIC_API_KEY;
|
|
333
244
|
if (apiKey) env.ANTHROPIC_API_KEY = apiKey;
|
|
334
|
-
const authToken =
|
|
245
|
+
const authToken = processEnv.ANTHROPIC_AUTH_TOKEN;
|
|
335
246
|
if (authToken) env.ANTHROPIC_AUTH_TOKEN = authToken;
|
|
336
|
-
const baseUrl =
|
|
247
|
+
const baseUrl = processEnv.ANTHROPIC_BASE_URL;
|
|
337
248
|
if (baseUrl) env.ANTHROPIC_BASE_URL = baseUrl;
|
|
338
249
|
return env;
|
|
339
250
|
}
|
|
340
251
|
|
|
341
252
|
function pickGateway({
|
|
342
|
-
explicit,
|
|
343
253
|
gatewayAuthFromEnv,
|
|
344
254
|
}: {
|
|
345
|
-
explicit: NonNullable<LegacyOpenCodeAuthOptions['gateway']>;
|
|
346
255
|
gatewayAuthFromEnv: ReturnType<typeof getAiGatewayAuthFromEnv>;
|
|
347
256
|
}): Record<string, string> {
|
|
348
257
|
const env: Record<string, string> = {};
|
|
349
|
-
const apiKey =
|
|
258
|
+
const apiKey = gatewayAuthFromEnv.apiKey;
|
|
350
259
|
if (apiKey) env.AI_GATEWAY_API_KEY = apiKey;
|
|
351
|
-
const baseUrl = toOpenCodeGatewayBaseUrl(
|
|
352
|
-
explicit.baseUrl ?? gatewayAuthFromEnv.baseUrl,
|
|
353
|
-
);
|
|
260
|
+
const baseUrl = toOpenCodeGatewayBaseUrl(gatewayAuthFromEnv.baseUrl);
|
|
354
261
|
env.AI_GATEWAY_BASE_URL = baseUrl;
|
|
355
262
|
return env;
|
|
356
263
|
}
|
|
@@ -14,7 +14,9 @@ export const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
|
14
14
|
provider: z.string().optional(),
|
|
15
15
|
variant: z.string().optional(),
|
|
16
16
|
instructions: z.string().optional(),
|
|
17
|
+
skillsChanged: z.boolean().optional(),
|
|
17
18
|
resumeSessionId: z.string().optional(),
|
|
19
|
+
openCodeConfig: z.record(z.string(), z.unknown()).optional(),
|
|
18
20
|
mcpServers: z.record(z.string(), z.unknown()).optional(),
|
|
19
21
|
});
|
|
20
22
|
|