@get-bb/plugin-sdk 0.6.150 → 0.6.164

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.
@@ -4487,7 +4487,8 @@ import { z as z26 } from "zod";
4487
4487
  var providerMaintenanceParamsSchema = z26.object({
4488
4488
  providerId: z26.string().min(1),
4489
4489
  cwd: z26.string().min(1).optional(),
4490
- providerOptions: z26.record(z26.string(), z26.unknown()).optional()
4490
+ providerOptions: z26.record(z26.string(), z26.unknown()).optional(),
4491
+ envVars: z26.record(z26.string(), z26.string()).optional()
4491
4492
  }).passthrough();
4492
4493
  var providerInstallationRequirementSchema = z26.enum(["thread_rewind"]);
4493
4494
  var providerInstallationStatusParamsSchema = providerMaintenanceParamsSchema.extend({
@@ -4655,7 +4656,10 @@ var modelListParamsSchema = z27.object({
4655
4656
  envVars: z27.record(z27.string(), z27.string()).optional(),
4656
4657
  selectedModel: z27.string().min(1).optional()
4657
4658
  }).passthrough();
4658
- var commandListParamsSchema = z27.object({ cwd: z27.string().min(1) }).passthrough();
4659
+ var commandListParamsSchema = z27.object({
4660
+ cwd: z27.string().min(1),
4661
+ envVars: z27.record(z27.string(), z27.string()).optional()
4662
+ }).passthrough();
4659
4663
  var threadStartParamsSchema = z27.object({
4660
4664
  ...sessionConstructionFields,
4661
4665
  input: z27.array(promptInputSchema).optional()
@@ -4741,8 +4745,12 @@ var BRIDGE_NOTIFICATION_METHODS = {
4741
4745
  sessionReplaced: "session/replaced",
4742
4746
  providerRaw: "provider/raw",
4743
4747
  providerRecovery: "provider/recovery",
4744
- error: "error"
4748
+ error: "error",
4749
+ requestCancelled: "notifications/cancelled"
4745
4750
  };
4751
+ var requestCancelledNotificationSchema = z29.object({
4752
+ requestId: z29.union([z29.string(), z29.number().int()])
4753
+ }).passthrough();
4746
4754
  var threadIdentityNotificationSchema = z29.object({
4747
4755
  threadId: z29.string().min(1),
4748
4756
  providerThreadId: z29.string().min(1),
@@ -5220,7 +5228,7 @@ async function runHandshakeScenario(client, fixture) {
5220
5228
  ...await runDeclaredRequestScenario(client, {
5221
5229
  id: "commands/list-declared",
5222
5230
  method: BRIDGE_REQUEST_METHODS.commandList,
5223
- params: { cwd: fixture.cwd },
5231
+ params: { envVars: {}, cwd: fixture.cwd },
5224
5232
  capability: "commands.list",
5225
5233
  declared: parsed.data.capabilities.commands.list
5226
5234
  })
@@ -7066,6 +7074,7 @@ function readBoundedLines(args) {
7066
7074
  const maxLineBytes = args.maxLineBytes ?? MAX_JSON_RPC_LINE_BYTES;
7067
7075
  const decoder = new StringDecoder("utf8");
7068
7076
  let pending = "";
7077
+ let pendingBytes = 0;
7069
7078
  let discarding = false;
7070
7079
  let discardedBytes = 0;
7071
7080
  args.input.on("data", (chunk) => {
@@ -7084,18 +7093,22 @@ function readBoundedLines(args) {
7084
7093
  emit(pending + text.slice(start, newlineIndex));
7085
7094
  }
7086
7095
  pending = "";
7096
+ pendingBytes = 0;
7087
7097
  start = newlineIndex + 1;
7088
7098
  }
7089
7099
  const tail = text.slice(start);
7100
+ const tailBytes = Buffer.byteLength(tail);
7090
7101
  if (discarding) {
7091
- discardedBytes += Buffer.byteLength(tail);
7102
+ discardedBytes += tailBytes;
7092
7103
  return;
7093
7104
  }
7094
7105
  pending += tail;
7095
- if (Buffer.byteLength(pending) > maxLineBytes) {
7106
+ pendingBytes += tailBytes;
7107
+ if (pendingBytes > maxLineBytes) {
7096
7108
  discarding = true;
7097
- discardedBytes = Buffer.byteLength(pending);
7109
+ discardedBytes = pendingBytes;
7098
7110
  pending = "";
7111
+ pendingBytes = 0;
7099
7112
  }
7100
7113
  });
7101
7114
  args.input.on("end", () => {
@@ -7103,6 +7116,7 @@ function readBoundedLines(args) {
7103
7116
  emit(pending);
7104
7117
  }
7105
7118
  pending = "";
7119
+ pendingBytes = 0;
7106
7120
  args.onClose?.();
7107
7121
  });
7108
7122
  function emit(line) {
@@ -1266,6 +1266,7 @@ function readBoundedLines(args) {
1266
1266
  const maxLineBytes = args.maxLineBytes ?? MAX_JSON_RPC_LINE_BYTES;
1267
1267
  const decoder = new StringDecoder("utf8");
1268
1268
  let pending = "";
1269
+ let pendingBytes = 0;
1269
1270
  let discarding = false;
1270
1271
  let discardedBytes = 0;
1271
1272
  args.input.on("data", (chunk) => {
@@ -1284,18 +1285,22 @@ function readBoundedLines(args) {
1284
1285
  emit(pending + text.slice(start, newlineIndex));
1285
1286
  }
1286
1287
  pending = "";
1288
+ pendingBytes = 0;
1287
1289
  start = newlineIndex + 1;
1288
1290
  }
1289
1291
  const tail = text.slice(start);
1292
+ const tailBytes = Buffer.byteLength(tail);
1290
1293
  if (discarding) {
1291
- discardedBytes += Buffer.byteLength(tail);
1294
+ discardedBytes += tailBytes;
1292
1295
  return;
1293
1296
  }
1294
1297
  pending += tail;
1295
- if (Buffer.byteLength(pending) > maxLineBytes) {
1298
+ pendingBytes += tailBytes;
1299
+ if (pendingBytes > maxLineBytes) {
1296
1300
  discarding = true;
1297
- discardedBytes = Buffer.byteLength(pending);
1301
+ discardedBytes = pendingBytes;
1298
1302
  pending = "";
1303
+ pendingBytes = 0;
1299
1304
  }
1300
1305
  });
1301
1306
  args.input.on("end", () => {
@@ -1303,6 +1308,7 @@ function readBoundedLines(args) {
1303
1308
  emit(pending);
1304
1309
  }
1305
1310
  pending = "";
1311
+ pendingBytes = 0;
1306
1312
  args.onClose?.();
1307
1313
  });
1308
1314
  function emit(line) {
@@ -733,6 +733,7 @@ function readBoundedLines(args) {
733
733
  const maxLineBytes = args.maxLineBytes ?? MAX_JSON_RPC_LINE_BYTES;
734
734
  const decoder = new StringDecoder("utf8");
735
735
  let pending = "";
736
+ let pendingBytes = 0;
736
737
  let discarding = false;
737
738
  let discardedBytes = 0;
738
739
  args.input.on("data", (chunk) => {
@@ -751,18 +752,22 @@ function readBoundedLines(args) {
751
752
  emit(pending + text.slice(start, newlineIndex));
752
753
  }
753
754
  pending = "";
755
+ pendingBytes = 0;
754
756
  start = newlineIndex + 1;
755
757
  }
756
758
  const tail = text.slice(start);
759
+ const tailBytes = Buffer.byteLength(tail);
757
760
  if (discarding) {
758
- discardedBytes += Buffer.byteLength(tail);
761
+ discardedBytes += tailBytes;
759
762
  return;
760
763
  }
761
764
  pending += tail;
762
- if (Buffer.byteLength(pending) > maxLineBytes) {
765
+ pendingBytes += tailBytes;
766
+ if (pendingBytes > maxLineBytes) {
763
767
  discarding = true;
764
- discardedBytes = Buffer.byteLength(pending);
768
+ discardedBytes = pendingBytes;
765
769
  pending = "";
770
+ pendingBytes = 0;
766
771
  }
767
772
  });
768
773
  args.input.on("end", () => {
@@ -770,6 +775,7 @@ function readBoundedLines(args) {
770
775
  emit(pending);
771
776
  }
772
777
  pending = "";
778
+ pendingBytes = 0;
773
779
  args.onClose?.();
774
780
  });
775
781
  function emit(line) {
@@ -1056,6 +1062,19 @@ function withoutBridgeRuntimeEnv(env) {
1056
1062
  delete childEnv[PROVIDER_BRIDGE_RECORD_DIR_ENV];
1057
1063
  return childEnv;
1058
1064
  }
1065
+ function buildProviderCliEnv(envVars) {
1066
+ const inherited = withoutBridgeRuntimeEnv(process.env);
1067
+ const overrides = buildShellEnvOverrides(envVars);
1068
+ if (process.platform === "win32") {
1069
+ const overridden = new Set(
1070
+ Object.keys(overrides).map((name) => name.toUpperCase())
1071
+ );
1072
+ for (const name of Object.keys(inherited)) {
1073
+ if (overridden.has(name.toUpperCase())) delete inherited[name];
1074
+ }
1075
+ }
1076
+ return { ...inherited, ...overrides };
1077
+ }
1059
1078
 
1060
1079
  // ../provider-bridge-protocol/src/bridge-kit/bridge-tool-calls.ts
1061
1080
  import { z as z26 } from "zod";
@@ -2347,6 +2366,27 @@ var interactionLifecycleSchema = z15.union([
2347
2366
  pluginExtensionInteractionLifecycleSchema
2348
2367
  ]);
2349
2368
 
2369
+ // ../text-utils/src/utf16.ts
2370
+ function isHighSurrogateAt(value, index) {
2371
+ const code = value.charCodeAt(index);
2372
+ return code >= 55296 && code <= 56319;
2373
+ }
2374
+ function isLowSurrogateAt(value, index) {
2375
+ const code = value.charCodeAt(index);
2376
+ return code >= 56320 && code <= 57343;
2377
+ }
2378
+ function sliceUtf16Head(value, maxChars) {
2379
+ let end = Math.min(value.length, Math.max(0, maxChars));
2380
+ if (isHighSurrogateAt(value, end - 1) && isLowSurrogateAt(value, end)) {
2381
+ end -= 1;
2382
+ }
2383
+ return value.slice(0, end);
2384
+ }
2385
+ var LONE_SURROGATE = /[\uD800-\uDFFF]/gu;
2386
+ function toWellFormedUtf16(value) {
2387
+ return value.replace(LONE_SURROGATE, "\uFFFD");
2388
+ }
2389
+
2350
2390
  // ../domain/src/provider-event.ts
2351
2391
  import { z as z20 } from "zod";
2352
2392
 
@@ -3871,23 +3911,6 @@ function shouldAutoDenyInteractiveRequest(policy) {
3871
3911
  return policy.permissionEscalation === "deny";
3872
3912
  }
3873
3913
 
3874
- // ../text-utils/src/utf16.ts
3875
- function isHighSurrogateAt(value, index) {
3876
- const code = value.charCodeAt(index);
3877
- return code >= 55296 && code <= 56319;
3878
- }
3879
- function isLowSurrogateAt(value, index) {
3880
- const code = value.charCodeAt(index);
3881
- return code >= 56320 && code <= 57343;
3882
- }
3883
- function sliceUtf16Head(value, maxChars) {
3884
- let end = Math.min(value.length, Math.max(0, maxChars));
3885
- if (isHighSurrogateAt(value, end - 1) && isLowSurrogateAt(value, end)) {
3886
- end -= 1;
3887
- }
3888
- return value.slice(0, end);
3889
- }
3890
-
3891
3914
  // ../provider-bridge-protocol/src/bridge-kit/presentation.ts
3892
3915
  var PRESENTATION_TITLE_MAX_LENGTH = 160;
3893
3916
  function presentationTitle(text) {
@@ -4608,8 +4631,7 @@ function spawnPortableProcess(request) {
4608
4631
  cwd: request.cwd,
4609
4632
  detached: request.detached,
4610
4633
  env: request.env,
4611
- stdio: request.stdio,
4612
- windowsHide: true
4634
+ stdio: request.stdio
4613
4635
  });
4614
4636
  }
4615
4637
 
@@ -4638,7 +4660,7 @@ function terminateWindowsProcessTrees(pids) {
4638
4660
  "taskkill.exe"
4639
4661
  ),
4640
4662
  [...pids.flatMap((pid) => ["/pid", String(pid)]), "/T", "/F"],
4641
- { windowsHide: true },
4663
+ {},
4642
4664
  (error) => finish(error === null)
4643
4665
  );
4644
4666
  timer = setTimeout(() => {
@@ -11925,14 +11947,14 @@ import path8 from "node:path";
11925
11947
  import { z as z28 } from "zod";
11926
11948
  var CLI_PROBE_TIMEOUT_MS = 5e3;
11927
11949
  var INSTALLATION_CHECK_TIMEOUT_MS = 15e3;
11928
- async function resolveExecutablePath(command) {
11929
- return hostToolchain.resolve(command);
11950
+ async function resolveExecutablePath(command, env) {
11951
+ return hostToolchain.resolve(command, env === void 0 ? {} : { env });
11930
11952
  }
11931
- async function commandOutput(command, args) {
11953
+ async function commandOutput(command, args, env) {
11932
11954
  try {
11933
11955
  const { stdout, stderr } = await execPortableFile(command, [...args], {
11934
11956
  cwd: process.cwd(),
11935
- env: process.env,
11957
+ env: env ?? process.env,
11936
11958
  maxBuffer: 1024 * 1024,
11937
11959
  timeout: INSTALLATION_CHECK_TIMEOUT_MS
11938
11960
  });
@@ -11946,11 +11968,11 @@ function versionFrom(value) {
11946
11968
  const candidate = value?.match(/\bv?(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)/u)?.[1];
11947
11969
  return candidate !== void 0 && (0, import_valid.default)(candidate) !== null ? candidate : null;
11948
11970
  }
11949
- async function readCliVersion(command) {
11971
+ async function readCliVersion(command, env) {
11950
11972
  try {
11951
11973
  const { stdout, stderr } = await execPortableFile(command, ["--version"], {
11952
11974
  cwd: process.cwd(),
11953
- env: process.env,
11975
+ env: env ?? process.env,
11954
11976
  maxBuffer: 1024 * 1024,
11955
11977
  timeout: CLI_PROBE_TIMEOUT_MS
11956
11978
  });
@@ -11976,16 +11998,16 @@ function npmGlobalInstallCommand(npmPackage) {
11976
11998
  const args = ["install", "-g", `${npmPackage}@latest`];
11977
11999
  return { command, args, displayCommand: formatCommand(command, args) };
11978
12000
  }
11979
- async function npmLatestVersion(npmPackage) {
12001
+ async function npmLatestVersion(npmPackage, env) {
11980
12002
  return versionFrom(
11981
- await commandOutput(npmCommand(), ["view", npmPackage, "version"])
12003
+ await commandOutput(npmCommand(), ["view", npmPackage, "version"], env)
11982
12004
  );
11983
12005
  }
11984
- async function probeNpmGlobalPackage(npmPackage) {
12006
+ async function probeNpmGlobalPackage(npmPackage, env) {
11985
12007
  const npm = npmCommand();
11986
12008
  const [prefixOutput, listOutput] = await Promise.all([
11987
- commandOutput(npm, ["prefix", "-g"]),
11988
- commandOutput(npm, ["list", "-g", npmPackage, "--depth=0", "--json"])
12009
+ commandOutput(npm, ["prefix", "-g"], env),
12010
+ commandOutput(npm, ["list", "-g", npmPackage, "--depth=0", "--json"], env)
11989
12011
  ]);
11990
12012
  const npmPrefix = firstLine(prefixOutput);
11991
12013
  return {
@@ -12105,6 +12127,59 @@ var ProviderResponseEncodeError = class extends Error {
12105
12127
  }
12106
12128
  };
12107
12129
  var ignoredJsonRpcResultSchema = z31.unknown();
12130
+ function wellFormedStrings(_key, value) {
12131
+ return typeof value === "string" ? toWellFormedUtf16(value) : value;
12132
+ }
12133
+ function serializeJsonRpcLine(message) {
12134
+ const line = JSON.stringify(message);
12135
+ return line.includes("\\ud") ? JSON.stringify(message, wellFormedStrings) : line;
12136
+ }
12137
+
12138
+ // ../provider-bridge-protocol/src/bridge-kit/unanswered-interaction.ts
12139
+ var UNANSWERED_INTERACTION_WARNING_SUMMARY = "bb answered the agent without you";
12140
+ function sentence(text) {
12141
+ return text.trim().replace(/[.\s]+$/u, "");
12142
+ }
12143
+ function causeText(cause) {
12144
+ switch (cause.kind) {
12145
+ case "unshowable-request":
12146
+ return `it could not show the question: ${sentence(cause.detail)}`;
12147
+ case "runtime-error":
12148
+ return `it stopped waiting for your answer: ${sentence(cause.message)}`;
12149
+ case "unreadable-resolution":
12150
+ return "it could not read the answer it received";
12151
+ case "unmappable-answer":
12152
+ return `your answer did not fit the question: ${sentence(cause.detail)}`;
12153
+ case "withdrawn":
12154
+ return `it withdrew the question: ${sentence(cause.detail)}`;
12155
+ }
12156
+ }
12157
+ function agentCauseText(cause) {
12158
+ switch (cause.kind) {
12159
+ case "unshowable-request":
12160
+ return `bb could not show the question (${sentence(cause.detail)})`;
12161
+ case "runtime-error":
12162
+ return `bb stopped waiting for the answer (${sentence(cause.message)})`;
12163
+ case "unreadable-resolution":
12164
+ return "bb could not read the answer it received";
12165
+ case "unmappable-answer":
12166
+ return `the answer did not fit the question (${sentence(cause.detail)})`;
12167
+ case "withdrawn":
12168
+ return `bb withdrew the question (${sentence(cause.detail)})`;
12169
+ }
12170
+ }
12171
+ function unansweredInteractionErrorMessage(cause) {
12172
+ return `The user did not answer: ${agentCauseText(cause)}.`;
12173
+ }
12174
+ function unansweredInteractionWarning(args) {
12175
+ const answer = args.answer.kind === "error" ? "an error" : JSON.stringify(args.answer.value);
12176
+ return {
12177
+ kind: "provider.warning",
12178
+ summary: UNANSWERED_INTERACTION_WARNING_SUMMARY,
12179
+ details: `bb answered the agent with ${answer} because ${causeText(args.cause)}.`,
12180
+ vouchedTurn: true
12181
+ };
12182
+ }
12108
12183
 
12109
12184
  // ../provider-bridge-protocol/src/version.ts
12110
12185
  var PROVIDER_BRIDGE_PROTOCOL_VERSION = 2;
@@ -12166,7 +12241,8 @@ import { z as z34 } from "zod";
12166
12241
  var providerMaintenanceParamsSchema = z34.object({
12167
12242
  providerId: z34.string().min(1),
12168
12243
  cwd: z34.string().min(1).optional(),
12169
- providerOptions: z34.record(z34.string(), z34.unknown()).optional()
12244
+ providerOptions: z34.record(z34.string(), z34.unknown()).optional(),
12245
+ envVars: z34.record(z34.string(), z34.string()).optional()
12170
12246
  }).passthrough();
12171
12247
  var providerInstallationRequirementSchema = z34.enum(["thread_rewind"]);
12172
12248
  var providerInstallationStatusParamsSchema = providerMaintenanceParamsSchema.extend({
@@ -12334,7 +12410,10 @@ var modelListParamsSchema = z35.object({
12334
12410
  envVars: z35.record(z35.string(), z35.string()).optional(),
12335
12411
  selectedModel: z35.string().min(1).optional()
12336
12412
  }).passthrough();
12337
- var commandListParamsSchema = z35.object({ cwd: z35.string().min(1) }).passthrough();
12413
+ var commandListParamsSchema = z35.object({
12414
+ cwd: z35.string().min(1),
12415
+ envVars: z35.record(z35.string(), z35.string()).optional()
12416
+ }).passthrough();
12338
12417
  var commandListResultSchema = threadProviderCommandsStateSchema;
12339
12418
  var threadStartParamsSchema = z35.object({
12340
12419
  ...sessionConstructionFields,
@@ -12405,8 +12484,12 @@ var BRIDGE_NOTIFICATION_METHODS = {
12405
12484
  sessionReplaced: "session/replaced",
12406
12485
  providerRaw: "provider/raw",
12407
12486
  providerRecovery: "provider/recovery",
12408
- error: "error"
12487
+ error: "error",
12488
+ requestCancelled: "notifications/cancelled"
12409
12489
  };
12490
+ var requestCancelledNotificationSchema = z36.object({
12491
+ requestId: z36.union([z36.string(), z36.number().int()])
12492
+ }).passthrough();
12410
12493
  var threadIdentityNotificationSchema = z36.object({
12411
12494
  threadId: z36.string().min(1),
12412
12495
  providerThreadId: z36.string().min(1),
@@ -13051,6 +13134,7 @@ export {
13051
13134
  COMPACTION_PRESENTATION as experimental_COMPACTION_PRESENTATION,
13052
13135
  REASONING_PRESENTATION as experimental_REASONING_PRESENTATION,
13053
13136
  buildBridgeToolCallContent as experimental_buildBridgeToolCallContent,
13137
+ buildProviderCliEnv as experimental_buildProviderCliEnv,
13054
13138
  clampPercent as experimental_clampPercent,
13055
13139
  commandOutput as experimental_commandOutput,
13056
13140
  compareVersions as experimental_compareVersions,
@@ -13077,8 +13161,11 @@ export {
13077
13161
  scanSkillFiles as experimental_scanSkillFiles,
13078
13162
  searchPresentation as experimental_searchPresentation,
13079
13163
  selectedSkillMentions as experimental_selectedSkillMentions,
13164
+ serializeJsonRpcLine as experimental_serializeJsonRpcLine,
13080
13165
  spawnPortableProcess as experimental_spawnPortableProcess,
13081
13166
  toolPresentation as experimental_toolPresentation,
13167
+ unansweredInteractionErrorMessage as experimental_unansweredInteractionErrorMessage,
13168
+ unansweredInteractionWarning as experimental_unansweredInteractionWarning,
13082
13169
  versionFrom as experimental_versionFrom,
13083
13170
  webFetchPresentation as experimental_webFetchPresentation,
13084
13171
  webSearchPresentation as experimental_webSearchPresentation,