@get-bb/plugin-sdk 0.6.164 → 0.6.178

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.
@@ -71,6 +71,9 @@ type PluginNavPanelFixedTabRegistration = {
71
71
  layout?: "flush" | "padded";
72
72
  experimental_target?: _get_bb_plugin_sdk.ExperimentalFixedTabTargetContract<_get_bb_plugin_sdk.JsonValue>;
73
73
  };
74
+ interface CollectedThreadContextCardSectionRegistration extends ExperimentalThreadContextCardSectionRegistration {
75
+ legacyTitle: string | null;
76
+ }
74
77
  type CollectedPluginProviderIconRegistration = Omit<PluginProviderIconRegistration, "providerKind"> & {
75
78
  providerKind: PluginProviderIconRegistration["providerKind"] | "all";
76
79
  };
@@ -116,7 +119,7 @@ interface CollectedPluginAppRegistrations {
116
119
  threadHeaderRows: ExperimentalThreadHeaderRowRegistration[];
117
120
  threadHeaderTitles: ExperimentalThreadHeaderTitleRegistration[];
118
121
  threadContextCardRows: ExperimentalThreadContextCardRowRegistration[];
119
- threadContextCardSections: ExperimentalThreadContextCardSectionRegistration[];
122
+ threadContextCardSections: CollectedThreadContextCardSectionRegistration[];
120
123
  threadActions: PluginThreadActionRegistration<unknown>[];
121
124
  browserToolbarActions: ExperimentalPluginBrowserToolbarActionRegistration[];
122
125
  fileOpeners: PluginFileOpenerRegistration[];
@@ -141,4 +144,4 @@ interface CollectedSidebarNavigationRegistration extends ExperimentalSidebarNavi
141
144
  declare function collectPluginAppRegistrations(definition: PluginAppDefinition, onWarning?: (message: string) => void): CollectedPluginAppRegistrations;
142
145
 
143
146
  export { adaptSidebarFooterAction, collectPluginAppRegistrations, getCollectedSidebarFooterItems };
144
- export type { CollectedCompatibilitySidebarFooterItem, CollectedExperimentalSidebarFooterItem, CollectedManagedSidebarFooterItem, CollectedPluginAppRegistrations, CollectedPluginCommandRegistration, CollectedPluginMessageActionRegistration, CollectedPluginProviderIconRegistration, CollectedSidebarFooterItem, CollectedSidebarNavigationRegistration, ExperimentalSidebarFooterCommandKind, ExperimentalSidebarFooterItemRuntime, ExperimentalSidebarFooterRuntimeSnapshot, LegacyNavPanelRegistration, LegacyThreadHeaderActionRegistration, LegacyThreadPanelActionRegistration };
147
+ export type { CollectedCompatibilitySidebarFooterItem, CollectedExperimentalSidebarFooterItem, CollectedManagedSidebarFooterItem, CollectedPluginAppRegistrations, CollectedPluginCommandRegistration, CollectedPluginMessageActionRegistration, CollectedPluginProviderIconRegistration, CollectedSidebarFooterItem, CollectedSidebarNavigationRegistration, CollectedThreadContextCardSectionRegistration, ExperimentalSidebarFooterCommandKind, ExperimentalSidebarFooterItemRuntime, ExperimentalSidebarFooterRuntimeSnapshot, LegacyNavPanelRegistration, LegacyThreadHeaderActionRegistration, LegacyThreadPanelActionRegistration };
@@ -826,7 +826,7 @@ interface PluginTurnFailedEvent {
826
826
  originPluginId: string | null;
827
827
  }
828
828
  /**
829
- * Lifecycle events a plugin can observe with `bb.events.on` (design §4.5).
829
+ * Lifecycle events a plugin can observe with `bb.events.on`.
830
830
  *
831
831
  * **Events are announcements core makes.** Something already happened; a
832
832
  * handler is told about it and whatever it returns is IGNORED. Handlers run
@@ -287,8 +287,8 @@ interface PluginThreadStatus {
287
287
  * the content-script context's `experimental_setThreadRowStatus` (see
288
288
  * {@link PluginSdkApp.useSidebarThreadRowStatus}). bb's row draws it in
289
289
  * place of the draft glyph while it is set; a replaced list should do the
290
- * same so a status set by, say, the drafts or workflows plugin does not
291
- * vanish when the list changes hands.
290
+ * same so a status another plugin set does not vanish when the list changes
291
+ * hands. No bundled plugin sets one; only content scripts can.
292
292
  */
293
293
  type PluginSidebarThreadRowStatus = PluginComposerThreadRowStatus;
294
294
  /** Host-rendered status that temporarily replaces a thread's draft glyph. */
@@ -497,6 +497,7 @@ interface AcpDialect {
497
497
  handleClientRequest?(method: string, params: unknown): AcpClientRequestOutcome | undefined;
498
498
  maintenance?: AcpMaintenanceDialect;
499
499
  presentModel?(model: AvailableModel): AvailableModel;
500
+ readonly elicitationDescriptionIsHeading?: boolean;
500
501
  }
501
502
  interface AcpClientRequestOutcome {
502
503
  result: Record<string, unknown>;
@@ -497,6 +497,7 @@ interface AcpDialect {
497
497
  handleClientRequest?(method: string, params: unknown): AcpClientRequestOutcome | undefined;
498
498
  maintenance?: AcpMaintenanceDialect;
499
499
  presentModel?(model: AvailableModel): AvailableModel;
500
+ readonly elicitationDescriptionIsHeading?: boolean;
500
501
  }
501
502
  interface AcpClientRequestOutcome {
502
503
  result: Record<string, unknown>;
@@ -6,7 +6,7 @@
6
6
  // and read the real source: https://github.com/get-bb/bb
7
7
 
8
8
  import * as _get_bb_plugin_sdk from '@get-bb/plugin-sdk';
9
- import { ExperimentalSidebarFooterItemRegistration, PluginNavPanelRegistration, PluginProviderIconRegistration, PluginHomepageSectionRegistration, PluginSettingsSectionRegistration, ExperimentalAppOverlayRegistration, InternalDoNotUseSetupGuideSectionRegistration, ExperimentalTabRegistration, PluginNewThreadPanelActionRegistration, ComposerCustomization, PluginPendingInteractionRegistration, PluginSidebarFooterActionRegistration, PluginThreadListRegistration, ExperimentalSidebarNavigationRegistration, ExperimentalThreadContextSegmentRegistration, ExperimentalThreadInfoRowRegistration, ExperimentalThreadRowMetadataRegistration, ExperimentalThreadInfoSectionRegistration, ExperimentalThreadHeaderRowRegistration, ExperimentalThreadHeaderTitleRegistration, ExperimentalThreadContextCardRowRegistration, ExperimentalThreadContextCardSectionRegistration, PluginThreadActionRegistration, ExperimentalPluginBrowserToolbarActionRegistration, PluginFileOpenerRegistration, PluginSourceCodeRendererRegistration, PluginDiffRendererRegistration, ExperimentalComposerRegistration, PluginMessageDirectiveRegistration, ExperimentalCodeFenceRendererRegistration, PluginMessageActionRegistration, ExperimentalMessageMetadataRegistration, ExperimentalIconRegistration, PluginTimelineRendererRegistration, PluginEnvironmentProviderInputsRegistration, PluginMachineProviderInputsRegistration, PluginContentScriptRegistration, ComposerDraftSnapshot, PluginComposerScope, ComposerSelection, PluginComposerTextEffect, PluginComposerMention, ComposerSubmitOptions, ExperimentalClipboardContent, PluginComposerThreadRowStatus, BbNavigate, ExperimentalFilePreviewOptions, ExperimentalFileOpenOptions, PluginAppDefinition, PluginRpcContract, StandardSchemaV1InferInput, PluginRpcResult, PluginBrowserBbSdk, PluginRealtimeConnectionState, ComposerMention, ComposerAttachment, PluginSidebarThreadsState, PluginProvidersState, PluginCodeThemeState, BranchesState, CheckoutState, ExperimentalThreadContextKind, PluginSidebarThreadRowStatus, PluginSidebarThreadShortcut, PluginSidebarSplitLayout, ExperimentalComposerRendererApi, ExperimentalSidebarNavigationItem, PluginThreadActionTarget, PluginThreadActionEntry, PluginThreadActionRegistrationInfo, PluginEnvironmentProvidersState, ExperimentalLiveFileTarget, ExperimentalFilePreviewFile, ExperimentalServers, ExperimentalPanelController, ExperimentalPanelTabs, JsonValue, ExperimentalPageTitle, ExperimentalOpenTabOptions, ExperimentalSidebarNavigationActions, ExperimentalSidebarNavigationTarget } from '@get-bb/plugin-sdk';
9
+ import { ExperimentalSidebarFooterItemRegistration, PluginNavPanelRegistration, ExperimentalThreadContextCardSectionRegistration, PluginProviderIconRegistration, PluginHomepageSectionRegistration, PluginSettingsSectionRegistration, ExperimentalAppOverlayRegistration, InternalDoNotUseSetupGuideSectionRegistration, ExperimentalTabRegistration, PluginNewThreadPanelActionRegistration, ComposerCustomization, PluginPendingInteractionRegistration, PluginSidebarFooterActionRegistration, PluginThreadListRegistration, ExperimentalSidebarNavigationRegistration, ExperimentalThreadContextSegmentRegistration, ExperimentalThreadInfoRowRegistration, ExperimentalThreadRowMetadataRegistration, ExperimentalThreadInfoSectionRegistration, ExperimentalThreadHeaderRowRegistration, ExperimentalThreadHeaderTitleRegistration, ExperimentalThreadContextCardRowRegistration, PluginThreadActionRegistration, ExperimentalPluginBrowserToolbarActionRegistration, PluginFileOpenerRegistration, PluginSourceCodeRendererRegistration, PluginDiffRendererRegistration, ExperimentalComposerRegistration, PluginMessageDirectiveRegistration, ExperimentalCodeFenceRendererRegistration, PluginMessageActionRegistration, ExperimentalMessageMetadataRegistration, ExperimentalIconRegistration, PluginTimelineRendererRegistration, PluginEnvironmentProviderInputsRegistration, PluginMachineProviderInputsRegistration, PluginContentScriptRegistration, ComposerDraftSnapshot, PluginComposerScope, ComposerSelection, PluginComposerTextEffect, PluginComposerMention, ComposerSubmitOptions, ExperimentalClipboardContent, PluginComposerThreadRowStatus, ExperimentalThreadRequests, BbNavigate, ExperimentalFilePreviewOptions, ExperimentalFileOpenOptions, PluginAppDefinition, PluginRpcContract, StandardSchemaV1InferInput, PluginRpcResult, PluginBrowserBbSdk, ExperimentalPluginPanelPage, PluginRealtimeConnectionState, ComposerMention, ComposerAttachment, PluginSidebarThreadsState, PluginProvidersState, PluginCodeThemeState, BranchesState, CheckoutState, ExperimentalThreadContextKind, PluginSidebarThreadRowStatus, PluginSidebarThreadShortcut, PluginSidebarSplitLayout, ExperimentalComposerRendererApi, ExperimentalSidebarNavigationItem, PluginThreadActionTarget, PluginThreadActionEntry, PluginThreadActionRegistrationInfo, PluginEnvironmentProvidersState, ExperimentalLiveFileTarget, ExperimentalFilePreviewFile, ExperimentalServers, ExperimentalPanelController, ExperimentalPanelTabs, JsonValue, ExperimentalPageTitle, ExperimentalOpenTabOptions, ExperimentalSidebarNavigationActions, ExperimentalSidebarNavigationTarget } from '@get-bb/plugin-sdk';
10
10
  import { ComponentType, ReactNode } from 'react';
11
11
  import { RenderResult } from '@testing-library/react';
12
12
 
@@ -56,6 +56,9 @@ type PluginNavPanelFixedTabRegistration = {
56
56
  layout?: "flush" | "padded";
57
57
  experimental_target?: _get_bb_plugin_sdk.ExperimentalFixedTabTargetContract<_get_bb_plugin_sdk.JsonValue>;
58
58
  };
59
+ interface CollectedThreadContextCardSectionRegistration extends ExperimentalThreadContextCardSectionRegistration {
60
+ legacyTitle: string | null;
61
+ }
59
62
  type CollectedPluginProviderIconRegistration = Omit<PluginProviderIconRegistration, "providerKind"> & {
60
63
  providerKind: PluginProviderIconRegistration["providerKind"] | "all";
61
64
  };
@@ -204,6 +207,11 @@ type TestThreadActionsResolver = (thread: PluginThreadActionTarget, options: {
204
207
  * an empty list.
205
208
  */
206
209
  type TestThreadBulkActionsResolver = (threads: readonly PluginThreadActionTarget[]) => readonly PluginThreadActionEntry[];
210
+ /** One recorded `experimental_useThreadRequests()` call. */
211
+ interface ExperimentalThreadRequestCall {
212
+ method: keyof ExperimentalThreadRequests;
213
+ threadIds: string[];
214
+ }
207
215
  /**
208
216
  * One recorded `experimental_useSidebarNavigation()` action, or a split drag
209
217
  * started from `experimental_useSidebarNavigationSplit()` (`beginSplitDrag`).
@@ -247,7 +255,7 @@ interface CapturedPluginApp {
247
255
  threadHeaderRows: ExperimentalThreadHeaderRowRegistration[];
248
256
  threadHeaderTitles: ExperimentalThreadHeaderTitleRegistration[];
249
257
  threadContextCardRows: ExperimentalThreadContextCardRowRegistration[];
250
- threadContextCardSections: ExperimentalThreadContextCardSectionRegistration[];
258
+ threadContextCardSections: CollectedThreadContextCardSectionRegistration[];
251
259
  threadActions: PluginThreadActionRegistration<unknown>[];
252
260
  browserToolbarActions: ExperimentalPluginBrowserToolbarActionRegistration[];
253
261
  fileOpeners: PluginFileOpenerRegistration[];
@@ -269,12 +277,19 @@ type PluginAppModule = {
269
277
  default: unknown;
270
278
  };
271
279
  type PluginAppSource = PluginAppDefinition | PluginAppModule | (() => Promise<PluginAppDefinition | PluginAppModule>);
280
+ interface LoadPluginAppOptions {
281
+ /**
282
+ * Answer for `experimental_hasServers()` while the app definition runs.
283
+ * Omitted → false, as in a web browser.
284
+ */
285
+ hasServers?: boolean;
286
+ }
272
287
  /**
273
288
  * Install the test runtime, resolve the plugin app definition, and capture
274
289
  * its slot registrations. Pass the imported module, its default export, or a
275
290
  * thunk (`() => import("../app.tsx")`).
276
291
  */
277
- declare function loadPluginApp(source: PluginAppSource): Promise<CapturedPluginApp>;
292
+ declare function loadPluginApp(source: PluginAppSource, options?: LoadPluginAppOptions): Promise<CapturedPluginApp>;
278
293
  interface ContentScriptTestMountOptions {
279
294
  pluginId: string;
280
295
  /** Defaults to 1. Pass the host generation you want the plugin to observe. */
@@ -331,10 +346,11 @@ interface RenderSlotOptions<Contract extends PluginRpcContract = PluginRpcContra
331
346
  experimental_rpcContract?: NoInfer<Contract>;
332
347
  /** `useSettings()` values; omitted → `{ values: undefined, isLoading: false }`. */
333
348
  settings?: Record<string, string | number | boolean>;
334
- /** `useBbContext()` selection; both default to null. */
349
+ /** `useBbContext()` selection; each defaults to null. */
335
350
  context?: {
336
351
  projectId?: string | null;
337
352
  threadId?: string | null;
353
+ experimental_pluginPanel?: ExperimentalPluginPanelPage | null;
338
354
  };
339
355
  /** `experimental_usePluginId()` value; defaults to `test-plugin`. */
340
356
  pluginId?: string;
@@ -479,8 +495,8 @@ interface RenderSlotOptions<Contract extends PluginRpcContract = PluginRpcContra
479
495
  tabVisible?: boolean;
480
496
  /**
481
497
  * Answer for `experimental_useServers()`. Omitted → null, as in a web
482
- * browser. Pass `{ status, servers, switchTo }` to act as bb Desktop or the
483
- * mobile app.
498
+ * browser. Pass `{ status, servers, switchTo, addServer, accountSignIn }` to
499
+ * act as bb Desktop or the mobile app.
484
500
  */
485
501
  servers?: ExperimentalServers | null;
486
502
  /** Host acceptance for `useBbNavigate().experimental_openTerminal`. */
@@ -547,6 +563,8 @@ interface RenderedSlotInspectionState {
547
563
  * call, in order.
548
564
  */
549
565
  readonly experimental_environmentArchiveCalls: string[];
566
+ /** Every `experimental_useThreadRequests()` call, in order. */
567
+ readonly experimental_threadRequestCalls: ExperimentalThreadRequestCall[];
550
568
  /** Every `useSdk()` call, in order, as `"<area>.<method>"`. */
551
569
  readonly sdkCalls: SdkCall[];
552
570
  /** Every `experimental_copyToClipboard()` write, in order. */
@@ -574,4 +592,4 @@ declare function renderSlot<Props extends object, Contract extends PluginRpcCont
574
592
  }, props: Props, options?: RenderSlotOptions<Contract>): RenderedSlot;
575
593
 
576
594
  export { installTestPluginRuntime, loadPluginApp, mountPluginContentScripts, renderSlot };
577
- export type { CapturedPluginApp, ComposerLog, ContentScriptTestMountOptions, ContentScriptThreadRowStatusCall, MountedPluginContentScripts, NavigateCall, PluginAppSource, PluginRpcTestHandlers, PluginSdkTestFakes, RenderSlotOptions, RenderedSlot, RenderedSlotBehaviorDrivers, RenderedSlotInspectionState, RenderedSlotLifecycleControls, RpcCall, SdkCall, SidebarNavigationCall, TestThreadActionsResolver, TestThreadBulkActionsResolver };
595
+ export type { CapturedPluginApp, ComposerLog, ContentScriptTestMountOptions, ContentScriptThreadRowStatusCall, ExperimentalThreadRequestCall, LoadPluginAppOptions, MountedPluginContentScripts, NavigateCall, PluginAppSource, PluginRpcTestHandlers, PluginSdkTestFakes, RenderSlotOptions, RenderedSlot, RenderedSlotBehaviorDrivers, RenderedSlotInspectionState, RenderedSlotLifecycleControls, RpcCall, SdkCall, SidebarNavigationCall, TestThreadActionsResolver, TestThreadBulkActionsResolver };
@@ -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 { StandardSchemaV1 as StandardSchemaV1$1, StandardSchemaV1InferOutput as StandardSchemaV1InferOutput$1, PluginMachineValidateDecision, JsonValue as JsonValue$2, PluginEnvironmentProviderRequirements as PluginEnvironmentProviderRequirements$1, PluginEnvironmentValidateDecision, BbPluginApi, PluginSettingValue as PluginSettingValue$1, PluginSharedPortTunnelIdentity, PluginRowPresentation, PluginAgentToolContext, PluginAgentToolResult, PluginCliCommandInfo, PluginCliContext, PluginCliResult, PluginHttpAuthMode, PluginHttpHandler, PluginMentionTrigger, PluginMentionSearchContext, PluginMentionItem, PluginMentionProviderRegistration, ExperimentalPluginRpcCaller, PluginCliExecutionResult, PluginThreadEventName, PluginThreadEventPayloads, PluginAgentConfigurationContext, ExperimentalPluginProviderEnvContext, ExperimentalPluginProviderEnvEntry, ExperimentalPluginProviderEnvHealthContext, ExperimentalPluginProviderEnvHealth, PluginSettingDescriptors, ExperimentalPluginWebSocketHandler, PluginAgentConfiguration, PluginHookName, PluginHookHandler, PluginAiServiceDeclaration, PluginInteractionRequest, ExperimentalPanelController, MessageDispatchHookContext } from '@get-bb/plugin-sdk';
8
+ import { StandardSchemaV1 as StandardSchemaV1$1, StandardSchemaV1InferOutput as StandardSchemaV1InferOutput$1, PluginMachineValidateDecision, JsonValue as JsonValue$2, PluginEnvironmentProviderRequirements as PluginEnvironmentProviderRequirements$1, PluginEnvironmentValidateDecision as PluginEnvironmentValidateDecision$1, BbPluginApi, PluginSettingValue as PluginSettingValue$1, PluginSharedPortTunnelIdentity, PluginRowPresentation, PluginAgentToolContext, PluginAgentToolResult, PluginCliCommandInfo, PluginCliContext, PluginCliResult, PluginHttpAuthMode, PluginHttpHandler, PluginMentionTrigger, PluginMentionSearchContext, PluginMentionItem, PluginMentionProviderRegistration, ExperimentalPluginRpcCaller, PluginCliExecutionResult, PluginThreadEventName, PluginThreadEventPayloads, PluginAgentConfigurationContext, ExperimentalPluginProviderEnvContext, ExperimentalPluginProviderEnvEntry, ExperimentalPluginProviderEnvHealthContext, ExperimentalPluginProviderEnvHealth, PluginSettingDescriptors, ExperimentalPluginWebSocketHandler, PluginAgentConfiguration, PluginHookName, PluginHookHandler, PluginAiServiceDeclaration, PluginInteractionRequest, ExperimentalPluginActionContext, ExperimentalPanelController, MessageDispatchHookContext } from '@get-bb/plugin-sdk';
9
9
  import { z } from 'zod';
10
10
  import { ChildProcess } from 'node:child_process';
11
11
 
@@ -160,6 +160,7 @@ declare const environmentSchema: z.ZodObject<{
160
160
  type: z.ZodLiteral<"new">;
161
161
  }, z.core.$strip>], "type">;
162
162
  }, z.core.$strip>>;
163
+ heldBy: z.ZodNullable<z.ZodLiteral<"user">>;
163
164
  hostId: z.ZodString;
164
165
  hostLifecycle: z.ZodEnum<{
165
166
  "cleanup-failed": "cleanup-failed";
@@ -201,6 +202,7 @@ declare const environmentSchema: z.ZodObject<{
201
202
  provisioning: "provisioning";
202
203
  ready: "ready";
203
204
  }>;
205
+ statusMessage: z.ZodNullable<z.ZodString>;
204
206
  updatedAt: z.ZodNumber;
205
207
  workspaceProvisionType: z.ZodNullable<z.ZodEnum<{
206
208
  "managed-worktree": "managed-worktree";
@@ -274,78 +276,18 @@ type Project = z.infer<typeof projectSchema>;
274
276
  declare const PROVIDER_FORK_VALUES: readonly ["none", "tip", "checkpoint"];
275
277
  type ProviderFork = (typeof PROVIDER_FORK_VALUES)[number];
276
278
 
277
- declare const threadResponseSchema: z.ZodObject<{
278
- activeBackgroundAgentCount: z.ZodNumber;
279
- archivedAt: z.ZodNullable<z.ZodNumber>;
280
- canEditMessages: z.ZodBoolean;
281
- canRestoreEnvironment: z.ZodBoolean;
282
- canSpawnChild: z.ZodBoolean;
283
- createdAt: z.ZodNumber;
284
- deletedAt: z.ZodNullable<z.ZodNumber>;
285
- environmentId: z.ZodNullable<z.ZodString>;
286
- id: z.ZodString;
287
- lastReadAt: z.ZodNullable<z.ZodNumber>;
288
- latestAttentionAt: z.ZodNumber;
289
- lifecycleOwnerThreadId: z.ZodNullable<z.ZodString>;
290
- originKind: z.ZodNullable<z.ZodEnum<{
291
- fork: "fork";
292
- }>>;
293
- originPluginId: z.ZodNullable<z.ZodString>;
294
- parentNotifications: z.ZodEnum<{
295
- auto: "auto";
296
- off: "off";
297
- stuck: "stuck";
298
- }>;
299
- parentThreadId: z.ZodNullable<z.ZodString>;
300
- pinnedAt: z.ZodNullable<z.ZodNumber>;
301
- projectId: z.ZodString;
302
- providerId: z.ZodString;
303
- queuedMessageCount: z.ZodNumber;
304
- runtime: z.ZodObject<{
305
- displayStatus: z.ZodEnum<{
306
- "waiting-for-host": "waiting-for-host";
307
- active: "active";
308
- error: "error";
309
- idle: "idle";
310
- pending: "pending";
311
- provisioning: "provisioning";
312
- starting: "starting";
313
- stopping: "stopping";
314
- }>;
315
- }, z.core.$strip>;
316
- sectionId: z.ZodNullable<z.ZodString>;
317
- sourceThreadId: z.ZodNullable<z.ZodString>;
318
- status: z.ZodEnum<{
319
- active: "active";
320
- error: "error";
321
- idle: "idle";
322
- pending: "pending";
323
- starting: "starting";
324
- stopping: "stopping";
325
- }>;
326
- title: z.ZodNullable<z.ZodString>;
327
- titleFallback: z.ZodNullable<z.ZodString>;
328
- updatedAt: z.ZodNumber;
329
- visibility: z.ZodEnum<{
330
- hidden: "hidden";
331
- visible: "visible";
332
- }>;
333
- }, z.core.$strip>;
334
- type ThreadResponse$1 = z.infer<typeof threadResponseSchema>;
335
-
336
279
  type PluginEnvironmentProviderInputsSchema = StandardSchemaV1$1 | undefined;
337
280
  type Fact<R, K extends PropertyKey, T> = R extends Record<K, true> ? T : T | null;
281
+ /** `ownsPath`: bb cloned this checkout, so a provider may own work there. */
282
+ interface ProjectCheckout {
283
+ path: string;
284
+ ownsPath: boolean;
285
+ }
338
286
  type Checkout<R> = R extends {
339
287
  projectCheckout: true;
340
288
  } | {
341
289
  gitCheckout: true;
342
- } ? {
343
- path: string;
344
- experimental_ownsPath: boolean;
345
- } : {
346
- path: string;
347
- experimental_ownsPath: boolean;
348
- } | null;
290
+ } ? ProjectCheckout : ProjectCheckout | null;
349
291
  type InputsValue<S> = S extends StandardSchemaV1$1 ? StandardSchemaV1InferOutput$1<S> : null;
350
292
  /** Attempt-scoped updates; core persists each update before this call returns. */
351
293
  interface PluginEnvironmentProviderProgress {
@@ -359,6 +301,15 @@ interface PluginEnvironmentProviderValidateContext<R extends PluginEnvironmentPr
359
301
  gitRemote: Fact<R, "gitRemote", string>;
360
302
  inputs: InputsValue<S>;
361
303
  }
304
+ interface PluginEnvironmentProviderLocation {
305
+ path: string;
306
+ reuse: boolean;
307
+ }
308
+ interface PluginEnvironmentProviderLocateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
309
+ host: Host;
310
+ projectCheckout: Checkout<R>;
311
+ inputs: InputsValue<S>;
312
+ }
362
313
  interface PluginEnvironmentProviderAvailabilityContext {
363
314
  project: Project;
364
315
  host: Host;
@@ -376,28 +327,46 @@ type PluginEnvironmentProviderAvailability = {
376
327
  status: "unavailable";
377
328
  message: string;
378
329
  };
379
- interface PluginEnvironmentProviderCreateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S> {
380
- thread: ThreadResponse$1;
381
- suggestedBranchName: string;
330
+ /** The environment a create or restore produces a workspace for. */
331
+ interface PluginEnvironmentProviderEnvironment {
332
+ id: string;
333
+ name: string | null;
334
+ projectId: string;
335
+ }
336
+ /** Core's create steps, which a provider calls in the order it needs. */
337
+ interface PluginEnvironmentProviderSteps {
338
+ /**
339
+ * The name for a branch this operation makes. A thread's environment
340
+ * resolves to `<prefix><slug(title)>-<threadId>` once the thread's title
341
+ * settles (generated, provided, or the fallback); a thread-less one resolves
342
+ * at once to `<prefix><slug(name)>-<id>`, or `<prefix><id>` without a name.
343
+ * Core generates the title while create runs, so await it as late as
344
+ * possible. Repeated calls return the same name.
345
+ */
346
+ branchName(): Promise<string>;
347
+ /**
348
+ * Claims `path` as this environment's provider-owned workspace and asks core
349
+ * to run setup there; resolves once the request is recorded, while setup
350
+ * runs alongside the rest of create. The environment becomes ready only
351
+ * after create returns `created` with the same path and `ownsPath: true`.
352
+ * Without a call, core runs setup after create returns.
353
+ */
354
+ setup(path: string): Promise<void>;
355
+ }
356
+ interface PluginEnvironmentProviderCreateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S>, PluginEnvironmentProviderSteps {
357
+ environment: PluginEnvironmentProviderEnvironment;
382
358
  attempt: number;
383
359
  pathKey: string;
384
- experimental_claimPath(path: string): Promise<boolean>;
385
360
  report: PluginEnvironmentProviderProgress;
386
361
  signal: AbortSignal;
387
362
  }
388
363
  /** Rebuilds a thread's destroyed environment; `inputs` are the ones it was created with. */
389
- interface PluginEnvironmentProviderRestoreContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S> {
390
- thread: ThreadResponse$1;
391
- attempt: number;
392
- pathKey: string;
393
- experimental_claimPath(path: string): Promise<boolean>;
364
+ interface PluginEnvironmentProviderRestoreContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderCreateContext<R, S> {
394
365
  /** Resource is private to this provider; null after completed removal. */
395
366
  previous: {
396
367
  environment: Environment;
397
368
  resource: JsonValue$2 | null;
398
369
  };
399
- report: PluginEnvironmentProviderProgress;
400
- signal: AbortSignal;
401
370
  }
402
371
  type PluginEnvironmentProviderCreateResult = {
403
372
  status: "created";
@@ -430,11 +399,25 @@ type PluginEnvironmentProviderRemoveResult = {
430
399
  interface PluginEnvironmentProviderPolicy {
431
400
  /** Default five minutes; null keeps the environment indefinitely. */
432
401
  retireGraceMs: number | null;
433
- /** Default per-thread; replacement environments use a fresh key to avoid dead paths. */
434
- pathKeys: "per-attempt" | "per-thread";
402
+ /**
403
+ * Default per-environment: one key for the environment's workspace, stable
404
+ * across retries. Core derives it from the driving thread when there is one
405
+ * and from the environment otherwise, so thread workspaces keep their
406
+ * names. Replacement environments use a fresh key to avoid dead paths.
407
+ */
408
+ pathKeys: "per-attempt" | "per-environment";
435
409
  }
436
- /** Resource operations only. Core owns durable launches, retries and retirement. */
410
+ /**
411
+ * Resource operations only. Core owns durable launches, retries and
412
+ * retirement. Contexts carry the `environment` being created rather than a
413
+ * thread, so core can also create environments before any thread exists.
414
+ */
437
415
  interface PluginEnvironmentProviderDefinition<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
416
+ /**
417
+ * The context shape `create` and `restore` receive. Required: bb still runs
418
+ * providers built before it with the earlier, thread-based contexts.
419
+ */
420
+ apiVersion: 2;
438
421
  id: string;
439
422
  displayName: string;
440
423
  /** Short explanation shown in environment choices. */
@@ -446,11 +429,19 @@ interface PluginEnvironmentProviderDefinition<R extends PluginEnvironmentProvide
446
429
  policy?: Partial<PluginEnvironmentProviderPolicy>;
447
430
  /** Experimental per-machine availability, probed in the background for pickers and again at thread creation: see docs/api_to_audit.md. */
448
431
  availability?(context: PluginEnvironmentProviderAvailabilityContext): PluginEnvironmentProviderAvailability | Promise<PluginEnvironmentProviderAvailability>;
449
- validate?(context: PluginEnvironmentProviderValidateContext<R, S>): PluginEnvironmentValidateDecision | Promise<PluginEnvironmentValidateDecision>;
450
- /** Pure path selection from parsed inputs. Core reuses a recorded environment on the selected host before calling create; null requests normal creation. */
451
- experimental_existingPath?(inputs: InputsValue<S>): string | null;
432
+ validate?(context: PluginEnvironmentProviderValidateContext<R, S>): PluginEnvironmentValidateDecision$1 | Promise<PluginEnvironmentValidateDecision$1>;
433
+ /**
434
+ * Where an environment for these inputs lives, if the provider knows before
435
+ * creating anything; null asks for a new environment. Core claims the path
436
+ * for the operation. With `reuse: true`, a thread joins the environment
437
+ * recorded at `path` as it is. Otherwise create runs on a fresh
438
+ * reservation, which core refuses while another live thread uses an
439
+ * environment at `path`, and core folds the result into that environment
440
+ * when create returns the same path.
441
+ */
442
+ locate?(context: PluginEnvironmentProviderLocateContext<R, S>): PluginEnvironmentProviderLocation | null | Promise<PluginEnvironmentProviderLocation | null>;
452
443
  create(context: PluginEnvironmentProviderCreateContext<R, S>): Promise<PluginEnvironmentProviderCreateResult>;
453
- /** Experimental: rebuild a destroyed environment when its thread asks for it back. Without it, core never rebuilds this provider's destroyed environments: see docs/api_to_audit.md. */
444
+ /** Experimental: rebuild a destroyed environment when a thread asks for it back. Without it, core never rebuilds this provider's destroyed environments: see docs/api_to_audit.md. */
454
445
  restore?(context: PluginEnvironmentProviderRestoreContext<R, S>): Promise<PluginEnvironmentProviderCreateResult>;
455
446
  remove(context: PluginEnvironmentProviderRemoveContext): Promise<PluginEnvironmentProviderRemoveResult>;
456
447
  }
@@ -479,6 +470,65 @@ interface MachineBootstrapApi {
479
470
  }>;
480
471
  }
481
472
 
473
+ declare const threadResponseSchema: z.ZodObject<{
474
+ activeBackgroundAgentCount: z.ZodNumber;
475
+ archivedAt: z.ZodNullable<z.ZodNumber>;
476
+ canEditMessages: z.ZodBoolean;
477
+ canRestoreEnvironment: z.ZodBoolean;
478
+ canSpawnChild: z.ZodBoolean;
479
+ createdAt: z.ZodNumber;
480
+ deletedAt: z.ZodNullable<z.ZodNumber>;
481
+ environmentId: z.ZodNullable<z.ZodString>;
482
+ id: z.ZodString;
483
+ lastReadAt: z.ZodNullable<z.ZodNumber>;
484
+ latestAttentionAt: z.ZodNumber;
485
+ lifecycleOwnerThreadId: z.ZodNullable<z.ZodString>;
486
+ originKind: z.ZodNullable<z.ZodEnum<{
487
+ fork: "fork";
488
+ }>>;
489
+ originPluginId: z.ZodNullable<z.ZodString>;
490
+ parentNotifications: z.ZodEnum<{
491
+ auto: "auto";
492
+ off: "off";
493
+ stuck: "stuck";
494
+ }>;
495
+ parentThreadId: z.ZodNullable<z.ZodString>;
496
+ pinnedAt: z.ZodNullable<z.ZodNumber>;
497
+ projectId: z.ZodString;
498
+ providerId: z.ZodString;
499
+ queuedMessageCount: z.ZodNumber;
500
+ runtime: z.ZodObject<{
501
+ displayStatus: z.ZodEnum<{
502
+ "waiting-for-host": "waiting-for-host";
503
+ active: "active";
504
+ error: "error";
505
+ idle: "idle";
506
+ pending: "pending";
507
+ provisioning: "provisioning";
508
+ starting: "starting";
509
+ stopping: "stopping";
510
+ }>;
511
+ }, z.core.$strip>;
512
+ sectionId: z.ZodNullable<z.ZodString>;
513
+ sourceThreadId: z.ZodNullable<z.ZodString>;
514
+ status: z.ZodEnum<{
515
+ active: "active";
516
+ error: "error";
517
+ idle: "idle";
518
+ pending: "pending";
519
+ starting: "starting";
520
+ stopping: "stopping";
521
+ }>;
522
+ title: z.ZodNullable<z.ZodString>;
523
+ titleFallback: z.ZodNullable<z.ZodString>;
524
+ updatedAt: z.ZodNumber;
525
+ visibility: z.ZodEnum<{
526
+ hidden: "hidden";
527
+ visible: "visible";
528
+ }>;
529
+ }, z.core.$strip>;
530
+ type ThreadResponse$1 = z.infer<typeof threadResponseSchema>;
531
+
482
532
  /**
483
533
  * A value that survives a JSON round trip without coercion or data loss.
484
534
  *
@@ -571,6 +621,16 @@ interface PluginEnvironmentProviderRequirements {
571
621
  gitRemote?: boolean;
572
622
  projectless?: boolean;
573
623
  }
624
+ /**
625
+ * What `validate` answers. `refuse` fails the create request with `message`
626
+ * as the caller's error, before a thread or an environment row exists.
627
+ */
628
+ type PluginEnvironmentValidateDecision = {
629
+ action: "accept";
630
+ } | {
631
+ action: "refuse";
632
+ message: string;
633
+ };
574
634
  /**
575
635
  * Resource operations for one place a thread can run. Core persists progress,
576
636
  * retries, cancellation and retirement. Operations must be idempotent for the
@@ -1033,7 +1093,7 @@ declare const environmentCompositionSchema: z.ZodObject<{
1033
1093
  machineProviderId: z.ZodString;
1034
1094
  }, z.core.$strict>;
1035
1095
  type NormalizedPluginEnvironmentComposition = z.infer<typeof environmentCompositionSchema>;
1036
- interface NormalizedPluginEnvironmentProvider {
1096
+ interface NormalizedPluginEnvironmentProviderCommon {
1037
1097
  id: string;
1038
1098
  displayName: string;
1039
1099
  description: string | null;
@@ -1042,13 +1102,62 @@ interface NormalizedPluginEnvironmentProvider {
1042
1102
  inputs: StandardSchemaV1 | null;
1043
1103
  inputsJsonSchema: JsonValue | null;
1044
1104
  availability: NonNullable<PluginEnvironmentProviderDeclaration["availability"]> | null;
1045
- validate: NonNullable<PluginEnvironmentProviderDeclaration["validate"]> | null;
1046
- experimental_existingPath: NonNullable<PluginEnvironmentProviderDeclaration["experimental_existingPath"]> | null;
1047
- create: PluginEnvironmentProviderDeclaration["create"];
1048
- restore: NonNullable<PluginEnvironmentProviderDeclaration["restore"]> | null;
1105
+ /** Version 2's own, or version 1's `experimental_existingPath` as a reusing location. */
1106
+ locate: NonNullable<PluginEnvironmentProviderDeclaration["locate"]> | null;
1049
1107
  remove: PluginEnvironmentProviderDeclaration["remove"];
1108
+ }
1109
+ type ProviderModule = PluginEnvironmentProviderDefinition;
1110
+ type V2ValidateContext = PluginEnvironmentProviderValidateContext;
1111
+ type V2CreateContext = PluginEnvironmentProviderCreateContext;
1112
+ type V2RestoreContext = PluginEnvironmentProviderRestoreContext;
1113
+ type CreateResult = PluginEnvironmentProviderCreateResult;
1114
+ /**
1115
+ * The contexts of a provider declared without `apiVersion` (version 1). The
1116
+ * public types offer only version 2; core still runs version-1 providers
1117
+ * built against earlier SDKs through this adapter.
1118
+ */
1119
+ type PluginEnvironmentProviderV1ValidateContext = Omit<V2ValidateContext, "projectCheckout"> & {
1120
+ projectCheckout: {
1121
+ path: string;
1122
+ experimental_ownsPath: boolean;
1123
+ } | null;
1124
+ };
1125
+ type V1OperationContext = PluginEnvironmentProviderV1ValidateContext & Pick<V2CreateContext, "attempt" | "pathKey" | "report" | "signal"> & {
1126
+ thread: ThreadResponse$1;
1127
+ experimental_claimPath(path: string): Promise<boolean>;
1128
+ };
1129
+ type PluginEnvironmentProviderV1CreateContext = V1OperationContext & {
1130
+ suggestedBranchName: string;
1131
+ };
1132
+ type PluginEnvironmentProviderV1RestoreContext = V1OperationContext & Pick<V2RestoreContext, "previous">;
1133
+ interface PluginEnvironmentProviderV1Policy {
1134
+ retireGraceMs: number | null;
1135
+ pathKeys: "per-attempt" | "per-thread";
1136
+ }
1137
+ interface PluginEnvironmentProviderV1Declaration extends Omit<ProviderModule, "apiVersion" | "create" | "policy" | "restore" | "validate"> {
1138
+ apiVersion?: 1;
1139
+ policy?: Partial<PluginEnvironmentProviderV1Policy>;
1140
+ validate?(context: PluginEnvironmentProviderV1ValidateContext): PluginEnvironmentValidateDecision | Promise<PluginEnvironmentValidateDecision>;
1141
+ experimental_existingPath?(inputs: V2ValidateContext["inputs"]): string | null;
1142
+ create(context: PluginEnvironmentProviderV1CreateContext): Promise<CreateResult>;
1143
+ restore?(context: PluginEnvironmentProviderV1RestoreContext): Promise<CreateResult>;
1144
+ }
1145
+ interface NormalizedPluginEnvironmentProviderV1 {
1146
+ apiVersion: 1;
1147
+ validate: NonNullable<PluginEnvironmentProviderV1Declaration["validate"]> | null;
1148
+ create: PluginEnvironmentProviderV1Declaration["create"];
1149
+ restore: NonNullable<PluginEnvironmentProviderV1Declaration["restore"]> | null;
1150
+ policy: PluginEnvironmentProviderV1Policy;
1151
+ }
1152
+ interface NormalizedPluginEnvironmentProviderV2 {
1153
+ apiVersion: 2;
1154
+ validate: NonNullable<ProviderModule["validate"]> | null;
1155
+ create: ProviderModule["create"];
1156
+ restore: NonNullable<ProviderModule["restore"]> | null;
1050
1157
  policy: PluginEnvironmentProviderPolicy;
1051
1158
  }
1159
+ /** Normalized once at registration; `apiVersion` selects the context shape core builds for create and restore. */
1160
+ type NormalizedPluginEnvironmentProvider = NormalizedPluginEnvironmentProviderCommon & (NormalizedPluginEnvironmentProviderV1 | NormalizedPluginEnvironmentProviderV2);
1052
1161
  interface NormalizedPluginMachineProvider {
1053
1162
  id: string;
1054
1163
  displayName: string;
@@ -1132,7 +1241,9 @@ declare function createFakeSdk(options: {
1132
1241
  * Deliberately different from the real host:
1133
1242
  * - storage is process-local: kv in a Map, `storage.database()` one shared
1134
1243
  * better-sqlite3 handle in a temp directory (same data across calls, like
1135
- * the host's shared file), secret settings alongside plain values (no files).
1244
+ * the host's shared file), `storage.experimental_directory()` a `files`
1245
+ * folder in that temp directory rather than under `server.experimental_dataDir`,
1246
+ * secret settings alongside plain values (no files).
1136
1247
  * - `bb.sdk` is always bound (no listen gate) and every unstubbed method
1137
1248
  * throws instead of hitting a server.
1138
1249
  * - http auth modes are recorded but not enforced — signature checks and
@@ -1569,6 +1680,28 @@ declare function makeTurnFailedEvent(overrides?: Partial<TurnFailedEvent>): Turn
1569
1680
  * closed, empty panel, except the methods in `overrides`.
1570
1681
  */
1571
1682
  declare function makePanelController(overrides?: Partial<ExperimentalPanelController>): ExperimentalPanelController;
1683
+ /** One call recorded by {@link makeActionContext}'s default members. */
1684
+ interface ExperimentalActionContextCall {
1685
+ /** `"threadRequests.requestArchive"`, `"threadRequests.requestDelete"`, `"navigate.<method>"` or `"sdk.<area>.<method>"`. */
1686
+ member: string;
1687
+ args: unknown[];
1688
+ }
1689
+ /** A complete callback context plus the log of its default members' calls. */
1690
+ interface ExperimentalActionContextFixture extends ExperimentalPluginActionContext {
1691
+ /** Calls to the members `overrides` did not replace, in order. */
1692
+ readonly calls: ExperimentalActionContextCall[];
1693
+ }
1694
+ /**
1695
+ * A complete callback context for tests that call a command, thread action,
1696
+ * message action or composer callback directly, so a test lists only the
1697
+ * members it uses and keeps compiling when bb adds one. Defaults record each
1698
+ * call in `calls`: `threadRequests` methods resolve, `composer` is null, `navigate`
1699
+ * methods return false, `panel` is {@link makePanelController}'s, and `sdk`
1700
+ * methods reject because a test that reads data should stub it. Spread the
1701
+ * result and add a context's own fields, such as a command's `threadId` or a
1702
+ * thread action's `thread`.
1703
+ */
1704
+ declare function makeActionContext(overrides?: Partial<ExperimentalPluginActionContext>): ExperimentalActionContextFixture;
1572
1705
 
1573
1706
  interface PublicSdkOnlyScanOptions {
1574
1707
  /**
@@ -1687,5 +1820,5 @@ type ExperimentalDescendantPipe = DescendantPipe;
1687
1820
  */
1688
1821
  declare function experimental_createDescendantPipe(): Promise<ExperimentalDescendantPipe>;
1689
1822
 
1690
- export { PluginContextStaleError, createFakePluginHost, createFakeSdk, experimental_createDescendantPipe, experimental_createProcessLifeline, makePanelController as experimental_makePanelController, scanPublicSdkOnly as experimental_scanPublicSdkOnly, experimental_trackChildProcesses, makeHostResponse, makeMessageDispatchHookContext, makePluginAgentConfigurationContext, makeQueueEntry, makeThreadResponse, makeTurnFailedEvent };
1691
- export type { CreateFakePluginHostOptions, ExperimentalChildProcessTracker, ExperimentalDescendantPipe, ExperimentalFakeHostRpcCall, ExperimentalLifelineHolder, ExperimentalProcessLifeline, FakeAgentToolRecord, FakeCliRecord, FakeHttpRouteRecord, FakeLogEntry, FakeLogLevel, FakeMentionProviderRecord, FakePluginBehaviorDrivers, FakePluginHarness, FakePluginHost, FakePluginInspectionState, FakePluginLifecycleControls, FakePluginRegistrations, FakeRealtimeSignal, FakeScheduleRecord, FakeSdkCall, FakeSdkHarness, FakeSdkOverrides, FakeServiceRecord, PublicSdkOnlyScan, PublicSdkOnlyScanOptions, PublicSdkOnlyViolation };
1823
+ export { PluginContextStaleError, createFakePluginHost, createFakeSdk, experimental_createDescendantPipe, experimental_createProcessLifeline, makeActionContext as experimental_makeActionContext, makePanelController as experimental_makePanelController, scanPublicSdkOnly as experimental_scanPublicSdkOnly, experimental_trackChildProcesses, makeHostResponse, makeMessageDispatchHookContext, makePluginAgentConfigurationContext, makeQueueEntry, makeThreadResponse, makeTurnFailedEvent };
1824
+ export type { CreateFakePluginHostOptions, ExperimentalActionContextCall, ExperimentalActionContextFixture, ExperimentalChildProcessTracker, ExperimentalDescendantPipe, ExperimentalFakeHostRpcCall, ExperimentalLifelineHolder, ExperimentalProcessLifeline, FakeAgentToolRecord, FakeCliRecord, FakeHttpRouteRecord, FakeLogEntry, FakeLogLevel, FakeMentionProviderRecord, FakePluginBehaviorDrivers, FakePluginHarness, FakePluginHost, FakePluginInspectionState, FakePluginLifecycleControls, FakePluginRegistrations, FakeRealtimeSignal, FakeScheduleRecord, FakeSdkCall, FakeSdkHarness, FakeSdkOverrides, FakeServiceRecord, PublicSdkOnlyScan, PublicSdkOnlyScanOptions, PublicSdkOnlyViolation };