@get-bb/plugin-sdk 0.6.133 → 0.6.138
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 +278 -9
- package/bundled-types/bb-plugin-sdk.d.ts +278 -9
- package/dist/internal/host-policy.js +39 -37
- package/dist/internal/rpc-query-host.js +2 -1
- package/dist/provider-bridge-acp-next.js +44 -15
- package/dist/provider-bridge-acp.js +44 -15
- package/dist/testing/app.js +2 -1
- package/dist/testing/index.js +39 -37
- package/package.json +3 -2
|
@@ -22432,7 +22432,7 @@ async function loadDeclaredSessionOptions(agent, parameterizedModelPicker, diale
|
|
|
22432
22432
|
let timeout;
|
|
22433
22433
|
const timeoutReached = new Promise((_, reject) => {
|
|
22434
22434
|
timeout = setTimeout(() => {
|
|
22435
|
-
connection.kill();
|
|
22435
|
+
void connection.kill();
|
|
22436
22436
|
reject(
|
|
22437
22437
|
new Error(
|
|
22438
22438
|
`ACP option discovery timed out after ${MODEL_LIST_TIMEOUT_MS}ms`
|
|
@@ -22530,7 +22530,7 @@ async function loadSessionDiscoveredModels(agent, reasoningProbePriorityModelIds
|
|
|
22530
22530
|
let timeout;
|
|
22531
22531
|
const timeoutReached = new Promise((_, reject) => {
|
|
22532
22532
|
timeout = setTimeout(() => {
|
|
22533
|
-
connection.kill();
|
|
22533
|
+
void connection.kill();
|
|
22534
22534
|
reject(
|
|
22535
22535
|
new Error(
|
|
22536
22536
|
`The agent did not answer within ${MODEL_LIST_TIMEOUT_MS / 1e3} seconds while bb asked it for its models`
|
|
@@ -22666,7 +22666,7 @@ async function discoverAcpNativeModelSupport(args) {
|
|
|
22666
22666
|
const timeoutReached = new Promise((resolve5) => {
|
|
22667
22667
|
timeout = setTimeout(() => {
|
|
22668
22668
|
timedOut = true;
|
|
22669
|
-
args.connection.kill();
|
|
22669
|
+
void args.connection.kill();
|
|
22670
22670
|
resolve5(supportByModel);
|
|
22671
22671
|
}, ACP_NATIVE_REASONING_DISCOVERY_TIMEOUT_MS);
|
|
22672
22672
|
});
|
|
@@ -23503,13 +23503,18 @@ async function startAgentSession(request) {
|
|
|
23503
23503
|
let loadedConfigOptions;
|
|
23504
23504
|
let loadedModels;
|
|
23505
23505
|
let createdFreshSession = false;
|
|
23506
|
+
let forkHandoffProviderThreadId;
|
|
23506
23507
|
if (request.kind === "fork") {
|
|
23507
|
-
const
|
|
23508
|
+
const source = getSessionByProviderThreadId(
|
|
23509
|
+
request.sourceProviderThreadId
|
|
23510
|
+
);
|
|
23511
|
+
const handoffSource = source !== void 0 && !source.stopping && !source.connection.exited && source.capabilities?.session.fork === true && source.capabilities.session.close === true && (capabilities.session.resume || supportsLoadSession) ? source : void 0;
|
|
23512
|
+
const forkedSession = await (handoffSource?.connection ?? connection).request({
|
|
23508
23513
|
method: "session/fork",
|
|
23509
23514
|
params: {
|
|
23510
23515
|
sessionId: request.sourceProviderThreadId,
|
|
23511
23516
|
cwd: params.cwd,
|
|
23512
|
-
mcpServers,
|
|
23517
|
+
mcpServers: handoffSource === void 0 ? mcpServers : [],
|
|
23513
23518
|
...additionalSessionDirectories(params, capabilities)
|
|
23514
23519
|
},
|
|
23515
23520
|
resultSchema: acpSessionForkResultSchema,
|
|
@@ -23520,21 +23525,33 @@ async function startAgentSession(request) {
|
|
|
23520
23525
|
`ACP agent "${agentLabel}" returned an active session ID for session/fork.`
|
|
23521
23526
|
);
|
|
23522
23527
|
}
|
|
23523
|
-
sessionId = forkedSession.sessionId;
|
|
23524
23528
|
loadedConfigOptions = forkedSession.configOptions;
|
|
23525
23529
|
loadedModels = forkedSession.models;
|
|
23526
|
-
|
|
23527
|
-
|
|
23530
|
+
if (handoffSource === void 0) {
|
|
23531
|
+
sessionId = forkedSession.sessionId;
|
|
23532
|
+
rememberGrokContextWindow(session, forkedSession.models);
|
|
23533
|
+
} else {
|
|
23534
|
+
forkHandoffProviderThreadId = forkedSession.sessionId;
|
|
23535
|
+
await handoffSource.connection.request({
|
|
23536
|
+
method: "session/close",
|
|
23537
|
+
params: { sessionId: forkedSession.sessionId },
|
|
23538
|
+
resultSchema: z51.unknown(),
|
|
23539
|
+
timeoutMs: ACP_SESSION_SETUP_TIMEOUT_MS
|
|
23540
|
+
});
|
|
23541
|
+
}
|
|
23542
|
+
}
|
|
23543
|
+
const resumeProviderThreadId = request.kind === "resume" ? request.resumeProviderThreadId : forkHandoffProviderThreadId;
|
|
23544
|
+
if (resumeProviderThreadId !== void 0 && (capabilities.session.resume || supportsLoadSession)) {
|
|
23528
23545
|
const restoreMethod = capabilities.session.resume ? "session/resume" : "session/load";
|
|
23529
23546
|
session.loading = true;
|
|
23530
|
-
session.loadingSessionId =
|
|
23547
|
+
session.loadingSessionId = resumeProviderThreadId;
|
|
23531
23548
|
session.pendingLoadUsageUpdate = void 0;
|
|
23532
23549
|
session.model.beginReplay();
|
|
23533
23550
|
try {
|
|
23534
23551
|
const configState = await connection.request({
|
|
23535
23552
|
method: restoreMethod,
|
|
23536
23553
|
params: {
|
|
23537
|
-
sessionId:
|
|
23554
|
+
sessionId: resumeProviderThreadId,
|
|
23538
23555
|
cwd: params.cwd,
|
|
23539
23556
|
mcpServers,
|
|
23540
23557
|
...additionalSessionDirectories(params, capabilities)
|
|
@@ -23542,12 +23559,16 @@ async function startAgentSession(request) {
|
|
|
23542
23559
|
resultSchema: z51.union([acpConfigStateResultSchema, z51.null()]),
|
|
23543
23560
|
timeoutMs: ACP_SESSION_SETUP_TIMEOUT_MS
|
|
23544
23561
|
});
|
|
23545
|
-
|
|
23546
|
-
|
|
23562
|
+
if (configState?.configOptions !== void 0) {
|
|
23563
|
+
loadedConfigOptions = configState.configOptions;
|
|
23564
|
+
}
|
|
23565
|
+
if (configState?.models !== void 0) {
|
|
23566
|
+
loadedModels = configState.models;
|
|
23567
|
+
}
|
|
23547
23568
|
rememberGrokContextWindow(session, configState?.models);
|
|
23548
|
-
sessionId =
|
|
23569
|
+
sessionId = resumeProviderThreadId;
|
|
23549
23570
|
} catch (error) {
|
|
23550
|
-
if (isAcpAuthRequiredResponse(error)) {
|
|
23571
|
+
if (isAcpAuthRequiredResponse(error) || request.kind === "fork") {
|
|
23551
23572
|
throw error;
|
|
23552
23573
|
}
|
|
23553
23574
|
sessionId = void 0;
|
|
@@ -23872,6 +23893,9 @@ function noteAgentResponse(session, method, result) {
|
|
|
23872
23893
|
case "session/load":
|
|
23873
23894
|
case "session/resume":
|
|
23874
23895
|
case "session/fork":
|
|
23896
|
+
if (session.providerThreadId !== "") {
|
|
23897
|
+
return;
|
|
23898
|
+
}
|
|
23875
23899
|
publishSessionStateEvents(
|
|
23876
23900
|
session,
|
|
23877
23901
|
session.model.applySessionSetup(result)
|
|
@@ -24908,7 +24932,12 @@ async function probeAcpAgent(request) {
|
|
|
24908
24932
|
} catch (error) {
|
|
24909
24933
|
return { reachable: false, reason: describe(error) };
|
|
24910
24934
|
} finally {
|
|
24911
|
-
connected.kill()
|
|
24935
|
+
void connected.kill().catch((error) => {
|
|
24936
|
+
process.stderr.write(
|
|
24937
|
+
`acp probe: stopping "${request.command}" failed: ${describe(error)}
|
|
24938
|
+
`
|
|
24939
|
+
);
|
|
24940
|
+
});
|
|
24912
24941
|
}
|
|
24913
24942
|
}
|
|
24914
24943
|
var acpAgentProbeSchema = z52.union([
|
package/dist/testing/app.js
CHANGED
|
@@ -2036,7 +2036,8 @@ var HOST_CHANGE_KINDS = [
|
|
|
2036
2036
|
"host-disconnected",
|
|
2037
2037
|
"provider-model-catalog-changed",
|
|
2038
2038
|
"provider-commands-changed",
|
|
2039
|
-
"provider-cli-status-changed"
|
|
2039
|
+
"provider-cli-status-changed",
|
|
2040
|
+
"provider-cli-install-jobs-changed"
|
|
2040
2041
|
];
|
|
2041
2042
|
var SYSTEM_CHANGE_KINDS = [
|
|
2042
2043
|
"config-changed",
|
package/dist/testing/index.js
CHANGED
|
@@ -2895,59 +2895,61 @@ async function validateRpcValue(schema, value, phase, fail) {
|
|
|
2895
2895
|
}
|
|
2896
2896
|
function normalizeRpcJsonResult(value, fail) {
|
|
2897
2897
|
const ancestors = /* @__PURE__ */ new Set();
|
|
2898
|
-
|
|
2898
|
+
const pathSegments = [];
|
|
2899
|
+
function failAt(problem) {
|
|
2900
|
+
let path = "$result";
|
|
2901
|
+
for (const segment of pathSegments) {
|
|
2902
|
+
path += typeof segment === "number" ? `[${segment}]` : `.${segment}`;
|
|
2903
|
+
}
|
|
2904
|
+
return fail({
|
|
2905
|
+
code: "non_json_result",
|
|
2906
|
+
message: `rpc result at ${path} ${problem}`
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
function visit(current) {
|
|
2899
2910
|
if (current === null || typeof current === "string" || typeof current === "boolean") {
|
|
2900
2911
|
return current;
|
|
2901
2912
|
}
|
|
2902
2913
|
if (typeof current === "number") {
|
|
2903
2914
|
if (!Number.isFinite(current)) {
|
|
2904
|
-
return
|
|
2905
|
-
code: "non_json_result",
|
|
2906
|
-
message: `rpc result at ${path} contains a non-finite number`
|
|
2907
|
-
});
|
|
2915
|
+
return failAt("contains a non-finite number");
|
|
2908
2916
|
}
|
|
2909
2917
|
return current;
|
|
2910
2918
|
}
|
|
2911
2919
|
if (typeof current !== "object") {
|
|
2912
|
-
return
|
|
2913
|
-
code: "non_json_result",
|
|
2914
|
-
message: `rpc result at ${path} is not a JSON value (${typeof current})`
|
|
2915
|
-
});
|
|
2920
|
+
return failAt(`is not a JSON value (${typeof current})`);
|
|
2916
2921
|
}
|
|
2917
2922
|
if (ancestors.has(current)) {
|
|
2918
|
-
return
|
|
2919
|
-
code: "non_json_result",
|
|
2920
|
-
message: `rpc result at ${path} is cyclic`
|
|
2921
|
-
});
|
|
2923
|
+
return failAt("is cyclic");
|
|
2922
2924
|
}
|
|
2923
2925
|
ancestors.add(current);
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
code: "non_json_result",
|
|
2932
|
-
message: `rpc result at ${path} must be a plain JSON object`
|
|
2933
|
-
});
|
|
2934
|
-
}
|
|
2935
|
-
if (Reflect.ownKeys(current).some((key) => typeof key === "symbol")) {
|
|
2936
|
-
return fail({
|
|
2937
|
-
code: "non_json_result",
|
|
2938
|
-
message: `rpc result at ${path} contains a symbol key`
|
|
2939
|
-
});
|
|
2940
|
-
}
|
|
2941
|
-
const normalized = {};
|
|
2942
|
-
for (const [key, child] of Object.entries(current)) {
|
|
2943
|
-
normalized[key] = visit(child, `${path}.${key}`);
|
|
2944
|
-
}
|
|
2945
|
-
return normalized;
|
|
2946
|
-
} finally {
|
|
2926
|
+
if (Array.isArray(current)) {
|
|
2927
|
+
const normalized2 = current.map((item, index) => {
|
|
2928
|
+
pathSegments.push(index);
|
|
2929
|
+
const child = visit(item);
|
|
2930
|
+
pathSegments.pop();
|
|
2931
|
+
return child;
|
|
2932
|
+
});
|
|
2947
2933
|
ancestors.delete(current);
|
|
2934
|
+
return normalized2;
|
|
2935
|
+
}
|
|
2936
|
+
const prototype = Object.getPrototypeOf(current);
|
|
2937
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
2938
|
+
return failAt("must be a plain JSON object");
|
|
2939
|
+
}
|
|
2940
|
+
if (Object.getOwnPropertySymbols(current).length > 0) {
|
|
2941
|
+
return failAt("contains a symbol key");
|
|
2942
|
+
}
|
|
2943
|
+
const normalized = {};
|
|
2944
|
+
for (const key of Object.keys(current)) {
|
|
2945
|
+
pathSegments.push(key);
|
|
2946
|
+
normalized[key] = visit(Reflect.get(current, key));
|
|
2947
|
+
pathSegments.pop();
|
|
2948
2948
|
}
|
|
2949
|
+
ancestors.delete(current);
|
|
2950
|
+
return normalized;
|
|
2949
2951
|
}
|
|
2950
|
-
return visit(value
|
|
2952
|
+
return visit(value);
|
|
2951
2953
|
}
|
|
2952
2954
|
|
|
2953
2955
|
// src/testing/fake-plugin-host.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@get-bb/plugin-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.138",
|
|
4
4
|
"homepage": "https://github.com/get-bb/bb#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/get-bb/bb/issues"
|
|
@@ -161,7 +161,8 @@
|
|
|
161
161
|
"clean": "rimraf bundled-types dist tsconfig.tsbuildinfo",
|
|
162
162
|
"prepack": "node --max-semi-space-size=128 --max-old-space-size=4096 scripts/build-bundled-dts.mjs && node scripts/build-runtime.mjs",
|
|
163
163
|
"test": "vitest run --config vitest.config.ts",
|
|
164
|
-
"typecheck": "tsrs --noEmit"
|
|
164
|
+
"typecheck": "tsrs --noEmit",
|
|
165
|
+
"lint:type-aware": "oxlint -c ../../.oxlintrc.type-aware.json"
|
|
165
166
|
},
|
|
166
167
|
"dependencies": {
|
|
167
168
|
"@tanstack/react-query": "^5.106.1",
|