@get-bb/plugin-sdk 0.4.84 → 0.4.88

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.
@@ -18,6 +18,14 @@ import { z } from 'zod';
18
18
  type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | {
19
19
  [key: string]: JsonValue$1;
20
20
  };
21
+ /**
22
+ * A `JsonValue` that is read-only at every depth. BB uses it for JSON
23
+ * snapshots it deep-freezes before handing them to a plugin, where any write
24
+ * throws at runtime.
25
+ */
26
+ type ReadonlyJsonValue = string | number | boolean | null | readonly ReadonlyJsonValue[] | {
27
+ readonly [key: string]: ReadonlyJsonValue;
28
+ };
21
29
 
22
30
  /** A JSON-safe path segment reported by a Standard Schema validation issue. */
23
31
  type PluginRpcIssuePathSegment = string | number;
@@ -2821,4 +2829,4 @@ declare const experimental_useProviders: () => PluginProvidersState;
2821
2829
  declare const experimental_useCodeTheme: () => PluginCodeThemeState;
2822
2830
 
2823
2831
  export { Markdown, ThreadChat, UrlLink, definePluginApp, experimental_BranchPicker, experimental_Diff, experimental_FileLink, experimental_Icon, experimental_NewThreadComposer, experimental_PermissionModePicker, experimental_ProviderIcon, experimental_ProviderModelPicker, experimental_SourceCode, experimental_useAppPanel, experimental_useBranches, experimental_useCheckoutState, experimental_useCodeTheme, experimental_useFixedTabTarget, experimental_useProviders, experimental_useSidebarThreadActions, experimental_useSidebarThreadPullRequest, experimental_useSidebarThreadSplit, experimental_useSidebarThreads, useBbContext, useBbNavigate, useComposer, useComposerView, useRealtime, useRealtimeConnectionState, useRpc, useSettings };
2824
- export type { BbContext, BbNavigate, BranchPickerProps, BranchesState, CheckoutState, CodeOverflowMode, ComposerCustomization, ComposerPlusMenuItem, ComposerRichTextSpec, ComposerStructuredDraft, ComposerView, DiffProps, DiffViewMode, ExperimentalAppIcons, ExperimentalAppOverlayProps, ExperimentalAppOverlayRegistration, ExperimentalAppPanel, ExperimentalAppPanelSurface, ExperimentalComposerSubmitOptions, ExperimentalDiffFileContent, ExperimentalDiffFullFileContents, ExperimentalFileLinkProps, ExperimentalFileLocation, ExperimentalFileOpenOptions, ExperimentalFixedTabTargetContract, ExperimentalFixedTabTargetState, ExperimentalIconProps, ExperimentalIconRegistration, ExperimentalLiveFileTarget, ExperimentalOpenFixedTabOptions, ExperimentalPermissionModePickerProps, ExperimentalPluginFixedTabReference, ExperimentalProviderIconProps, ExperimentalProviderModelPickerProps, ExperimentalProviderModelPickerRouting, ExperimentalProviderModelPickerValue, ExperimentalSidebarFooter, ExperimentalSidebarFooterActionContext, ExperimentalSidebarFooterActionRegistration, ExperimentalSidebarFooterDisclosureController, ExperimentalSidebarFooterDisclosureProps, ExperimentalSidebarFooterDisclosureRegistration, ExperimentalSidebarFooterItemBase, ExperimentalSidebarFooterItemRegistration, ExperimentalSidebarNavigationAction, ExperimentalSidebarNavigationActivationOptions, ExperimentalSidebarNavigationIcon, ExperimentalSidebarNavigationItem, ExperimentalSidebarNavigationProps, ExperimentalSidebarNavigationRegistration, ExperimentalSidebarNavigationShortcut, JsonValue$1 as JsonValue, MarkdownProps, NewThreadComposerProps, NewThreadRequest, PluginAppBuilder, PluginAppComposer, PluginAppContentScripts, PluginAppDefinition, PluginAppSetup, PluginAppSlots, PluginCodeThemeData, PluginCodeThemeState, PluginCodeThemeTokenRule, PluginCommandPaletteActionContext, PluginCommandPaletteActionRegistration, PluginComposerApi, PluginComposerMention, PluginComposerScope, PluginComposerTextEffect, PluginComposerThreadRowStatus, PluginContentScriptContext, PluginContentScriptDisposer, PluginContentScriptRegistration, PluginDiffRendererProps, PluginDiffRendererRegistration, PluginEnvironmentProviderInputsChange, PluginEnvironmentProviderInputsProps, PluginEnvironmentProviderInputsRegistration, PluginFileOpenerProps, PluginFileOpenerRegistration, PluginFileOpenerSource, PluginFixedTabDeclaration, PluginFixedTabRegistration, PluginHomepageSectionProps, PluginHomepageSectionRegistration, PluginMachineProviderInputsChange, PluginMachineProviderInputsProps, PluginMachineProviderInputsRegistration, PluginMessageActionContext, PluginMessageActionRegistration, PluginMessageDirectiveMessage, PluginMessageDirectiveOpenWorkspaceFile, PluginMessageDirectiveProps, PluginMessageDirectiveRegistration, PluginNavPanelProps, PluginNavPanelRegistration, PluginNewThreadPanelActionContext, PluginNewThreadPanelActionRegistration, PluginNewThreadPanelProps, PluginPanelActionOpenOptions, PluginPendingInteractionProps, PluginPendingInteractionRegistration, PluginPendingInteractionView, PluginProviderIconRegistration, PluginProvidersState, 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, PluginSourceCodeRendererProps, PluginSourceCodeRendererRegistration, PluginTargetedPanelActionOpenOptions, PluginThreadHeaderActionProps, PluginThreadHeaderActionRegistration, PluginThreadListProps, PluginThreadListRegistration, PluginThreadPanelActionContext, PluginThreadPanelActionRegistration, PluginThreadPanelProps, PluginTimelineRendererProps, PluginTimelineRendererRegistration, PluginTimelineRendererRow, PluginTimelineRowPresentation, PluginTimelineRowStatus, SourceCodeLineRange, SourceCodeProps, StandardSchemaV1, StandardSchemaV1InferInput, StandardSchemaV1InferOutput, StandardSchemaV1Issue, StandardSchemaV1Result, ThreadChatMessageAction, ThreadChatMessageReference, ThreadChatProps, UrlLinkProps, UseBranchesArgs, UseCheckoutStateArgs };
2832
+ export type { BbContext, BbNavigate, BranchPickerProps, BranchesState, CheckoutState, CodeOverflowMode, ComposerCustomization, ComposerPlusMenuItem, ComposerRichTextSpec, ComposerStructuredDraft, ComposerView, DiffProps, DiffViewMode, ExperimentalAppIcons, ExperimentalAppOverlayProps, ExperimentalAppOverlayRegistration, ExperimentalAppPanel, ExperimentalAppPanelSurface, ExperimentalComposerSubmitOptions, ExperimentalDiffFileContent, ExperimentalDiffFullFileContents, ExperimentalFileLinkProps, ExperimentalFileLocation, ExperimentalFileOpenOptions, ExperimentalFixedTabTargetContract, ExperimentalFixedTabTargetState, ExperimentalIconProps, ExperimentalIconRegistration, ExperimentalLiveFileTarget, ExperimentalOpenFixedTabOptions, ExperimentalPermissionModePickerProps, ExperimentalPluginFixedTabReference, ExperimentalProviderIconProps, ExperimentalProviderModelPickerProps, ExperimentalProviderModelPickerRouting, ExperimentalProviderModelPickerValue, ExperimentalSidebarFooter, ExperimentalSidebarFooterActionContext, ExperimentalSidebarFooterActionRegistration, ExperimentalSidebarFooterDisclosureController, ExperimentalSidebarFooterDisclosureProps, ExperimentalSidebarFooterDisclosureRegistration, ExperimentalSidebarFooterItemBase, ExperimentalSidebarFooterItemRegistration, ExperimentalSidebarNavigationAction, ExperimentalSidebarNavigationActivationOptions, ExperimentalSidebarNavigationIcon, ExperimentalSidebarNavigationItem, ExperimentalSidebarNavigationProps, ExperimentalSidebarNavigationRegistration, ExperimentalSidebarNavigationShortcut, JsonValue$1 as JsonValue, MarkdownProps, NewThreadComposerProps, NewThreadRequest, PluginAppBuilder, PluginAppComposer, PluginAppContentScripts, PluginAppDefinition, PluginAppSetup, PluginAppSlots, PluginCodeThemeData, PluginCodeThemeState, PluginCodeThemeTokenRule, PluginCommandPaletteActionContext, PluginCommandPaletteActionRegistration, PluginComposerApi, PluginComposerMention, PluginComposerScope, PluginComposerTextEffect, PluginComposerThreadRowStatus, PluginContentScriptContext, PluginContentScriptDisposer, PluginContentScriptRegistration, PluginDiffRendererProps, PluginDiffRendererRegistration, PluginEnvironmentProviderInputsChange, PluginEnvironmentProviderInputsProps, PluginEnvironmentProviderInputsRegistration, PluginFileOpenerProps, PluginFileOpenerRegistration, PluginFileOpenerSource, PluginFixedTabDeclaration, PluginFixedTabRegistration, PluginHomepageSectionProps, PluginHomepageSectionRegistration, PluginMachineProviderInputsChange, PluginMachineProviderInputsProps, PluginMachineProviderInputsRegistration, PluginMessageActionContext, PluginMessageActionRegistration, PluginMessageDirectiveMessage, PluginMessageDirectiveOpenWorkspaceFile, PluginMessageDirectiveProps, PluginMessageDirectiveRegistration, PluginNavPanelProps, PluginNavPanelRegistration, PluginNewThreadPanelActionContext, PluginNewThreadPanelActionRegistration, PluginNewThreadPanelProps, PluginPanelActionOpenOptions, PluginPendingInteractionProps, PluginPendingInteractionRegistration, PluginPendingInteractionView, PluginProviderIconRegistration, PluginProvidersState, 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, PluginSourceCodeRendererProps, PluginSourceCodeRendererRegistration, PluginTargetedPanelActionOpenOptions, PluginThreadHeaderActionProps, PluginThreadHeaderActionRegistration, PluginThreadListProps, PluginThreadListRegistration, PluginThreadPanelActionContext, PluginThreadPanelActionRegistration, PluginThreadPanelProps, PluginTimelineRendererProps, PluginTimelineRendererRegistration, PluginTimelineRendererRow, PluginTimelineRowPresentation, PluginTimelineRowStatus, ReadonlyJsonValue, SourceCodeLineRange, SourceCodeProps, StandardSchemaV1, StandardSchemaV1InferInput, StandardSchemaV1InferOutput, StandardSchemaV1Issue, StandardSchemaV1Result, ThreadChatMessageAction, ThreadChatMessageReference, ThreadChatProps, UrlLinkProps, UseBranchesArgs, UseCheckoutStateArgs };
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { z } from 'zod';
9
9
  import { StandardSchemaV1 as StandardSchemaV1$1, PluginEnvironmentProviderRequirements as PluginEnvironmentProviderRequirements$1, StandardSchemaV1InferOutput, PluginEnvironmentValidateDecision, JsonValue as JsonValue$2, PluginMachineValidateDecision } from '@get-bb/plugin-sdk';
10
+ import Database from 'better-sqlite3';
10
11
 
11
12
  /** Input-form entry: a path, or a path with options. */
12
13
  declare const providerNativeRootInputSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -707,6 +708,21 @@ type JsonValue = string | number | boolean | null | JsonValue[] | {
707
708
  [key: string]: JsonValue;
708
709
  };
709
710
 
711
+ /** A JSON-safe path segment reported by a Standard Schema validation issue. */
712
+ type PluginRpcIssuePathSegment = string | number;
713
+ /** Validator-neutral validation detail carried by an RPC error envelope. */
714
+ interface PluginRpcValidationIssue {
715
+ message: string;
716
+ path?: PluginRpcIssuePathSegment[];
717
+ }
718
+ /** Stable wire error categories for plugin RPC. */
719
+ type PluginRpcErrorCode = "handler_error" | "invalid_input" | "invalid_json" | "invalid_output" | "non_json_result" | "unknown_method";
720
+ /** Structured RPC failure returned as `{ ok: false, error }`. */
721
+ interface PluginRpcError {
722
+ code: PluginRpcErrorCode;
723
+ message: string;
724
+ issues?: PluginRpcValidationIssue[];
725
+ }
710
726
  /**
711
727
  * The validator-neutral subset of Standard Schema v1 used by plugin contracts.
712
728
  * Zod 4 schemas implement this interface directly; other validators can do
@@ -735,10 +751,6 @@ interface StandardSchemaV1Issue {
735
751
  readonly key: PropertyKey;
736
752
  })[];
737
753
  }
738
- interface PluginRpcMethodContract<InputSchema extends StandardSchemaV1 = StandardSchemaV1, OutputSchema extends StandardSchemaV1 = StandardSchemaV1> {
739
- readonly input: InputSchema;
740
- readonly output: OutputSchema;
741
- }
742
754
 
743
755
  type PluginSettingDescriptor = {
744
756
  type: "string";
@@ -1021,6 +1033,33 @@ interface PluginHookSignatures {
1021
1033
  }
1022
1034
  type PluginHookName = keyof PluginHookSignatures;
1023
1035
  type PluginHookHandler<K extends PluginHookName> = (context: PluginHookSignatures[K]["context"]) => PluginHookSignatures[K]["decision"] | Promise<PluginHookSignatures[K]["decision"]>;
1036
+ type PluginHttpAuthMode = "local" | "none" | "token";
1037
+ interface PluginCliCommandInfo {
1038
+ name: string;
1039
+ summary: string;
1040
+ usage: string;
1041
+ }
1042
+ /** Context forwarded from the invoking CLI when known; all fields optional. */
1043
+ interface PluginCliContext {
1044
+ cwd?: string;
1045
+ threadId?: string;
1046
+ projectId?: string;
1047
+ /** Aborted when the invoking CLI HTTP request disconnects. */
1048
+ signal?: AbortSignal;
1049
+ }
1050
+ interface PluginInteractionRequest {
1051
+ threadId: string;
1052
+ rendererId: string;
1053
+ title: string;
1054
+ payload: JsonValue;
1055
+ /** Defaults to ten minutes; capped at one hour. */
1056
+ timeoutMs?: number;
1057
+ }
1058
+ interface PluginCliResult {
1059
+ exitCode: number;
1060
+ stdout?: string;
1061
+ stderr?: string;
1062
+ }
1024
1063
  interface PluginCliOutputLimitError {
1025
1064
  code: "plugin_cli_output_too_large";
1026
1065
  message: string;
@@ -1036,6 +1075,39 @@ interface PluginCliExecutionResult {
1036
1075
  stderr: string;
1037
1076
  error?: PluginCliOutputLimitError;
1038
1077
  }
1078
+ interface PluginCliRegistration {
1079
+ /** Preferred top-level command name (`bb <name> …`): lowercase [a-z0-9-]+.
1080
+ * A core collision logs an activation warning and remains available through
1081
+ * `bb plugin run <plugin-id>`. */
1082
+ name: string;
1083
+ summary: string;
1084
+ /** Subcommand metadata rendered in help and the plugin-commands skill
1085
+ * without executing plugin code. Parsing argv is plugin-owned. */
1086
+ commands?: PluginCliCommandInfo[];
1087
+ run(argv: string[], ctx: PluginCliContext): PluginCliResult | Promise<PluginCliResult>;
1088
+ }
1089
+ /** Per-turn context handed to bb.agents context providers (design §4.4). */
1090
+ /** MCP-style content parts a native tool may return (design §4.4). */
1091
+ type PluginAgentToolContentPart = {
1092
+ type: "text";
1093
+ text: string;
1094
+ } | {
1095
+ type: "image";
1096
+ data: string;
1097
+ mimeType: string;
1098
+ };
1099
+ type PluginAgentToolResult = string | {
1100
+ content: PluginAgentToolContentPart[];
1101
+ isError?: boolean;
1102
+ };
1103
+ /** Per-call context handed to a native tool's execute (design §4.4). */
1104
+ interface PluginAgentToolContext {
1105
+ threadId: string;
1106
+ projectId: string;
1107
+ /** The tool-call request's abort signal (aborts if the daemon round-trip
1108
+ * is torn down mid-call). */
1109
+ signal: AbortSignal;
1110
+ }
1039
1111
  /**
1040
1112
  * The row title of a plugin tool call while it is pending and once it
1041
1113
  * settled. Each label is capped at 80 characters and rendered as plain text.
@@ -1421,6 +1493,52 @@ interface ExperimentalPluginProviderEnvEntry {
1421
1493
  reason: string;
1422
1494
  }
1423
1495
  type PluginMentionTrigger = "!" | "#" | "$" | "@" | "~";
1496
+ /** Search context handed to a mention provider (design §4.9). `projectId`/
1497
+ * `threadId` are null when the composer has not committed one yet. */
1498
+ interface PluginMentionSearchContext {
1499
+ trigger: PluginMentionTrigger;
1500
+ query: string;
1501
+ projectId: string | null;
1502
+ threadId: string | null;
1503
+ }
1504
+ /** One row a mention provider returns from `search`. `id` is the provider's
1505
+ * own item id — the host namespaces it before it reaches the wire. */
1506
+ interface PluginMentionItem {
1507
+ id: string;
1508
+ title: string;
1509
+ subtitle?: string;
1510
+ icon?: string;
1511
+ }
1512
+ interface PluginMentionProviderRegistration {
1513
+ /** Unique within this plugin: [a-zA-Z0-9_-]+ (no ":" — the host composes
1514
+ * wire item ids as "<providerId>:<itemId>"). */
1515
+ id: string;
1516
+ /** Section label shown above this provider's rows in the mention menu. */
1517
+ label: string;
1518
+ /**
1519
+ * Composer trigger characters this provider should answer. Omit to use the
1520
+ * default `@` mention trigger. Valid triggers are `@`, `#`, `$`, `!`, and `~`.
1521
+ */
1522
+ triggers?: readonly PluginMentionTrigger[];
1523
+ /**
1524
+ * Runs server-side as the user types after one of this provider's triggers
1525
+ * in the composer. Each call is time-boxed (2s) and failure-isolated: a slow
1526
+ * or throwing provider contributes an empty list — it can never break the
1527
+ * mention menu.
1528
+ */
1529
+ search(ctx: PluginMentionSearchContext): PluginMentionItem[] | Promise<PluginMentionItem[]>;
1530
+ /**
1531
+ * Resolves one picked item into agent context, called once per unique
1532
+ * item at message send time. The returned `context` is attached to the
1533
+ * message as an agent-visible (user-hidden) prompt input. Throwing blocks
1534
+ * the send with a visible error.
1535
+ */
1536
+ resolve(itemId: string): {
1537
+ context: string;
1538
+ } | Promise<{
1539
+ context: string;
1540
+ }>;
1541
+ }
1424
1542
  /**
1425
1543
  * What a plugin's AI service does. `inference` answers bb's server-side helper
1426
1544
  * completions (thread titles, commit messages: a prompt and a JSON Schema in,
@@ -1453,21 +1571,11 @@ declare function pluginCliCollisionWarning(pluginId: string, commandName: string
1453
1571
  declare const RESERVED_AGENT_TOOL_NAMES: readonly string[];
1454
1572
  /** JSON values ≤256KB; larger writes are rejected with a clear error. */
1455
1573
  declare const KV_VALUE_MAX_BYTES: number;
1456
- declare const PLUGIN_HTTP_METHODS: ReadonlySet<string>;
1457
- declare const RPC_METHOD_PATTERN: RegExp;
1458
- declare const BACKGROUND_NAME_PATTERN: RegExp;
1459
- declare const CLI_COMMAND_NAME_PATTERN: RegExp;
1460
- declare const AGENT_TOOL_NAME_PATTERN: RegExp;
1461
1574
  declare const PLUGIN_PROVIDER_ENV_NAME_PATTERN: RegExp;
1462
1575
  declare const PLUGIN_PROVIDER_ENV_MAX_ENTRIES = 32;
1463
1576
  declare function validatePluginProviderEnvEntries(value: unknown): ExperimentalPluginProviderEnvEntry[];
1464
- declare const PLUGIN_AGENT_STATIC_INSTRUCTIONS_MAX_CHARS = 4096;
1465
1577
  /** Status labels ride on every tool-call event and share one timeline row. */
1466
1578
  declare const PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS = 80;
1467
- declare const PLUGIN_AGENT_SELECTION_MAX_IDS = 256;
1468
- declare const PLUGIN_AGENT_DYNAMIC_INSTRUCTIONS_MAX_CHARS = 4096;
1469
- declare const PLUGIN_AGENT_TOOL_PARAMETERS_MAX_BYTES: number;
1470
- declare const MENTION_PROVIDER_ID_PATTERN: RegExp;
1471
1579
  declare const PROVIDER_ID_PATTERN: RegExp;
1472
1580
  declare const PLUGIN_PROVIDER_BRIDGE_OPTIONS_MAX_BYTES: number;
1473
1581
  declare const SETTING_KEY_PATTERN: RegExp;
@@ -1479,9 +1587,9 @@ declare const SETTING_KEY_PATTERN: RegExp;
1479
1587
  declare function registerSettingDescriptors(target: PluginSettingDescriptors, added: Record<string, unknown>): PluginSettingDescriptors;
1480
1588
  /** Validate a settings update. `null` means unset. */
1481
1589
  declare function validateSettingsUpdate(descriptors: PluginSettingDescriptors, values: Record<string, unknown>): string[];
1590
+ declare function coerceStoredPluginSettingValue(descriptor: PluginSettingDescriptor, value: unknown): PluginSettingValue | undefined;
1482
1591
  declare const PLUGIN_MENTION_TRIGGER_VALUES: readonly ["@", "#", "$", "!", "~"];
1483
1592
  declare function isPluginMentionTrigger(value: unknown): value is PluginMentionTrigger;
1484
- declare function normalizeMentionProviderTriggers(providerId: string, triggers: unknown): readonly PluginMentionTrigger[];
1485
1593
  declare const PLUGIN_PROVIDER_DISPLAY_NAME_MAX_CHARS = 80;
1486
1594
  declare const PLUGIN_PROVIDER_PERMISSION_MODE_VALUES: readonly ["accept-edits", "auto", "full"];
1487
1595
  declare const PLUGIN_PROVIDER_REASONING_LEVEL_VALUES: readonly ["none", "low", "medium", "high", "xhigh", "ultracode", "max", "ultra"];
@@ -1583,30 +1691,6 @@ declare function deriveValidatedProviderOptions(args: {
1583
1691
  context: Parameters<NonNullable<PluginProviderDeclaration["deriveProviderOptions"]>>[0];
1584
1692
  }): Readonly<Record<string, JsonValue>>;
1585
1693
  declare function isStandardSchema(value: unknown): value is StandardSchemaV1;
1586
- declare function readRpcMethodContract(method: string, value: unknown): PluginRpcMethodContract;
1587
- /** Duck-typed zod detection: plugin sources may carry their own zod copy,
1588
- * so instanceof is useless — anything with safeParse is treated as zod. */
1589
- type ZodSchemaLike = {
1590
- safeParse: z.ZodType["safeParse"];
1591
- toJSONSchema?: z.ZodType["toJSONSchema"];
1592
- };
1593
- declare function isZodSchemaLike(value: unknown): value is ZodSchemaLike;
1594
- declare function zodSchemaToJsonSchema(schema: ZodSchemaLike): unknown;
1595
- /**
1596
- * Reject recursive local references before a tool schema reaches a provider.
1597
- * Some providers reject the complete tool list when any one schema contains a
1598
- * recursive `$ref`, so this is a shared production/fake-host boundary rule.
1599
- */
1600
- declare function assertNoRecursiveJsonSchemaReferences(schema: unknown, subject: string): void;
1601
- /**
1602
- * Reject the fields a registration never reads. Renamed fields get the
1603
- * message above; any other `experimental_` field is unknown (the same
1604
- * rule configure() output follows in the plugin service). The production
1605
- * host and the fake host both call this before parsing `presentation`, so
1606
- * a registration built against an older SDK fails a plugin's own unit test
1607
- * with the message bb would give it.
1608
- */
1609
- declare function rejectStaleAgentToolFields(toolName: string, tool: object): void;
1610
1694
  /**
1611
1695
  * The declared shape of `presentation`, copied field by field so
1612
1696
  * a plugin's object cannot smuggle prototypes or extra markup into the
@@ -1618,7 +1702,6 @@ declare function rejectStaleAgentToolFields(toolName: string, tool: object): voi
1618
1702
  declare function parsePluginAgentToolPresentation(toolName: string, value: unknown): PluginAgentToolPresentation | null;
1619
1703
  /** Compact issue summary from a (possibly foreign-instance) zod error. */
1620
1704
  declare function summarizeStandardIssues(issues: readonly StandardSchemaV1Issue[]): string;
1621
- declare function summarizeParseIssues(error: unknown): string;
1622
1705
  declare function enforcePluginCliOutputLimit(result: Omit<PluginCliExecutionResult, "error">, jsonOutput: boolean): PluginCliExecutionResult;
1623
1706
  /**
1624
1707
  * Adopt the value a plugin HTTP route handler returned.
@@ -1650,8 +1733,6 @@ declare function adoptHttpRouteResponse(value: unknown): Response;
1650
1733
  declare function undeclaredIconProblem(pluginId: string, declaredIconNames: ReadonlySet<string>, glyph: string): string | null;
1651
1734
  /** `bb.providers.register` refusal for an icon {@link undeclaredIconProblem} rejects. */
1652
1735
  declare function providerIconRefusalMessage(providerId: string, problem: string): string;
1653
- /** `bb.agents.registerTool` refusal for a glyph {@link undeclaredIconProblem} rejects. */
1654
- declare function agentToolIconRefusalMessage(toolName: string, problem: string): string;
1655
1736
  /**
1656
1737
  * `bb.providers.register` refusal for a plugin whose manifest declares no
1657
1738
  * `bb.host` entry: a declaration is metadata, and the bridge it runs on is
@@ -1726,6 +1807,111 @@ interface NormalizedPluginMachineProvider {
1726
1807
  }
1727
1808
  declare function validatePluginMachineProviderDeclaration(declaration: PluginMachineProviderDeclaration): NormalizedPluginMachineProvider;
1728
1809
  declare function validateServerAccessProviderDeclaration(declaration: ServerAccessProviderDeclaration): ServerAccessProviderDeclaration;
1810
+ declare function runPluginStorageMigrations(database: Database.Database, statements: string[]): void;
1811
+ declare function normalizeHttpRouteRegistration(method: string, path: string, handler: unknown, opts: {
1812
+ auth?: PluginHttpAuthMode;
1813
+ } | undefined, existingRoutes: readonly {
1814
+ method: string;
1815
+ path: string;
1816
+ }[]): {
1817
+ method: string;
1818
+ path: string;
1819
+ auth: PluginHttpAuthMode;
1820
+ };
1821
+ declare function normalizeWebSocketRouteRegistration(path: string, handler: unknown, opts: {
1822
+ auth?: PluginHttpAuthMode;
1823
+ } | undefined, existingRoutes: readonly {
1824
+ path: string;
1825
+ }[]): {
1826
+ path: string;
1827
+ auth: PluginHttpAuthMode;
1828
+ };
1829
+ type RpcRegistrationRecord = {
1830
+ inputSchema: StandardSchemaV1;
1831
+ outputSchema: StandardSchemaV1;
1832
+ handler: (input: unknown) => unknown;
1833
+ };
1834
+ declare function normalizeRpcRegistration(contract: unknown, handlers: unknown, registered: ReadonlyMap<string, unknown>): Array<[string, RpcRegistrationRecord]>;
1835
+ declare function normalizeRealtimePayload(channel: string, payload: unknown): unknown;
1836
+ declare function validateBackgroundServiceRegistration(name: string, service: {
1837
+ start(signal: AbortSignal): void | Promise<void>;
1838
+ }, existing: readonly {
1839
+ name: string;
1840
+ }[]): {
1841
+ name: string;
1842
+ start: (signal: AbortSignal) => void | Promise<void>;
1843
+ };
1844
+ declare function validateScheduleRegistration(name: string, cron: string, fn: () => void | Promise<void>, existing: readonly {
1845
+ name: string;
1846
+ }[], parseCron: (cron: string) => void): {
1847
+ name: string;
1848
+ cron: string;
1849
+ fn: () => void | Promise<void>;
1850
+ };
1851
+ declare function normalizeCliRegistration(registration: PluginCliRegistration, alreadyRegistered: boolean): {
1852
+ name: string;
1853
+ summary: string;
1854
+ commands: PluginCliCommandInfo[];
1855
+ run: PluginCliRegistration["run"];
1856
+ };
1857
+ type AgentToolExecute = (params: unknown, ctx: PluginAgentToolContext) => PluginAgentToolResult | Promise<PluginAgentToolResult>;
1858
+ type AgentToolParse = (input: unknown) => {
1859
+ ok: true;
1860
+ value: unknown;
1861
+ } | {
1862
+ ok: false;
1863
+ error: string;
1864
+ };
1865
+ declare function normalizeAgentToolRegistration(args: {
1866
+ pluginId: string;
1867
+ declaredIconNames: ReadonlySet<string>;
1868
+ tool: {
1869
+ name: string;
1870
+ description: string;
1871
+ instructions?: string;
1872
+ presentation?: PluginAgentToolPresentation;
1873
+ parameters: unknown;
1874
+ execute(params: never, ctx: PluginAgentToolContext): PluginAgentToolResult | Promise<PluginAgentToolResult>;
1875
+ };
1876
+ }): {
1877
+ name: string;
1878
+ description: string;
1879
+ presentation: PluginAgentToolPresentation | null;
1880
+ instructions: string | null;
1881
+ inputSchema: unknown;
1882
+ parse: AgentToolParse;
1883
+ execute: AgentToolExecute;
1884
+ };
1885
+ declare function normalizeMentionProviderRegistration(provider: PluginMentionProviderRegistration, existing: readonly {
1886
+ id: string;
1887
+ }[]): {
1888
+ id: string;
1889
+ label: string;
1890
+ triggers: readonly PluginMentionTrigger[];
1891
+ search: PluginMentionProviderRegistration["search"];
1892
+ resolve: PluginMentionProviderRegistration["resolve"];
1893
+ };
1894
+ declare function normalizeInteractionRequest(request: PluginInteractionRequest): {
1895
+ threadId: string;
1896
+ rendererId: string;
1897
+ title: string;
1898
+ payload: JsonValue;
1899
+ timeoutMs: number;
1900
+ };
1901
+ declare function validateProviderEnvContribution(label: "provider environment contribution" | "provider environment health contribution", providerId: string, resolve: unknown, registered: ReadonlyMap<string, unknown>): void;
1902
+ declare function normalizePluginAgentConfiguration(args: {
1903
+ knownSkillIds: ReadonlySet<string>;
1904
+ knownToolIds: ReadonlySet<string>;
1905
+ pluginId: string;
1906
+ value: unknown;
1907
+ }): {
1908
+ toolIds: string[];
1909
+ toolParameterOverrides: Map<string, Record<string, unknown>>;
1910
+ skillIds: string[];
1911
+ instructions: string | null;
1912
+ };
1913
+ declare function validateRpcValue(schema: StandardSchemaV1, value: unknown, phase: "input" | "output", fail: (error: PluginRpcError) => never): Promise<unknown>;
1914
+ declare function normalizeRpcJsonResult(value: unknown, fail: (error: PluginRpcError) => never): JsonValue;
1729
1915
 
1730
- export { AGENT_TOOL_NAME_PATTERN, BACKGROUND_NAME_PATTERN, CLI_COMMAND_NAME_PATTERN, ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS, ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS, ENVIRONMENT_PROVIDER_ID_PATTERN, ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES, KV_VALUE_MAX_BYTES, MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS, MENTION_PROVIDER_ID_PATTERN, PLUGIN_AGENT_DYNAMIC_INSTRUCTIONS_MAX_CHARS, PLUGIN_AGENT_SELECTION_MAX_IDS, PLUGIN_AGENT_STATIC_INSTRUCTIONS_MAX_CHARS, PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS, PLUGIN_AGENT_TOOL_PARAMETERS_MAX_BYTES, PLUGIN_HTTP_METHODS, PLUGIN_MENTION_TRIGGER_VALUES, PLUGIN_PROVIDER_BRIDGE_OPTIONS_MAX_BYTES, PLUGIN_PROVIDER_COMPOSER_ACTION_VALUES, PLUGIN_PROVIDER_DISPLAY_NAME_MAX_CHARS, PLUGIN_PROVIDER_ENV_MAX_ENTRIES, PLUGIN_PROVIDER_ENV_NAME_PATTERN, PLUGIN_PROVIDER_PERMISSION_MODE_VALUES, PLUGIN_PROVIDER_REASONING_LEVEL_VALUES, PROVIDER_ID_PATTERN, RESERVED_AGENT_TOOL_NAMES, RESERVED_BB_CLI_COMMANDS, RPC_METHOD_PATTERN, SERVER_DIRECT_AI_SERVICE_IDS, SETTING_KEY_PATTERN, adoptHttpRouteResponse, agentToolIconRefusalMessage, aiServiceAlreadyRegisteredMessage, assertAiServiceRegistrable, assertNoRecursiveJsonSchemaReferences, deriveValidatedProviderOptions, enforcePluginCliOutputLimit, environmentCompositionSchema, isPluginMentionTrigger, isStandardSchema, isZodSchemaLike, normalizeMentionProviderTriggers, parsePluginAgentToolPresentation, pluginCliCollisionWarning, pluginHookAlreadyRegisteredMessage, providerAlreadyRegisteredMessage, providerIconRefusalMessage, providerWithoutBridgeMessage, readRpcMethodContract, registerSettingDescriptors, rejectStaleAgentToolFields, storePluginHook, summarizeParseIssues, summarizeStandardIssues, undeclaredIconProblem, validatePluginAiServiceDeclaration, validatePluginEnvironmentProviderDeclaration, validatePluginMachineProviderDeclaration, validatePluginProviderDeclaration, validatePluginProviderEnvEntries, validateServerAccessProviderDeclaration, validateSettingsUpdate, zodSchemaToJsonSchema };
1916
+ export { ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS, ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS, ENVIRONMENT_PROVIDER_ID_PATTERN, ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES, KV_VALUE_MAX_BYTES, MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS, PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS, PLUGIN_MENTION_TRIGGER_VALUES, PLUGIN_PROVIDER_BRIDGE_OPTIONS_MAX_BYTES, PLUGIN_PROVIDER_COMPOSER_ACTION_VALUES, PLUGIN_PROVIDER_DISPLAY_NAME_MAX_CHARS, PLUGIN_PROVIDER_ENV_MAX_ENTRIES, PLUGIN_PROVIDER_ENV_NAME_PATTERN, PLUGIN_PROVIDER_PERMISSION_MODE_VALUES, PLUGIN_PROVIDER_REASONING_LEVEL_VALUES, PROVIDER_ID_PATTERN, RESERVED_AGENT_TOOL_NAMES, RESERVED_BB_CLI_COMMANDS, SERVER_DIRECT_AI_SERVICE_IDS, SETTING_KEY_PATTERN, adoptHttpRouteResponse, aiServiceAlreadyRegisteredMessage, assertAiServiceRegistrable, coerceStoredPluginSettingValue, deriveValidatedProviderOptions, enforcePluginCliOutputLimit, environmentCompositionSchema, isPluginMentionTrigger, isStandardSchema, normalizeAgentToolRegistration, normalizeCliRegistration, normalizeHttpRouteRegistration, normalizeInteractionRequest, normalizeMentionProviderRegistration, normalizePluginAgentConfiguration, normalizeRealtimePayload, normalizeRpcJsonResult, normalizeRpcRegistration, normalizeWebSocketRouteRegistration, parsePluginAgentToolPresentation, pluginCliCollisionWarning, pluginHookAlreadyRegisteredMessage, providerAlreadyRegisteredMessage, providerIconRefusalMessage, providerWithoutBridgeMessage, registerSettingDescriptors, runPluginStorageMigrations, storePluginHook, summarizeStandardIssues, undeclaredIconProblem, validateBackgroundServiceRegistration, validatePluginAiServiceDeclaration, validatePluginEnvironmentProviderDeclaration, validatePluginMachineProviderDeclaration, validatePluginProviderDeclaration, validatePluginProviderEnvEntries, validateProviderEnvContribution, validateRpcValue, validateScheduleRegistration, validateServerAccessProviderDeclaration, validateSettingsUpdate };
1731
1917
  export type { AiServiceHostBinding, NormalizedPluginEnvironmentComposition, NormalizedPluginEnvironmentProvider, NormalizedPluginEnvironmentProviderRequirements, NormalizedPluginMachineProvider, NormalizedPluginProviderDeclaration };
@@ -3152,6 +3152,32 @@ declare const threadEventSchema: z.ZodPipe<z.ZodUnknown, z.ZodUnion<readonly [z.
3152
3152
  contextWindowUsage: z.ZodObject<{
3153
3153
  estimated: z.ZodBoolean;
3154
3154
  modelContextWindow: z.ZodNullable<z.ZodNumber>;
3155
+ snapshot: z.ZodOptional<z.ZodObject<{
3156
+ autoCompactAtTokens: z.ZodNullable<z.ZodNumber>;
3157
+ capturedAt: z.ZodISODateTime;
3158
+ categories: z.ZodArray<z.ZodObject<{
3159
+ entries: z.ZodArray<z.ZodObject<{
3160
+ id: z.ZodString;
3161
+ label: z.ZodString;
3162
+ tokens: z.ZodNumber;
3163
+ }, z.core.$strip>>;
3164
+ id: z.ZodString;
3165
+ kind: z.ZodEnum<{
3166
+ deferred: "deferred";
3167
+ free: "free";
3168
+ reserved: "reserved";
3169
+ used: "used";
3170
+ }>;
3171
+ label: z.ZodString;
3172
+ tokens: z.ZodNumber;
3173
+ }, z.core.$strip>>;
3174
+ contextWindowTokens: z.ZodNumber;
3175
+ estimated: z.ZodBoolean;
3176
+ model: z.ZodString;
3177
+ providerSessionId: z.ZodString;
3178
+ providerTurnId: z.ZodNullable<z.ZodString>;
3179
+ usedTokens: z.ZodNumber;
3180
+ }, z.core.$strip>>;
3155
3181
  usedTokens: z.ZodNullable<z.ZodNumber>;
3156
3182
  }, z.core.$strip>;
3157
3183
  providerThreadId: z.ZodString;
@@ -4730,6 +4756,32 @@ declare const threadDeltaSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4730
4756
  kind: z.ZodLiteral<"contextWindow">;
4731
4757
  providerTurnId: z.ZodOptional<z.ZodString>;
4732
4758
  size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
4759
+ snapshot: z.ZodOptional<z.ZodObject<{
4760
+ autoCompactAtTokens: z.ZodNullable<z.ZodNumber>;
4761
+ capturedAt: z.ZodISODateTime;
4762
+ categories: z.ZodArray<z.ZodObject<{
4763
+ entries: z.ZodArray<z.ZodObject<{
4764
+ id: z.ZodString;
4765
+ label: z.ZodString;
4766
+ tokens: z.ZodNumber;
4767
+ }, z.core.$strip>>;
4768
+ id: z.ZodString;
4769
+ kind: z.ZodEnum<{
4770
+ deferred: "deferred";
4771
+ free: "free";
4772
+ reserved: "reserved";
4773
+ used: "used";
4774
+ }>;
4775
+ label: z.ZodString;
4776
+ tokens: z.ZodNumber;
4777
+ }, z.core.$strip>>;
4778
+ contextWindowTokens: z.ZodNumber;
4779
+ estimated: z.ZodBoolean;
4780
+ model: z.ZodString;
4781
+ providerSessionId: z.ZodString;
4782
+ providerTurnId: z.ZodNullable<z.ZodString>;
4783
+ usedTokens: z.ZodNumber;
4784
+ }, z.core.$strip>>;
4733
4785
  used: z.ZodNullable<z.ZodNumber>;
4734
4786
  }, z.core.$strip>, z.ZodObject<{
4735
4787
  kind: z.ZodLiteral<"context.compacted">;