@get-bb/plugin-sdk 0.4.47 → 0.4.50

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.
@@ -0,0 +1,266 @@
1
+ // Portable type declarations for `@get-bb/plugin-sdk`. Unpublished BB
2
+ // workspace contracts are flattened; public subpaths may reuse the
3
+ // package root without requiring any other @bb/* package.
4
+ //
5
+ // Confused by the API, or need a symbol that isn't here? Clone the BB repo
6
+ // and read the real source: https://github.com/get-bb/bb
7
+
8
+ import { z } from 'zod';
9
+ import { PluginEnvironmentProviderRequirements, StandardSchemaV1, StandardSchemaV1InferOutput, JsonValue as JsonValue$1, PluginEnvironmentValidateDecision } from '@get-bb/plugin-sdk';
10
+
11
+ interface JsonObject {
12
+ [key: string]: JsonValue;
13
+ }
14
+ type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
15
+
16
+ declare const environmentSchema: z.ZodObject<{
17
+ baseBranch: z.ZodNullable<z.ZodString>;
18
+ branchName: z.ZodNullable<z.ZodString>;
19
+ createdAt: z.ZodNumber;
20
+ defaultBranch: z.ZodNullable<z.ZodString>;
21
+ environmentProviderId: z.ZodNullable<z.ZodString>;
22
+ environmentProviderInstanceKey: z.ZodNullable<z.ZodString>;
23
+ environmentProviderSelection: z.ZodNullable<z.ZodObject<{
24
+ inputs: z.ZodNullable<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
25
+ machine: z.ZodObject<{
26
+ hostId: z.ZodString;
27
+ type: z.ZodLiteral<"existing">;
28
+ }, z.core.$strip>;
29
+ }, z.core.$strip>>;
30
+ hostId: z.ZodString;
31
+ id: z.ZodString;
32
+ isGitRepo: z.ZodBoolean;
33
+ isWorktree: z.ZodBoolean;
34
+ lifecycle: z.ZodObject<{
35
+ phase: z.ZodEnum<{
36
+ active: "active";
37
+ destroyed: "destroyed";
38
+ retiring: "retiring";
39
+ teardown: "teardown";
40
+ }>;
41
+ retireAt: z.ZodNullable<z.ZodNumber>;
42
+ teardown: z.ZodNullable<z.ZodObject<{
43
+ attempt: z.ZodNumber;
44
+ message: z.ZodOptional<z.ZodString>;
45
+ status: z.ZodEnum<{
46
+ failed: "failed";
47
+ removed: "removed";
48
+ running: "running";
49
+ }>;
50
+ }, z.core.$strip>>;
51
+ }, z.core.$strip>;
52
+ managed: z.ZodBoolean;
53
+ mergeBaseBranch: z.ZodNullable<z.ZodString>;
54
+ name: z.ZodNullable<z.ZodString>;
55
+ path: z.ZodNullable<z.ZodString>;
56
+ projectId: z.ZodString;
57
+ status: z.ZodEnum<{
58
+ destroyed: "destroyed";
59
+ error: "error";
60
+ provisioning: "provisioning";
61
+ ready: "ready";
62
+ }>;
63
+ updatedAt: z.ZodNumber;
64
+ workspaceProvisionType: z.ZodNullable<z.ZodEnum<{
65
+ "managed-worktree": "managed-worktree";
66
+ personal: "personal";
67
+ unmanaged: "unmanaged";
68
+ }>>;
69
+ }, z.core.$strip>;
70
+ type Environment = z.infer<typeof environmentSchema>;
71
+
72
+ declare const hostSchema: z.ZodObject<{
73
+ createdAt: z.ZodNumber;
74
+ id: z.ZodString;
75
+ lastRejectedProtocolVersion: z.ZodNullable<z.ZodNumber>;
76
+ lastSeenAt: z.ZodNullable<z.ZodNumber>;
77
+ maxPermissionMode: z.ZodEnum<{
78
+ "accept-edits": "accept-edits";
79
+ auto: "auto";
80
+ full: "full";
81
+ }>;
82
+ name: z.ZodString;
83
+ status: z.ZodEnum<{
84
+ connected: "connected";
85
+ disconnected: "disconnected";
86
+ }>;
87
+ type: z.ZodEnum<{
88
+ persistent: "persistent";
89
+ }>;
90
+ updatedAt: z.ZodNumber;
91
+ }, z.core.$strip>;
92
+ type Host = z.infer<typeof hostSchema>;
93
+
94
+ declare const projectSchema: z.ZodObject<{
95
+ createdAt: z.ZodNumber;
96
+ gitRemoteUrl: z.ZodNullable<z.ZodString>;
97
+ id: z.ZodString;
98
+ kind: z.ZodEnum<{
99
+ personal: "personal";
100
+ standard: "standard";
101
+ }>;
102
+ name: z.ZodString;
103
+ updatedAt: z.ZodNumber;
104
+ }, z.core.$strip>;
105
+ type Project = z.infer<typeof projectSchema>;
106
+
107
+ declare const threadResponseSchema: z.ZodObject<{
108
+ activeBackgroundAgentCount: z.ZodNumber;
109
+ archivedAt: z.ZodNullable<z.ZodNumber>;
110
+ canSpawnChild: z.ZodBoolean;
111
+ createdAt: z.ZodNumber;
112
+ deletedAt: z.ZodNullable<z.ZodNumber>;
113
+ environmentId: z.ZodNullable<z.ZodString>;
114
+ id: z.ZodString;
115
+ lastReadAt: z.ZodNullable<z.ZodNumber>;
116
+ latestAttentionAt: z.ZodNumber;
117
+ originKind: z.ZodNullable<z.ZodEnum<{
118
+ fork: "fork";
119
+ }>>;
120
+ originPluginId: z.ZodNullable<z.ZodString>;
121
+ parentThreadId: z.ZodNullable<z.ZodString>;
122
+ pinnedAt: z.ZodNullable<z.ZodNumber>;
123
+ projectId: z.ZodString;
124
+ providerId: z.ZodString;
125
+ queuedMessageCount: z.ZodNumber;
126
+ runtime: z.ZodObject<{
127
+ displayStatus: z.ZodEnum<{
128
+ "host-reconnecting": "host-reconnecting";
129
+ "waiting-for-host": "waiting-for-host";
130
+ active: "active";
131
+ error: "error";
132
+ idle: "idle";
133
+ pending: "pending";
134
+ provisioning: "provisioning";
135
+ starting: "starting";
136
+ stopping: "stopping";
137
+ }>;
138
+ hostReconnectGraceExpiresAt: z.ZodNullable<z.ZodNumber>;
139
+ }, z.core.$strip>;
140
+ sectionId: z.ZodNullable<z.ZodString>;
141
+ sourceThreadId: z.ZodNullable<z.ZodString>;
142
+ status: z.ZodEnum<{
143
+ active: "active";
144
+ error: "error";
145
+ idle: "idle";
146
+ pending: "pending";
147
+ starting: "starting";
148
+ stopping: "stopping";
149
+ }>;
150
+ title: z.ZodNullable<z.ZodString>;
151
+ titleFallback: z.ZodNullable<z.ZodString>;
152
+ updatedAt: z.ZodNumber;
153
+ visibility: z.ZodEnum<{
154
+ hidden: "hidden";
155
+ visible: "visible";
156
+ }>;
157
+ }, z.core.$strip>;
158
+ type ThreadResponse = z.infer<typeof threadResponseSchema>;
159
+
160
+ type PluginEnvironmentProviderInputsSchema = StandardSchemaV1 | undefined;
161
+ type Fact<R, K extends PropertyKey, T> = R extends Record<K, true> ? T : T | null;
162
+ type Checkout<R> = R extends {
163
+ projectCheckout: true;
164
+ } | {
165
+ gitCheckout: true;
166
+ } ? {
167
+ path: string;
168
+ } : {
169
+ path: string;
170
+ } | null;
171
+ type InputsValue<S> = S extends StandardSchemaV1 ? StandardSchemaV1InferOutput<S> : null;
172
+ /** Attempt-scoped updates; core persists each update before this call returns. */
173
+ interface PluginEnvironmentProviderProgress {
174
+ step(text: string): void;
175
+ log(text: string): void;
176
+ }
177
+ interface PluginEnvironmentProviderValidateContext<R extends PluginEnvironmentProviderRequirements = PluginEnvironmentProviderRequirements, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
178
+ project: Project;
179
+ host: Host;
180
+ projectCheckout: Checkout<R>;
181
+ gitRemote: Fact<R, "gitRemote", string>;
182
+ inputs: InputsValue<S>;
183
+ }
184
+ interface PluginEnvironmentProviderAvailabilityContext {
185
+ project: Project;
186
+ host: Host | null;
187
+ projectCheckout: {
188
+ path: string;
189
+ } | null;
190
+ gitRemote: string | null;
191
+ }
192
+ type PluginEnvironmentProviderAvailability = {
193
+ status: "available";
194
+ } | {
195
+ status: "setup-required";
196
+ message: string;
197
+ } | {
198
+ status: "unavailable";
199
+ message: string;
200
+ };
201
+ interface PluginEnvironmentProviderCreateContext<R extends PluginEnvironmentProviderRequirements = PluginEnvironmentProviderRequirements, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S> {
202
+ thread: ThreadResponse;
203
+ suggestedBranchName: string;
204
+ attempt: number;
205
+ pathKey: string;
206
+ rebuild: boolean;
207
+ experimental_claimPath(path: string): Promise<boolean>;
208
+ /** Resource is private to this provider; null after completed removal. */
209
+ previous: {
210
+ environment: Environment;
211
+ resource: JsonValue$1 | null;
212
+ } | null;
213
+ report: PluginEnvironmentProviderProgress;
214
+ signal: AbortSignal;
215
+ }
216
+ type PluginEnvironmentProviderCreateResult = {
217
+ status: "created";
218
+ path: string;
219
+ ownsPath: boolean;
220
+ mergeBaseBranch?: string;
221
+ resource?: JsonValue$1;
222
+ } | {
223
+ status: "failed";
224
+ failure: "terminal" | "transient";
225
+ message: string;
226
+ };
227
+ interface PluginEnvironmentProviderRemoveContext {
228
+ environment: Environment | null;
229
+ hostId: string | null;
230
+ path: string | null;
231
+ pathKey: string;
232
+ resource: JsonValue$1 | null;
233
+ attempt: number;
234
+ report: PluginEnvironmentProviderProgress;
235
+ signal: AbortSignal;
236
+ }
237
+ type PluginEnvironmentProviderRemoveResult = {
238
+ status: "removed";
239
+ } | {
240
+ status: "failed";
241
+ message: string;
242
+ };
243
+ /** Core normalizes omitted policy members once at registration. */
244
+ interface PluginEnvironmentProviderPolicy {
245
+ /** Default five minutes; null keeps the environment indefinitely. */
246
+ retireGraceMs: number | null;
247
+ /** Default per-thread; rebuilds use a fresh key to avoid dead paths. */
248
+ pathKeys: "per-attempt" | "per-thread";
249
+ }
250
+ /** Resource operations only. Core owns durable launches, retries and retirement. */
251
+ interface PluginEnvironmentProviderDefinition<R extends PluginEnvironmentProviderRequirements = PluginEnvironmentProviderRequirements, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
252
+ id: string;
253
+ displayName: string;
254
+ /** Host glyph, plugin-relative icon path, or this plugin’s declared namespaced icon. */
255
+ icon?: string;
256
+ requires?: R;
257
+ inputs?: S;
258
+ policy?: Partial<PluginEnvironmentProviderPolicy>;
259
+ /** Experimental: see docs/api_to_audit.md. */
260
+ availability?(context: PluginEnvironmentProviderAvailabilityContext): PluginEnvironmentProviderAvailability | Promise<PluginEnvironmentProviderAvailability>;
261
+ validate?(context: PluginEnvironmentProviderValidateContext<R, S>): PluginEnvironmentValidateDecision | Promise<PluginEnvironmentValidateDecision>;
262
+ create(context: PluginEnvironmentProviderCreateContext<R, S>): Promise<PluginEnvironmentProviderCreateResult>;
263
+ remove(context: PluginEnvironmentProviderRemoveContext): Promise<PluginEnvironmentProviderRemoveResult>;
264
+ }
265
+
266
+ export type { PluginEnvironmentProviderAvailability, PluginEnvironmentProviderAvailabilityContext, PluginEnvironmentProviderCreateContext, PluginEnvironmentProviderCreateResult, PluginEnvironmentProviderDefinition, PluginEnvironmentProviderInputsSchema, PluginEnvironmentProviderPolicy, PluginEnvironmentProviderProgress, PluginEnvironmentProviderRemoveContext, PluginEnvironmentProviderRemoveResult, PluginEnvironmentProviderValidateContext };
@@ -6,6 +6,8 @@
6
6
  // and read the real source: https://github.com/get-bb/bb
7
7
 
8
8
  import { z } from 'zod';
9
+ import { ChildProcess } from 'node:child_process';
10
+ import { Readable } from 'node:stream';
9
11
 
10
12
  /**
11
13
  * The validator-neutral subset of Standard Schema v1 used by plugin contracts.
@@ -597,5 +599,34 @@ declare function experimental_resolveVendorPluginRoots(args: ExperimentalVendorP
597
599
  */
598
600
  declare function experimental_resolveClaudePluginRoots(args: ExperimentalClaudePluginRootsArgs): Promise<ExperimentalClaudePluginRoots>;
599
601
 
600
- export { experimental_defineHostEntry, experimental_filterResolvedNativeRoots, experimental_nativeRootsHostContract, experimental_nativeRootsResolveInputSchema, experimental_nativeRootsResolveOutputSchema, experimental_resolveClaudePluginRoots, experimental_resolveVendorPluginRoots };
601
- export type { ExperimentalClaudePluginRoots, ExperimentalClaudePluginRootsArgs, ExperimentalDroppedNativeRoot, ExperimentalFilteredNativeRoots, ExperimentalHostEntry, ExperimentalHostPaths, ExperimentalHostRpcContext, ExperimentalHostRpcHandlers, ExperimentalHostSignalContract, ExperimentalHostSignals, ExperimentalHostWatchChange, ExperimentalHostWatchChangeType, ExperimentalHostWatchEvent, ExperimentalHostWatchListener, ExperimentalHostWatchOptions, ExperimentalHostWatchSubscription, ExperimentalHostWorkerLease, ExperimentalNativeRootsHostContract, ExperimentalNativeRootsResolveAnswer, ExperimentalNativeRootsResolveInput, ExperimentalNativeRootsResolveOutput, ExperimentalVendorPlugin, ExperimentalVendorPluginRoots, ExperimentalVendorPluginRootsArgs };
602
+ type PortableChildProcess = ChildProcess;
603
+ interface PortablePipedSpawnRequest {
604
+ command: string;
605
+ args: string[];
606
+ cwd?: string;
607
+ detached?: boolean;
608
+ env?: NodeJS.ProcessEnv;
609
+ }
610
+ interface PortableOutputChildProcess extends PortableChildProcess {
611
+ stdin: null;
612
+ stdout: Readable;
613
+ stderr: Readable;
614
+ }
615
+ interface ProcessWithCwd {
616
+ pid: number;
617
+ cwd: string;
618
+ }
619
+ interface KillProcessesWithCwdUnderArgs {
620
+ directory: string;
621
+ graceMs?: number;
622
+ }
623
+ interface SanitizeInheritedChildProcessEnvArgs {
624
+ env: NodeJS.ProcessEnv;
625
+ shellPath?: string;
626
+ }
627
+ declare function spawnPortableOutputProcess(request: PortablePipedSpawnRequest): PortableOutputChildProcess;
628
+ declare function killProcessesWithCwdUnder(args: KillProcessesWithCwdUnderArgs): Promise<ProcessWithCwd[]>;
629
+ declare function sanitizeInheritedChildProcessEnv(args: SanitizeInheritedChildProcessEnvArgs): NodeJS.ProcessEnv;
630
+
631
+ export { experimental_defineHostEntry, experimental_filterResolvedNativeRoots, killProcessesWithCwdUnder as experimental_killProcessesWithCwdUnder, experimental_nativeRootsHostContract, experimental_nativeRootsResolveInputSchema, experimental_nativeRootsResolveOutputSchema, experimental_resolveClaudePluginRoots, experimental_resolveVendorPluginRoots, sanitizeInheritedChildProcessEnv as experimental_sanitizeInheritedChildProcessEnv, spawnPortableOutputProcess as experimental_spawnPortableOutputProcess };
632
+ export type { ExperimentalClaudePluginRoots, ExperimentalClaudePluginRootsArgs, ExperimentalDroppedNativeRoot, ExperimentalFilteredNativeRoots, ExperimentalHostEntry, ExperimentalHostPaths, ExperimentalHostRpcContext, ExperimentalHostRpcHandlers, ExperimentalHostSignalContract, ExperimentalHostSignals, ExperimentalHostWatchChange, ExperimentalHostWatchChangeType, ExperimentalHostWatchEvent, ExperimentalHostWatchListener, ExperimentalHostWatchOptions, ExperimentalHostWatchSubscription, ExperimentalHostWorkerLease, ExperimentalNativeRootsHostContract, ExperimentalNativeRootsResolveAnswer, ExperimentalNativeRootsResolveInput, ExperimentalNativeRootsResolveOutput, SanitizeInheritedChildProcessEnvArgs as ExperimentalSanitizeInheritedChildProcessEnvArgs, ExperimentalVendorPlugin, ExperimentalVendorPluginRoots, ExperimentalVendorPluginRootsArgs };
@@ -16,6 +16,7 @@ type RejectionReporter = (reason: string) => void;
16
16
  */
17
17
  declare function normalizePluginThreadRowStatus(value: unknown, onRejected: RejectionReporter): PluginComposerThreadRowStatus | null | undefined;
18
18
  declare function requireSlotId(kind: string, value: unknown): string;
19
+ declare function requireEnvironmentProviderId(kind: string, value: unknown): string;
19
20
  /**
20
21
  * Provider ids follow the same character rules as slot ids, but they name a
21
22
  * provider the host knows (`codex`, `acp-cursor`), not a per-plugin slot.
@@ -41,4 +42,4 @@ declare function requireUniqueId(kind: string, seen: Set<string>, id: string): v
41
42
  */
42
43
  declare function collectComposerCustomization(registration: unknown, seenIds: Set<string>, onRejected: RejectionReporter): ComposerCustomization | null;
43
44
 
44
- export { PLUGIN_SLOT_ID_PATTERN, PLUGIN_TIMELINE_RENDERER_KIND_PATTERN, collectComposerCustomization, normalizePluginThreadRowStatus, requireComponent, requireMessageDirectiveId, requireNonEmptyString, requireOptionalString, requireProviderId, requireSlotId, requireTimelineRendererKind, requireUniqueId };
45
+ export { PLUGIN_SLOT_ID_PATTERN, PLUGIN_TIMELINE_RENDERER_KIND_PATTERN, collectComposerCustomization, normalizePluginThreadRowStatus, requireComponent, requireEnvironmentProviderId, requireMessageDirectiveId, requireNonEmptyString, requireOptionalString, requireProviderId, requireSlotId, requireTimelineRendererKind, requireUniqueId };
@@ -6,8 +6,7 @@
6
6
  // and read the real source: https://github.com/get-bb/bb
7
7
 
8
8
  import { z } from 'zod';
9
-
10
- declare const RESERVED_BB_CLI_COMMANDS: readonly string[];
9
+ import { StandardSchemaV1 as StandardSchemaV1$1, PluginEnvironmentProviderRequirements as PluginEnvironmentProviderRequirements$1, StandardSchemaV1InferOutput, PluginEnvironmentValidateDecision, JsonValue as JsonValue$2 } from '@get-bb/plugin-sdk';
11
10
 
12
11
  /** Input-form entry: a path, or a path with options. */
13
12
  declare const providerNativeRootInputSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -61,15 +60,47 @@ interface ProviderNativeRootsInputLike {
61
60
  readonly project?: readonly ProviderNativeRootInput[];
62
61
  }
63
62
 
63
+ interface JsonObject {
64
+ [key: string]: JsonValue$1;
65
+ }
66
+ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | JsonObject;
67
+
64
68
  declare const environmentSchema: z.ZodObject<{
65
69
  baseBranch: z.ZodNullable<z.ZodString>;
66
70
  branchName: z.ZodNullable<z.ZodString>;
67
71
  createdAt: z.ZodNumber;
68
72
  defaultBranch: z.ZodNullable<z.ZodString>;
73
+ environmentProviderId: z.ZodNullable<z.ZodString>;
74
+ environmentProviderInstanceKey: z.ZodNullable<z.ZodString>;
75
+ environmentProviderSelection: z.ZodNullable<z.ZodObject<{
76
+ inputs: z.ZodNullable<z.ZodType<JsonValue$1, unknown, z.core.$ZodTypeInternals<JsonValue$1, unknown>>>;
77
+ machine: z.ZodObject<{
78
+ hostId: z.ZodString;
79
+ type: z.ZodLiteral<"existing">;
80
+ }, z.core.$strip>;
81
+ }, z.core.$strip>>;
69
82
  hostId: z.ZodString;
70
83
  id: z.ZodString;
71
84
  isGitRepo: z.ZodBoolean;
72
85
  isWorktree: z.ZodBoolean;
86
+ lifecycle: z.ZodObject<{
87
+ phase: z.ZodEnum<{
88
+ active: "active";
89
+ destroyed: "destroyed";
90
+ retiring: "retiring";
91
+ teardown: "teardown";
92
+ }>;
93
+ retireAt: z.ZodNullable<z.ZodNumber>;
94
+ teardown: z.ZodNullable<z.ZodObject<{
95
+ attempt: z.ZodNumber;
96
+ message: z.ZodOptional<z.ZodString>;
97
+ status: z.ZodEnum<{
98
+ failed: "failed";
99
+ removed: "removed";
100
+ running: "running";
101
+ }>;
102
+ }, z.core.$strip>>;
103
+ }, z.core.$strip>;
73
104
  managed: z.ZodBoolean;
74
105
  mergeBaseBranch: z.ZodNullable<z.ZodString>;
75
106
  name: z.ZodNullable<z.ZodString>;
@@ -77,18 +108,16 @@ declare const environmentSchema: z.ZodObject<{
77
108
  projectId: z.ZodString;
78
109
  status: z.ZodEnum<{
79
110
  destroyed: "destroyed";
80
- destroying: "destroying";
81
111
  error: "error";
82
112
  provisioning: "provisioning";
83
113
  ready: "ready";
84
- retiring: "retiring";
85
114
  }>;
86
115
  updatedAt: z.ZodNumber;
87
- workspaceProvisionType: z.ZodEnum<{
116
+ workspaceProvisionType: z.ZodNullable<z.ZodEnum<{
88
117
  "managed-worktree": "managed-worktree";
89
118
  personal: "personal";
90
119
  unmanaged: "unmanaged";
91
- }>;
120
+ }>>;
92
121
  }, z.core.$strip>;
93
122
  type Environment = z.infer<typeof environmentSchema>;
94
123
 
@@ -327,6 +356,11 @@ declare const threadQueuedMessageSchema: z.ZodObject<{
327
356
  failureReason: z.ZodNullable<z.ZodString>;
328
357
  groupWithNext: z.ZodBoolean;
329
358
  id: z.ZodString;
359
+ initiator: z.ZodEnum<{
360
+ agent: "agent";
361
+ system: "system";
362
+ user: "user";
363
+ }>;
330
364
  model: z.ZodString;
331
365
  payload: z.ZodDiscriminatedUnion<[z.ZodObject<{
332
366
  kind: z.ZodLiteral<"inline">;
@@ -352,6 +386,7 @@ declare const threadQueuedMessageSchema: z.ZodObject<{
352
386
  xhigh: "xhigh";
353
387
  }>;
354
388
  sendAt: z.ZodNullable<z.ZodNumber>;
389
+ senderThreadId: z.ZodNullable<z.ZodString>;
355
390
  serviceTier: z.ZodEnum<{
356
391
  default: "default";
357
392
  fast: "fast";
@@ -448,6 +483,114 @@ declare const threadResponseSchema: z.ZodObject<{
448
483
  }, z.core.$strip>;
449
484
  type ThreadResponse = z.infer<typeof threadResponseSchema>;
450
485
 
486
+ type PluginEnvironmentProviderInputsSchema = StandardSchemaV1$1 | undefined;
487
+ type Fact<R, K extends PropertyKey, T> = R extends Record<K, true> ? T : T | null;
488
+ type Checkout<R> = R extends {
489
+ projectCheckout: true;
490
+ } | {
491
+ gitCheckout: true;
492
+ } ? {
493
+ path: string;
494
+ } : {
495
+ path: string;
496
+ } | null;
497
+ type InputsValue<S> = S extends StandardSchemaV1$1 ? StandardSchemaV1InferOutput<S> : null;
498
+ /** Attempt-scoped updates; core persists each update before this call returns. */
499
+ interface PluginEnvironmentProviderProgress {
500
+ step(text: string): void;
501
+ log(text: string): void;
502
+ }
503
+ interface PluginEnvironmentProviderValidateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
504
+ project: Project;
505
+ host: Host;
506
+ projectCheckout: Checkout<R>;
507
+ gitRemote: Fact<R, "gitRemote", string>;
508
+ inputs: InputsValue<S>;
509
+ }
510
+ interface PluginEnvironmentProviderAvailabilityContext {
511
+ project: Project;
512
+ host: Host | null;
513
+ projectCheckout: {
514
+ path: string;
515
+ } | null;
516
+ gitRemote: string | null;
517
+ }
518
+ type PluginEnvironmentProviderAvailability = {
519
+ status: "available";
520
+ } | {
521
+ status: "setup-required";
522
+ message: string;
523
+ } | {
524
+ status: "unavailable";
525
+ message: string;
526
+ };
527
+ interface PluginEnvironmentProviderCreateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S> {
528
+ thread: ThreadResponse;
529
+ suggestedBranchName: string;
530
+ attempt: number;
531
+ pathKey: string;
532
+ rebuild: boolean;
533
+ experimental_claimPath(path: string): Promise<boolean>;
534
+ /** Resource is private to this provider; null after completed removal. */
535
+ previous: {
536
+ environment: Environment;
537
+ resource: JsonValue$2 | null;
538
+ } | null;
539
+ report: PluginEnvironmentProviderProgress;
540
+ signal: AbortSignal;
541
+ }
542
+ type PluginEnvironmentProviderCreateResult = {
543
+ status: "created";
544
+ path: string;
545
+ ownsPath: boolean;
546
+ mergeBaseBranch?: string;
547
+ resource?: JsonValue$2;
548
+ } | {
549
+ status: "failed";
550
+ failure: "terminal" | "transient";
551
+ message: string;
552
+ };
553
+ interface PluginEnvironmentProviderRemoveContext {
554
+ environment: Environment | null;
555
+ hostId: string | null;
556
+ path: string | null;
557
+ pathKey: string;
558
+ resource: JsonValue$2 | null;
559
+ attempt: number;
560
+ report: PluginEnvironmentProviderProgress;
561
+ signal: AbortSignal;
562
+ }
563
+ type PluginEnvironmentProviderRemoveResult = {
564
+ status: "removed";
565
+ } | {
566
+ status: "failed";
567
+ message: string;
568
+ };
569
+ /** Core normalizes omitted policy members once at registration. */
570
+ interface PluginEnvironmentProviderPolicy {
571
+ /** Default five minutes; null keeps the environment indefinitely. */
572
+ retireGraceMs: number | null;
573
+ /** Default per-thread; rebuilds use a fresh key to avoid dead paths. */
574
+ pathKeys: "per-attempt" | "per-thread";
575
+ }
576
+ /** Resource operations only. Core owns durable launches, retries and retirement. */
577
+ interface PluginEnvironmentProviderDefinition<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
578
+ id: string;
579
+ displayName: string;
580
+ /** Host glyph, plugin-relative icon path, or this plugin’s declared namespaced icon. */
581
+ icon?: string;
582
+ requires?: R;
583
+ inputs?: S;
584
+ policy?: Partial<PluginEnvironmentProviderPolicy>;
585
+ /** Experimental: see docs/api_to_audit.md. */
586
+ availability?(context: PluginEnvironmentProviderAvailabilityContext): PluginEnvironmentProviderAvailability | Promise<PluginEnvironmentProviderAvailability>;
587
+ validate?(context: PluginEnvironmentProviderValidateContext<R, S>): PluginEnvironmentValidateDecision | Promise<PluginEnvironmentValidateDecision>;
588
+ create(context: PluginEnvironmentProviderCreateContext<R, S>): Promise<PluginEnvironmentProviderCreateResult>;
589
+ remove(context: PluginEnvironmentProviderRemoveContext): Promise<PluginEnvironmentProviderRemoveResult>;
590
+ }
591
+
592
+ declare const RESERVED_BB_CLI_COMMANDS: readonly string[];
593
+
451
594
  /**
452
595
  * A value that survives a JSON round trip without coercion or data loss.
453
596
  *
@@ -536,6 +679,57 @@ type PluginSettingDescriptor = {
536
679
  };
537
680
  type PluginSettingDescriptors = Record<string, PluginSettingDescriptor>;
538
681
  type PluginSettingValue = string | number | boolean;
682
+ /**
683
+ * The facts this provider consumes, in one declaration. Every member is
684
+ * something core can evaluate before the thread exists and supply to
685
+ * `create`, so it is also the whole of what decides where the provider is
686
+ * offered, and the picker needs to know no provider by name. Every member
687
+ * defaults to false.
688
+ *
689
+ * - `projectCheckout` — the provider works from this project's directory on
690
+ * that machine, git or not, so core refuses a machine with no checkout of
691
+ * the project at create time and `context.projectCheckout` is non-null.
692
+ * - `gitCheckout` — that directory must also be a git repository with at
693
+ * least one commit. The picker greys the row out where it is not, and core
694
+ * rejects an explicit selection using the same machine inspection before
695
+ * creating the thread. Implies `projectCheckout`.
696
+ * - `gitRemote` — the provider clones the project itself, so it is greyed out
697
+ * in a project with no git remote and an explicit selection is rejected.
698
+ * - `projectless` — this provider serves only threads that have no project,
699
+ * so it is offered for those and nowhere else. It cannot be combined with
700
+ * `projectCheckout`, `gitCheckout` or `gitRemote`, which need a project.
701
+ */
702
+ interface PluginEnvironmentProviderRequirements {
703
+ projectCheckout?: boolean;
704
+ gitCheckout?: boolean;
705
+ gitRemote?: boolean;
706
+ projectless?: boolean;
707
+ }
708
+ /**
709
+ * Resource operations for one place a thread can run. Core persists progress,
710
+ * retries, cancellation and retirement. Operations must be idempotent for the
711
+ * supplied pathKey. Provider ids are unique across running plugins.
712
+ */
713
+ type PluginEnvironmentProviderDeclaration<Requires extends PluginEnvironmentProviderRequirements = PluginEnvironmentProviderRequirements, Inputs extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> = PluginEnvironmentProviderDefinition<Requires, Inputs>;
714
+ /**
715
+ * Where a thread is going to run, as far as core knows at the checkpoint.
716
+ * Before provisioning attaches an environment this is the start intent the
717
+ * thread was created with; afterwards it is the environment itself.
718
+ */
719
+ type PluginDispatchEnvironmentIntent = {
720
+ kind: "environment";
721
+ environmentId: string;
722
+ }
723
+ /** Ask a registered environment provider for the environment. */
724
+ | {
725
+ kind: "provider";
726
+ environmentProviderId: string;
727
+ machine: {
728
+ type: "existing";
729
+ hostId: string;
730
+ };
731
+ inputs: JsonValue | null;
732
+ };
539
733
  /**
540
734
  * What a `message.dispatch` hook answers.
541
735
  *
@@ -637,6 +831,13 @@ interface MessageDispatchHookContext {
637
831
  * about to occupy. Null only when neither names a machine.
638
832
  */
639
833
  host: Host | null;
834
+ /**
835
+ * What kind of environment the thread will run in, so a policy can tell a
836
+ * worktree on this machine from a cloud sandbox from an attached directory
837
+ * before any of them exists. Null only for a thread with neither an
838
+ * environment nor a start intent.
839
+ */
840
+ environmentIntent: PluginDispatchEnvironmentIntent | null;
640
841
  input: PluginDispatchInput;
641
842
  requestedExecution: PluginDispatchExecution;
642
843
  /** Where each execution value came from. */
@@ -1278,6 +1479,7 @@ declare function rejectStaleAgentToolFields(toolName: string, tool: object): voi
1278
1479
  */
1279
1480
  declare function parsePluginAgentToolPresentation(toolName: string, value: unknown): PluginAgentToolPresentation | null;
1280
1481
  /** Compact issue summary from a (possibly foreign-instance) zod error. */
1482
+ declare function summarizeStandardIssues(issues: readonly StandardSchemaV1Issue[]): string;
1281
1483
  declare function summarizeParseIssues(error: unknown): string;
1282
1484
  declare function enforcePluginCliOutputLimit(result: Omit<PluginCliExecutionResult, "error">, jsonOutput: boolean): PluginCliExecutionResult;
1283
1485
  /**
@@ -1336,6 +1538,27 @@ declare function storePluginHook<K extends PluginHookName>(records: {
1336
1538
  }, hook: K, handler: PluginHookHandler<K>): void;
1337
1539
  /** The refusal a second handler for one hook from one plugin gets. */
1338
1540
  declare function pluginHookAlreadyRegisteredMessage(hook: PluginHookName): string;
1541
+ declare const ENVIRONMENT_PROVIDER_ID_PATTERN: RegExp;
1542
+ declare const ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS = 80;
1543
+ declare const ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES: readonly ["projectCheckout", "gitCheckout", "gitRemote", "projectless"];
1544
+ type NormalizedPluginEnvironmentProviderRequirements = {
1545
+ [K in (typeof ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES)[number]]: boolean;
1546
+ };
1547
+ interface NormalizedPluginEnvironmentProvider {
1548
+ id: string;
1549
+ displayName: string;
1550
+ icon: string | null;
1551
+ requires: NormalizedPluginEnvironmentProviderRequirements;
1552
+ inputs: StandardSchemaV1 | null;
1553
+ inputsJsonSchema: JsonValue | null;
1554
+ availability: NonNullable<PluginEnvironmentProviderDeclaration["availability"]> | null;
1555
+ validate: NonNullable<PluginEnvironmentProviderDeclaration["validate"]> | null;
1556
+ create: PluginEnvironmentProviderDeclaration["create"];
1557
+ remove: PluginEnvironmentProviderDeclaration["remove"];
1558
+ policy: PluginEnvironmentProviderPolicy;
1559
+ }
1560
+ declare function validatePluginEnvironmentProviderDeclaration(declaration: PluginEnvironmentProviderDeclaration): NormalizedPluginEnvironmentProvider;
1561
+ declare const MACHINE_PROVIDER_REQUIREMENT_NAMES: readonly ["gitRemote"];
1339
1562
 
1340
- export { AGENT_TOOL_NAME_PATTERN, BACKGROUND_NAME_PATTERN, CLI_COMMAND_NAME_PATTERN, KV_VALUE_MAX_BYTES, 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, isPluginMentionTrigger, isStandardSchema, isZodSchemaLike, normalizeMentionProviderTriggers, parsePluginAgentToolPresentation, pluginCliCollisionWarning, pluginHookAlreadyRegisteredMessage, providerAlreadyRegisteredMessage, providerIconRefusalMessage, providerWithoutBridgeMessage, readRpcMethodContract, registerSettingDescriptors, rejectStaleAgentToolFields, storePluginHook, summarizeParseIssues, undeclaredIconProblem, validatePluginAiServiceDeclaration, validatePluginProviderDeclaration, validatePluginProviderEnvEntries, validateSettingsUpdate, zodSchemaToJsonSchema };
1341
- export type { AiServiceHostBinding, NormalizedPluginProviderDeclaration };
1563
+ export { AGENT_TOOL_NAME_PATTERN, BACKGROUND_NAME_PATTERN, CLI_COMMAND_NAME_PATTERN, ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS, ENVIRONMENT_PROVIDER_ID_PATTERN, ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES, KV_VALUE_MAX_BYTES, MACHINE_PROVIDER_REQUIREMENT_NAMES, 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, isPluginMentionTrigger, isStandardSchema, isZodSchemaLike, normalizeMentionProviderTriggers, parsePluginAgentToolPresentation, pluginCliCollisionWarning, pluginHookAlreadyRegisteredMessage, providerAlreadyRegisteredMessage, providerIconRefusalMessage, providerWithoutBridgeMessage, readRpcMethodContract, registerSettingDescriptors, rejectStaleAgentToolFields, storePluginHook, summarizeParseIssues, summarizeStandardIssues, undeclaredIconProblem, validatePluginAiServiceDeclaration, validatePluginEnvironmentProviderDeclaration, validatePluginProviderDeclaration, validatePluginProviderEnvEntries, validateSettingsUpdate, zodSchemaToJsonSchema };
1564
+ export type { AiServiceHostBinding, NormalizedPluginEnvironmentProvider, NormalizedPluginEnvironmentProviderRequirements, NormalizedPluginProviderDeclaration };
@@ -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 { ExperimentalSidebarFooterActionContext, ExperimentalSidebarFooterItemRegistration, PluginHomepageSectionRegistration, PluginSettingsSectionRegistration, ExperimentalAppOverlayRegistration, PluginNavPanelRegistration, PluginThreadPanelActionRegistration, PluginNewThreadPanelActionRegistration, ComposerCustomization, PluginPendingInteractionRegistration, PluginSidebarFooterActionRegistration, ExperimentalSidebarNavigationRegistration, PluginThreadListRegistration, PluginThreadHeaderActionRegistration, PluginFileOpenerRegistration, PluginSourceCodeRendererRegistration, PluginDiffRendererRegistration, PluginMessageDirectiveRegistration, PluginMessageActionRegistration, PluginCommandPaletteActionRegistration, PluginProviderIconRegistration, PluginTimelineRendererRegistration, PluginContentScriptRegistration, PluginAppDefinition } from '@get-bb/plugin-sdk';
8
+ import { ExperimentalSidebarFooterActionContext, ExperimentalSidebarFooterItemRegistration, PluginHomepageSectionRegistration, PluginSettingsSectionRegistration, ExperimentalAppOverlayRegistration, PluginNavPanelRegistration, PluginThreadPanelActionRegistration, PluginNewThreadPanelActionRegistration, ComposerCustomization, PluginPendingInteractionRegistration, PluginSidebarFooterActionRegistration, ExperimentalSidebarNavigationRegistration, PluginThreadListRegistration, PluginThreadHeaderActionRegistration, PluginFileOpenerRegistration, PluginSourceCodeRendererRegistration, PluginDiffRendererRegistration, PluginMessageDirectiveRegistration, PluginMessageActionRegistration, PluginCommandPaletteActionRegistration, PluginProviderIconRegistration, PluginTimelineRendererRegistration, PluginEnvironmentProviderInputsRegistration, PluginContentScriptRegistration, PluginAppDefinition } from '@get-bb/plugin-sdk';
9
9
 
10
10
  type ExperimentalSidebarFooterCommandKind = "close" | "open" | "toggle";
11
11
  interface ExperimentalSidebarFooterRuntimeSnapshot {
@@ -59,6 +59,7 @@ interface CollectedPluginAppRegistrations {
59
59
  commandPaletteActions: PluginCommandPaletteActionRegistration[];
60
60
  providerIcons: PluginProviderIconRegistration[];
61
61
  timelineRenderers: PluginTimelineRendererRegistration[];
62
+ environmentProviderInputs: PluginEnvironmentProviderInputsRegistration[];
62
63
  contentScripts: PluginContentScriptRegistration[];
63
64
  }
64
65
  declare function getCollectedSidebarFooterItems(registrations: object): readonly CollectedSidebarFooterItem[] | null;