@ai-sdk/harness-opencode 1.0.177 → 1.0.178
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 +11 -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 +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bridge/index.ts +13 -0
- package/src/opencode-harness.ts +7 -1
- package/src/opencode-subscription.ts +26 -14
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ type OpenCodeHarnessSettings = {
|
|
|
39
39
|
*/
|
|
40
40
|
readonly portEndpoint?: HarnessV1PortEndpoint;
|
|
41
41
|
readonly startupTimeoutMs?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Abort a running turn when its host disconnects and does not reconnect
|
|
44
|
+
* within this many milliseconds, so the turn stops spending. A suspended
|
|
45
|
+
* turn is exempt. Unset keeps the turn running until it finishes.
|
|
46
|
+
*/
|
|
47
|
+
readonly hostDisconnectTimeoutMs?: number;
|
|
42
48
|
/**
|
|
43
49
|
* Configures reconnection attempts after an established bridge connection
|
|
44
50
|
* 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":";;;;;KAqNY,6BAA6B;;;KCvH7B;WACD,OAAO;;;;;;WAMP,uBAAuB;;;;;;WAMvB,iBAAiB;;;;;WAKjB,aAAa;WACb;;;;;;WAMA;WACA;;;;;WAKA,eAAe;WACf;;;;;;;WAOA,YAAY;;;;;WAKZ,kBAAkB;;cAKvB;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.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;;;;;;;;;wBA1hC30hB,eACd,WAAU,0BACT,iBAAiB;;;qBCrRP;;;;;;;qBCIA,oCAAQ;;;;;;;;;;;;;QAO+51D;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;QAA2C;;;;;;;;;;;;;;;UAAzP;UAAoC;;;YAAmE;YAAsC;;UAAiE;UAA2C;;;;;;;;;;;;;UAAzP;UAAoC;;;YAAmE;YAAsC;;UAAiE;UAA2C;;;;;;;;;UAA4K;;;;;;UAAgJ;;;;;;;;;;;;QAAhJ;;;;;;QAAgJ;;;;;;;;;;;;;;;;;;;UAArjB;UAAoC;;;YAAmE;YAAsC;;UAAiE;UAA2C"}
|
package/dist/index.js
CHANGED
|
@@ -448,6 +448,7 @@ async function resolveOpenCodeAuthentication({ auth, model, provider, processEnv
|
|
|
448
448
|
async function readOpenCodeSubscription({ providerId, env = process.env, homeDirectory = homedir(), platform = process.platform, fetch }) {
|
|
449
449
|
if (!isSubscriptionProvider(providerId)) return void 0;
|
|
450
450
|
const stored = await readStore({
|
|
451
|
+
providerId,
|
|
451
452
|
env,
|
|
452
453
|
homeDirectory,
|
|
453
454
|
platform
|
|
@@ -680,23 +681,26 @@ async function extractOpenAIAccountId(accessToken) {
|
|
|
680
681
|
const accountId = auth.chatgpt_account_id;
|
|
681
682
|
return typeof accountId === "string" ? accountId : void 0;
|
|
682
683
|
}
|
|
683
|
-
async function readStore({ env, homeDirectory, platform }) {
|
|
684
|
+
async function readStore({ providerId, env, homeDirectory, platform }) {
|
|
684
685
|
if (env.OPENCODE_AUTH_CONTENT != null) {
|
|
685
686
|
const parsed = await safeParseJSON({ text: env.OPENCODE_AUTH_CONTENT });
|
|
686
687
|
return parsed.success && isRecord(parsed.value) ? { value: parsed.value } : void 0;
|
|
687
688
|
}
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
value
|
|
698
|
-
|
|
699
|
-
|
|
689
|
+
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")] : []];
|
|
690
|
+
for (const authPath of authPaths) {
|
|
691
|
+
const text = await readFile(authPath, "utf8").catch(() => void 0);
|
|
692
|
+
if (text == null) continue;
|
|
693
|
+
const parsed = await safeParseJSON({ text });
|
|
694
|
+
if (!parsed.success || !isRecord(parsed.value)) continue;
|
|
695
|
+
if (!isRecord(parsed.value[providerId])) continue;
|
|
696
|
+
return {
|
|
697
|
+
value: parsed.value,
|
|
698
|
+
write: (value) => writeStore({
|
|
699
|
+
authPath,
|
|
700
|
+
value
|
|
701
|
+
})
|
|
702
|
+
};
|
|
703
|
+
}
|
|
700
704
|
}
|
|
701
705
|
async function writeStore({ authPath, value }) {
|
|
702
706
|
await mkdir(dirname(authPath), { recursive: true });
|
|
@@ -742,7 +746,7 @@ const startMessageSchema = harnessV1BridgeStartBaseSchema.omit({ builtinToolFilt
|
|
|
742
746
|
z.discriminatedUnion("type", [startMessageSchema, ...harnessV1BridgeInboundCommandSchemas]);
|
|
743
747
|
//#endregion
|
|
744
748
|
//#region src/version.ts
|
|
745
|
-
const VERSION = "1.0.
|
|
749
|
+
const VERSION = "1.0.178";
|
|
746
750
|
//#endregion
|
|
747
751
|
//#region src/opencode-harness.ts
|
|
748
752
|
/**
|
|
@@ -1058,7 +1062,7 @@ function createOpenCode(settings = {}) {
|
|
|
1058
1062
|
abortSignal: startOpts.abortSignal
|
|
1059
1063
|
});
|
|
1060
1064
|
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)}`,
|
|
1065
|
+
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
1066
|
env,
|
|
1063
1067
|
abortSignal: startOpts.abortSignal
|
|
1064
1068
|
});
|