@get-bb/plugin-sdk 0.6.94 → 0.6.104

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.
@@ -987,13 +987,13 @@ async function invalidateTags(client, scope, tags) {
987
987
  }
988
988
  async function executeTaggedMutation(invalidate, call, prediction) {
989
989
  const { result, invalidated } = await call();
990
- prediction?.accept(result);
990
+ prediction.accept(result);
991
991
  const refresh = async () => {
992
992
  try {
993
993
  if (invalidate !== void 0 && invalidated.length > 0)
994
994
  await invalidate(invalidated);
995
995
  } finally {
996
- prediction?.settle();
996
+ prediction.settle();
997
997
  }
998
998
  };
999
999
  void refresh().catch(() => {
@@ -1508,7 +1508,7 @@ var sessionOptionSelectionsSchema = z2.record(
1508
1508
  var runtimeThreadExecutionBaseOptionsSchema = z2.object({
1509
1509
  model: z2.string().min(1),
1510
1510
  serviceTier: serviceTierSchema,
1511
- reasoningLevel: reasoningLevelSchema,
1511
+ reasoningLevel: reasoningLevelSchema.optional(),
1512
1512
  promptMode: promptModeSchema.optional(),
1513
1513
  sessionOptions: sessionOptionSelectionsSchema.optional(),
1514
1514
  providerOptions: jsonObjectSchema
@@ -2034,6 +2034,7 @@ var SYSTEM_CHANGE_KINDS = [
2034
2034
  "plugin-install-jobs-changed",
2035
2035
  "plugin-update-jobs-changed",
2036
2036
  "provider-registrations-changed",
2037
+ "ui-preferences-changed",
2037
2038
  "environment-availability-changed",
2038
2039
  "server-move-changed",
2039
2040
  "app-update-changed"
@@ -2191,11 +2192,6 @@ var systemChangedMessageSchema = z17.object({
2191
2192
  entity: z17.literal("system"),
2192
2193
  changes: z17.array(systemChangeKindSchema).readonly()
2193
2194
  }).strict();
2194
- var tagsChangedMessageSchema = z17.object({
2195
- type: z17.literal("changed"),
2196
- entity: z17.literal("tags"),
2197
- tags: z17.array(z17.string().min(1)).min(1)
2198
- }).strict();
2199
2195
  var pluginChangedMessageSchema = z17.object({
2200
2196
  type: z17.literal("changed"),
2201
2197
  entity: z17.literal("plugin"),
@@ -2208,7 +2204,6 @@ var changedMessageSchema = z17.discriminatedUnion("entity", [
2208
2204
  environmentChangedMessageSchema,
2209
2205
  hostChangedMessageSchema,
2210
2206
  systemChangedMessageSchema,
2211
- tagsChangedMessageSchema,
2212
2207
  pluginChangedMessageSchema
2213
2208
  ]);
2214
2209
  function lenientKinds(kinds) {
@@ -2268,7 +2263,6 @@ var changedMessageLenientSchema = z17.discriminatedUnion("entity", [
2268
2263
  environmentChangedMessageLenientSchema,
2269
2264
  hostChangedMessageLenientSchema,
2270
2265
  systemChangedMessageLenientSchema,
2271
- tagsChangedMessageSchema.strip(),
2272
2266
  pluginChangedMessageSchema.strip()
2273
2267
  ]);
2274
2268
 
@@ -3856,6 +3850,8 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3856
3850
  threadInfoRows: [],
3857
3851
  threadRowMetadata: [],
3858
3852
  threadInfoSections: [],
3853
+ threadContextCardRows: [],
3854
+ threadContextCardSections: [],
3859
3855
  threadActions: [],
3860
3856
  browserToolbarActions: [],
3861
3857
  fileOpeners: [],
@@ -3865,6 +3861,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3865
3861
  messageDirectives: [],
3866
3862
  codeFenceRenderers: [],
3867
3863
  messageActions: [],
3864
+ messageMetadata: [],
3868
3865
  commandPaletteActions: [],
3869
3866
  providerIcons: [],
3870
3867
  icons: [],
@@ -3893,6 +3890,8 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3893
3890
  threadInfoRow: /* @__PURE__ */ new Set(),
3894
3891
  threadRowMetadata: /* @__PURE__ */ new Set(),
3895
3892
  threadInfoSection: /* @__PURE__ */ new Set(),
3893
+ threadContextCardRow: /* @__PURE__ */ new Set(),
3894
+ threadContextCardSection: /* @__PURE__ */ new Set(),
3896
3895
  threadAction: /* @__PURE__ */ new Set(),
3897
3896
  browserToolbarAction: /* @__PURE__ */ new Set(),
3898
3897
  fileOpener: /* @__PURE__ */ new Set(),
@@ -3903,6 +3902,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3903
3902
  codeFenceRenderer: /* @__PURE__ */ new Set(),
3904
3903
  codeFenceLanguage: /* @__PURE__ */ new Set(),
3905
3904
  messageAction: /* @__PURE__ */ new Set(),
3905
+ messageMetadata: /* @__PURE__ */ new Set(),
3906
3906
  command: /* @__PURE__ */ new Set(),
3907
3907
  providerIcon: /* @__PURE__ */ new Set(),
3908
3908
  timelineRenderer: /* @__PURE__ */ new Set(),
@@ -4295,6 +4295,29 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4295
4295
  component: requireComponent(kind, registration.component)
4296
4296
  });
4297
4297
  },
4298
+ experimental_threadContextCardRow(registration) {
4299
+ const kind = "slots.experimental_threadContextCardRow";
4300
+ const id = requireSlotId(kind, registration?.id);
4301
+ requireUniqueId(kind, seenIds.threadContextCardRow, id);
4302
+ collected.threadContextCardRows.push({
4303
+ id,
4304
+ group: requireNonEmptyString(kind, "group", registration.group),
4305
+ ...requireOptionalOrder(kind, registration.order),
4306
+ component: requireComponent(kind, registration.component)
4307
+ });
4308
+ },
4309
+ experimental_threadContextCardSection(registration) {
4310
+ const kind = "slots.experimental_threadContextCardSection";
4311
+ const id = requireSlotId(kind, registration?.id);
4312
+ requireUniqueId(kind, seenIds.threadContextCardSection, id);
4313
+ collected.threadContextCardSections.push({
4314
+ id,
4315
+ title: requireNonEmptyString(kind, "title", registration.title),
4316
+ group: requireNonEmptyString(kind, "group", registration.group),
4317
+ ...requireOptionalOrder(kind, registration.order),
4318
+ component: requireComponent(kind, registration.component)
4319
+ });
4320
+ },
4298
4321
  experimental_threadAction(registration) {
4299
4322
  const kind = "slots.experimental_threadAction";
4300
4323
  const id = requireSlotId(kind, registration?.id);
@@ -4442,6 +4465,22 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4442
4465
  run: registration.run
4443
4466
  });
4444
4467
  },
4468
+ experimental_messageMetadata(registration) {
4469
+ const kind = "slots.experimental_messageMetadata";
4470
+ const id = requireSlotId(kind, registration?.id);
4471
+ requireUniqueId(kind, seenIds.messageMetadata, id);
4472
+ const placement = registration.placement ?? "above";
4473
+ if (placement !== "above" && placement !== "actionRow") {
4474
+ throw new Error(
4475
+ `${kind}: "placement" must be "above" or "actionRow"`
4476
+ );
4477
+ }
4478
+ collected.messageMetadata.push({
4479
+ id,
4480
+ placement,
4481
+ component: requireComponent(kind, registration.component)
4482
+ });
4483
+ },
4445
4484
  commandPaletteAction(registration) {
4446
4485
  registerCommand(registration);
4447
4486
  },
@@ -4677,7 +4716,9 @@ function TestThreadStatusGlyph({
4677
4716
  }
4678
4717
  );
4679
4718
  }
4680
- function TestThreadRowMetadata({ thread }) {
4719
+ function TestThreadRowMetadata({
4720
+ thread
4721
+ }) {
4681
4722
  return /* @__PURE__ */ jsx("span", { "data-thread-row-metadata": thread.id });
4682
4723
  }
4683
4724
  function SlotLifecycleGuard({
@@ -5434,6 +5475,46 @@ function TestDetailRow({ label, icon, children }) {
5434
5475
  /* @__PURE__ */ jsx("dd", { children })
5435
5476
  ] });
5436
5477
  }
5478
+ var NO_PANEL_TABS = {
5479
+ open: false,
5480
+ selectedKey: null,
5481
+ tabs: []
5482
+ };
5483
+ function TestPanelTabIcon({ tabKey }) {
5484
+ return /* @__PURE__ */ jsx("span", { "data-panel-tab-icon": tabKey });
5485
+ }
5486
+ function TestThreadContextCardRow(props) {
5487
+ const { icon, leading, label, trailing, title, disabled, action } = props;
5488
+ const content = /* @__PURE__ */ jsxs(Fragment2, { children: [
5489
+ leading,
5490
+ label,
5491
+ trailing
5492
+ ] });
5493
+ const main = props.onClick !== void 0 ? /* @__PURE__ */ jsx(
5494
+ "button",
5495
+ {
5496
+ type: "button",
5497
+ "data-testid": "bb-thread-context-card-row",
5498
+ "data-icon": icon,
5499
+ title,
5500
+ disabled,
5501
+ onClick: () => props.onClick?.(),
5502
+ children: content
5503
+ }
5504
+ ) : /* @__PURE__ */ jsx(
5505
+ "div",
5506
+ {
5507
+ "data-testid": "bb-thread-context-card-row",
5508
+ "data-icon": icon,
5509
+ title,
5510
+ children: content
5511
+ }
5512
+ );
5513
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
5514
+ main,
5515
+ action
5516
+ ] });
5517
+ }
5437
5518
  function TestInfoList({
5438
5519
  items,
5439
5520
  getKey,
@@ -5509,6 +5590,9 @@ var testPluginSdkApp = {
5509
5590
  experimental_useExperiment(key) {
5510
5591
  return useSlotEnv("experimental_useExperiment").experiments.has(key);
5511
5592
  },
5593
+ experimental_useThreadContextKind() {
5594
+ return useSlotEnv("experimental_useThreadContextKind").threadContextKind;
5595
+ },
5512
5596
  useBbContext() {
5513
5597
  return useSlotEnv("useBbContext").bbContext;
5514
5598
  },
@@ -5524,6 +5608,9 @@ var testPluginSdkApp = {
5524
5608
  experimental_useAppPanel() {
5525
5609
  return useSlotEnv("experimental_useAppPanel").appPanel;
5526
5610
  },
5611
+ experimental_usePanelTabs() {
5612
+ return useSlotEnv("experimental_usePanelTabs").panelTabs;
5613
+ },
5527
5614
  experimental_useFixedTabTarget(tab) {
5528
5615
  const store = useSlotEnv("experimental_useFixedTabTarget").fixedTabTarget;
5529
5616
  const state = useSyncExternalStore2(
@@ -5621,6 +5708,8 @@ var testPluginSdkApp = {
5621
5708
  experimental_Diff: TestDiff,
5622
5709
  experimental_InfoSection: TestInfoSection,
5623
5710
  experimental_DetailRow: TestDetailRow,
5711
+ experimental_ThreadContextCardRow: TestThreadContextCardRow,
5712
+ experimental_PanelTabIcon: TestPanelTabIcon,
5624
5713
  experimental_InfoList: TestInfoList,
5625
5714
  experimental_InfoListRow: TestInfoListRow,
5626
5715
  experimental_useSidebarThreads() {
@@ -5640,6 +5729,9 @@ var testPluginSdkApp = {
5640
5729
  experimental_useTabVisible() {
5641
5730
  return useSlotEnv("experimental_useTabVisible").tabVisible;
5642
5731
  },
5732
+ experimental_useServers() {
5733
+ return useSlotEnv("experimental_useServers").servers;
5734
+ },
5643
5735
  experimental_copyToClipboard(content) {
5644
5736
  return activeClipboard?.(content) ?? Promise.resolve(true);
5645
5737
  },
@@ -6105,6 +6197,17 @@ function renderSlot(registration, props, options = {}) {
6105
6197
  if (json === null) return false;
6106
6198
  return options.experimental_panel?.toggleTab?.(json) ?? false;
6107
6199
  },
6200
+ getTabs() {
6201
+ return options.experimental_panel?.getTabs?.() ?? options.experimental_panelTabs ?? NO_PANEL_TABS;
6202
+ },
6203
+ selectTab(key) {
6204
+ experimental_panelCalls.push({ method: "selectTab", key });
6205
+ return options.experimental_panel?.selectTab?.(key) ?? false;
6206
+ },
6207
+ closeTab(key) {
6208
+ experimental_panelCalls.push({ method: "closeTab", key });
6209
+ return options.experimental_panel?.closeTab?.(key) ?? false;
6210
+ },
6108
6211
  close() {
6109
6212
  experimental_panelCalls.push({ method: "close" });
6110
6213
  return options.experimental_panel?.close?.() ?? false;
@@ -6581,12 +6684,16 @@ ${block}
6581
6684
  pluginId: options.pluginId ?? "test-plugin",
6582
6685
  questionFormHost: {
6583
6686
  shortcuts: /* @__PURE__ */ new Map(),
6687
+ actionShortcuts: /* @__PURE__ */ new Map(),
6584
6688
  registerChoiceHandler: () => () => {
6689
+ },
6690
+ registerActionHandler: () => () => {
6585
6691
  }
6586
6692
  },
6587
6693
  navigate,
6588
6694
  navigateCalls,
6589
6695
  appPanel,
6696
+ panelTabs: options.experimental_panelTabs ?? NO_PANEL_TABS,
6590
6697
  fixedTabTarget,
6591
6698
  composer,
6592
6699
  composerLog,
@@ -6601,6 +6708,7 @@ ${block}
6601
6708
  threadActionRegistrations: options.threadActionRegistrations ?? NO_THREAD_ACTION_REGISTRATIONS,
6602
6709
  sidebarDraftThreadIds,
6603
6710
  experiments: new Set(options.experiments ?? []),
6711
+ threadContextKind: options.threadContextKind ?? "banner",
6604
6712
  sidebarRowStatuses,
6605
6713
  sidebarShortcuts,
6606
6714
  sidebarSplitLayout: options.sidebarSplitLayout ?? null,
@@ -6612,6 +6720,7 @@ ${block}
6612
6720
  codeTheme,
6613
6721
  canOpenFileExternally: options.canOpenFileExternally ?? (() => false),
6614
6722
  tabVisible: options.tabVisible ?? true,
6723
+ servers: options.servers ?? null,
6615
6724
  branchesState: {
6616
6725
  branches: options.branchesState?.branches ?? [],
6617
6726
  remoteBranches: options.branchesState?.remoteBranches ?? [],
@@ -560,7 +560,10 @@ function registerSettingDescriptors(target, added) {
560
560
  `invalid setting key "${key}" \u2014 use letters, digits, "-" and "_"`
561
561
  );
562
562
  }
563
- if (key in target) {
563
+ if (key === "__proto__") {
564
+ throw new Error(`setting key "${key}" is reserved`);
565
+ }
566
+ if (Object.hasOwn(target, key)) {
564
567
  throw new Error(`setting "${key}" is already defined`);
565
568
  }
566
569
  const parsed = settingDescriptorSchema.safeParse(raw);
@@ -623,7 +626,10 @@ function settingSchemaError(key, schema, value) {
623
626
  function validateSettingsUpdate(descriptors, values) {
624
627
  const errors = [];
625
628
  for (const [key, value] of Object.entries(values)) {
626
- const descriptor = descriptors[key];
629
+ const descriptor = Object.hasOwn(
630
+ descriptors,
631
+ key
632
+ ) ? descriptors[key] : void 0;
627
633
  if (!descriptor) {
628
634
  errors.push(`unknown setting "${key}"`);
629
635
  continue;
@@ -2255,9 +2261,7 @@ function runPluginStorageMigrations(database, statements) {
2255
2261
  if (!migrationColumns.some((column) => column.name === "statement_hash")) {
2256
2262
  database.exec("ALTER TABLE _bb_migrations ADD COLUMN statement_hash TEXT");
2257
2263
  }
2258
- const rows = database.prepare(
2259
- "SELECT id, statement_hash FROM _bb_migrations ORDER BY id"
2260
- ).all();
2264
+ const rows = database.prepare("SELECT id, statement_hash FROM _bb_migrations ORDER BY id").all();
2261
2265
  const applied = /* @__PURE__ */ new Map();
2262
2266
  for (const row of rows) applied.set(row.id, row.statement_hash);
2263
2267
  const statementHashes = statements.map(migrationStatementHash);
@@ -3175,6 +3179,7 @@ function createFakePluginHostInternal(options, sharedState) {
3175
3179
  assertLive();
3176
3180
  if (!databaseHandle?.open) {
3177
3181
  databaseHandle = new Database(join(storageRoot, "data.db"));
3182
+ databaseHandle.pragma("journal_mode = WAL");
3178
3183
  databaseHandle.pragma("busy_timeout = 5000");
3179
3184
  }
3180
3185
  return databaseHandle;
@@ -3905,9 +3910,11 @@ function createFakePluginHostInternal(options, sharedState) {
3905
3910
  installHandlers.push(handler);
3906
3911
  }
3907
3912
  };
3913
+ const hostLifetime = new AbortController();
3908
3914
  async function disposeHost(cleanupStorage) {
3909
3915
  if (disposed) return;
3910
3916
  disposed = true;
3917
+ hostLifetime.abort();
3911
3918
  for (const [id, pending] of pendingInteractions) {
3912
3919
  clearTimeout(pending.timer);
3913
3920
  pendingInteractions.delete(id);
@@ -4170,7 +4177,8 @@ function createFakePluginHostInternal(options, sharedState) {
4170
4177
  result = await record.handler(validatedInput, {
4171
4178
  experimental_caller: options2.experimental_caller ?? {
4172
4179
  kind: "client"
4173
- }
4180
+ },
4181
+ experimental_signal: options2.signal === void 0 ? hostLifetime.signal : AbortSignal.any([options2.signal, hostLifetime.signal])
4174
4182
  });
4175
4183
  } catch (error) {
4176
4184
  const refusal = readPluginRpcRefusal(error);
@@ -4744,6 +4752,17 @@ function makeTurnFailedEvent(overrides = {}) {
4744
4752
  ...overrides
4745
4753
  };
4746
4754
  }
4755
+ function makePanelController(overrides = {}) {
4756
+ return {
4757
+ openTab: () => false,
4758
+ toggleTab: () => false,
4759
+ close: () => false,
4760
+ getTabs: () => ({ open: false, selectedKey: null, tabs: [] }),
4761
+ selectTab: () => false,
4762
+ closeTab: () => false,
4763
+ ...overrides
4764
+ };
4765
+ }
4747
4766
 
4748
4767
  // src/testing/public-sdk-only.ts
4749
4768
  import { readdirSync, readFileSync } from "node:fs";
@@ -5189,6 +5208,7 @@ export {
5189
5208
  PluginContextStaleError,
5190
5209
  createFakePluginHost,
5191
5210
  createFakeSdk,
5211
+ makePanelController as experimental_makePanelController,
5192
5212
  scanPublicSdkOnly as experimental_scanPublicSdkOnly,
5193
5213
  makeHostResponse,
5194
5214
  makeMessageDispatchHookContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.6.94",
3
+ "version": "0.6.104",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"