@get-bb/plugin-sdk 0.4.14 → 0.4.16

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,807 @@
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
+
10
+ interface JsonObject {
11
+ [key: string]: JsonValue;
12
+ }
13
+ type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
14
+
15
+ declare const reasoningLevelSchema: z.ZodEnum<{
16
+ high: "high";
17
+ low: "low";
18
+ max: "max";
19
+ medium: "medium";
20
+ none: "none";
21
+ ultra: "ultra";
22
+ ultracode: "ultracode";
23
+ xhigh: "xhigh";
24
+ }>;
25
+ type ReasoningLevel = z.infer<typeof reasoningLevelSchema>;
26
+ declare const serviceTierSchema: z.ZodEnum<{
27
+ default: "default";
28
+ fast: "fast";
29
+ }>;
30
+ type ServiceTier = z.infer<typeof serviceTierSchema>;
31
+
32
+ declare const availableModelSchema: z.ZodObject<{
33
+ defaultReasoningEffort: z.ZodEnum<{
34
+ high: "high";
35
+ low: "low";
36
+ max: "max";
37
+ medium: "medium";
38
+ none: "none";
39
+ ultra: "ultra";
40
+ ultracode: "ultracode";
41
+ xhigh: "xhigh";
42
+ }>;
43
+ description: z.ZodString;
44
+ displayName: z.ZodString;
45
+ id: z.ZodString;
46
+ isDefault: z.ZodBoolean;
47
+ model: z.ZodString;
48
+ routeProviderId: z.ZodOptional<z.ZodString>;
49
+ supportedReasoningEfforts: z.ZodArray<z.ZodObject<{
50
+ description: z.ZodString;
51
+ reasoningEffort: z.ZodEnum<{
52
+ high: "high";
53
+ low: "low";
54
+ max: "max";
55
+ medium: "medium";
56
+ none: "none";
57
+ ultra: "ultra";
58
+ ultracode: "ultracode";
59
+ xhigh: "xhigh";
60
+ }>;
61
+ }, z.core.$strip>>;
62
+ }, z.core.$strip>;
63
+ type AvailableModel = z.infer<typeof availableModelSchema>;
64
+
65
+ /**
66
+ * Declarative presentation a bridge attaches to an item at `item.open` (and
67
+ * re-states on `item.close`, whose item is the full terminal shape). The
68
+ * assembler persists it on the canonical item so the row renders after the
69
+ * plugin is uninstalled or upgraded, and so mobile renders every kind without
70
+ * plugin code. The same schema as the persisted field
71
+ * (`threadEventItemPresentationSchema` in @bb/domain) — one vocabulary, no
72
+ * translation.
73
+ *
74
+ * Optional in grammar v3 while rows persisted before bridges stamped it are
75
+ * upgraded at read time; it becomes required together with the
76
+ * `legacy-tool-item-backfill` migration that stamps those rows and retires
77
+ * that adapter.
78
+ */
79
+ declare const deltaPresentationSchema: z.ZodObject<{
80
+ detail: z.ZodOptional<z.ZodString>;
81
+ icon: z.ZodObject<{
82
+ glyph: z.ZodString;
83
+ }, z.core.$strip>;
84
+ label: z.ZodObject<{
85
+ completed: z.ZodString;
86
+ pending: z.ZodString;
87
+ }, z.core.$strip>;
88
+ suppress: z.ZodOptional<z.ZodBoolean>;
89
+ tint: z.ZodOptional<z.ZodObject<{
90
+ dark: z.ZodString;
91
+ light: z.ZodString;
92
+ }, z.core.$strip>>;
93
+ title: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strip>;
95
+ type DeltaPresentation = z.infer<typeof deltaPresentationSchema>;
96
+ declare const deltaItemShapeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
97
+ aggregatedOutput: z.ZodOptional<z.ZodString>;
98
+ command: z.ZodString;
99
+ cwd: z.ZodString;
100
+ durationMs: z.ZodOptional<z.ZodNumber>;
101
+ exitCode: z.ZodOptional<z.ZodNumber>;
102
+ type: z.ZodLiteral<"command">;
103
+ }, z.core.$strip>, z.ZodObject<{
104
+ changes: z.ZodArray<z.ZodObject<{
105
+ diff: z.ZodOptional<z.ZodString>;
106
+ kind: z.ZodEnum<{
107
+ add: "add";
108
+ delete: "delete";
109
+ update: "update";
110
+ }>;
111
+ movePath: z.ZodOptional<z.ZodString>;
112
+ newText: z.ZodOptional<z.ZodString>;
113
+ oldText: z.ZodOptional<z.ZodString>;
114
+ path: z.ZodString;
115
+ }, z.core.$strip>>;
116
+ type: z.ZodLiteral<"fileChange">;
117
+ }, z.core.$strip>, z.ZodObject<{
118
+ args: z.ZodOptional<z.ZodUnknown>;
119
+ durationMs: z.ZodOptional<z.ZodNumber>;
120
+ error: z.ZodOptional<z.ZodString>;
121
+ result: z.ZodOptional<z.ZodUnknown>;
122
+ server: z.ZodOptional<z.ZodString>;
123
+ tool: z.ZodString;
124
+ type: z.ZodLiteral<"tool">;
125
+ }, z.core.$strip>, z.ZodObject<{
126
+ type: z.ZodLiteral<"compaction">;
127
+ }, z.core.$strip>, z.ZodObject<{
128
+ text: z.ZodString;
129
+ type: z.ZodLiteral<"agentMessage">;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ content: z.ZodArray<z.ZodString>;
132
+ summary: z.ZodArray<z.ZodString>;
133
+ type: z.ZodLiteral<"reasoning">;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ text: z.ZodString;
136
+ type: z.ZodLiteral<"plan">;
137
+ }, z.core.$strip>, z.ZodObject<{
138
+ queries: z.ZodArray<z.ZodString>;
139
+ type: z.ZodLiteral<"webSearch">;
140
+ }, z.core.$strip>, z.ZodObject<{
141
+ pattern: z.ZodNullable<z.ZodString>;
142
+ prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
143
+ type: z.ZodLiteral<"webFetch">;
144
+ url: z.ZodString;
145
+ }, z.core.$strip>, z.ZodObject<{
146
+ path: z.ZodString;
147
+ type: z.ZodLiteral<"imageView">;
148
+ }, z.core.$strip>, z.ZodObject<{
149
+ description: z.ZodString;
150
+ error: z.ZodOptional<z.ZodString>;
151
+ familyId: z.ZodString;
152
+ outputFile: z.ZodOptional<z.ZodString>;
153
+ skipTranscript: z.ZodBoolean;
154
+ status: z.ZodEnum<{
155
+ completed: "completed";
156
+ failed: "failed";
157
+ interrupted: "interrupted";
158
+ pending: "pending";
159
+ }>;
160
+ summary: z.ZodOptional<z.ZodString>;
161
+ taskStatus: z.ZodEnum<{
162
+ completed: "completed";
163
+ failed: "failed";
164
+ killed: "killed";
165
+ paused: "paused";
166
+ pending: "pending";
167
+ running: "running";
168
+ stopped: "stopped";
169
+ }>;
170
+ taskType: z.ZodString;
171
+ type: z.ZodLiteral<"backgroundTask">;
172
+ usage: z.ZodOptional<z.ZodObject<{
173
+ durationMs: z.ZodNumber;
174
+ toolUses: z.ZodNumber;
175
+ totalTokens: z.ZodNumber;
176
+ }, z.core.$strip>>;
177
+ workflow: z.ZodOptional<z.ZodObject<{
178
+ agents: z.ZodArray<z.ZodObject<{
179
+ agentType: z.ZodOptional<z.ZodString>;
180
+ attempt: z.ZodNumber;
181
+ cached: z.ZodBoolean;
182
+ durationMs: z.ZodOptional<z.ZodNumber>;
183
+ error: z.ZodOptional<z.ZodString>;
184
+ index: z.ZodNumber;
185
+ isolation: z.ZodOptional<z.ZodString>;
186
+ label: z.ZodString;
187
+ lastProgressAt: z.ZodNumber;
188
+ lastToolName: z.ZodOptional<z.ZodString>;
189
+ lastToolSummary: z.ZodOptional<z.ZodString>;
190
+ model: z.ZodString;
191
+ phaseIndex: z.ZodOptional<z.ZodNumber>;
192
+ phaseTitle: z.ZodOptional<z.ZodString>;
193
+ promptPreview: z.ZodOptional<z.ZodString>;
194
+ queuedAt: z.ZodOptional<z.ZodNumber>;
195
+ resultPreview: z.ZodOptional<z.ZodString>;
196
+ startedAt: z.ZodOptional<z.ZodNumber>;
197
+ state: z.ZodEnum<{
198
+ done: "done";
199
+ failed: "failed";
200
+ queued: "queued";
201
+ running: "running";
202
+ skipped: "skipped";
203
+ }>;
204
+ tokens: z.ZodOptional<z.ZodNumber>;
205
+ toolCalls: z.ZodOptional<z.ZodNumber>;
206
+ }, z.core.$strip>>;
207
+ phases: z.ZodArray<z.ZodObject<{
208
+ index: z.ZodNumber;
209
+ kind: z.ZodOptional<z.ZodString>;
210
+ title: z.ZodString;
211
+ }, z.core.$strip>>;
212
+ }, z.core.$strip>>;
213
+ workflowName: z.ZodOptional<z.ZodString>;
214
+ }, z.core.$strip>, z.ZodObject<{
215
+ cmd: z.ZodOptional<z.ZodString>;
216
+ path: z.ZodString;
217
+ type: z.ZodLiteral<"fileRead">;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ cmd: z.ZodOptional<z.ZodString>;
220
+ mode: z.ZodEnum<{
221
+ content: "content";
222
+ list: "list";
223
+ path: "path";
224
+ }>;
225
+ path: z.ZodOptional<z.ZodString>;
226
+ query: z.ZodString;
227
+ type: z.ZodLiteral<"search">;
228
+ }, z.core.$strip>, z.ZodObject<{
229
+ background: z.ZodBoolean;
230
+ childRef: z.ZodString;
231
+ label: z.ZodString;
232
+ summary: z.ZodOptional<z.ZodString>;
233
+ type: z.ZodLiteral<"delegation">;
234
+ }, z.core.$strip>, z.ZodObject<{
235
+ explanation: z.ZodOptional<z.ZodString>;
236
+ steps: z.ZodArray<z.ZodObject<{
237
+ status: z.ZodOptional<z.ZodEnum<{
238
+ active: "active";
239
+ completed: "completed";
240
+ failed: "failed";
241
+ pending: "pending";
242
+ }>>;
243
+ step: z.ZodString;
244
+ }, z.core.$strip>>;
245
+ type: z.ZodLiteral<"planSteps">;
246
+ }, z.core.$strip>, z.ZodObject<{
247
+ kind: z.ZodString & z.ZodType<`${string}/${string}`, string, z.core.$ZodTypeInternals<`${string}/${string}`, string>>;
248
+ payload: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
249
+ type: z.ZodLiteral<"extension">;
250
+ }, z.core.$strip>], "type">;
251
+ type DeltaItemShape = z.infer<typeof deltaItemShapeSchema>;
252
+
253
+ /** Where this bridge process may keep files, scoped to the owning plugin. */
254
+ interface ProviderBridgeContext {
255
+ /** The plugin that ships this bridge. */
256
+ pluginId: string;
257
+ /** Persistent, per-plugin, survives daemon restarts and plugin updates. */
258
+ dataDir: string;
259
+ /** This process only; removed when it exits. */
260
+ tempDir: string;
261
+ }
262
+ interface ProviderBridgeDefinition {
263
+ /** One decoded stdin line of the Provider Bridge Protocol. */
264
+ handleLine: (line: string) => void;
265
+ /**
266
+ * Called once before the first line is read, with the process's
267
+ * plugin-scoped directories. Omit it when the bridge keeps no files.
268
+ */
269
+ start?: (context: ProviderBridgeContext) => void;
270
+ /** Stdin closed: the runtime is gone and the bridge must shut down. */
271
+ onClose?: () => void;
272
+ onSigterm?: () => void;
273
+ onSigint?: () => void;
274
+ }
275
+ interface ProviderBridgeEntry extends ProviderBridgeDefinition {
276
+ /** Bumped when the bootstrap↔bridge contract changes incompatibly. */
277
+ experimental_apiVersion: 1;
278
+ }
279
+
280
+ declare const providerUsageResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
281
+ supported: z.ZodLiteral<false>;
282
+ }, z.core.$loose>, z.ZodObject<{
283
+ supported: z.ZodLiteral<true>;
284
+ usage: z.ZodDiscriminatedUnion<[z.ZodObject<{
285
+ accountEmail: z.ZodNullable<z.ZodString>;
286
+ planLabel: z.ZodNullable<z.ZodString>;
287
+ status: z.ZodLiteral<"ok">;
288
+ windows: z.ZodArray<z.ZodObject<{
289
+ cost: z.ZodOptional<z.ZodObject<{
290
+ limitUsdCents: z.ZodNumber;
291
+ usedUsdCents: z.ZodNumber;
292
+ }, z.core.$strip>>;
293
+ label: z.ZodString;
294
+ resetsAt: z.ZodNullable<z.ZodString>;
295
+ usedPercent: z.ZodNumber;
296
+ }, z.core.$loose>>;
297
+ }, z.core.$loose>, z.ZodObject<{
298
+ status: z.ZodLiteral<"not_installed">;
299
+ }, z.core.$loose>, z.ZodObject<{
300
+ status: z.ZodLiteral<"unauthenticated">;
301
+ }, z.core.$loose>, z.ZodObject<{
302
+ status: z.ZodLiteral<"expired">;
303
+ }, z.core.$loose>, z.ZodObject<{
304
+ accountEmail: z.ZodDefault<z.ZodNullable<z.ZodString>>;
305
+ message: z.ZodString;
306
+ planLabel: z.ZodDefault<z.ZodNullable<z.ZodString>>;
307
+ status: z.ZodLiteral<"error">;
308
+ }, z.core.$loose>], "status">;
309
+ }, z.core.$loose>], "supported">;
310
+ type ProviderUsageResult = z.infer<typeof providerUsageResultSchema>;
311
+
312
+ declare const experimental_providerBridge: ProviderBridgeEntry;
313
+
314
+ /**
315
+ * What an agent's own dialect knows about keeping it healthy: how a user
316
+ * signs in, whether bb can install it, and where its account and usage live.
317
+ * ACP standardizes none of it, so a generic bridge can only report whether
318
+ * the executable exists — everything richer belongs to the agent, and is
319
+ * therefore the dialect's (see `dialect.ts`), never a bb provider id's.
320
+ */
321
+ interface AcpMaintenanceDialect {
322
+ /** The shell command that signs the user in. */
323
+ loginCommand: string;
324
+ /** How bb installs or updates the agent, when it can. */
325
+ installer(): {
326
+ command: string;
327
+ args: string[];
328
+ displayCommand: string;
329
+ };
330
+ /** The signed-in account, or null when the agent is not signed in. */
331
+ readAccount(): Promise<{
332
+ email: string | null;
333
+ } | null>;
334
+ /** The agent's usage windows, for the usage surfaces. */
335
+ readUsage(): Promise<ProviderUsageResult>;
336
+ }
337
+
338
+ /**
339
+ * Zod schemas for the subset of the Agent Client Protocol (ACP) that BB
340
+ * consumes — https://agentclientprotocol.com. The bridge validates agent
341
+ * traffic with these before forwarding, and the adapter re-validates the
342
+ * `update` payloads it translates into thread events.
343
+ */
344
+
345
+ declare const acpToolKindSchema: z.ZodEnum<{
346
+ delete: "delete";
347
+ edit: "edit";
348
+ execute: "execute";
349
+ fetch: "fetch";
350
+ move: "move";
351
+ other: "other";
352
+ read: "read";
353
+ search: "search";
354
+ switch_mode: "switch_mode";
355
+ think: "think";
356
+ }>;
357
+ type AcpToolKind = z.infer<typeof acpToolKindSchema>;
358
+ declare const acpToolCallStatusSchema: z.ZodEnum<{
359
+ cancelled: "cancelled";
360
+ completed: "completed";
361
+ failed: "failed";
362
+ in_progress: "in_progress";
363
+ pending: "pending";
364
+ }>;
365
+ type AcpToolCallStatus = z.infer<typeof acpToolCallStatusSchema>;
366
+ declare const acpToolCallContentSchema: z.ZodUnion<readonly [z.ZodObject<{
367
+ content: z.ZodUnion<readonly [z.ZodObject<{
368
+ text: z.ZodString;
369
+ type: z.ZodLiteral<"text">;
370
+ }, z.core.$loose>, z.ZodObject<{
371
+ type: z.ZodString;
372
+ }, z.core.$loose>]>;
373
+ type: z.ZodLiteral<"content">;
374
+ }, z.core.$loose>, z.ZodObject<{
375
+ newText: z.ZodString;
376
+ oldText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
377
+ path: z.ZodString;
378
+ type: z.ZodLiteral<"diff">;
379
+ }, z.core.$loose>, z.ZodObject<{
380
+ terminalId: z.ZodString;
381
+ type: z.ZodLiteral<"terminal">;
382
+ }, z.core.$loose>]>;
383
+ type AcpToolCallContent = z.infer<typeof acpToolCallContentSchema>;
384
+ declare const acpToolCallUpdateEventSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
385
+ content: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodUnknown>, z.ZodTransform<({
386
+ [x: string]: unknown;
387
+ type: "content";
388
+ content: {
389
+ [x: string]: unknown;
390
+ type: "text";
391
+ text: string;
392
+ } | {
393
+ [x: string]: unknown;
394
+ type: string;
395
+ };
396
+ } | {
397
+ [x: string]: unknown;
398
+ type: "diff";
399
+ path: string;
400
+ newText: string;
401
+ oldText?: string | null | undefined;
402
+ } | {
403
+ [x: string]: unknown;
404
+ type: "terminal";
405
+ terminalId: string;
406
+ })[], unknown[]>>>;
407
+ kind: z.ZodOptional<z.ZodEnum<{
408
+ delete: "delete";
409
+ edit: "edit";
410
+ execute: "execute";
411
+ fetch: "fetch";
412
+ move: "move";
413
+ other: "other";
414
+ read: "read";
415
+ search: "search";
416
+ switch_mode: "switch_mode";
417
+ think: "think";
418
+ }>>;
419
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
420
+ line: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
421
+ path: z.ZodString;
422
+ }, z.core.$loose>>>;
423
+ name: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>, z.ZodTransform<string | undefined, string | null>>>;
424
+ rawInput: z.ZodOptional<z.ZodUnknown>;
425
+ rawKind: z.ZodOptional<z.ZodString>;
426
+ rawOutput: z.ZodOptional<z.ZodUnknown>;
427
+ sessionUpdate: z.ZodEnum<{
428
+ tool_call: "tool_call";
429
+ tool_call_update: "tool_call_update";
430
+ }>;
431
+ status: z.ZodOptional<z.ZodEnum<{
432
+ cancelled: "cancelled";
433
+ completed: "completed";
434
+ failed: "failed";
435
+ in_progress: "in_progress";
436
+ pending: "pending";
437
+ }>>;
438
+ title: z.ZodOptional<z.ZodString>;
439
+ toolCallId: z.ZodString;
440
+ }, z.core.$loose>>;
441
+ type AcpToolCallUpdateEvent = z.infer<typeof acpToolCallUpdateEventSchema>;
442
+
443
+ /**
444
+ * ACP tool call → grammar v3 item shape + presentation.
445
+ *
446
+ * An ACP agent describes a tool call with a native kind enum and a human
447
+ * title. The kind maps straight onto the core kinds: `execute` → `command`,
448
+ * `edit`/`delete` → `fileChange`, `read` → `fileRead`, `search` → `search`,
449
+ * `fetch` → `webFetch`, `think` → `reasoning`; everything else — `other`,
450
+ * `move`, an agent that sent no kind — is a generic `tool` whose `tool` slot
451
+ * names the kind. The title is never a tool name: it rides
452
+ * `presentation.title`.
453
+ *
454
+ * A core shape has required fields the agent does not always fill (Cursor's
455
+ * `read` and `fetch` calls carry an empty `rawInput` and no `locations`). A
456
+ * kind whose shape cannot be built honestly stays a generic `tool` that
457
+ * presents as its kind ("Reading file" with the agent's title), so a row is
458
+ * never a `fileRead` without a path or a `webFetch` without a URL.
459
+ *
460
+ * The command / file-change decision is `tool-call-operation.ts`'s, which the
461
+ * permission mapping shares, so an approval row and its timeline item never
462
+ * disagree (#1803).
463
+ */
464
+
465
+ /** A tool call's item shape plus the presentation that rides its lifecycle. */
466
+ interface AcpClassifiedToolCall {
467
+ item: DeltaItemShape;
468
+ presentation: DeltaPresentation;
469
+ }
470
+
471
+ /**
472
+ * Per-agent dialects: the vendor side channels of an ACP agent.
473
+ *
474
+ * The ACP wire schema (`wire.ts`) parses only the protocol. What an agent
475
+ * puts beside the protocol is a dialect: grok stamps `_meta["x.ai/tool"]` on
476
+ * every tool event, Cursor reports its sub-agents through a vendor JSON-RPC
477
+ * request (`cursor/task`) that the protocol has no place for. A dialect is a
478
+ * small, per-agent module that reads those channels and answers the few
479
+ * questions the shared translator asks. The shared schema never learns a
480
+ * vendor key, and a dialect never changes what a protocol field means.
481
+ *
482
+ * Version 1 of the protocol has no sub-agent concept at all (`session/fork`
483
+ * is unstable and unrelated), so every delegation an ACP agent reports is
484
+ * vendor-specific and belongs here rather than in the classifier.
485
+ *
486
+ * The dialect is selected per session from the agent's launch command. An
487
+ * agent with no dialect of its own gets the generic one, which answers
488
+ * nothing and leaves every decision to the protocol fields.
489
+ */
490
+
491
+ /**
492
+ * The programmatic identity of a tool call, when the agent reports one
493
+ * outside the protocol's unstable `name` field: the tool's own name and, for
494
+ * an agent that sends the `kind` late (grok puts it on the first update, a
495
+ * few milliseconds after the `tool_call`), the kind at open, so the opened
496
+ * shape and the closed shape agree.
497
+ */
498
+ interface AcpToolIdentity {
499
+ name?: string;
500
+ kind?: AcpToolKind;
501
+ }
502
+ /** What a dialect learned about a sub-agent the agent launched. */
503
+ interface AcpDelegationReport {
504
+ /** The tool call the delegation belongs to. */
505
+ toolCallId: string;
506
+ /** The child's provider-native id. */
507
+ childRef: string;
508
+ /** The row headline: what the sub-agent was asked to do. */
509
+ label: string;
510
+ /** A sub-agent type or model the row can name, when the agent says. */
511
+ detail?: string;
512
+ }
513
+ interface AcpDialect {
514
+ /** Stable id, for logs and tests. */
515
+ readonly id: string;
516
+ /**
517
+ * The tool identity a tool_call / tool_call_update carries in the agent's
518
+ * side channel, if any. The translator fills an absent protocol `name` and
519
+ * `kind` from it; a protocol value always wins over the dialect's.
520
+ */
521
+ toolIdentity?(event: AcpToolCallUpdateEvent): AcpToolIdentity | undefined;
522
+ /**
523
+ * The agent's own classification of a tool call, when its side channel
524
+ * says something the protocol fields cannot. Returning `undefined` leaves
525
+ * the shared classifier in charge — which is the normal answer.
526
+ */
527
+ classifyToolCall?(event: AcpToolCallUpdateEvent): AcpClassifiedToolCall | undefined;
528
+ /**
529
+ * A vendor JSON-RPC request the agent sends to the client. A dialect that
530
+ * answers one returns the JSON-RPC result to reply with (`{}` is a valid
531
+ * acknowledgement) and, optionally, what the request reported. A request
532
+ * no dialect claims stays an unsupported method.
533
+ */
534
+ handleClientRequest?(method: string, params: unknown): AcpClientRequestOutcome | undefined;
535
+ /**
536
+ * How bb keeps this agent healthy: sign-in, installation, account and
537
+ * usage. ACP standardizes none of it, so an agent without one reports only
538
+ * whether its executable exists.
539
+ */
540
+ maintenance?: AcpMaintenanceDialect;
541
+ }
542
+ interface AcpClientRequestOutcome {
543
+ /** The JSON-RPC result the bridge replies with. */
544
+ result: Record<string, unknown>;
545
+ /** A sub-agent the request reported, if it reported one. */
546
+ delegation?: AcpDelegationReport;
547
+ }
548
+
549
+ /**
550
+ * What one installed ACP agent can actually do (Q21).
551
+ *
552
+ * A provider declaration states its capabilities before any agent has spoken,
553
+ * so bb declared one answer for every ACP agent and got them wrong: the ACP
554
+ * tier offered `session/fork` for five agents, of which the two bb has since
555
+ * read the wire for support none of it. A declaration above what the agent
556
+ * answers is not a missing feature — the bridge refuses the fork only after
557
+ * bb created the fork thread, so the thread dies on start (get-bb/bb#1833).
558
+ *
559
+ * The agent already reports the truth: `initialize` returns
560
+ * `agentCapabilities`. This probe asks it. It runs on the host, because the
561
+ * agent is a host-local executable, and it is deliberately cheap and
562
+ * disposable: spawn, initialize, read the reply, kill. It never starts a
563
+ * session and never prompts.
564
+ */
565
+
566
+ interface AcpAgentProbeRequest {
567
+ command: string;
568
+ args: readonly string[];
569
+ /** Extra environment the agent's launch spec asks for. */
570
+ env?: Record<string, string>;
571
+ /** Where to run the probe; the agent may refuse to start without one. */
572
+ cwd: string;
573
+ timeoutMs?: number;
574
+ }
575
+ /** What the agent said about itself, or why bb could not ask. */
576
+ type AcpAgentProbe = {
577
+ reachable: true;
578
+ /** The agent implements the unstable `session/fork`. */
579
+ fork: boolean;
580
+ } | {
581
+ reachable: false;
582
+ reason: string;
583
+ };
584
+ /**
585
+ * Ask one agent what it supports. Never throws: an agent that is missing,
586
+ * broken, or too slow is a `reachable: false` answer with the reason, which
587
+ * the caller reports as "bb could not verify this agent" rather than as a
588
+ * capability.
589
+ */
590
+ declare function probeAcpAgent(request: AcpAgentProbeRequest): Promise<AcpAgentProbe>;
591
+ declare const acpAgentProbeSchema: z.ZodType<AcpAgentProbe>;
592
+
593
+ declare const acpLaunchSpecSchema: z.ZodObject<{
594
+ args: z.ZodArray<z.ZodString>;
595
+ command: z.ZodString;
596
+ cwd: z.ZodOptional<z.ZodString>;
597
+ displayName: z.ZodString;
598
+ env: z.ZodRecord<z.ZodString, z.ZodString>;
599
+ modelCli: z.ZodOptional<z.ZodPipe<z.ZodObject<{
600
+ listArgs: z.ZodArray<z.ZodString>;
601
+ primaryModels: z.ZodArray<z.ZodString>;
602
+ selectFlag: z.ZodOptional<z.ZodString>;
603
+ }, z.core.$strict>, z.ZodTransform<{
604
+ listArgs: string[];
605
+ primaryModels: string[];
606
+ selectFlag?: string | undefined;
607
+ } | undefined, {
608
+ listArgs: string[];
609
+ primaryModels: string[];
610
+ selectFlag?: string | undefined;
611
+ }>>>;
612
+ nativeReasoning: z.ZodOptional<z.ZodObject<{
613
+ configId: z.ZodString;
614
+ defaultLevel: z.ZodOptional<z.ZodEnum<{
615
+ high: "high";
616
+ low: "low";
617
+ max: "max";
618
+ medium: "medium";
619
+ none: "none";
620
+ ultra: "ultra";
621
+ ultracode: "ultracode";
622
+ xhigh: "xhigh";
623
+ }>>;
624
+ levelValues: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
625
+ high: "high";
626
+ low: "low";
627
+ max: "max";
628
+ medium: "medium";
629
+ none: "none";
630
+ ultra: "ultra";
631
+ ultracode: "ultracode";
632
+ xhigh: "xhigh";
633
+ }> & z.core.$partial, z.ZodString>>;
634
+ supportedLevels: z.ZodArray<z.ZodEnum<{
635
+ high: "high";
636
+ low: "low";
637
+ max: "max";
638
+ medium: "medium";
639
+ none: "none";
640
+ ultra: "ultra";
641
+ ultracode: "ultracode";
642
+ xhigh: "xhigh";
643
+ }>>;
644
+ }, z.core.$strict>>;
645
+ nativeSkillRoots: z.ZodOptional<z.ZodObject<{
646
+ project: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
647
+ ancestors: z.ZodOptional<z.ZodBoolean>;
648
+ namePrefix: z.ZodOptional<z.ZodString>;
649
+ path: z.ZodString;
650
+ recursive: z.ZodOptional<z.ZodBoolean>;
651
+ skipIfManifest: z.ZodOptional<z.ZodString>;
652
+ }, z.core.$strict>]>>>;
653
+ user: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
654
+ ancestors: z.ZodOptional<z.ZodBoolean>;
655
+ namePrefix: z.ZodOptional<z.ZodString>;
656
+ path: z.ZodString;
657
+ recursive: z.ZodOptional<z.ZodBoolean>;
658
+ skipIfManifest: z.ZodOptional<z.ZodString>;
659
+ }, z.core.$strict>]>>>;
660
+ }, z.core.$strict>>;
661
+ permissionCli: z.ZodOptional<z.ZodObject<{
662
+ full: z.ZodOptional<z.ZodArray<z.ZodString>>;
663
+ insertAfterArgs: z.ZodOptional<z.ZodNumber>;
664
+ readonly: z.ZodOptional<z.ZodArray<z.ZodString>>;
665
+ workspaceWrite: z.ZodOptional<z.ZodArray<z.ZodString>>;
666
+ }, z.core.$strict>>;
667
+ reasoningCli: z.ZodOptional<z.ZodObject<{
668
+ defaultLevel: z.ZodOptional<z.ZodEnum<{
669
+ high: "high";
670
+ low: "low";
671
+ max: "max";
672
+ medium: "medium";
673
+ none: "none";
674
+ ultra: "ultra";
675
+ ultracode: "ultracode";
676
+ xhigh: "xhigh";
677
+ }>>;
678
+ flag: z.ZodString;
679
+ levelValues: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
680
+ high: "high";
681
+ low: "low";
682
+ max: "max";
683
+ medium: "medium";
684
+ none: "none";
685
+ ultra: "ultra";
686
+ ultracode: "ultracode";
687
+ xhigh: "xhigh";
688
+ }> & z.core.$partial, z.ZodString>>;
689
+ supportedLevels: z.ZodArray<z.ZodEnum<{
690
+ high: "high";
691
+ low: "low";
692
+ max: "max";
693
+ medium: "medium";
694
+ none: "none";
695
+ ultra: "ultra";
696
+ ultracode: "ultracode";
697
+ xhigh: "xhigh";
698
+ }>>;
699
+ }, z.core.$strict>>;
700
+ }, z.core.$strict>;
701
+ type AcpLaunchSpec = z.infer<typeof acpLaunchSpecSchema>;
702
+
703
+ /**
704
+ * Agent CLI model catalog.
705
+ *
706
+ * Cursor's `cursor-agent --list-models` prints one
707
+ * `id - Display Name` line per model,
708
+ * OpenCode's `opencode models` prints one bare id per line, and Grok's
709
+ * `grok models` prints a bulleted list. These ids can encode reasoning effort:
710
+ * `gpt-5.3-codex-low`, bare `gpt-5.3-codex` for medium, `gpt-5.5-extra-high`
711
+ * as an alternate xhigh spelling, with an optional `-fast` service tail after
712
+ * the effort token (`gpt-5.3-codex-low-fast`). This module groups those raw
713
+ * variants into bb model families so the picker offers one clean entry per
714
+ * family with selectable reasoning efforts, and resolves a (family, effort,
715
+ * serviceTier) selection back to the exact raw id at session launch — by table
716
+ * lookup, never string synthesis, because effort spellings vary per family.
717
+ *
718
+ * The `-fast` tail is a service tier, not a separate model: both the normal
719
+ * and fast raw ids for a given effort collapse into one family, and the bb
720
+ * "Fast mode" toggle (serviceTier) selects between them at launch.
721
+ *
722
+ * Cursor's "thinking" marker (appearing as an infix `…-thinking-medium` or a
723
+ * suffix `…-medium-thinking` / `…-thinking`) is folded into the reasoning
724
+ * ladder too: thinking variants keep their effort, and the model's
725
+ * non-thinking variants collapse onto a single "none" (thinking-off) level at
726
+ * the bottom of the ladder. So one "Opus 4.8" entry offers None, Low … Max
727
+ * instead of separate "Opus 4.8" and "Opus 4.8 Thinking" rows. An explicit
728
+ * `-none` effort id (e.g. `gpt-5.5-none`) is the same "none" level.
729
+ *
730
+ * Display names are stripped of noise the picker renders elsewhere or doesn't
731
+ * need — the per-model effort word and "Thinking" marker (reasoning has its
732
+ * own control), the redundant `1M` context tag, the `(NO ZDR)` data-retention
733
+ * marker, and Cursor's own `(default)`/`(current)` annotations.
734
+ */
735
+
736
+ interface AgentModelCatalog {
737
+ models: AvailableModel[];
738
+ /**
739
+ * Exact raw agent id for the family identified by its default-variant id
740
+ * (`AvailableModel.id`) at the given effort and service tier. Picks the
741
+ * `-fast` id when `serviceTier` is "fast" and the family has one, otherwise
742
+ * the normal id. `reasoningLevel` omitted falls back to the family's default
743
+ * effort. Returns undefined when the family or requested effort is unknown.
744
+ */
745
+ resolveVariant(args: {
746
+ model: string;
747
+ reasoningLevel?: ReasoningLevel;
748
+ serviceTier?: ServiceTier;
749
+ }): string | undefined;
750
+ }
751
+
752
+ /**
753
+ * `@get-bb/plugin-sdk/provider-bridge/acp` — the published ACP bridge kit.
754
+ *
755
+ * The Agent Client Protocol (https://agentclientprotocol.com) is one wire
756
+ * protocol spoken by many agents, so bb runs all of them through one generic
757
+ * bridge: the agent to launch arrives per command in the provider options,
758
+ * and nothing in the bridge is bb-first-party. A plugin that wants to add an
759
+ * ACP agent re-exports the bridge from its `bb.host` artifact and registers
760
+ * its providers as any other plugin does:
761
+ *
762
+ * ```ts
763
+ * // host.ts (the plugin's `bb.host` entry)
764
+ * export { experimental_acpProviderBridge as experimental_providerBridge }
765
+ * from "@get-bb/plugin-sdk/provider-bridge/acp";
766
+ *
767
+ * // server.ts
768
+ * bb.providers.register({
769
+ * id: "amp",
770
+ * displayName: "Amp",
771
+ * experimental_bridgeOptions: {
772
+ * acpLaunchSpec: { displayName: "Amp", command: "amp", args: ["acp"], env: {} },
773
+ * acpDialect: "generic",
774
+ * },
775
+ * // …the rest of the declaration
776
+ * })
777
+ * ```
778
+ *
779
+ * **Dialects.** Version 1 of the protocol has no sub-agent concept and
780
+ * standardizes nothing about `rawInput`, so what most distinguishes one
781
+ * agent from another lives beside the protocol: grok stamps
782
+ * `_meta["x.ai/tool"]` on every tool event, Cursor reports sub-agents
783
+ * through a vendor `cursor/task` request. A dialect is a small module that
784
+ * reads those channels; the bridge ships `generic`, `cursor` and `grok`,
785
+ * named by id in the registration's bridge options (`acpDialect`). The
786
+ * dialect registry itself is not public yet: no plugin has needed to supply
787
+ * one, and its shape (process-global, unversioned hooks) is still open — see
788
+ * docs/api_to_audit.md.
789
+ *
790
+ * Curated by hand — named exports only, never `export *`. Value exports
791
+ * carry the `experimental_` prefix every new plugin API member ships with
792
+ * (see docs/api_to_audit.md); types are unprefixed. Exports no plugin
793
+ * consumes are not published: the surface grows with a consumer, not ahead
794
+ * of one.
795
+ */
796
+
797
+ /**
798
+ * @deprecated The bridge reads the parsed `AcpLaunchSpec` directly; the
799
+ * profile it used to derive from the spec carried the same fields under
800
+ * other names, and nothing outside the bridge produced or consumed it. Kept
801
+ * as an alias because 0.4.x published the name; scheduled for removal at the
802
+ * next major (docs/api_to_audit.md).
803
+ */
804
+ type AcpAgentProfile = AcpLaunchSpec;
805
+
806
+ export { acpAgentProbeSchema as experimental_acpAgentProbeSchema, acpLaunchSpecSchema as experimental_acpLaunchSpecSchema, experimental_providerBridge as experimental_acpProviderBridge, probeAcpAgent as experimental_probeAcpAgent };
807
+ export type { AgentModelCatalog as AcpAgentModelCatalog, AcpAgentProbe, AcpAgentProbeRequest, AcpAgentProfile, AcpClassifiedToolCall, AcpClientRequestOutcome, AcpDelegationReport, AcpDialect, AcpLaunchSpec, AcpToolCallContent, AcpToolCallStatus, AcpToolCallUpdateEvent, AcpToolIdentity, AcpToolKind };