@get-bb/plugin-sdk 0.6.60 → 0.6.65
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/bundled-types/bb-plugin-sdk-app.d.ts +341 -83
- package/bundled-types/bb-plugin-sdk-host.d.ts +196 -214
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +17 -7
- package/bundled-types/bb-plugin-sdk-internal-rpc-query-host.d.ts +192 -0
- package/bundled-types/bb-plugin-sdk-internal-rpc-tags.d.ts +23 -0
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +7 -2
- package/bundled-types/bb-plugin-sdk-testing.d.ts +12 -4
- package/bundled-types/bb-plugin-sdk.d.ts +392 -109
- package/dist/app.js +98 -0
- package/dist/host.js +12 -0
- package/dist/index.js +81 -0
- package/dist/internal/host-policy.js +33 -1
- package/dist/internal/plugin-app-collector.js +16 -0
- package/dist/internal/rpc-query-host.js +922 -0
- package/dist/internal/rpc-tags.js +18 -0
- package/dist/provider-bridge-acp-next.js +37 -26
- package/dist/provider-bridge-acp.js +37 -26
- package/dist/provider-bridge.js +21 -20
- package/dist/replay-provider-child.mjs +6 -2
- package/dist/testing/app.js +1128 -100
- package/dist/testing/index.js +247 -104
- package/package.json +16 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/internal/rpc-tags.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var rpcInvalidationTags = z.array(z.string().min(1)).min(1);
|
|
4
|
+
function rpcResponseTags(declarations, input, output) {
|
|
5
|
+
const tags = z.array(z.string().min(1)).parse(declarations.tags?.(input, output) ?? []);
|
|
6
|
+
const keyTags = {};
|
|
7
|
+
if (declarations.keyTags && typeof output === "object" && output !== null && !Array.isArray(output)) {
|
|
8
|
+
for (const [key, value] of Object.entries(output)) {
|
|
9
|
+
keyTags[key] = z.array(z.string().min(1)).parse(declarations.keyTags(key, value));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const invalidated = z.array(z.string().min(1)).parse(declarations.invalidates?.(input, output) ?? []);
|
|
13
|
+
return { tags, keyTags, invalidated };
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
rpcInvalidationTags,
|
|
17
|
+
rpcResponseTags
|
|
18
|
+
};
|
|
@@ -11663,6 +11663,18 @@ function whichCommandSync(command, options = {}) {
|
|
|
11663
11663
|
}
|
|
11664
11664
|
|
|
11665
11665
|
// ../process-utils/src/exec-portable-file.ts
|
|
11666
|
+
function resolvePortableCommand(command, options) {
|
|
11667
|
+
const envKeys = Object.keys(options.env).sort();
|
|
11668
|
+
const pathKey2 = envKeys.find((key) => key.toUpperCase() === "PATH");
|
|
11669
|
+
const pathExtKey = envKeys.find((key) => key.toUpperCase() === "PATHEXT");
|
|
11670
|
+
const commandExtension = extname2(command);
|
|
11671
|
+
const pathExt = options.env[pathExtKey ?? "PATHEXT"];
|
|
11672
|
+
return whichCommandSync(command, {
|
|
11673
|
+
cwd: options.cwd,
|
|
11674
|
+
path: options.env[pathKey2 ?? "PATH"],
|
|
11675
|
+
pathExt: commandExtension ? `${commandExtension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
|
|
11676
|
+
});
|
|
11677
|
+
}
|
|
11666
11678
|
async function execPortableFile(command, args, options) {
|
|
11667
11679
|
const executable = basename(command).toLowerCase().replace(/\.(exe|cmd|bat)$/u, "");
|
|
11668
11680
|
if (executable === "git" || executable === "gh") {
|
|
@@ -11680,26 +11692,15 @@ async function execPortableFile(command, args, options) {
|
|
|
11680
11692
|
}
|
|
11681
11693
|
async function execPortableFileUnbounded(command, args, options) {
|
|
11682
11694
|
if (options.signal?.aborted) throw options.signal.reason;
|
|
11683
|
-
if (process.platform === "win32") {
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
pathExt: commandExtension ? `${commandExtension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
|
|
11693
|
-
}) === void 0) {
|
|
11694
|
-
throw Object.assign(new Error(`spawn ${command} ENOENT`), {
|
|
11695
|
-
code: "ENOENT",
|
|
11696
|
-
syscall: `spawn ${command}`,
|
|
11697
|
-
stdout: "",
|
|
11698
|
-
stderr: "",
|
|
11699
|
-
signal: null,
|
|
11700
|
-
killed: false
|
|
11701
|
-
});
|
|
11702
|
-
}
|
|
11695
|
+
if (process.platform === "win32" && resolvePortableCommand(command, options) === void 0) {
|
|
11696
|
+
throw Object.assign(new Error(`spawn ${command} ENOENT`), {
|
|
11697
|
+
code: "ENOENT",
|
|
11698
|
+
syscall: `spawn ${command}`,
|
|
11699
|
+
stdout: "",
|
|
11700
|
+
stderr: "",
|
|
11701
|
+
signal: null,
|
|
11702
|
+
killed: false
|
|
11703
|
+
});
|
|
11703
11704
|
}
|
|
11704
11705
|
const subprocess = execa(command, args, {
|
|
11705
11706
|
cwd: options.cwd,
|
|
@@ -12365,6 +12366,7 @@ var storedOAuthSchema = z38.object({
|
|
|
12365
12366
|
orgID: z38.string().min(1)
|
|
12366
12367
|
})
|
|
12367
12368
|
});
|
|
12369
|
+
var OPENCODE_2_CREDENTIAL_IMPORT_MIGRATION = "20260805200742_import_legacy_credentials";
|
|
12368
12370
|
function isOfficialConsole(url2) {
|
|
12369
12371
|
const issuer = new URL(url2);
|
|
12370
12372
|
return issuer.origin === "https://opencode.ai" && ["/", "/console", "/console/"].includes(issuer.pathname);
|
|
@@ -12419,7 +12421,7 @@ function readStoredCredential(database) {
|
|
|
12419
12421
|
).get();
|
|
12420
12422
|
if (!table) return null;
|
|
12421
12423
|
const query = database.prepare(
|
|
12422
|
-
"SELECT value FROM credential WHERE integration_id = ?
|
|
12424
|
+
"SELECT value FROM credential WHERE integration_id = ? ORDER BY active DESC, time_created DESC, id DESC LIMIT 1"
|
|
12423
12425
|
);
|
|
12424
12426
|
for (const provider of ["opencode-go", "opencode"]) {
|
|
12425
12427
|
const row = query.get(provider);
|
|
@@ -12447,6 +12449,13 @@ function readStoredCredential(database) {
|
|
|
12447
12449
|
}
|
|
12448
12450
|
return null;
|
|
12449
12451
|
}
|
|
12452
|
+
function isOpenCode2Database(database) {
|
|
12453
|
+
const table = database.prepare(
|
|
12454
|
+
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'migration'"
|
|
12455
|
+
).get();
|
|
12456
|
+
if (!table) return false;
|
|
12457
|
+
return database.prepare("SELECT id FROM migration WHERE id = ?").get(OPENCODE_2_CREDENTIAL_IMPORT_MIGRATION) !== void 0;
|
|
12458
|
+
}
|
|
12450
12459
|
async function readLegacyApiKey(env) {
|
|
12451
12460
|
let content = env.OPENCODE_AUTH_CONTENT;
|
|
12452
12461
|
if (content) {
|
|
@@ -12487,25 +12496,27 @@ async function readOpenCodeGoUsage(env) {
|
|
|
12487
12496
|
});
|
|
12488
12497
|
let apiKey;
|
|
12489
12498
|
let account = null;
|
|
12499
|
+
let openCode2 = false;
|
|
12490
12500
|
try {
|
|
12491
12501
|
apiKey = env.OPENCODE_API_KEY?.trim() || null;
|
|
12492
12502
|
if (apiKey === null) {
|
|
12493
12503
|
const database = await openDatabase(env);
|
|
12494
12504
|
if (database) {
|
|
12495
12505
|
try {
|
|
12496
|
-
|
|
12497
|
-
if (
|
|
12498
|
-
apiKey = account.access_token;
|
|
12499
|
-
} else {
|
|
12506
|
+
openCode2 = isOpenCode2Database(database);
|
|
12507
|
+
if (openCode2) {
|
|
12500
12508
|
const stored = readStoredCredential(database);
|
|
12501
12509
|
apiKey = stored?.apiKey ?? null;
|
|
12502
12510
|
account = stored?.account ?? null;
|
|
12511
|
+
} else {
|
|
12512
|
+
account = readAccount(database);
|
|
12513
|
+
apiKey = account?.access_token ?? null;
|
|
12503
12514
|
}
|
|
12504
12515
|
} finally {
|
|
12505
12516
|
database.close();
|
|
12506
12517
|
}
|
|
12507
12518
|
}
|
|
12508
|
-
apiKey ??= await readLegacyApiKey(env);
|
|
12519
|
+
if (!openCode2) apiKey ??= await readLegacyApiKey(env);
|
|
12509
12520
|
}
|
|
12510
12521
|
} catch {
|
|
12511
12522
|
return failure("OpenCode credentials could not be read.");
|
|
@@ -11663,6 +11663,18 @@ function whichCommandSync(command, options = {}) {
|
|
|
11663
11663
|
}
|
|
11664
11664
|
|
|
11665
11665
|
// ../process-utils/src/exec-portable-file.ts
|
|
11666
|
+
function resolvePortableCommand(command, options) {
|
|
11667
|
+
const envKeys = Object.keys(options.env).sort();
|
|
11668
|
+
const pathKey2 = envKeys.find((key) => key.toUpperCase() === "PATH");
|
|
11669
|
+
const pathExtKey = envKeys.find((key) => key.toUpperCase() === "PATHEXT");
|
|
11670
|
+
const commandExtension = extname2(command);
|
|
11671
|
+
const pathExt = options.env[pathExtKey ?? "PATHEXT"];
|
|
11672
|
+
return whichCommandSync(command, {
|
|
11673
|
+
cwd: options.cwd,
|
|
11674
|
+
path: options.env[pathKey2 ?? "PATH"],
|
|
11675
|
+
pathExt: commandExtension ? `${commandExtension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
|
|
11676
|
+
});
|
|
11677
|
+
}
|
|
11666
11678
|
async function execPortableFile(command, args, options) {
|
|
11667
11679
|
const executable = basename(command).toLowerCase().replace(/\.(exe|cmd|bat)$/u, "");
|
|
11668
11680
|
if (executable === "git" || executable === "gh") {
|
|
@@ -11680,26 +11692,15 @@ async function execPortableFile(command, args, options) {
|
|
|
11680
11692
|
}
|
|
11681
11693
|
async function execPortableFileUnbounded(command, args, options) {
|
|
11682
11694
|
if (options.signal?.aborted) throw options.signal.reason;
|
|
11683
|
-
if (process.platform === "win32") {
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
pathExt: commandExtension ? `${commandExtension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
|
|
11693
|
-
}) === void 0) {
|
|
11694
|
-
throw Object.assign(new Error(`spawn ${command} ENOENT`), {
|
|
11695
|
-
code: "ENOENT",
|
|
11696
|
-
syscall: `spawn ${command}`,
|
|
11697
|
-
stdout: "",
|
|
11698
|
-
stderr: "",
|
|
11699
|
-
signal: null,
|
|
11700
|
-
killed: false
|
|
11701
|
-
});
|
|
11702
|
-
}
|
|
11695
|
+
if (process.platform === "win32" && resolvePortableCommand(command, options) === void 0) {
|
|
11696
|
+
throw Object.assign(new Error(`spawn ${command} ENOENT`), {
|
|
11697
|
+
code: "ENOENT",
|
|
11698
|
+
syscall: `spawn ${command}`,
|
|
11699
|
+
stdout: "",
|
|
11700
|
+
stderr: "",
|
|
11701
|
+
signal: null,
|
|
11702
|
+
killed: false
|
|
11703
|
+
});
|
|
11703
11704
|
}
|
|
11704
11705
|
const subprocess = execa(command, args, {
|
|
11705
11706
|
cwd: options.cwd,
|
|
@@ -12365,6 +12366,7 @@ var storedOAuthSchema = z38.object({
|
|
|
12365
12366
|
orgID: z38.string().min(1)
|
|
12366
12367
|
})
|
|
12367
12368
|
});
|
|
12369
|
+
var OPENCODE_2_CREDENTIAL_IMPORT_MIGRATION = "20260805200742_import_legacy_credentials";
|
|
12368
12370
|
function isOfficialConsole(url2) {
|
|
12369
12371
|
const issuer = new URL(url2);
|
|
12370
12372
|
return issuer.origin === "https://opencode.ai" && ["/", "/console", "/console/"].includes(issuer.pathname);
|
|
@@ -12419,7 +12421,7 @@ function readStoredCredential(database) {
|
|
|
12419
12421
|
).get();
|
|
12420
12422
|
if (!table) return null;
|
|
12421
12423
|
const query = database.prepare(
|
|
12422
|
-
"SELECT value FROM credential WHERE integration_id = ?
|
|
12424
|
+
"SELECT value FROM credential WHERE integration_id = ? ORDER BY active DESC, time_created DESC, id DESC LIMIT 1"
|
|
12423
12425
|
);
|
|
12424
12426
|
for (const provider of ["opencode-go", "opencode"]) {
|
|
12425
12427
|
const row = query.get(provider);
|
|
@@ -12447,6 +12449,13 @@ function readStoredCredential(database) {
|
|
|
12447
12449
|
}
|
|
12448
12450
|
return null;
|
|
12449
12451
|
}
|
|
12452
|
+
function isOpenCode2Database(database) {
|
|
12453
|
+
const table = database.prepare(
|
|
12454
|
+
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'migration'"
|
|
12455
|
+
).get();
|
|
12456
|
+
if (!table) return false;
|
|
12457
|
+
return database.prepare("SELECT id FROM migration WHERE id = ?").get(OPENCODE_2_CREDENTIAL_IMPORT_MIGRATION) !== void 0;
|
|
12458
|
+
}
|
|
12450
12459
|
async function readLegacyApiKey(env) {
|
|
12451
12460
|
let content = env.OPENCODE_AUTH_CONTENT;
|
|
12452
12461
|
if (content) {
|
|
@@ -12487,25 +12496,27 @@ async function readOpenCodeGoUsage(env) {
|
|
|
12487
12496
|
});
|
|
12488
12497
|
let apiKey;
|
|
12489
12498
|
let account = null;
|
|
12499
|
+
let openCode2 = false;
|
|
12490
12500
|
try {
|
|
12491
12501
|
apiKey = env.OPENCODE_API_KEY?.trim() || null;
|
|
12492
12502
|
if (apiKey === null) {
|
|
12493
12503
|
const database = await openDatabase(env);
|
|
12494
12504
|
if (database) {
|
|
12495
12505
|
try {
|
|
12496
|
-
|
|
12497
|
-
if (
|
|
12498
|
-
apiKey = account.access_token;
|
|
12499
|
-
} else {
|
|
12506
|
+
openCode2 = isOpenCode2Database(database);
|
|
12507
|
+
if (openCode2) {
|
|
12500
12508
|
const stored = readStoredCredential(database);
|
|
12501
12509
|
apiKey = stored?.apiKey ?? null;
|
|
12502
12510
|
account = stored?.account ?? null;
|
|
12511
|
+
} else {
|
|
12512
|
+
account = readAccount(database);
|
|
12513
|
+
apiKey = account?.access_token ?? null;
|
|
12503
12514
|
}
|
|
12504
12515
|
} finally {
|
|
12505
12516
|
database.close();
|
|
12506
12517
|
}
|
|
12507
12518
|
}
|
|
12508
|
-
apiKey ??= await readLegacyApiKey(env);
|
|
12519
|
+
if (!openCode2) apiKey ??= await readLegacyApiKey(env);
|
|
12509
12520
|
}
|
|
12510
12521
|
} catch {
|
|
12511
12522
|
return failure("OpenCode credentials could not be read.");
|
package/dist/provider-bridge.js
CHANGED
|
@@ -11183,6 +11183,18 @@ function whichCommandSync(command, options = {}) {
|
|
|
11183
11183
|
}
|
|
11184
11184
|
|
|
11185
11185
|
// ../process-utils/src/exec-portable-file.ts
|
|
11186
|
+
function resolvePortableCommand(command, options) {
|
|
11187
|
+
const envKeys = Object.keys(options.env).sort();
|
|
11188
|
+
const pathKey2 = envKeys.find((key) => key.toUpperCase() === "PATH");
|
|
11189
|
+
const pathExtKey = envKeys.find((key) => key.toUpperCase() === "PATHEXT");
|
|
11190
|
+
const commandExtension = extname2(command);
|
|
11191
|
+
const pathExt = options.env[pathExtKey ?? "PATHEXT"];
|
|
11192
|
+
return whichCommandSync(command, {
|
|
11193
|
+
cwd: options.cwd,
|
|
11194
|
+
path: options.env[pathKey2 ?? "PATH"],
|
|
11195
|
+
pathExt: commandExtension ? `${commandExtension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
|
|
11196
|
+
});
|
|
11197
|
+
}
|
|
11186
11198
|
async function execPortableFile(command, args, options) {
|
|
11187
11199
|
const executable = basename(command).toLowerCase().replace(/\.(exe|cmd|bat)$/u, "");
|
|
11188
11200
|
if (executable === "git" || executable === "gh") {
|
|
@@ -11200,26 +11212,15 @@ async function execPortableFile(command, args, options) {
|
|
|
11200
11212
|
}
|
|
11201
11213
|
async function execPortableFileUnbounded(command, args, options) {
|
|
11202
11214
|
if (options.signal?.aborted) throw options.signal.reason;
|
|
11203
|
-
if (process.platform === "win32") {
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
pathExt: commandExtension ? `${commandExtension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
|
|
11213
|
-
}) === void 0) {
|
|
11214
|
-
throw Object.assign(new Error(`spawn ${command} ENOENT`), {
|
|
11215
|
-
code: "ENOENT",
|
|
11216
|
-
syscall: `spawn ${command}`,
|
|
11217
|
-
stdout: "",
|
|
11218
|
-
stderr: "",
|
|
11219
|
-
signal: null,
|
|
11220
|
-
killed: false
|
|
11221
|
-
});
|
|
11222
|
-
}
|
|
11215
|
+
if (process.platform === "win32" && resolvePortableCommand(command, options) === void 0) {
|
|
11216
|
+
throw Object.assign(new Error(`spawn ${command} ENOENT`), {
|
|
11217
|
+
code: "ENOENT",
|
|
11218
|
+
syscall: `spawn ${command}`,
|
|
11219
|
+
stdout: "",
|
|
11220
|
+
stderr: "",
|
|
11221
|
+
signal: null,
|
|
11222
|
+
killed: false
|
|
11223
|
+
});
|
|
11223
11224
|
}
|
|
11224
11225
|
const subprocess = execa(command, args, {
|
|
11225
11226
|
cwd: options.cwd,
|
|
@@ -445,8 +445,12 @@ function main() {
|
|
|
445
445
|
return;
|
|
446
446
|
}
|
|
447
447
|
const segments = buildSegments(entries, dialect);
|
|
448
|
-
const
|
|
449
|
-
|
|
448
|
+
const diagnosticFork =
|
|
449
|
+
args.dialect === "claude-cli" &&
|
|
450
|
+
process.argv.includes("--fork-session") &&
|
|
451
|
+
process.argv.includes("--no-session-persistence");
|
|
452
|
+
const segmentIndex = diagnosticFork ? null : claimSegmentIndex(args.state);
|
|
453
|
+
let script = segmentIndex === null ? [] : (segments[segmentIndex] ?? []);
|
|
450
454
|
const log = (text) => process.stderr.write(`[replay-child #${segmentIndex}] ${text}\n`);
|
|
451
455
|
if (script.length === 0) {
|
|
452
456
|
log(`no recorded segment ${segmentIndex} (recording has ${segments.length}); answering generically`);
|