@get-bb/plugin-sdk 0.4.8 → 0.4.9

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.
@@ -389,6 +389,96 @@ interface PluginFileOpenerProps {
389
389
  */
390
390
  experimental_Original: ComponentType;
391
391
  }
392
+ /** How a code line longer than the viewport is presented. */
393
+ type CodeOverflowMode = "scroll" | "wrap";
394
+ /** How a diff presents its two sides. */
395
+ type DiffViewMode = "split" | "unified";
396
+ /** A 1-based, inclusive line range. */
397
+ interface SourceCodeLineRange {
398
+ start: number;
399
+ end: number;
400
+ }
401
+ /**
402
+ * Props of the host-owned `experimental_SourceCode` component — BB's source
403
+ * viewer. The host owns syntax highlighting, gutters, wrapping, line-selection
404
+ * presentation, and the live BB code theme; the caller owns loading the text
405
+ * and any surrounding chrome.
406
+ */
407
+ interface SourceCodeProps {
408
+ /** The complete source text to render. */
409
+ content: string;
410
+ /** File path or name. Drives language detection and the a11y label. */
411
+ path: string;
412
+ /** Long-line presentation. Defaults to `"scroll"`. */
413
+ overflow?: CodeOverflowMode;
414
+ /**
415
+ * Lines to highlight and scroll into view (1-based, inclusive). Defaults to
416
+ * `null` — nothing highlighted.
417
+ */
418
+ highlightedLines?: SourceCodeLineRange | null;
419
+ /** Applied to the renderer's root element. */
420
+ className?: string;
421
+ }
422
+ /**
423
+ * Props of the host-owned `experimental_Diff` component — BB's diff viewer.
424
+ * The host owns patch normalization (a patch without a `diff --git` header is
425
+ * completed from `path`), syntax highlighting, unified/split presentation,
426
+ * gutters, line-selection presentation, and the live BB code theme. Content
427
+ * that cannot be parsed as a patch degrades to plain monospace text.
428
+ */
429
+ interface DiffProps {
430
+ /** Unified patch text for exactly ONE file. */
431
+ patch: string;
432
+ /**
433
+ * The file the patch applies to. Used to complete a patch that arrives
434
+ * without a `diff --git` header (GitHub's REST patches, single `@@` hunks)
435
+ * and for language detection.
436
+ */
437
+ path: string;
438
+ /** Side-by-side or inline. Defaults to `"unified"`. */
439
+ view?: DiffViewMode;
440
+ /** Long-line presentation. Defaults to `"scroll"`. */
441
+ overflow?: CodeOverflowMode;
442
+ /** Whether the gutter shows line numbers. Defaults to `true`. */
443
+ showLineNumbers?: boolean;
444
+ /** Applied to the renderer's root element. */
445
+ className?: string;
446
+ }
447
+ /**
448
+ * Props passed to an `experimental_sourceCodeRenderer` component. Every value
449
+ * is already resolved — the replacement never re-applies a host default.
450
+ */
451
+ interface PluginSourceCodeRendererProps {
452
+ content: string;
453
+ path: string;
454
+ overflow: CodeOverflowMode;
455
+ highlightedLines: SourceCodeLineRange | null;
456
+ /**
457
+ * BB's source renderer, bound to this request. Render it to delegate
458
+ * conditionally without re-entering plugin replacement resolution.
459
+ *
460
+ * @experimental Audit before relying on this as a stable contract.
461
+ */
462
+ experimental_Original: ComponentType;
463
+ }
464
+ /**
465
+ * Props passed to an `experimental_diffRenderer` component. `patch` is always
466
+ * a complete single-file unified patch, whatever shape the caller supplied.
467
+ */
468
+ interface PluginDiffRendererProps {
469
+ patch: string;
470
+ path: string;
471
+ view: DiffViewMode;
472
+ overflow: CodeOverflowMode;
473
+ showLineNumbers: boolean;
474
+ /**
475
+ * BB's diff renderer, bound to this request. Render it to delegate
476
+ * conditionally without re-entering plugin replacement resolution.
477
+ *
478
+ * @experimental Audit before relying on this as a stable contract.
479
+ */
480
+ experimental_Original: ComponentType;
481
+ }
392
482
  /**
393
483
  * Message context passed to a `messageDirective` component — the assistant
394
484
  * (or nested agent) message that contained the directive.
@@ -885,6 +975,41 @@ interface PluginFileOpenerRegistration {
885
975
  extensions: readonly string[];
886
976
  component: ComponentType<PluginFileOpenerProps>;
887
977
  }
978
+ /**
979
+ * Replace BB's source-code renderer everywhere it renders supplied source
980
+ * text — the native file preview and every plugin that calls
981
+ * `experimental_SourceCode`. Like `experimental_threadList` this slot is
982
+ * **exclusive**: one renderer at a time. Registering activates it while the
983
+ * plugin is enabled; if several are registered the first in deterministic slot
984
+ * order wins. A missing, disabled, or crashing replacement falls back to BB's
985
+ * renderer, and a replacement can render `experimental_Original` to delegate
986
+ * per call (behind its own setting, by language, by size — whatever it needs).
987
+ */
988
+ interface PluginSourceCodeRendererRegistration {
989
+ /** Unique within the plugin; letters, digits, `-`, `_`. */
990
+ id: string;
991
+ /** Label shown in capability details. */
992
+ title: string;
993
+ /** Optional one-line description shown with the provider choice. */
994
+ description?: string;
995
+ component: ComponentType<PluginSourceCodeRendererProps>;
996
+ }
997
+ /**
998
+ * Replace BB's diff renderer everywhere it renders supplied diff content — the
999
+ * timeline file diffs, the environment diff panel's text bodies, and every
1000
+ * plugin that calls `experimental_Diff`. Exclusive, with the same activation,
1001
+ * fallback, and `experimental_Original` delegation rules as
1002
+ * {@link PluginSourceCodeRendererRegistration}.
1003
+ */
1004
+ interface PluginDiffRendererRegistration {
1005
+ /** Unique within the plugin; letters, digits, `-`, `_`. */
1006
+ id: string;
1007
+ /** Label shown in capability details. */
1008
+ title: string;
1009
+ /** Optional one-line description shown with the provider choice. */
1010
+ description?: string;
1011
+ component: ComponentType<PluginDiffRendererProps>;
1012
+ }
888
1013
  /**
889
1014
  * Register a leaf message directive rendered inside assistant (and nested
890
1015
  * agent) message Markdown. `id` is the directive name: `inline-vis` matches
@@ -1018,6 +1143,18 @@ interface PluginAppSlots {
1018
1143
  */
1019
1144
  experimental_threadHeaderAction(registration: PluginThreadHeaderActionRegistration): void;
1020
1145
  fileOpener(registration: PluginFileOpenerRegistration): void;
1146
+ /**
1147
+ * Replace BB's source-code renderer (see
1148
+ * {@link PluginSourceCodeRendererRegistration}). Experimental: see
1149
+ * docs/api_to_audit.md.
1150
+ */
1151
+ experimental_sourceCodeRenderer(registration: PluginSourceCodeRendererRegistration): void;
1152
+ /**
1153
+ * Replace BB's diff renderer (see
1154
+ * {@link PluginDiffRendererRegistration}). Experimental: see
1155
+ * docs/api_to_audit.md.
1156
+ */
1157
+ experimental_diffRenderer(registration: PluginDiffRendererRegistration): void;
1021
1158
  messageDirective(registration: PluginMessageDirectiveRegistration): void;
1022
1159
  messageAction(registration: PluginMessageActionRegistration): void;
1023
1160
  /**
@@ -1553,6 +1690,13 @@ interface PluginSdkApp {
1553
1690
  * The sidebar's live thread view (see {@link PluginSidebarThreadsState}).
1554
1691
  * Reads the host's own cache and realtime subscriptions, so it costs no
1555
1692
  * extra request and updates exactly when the built-in sidebar does.
1693
+ *
1694
+ * `threads` is one array of every visible thread and is not capped. Thread
1695
+ * objects keep their identity across updates while the underlying entry is
1696
+ * unchanged, so a memoized row re-renders only when its own thread changed;
1697
+ * the array itself is new on every update. Window your rows (render only
1698
+ * what is on screen) as the built-in sidebar does — a list that mounts one
1699
+ * row per thread is slow on phones with many threads.
1556
1700
  * Experimental: see docs/api_to_audit.md.
1557
1701
  */
1558
1702
  experimental_useSidebarThreads(): PluginSidebarThreadsState;
@@ -1597,6 +1741,21 @@ interface PluginSdkApp {
1597
1741
  * docs/api_to_audit.md for what to audit before the prefix drops.
1598
1742
  */
1599
1743
  experimental_NewThreadComposer: ComponentType<NewThreadComposerProps>;
1744
+ /**
1745
+ * The host-owned source viewer (see {@link SourceCodeProps}). Renders
1746
+ * supplied source text with BB's syntax highlighting, gutters, and live code
1747
+ * theme, and honours an active `experimental_sourceCodeRenderer`
1748
+ * replacement. Experimental: see docs/api_to_audit.md.
1749
+ */
1750
+ experimental_SourceCode: ComponentType<SourceCodeProps>;
1751
+ /**
1752
+ * The host-owned diff viewer (see {@link DiffProps}). Renders supplied patch
1753
+ * content with BB's normalization, syntax highlighting, unified/split
1754
+ * presentation, and live code theme, and honours an active
1755
+ * `experimental_diffRenderer` replacement. Experimental: see
1756
+ * docs/api_to_audit.md.
1757
+ */
1758
+ experimental_Diff: ComponentType<DiffProps>;
1600
1759
  useComposerView(): ComposerView;
1601
1760
  }
1602
1761
 
@@ -1604,6 +1763,8 @@ declare const definePluginApp: (setup: PluginAppSetup) => PluginAppDefinition;
1604
1763
  declare const ThreadChat: react.ComponentType<ThreadChatProps>;
1605
1764
  declare const Markdown: react.ComponentType<MarkdownProps>;
1606
1765
  declare const experimental_NewThreadComposer: react.ComponentType<NewThreadComposerProps>;
1766
+ declare const experimental_SourceCode: react.ComponentType<SourceCodeProps>;
1767
+ declare const experimental_Diff: react.ComponentType<DiffProps>;
1607
1768
  declare const useRpc: <Contract extends PluginRpcContract = Readonly<Record<string, PluginRpcMethodContract<StandardSchemaV1<unknown, unknown>, StandardSchemaV1<unknown, unknown>>>>>() => PluginRpcClient<Contract>;
1608
1769
  declare const useRealtime: (channel: string, handler: (payload: unknown) => void) => void;
1609
1770
  declare const useRealtimeConnectionState: () => PluginRealtimeConnectionState;
@@ -1617,5 +1778,5 @@ declare const experimental_useSidebarThreadActions: () => PluginSidebarThreadAct
1617
1778
  declare const experimental_useSidebarThreadPullRequest: (threadId: string) => PluginSidebarThreadPullRequestState;
1618
1779
  declare const experimental_useSidebarThreadSplit: (threadId: string) => PluginSidebarThreadSplit;
1619
1780
 
1620
- export { Markdown, ThreadChat, definePluginApp, experimental_NewThreadComposer, experimental_useSidebarThreadActions, experimental_useSidebarThreadPullRequest, experimental_useSidebarThreadSplit, experimental_useSidebarThreads, useBbContext, useBbNavigate, useComposer, useComposerView, useRealtime, useRealtimeConnectionState, useRpc, useSettings };
1621
- export type { BbContext, BbNavigate, ComposerCustomization, ComposerPlusMenuItem, ComposerRichTextSpec, ComposerStructuredDraft, ComposerView, JsonValue, MarkdownProps, NewThreadComposerProps, NewThreadRequest, PluginAppBuilder, PluginAppComposer, PluginAppContentScripts, PluginAppDefinition, PluginAppSetup, PluginAppSlots, PluginComposerApi, PluginComposerMention, PluginComposerScope, PluginComposerTextEffect, PluginComposerThreadRowStatus, PluginContentScriptContext, PluginContentScriptDisposer, PluginContentScriptRegistration, PluginFileOpenerProps, PluginFileOpenerRegistration, PluginFileOpenerSource, PluginHomepageSectionProps, PluginHomepageSectionRegistration, PluginMessageActionContext, PluginMessageActionRegistration, PluginMessageDirectiveMessage, PluginMessageDirectiveOpenWorkspaceFile, PluginMessageDirectiveProps, PluginMessageDirectiveRegistration, PluginNavPanelProps, PluginNavPanelRegistration, PluginNewThreadPanelActionContext, PluginNewThreadPanelActionRegistration, PluginNewThreadPanelProps, PluginPanelActionOpenOptions, PluginPendingInteractionProps, PluginPendingInteractionRegistration, PluginPendingInteractionView, PluginProviderIconRegistration, PluginRealtimeConnectionState, PluginRpcCallArgs, PluginRpcClient, PluginRpcContract, PluginRpcError, PluginRpcErrorCode, PluginRpcHandlers, PluginRpcIssuePathSegment, PluginRpcMethodContract, PluginRpcResult, PluginRpcValidationIssue, PluginSdkApp, PluginSettingsSectionProps, PluginSettingsSectionRegistration, PluginSettingsState, PluginSidebarFooterActionContext, PluginSidebarFooterActionProps, PluginSidebarFooterActionRegistration, PluginSidebarProject, PluginSidebarPullRequest, PluginSidebarSplitPane, PluginSidebarThread, PluginSidebarThreadActions, PluginSidebarThreadActivity, PluginSidebarThreadIndicator, PluginSidebarThreadPullRequestState, PluginSidebarThreadSplit, PluginSidebarThreadsState, PluginSidebarWorkspaceKind, PluginTargetedPanelActionOpenOptions, PluginThreadHeaderActionProps, PluginThreadHeaderActionRegistration, PluginThreadListProps, PluginThreadListRegistration, PluginThreadPanelActionContext, PluginThreadPanelActionRegistration, PluginThreadPanelProps, StandardSchemaV1, StandardSchemaV1InferInput, StandardSchemaV1InferOutput, StandardSchemaV1Issue, StandardSchemaV1Result, ThreadChatMessageAction, ThreadChatMessageReference, ThreadChatProps };
1781
+ export { Markdown, ThreadChat, definePluginApp, experimental_Diff, experimental_NewThreadComposer, experimental_SourceCode, experimental_useSidebarThreadActions, experimental_useSidebarThreadPullRequest, experimental_useSidebarThreadSplit, experimental_useSidebarThreads, useBbContext, useBbNavigate, useComposer, useComposerView, useRealtime, useRealtimeConnectionState, useRpc, useSettings };
1782
+ export type { BbContext, BbNavigate, CodeOverflowMode, ComposerCustomization, ComposerPlusMenuItem, ComposerRichTextSpec, ComposerStructuredDraft, ComposerView, DiffProps, DiffViewMode, JsonValue, MarkdownProps, NewThreadComposerProps, NewThreadRequest, PluginAppBuilder, PluginAppComposer, PluginAppContentScripts, PluginAppDefinition, PluginAppSetup, PluginAppSlots, PluginComposerApi, PluginComposerMention, PluginComposerScope, PluginComposerTextEffect, PluginComposerThreadRowStatus, PluginContentScriptContext, PluginContentScriptDisposer, PluginContentScriptRegistration, PluginDiffRendererProps, PluginDiffRendererRegistration, PluginFileOpenerProps, PluginFileOpenerRegistration, PluginFileOpenerSource, PluginHomepageSectionProps, PluginHomepageSectionRegistration, PluginMessageActionContext, PluginMessageActionRegistration, PluginMessageDirectiveMessage, PluginMessageDirectiveOpenWorkspaceFile, PluginMessageDirectiveProps, PluginMessageDirectiveRegistration, PluginNavPanelProps, PluginNavPanelRegistration, PluginNewThreadPanelActionContext, PluginNewThreadPanelActionRegistration, PluginNewThreadPanelProps, PluginPanelActionOpenOptions, PluginPendingInteractionProps, PluginPendingInteractionRegistration, PluginPendingInteractionView, PluginProviderIconRegistration, PluginRealtimeConnectionState, PluginRpcCallArgs, PluginRpcClient, PluginRpcContract, PluginRpcError, PluginRpcErrorCode, PluginRpcHandlers, PluginRpcIssuePathSegment, PluginRpcMethodContract, PluginRpcResult, PluginRpcValidationIssue, PluginSdkApp, PluginSettingsSectionProps, PluginSettingsSectionRegistration, PluginSettingsState, PluginSidebarFooterActionContext, PluginSidebarFooterActionProps, PluginSidebarFooterActionRegistration, PluginSidebarProject, PluginSidebarPullRequest, PluginSidebarSplitPane, PluginSidebarThread, PluginSidebarThreadActions, PluginSidebarThreadActivity, PluginSidebarThreadIndicator, PluginSidebarThreadPullRequestState, PluginSidebarThreadSplit, PluginSidebarThreadsState, PluginSidebarWorkspaceKind, PluginSourceCodeRendererProps, PluginSourceCodeRendererRegistration, PluginTargetedPanelActionOpenOptions, PluginThreadHeaderActionProps, PluginThreadHeaderActionRegistration, PluginThreadListProps, PluginThreadListRegistration, PluginThreadPanelActionContext, PluginThreadPanelActionRegistration, PluginThreadPanelProps, SourceCodeLineRange, SourceCodeProps, StandardSchemaV1, StandardSchemaV1InferInput, StandardSchemaV1InferOutput, StandardSchemaV1Issue, StandardSchemaV1Result, ThreadChatMessageAction, ThreadChatMessageReference, ThreadChatProps };
@@ -5,7 +5,7 @@
5
5
  // Confused by the API, or need a symbol that isn't here? Clone the BB repo
6
6
  // and read the real source: https://github.com/get-bb/bb
7
7
 
8
- import { PluginHomepageSectionRegistration, PluginSettingsSectionRegistration, PluginNavPanelRegistration, PluginThreadPanelActionRegistration, PluginNewThreadPanelActionRegistration, ComposerCustomization, PluginPendingInteractionRegistration, PluginSidebarFooterActionRegistration, PluginThreadListRegistration, PluginThreadHeaderActionRegistration, PluginFileOpenerRegistration, PluginMessageDirectiveRegistration, PluginMessageActionRegistration, PluginProviderIconRegistration, PluginContentScriptRegistration, PluginAppDefinition } from '@get-bb/plugin-sdk';
8
+ import { PluginHomepageSectionRegistration, PluginSettingsSectionRegistration, PluginNavPanelRegistration, PluginThreadPanelActionRegistration, PluginNewThreadPanelActionRegistration, ComposerCustomization, PluginPendingInteractionRegistration, PluginSidebarFooterActionRegistration, PluginThreadListRegistration, PluginThreadHeaderActionRegistration, PluginFileOpenerRegistration, PluginSourceCodeRendererRegistration, PluginDiffRendererRegistration, PluginMessageDirectiveRegistration, PluginMessageActionRegistration, PluginProviderIconRegistration, PluginContentScriptRegistration, PluginAppDefinition } from '@get-bb/plugin-sdk';
9
9
 
10
10
  /** Validated registrations produced by one plugin app setup execution. */
11
11
  interface CollectedPluginAppRegistrations {
@@ -20,6 +20,8 @@ interface CollectedPluginAppRegistrations {
20
20
  threadLists: PluginThreadListRegistration[];
21
21
  threadHeaderActions: PluginThreadHeaderActionRegistration[];
22
22
  fileOpeners: PluginFileOpenerRegistration[];
23
+ sourceCodeRenderers: PluginSourceCodeRendererRegistration[];
24
+ diffRenderers: PluginDiffRendererRegistration[];
23
25
  messageDirectives: PluginMessageDirectiveRegistration[];
24
26
  messageActions: PluginMessageActionRegistration[];
25
27
  providerIcons: PluginProviderIconRegistration[];