@get-bb/plugin-sdk 0.6.59 → 0.6.60

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.
@@ -20433,7 +20433,7 @@ interface PluginFileOpenerRegistration {
20433
20433
  id: string;
20434
20434
  /** Label in the "Open with" menu (e.g. "Notes editor"). */
20435
20435
  title: string;
20436
- /** Lowercase extensions without the dot (e.g. ["md", "mdx"]). */
20436
+ /** Lowercase alphanumeric extensions without the dot; single underscores or hyphens may separate segments. */
20437
20437
  extensions: readonly string[];
20438
20438
  component: ComponentType<PluginFileOpenerProps>;
20439
20439
  }
@@ -268,7 +268,8 @@ type PluginEnvironmentProviderCreateResult = {
268
268
  status: "created";
269
269
  path: string;
270
270
  ownsPath: boolean;
271
- mergeBaseBranch?: string;
271
+ /** Ref the workspace's changes are compared against. Null clears the value recorded on a reused environment; omit to keep it. */
272
+ mergeBaseBranch?: string | null;
272
273
  resource?: JsonValue$1;
273
274
  } | {
274
275
  status: "failed";
@@ -606,7 +606,8 @@ type PluginEnvironmentProviderCreateResult = {
606
606
  status: "created";
607
607
  path: string;
608
608
  ownsPath: boolean;
609
- mergeBaseBranch?: string;
609
+ /** Ref the workspace's changes are compared against. Null clears the value recorded on a reused environment; omit to keep it. */
610
+ mergeBaseBranch?: string | null;
610
611
  resource?: JsonValue$2;
611
612
  } | {
612
613
  status: "failed";
@@ -399,7 +399,8 @@ type PluginEnvironmentProviderCreateResult = {
399
399
  status: "created";
400
400
  path: string;
401
401
  ownsPath: boolean;
402
- mergeBaseBranch?: string;
402
+ /** Ref the workspace's changes are compared against. Null clears the value recorded on a reused environment; omit to keep it. */
403
+ mergeBaseBranch?: string | null;
403
404
  resource?: JsonValue$2;
404
405
  } | {
405
406
  status: "failed";
@@ -20617,7 +20617,7 @@ interface PluginFileOpenerRegistration {
20617
20617
  id: string;
20618
20618
  /** Label in the "Open with" menu (e.g. "Notes editor"). */
20619
20619
  title: string;
20620
- /** Lowercase extensions without the dot (e.g. ["md", "mdx"]). */
20620
+ /** Lowercase alphanumeric extensions without the dot; single underscores or hyphens may separate segments. */
20621
20621
  extensions: readonly string[];
20622
20622
  component: ComponentType<PluginFileOpenerProps>;
20623
20623
  }
@@ -22751,7 +22751,8 @@ type PluginEnvironmentProviderCreateResult = {
22751
22751
  status: "created";
22752
22752
  path: string;
22753
22753
  ownsPath: boolean;
22754
- mergeBaseBranch?: string;
22754
+ /** Ref the workspace's changes are compared against. Null clears the value recorded on a reused environment; omit to keep it. */
22755
+ mergeBaseBranch?: string | null;
22755
22756
  resource?: JsonValue$2;
22756
22757
  } | {
22757
22758
  status: "failed";
@@ -833,9 +833,9 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
833
833
  );
834
834
  }
835
835
  const extensions = rawExtensions.map((extension) => {
836
- if (typeof extension !== "string" || !/^[a-z0-9]+$/.test(extension)) {
836
+ if (typeof extension !== "string" || !/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(extension)) {
837
837
  throw new Error(
838
- `${kind}: extensions must be lowercase alphanumerics without the dot, got ${JSON.stringify(extension)}`
838
+ `${kind}: extensions must be lowercase alphanumerics with single underscores or hyphens between segments, without the dot, got ${JSON.stringify(extension)}`
839
839
  );
840
840
  }
841
841
  return extension;
@@ -11841,20 +11841,6 @@ function versionFrom(value) {
11841
11841
  const candidate = value?.match(/\bv?(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)/u)?.[1];
11842
11842
  return candidate !== void 0 && (0, import_valid.default)(candidate) !== null ? candidate : null;
11843
11843
  }
11844
- async function readCliVersion(command) {
11845
- try {
11846
- const { stdout, stderr } = await execPortableFile(command, ["--version"], {
11847
- cwd: process.cwd(),
11848
- env: process.env,
11849
- maxBuffer: 1024 * 1024,
11850
- timeout: CLI_PROBE_TIMEOUT_MS
11851
- });
11852
- return versionFrom(`${stdout}
11853
- ${stderr}`);
11854
- } catch {
11855
- return null;
11856
- }
11857
- }
11858
11844
  function downloadedInstallerCommand(url2, options = {}) {
11859
11845
  if ((options.platform ?? process.platform) === "win32" && options.powershellUrl !== void 0) {
11860
11846
  const powershellScript = `irm ${options.powershellUrl} | iex`;
@@ -11909,7 +11895,7 @@ var ignoredJsonRpcResultSchema = z35.unknown();
11909
11895
 
11910
11896
  // ../provider-bridge-acp/src/bridge/bridge.ts
11911
11897
  import { randomBytes as randomBytes2 } from "node:crypto";
11912
- import { promises as fs4, readFileSync as readFileSync3 } from "node:fs";
11898
+ import { promises as fs4, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
11913
11899
  import { createServer } from "node:net";
11914
11900
  import { dirname as dirname2, isAbsolute as isAbsolute2, basename as basename4, relative as relative2, resolve as resolve4 } from "node:path";
11915
11901
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -12283,6 +12269,7 @@ var acpBridgeCommandMethodValues = acpBridgeCommandSchema.options.map(
12283
12269
  );
12284
12270
  var ACP_TURN_STARTED_METHOD = "acp/turn/started";
12285
12271
  var ACP_TURN_COMPLETED_METHOD = "acp/turn/completed";
12272
+ var ACP_PROMPT_INTERRUPTED_METHOD = "acp/prompt/interrupted";
12286
12273
  var ACP_COMPACTION_STARTED_METHOD = "acp/compaction/started";
12287
12274
  var ACP_COMPACTION_COMPLETED_METHOD = "acp/compaction/completed";
12288
12275
  var ACP_UPDATE_METHOD = "acp/update";
@@ -12691,6 +12678,23 @@ function healthResult(args) {
12691
12678
  }
12692
12679
  };
12693
12680
  }
12681
+ async function readAcpCliVersion(command) {
12682
+ try {
12683
+ const { stdout, stderr } = await execPortableFile(command, ["--version"], {
12684
+ cwd: process.cwd(),
12685
+ env: process.env,
12686
+ maxBuffer: 1024 * 1024,
12687
+ timeout: 5e3
12688
+ });
12689
+ const output = `${stdout}
12690
+ ${stderr}`;
12691
+ return versionFrom(output) ?? output.match(
12692
+ /(?:^|\s)(\d{4}\.(?:0[1-9]|1[0-2])\.(?:0[1-9]|[12]\d|3[01])-[0-9a-f]+)(?=\s|$)/u
12693
+ )?.[1] ?? null;
12694
+ } catch {
12695
+ return null;
12696
+ }
12697
+ }
12694
12698
  async function getAcpProviderHealth(args) {
12695
12699
  const maintenance = args.maintenance;
12696
12700
  if (args.command === null) {
@@ -12703,7 +12707,7 @@ async function getAcpProviderHealth(args) {
12703
12707
  if (await resolveExecutablePath(args.command) === null) {
12704
12708
  return healthResult({ maintenance, status: "not_installed" });
12705
12709
  }
12706
- const version = await readCliVersion(args.command);
12710
+ const version = await readAcpCliVersion(args.command);
12707
12711
  if (maintenance === void 0) {
12708
12712
  return healthResult({
12709
12713
  maintenance,
@@ -12732,7 +12736,7 @@ async function getAcpProviderInstallationStatus(args) {
12732
12736
  const executableName = args.command ?? "";
12733
12737
  const resolvedExecutable = args.command === null ? null : await resolveExecutablePath(args.command);
12734
12738
  const installed = resolvedExecutable !== null;
12735
- const currentVersion = installed && args.command !== null ? await readCliVersion(args.command) : null;
12739
+ const currentVersion = installed && args.command !== null ? await readAcpCliVersion(args.command) : null;
12736
12740
  const installAction = args.maintenance !== void 0 && !installed ? {
12737
12741
  kind: "install",
12738
12742
  label: "Install",
@@ -13308,25 +13312,35 @@ function fileChangeVerb(changes, fallback) {
13308
13312
  }
13309
13313
  return "update";
13310
13314
  }
13315
+ var DEV_NULL_OLD_TEXT = /^-{2,3} \/dev\/null$/u;
13316
+ var NEW_FILE_HEADER = /^\+{2,3} b\/[^\n]*(?:\n|$)/u;
13311
13317
  function buildAcpFileChanges(event, operation, options) {
13312
13318
  const changes = [];
13313
13319
  for (const entry of event.content ?? []) {
13314
13320
  if (entry.type !== "diff") {
13315
13321
  continue;
13316
13322
  }
13317
- const oldText = entry.oldText ?? void 0;
13323
+ const createsFile = entry.oldText === null || entry.oldText === void 0 || DEV_NULL_OLD_TEXT.test(entry.oldText);
13318
13324
  changes.push({
13319
13325
  path: resolveAcpToolCallPath(entry.path, options),
13320
- kind: oldText === void 0 ? "add" : "update",
13321
- ...oldText === void 0 ? {} : { oldText },
13322
- newText: entry.newText
13326
+ kind: createsFile ? "add" : "update",
13327
+ ...createsFile ? {} : { oldText: entry.oldText ?? void 0 },
13328
+ newText: createsFile ? entry.newText.replace(NEW_FILE_HEADER, "") : entry.newText
13323
13329
  });
13324
13330
  }
13325
13331
  if (changes.length > 0) {
13326
13332
  return changes;
13327
13333
  }
13328
13334
  const [path13] = operation.paths;
13329
- return path13 === void 0 ? [] : [{ path: path13, kind: operation.changeKind }];
13335
+ if (path13 === void 0) {
13336
+ return [];
13337
+ }
13338
+ return [
13339
+ {
13340
+ path: path13,
13341
+ kind: operation.changeKind === "update" && options?.existedBefore?.get(path13) === false ? "add" : operation.changeKind
13342
+ }
13343
+ ];
13330
13344
  }
13331
13345
  function fileChangeItem(changes, fallbackVerb) {
13332
13346
  return {
@@ -14218,6 +14232,34 @@ function createAcpDeltaTranslator(options = {}) {
14218
14232
  const dialect = options.dialect ?? GENERIC_ACP_DIALECT;
14219
14233
  const pathOptions = { cwd: options.cwd };
14220
14234
  const mergedToolCalls = /* @__PURE__ */ new Map();
14235
+ const fileExistence = /* @__PURE__ */ new Map();
14236
+ const filesAddedThisTurn = /* @__PURE__ */ new Set();
14237
+ function noteEditedPaths(key, event) {
14238
+ const fileCreatedThisTurn = options.fileCreatedThisTurn;
14239
+ if (fileCreatedThisTurn === void 0 || event.kind !== "edit") {
14240
+ return;
14241
+ }
14242
+ const seen = fileExistence.get(key) ?? /* @__PURE__ */ new Map();
14243
+ for (const location of event.locations ?? []) {
14244
+ const resolved = resolveAcpToolCallPath(location.path, pathOptions);
14245
+ if (seen.has(resolved)) {
14246
+ continue;
14247
+ }
14248
+ const created = fileCreatedThisTurn(resolved);
14249
+ if (created === void 0) {
14250
+ seen.set(resolved, void 0);
14251
+ continue;
14252
+ }
14253
+ const added = created && !filesAddedThisTurn.has(resolved);
14254
+ if (added) {
14255
+ filesAddedThisTurn.add(resolved);
14256
+ }
14257
+ seen.set(resolved, !added);
14258
+ }
14259
+ if (seen.size > 0) {
14260
+ fileExistence.set(key, seen);
14261
+ }
14262
+ }
14221
14263
  let lastUsageCost;
14222
14264
  let lastAgentTitle;
14223
14265
  let injectedToolsByName = /* @__PURE__ */ new Map();
@@ -14302,7 +14344,10 @@ function createAcpDeltaTranslator(options = {}) {
14302
14344
  return dialectShape;
14303
14345
  }
14304
14346
  }
14305
- return classifyAcpToolCall2(event, injected, pathOptions);
14347
+ return classifyAcpToolCall2(event, injected, {
14348
+ ...pathOptions,
14349
+ existedBefore: fileExistence.get(callKey(context, event.toolCallId))
14350
+ });
14306
14351
  }
14307
14352
  function withClientFileWrites(event, writes) {
14308
14353
  if (writes.length === 0) {
@@ -14473,6 +14518,7 @@ function createAcpDeltaTranslator(options = {}) {
14473
14518
  args.permissionTitle
14474
14519
  );
14475
14520
  injectedToolBindings.delete(callKey(args.context, args.event.toolCallId));
14521
+ fileExistence.delete(callKey(args.context, args.event.toolCallId));
14476
14522
  const closeFields = classified.item.type === "command" ? commandCloseFields(args.event, args.status) : genericCloseFields(args.event);
14477
14523
  return {
14478
14524
  kind: "item.close",
@@ -14570,6 +14616,7 @@ function createAcpDeltaTranslator(options = {}) {
14570
14616
  if (bound !== void 0) {
14571
14617
  injectedToolBindings.set(announcedKey, bound);
14572
14618
  }
14619
+ noteEditedPaths(announcedKey, event);
14573
14620
  if (isTerminalAcpStatus(event.status)) {
14574
14621
  return [
14575
14622
  ...flush,
@@ -14611,6 +14658,7 @@ function createAcpDeltaTranslator(options = {}) {
14611
14658
  mergeAcpToolCallEvents(open?.event, event),
14612
14659
  open?.clientFileWrites ?? []
14613
14660
  );
14661
+ noteEditedPaths(key, merged);
14614
14662
  if (isTerminalAcpStatus(merged.status)) {
14615
14663
  mergedToolCalls.delete(key);
14616
14664
  return [
@@ -14787,8 +14835,18 @@ function createAcpDeltaTranslator(options = {}) {
14787
14835
  return [];
14788
14836
  }
14789
14837
  clearThreadCalls(context);
14838
+ filesAddedThisTurn.clear();
14790
14839
  return [{ kind: "turn.open" }];
14791
14840
  }
14841
+ case ACP_PROMPT_INTERRUPTED_METHOD: {
14842
+ const params = acpTurnStartedNotificationParamsSchema.safeParse(
14843
+ envelope.data.params
14844
+ );
14845
+ if (!params.success) {
14846
+ return [];
14847
+ }
14848
+ return drainOpenToolCalls(context, "interrupted");
14849
+ }
14792
14850
  case ACP_TURN_COMPLETED_METHOD: {
14793
14851
  const params = acpTurnCompletedNotificationParamsSchema.safeParse(
14794
14852
  envelope.data.params
@@ -21429,6 +21487,7 @@ var pendingRuntimeRequests = /* @__PURE__ */ new Map();
21429
21487
  var runtimeRequestIdCounter = 0;
21430
21488
  var dynamicToolBridgePromise = null;
21431
21489
  var THREAD_STOP_CANCEL_TIMEOUT_MS = 4e3;
21490
+ var SHUTDOWN_CANCEL_TIMEOUT_MS = 1500;
21432
21491
  var AGENT_TURN_QUIET_MS = 5e3;
21433
21492
  var SESSION_BUSY_QUIET_MS = 2e3;
21434
21493
  var SESSION_BUSY_MAX_WAITS = 300;
@@ -22482,23 +22541,39 @@ async function selectAcpNativeServiceTier(args) {
22482
22541
  });
22483
22542
  recordAcpConfigValue(args.session, configState, fastOption.id, value);
22484
22543
  }
22485
- function textWithoutUnknownLeadingSkillCommand(session, item) {
22486
- const advertised = session.model.snapshot().commands;
22487
- if (advertised.length === 0) {
22488
- return item.text;
22489
- }
22490
- const firstCharacter = item.text.search(/\S/u);
22491
- const leading = item.mentions.find(
22492
- (mention) => mention.start === firstCharacter && mention.resource.kind === "command" && mention.resource.source === "skill" && mention.resource.trigger === "/"
22544
+ function textWithBbSkillCommandsSpelledOut(session, item) {
22545
+ const bbSkillNames = new Set(
22546
+ (configuredSkillRoots ?? []).flatMap(
22547
+ (root) => root.skills.map((skill) => skill.name)
22548
+ )
22493
22549
  );
22494
- if (!leading || leading.resource.kind !== "command") {
22550
+ if (bbSkillNames.size === 0) {
22495
22551
  return item.text;
22496
22552
  }
22497
- const name = leading.resource.name;
22498
- if (advertised.some((command) => command.name === name)) {
22499
- return item.text;
22553
+ const advertised = new Set(
22554
+ session.model.snapshot().commands.map((command) => command.name)
22555
+ );
22556
+ const mentions = item.mentions.flatMap(
22557
+ (mention) => mention.resource.kind === "command" && mention.resource.source === "skill" && mention.resource.trigger === "/" && bbSkillNames.has(mention.resource.name) && !advertised.has(mention.resource.name) && item.text.slice(mention.start, mention.end) === `/${mention.resource.name}` ? [
22558
+ {
22559
+ start: mention.start,
22560
+ end: mention.end,
22561
+ name: mention.resource.name
22562
+ }
22563
+ ] : []
22564
+ ).sort((a2, b) => b.start - a2.start);
22565
+ const firstCharacter = item.text.search(/\S/u);
22566
+ let text = item.text;
22567
+ let nextStart = text.length;
22568
+ for (const mention of mentions) {
22569
+ if (mention.end > nextStart) {
22570
+ continue;
22571
+ }
22572
+ const leadsText = mention.start === firstCharacter && text.slice(mention.end).trim().length > 0;
22573
+ text = `${text.slice(0, mention.start)}Use the bb skill "${mention.name}"${leadsText ? ":" : ""}${text.slice(mention.end)}`;
22574
+ nextStart = mention.start;
22500
22575
  }
22501
- return `${item.text.slice(0, leading.start)}Use the bb skill "${name}":${item.text.slice(leading.end)}`;
22576
+ return text;
22502
22577
  }
22503
22578
  function buildPromptContentBlocks(session, input) {
22504
22579
  const blocks = [];
@@ -22512,12 +22587,12 @@ ${instructions}
22512
22587
  </system_instructions>`
22513
22588
  });
22514
22589
  }
22515
- for (const [index, item] of input.entries()) {
22590
+ for (const item of input) {
22516
22591
  switch (item.type) {
22517
22592
  case "text":
22518
22593
  blocks.push({
22519
22594
  type: "text",
22520
- text: index === 0 ? textWithoutUnknownLeadingSkillCommand(session, item) : item.text
22595
+ text: textWithBbSkillCommandsSpelledOut(session, item)
22521
22596
  });
22522
22597
  break;
22523
22598
  case "image":
@@ -22817,6 +22892,33 @@ function getSessionByProviderThreadId(providerThreadId) {
22817
22892
  const bbThreadId = bbThreadIdByProviderThreadId.get(providerThreadId);
22818
22893
  return bbThreadId ? sessionsByBbThreadId.get(bbThreadId) : void 0;
22819
22894
  }
22895
+ function fileCreatedSince(path13, sinceMs) {
22896
+ if (sinceMs === void 0) {
22897
+ return void 0;
22898
+ }
22899
+ try {
22900
+ const { birthtimeMs } = statSync2(path13);
22901
+ return birthtimeMs > 0 ? birthtimeMs >= sinceMs : void 0;
22902
+ } catch {
22903
+ return void 0;
22904
+ }
22905
+ }
22906
+ function dialectLaunchEnv(dialectId, permissionMode) {
22907
+ if (dialectId !== "opencode") {
22908
+ return {};
22909
+ }
22910
+ const outsideEdits = permissionMode === "full" ? "allow" : "ask";
22911
+ return {
22912
+ OPENCODE_CLIENT: "acp",
22913
+ OPENCODE_ENABLE_QUESTION_TOOL: "false",
22914
+ OPENCODE_PERMISSION: JSON.stringify({
22915
+ edit: "allow",
22916
+ bash: outsideEdits,
22917
+ webfetch: outsideEdits,
22918
+ external_directory: outsideEdits
22919
+ })
22920
+ };
22921
+ }
22820
22922
  async function startAgentSession(request) {
22821
22923
  const params = request.params;
22822
22924
  const bbThreadId = params.threadId;
@@ -22830,7 +22932,8 @@ async function startAgentSession(request) {
22830
22932
  });
22831
22933
  const translator = createAcpDeltaTranslator({
22832
22934
  cwd: params.cwd,
22833
- dialect
22935
+ dialect,
22936
+ fileCreatedThisTurn: (path13) => fileCreatedSince(path13, session.turnStartedAtMs)
22834
22937
  });
22835
22938
  translator.configureInjectedTools(
22836
22939
  (params.dynamicTools ?? []).map((tool) => ({
@@ -22859,7 +22962,7 @@ async function startAgentSession(request) {
22859
22962
  const childEnv = {
22860
22963
  ...withoutBridgeRuntimeEnv(process.env),
22861
22964
  ...params.envVars,
22862
- ...dialect.id === "opencode" ? { OPENCODE_CLIENT: "acp", OPENCODE_ENABLE_QUESTION_TOOL: "false" } : {}
22965
+ ...dialectLaunchEnv(dialect.id, params.permissionMode)
22863
22966
  };
22864
22967
  const connection = createBridgeAgentConnection({
22865
22968
  command: params.agent.command,
@@ -22917,6 +23020,7 @@ async function startAgentSession(request) {
22917
23020
  queuedInputs: [],
22918
23021
  promptRequestPending: false,
22919
23022
  cancelRequested: false,
23023
+ turnStartedAtMs: void 0,
22920
23024
  restartAfterCancelError: false,
22921
23025
  loading: false,
22922
23026
  loadingSessionId: void 0,
@@ -23125,7 +23229,7 @@ async function startAgentSession(request) {
23125
23229
  });
23126
23230
  }
23127
23231
  }
23128
- async function stopSession(session) {
23232
+ async function stopSession(session, cancelTimeoutMs = THREAD_STOP_CANCEL_TIMEOUT_MS) {
23129
23233
  if (session.stopping) {
23130
23234
  return;
23131
23235
  }
@@ -23143,7 +23247,7 @@ async function stopSession(session) {
23143
23247
  await Promise.race([
23144
23248
  session.turnSettled,
23145
23249
  new Promise(
23146
- (resolveTimeout) => setTimeout(resolveTimeout, THREAD_STOP_CANCEL_TIMEOUT_MS)
23250
+ (resolveTimeout) => setTimeout(resolveTimeout, cancelTimeoutMs)
23147
23251
  )
23148
23252
  ]);
23149
23253
  }
@@ -23425,6 +23529,7 @@ function finishTurn(session, stopReason) {
23425
23529
  if (session.activePromptKind !== "turn") {
23426
23530
  return;
23427
23531
  }
23532
+ session.turnStartedAtMs = void 0;
23428
23533
  for (const controller of session.pendingToolCalls) controller.abort();
23429
23534
  setActivePromptKind(session, null);
23430
23535
  dropQueuedTurnInputs(session, "ACP turn ended before the steer was sent");
@@ -23503,6 +23608,7 @@ function runTurn(session, firstInput, turnAlreadyOpen = false) {
23503
23608
  const prompt = buildPromptContentBlocks(session, pending.input);
23504
23609
  let inputAccepted = false;
23505
23610
  let busyRetries = 0;
23611
+ session.turnStartedAtMs ??= Date.now();
23506
23612
  for (; ; ) {
23507
23613
  session.promptRequestPending = true;
23508
23614
  const promptResult = session.connection.request({
@@ -23563,6 +23669,11 @@ function runTurn(session, firstInput, turnAlreadyOpen = false) {
23563
23669
  if (!session.stopping) {
23564
23670
  const next = session.queuedInputs.shift();
23565
23671
  if (next) {
23672
+ if (stopReason === "cancelled") {
23673
+ emitForSession(session, ACP_PROMPT_INTERRUPTED_METHOD, {
23674
+ threadId: session.bbThreadId
23675
+ });
23676
+ }
23566
23677
  pending = next;
23567
23678
  continue;
23568
23679
  }
@@ -23606,6 +23717,15 @@ function reconcileExecutionSettings(session, options) {
23606
23717
  permissionMode: options.permissionMode,
23607
23718
  workspaceWriteRoots
23608
23719
  };
23720
+ const launchModelChanged = !isDeepStrictEqual(
23721
+ launchModelSelection(session.construction),
23722
+ launchModelSelection(construction)
23723
+ );
23724
+ if (launchModelChanged && !session.supportsLoadSession) {
23725
+ throw new Error(
23726
+ "This ACP agent cannot restore its session. Start a new thread to change the launch-time model or reasoning level."
23727
+ );
23728
+ }
23609
23729
  const launchArgsChanged = !isDeepStrictEqual(
23610
23730
  permissionCliArgsForMode(
23611
23731
  session.construction.permissionCli,
@@ -23616,9 +23736,9 @@ function reconcileExecutionSettings(session, options) {
23616
23736
  construction.permissionMode
23617
23737
  )
23618
23738
  ) || !isDeepStrictEqual(
23619
- launchModelSelection(session.construction),
23620
- launchModelSelection(construction)
23621
- );
23739
+ dialectLaunchEnv(session.dialect.id, session.construction.permissionMode),
23740
+ dialectLaunchEnv(session.dialect.id, construction.permissionMode)
23741
+ ) || launchModelChanged;
23622
23742
  const restart = session.connection.exited || session.restartAfterCancelError || launchArgsChanged || !isDeepStrictEqual(envVars ?? {}, session.construction.envVars ?? {});
23623
23743
  cancelPendingPermissions(session);
23624
23744
  session.policy = {
@@ -24235,13 +24355,21 @@ function handleParsedMessage(parsed) {
24235
24355
  }
24236
24356
  var handleLine = createBridgeLineHandler({ handleParsedMessage });
24237
24357
  async function stopAllSessions() {
24358
+ const sessions = Array.from(sessionsByBbThreadId.values());
24359
+ const sessionConnections = new Set(
24360
+ sessions.map((session) => session.connection)
24361
+ );
24238
24362
  const results = await Promise.allSettled([
24239
- ...Array.from(
24240
- sessionsByBbThreadId.values(),
24241
- (session) => releaseSession(session)
24363
+ ...sessions.map(
24364
+ (session) => stopSession(session, SHUTDOWN_CANCEL_TIMEOUT_MS)
24242
24365
  ),
24243
- ...Array.from(agentConnections, (connection) => connection.kill())
24366
+ ...Array.from(agentConnections).filter((connection) => !sessionConnections.has(connection)).map((connection) => connection.kill())
24244
24367
  ]);
24368
+ results.push(
24369
+ ...await Promise.allSettled(
24370
+ Array.from(agentConnections, (connection) => connection.kill())
24371
+ )
24372
+ );
24245
24373
  for (const result of results) {
24246
24374
  if (result.status === "rejected") {
24247
24375
  process.stderr.write(
@@ -11841,20 +11841,6 @@ function versionFrom(value) {
11841
11841
  const candidate = value?.match(/\bv?(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)/u)?.[1];
11842
11842
  return candidate !== void 0 && (0, import_valid.default)(candidate) !== null ? candidate : null;
11843
11843
  }
11844
- async function readCliVersion(command) {
11845
- try {
11846
- const { stdout, stderr } = await execPortableFile(command, ["--version"], {
11847
- cwd: process.cwd(),
11848
- env: process.env,
11849
- maxBuffer: 1024 * 1024,
11850
- timeout: CLI_PROBE_TIMEOUT_MS
11851
- });
11852
- return versionFrom(`${stdout}
11853
- ${stderr}`);
11854
- } catch {
11855
- return null;
11856
- }
11857
- }
11858
11844
  function downloadedInstallerCommand(url2, options = {}) {
11859
11845
  if ((options.platform ?? process.platform) === "win32" && options.powershellUrl !== void 0) {
11860
11846
  const powershellScript = `irm ${options.powershellUrl} | iex`;
@@ -11909,7 +11895,7 @@ var ignoredJsonRpcResultSchema = z35.unknown();
11909
11895
 
11910
11896
  // ../provider-bridge-acp/src/bridge/bridge.ts
11911
11897
  import { randomBytes as randomBytes2 } from "node:crypto";
11912
- import { promises as fs4, readFileSync as readFileSync3 } from "node:fs";
11898
+ import { promises as fs4, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
11913
11899
  import { createServer } from "node:net";
11914
11900
  import { dirname as dirname2, isAbsolute as isAbsolute2, basename as basename4, relative as relative2, resolve as resolve4 } from "node:path";
11915
11901
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -12283,6 +12269,7 @@ var acpBridgeCommandMethodValues = acpBridgeCommandSchema.options.map(
12283
12269
  );
12284
12270
  var ACP_TURN_STARTED_METHOD = "acp/turn/started";
12285
12271
  var ACP_TURN_COMPLETED_METHOD = "acp/turn/completed";
12272
+ var ACP_PROMPT_INTERRUPTED_METHOD = "acp/prompt/interrupted";
12286
12273
  var ACP_COMPACTION_STARTED_METHOD = "acp/compaction/started";
12287
12274
  var ACP_COMPACTION_COMPLETED_METHOD = "acp/compaction/completed";
12288
12275
  var ACP_UPDATE_METHOD = "acp/update";
@@ -12691,6 +12678,23 @@ function healthResult(args) {
12691
12678
  }
12692
12679
  };
12693
12680
  }
12681
+ async function readAcpCliVersion(command) {
12682
+ try {
12683
+ const { stdout, stderr } = await execPortableFile(command, ["--version"], {
12684
+ cwd: process.cwd(),
12685
+ env: process.env,
12686
+ maxBuffer: 1024 * 1024,
12687
+ timeout: 5e3
12688
+ });
12689
+ const output = `${stdout}
12690
+ ${stderr}`;
12691
+ return versionFrom(output) ?? output.match(
12692
+ /(?:^|\s)(\d{4}\.(?:0[1-9]|1[0-2])\.(?:0[1-9]|[12]\d|3[01])-[0-9a-f]+)(?=\s|$)/u
12693
+ )?.[1] ?? null;
12694
+ } catch {
12695
+ return null;
12696
+ }
12697
+ }
12694
12698
  async function getAcpProviderHealth(args) {
12695
12699
  const maintenance = args.maintenance;
12696
12700
  if (args.command === null) {
@@ -12703,7 +12707,7 @@ async function getAcpProviderHealth(args) {
12703
12707
  if (await resolveExecutablePath(args.command) === null) {
12704
12708
  return healthResult({ maintenance, status: "not_installed" });
12705
12709
  }
12706
- const version = await readCliVersion(args.command);
12710
+ const version = await readAcpCliVersion(args.command);
12707
12711
  if (maintenance === void 0) {
12708
12712
  return healthResult({
12709
12713
  maintenance,
@@ -12732,7 +12736,7 @@ async function getAcpProviderInstallationStatus(args) {
12732
12736
  const executableName = args.command ?? "";
12733
12737
  const resolvedExecutable = args.command === null ? null : await resolveExecutablePath(args.command);
12734
12738
  const installed = resolvedExecutable !== null;
12735
- const currentVersion = installed && args.command !== null ? await readCliVersion(args.command) : null;
12739
+ const currentVersion = installed && args.command !== null ? await readAcpCliVersion(args.command) : null;
12736
12740
  const installAction = args.maintenance !== void 0 && !installed ? {
12737
12741
  kind: "install",
12738
12742
  label: "Install",
@@ -13308,25 +13312,35 @@ function fileChangeVerb(changes, fallback) {
13308
13312
  }
13309
13313
  return "update";
13310
13314
  }
13315
+ var DEV_NULL_OLD_TEXT = /^-{2,3} \/dev\/null$/u;
13316
+ var NEW_FILE_HEADER = /^\+{2,3} b\/[^\n]*(?:\n|$)/u;
13311
13317
  function buildAcpFileChanges(event, operation, options) {
13312
13318
  const changes = [];
13313
13319
  for (const entry of event.content ?? []) {
13314
13320
  if (entry.type !== "diff") {
13315
13321
  continue;
13316
13322
  }
13317
- const oldText = entry.oldText ?? void 0;
13323
+ const createsFile = entry.oldText === null || entry.oldText === void 0 || DEV_NULL_OLD_TEXT.test(entry.oldText);
13318
13324
  changes.push({
13319
13325
  path: resolveAcpToolCallPath(entry.path, options),
13320
- kind: oldText === void 0 ? "add" : "update",
13321
- ...oldText === void 0 ? {} : { oldText },
13322
- newText: entry.newText
13326
+ kind: createsFile ? "add" : "update",
13327
+ ...createsFile ? {} : { oldText: entry.oldText ?? void 0 },
13328
+ newText: createsFile ? entry.newText.replace(NEW_FILE_HEADER, "") : entry.newText
13323
13329
  });
13324
13330
  }
13325
13331
  if (changes.length > 0) {
13326
13332
  return changes;
13327
13333
  }
13328
13334
  const [path13] = operation.paths;
13329
- return path13 === void 0 ? [] : [{ path: path13, kind: operation.changeKind }];
13335
+ if (path13 === void 0) {
13336
+ return [];
13337
+ }
13338
+ return [
13339
+ {
13340
+ path: path13,
13341
+ kind: operation.changeKind === "update" && options?.existedBefore?.get(path13) === false ? "add" : operation.changeKind
13342
+ }
13343
+ ];
13330
13344
  }
13331
13345
  function fileChangeItem(changes, fallbackVerb) {
13332
13346
  return {
@@ -14218,6 +14232,34 @@ function createAcpDeltaTranslator(options = {}) {
14218
14232
  const dialect = options.dialect ?? GENERIC_ACP_DIALECT;
14219
14233
  const pathOptions = { cwd: options.cwd };
14220
14234
  const mergedToolCalls = /* @__PURE__ */ new Map();
14235
+ const fileExistence = /* @__PURE__ */ new Map();
14236
+ const filesAddedThisTurn = /* @__PURE__ */ new Set();
14237
+ function noteEditedPaths(key, event) {
14238
+ const fileCreatedThisTurn = options.fileCreatedThisTurn;
14239
+ if (fileCreatedThisTurn === void 0 || event.kind !== "edit") {
14240
+ return;
14241
+ }
14242
+ const seen = fileExistence.get(key) ?? /* @__PURE__ */ new Map();
14243
+ for (const location of event.locations ?? []) {
14244
+ const resolved = resolveAcpToolCallPath(location.path, pathOptions);
14245
+ if (seen.has(resolved)) {
14246
+ continue;
14247
+ }
14248
+ const created = fileCreatedThisTurn(resolved);
14249
+ if (created === void 0) {
14250
+ seen.set(resolved, void 0);
14251
+ continue;
14252
+ }
14253
+ const added = created && !filesAddedThisTurn.has(resolved);
14254
+ if (added) {
14255
+ filesAddedThisTurn.add(resolved);
14256
+ }
14257
+ seen.set(resolved, !added);
14258
+ }
14259
+ if (seen.size > 0) {
14260
+ fileExistence.set(key, seen);
14261
+ }
14262
+ }
14221
14263
  let lastUsageCost;
14222
14264
  let lastAgentTitle;
14223
14265
  let injectedToolsByName = /* @__PURE__ */ new Map();
@@ -14302,7 +14344,10 @@ function createAcpDeltaTranslator(options = {}) {
14302
14344
  return dialectShape;
14303
14345
  }
14304
14346
  }
14305
- return classifyAcpToolCall2(event, injected, pathOptions);
14347
+ return classifyAcpToolCall2(event, injected, {
14348
+ ...pathOptions,
14349
+ existedBefore: fileExistence.get(callKey(context, event.toolCallId))
14350
+ });
14306
14351
  }
14307
14352
  function withClientFileWrites(event, writes) {
14308
14353
  if (writes.length === 0) {
@@ -14473,6 +14518,7 @@ function createAcpDeltaTranslator(options = {}) {
14473
14518
  args.permissionTitle
14474
14519
  );
14475
14520
  injectedToolBindings.delete(callKey(args.context, args.event.toolCallId));
14521
+ fileExistence.delete(callKey(args.context, args.event.toolCallId));
14476
14522
  const closeFields = classified.item.type === "command" ? commandCloseFields(args.event, args.status) : genericCloseFields(args.event);
14477
14523
  return {
14478
14524
  kind: "item.close",
@@ -14570,6 +14616,7 @@ function createAcpDeltaTranslator(options = {}) {
14570
14616
  if (bound !== void 0) {
14571
14617
  injectedToolBindings.set(announcedKey, bound);
14572
14618
  }
14619
+ noteEditedPaths(announcedKey, event);
14573
14620
  if (isTerminalAcpStatus(event.status)) {
14574
14621
  return [
14575
14622
  ...flush,
@@ -14611,6 +14658,7 @@ function createAcpDeltaTranslator(options = {}) {
14611
14658
  mergeAcpToolCallEvents(open?.event, event),
14612
14659
  open?.clientFileWrites ?? []
14613
14660
  );
14661
+ noteEditedPaths(key, merged);
14614
14662
  if (isTerminalAcpStatus(merged.status)) {
14615
14663
  mergedToolCalls.delete(key);
14616
14664
  return [
@@ -14787,8 +14835,18 @@ function createAcpDeltaTranslator(options = {}) {
14787
14835
  return [];
14788
14836
  }
14789
14837
  clearThreadCalls(context);
14838
+ filesAddedThisTurn.clear();
14790
14839
  return [{ kind: "turn.open" }];
14791
14840
  }
14841
+ case ACP_PROMPT_INTERRUPTED_METHOD: {
14842
+ const params = acpTurnStartedNotificationParamsSchema.safeParse(
14843
+ envelope.data.params
14844
+ );
14845
+ if (!params.success) {
14846
+ return [];
14847
+ }
14848
+ return drainOpenToolCalls(context, "interrupted");
14849
+ }
14792
14850
  case ACP_TURN_COMPLETED_METHOD: {
14793
14851
  const params = acpTurnCompletedNotificationParamsSchema.safeParse(
14794
14852
  envelope.data.params
@@ -21429,6 +21487,7 @@ var pendingRuntimeRequests = /* @__PURE__ */ new Map();
21429
21487
  var runtimeRequestIdCounter = 0;
21430
21488
  var dynamicToolBridgePromise = null;
21431
21489
  var THREAD_STOP_CANCEL_TIMEOUT_MS = 4e3;
21490
+ var SHUTDOWN_CANCEL_TIMEOUT_MS = 1500;
21432
21491
  var AGENT_TURN_QUIET_MS = 5e3;
21433
21492
  var SESSION_BUSY_QUIET_MS = 2e3;
21434
21493
  var SESSION_BUSY_MAX_WAITS = 300;
@@ -22482,23 +22541,39 @@ async function selectAcpNativeServiceTier(args) {
22482
22541
  });
22483
22542
  recordAcpConfigValue(args.session, configState, fastOption.id, value);
22484
22543
  }
22485
- function textWithoutUnknownLeadingSkillCommand(session, item) {
22486
- const advertised = session.model.snapshot().commands;
22487
- if (advertised.length === 0) {
22488
- return item.text;
22489
- }
22490
- const firstCharacter = item.text.search(/\S/u);
22491
- const leading = item.mentions.find(
22492
- (mention) => mention.start === firstCharacter && mention.resource.kind === "command" && mention.resource.source === "skill" && mention.resource.trigger === "/"
22544
+ function textWithBbSkillCommandsSpelledOut(session, item) {
22545
+ const bbSkillNames = new Set(
22546
+ (configuredSkillRoots ?? []).flatMap(
22547
+ (root) => root.skills.map((skill) => skill.name)
22548
+ )
22493
22549
  );
22494
- if (!leading || leading.resource.kind !== "command") {
22550
+ if (bbSkillNames.size === 0) {
22495
22551
  return item.text;
22496
22552
  }
22497
- const name = leading.resource.name;
22498
- if (advertised.some((command) => command.name === name)) {
22499
- return item.text;
22553
+ const advertised = new Set(
22554
+ session.model.snapshot().commands.map((command) => command.name)
22555
+ );
22556
+ const mentions = item.mentions.flatMap(
22557
+ (mention) => mention.resource.kind === "command" && mention.resource.source === "skill" && mention.resource.trigger === "/" && bbSkillNames.has(mention.resource.name) && !advertised.has(mention.resource.name) && item.text.slice(mention.start, mention.end) === `/${mention.resource.name}` ? [
22558
+ {
22559
+ start: mention.start,
22560
+ end: mention.end,
22561
+ name: mention.resource.name
22562
+ }
22563
+ ] : []
22564
+ ).sort((a2, b) => b.start - a2.start);
22565
+ const firstCharacter = item.text.search(/\S/u);
22566
+ let text = item.text;
22567
+ let nextStart = text.length;
22568
+ for (const mention of mentions) {
22569
+ if (mention.end > nextStart) {
22570
+ continue;
22571
+ }
22572
+ const leadsText = mention.start === firstCharacter && text.slice(mention.end).trim().length > 0;
22573
+ text = `${text.slice(0, mention.start)}Use the bb skill "${mention.name}"${leadsText ? ":" : ""}${text.slice(mention.end)}`;
22574
+ nextStart = mention.start;
22500
22575
  }
22501
- return `${item.text.slice(0, leading.start)}Use the bb skill "${name}":${item.text.slice(leading.end)}`;
22576
+ return text;
22502
22577
  }
22503
22578
  function buildPromptContentBlocks(session, input) {
22504
22579
  const blocks = [];
@@ -22512,12 +22587,12 @@ ${instructions}
22512
22587
  </system_instructions>`
22513
22588
  });
22514
22589
  }
22515
- for (const [index, item] of input.entries()) {
22590
+ for (const item of input) {
22516
22591
  switch (item.type) {
22517
22592
  case "text":
22518
22593
  blocks.push({
22519
22594
  type: "text",
22520
- text: index === 0 ? textWithoutUnknownLeadingSkillCommand(session, item) : item.text
22595
+ text: textWithBbSkillCommandsSpelledOut(session, item)
22521
22596
  });
22522
22597
  break;
22523
22598
  case "image":
@@ -22817,6 +22892,33 @@ function getSessionByProviderThreadId(providerThreadId) {
22817
22892
  const bbThreadId = bbThreadIdByProviderThreadId.get(providerThreadId);
22818
22893
  return bbThreadId ? sessionsByBbThreadId.get(bbThreadId) : void 0;
22819
22894
  }
22895
+ function fileCreatedSince(path13, sinceMs) {
22896
+ if (sinceMs === void 0) {
22897
+ return void 0;
22898
+ }
22899
+ try {
22900
+ const { birthtimeMs } = statSync2(path13);
22901
+ return birthtimeMs > 0 ? birthtimeMs >= sinceMs : void 0;
22902
+ } catch {
22903
+ return void 0;
22904
+ }
22905
+ }
22906
+ function dialectLaunchEnv(dialectId, permissionMode) {
22907
+ if (dialectId !== "opencode") {
22908
+ return {};
22909
+ }
22910
+ const outsideEdits = permissionMode === "full" ? "allow" : "ask";
22911
+ return {
22912
+ OPENCODE_CLIENT: "acp",
22913
+ OPENCODE_ENABLE_QUESTION_TOOL: "false",
22914
+ OPENCODE_PERMISSION: JSON.stringify({
22915
+ edit: "allow",
22916
+ bash: outsideEdits,
22917
+ webfetch: outsideEdits,
22918
+ external_directory: outsideEdits
22919
+ })
22920
+ };
22921
+ }
22820
22922
  async function startAgentSession(request) {
22821
22923
  const params = request.params;
22822
22924
  const bbThreadId = params.threadId;
@@ -22830,7 +22932,8 @@ async function startAgentSession(request) {
22830
22932
  });
22831
22933
  const translator = createAcpDeltaTranslator({
22832
22934
  cwd: params.cwd,
22833
- dialect
22935
+ dialect,
22936
+ fileCreatedThisTurn: (path13) => fileCreatedSince(path13, session.turnStartedAtMs)
22834
22937
  });
22835
22938
  translator.configureInjectedTools(
22836
22939
  (params.dynamicTools ?? []).map((tool) => ({
@@ -22859,7 +22962,7 @@ async function startAgentSession(request) {
22859
22962
  const childEnv = {
22860
22963
  ...withoutBridgeRuntimeEnv(process.env),
22861
22964
  ...params.envVars,
22862
- ...dialect.id === "opencode" ? { OPENCODE_CLIENT: "acp", OPENCODE_ENABLE_QUESTION_TOOL: "false" } : {}
22965
+ ...dialectLaunchEnv(dialect.id, params.permissionMode)
22863
22966
  };
22864
22967
  const connection = createBridgeAgentConnection({
22865
22968
  command: params.agent.command,
@@ -22917,6 +23020,7 @@ async function startAgentSession(request) {
22917
23020
  queuedInputs: [],
22918
23021
  promptRequestPending: false,
22919
23022
  cancelRequested: false,
23023
+ turnStartedAtMs: void 0,
22920
23024
  restartAfterCancelError: false,
22921
23025
  loading: false,
22922
23026
  loadingSessionId: void 0,
@@ -23125,7 +23229,7 @@ async function startAgentSession(request) {
23125
23229
  });
23126
23230
  }
23127
23231
  }
23128
- async function stopSession(session) {
23232
+ async function stopSession(session, cancelTimeoutMs = THREAD_STOP_CANCEL_TIMEOUT_MS) {
23129
23233
  if (session.stopping) {
23130
23234
  return;
23131
23235
  }
@@ -23143,7 +23247,7 @@ async function stopSession(session) {
23143
23247
  await Promise.race([
23144
23248
  session.turnSettled,
23145
23249
  new Promise(
23146
- (resolveTimeout) => setTimeout(resolveTimeout, THREAD_STOP_CANCEL_TIMEOUT_MS)
23250
+ (resolveTimeout) => setTimeout(resolveTimeout, cancelTimeoutMs)
23147
23251
  )
23148
23252
  ]);
23149
23253
  }
@@ -23425,6 +23529,7 @@ function finishTurn(session, stopReason) {
23425
23529
  if (session.activePromptKind !== "turn") {
23426
23530
  return;
23427
23531
  }
23532
+ session.turnStartedAtMs = void 0;
23428
23533
  for (const controller of session.pendingToolCalls) controller.abort();
23429
23534
  setActivePromptKind(session, null);
23430
23535
  dropQueuedTurnInputs(session, "ACP turn ended before the steer was sent");
@@ -23503,6 +23608,7 @@ function runTurn(session, firstInput, turnAlreadyOpen = false) {
23503
23608
  const prompt = buildPromptContentBlocks(session, pending.input);
23504
23609
  let inputAccepted = false;
23505
23610
  let busyRetries = 0;
23611
+ session.turnStartedAtMs ??= Date.now();
23506
23612
  for (; ; ) {
23507
23613
  session.promptRequestPending = true;
23508
23614
  const promptResult = session.connection.request({
@@ -23563,6 +23669,11 @@ function runTurn(session, firstInput, turnAlreadyOpen = false) {
23563
23669
  if (!session.stopping) {
23564
23670
  const next = session.queuedInputs.shift();
23565
23671
  if (next) {
23672
+ if (stopReason === "cancelled") {
23673
+ emitForSession(session, ACP_PROMPT_INTERRUPTED_METHOD, {
23674
+ threadId: session.bbThreadId
23675
+ });
23676
+ }
23566
23677
  pending = next;
23567
23678
  continue;
23568
23679
  }
@@ -23606,6 +23717,15 @@ function reconcileExecutionSettings(session, options) {
23606
23717
  permissionMode: options.permissionMode,
23607
23718
  workspaceWriteRoots
23608
23719
  };
23720
+ const launchModelChanged = !isDeepStrictEqual(
23721
+ launchModelSelection(session.construction),
23722
+ launchModelSelection(construction)
23723
+ );
23724
+ if (launchModelChanged && !session.supportsLoadSession) {
23725
+ throw new Error(
23726
+ "This ACP agent cannot restore its session. Start a new thread to change the launch-time model or reasoning level."
23727
+ );
23728
+ }
23609
23729
  const launchArgsChanged = !isDeepStrictEqual(
23610
23730
  permissionCliArgsForMode(
23611
23731
  session.construction.permissionCli,
@@ -23616,9 +23736,9 @@ function reconcileExecutionSettings(session, options) {
23616
23736
  construction.permissionMode
23617
23737
  )
23618
23738
  ) || !isDeepStrictEqual(
23619
- launchModelSelection(session.construction),
23620
- launchModelSelection(construction)
23621
- );
23739
+ dialectLaunchEnv(session.dialect.id, session.construction.permissionMode),
23740
+ dialectLaunchEnv(session.dialect.id, construction.permissionMode)
23741
+ ) || launchModelChanged;
23622
23742
  const restart = session.connection.exited || session.restartAfterCancelError || launchArgsChanged || !isDeepStrictEqual(envVars ?? {}, session.construction.envVars ?? {});
23623
23743
  cancelPendingPermissions(session);
23624
23744
  session.policy = {
@@ -24235,13 +24355,21 @@ function handleParsedMessage(parsed) {
24235
24355
  }
24236
24356
  var handleLine = createBridgeLineHandler({ handleParsedMessage });
24237
24357
  async function stopAllSessions() {
24358
+ const sessions = Array.from(sessionsByBbThreadId.values());
24359
+ const sessionConnections = new Set(
24360
+ sessions.map((session) => session.connection)
24361
+ );
24238
24362
  const results = await Promise.allSettled([
24239
- ...Array.from(
24240
- sessionsByBbThreadId.values(),
24241
- (session) => releaseSession(session)
24363
+ ...sessions.map(
24364
+ (session) => stopSession(session, SHUTDOWN_CANCEL_TIMEOUT_MS)
24242
24365
  ),
24243
- ...Array.from(agentConnections, (connection) => connection.kill())
24366
+ ...Array.from(agentConnections).filter((connection) => !sessionConnections.has(connection)).map((connection) => connection.kill())
24244
24367
  ]);
24368
+ results.push(
24369
+ ...await Promise.allSettled(
24370
+ Array.from(agentConnections, (connection) => connection.kill())
24371
+ )
24372
+ );
24245
24373
  for (const result of results) {
24246
24374
  if (result.status === "rejected") {
24247
24375
  process.stderr.write(
@@ -1550,9 +1550,9 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
1550
1550
  );
1551
1551
  }
1552
1552
  const extensions = rawExtensions.map((extension) => {
1553
- if (typeof extension !== "string" || !/^[a-z0-9]+$/.test(extension)) {
1553
+ if (typeof extension !== "string" || !/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(extension)) {
1554
1554
  throw new Error(
1555
- `${kind}: extensions must be lowercase alphanumerics without the dot, got ${JSON.stringify(extension)}`
1555
+ `${kind}: extensions must be lowercase alphanumerics with single underscores or hyphens between segments, without the dot, got ${JSON.stringify(extension)}`
1556
1556
  );
1557
1557
  }
1558
1558
  return extension;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.6.59",
3
+ "version": "0.6.60",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"
@@ -137,7 +137,7 @@
137
137
  "clean": "rimraf bundled-types dist tsconfig.tsbuildinfo",
138
138
  "prepack": "node scripts/build-bundled-dts.mjs && node scripts/build-runtime.mjs",
139
139
  "test": "vitest run --config vitest.config.ts",
140
- "typecheck": "tsc --noEmit"
140
+ "typecheck": "tsrs --noEmit"
141
141
  },
142
142
  "dependencies": {
143
143
  "cross-spawn": "^7.0.6",
@@ -164,8 +164,8 @@
164
164
  "react-dom": "^19.0.0",
165
165
  "rollup": "^4.62.2",
166
166
  "rollup-plugin-dts": "^6.4.1",
167
+ "tsrs": "0.18.0-ts7.1.0-dev.20260929",
167
168
  "typescript": "npm:@typescript/typescript6@^6.0.2",
168
- "typescript-7": "npm:typescript@^7.0.2",
169
169
  "vitest": "^4.1.1"
170
170
  },
171
171
  "peerDependencies": {