@get-bb/plugin-sdk 0.6.52 → 0.6.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -131,6 +131,15 @@ var experimental_useSidebarThreadPullRequest = runtimeFunction(
131
131
  var experimental_useSidebarThreadSplit = runtimeFunction(
132
132
  "experimental_useSidebarThreadSplit"
133
133
  );
134
+ var experimental_useSidebarNavigation = runtimeFunction(
135
+ "experimental_useSidebarNavigation"
136
+ );
137
+ var experimental_useSidebarNavigationSplit = runtimeFunction(
138
+ "experimental_useSidebarNavigationSplit"
139
+ );
140
+ var experimental_SidebarNavigationIcon = runtimeComponent(
141
+ "experimental_SidebarNavigationIcon"
142
+ );
134
143
  var useSidebarThreadDraft = runtimeFunction("useSidebarThreadDraft");
135
144
  var useSidebarThreadDraftIds = runtimeFunction(
136
145
  "useSidebarThreadDraftIds"
@@ -177,6 +186,7 @@ export {
177
186
  experimental_PermissionModePicker,
178
187
  experimental_ProviderIcon,
179
188
  experimental_ProviderModelPicker,
189
+ experimental_SidebarNavigationIcon,
180
190
  experimental_SourceCode,
181
191
  experimental_THREAD_ACTION_GROUPS,
182
192
  experimental_ThreadActionsContextMenu,
@@ -194,6 +204,8 @@ export {
194
204
  experimental_usePluginId,
195
205
  experimental_useProviders,
196
206
  experimental_useQuestionFormHost,
207
+ experimental_useSidebarNavigation,
208
+ experimental_useSidebarNavigationSplit,
197
209
  experimental_useSidebarThreadActions,
198
210
  experimental_useSidebarThreadPullRequest,
199
211
  experimental_useSidebarThreadSplit,
package/dist/host.js CHANGED
@@ -805,6 +805,155 @@ function spawnPortableOutputProcess(request) {
805
805
  return child;
806
806
  }
807
807
 
808
+ // ../process-utils/src/vcs-process-scheduler.ts
809
+ import { AsyncLocalStorage } from "node:async_hooks";
810
+ import { availableParallelism } from "node:os";
811
+ var ranks = { interactive: 0, status: 1, background: 2 };
812
+ function localProcessCapacities(parallelism) {
813
+ const total = Math.min(6, Math.max(4, parallelism - 2));
814
+ return [total, total - 1, total - 2];
815
+ }
816
+ var capacities = {
817
+ local: localProcessCapacities(availableParallelism()),
818
+ network: [4, 3, 2]
819
+ };
820
+ var githubCapacity = 2;
821
+ var agingMs = 15e3;
822
+ var networkGitSubcommands = /* @__PURE__ */ new Set([
823
+ "fetch",
824
+ "pull",
825
+ "push",
826
+ "clone",
827
+ "ls-remote"
828
+ ]);
829
+ var gitGlobalOptionsWithValue = /* @__PURE__ */ new Set([
830
+ "-C",
831
+ "-c",
832
+ "--git-dir",
833
+ "--work-tree",
834
+ "--namespace",
835
+ "--config-env"
836
+ ]);
837
+ function isNetworkGitCommand(args) {
838
+ let index = 0;
839
+ while (index < args.length && args[index].startsWith("-")) {
840
+ index += gitGlobalOptionsWithValue.has(args[index]) ? 2 : 1;
841
+ }
842
+ const subcommand = args[index];
843
+ if (subcommand === void 0) return false;
844
+ if (networkGitSubcommands.has(subcommand)) return true;
845
+ const action = args.slice(index + 1).find((arg) => !arg.startsWith("-"));
846
+ return (subcommand === "submodule" || subcommand === "remote") && action === "update";
847
+ }
848
+ var VcsProcessScheduler = class {
849
+ priority = new AsyncLocalStorage();
850
+ admitted = new AsyncLocalStorage();
851
+ active = { local: 0, network: 0 };
852
+ githubActive = 0;
853
+ queue = [];
854
+ timer;
855
+ acquire(command, args, options) {
856
+ const pool = command === "gh" || isNetworkGitCommand(args) ? "network" : "local";
857
+ const slots = options.slots ?? 1;
858
+ if (!Number.isInteger(slots) || slots < 1 || slots > capacities[pool][ranks.background]) {
859
+ return Promise.reject(new Error("Invalid VCS process slot count"));
860
+ }
861
+ if (options.signal?.aborted) {
862
+ return Promise.reject(this.abortError(options.signal));
863
+ }
864
+ return new Promise((grant, reject) => {
865
+ const waiter = {
866
+ command,
867
+ pool,
868
+ priority: options.priority ?? this.priority.getStore() ?? "status",
869
+ slots,
870
+ queuedAt: performance.now(),
871
+ signal: options.signal,
872
+ grant,
873
+ onAbort: () => {
874
+ const index = this.queue.indexOf(waiter);
875
+ if (index === -1) return;
876
+ this.queue.splice(index, 1);
877
+ reject(this.abortError(options.signal));
878
+ this.drain();
879
+ }
880
+ };
881
+ this.queue.push(waiter);
882
+ options.signal?.addEventListener("abort", waiter.onAbort, { once: true });
883
+ this.drain();
884
+ });
885
+ }
886
+ abortError(signal) {
887
+ return Object.assign(
888
+ new Error("The operation was aborted", { cause: signal?.reason }),
889
+ {
890
+ name: "AbortError",
891
+ code: "ABORT_ERR"
892
+ }
893
+ );
894
+ }
895
+ rank(waiter) {
896
+ return Math.max(
897
+ 0,
898
+ ranks[waiter.priority] - Math.floor((performance.now() - waiter.queuedAt) / agingMs)
899
+ );
900
+ }
901
+ drain() {
902
+ clearTimeout(this.timer);
903
+ this.queue.sort(
904
+ (a, b) => this.rank(a) - this.rank(b) || a.queuedAt - b.queuedAt
905
+ );
906
+ const blocked = /* @__PURE__ */ new Set();
907
+ for (let index = 0; index < this.queue.length; ) {
908
+ const waiter = this.queue[index];
909
+ if (blocked.has(waiter.pool) || waiter.command === "gh" && this.githubActive + waiter.slots > githubCapacity) {
910
+ index += 1;
911
+ continue;
912
+ }
913
+ if (this.active[waiter.pool] + waiter.slots > capacities[waiter.pool][this.rank(waiter)]) {
914
+ blocked.add(waiter.pool);
915
+ index += 1;
916
+ continue;
917
+ }
918
+ this.queue.splice(index, 1);
919
+ waiter.signal?.removeEventListener("abort", waiter.onAbort);
920
+ this.active[waiter.pool] += waiter.slots;
921
+ if (waiter.command === "gh") this.githubActive += waiter.slots;
922
+ let released = false;
923
+ waiter.grant(() => {
924
+ if (released) return;
925
+ released = true;
926
+ this.active[waiter.pool] -= waiter.slots;
927
+ if (waiter.command === "gh") this.githubActive -= waiter.slots;
928
+ this.drain();
929
+ });
930
+ }
931
+ if (this.queue.length > 0) {
932
+ const delay2 = Math.min(
933
+ ...this.queue.map(
934
+ (waiter) => agingMs - (performance.now() - waiter.queuedAt) % agingMs
935
+ )
936
+ );
937
+ this.timer = setTimeout(() => this.drain(), delay2);
938
+ }
939
+ }
940
+ };
941
+ var registry = globalThis;
942
+ var scheduler = registry.__bbVcsProcessScheduler ??= new VcsProcessScheduler();
943
+ async function runVcsProcess(command, args, operation, options = {}) {
944
+ if (scheduler.admitted.getStore()) {
945
+ options.signal?.throwIfAborted();
946
+ return operation();
947
+ }
948
+ const release = await scheduler.acquire(command, args, options);
949
+ try {
950
+ options.signal?.throwIfAborted();
951
+ return await scheduler.admitted.run(true, operation);
952
+ } finally {
953
+ release();
954
+ }
955
+ }
956
+
808
957
  // ../process-utils/src/cwd-processes.ts
809
958
  import { lstat, readdir, readlink, realpath } from "node:fs/promises";
810
959
  import { basename, dirname, join, resolve, sep } from "node:path";
@@ -1037,11 +1186,6 @@ function parseElapsedSeconds(rawElapsed) {
1037
1186
  return ((days * 24 + hours) * 60 + minutes) * 60 + seconds;
1038
1187
  }
1039
1188
 
1040
- // ../process-utils/src/performance-diagnostics.ts
1041
- import { Session } from "node:inspector/promises";
1042
- var PROFILE_RETENTION_MS = 12 * 60 * 60 * 1e3;
1043
- var MAX_PROFILE_BYTES = 12 * 1024 * 1024;
1044
-
1045
1189
  // src/kill-processes.ts
1046
1190
  function experimental_killProcessesWithCwdUnder(args) {
1047
1191
  if ("directory" in args && typeof args.directory === "string")
@@ -1066,6 +1210,7 @@ export {
1066
1210
  experimental_readProcessIdentity,
1067
1211
  experimental_resolveClaudePluginRoots,
1068
1212
  experimental_resolveVendorPluginRoots,
1213
+ runVcsProcess as experimental_runVcsProcess,
1069
1214
  sanitizeInheritedChildProcessEnv as experimental_sanitizeInheritedChildProcessEnv,
1070
1215
  spawnPortableOutputProcess as experimental_spawnPortableOutputProcess
1071
1216
  };
@@ -378,21 +378,30 @@ var NAV_PANEL_REGISTRATION_KEYS = new Set(
378
378
  path: true,
379
379
  component: true,
380
380
  fixedTabs: true,
381
- experimental_sidebarAccessory: true,
381
+ experimental_useBadge: true,
382
382
  headerContent: true
383
383
  })
384
384
  );
385
385
  var RENAMED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
386
- ["experimental_fixedTabs", "fixedTabs"]
386
+ ["experimental_fixedTabs", 'was renamed to "fixedTabs" in SDK 0.4.16']
387
387
  ]);
388
- function rejectStaleNavPanelKeys(kind, registration) {
388
+ var RETIRED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
389
+ [
390
+ "experimental_sidebarAccessory",
391
+ 'is ignored: it was replaced by "experimental_useBadge", a hook returning a badge value, in SDK 0.6.53'
392
+ ]
393
+ ]);
394
+ function checkStaleNavPanelKeys(kind, registration, onWarning) {
389
395
  for (const key of Object.keys(registration)) {
390
396
  if (NAV_PANEL_REGISTRATION_KEYS.has(key)) continue;
391
- const renamedTo = RENAMED_NAV_PANEL_KEYS.get(key);
392
- if (renamedTo !== void 0) {
393
- throw new Error(
394
- `${kind}: "${key}" was renamed to "${renamedTo}" in SDK 0.4.16`
395
- );
397
+ const renamed = RENAMED_NAV_PANEL_KEYS.get(key);
398
+ if (renamed !== void 0) {
399
+ throw new Error(`${kind}: "${key}" ${renamed}`);
400
+ }
401
+ const retired = RETIRED_NAV_PANEL_KEYS.get(key);
402
+ if (retired !== void 0) {
403
+ onWarning(`${kind}: "${key}" ${retired}`);
404
+ continue;
396
405
  }
397
406
  if (key.startsWith("experimental_")) {
398
407
  throw new Error(`${kind}: unknown field "${key}"`);
@@ -457,7 +466,7 @@ function collectPanelAction(kind, seen, registration) {
457
466
  ...registration.run !== void 0 ? { run: registration.run } : {}
458
467
  };
459
468
  }
460
- function collectPluginAppRegistrations(definition, onComposerCustomizationRejected = (reason) => console.warn(reason)) {
469
+ function collectPluginAppRegistrations(definition, onWarning = (message) => console.warn(message)) {
461
470
  const sidebarFooterItems = [];
462
471
  const collected = {
463
472
  homepageSections: [],
@@ -471,6 +480,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
471
480
  sidebarFooterActions: [],
472
481
  experimentalSidebarFooterItems: [],
473
482
  threadLists: [],
483
+ experimentalSidebarNavigations: [],
474
484
  threadHeaderActions: [],
475
485
  threadActions: [],
476
486
  browserToolbarActions: [],
@@ -501,6 +511,8 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
501
511
  pendingInteraction: /* @__PURE__ */ new Set(),
502
512
  sidebarFooterItem: /* @__PURE__ */ new Set(),
503
513
  threadList: /* @__PURE__ */ new Set(),
514
+ sidebarNavigation: /* @__PURE__ */ new Set(),
515
+ sidebarHeader: /* @__PURE__ */ new Set(),
504
516
  threadHeaderAction: /* @__PURE__ */ new Set(),
505
517
  threadAction: /* @__PURE__ */ new Set(),
506
518
  browserToolbarAction: /* @__PURE__ */ new Set(),
@@ -550,9 +562,22 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
550
562
  run: registration.run
551
563
  });
552
564
  }
565
+ const legacySidebarHeaders = [];
566
+ const legacySlotAliases = {
567
+ experimental_sidebarHeader(registration) {
568
+ legacySidebarHeaders.push(
569
+ collectTitledComponent(
570
+ "slots.experimental_sidebarHeader",
571
+ seenIds.sidebarHeader,
572
+ registration
573
+ ).component
574
+ );
575
+ }
576
+ };
553
577
  definition.setup({
554
578
  commands: { register: registerCommand },
555
579
  slots: {
580
+ ...legacySlotAliases,
556
581
  homepageSection(registration) {
557
582
  const kind = "slots.homepageSection";
558
583
  const id = requireSlotId(kind, registration?.id);
@@ -598,7 +623,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
598
623
  const kind = "slots.navPanel";
599
624
  const id = requireSlotId(kind, registration?.id);
600
625
  requireUniqueId(kind, seenIds.navPanel, id);
601
- rejectStaleNavPanelKeys(kind, registration);
626
+ checkStaleNavPanelKeys(kind, registration, onWarning);
602
627
  const panelId = id;
603
628
  const path = requireNonEmptyString(kind, "path", registration.path);
604
629
  if (!PLUGIN_SLOT_ID_PATTERN.test(path)) {
@@ -611,9 +636,9 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
611
636
  `${kind}: "headerContent" must be a React component function when set`
612
637
  );
613
638
  }
614
- if (registration.experimental_sidebarAccessory !== void 0 && typeof registration.experimental_sidebarAccessory !== "function") {
639
+ if (registration.experimental_useBadge !== void 0 && typeof registration.experimental_useBadge !== "function") {
615
640
  throw new Error(
616
- `${kind}: "experimental_sidebarAccessory" must be a React component function when set`
641
+ `${kind}: "experimental_useBadge" must be a React hook function when set`
617
642
  );
618
643
  }
619
644
  const fixedTabs = (() => {
@@ -673,8 +698,8 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
673
698
  path,
674
699
  component: requireComponent(kind, registration.component),
675
700
  ...fixedTabs.length > 0 ? { fixedTabs } : {},
676
- ...registration.experimental_sidebarAccessory !== void 0 ? {
677
- experimental_sidebarAccessory: registration.experimental_sidebarAccessory
701
+ ...registration.experimental_useBadge !== void 0 ? {
702
+ experimental_useBadge: registration.experimental_useBadge
678
703
  } : {},
679
704
  ...registration.headerContent !== void 0 ? { headerContent: registration.headerContent } : {}
680
705
  });
@@ -731,6 +756,29 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
731
756
  )
732
757
  );
733
758
  },
759
+ experimental_sidebarNavigation(registration) {
760
+ const kind = "slots.experimental_sidebarNavigation";
761
+ const collectedRegistration = collectTitledComponent(
762
+ kind,
763
+ seenIds.sidebarNavigation,
764
+ registration
765
+ );
766
+ const placement = registration.placement;
767
+ if (placement !== void 0 && placement !== "rail" && placement !== "list") {
768
+ throw new Error(`${kind}: "placement" must be "rail" or "list"`);
769
+ }
770
+ const headerComponent = registration.headerComponent;
771
+ if (headerComponent !== void 0 && typeof headerComponent !== "function") {
772
+ throw new Error(
773
+ `${kind}: "headerComponent" must be a React component function`
774
+ );
775
+ }
776
+ collected.experimentalSidebarNavigations.push({
777
+ ...collectedRegistration,
778
+ placement: placement ?? "list",
779
+ ...headerComponent !== void 0 ? { headerComponent } : {}
780
+ });
781
+ },
734
782
  experimental_threadHeaderAction(registration) {
735
783
  const kind = "slots.experimental_threadHeaderAction";
736
784
  const id = requireSlotId(kind, registration?.id);
@@ -940,7 +988,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
940
988
  const customization = collectComposerCustomization(
941
989
  registration,
942
990
  seenIds.composerCustomization,
943
- onComposerCustomizationRejected,
991
+ (reason) => onWarning(`composer customization rejected: ${reason}`),
944
992
  seenIds.composerPopup
945
993
  );
946
994
  if (customization !== null) {
@@ -980,8 +1028,34 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
980
1028
  }
981
1029
  }
982
1030
  });
1031
+ attachLegacySidebarHeaders(
1032
+ collected.experimentalSidebarNavigations,
1033
+ legacySidebarHeaders,
1034
+ onWarning
1035
+ );
983
1036
  return collected;
984
1037
  }
1038
+ function attachLegacySidebarHeaders(navigations, headers, onWarning) {
1039
+ const [header, ...extraHeaders] = headers;
1040
+ if (header === void 0) return;
1041
+ const kind = "slots.experimental_sidebarHeader";
1042
+ if (extraHeaders.length > 0) {
1043
+ onWarning(
1044
+ `${kind}: only the first header is used; pass "headerComponent" to each experimental_sidebarNavigation instead`
1045
+ );
1046
+ }
1047
+ let attached = false;
1048
+ navigations.forEach((navigation, index) => {
1049
+ if (navigation.headerComponent !== void 0) return;
1050
+ navigations[index] = { ...navigation, headerComponent: header };
1051
+ attached = true;
1052
+ });
1053
+ if (!attached) {
1054
+ onWarning(
1055
+ `${kind}: ignored because the plugin registers no navigation without a "headerComponent"`
1056
+ );
1057
+ }
1058
+ }
985
1059
  export {
986
1060
  adaptSidebarFooterAction,
987
1061
  collectPluginAppRegistrations,