@get-bb/plugin-sdk 0.6.169 → 0.6.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/README.md +3 -1
- package/bundled-types/bb-plugin-sdk-app.d.ts +165 -22
- package/bundled-types/bb-plugin-sdk-environment-provider.d.ts +75 -84
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +308 -185
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp-next.d.ts +1 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +1 -0
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +19 -5
- package/bundled-types/bb-plugin-sdk-testing.d.ts +226 -93
- package/bundled-types/bb-plugin-sdk.d.ts +281 -58
- package/dist/app.js +12 -0
- package/dist/index.js +20 -0
- package/dist/internal/host-policy.js +46 -5
- package/dist/internal/rpc-query-host.js +12 -0
- package/dist/provider-bridge-acp-next.js +28 -10
- package/dist/provider-bridge-acp.js +28 -10
- package/dist/provider-bridge-testing.js +9 -0
- package/dist/provider-bridge.js +9 -0
- package/dist/testing/app.js +54 -2
- package/dist/testing/index.js +101 -10
- package/package.json +1 -1
package/dist/testing/index.js
CHANGED
|
@@ -1940,11 +1940,22 @@ function enforcePluginCliOutputLimit(result, jsonOutput) {
|
|
|
1940
1940
|
};
|
|
1941
1941
|
return jsonOutput ? {
|
|
1942
1942
|
exitCode: 1,
|
|
1943
|
-
stdout: JSON.stringify({ error }),
|
|
1943
|
+
stdout: JSON.stringify({ ok: false, error }),
|
|
1944
1944
|
stderr: "",
|
|
1945
1945
|
error
|
|
1946
1946
|
} : { exitCode: 1, stdout: "", stderr: error.message, error };
|
|
1947
1947
|
}
|
|
1948
|
+
function pluginCliFailureResult(failure, jsonOutput) {
|
|
1949
|
+
return enforcePluginCliOutputLimit(
|
|
1950
|
+
{
|
|
1951
|
+
exitCode: 1,
|
|
1952
|
+
stdout: jsonOutput ? `${JSON.stringify({ ok: false, error: failure }, null, 2)}
|
|
1953
|
+
` : "",
|
|
1954
|
+
stderr: failure.message
|
|
1955
|
+
},
|
|
1956
|
+
jsonOutput
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1948
1959
|
function adoptHttpRouteResponse(value) {
|
|
1949
1960
|
if (value instanceof Response) return value;
|
|
1950
1961
|
if (!isResponseLike(value)) {
|
|
@@ -2148,19 +2159,22 @@ function validatePluginEnvironmentProviderDeclaration(declaration) {
|
|
|
2148
2159
|
declaration.availability,
|
|
2149
2160
|
"availability"
|
|
2150
2161
|
);
|
|
2162
|
+
const existingPath = declaration.apiVersion === 2 ? void 0 : declaration.experimental_existingPath;
|
|
2163
|
+
const locate = declaration.locate;
|
|
2151
2164
|
assertOptionalFunction(
|
|
2152
2165
|
"environment provider",
|
|
2153
2166
|
id,
|
|
2154
|
-
|
|
2167
|
+
existingPath,
|
|
2155
2168
|
"experimental_existingPath"
|
|
2156
2169
|
);
|
|
2170
|
+
assertOptionalFunction("environment provider", id, locate, "a locate");
|
|
2157
2171
|
assertOptionalFunction(
|
|
2158
2172
|
"environment provider",
|
|
2159
2173
|
id,
|
|
2160
2174
|
declaration.restore,
|
|
2161
2175
|
"a restore"
|
|
2162
2176
|
);
|
|
2163
|
-
|
|
2177
|
+
const common = {
|
|
2164
2178
|
id,
|
|
2165
2179
|
displayName,
|
|
2166
2180
|
description,
|
|
@@ -2169,11 +2183,33 @@ function validatePluginEnvironmentProviderDeclaration(declaration) {
|
|
|
2169
2183
|
inputs: inputs === null ? null : inputs.schema,
|
|
2170
2184
|
inputsJsonSchema: inputs === null ? null : inputs.jsonSchema,
|
|
2171
2185
|
availability: declaration.availability ?? null,
|
|
2186
|
+
locate: locate ?? (existingPath === void 0 ? null : ({ inputs: inputs2 }) => {
|
|
2187
|
+
const path = existingPath(inputs2);
|
|
2188
|
+
return path === null ? null : { path, reuse: true };
|
|
2189
|
+
}),
|
|
2190
|
+
remove: declaration.remove
|
|
2191
|
+
};
|
|
2192
|
+
if (declaration.apiVersion === 2) {
|
|
2193
|
+
return {
|
|
2194
|
+
...common,
|
|
2195
|
+
apiVersion: 2,
|
|
2196
|
+
validate: declaration.validate ?? null,
|
|
2197
|
+
create: declaration.create,
|
|
2198
|
+
restore: declaration.restore ?? null,
|
|
2199
|
+
policy: environmentProviderV2PolicySchema.parse(declaration.policy ?? {})
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
if (declaration.apiVersion !== void 0 && declaration.apiVersion !== 1) {
|
|
2203
|
+
throw new Error(
|
|
2204
|
+
`environment provider "${id}" declares apiVersion ${JSON.stringify(declaration.apiVersion)}; this bb supports 1 and 2`
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
return {
|
|
2208
|
+
...common,
|
|
2209
|
+
apiVersion: 1,
|
|
2172
2210
|
validate: declaration.validate ?? null,
|
|
2173
|
-
experimental_existingPath: declaration.experimental_existingPath ?? null,
|
|
2174
2211
|
create: declaration.create,
|
|
2175
2212
|
restore: declaration.restore ?? null,
|
|
2176
|
-
remove: declaration.remove,
|
|
2177
2213
|
policy: environmentProviderPolicySchema.parse(declaration.policy ?? {})
|
|
2178
2214
|
};
|
|
2179
2215
|
}
|
|
@@ -2208,6 +2244,10 @@ var environmentProviderPolicySchema = z6.object({
|
|
|
2208
2244
|
retireGraceMs: z6.number().int().nonnegative().nullable().default(3e5),
|
|
2209
2245
|
pathKeys: z6.enum(["per-thread", "per-attempt"]).default("per-thread")
|
|
2210
2246
|
}).strict();
|
|
2247
|
+
var environmentProviderV2PolicySchema = z6.object({
|
|
2248
|
+
retireGraceMs: z6.number().int().nonnegative().nullable().default(3e5),
|
|
2249
|
+
pathKeys: z6.enum(["per-environment", "per-attempt"]).default("per-environment")
|
|
2250
|
+
}).strict();
|
|
2211
2251
|
var MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS = 200;
|
|
2212
2252
|
function validatePluginMachineProviderDeclaration(declaration) {
|
|
2213
2253
|
const { id, displayName } = requireProviderIdAndDisplayName(
|
|
@@ -2974,7 +3014,7 @@ function normalizeRpcJsonResult(value, fail) {
|
|
|
2974
3014
|
}
|
|
2975
3015
|
|
|
2976
3016
|
// src/testing/fake-plugin-host.ts
|
|
2977
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
3017
|
+
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
|
|
2978
3018
|
import { tmpdir } from "node:os";
|
|
2979
3019
|
import { join } from "node:path";
|
|
2980
3020
|
import Database from "better-sqlite3";
|
|
@@ -3310,6 +3350,12 @@ function createFakePluginHostInternal(options, sharedState) {
|
|
|
3310
3350
|
migrate(database, statements) {
|
|
3311
3351
|
assertLive();
|
|
3312
3352
|
runPluginStorageMigrations(database, statements);
|
|
3353
|
+
},
|
|
3354
|
+
experimental_directory() {
|
|
3355
|
+
assertLive();
|
|
3356
|
+
const directory = join(storageRoot, "files");
|
|
3357
|
+
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
3358
|
+
return directory;
|
|
3313
3359
|
}
|
|
3314
3360
|
};
|
|
3315
3361
|
const settingsDescriptors = {};
|
|
@@ -4346,11 +4392,10 @@ function createFakePluginHostInternal(options, sharedState) {
|
|
|
4346
4392
|
argv.includes("--json")
|
|
4347
4393
|
);
|
|
4348
4394
|
} catch (error) {
|
|
4349
|
-
return
|
|
4395
|
+
return pluginCliFailureResult(
|
|
4350
4396
|
{
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
stderr: `bb ${registration.name} failed: ${errorMessage(error)}`
|
|
4397
|
+
code: "command_failed",
|
|
4398
|
+
message: `bb ${registration.name} failed: ${errorMessage(error)}`
|
|
4354
4399
|
},
|
|
4355
4400
|
argv.includes("--json")
|
|
4356
4401
|
);
|
|
@@ -4790,8 +4835,10 @@ function makeMessageDispatchHookContext(overrides = {}) {
|
|
|
4790
4835
|
lifecycle: { phase: "active", retireAt: null, teardown: null },
|
|
4791
4836
|
hostLifecycle: "active",
|
|
4792
4837
|
managed: false,
|
|
4838
|
+
heldBy: null,
|
|
4793
4839
|
workspaceProvisionType: null,
|
|
4794
4840
|
status: "ready",
|
|
4841
|
+
statusMessage: null,
|
|
4795
4842
|
createdAt: 0,
|
|
4796
4843
|
updatedAt: 0
|
|
4797
4844
|
};
|
|
@@ -4885,6 +4932,49 @@ function makePanelController(overrides = {}) {
|
|
|
4885
4932
|
...overrides
|
|
4886
4933
|
};
|
|
4887
4934
|
}
|
|
4935
|
+
function makeActionContext(overrides = {}) {
|
|
4936
|
+
const calls = [];
|
|
4937
|
+
const record = (member, args) => {
|
|
4938
|
+
calls.push({ member, args });
|
|
4939
|
+
};
|
|
4940
|
+
const navigate = new Proxy({}, {
|
|
4941
|
+
get: (_target, method) => (...args) => {
|
|
4942
|
+
record(`navigate.${String(method)}`, args);
|
|
4943
|
+
return false;
|
|
4944
|
+
}
|
|
4945
|
+
});
|
|
4946
|
+
const sdk = new Proxy({}, {
|
|
4947
|
+
get: (_target, area) => new Proxy(
|
|
4948
|
+
{},
|
|
4949
|
+
{
|
|
4950
|
+
get: (_area, method) => (...args) => {
|
|
4951
|
+
const member = `sdk.${String(area)}.${String(method)}`;
|
|
4952
|
+
record(member, args);
|
|
4953
|
+
return Promise.reject(
|
|
4954
|
+
new Error(
|
|
4955
|
+
`${member} is not stubbed; pass sdk in the overrides`
|
|
4956
|
+
)
|
|
4957
|
+
);
|
|
4958
|
+
}
|
|
4959
|
+
}
|
|
4960
|
+
)
|
|
4961
|
+
});
|
|
4962
|
+
return {
|
|
4963
|
+
sdk: overrides.sdk ?? sdk,
|
|
4964
|
+
navigate: overrides.navigate ?? navigate,
|
|
4965
|
+
panel: overrides.panel ?? makePanelController(),
|
|
4966
|
+
composer: overrides.composer ?? null,
|
|
4967
|
+
threadRequests: overrides.threadRequests ?? {
|
|
4968
|
+
async requestArchive(threadIds) {
|
|
4969
|
+
record("threadRequests.requestArchive", [threadIds]);
|
|
4970
|
+
},
|
|
4971
|
+
async requestDelete(threadIds) {
|
|
4972
|
+
record("threadRequests.requestDelete", [threadIds]);
|
|
4973
|
+
}
|
|
4974
|
+
},
|
|
4975
|
+
calls
|
|
4976
|
+
};
|
|
4977
|
+
}
|
|
4888
4978
|
|
|
4889
4979
|
// src/testing/public-sdk-only.ts
|
|
4890
4980
|
import { readdirSync, readFileSync } from "node:fs";
|
|
@@ -5576,6 +5666,7 @@ export {
|
|
|
5576
5666
|
createFakeSdk,
|
|
5577
5667
|
experimental_createDescendantPipe,
|
|
5578
5668
|
experimental_createProcessLifeline,
|
|
5669
|
+
makeActionContext as experimental_makeActionContext,
|
|
5579
5670
|
makePanelController as experimental_makePanelController,
|
|
5580
5671
|
scanPublicSdkOnly as experimental_scanPublicSdkOnly,
|
|
5581
5672
|
experimental_trackChildProcesses,
|