@get-bb/plugin-sdk 0.6.33 → 0.6.39

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.
@@ -2,7 +2,9 @@
2
2
  import * as React from "react";
3
3
  import {
4
4
  createContext,
5
+ useCallback,
5
6
  useContext,
7
+ useLayoutEffect,
6
8
  useEffect,
7
9
  useMemo,
8
10
  useRef,
@@ -104,6 +106,7 @@ var mentionSchema = z.discriminatedUnion("kind", [
104
106
  origin: z.enum(["builtin", "project", "user"]),
105
107
  argumentHint: z.string().nullable()
106
108
  }),
109
+ z.object({ ...range, kind: z.literal("attachment"), path: z.string() }),
107
110
  z.object({
108
111
  ...range,
109
112
  kind: z.literal("plugin"),
@@ -954,6 +957,14 @@ function normalizeExperimentalFileOpenOptions(value) {
954
957
  return { target, location };
955
958
  }
956
959
 
960
+ // src/thread-action-groups.ts
961
+ var experimental_THREAD_ACTION_GROUPS = {
962
+ open: "1_open",
963
+ organize: "2_organize",
964
+ settings: "3_settings",
965
+ lifecycle: "4_lifecycle"
966
+ };
967
+
957
968
  // src/internal/plugin-app-collector.ts
958
969
  import { z as z2 } from "zod";
959
970
  var sidebarFooterCommandSequence = 0;
@@ -1176,6 +1187,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1176
1187
  experimentalSidebarFooterItems: [],
1177
1188
  threadLists: [],
1178
1189
  threadHeaderActions: [],
1190
+ threadActions: [],
1179
1191
  browserToolbarActions: [],
1180
1192
  fileOpeners: [],
1181
1193
  sourceCodeRenderers: [],
@@ -1204,6 +1216,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1204
1216
  sidebarFooterItem: /* @__PURE__ */ new Set(),
1205
1217
  threadList: /* @__PURE__ */ new Set(),
1206
1218
  threadHeaderAction: /* @__PURE__ */ new Set(),
1219
+ threadAction: /* @__PURE__ */ new Set(),
1207
1220
  browserToolbarAction: /* @__PURE__ */ new Set(),
1208
1221
  fileOpener: /* @__PURE__ */ new Set(),
1209
1222
  sourceCodeRenderer: /* @__PURE__ */ new Set(),
@@ -1440,6 +1453,29 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1440
1453
  component: requireComponent(kind, registration.component)
1441
1454
  });
1442
1455
  },
1456
+ experimental_threadAction(registration) {
1457
+ const kind = "slots.experimental_threadAction";
1458
+ const id = requireSlotId(kind, registration?.id);
1459
+ requireUniqueId(kind, seenIds.threadAction, id);
1460
+ if (typeof registration.item !== "function") {
1461
+ throw new Error(`${kind}: "item" must be a function`);
1462
+ }
1463
+ if (registration.useData !== void 0 && typeof registration.useData !== "function") {
1464
+ throw new Error(`${kind}: "useData" must be a function`);
1465
+ }
1466
+ if (registration.order !== void 0 && !Number.isFinite(registration.order)) {
1467
+ throw new Error(`${kind}: "order" must be a finite number`);
1468
+ }
1469
+ collected.threadActions.push({
1470
+ id,
1471
+ title: requireNonEmptyString(kind, "title", registration.title),
1472
+ icon: requireNonEmptyString(kind, "icon", registration.icon),
1473
+ group: requireNonEmptyString(kind, "group", registration.group),
1474
+ ...registration.order !== void 0 ? { order: registration.order } : {},
1475
+ ...registration.useData !== void 0 ? { useData: registration.useData } : {},
1476
+ item: registration.item
1477
+ });
1478
+ },
1443
1479
  experimental_browserToolbarAction(registration) {
1444
1480
  const kind = "slots.experimental_browserToolbarAction";
1445
1481
  const id = requireSlotId(kind, registration?.id);
@@ -1654,6 +1690,7 @@ function testComposerMentionText(mention) {
1654
1690
  case "command":
1655
1691
  return `${mention.trigger}${mention.name}`;
1656
1692
  case "plugin":
1693
+ case "attachment":
1657
1694
  return `@${mention.label}`;
1658
1695
  case "path": {
1659
1696
  const path = mention.source === "thread-storage" ? `thread-storage:${mention.path}` : mention.path;
@@ -1694,6 +1731,25 @@ function TestThreadTitle({ threadId }) {
1694
1731
  if (thread === void 0) return null;
1695
1732
  return /* @__PURE__ */ jsx("span", { "data-thread-title": threadId, children: thread.displayTitle });
1696
1733
  }
1734
+ function TestThreadStatusGlyph({
1735
+ indicator,
1736
+ archived = false,
1737
+ rowStatus = null,
1738
+ hideIdleDraftLabel = false,
1739
+ size = "default"
1740
+ }) {
1741
+ if (!archived && indicator === "none" && rowStatus === null) return null;
1742
+ return /* @__PURE__ */ jsx(
1743
+ "span",
1744
+ {
1745
+ "data-thread-status-glyph": archived ? "archived" : indicator,
1746
+ "data-row-status": rowStatus?.label,
1747
+ "data-row-status-tone": rowStatus?.tone,
1748
+ "data-hide-idle-draft-label": hideIdleDraftLabel ? "" : void 0,
1749
+ "data-size": size
1750
+ }
1751
+ );
1752
+ }
1697
1753
  function SlotLifecycleGuard({
1698
1754
  children,
1699
1755
  onUnmount
@@ -1702,6 +1758,161 @@ function SlotLifecycleGuard({
1702
1758
  return children;
1703
1759
  }
1704
1760
  var SlotEnvContext = createContext(null);
1761
+ var NO_THREAD_ACTIONS = () => [];
1762
+ var NO_THREAD_ACTION_REGISTRATIONS = [];
1763
+ function noRenameEditor() {
1764
+ }
1765
+ function useTestThreadActions(hook, thread, options) {
1766
+ const entries = useSlotEnv(hook).threadActions(thread, {
1767
+ requestRename: options?.requestRename ?? noRenameEditor
1768
+ });
1769
+ const keys = options?.keys;
1770
+ if (keys === void 0) return entries;
1771
+ return keys.flatMap((key) => {
1772
+ const entry = entries.find((candidate) => candidate.key === key);
1773
+ return entry === void 0 ? [] : [entry];
1774
+ });
1775
+ }
1776
+ function TestThreadActionsMenuItems({
1777
+ hook,
1778
+ thread,
1779
+ inline = [],
1780
+ requestRename,
1781
+ onClose
1782
+ }) {
1783
+ const rename = requestRename ?? noRenameEditor;
1784
+ const entries = useTestThreadActions(hook, thread, { requestRename: rename });
1785
+ const rows = [
1786
+ ...entries.map((entry) => ({
1787
+ key: entry.key,
1788
+ action: entry.action,
1789
+ run: () => entry.action.run()
1790
+ })),
1791
+ ...inline.map((item) => ({
1792
+ key: item.key,
1793
+ action: item.action,
1794
+ run: () => item.action.run({ requestRename: rename })
1795
+ }))
1796
+ ];
1797
+ return /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": "Thread actions", children: rows.map((row) => /* @__PURE__ */ jsx(
1798
+ "button",
1799
+ {
1800
+ type: "button",
1801
+ role: "menuitem",
1802
+ "data-thread-action": row.key,
1803
+ disabled: row.action.disabled,
1804
+ onClick: () => {
1805
+ void row.run();
1806
+ onClose();
1807
+ },
1808
+ children: row.action.label
1809
+ },
1810
+ row.key
1811
+ )) });
1812
+ }
1813
+ function useTestMenuOpenState({
1814
+ onOpenChange,
1815
+ onCloseAutoFocus
1816
+ }) {
1817
+ const [open, setOpen] = useState(false);
1818
+ return {
1819
+ open,
1820
+ show: () => {
1821
+ setOpen(true);
1822
+ onOpenChange?.(true);
1823
+ },
1824
+ close: () => {
1825
+ setOpen(false);
1826
+ onOpenChange?.(false);
1827
+ onCloseAutoFocus?.(new Event("focus", { cancelable: true }));
1828
+ }
1829
+ };
1830
+ }
1831
+ var TEST_TRIGGER_HOST_CLASS = "bb-test-thread-actions-trigger";
1832
+ function TestThreadActionsMenu({
1833
+ thread,
1834
+ trigger,
1835
+ inline,
1836
+ requestRename,
1837
+ onOpenChange,
1838
+ onCloseAutoFocus
1839
+ }) {
1840
+ const menu = useTestMenuOpenState({ onOpenChange, onCloseAutoFocus });
1841
+ const triggerElement = useRef(null);
1842
+ useLayoutEffect(() => {
1843
+ const element = triggerElement.current;
1844
+ if (element?.getAttribute("aria-haspopup") !== "menu") {
1845
+ throw new Error(
1846
+ "experimental_ThreadActionsMenu: `trigger` must spread the props and ref it receives onto the button it renders, or the menu never opens"
1847
+ );
1848
+ }
1849
+ if (!element.classList.contains(TEST_TRIGGER_HOST_CLASS)) {
1850
+ throw new Error(
1851
+ "experimental_ThreadActionsMenu: `trigger` replaced the host's className; merge props.className into its own"
1852
+ );
1853
+ }
1854
+ });
1855
+ return /* @__PURE__ */ jsxs("span", { "data-testid": "bb-thread-actions-menu", "data-thread-id": thread.id, children: [
1856
+ trigger({
1857
+ ref: triggerElement,
1858
+ type: "button",
1859
+ className: TEST_TRIGGER_HOST_CLASS,
1860
+ "aria-haspopup": "menu",
1861
+ "aria-expanded": menu.open,
1862
+ onClick: menu.show
1863
+ }),
1864
+ menu.open ? /* @__PURE__ */ jsx(
1865
+ TestThreadActionsMenuItems,
1866
+ {
1867
+ hook: "experimental_ThreadActionsMenu",
1868
+ thread,
1869
+ inline,
1870
+ requestRename,
1871
+ onClose: menu.close
1872
+ }
1873
+ ) : null
1874
+ ] });
1875
+ }
1876
+ function TestThreadActionsContextMenu({
1877
+ thread,
1878
+ children,
1879
+ inline,
1880
+ requestRename,
1881
+ onOpenChange,
1882
+ onCloseAutoFocus,
1883
+ disabled,
1884
+ dragging
1885
+ }) {
1886
+ const menu = useTestMenuOpenState({ onOpenChange, onCloseAutoFocus });
1887
+ return /* @__PURE__ */ jsxs(
1888
+ "div",
1889
+ {
1890
+ "data-testid": "bb-thread-actions-context-menu",
1891
+ "data-thread-id": thread.id,
1892
+ "data-disabled": disabled === true ? "true" : "false",
1893
+ "data-dragging": dragging === true ? "true" : "false",
1894
+ className: "contents",
1895
+ onContextMenu: (event) => {
1896
+ if (disabled === true || dragging === true) return;
1897
+ event.preventDefault();
1898
+ menu.show();
1899
+ },
1900
+ children: [
1901
+ children,
1902
+ menu.open ? /* @__PURE__ */ jsx(
1903
+ TestThreadActionsMenuItems,
1904
+ {
1905
+ hook: "experimental_ThreadActionsContextMenu",
1906
+ thread,
1907
+ inline,
1908
+ requestRename,
1909
+ onClose: menu.close
1910
+ }
1911
+ ) : null
1912
+ ]
1913
+ }
1914
+ );
1915
+ }
1705
1916
  function useSlotEnv(hook) {
1706
1917
  const env = useContext(SlotEnvContext);
1707
1918
  if (!env) {
@@ -2277,6 +2488,30 @@ var testPluginSdkApp = {
2277
2488
  experimental_useSidebarThreadActions() {
2278
2489
  return useSlotEnv("experimental_useSidebarThreadActions").sidebarActions;
2279
2490
  },
2491
+ experimental_useThreadActions(thread, options) {
2492
+ return useTestThreadActions(
2493
+ "experimental_useThreadActions",
2494
+ thread,
2495
+ options
2496
+ );
2497
+ },
2498
+ experimental_useArchiveEnvironmentThreads() {
2499
+ const calls = useSlotEnv(
2500
+ "experimental_useArchiveEnvironmentThreads"
2501
+ ).environmentArchiveCalls;
2502
+ return useCallback(
2503
+ async (environmentId) => {
2504
+ calls.push(environmentId);
2505
+ },
2506
+ [calls]
2507
+ );
2508
+ },
2509
+ experimental_useThreadActionRegistrations() {
2510
+ return useSlotEnv("experimental_useThreadActionRegistrations").threadActionRegistrations;
2511
+ },
2512
+ experimental_ThreadActionsMenu: TestThreadActionsMenu,
2513
+ experimental_ThreadActionsContextMenu: TestThreadActionsContextMenu,
2514
+ experimental_THREAD_ACTION_GROUPS,
2280
2515
  experimental_useSidebarThreadSplit(threadId) {
2281
2516
  const env = useSlotEnv("experimental_useSidebarThreadSplit");
2282
2517
  return useMemo(
@@ -2317,6 +2552,7 @@ var testPluginSdkApp = {
2317
2552
  return env.sidebarShortcuts.get(threadId) ?? null;
2318
2553
  },
2319
2554
  ThreadTitle: TestThreadTitle,
2555
+ experimental_ThreadStatusGlyph: TestThreadStatusGlyph,
2320
2556
  useEnvironmentProviders() {
2321
2557
  return useSlotEnv("useEnvironmentProviders").environmentProviders;
2322
2558
  },
@@ -2609,6 +2845,7 @@ function renderSlot(registration, props, options = {}) {
2609
2845
  }
2610
2846
  };
2611
2847
  const sidebarActionCalls = [];
2848
+ const environmentArchiveCalls = [];
2612
2849
  const sidebarPullRequests = new Map(
2613
2850
  Object.entries(options.sidebarPullRequests ?? {})
2614
2851
  );
@@ -2684,8 +2921,12 @@ function renderSlot(registration, props, options = {}) {
2684
2921
  }
2685
2922
  };
2686
2923
  const navigate = {
2687
- toThread(threadId2) {
2688
- navigateCalls.push({ method: "toThread", threadId: threadId2 });
2924
+ toThread(threadId2, threadOptions) {
2925
+ navigateCalls.push({
2926
+ method: "toThread",
2927
+ threadId: threadId2,
2928
+ ...threadOptions !== void 0 ? { options: threadOptions } : {}
2929
+ });
2689
2930
  },
2690
2931
  toProject(projectId2) {
2691
2932
  navigateCalls.push({ method: "toProject", projectId: projectId2 });
@@ -2989,6 +3230,9 @@ ${block}
2989
3230
  sidebarThreads,
2990
3231
  sidebarActions,
2991
3232
  sidebarActionCalls,
3233
+ environmentArchiveCalls,
3234
+ threadActions: options.threadActions ?? NO_THREAD_ACTIONS,
3235
+ threadActionRegistrations: options.threadActionRegistrations ?? NO_THREAD_ACTION_REGISTRATIONS,
2992
3236
  sidebarPullRequests,
2993
3237
  sidebarDraftThreadIds,
2994
3238
  sidebarRowStatuses,
@@ -3065,6 +3309,7 @@ ${block}
3065
3309
  navigateCalls,
3066
3310
  experimental_fixedTabOpenCalls,
3067
3311
  sidebarActionCalls,
3312
+ experimental_environmentArchiveCalls: environmentArchiveCalls,
3068
3313
  sdkCalls,
3069
3314
  experimental_clipboardWrites,
3070
3315
  composer: composerLog,
@@ -3079,6 +3324,7 @@ ${block}
3079
3324
  navigateCalls,
3080
3325
  experimental_fixedTabOpenCalls,
3081
3326
  sidebarActionCalls,
3327
+ experimental_environmentArchiveCalls: environmentArchiveCalls,
3082
3328
  sdkCalls,
3083
3329
  experimental_clipboardWrites,
3084
3330
  composer: composerLog
@@ -445,6 +445,7 @@ var settingDescriptorSchema = z5.discriminatedUnion("type", [
445
445
  type: z5.literal("select"),
446
446
  ...settingsBaseFields,
447
447
  options: z5.array(z5.string().min(1)).min(1),
448
+ experimental_optionLabels: z5.record(z5.string().min(1), z5.string().min(1)).optional(),
448
449
  experimental_schema: stringSettingSchemaSchema.optional(),
449
450
  default: z5.string().optional()
450
451
  }).strict(),
@@ -480,6 +481,16 @@ function registerSettingDescriptors(target, added) {
480
481
  `default for setting "${key}" must be one of its options`
481
482
  );
482
483
  }
484
+ if (descriptor.type === "select") {
485
+ const unknownLabel = Object.keys(
486
+ descriptor.experimental_optionLabels ?? {}
487
+ ).find((option) => !descriptor.options.includes(option));
488
+ if (unknownLabel !== void 0) {
489
+ throw new Error(
490
+ `label for setting "${key}" names "${unknownLabel}", which is not one of its options`
491
+ );
492
+ }
493
+ }
483
494
  if (descriptor.default !== void 0) {
484
495
  const errors = validateSettingsUpdate(
485
496
  { [key]: descriptor },
@@ -1076,13 +1087,12 @@ function validateProviderFallbackModels(providerId, value) {
1076
1087
  `provider "${providerId}" ${field}.supportedReasoningEfforts[${effortIndex}] must be { reasoningEffort, description }`
1077
1088
  );
1078
1089
  }
1079
- const reasoningEffort = Reflect.get(effort, "reasoningEffort");
1080
- if (typeof reasoningEffort !== "string" || !PLUGIN_PROVIDER_REASONING_LEVEL_VALUES.includes(reasoningEffort)) {
1081
- throw new Error(
1082
- `provider "${providerId}" ${field}.supportedReasoningEfforts[${effortIndex}].reasoningEffort must be one of ${PLUGIN_PROVIDER_REASONING_LEVEL_VALUES.join(", ")}`
1083
- );
1084
- }
1085
- const level = reasoningEffort;
1090
+ const level = requireNonBlankString({
1091
+ providerId,
1092
+ field: `${field}.supportedReasoningEfforts[${effortIndex}].reasoningEffort`,
1093
+ value: Reflect.get(effort, "reasoningEffort")
1094
+ });
1095
+ const label = Reflect.get(effort, "label");
1086
1096
  if (levels.has(level)) {
1087
1097
  throw new Error(
1088
1098
  `provider "${providerId}" ${field}.supportedReasoningEfforts repeats ${JSON.stringify(level)}`
@@ -1091,6 +1101,13 @@ function validateProviderFallbackModels(providerId, value) {
1091
1101
  levels.add(level);
1092
1102
  return Object.freeze({
1093
1103
  reasoningEffort: level,
1104
+ ...label === void 0 ? {} : {
1105
+ label: requireNonBlankString({
1106
+ providerId,
1107
+ field: `${field}.supportedReasoningEfforts[${effortIndex}].label`,
1108
+ value: label
1109
+ })
1110
+ },
1094
1111
  description: requireNonBlankString({
1095
1112
  providerId,
1096
1113
  field: `${field}.supportedReasoningEfforts[${effortIndex}].description`,
@@ -2823,6 +2840,7 @@ function normalizeCallArgs(pluginId, path, args) {
2823
2840
  case "threads.fork":
2824
2841
  return withThreadAttribution(pluginId, args);
2825
2842
  case "threads.getPluginMetadata":
2843
+ case "threads.experimental_listPluginMetadata":
2826
2844
  return withPluginMetadataTarget(pluginId, args, false);
2827
2845
  case "threads.updatePluginMetadata":
2828
2846
  return withPluginMetadataTarget(pluginId, args, true);
@@ -3304,6 +3322,7 @@ function createFakePluginHostInternal(options, sharedState) {
3304
3322
  });
3305
3323
  const threadEventHandlers = {
3306
3324
  "experimental_thread.events": [],
3325
+ "experimental_thread.parentChanged": [],
3307
3326
  "experimental_terminal.input": [],
3308
3327
  "experimental_host.deleted": [],
3309
3328
  "experimental_environment.removed": [],
@@ -3743,6 +3762,7 @@ function createFakePluginHostInternal(options, sharedState) {
3743
3762
  get threadEventHandlers() {
3744
3763
  return {
3745
3764
  "experimental_thread.events": threadEventHandlers["experimental_thread.events"].length,
3765
+ "experimental_thread.parentChanged": threadEventHandlers["experimental_thread.parentChanged"].length,
3746
3766
  "experimental_terminal.input": threadEventHandlers["experimental_terminal.input"].length,
3747
3767
  "experimental_environment.removed": threadEventHandlers["experimental_environment.removed"].length,
3748
3768
  "experimental_host.deleted": threadEventHandlers["experimental_host.deleted"].length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.6.33",
3
+ "version": "0.6.39",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"
@@ -44,6 +44,12 @@
44
44
  "import": "./dist/provider-bridge-acp.js",
45
45
  "default": "./dist/provider-bridge-acp.js"
46
46
  },
47
+ "./provider-bridge/acp-next": {
48
+ "source": "./src/provider-bridge-acp-next.ts",
49
+ "types": "./bundled-types/bb-plugin-sdk-provider-bridge-acp-next.d.ts",
50
+ "import": "./dist/provider-bridge-acp-next.js",
51
+ "default": "./dist/provider-bridge-acp-next.js"
52
+ },
47
53
  "./environment-provider": {
48
54
  "source": "./src/environment-provider.ts",
49
55
  "types": "./bundled-types/bb-plugin-sdk-environment-provider.d.ts",
@@ -141,6 +147,7 @@
141
147
  "@bb/domain": "workspace:*",
142
148
  "@bb/process-utils": "workspace:*",
143
149
  "@bb/provider-bridge-acp": "workspace:*",
150
+ "@bb/provider-bridge-acp-next": "workspace:*",
144
151
  "@bb/provider-bridge-protocol": "workspace:*",
145
152
  "@bb/sdk": "workspace:*",
146
153
  "@bb/server-contract": "workspace:*",