@ai-sdk/harness-opencode 1.0.177 → 1.0.179
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/dist/bridge/host-tool-mcp.mjs.map +1 -1
- package/dist/bridge/index.mjs +24 -2
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/bridge/index.ts +13 -0
- package/src/opencode-auth.ts +10 -1
- package/src/opencode-harness.ts +7 -1
- package/src/opencode-subscription.ts +26 -14
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,12 @@ import { SandboxChannelReconnectOptions } from "@ai-sdk/harness/utils";
|
|
|
3
3
|
import { Experimental_SandboxSession } from "@ai-sdk/provider-utils";
|
|
4
4
|
import { JSONObject } from "@ai-sdk/provider";
|
|
5
5
|
//#region src/opencode-auth.d.ts
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* OpenCode auth options. `direct` uses the selected provider's own
|
|
8
|
+
* credentials (environment variables, then a native OpenCode subscription)
|
|
9
|
+
* and ignores AI Gateway credentials such as `VERCEL_OIDC_TOKEN`.
|
|
10
|
+
*/
|
|
11
|
+
type OpenCodeAuthenticationMode = HarnessV1Authentication<'direct' | 'anthropic' | 'openai'>;
|
|
7
12
|
//#endregion
|
|
8
13
|
//#region src/opencode-harness.d.ts
|
|
9
14
|
type OpenCodeHarnessSettings = {
|
|
@@ -39,6 +44,12 @@ type OpenCodeHarnessSettings = {
|
|
|
39
44
|
*/
|
|
40
45
|
readonly portEndpoint?: HarnessV1PortEndpoint;
|
|
41
46
|
readonly startupTimeoutMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Abort a running turn when its host disconnects and does not reconnect
|
|
49
|
+
* within this many milliseconds, so the turn stops spending. A suspended
|
|
50
|
+
* turn is exempt. Unset keeps the turn running until it finishes.
|
|
51
|
+
*/
|
|
52
|
+
readonly hostDisconnectTimeoutMs?: number;
|
|
42
53
|
/**
|
|
43
54
|
* Configures reconnection attempts after an established bridge connection
|
|
44
55
|
* drops. The reconnect window includes connection establishment and
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["SandboxSession"],"sources":["../src/opencode-auth.ts","../src/opencode-harness.ts","../src/version.ts","../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["SandboxSession"],"sources":["../src/opencode-auth.ts","../src/opencode-harness.ts","../src/version.ts","../src/index.ts"],"mappings":";;;;;;;;;;KA0NY,6BAA6B;;;KC5H7B;WACD,OAAO;;;;;;WAMP,uBAAuB;;;;;;WAMvB,iBAAiB;;;;;WAKjB,aAAa;WACb;;;;;;WAMA;WACA;;;;;WAKA,eAAe;WACf;;;;;;WAMA;;;;;;;WAOA,YAAY;;;;;WAKZ,kBAAkB;;cAKvB;;;;;;;;;;;;;QA0pC4lhB;QAAoC;;;UAAmE;UAAsC;;QAAiE;QAA2C;;;;;;;;;;;QAAzP;QAAoC;;;UAAmE;UAAsC;;QAAiE;QAA2C;;;;;;;;;;;;;;;UAAzP;UAAoC;;;YAAmE;YAAsC;;UAAiE;UAA2C;;;;;;;;;;;;;UAAzP;UAAoC;;;YAAmE;YAAsC;;UAAiE;UAA2C;;;;;;;;;UAA4K;;;;;;UAAgJ;;;;;;;;;;;;QAAhJ;;;;;;QAAgJ;;;;;;;;;;;;QAArjB;QAAoC;;;UAAmE;UAAsC;;QAAiE;QAA2C;;;;;;;;QAA4K;;;;;;QAAgJ;;;;;;;;;;;;;;;;;;UAArjB;UAAoC;;;YAAmE;YAAsC;;UAAiE;UAA2C;;;;;;;;;;;;;;;;;;;;;;;QAAzP;QAAoC;;;UAAmE;UAAsC;;QAAiE;QAA2C;;;;;;;;;;;QAAzP;QAAoC;;;UAAmE;UAAsC;;QAAiE;QA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;;;;;;;;;UAArjB;UAAoC;;;YAAmE;YAAsC;;UAAiE;UAA2C"}
|
package/dist/index.js
CHANGED
|
@@ -178,7 +178,7 @@ function resolveOpenCodeEnv({ auth, model, provider, processEnv = process.env })
|
|
|
178
178
|
provider,
|
|
179
179
|
environment: authenticationEnvironment
|
|
180
180
|
});
|
|
181
|
-
if (selectedProvider === "openai" && auth === "openai" || selectedProvider === "anthropic" && auth === "anthropic") return pickDirectProvider({
|
|
181
|
+
if (auth === "direct" || selectedProvider === "openai" && auth === "openai" || selectedProvider === "anthropic" && auth === "anthropic") return pickDirectProvider({
|
|
182
182
|
provider: selectedProvider,
|
|
183
183
|
processEnv: authenticationEnvironment
|
|
184
184
|
});
|
|
@@ -202,6 +202,7 @@ function resolveOpenCodeAuthenticationMode({ auth, model, provider, processEnv =
|
|
|
202
202
|
provider,
|
|
203
203
|
environment: processEnv
|
|
204
204
|
});
|
|
205
|
+
if (auth === "direct") return selectedProvider;
|
|
205
206
|
if (selectedProvider === "openai" && auth === "openai") return "openai";
|
|
206
207
|
if (selectedProvider === "anthropic" && auth === "anthropic") return "anthropic";
|
|
207
208
|
if (auth === "ai-gateway") return "ai-gateway";
|
|
@@ -448,6 +449,7 @@ async function resolveOpenCodeAuthentication({ auth, model, provider, processEnv
|
|
|
448
449
|
async function readOpenCodeSubscription({ providerId, env = process.env, homeDirectory = homedir(), platform = process.platform, fetch }) {
|
|
449
450
|
if (!isSubscriptionProvider(providerId)) return void 0;
|
|
450
451
|
const stored = await readStore({
|
|
452
|
+
providerId,
|
|
451
453
|
env,
|
|
452
454
|
homeDirectory,
|
|
453
455
|
platform
|
|
@@ -680,23 +682,26 @@ async function extractOpenAIAccountId(accessToken) {
|
|
|
680
682
|
const accountId = auth.chatgpt_account_id;
|
|
681
683
|
return typeof accountId === "string" ? accountId : void 0;
|
|
682
684
|
}
|
|
683
|
-
async function readStore({ env, homeDirectory, platform }) {
|
|
685
|
+
async function readStore({ providerId, env, homeDirectory, platform }) {
|
|
684
686
|
if (env.OPENCODE_AUTH_CONTENT != null) {
|
|
685
687
|
const parsed = await safeParseJSON({ text: env.OPENCODE_AUTH_CONTENT });
|
|
686
688
|
return parsed.success && isRecord(parsed.value) ? { value: parsed.value } : void 0;
|
|
687
689
|
}
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
value
|
|
698
|
-
|
|
699
|
-
|
|
690
|
+
const authPaths = env.XDG_DATA_HOME != null ? [join(env.XDG_DATA_HOME, "opencode", "auth.json")] : [join(homeDirectory, ".local", "share", "opencode", "auth.json"), ...isWindows(platform) ? [join(homeDirectory, ".opencode", "auth.json")] : []];
|
|
691
|
+
for (const authPath of authPaths) {
|
|
692
|
+
const text = await readFile(authPath, "utf8").catch(() => void 0);
|
|
693
|
+
if (text == null) continue;
|
|
694
|
+
const parsed = await safeParseJSON({ text });
|
|
695
|
+
if (!parsed.success || !isRecord(parsed.value)) continue;
|
|
696
|
+
if (!isRecord(parsed.value[providerId])) continue;
|
|
697
|
+
return {
|
|
698
|
+
value: parsed.value,
|
|
699
|
+
write: (value) => writeStore({
|
|
700
|
+
authPath,
|
|
701
|
+
value
|
|
702
|
+
})
|
|
703
|
+
};
|
|
704
|
+
}
|
|
700
705
|
}
|
|
701
706
|
async function writeStore({ authPath, value }) {
|
|
702
707
|
await mkdir(dirname(authPath), { recursive: true });
|
|
@@ -742,7 +747,7 @@ const startMessageSchema = harnessV1BridgeStartBaseSchema.omit({ builtinToolFilt
|
|
|
742
747
|
z.discriminatedUnion("type", [startMessageSchema, ...harnessV1BridgeInboundCommandSchemas]);
|
|
743
748
|
//#endregion
|
|
744
749
|
//#region src/version.ts
|
|
745
|
-
const VERSION = "1.0.
|
|
750
|
+
const VERSION = "1.0.179";
|
|
746
751
|
//#endregion
|
|
747
752
|
//#region src/opencode-harness.ts
|
|
748
753
|
/**
|
|
@@ -1058,7 +1063,7 @@ function createOpenCode(settings = {}) {
|
|
|
1058
1063
|
abortSignal: startOpts.abortSignal
|
|
1059
1064
|
});
|
|
1060
1065
|
const proc = await toolSafeSandboxSession.spawn({
|
|
1061
|
-
command: `node ${shellQuote(`${bootstrapDir}/bridge.mjs`)} --workdir ${shellQuote(workDir)} --bridge-state-dir ${shellQuote(bridgeStateDir)} --bootstrap-dir ${shellQuote(bootstrapDir)} --skills-dir ${shellQuote(skillsDir)}`,
|
|
1066
|
+
command: `node ${shellQuote(`${bootstrapDir}/bridge.mjs`)} --workdir ${shellQuote(workDir)} --bridge-state-dir ${shellQuote(bridgeStateDir)} --bootstrap-dir ${shellQuote(bootstrapDir)} --skills-dir ${shellQuote(skillsDir)}${settings.hostDisconnectTimeoutMs !== void 0 ? ` --host-disconnect-timeout-ms ${shellQuote(String(settings.hostDisconnectTimeoutMs))}` : ""}`,
|
|
1062
1067
|
env,
|
|
1063
1068
|
abortSignal: startOpts.abortSignal
|
|
1064
1069
|
});
|