@get-bb/plugin-sdk 0.4.24 → 0.4.27
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.
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +0 -25
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +0 -200
- package/bundled-types/bb-plugin-sdk-provider-bridge-testing.d.ts +0 -440
- package/bundled-types/bb-plugin-sdk-provider-bridge.d.ts +0 -665
- package/bundled-types/bb-plugin-sdk-testing.d.ts +0 -16
- package/bundled-types/bb-plugin-sdk.d.ts +25 -277
- package/dist/ai-services.js +5 -1
- package/dist/internal/host-policy.js +95 -108
- package/dist/provider-bridge-acp.js +72 -615
- package/dist/provider-bridge-testing.js +175 -579
- package/dist/provider-bridge-worker-entry.mjs +15 -9
- package/dist/provider-bridge.js +62 -557
- package/dist/testing/index.js +133 -114
- package/package.json +1 -1
|
@@ -87,14 +87,6 @@ interface JsonObject {
|
|
|
87
87
|
type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
|
|
88
88
|
declare const jsonValueSchema: z.ZodType<JsonValue>;
|
|
89
89
|
|
|
90
|
-
/**
|
|
91
|
-
* Raw SDK task-type discriminants for the background tasks bb materializes as
|
|
92
|
-
* timeline rows: dynamic workflows (the Workflow tool), backgrounded shell
|
|
93
|
-
* commands (Bash with run_in_background), and backgrounded subagents. They
|
|
94
|
-
* share the provider task event family (task_started / task_progress /
|
|
95
|
-
* task_updated / task_notification). Other task types such as monitors share
|
|
96
|
-
* the family too but are not materialized.
|
|
97
|
-
*/
|
|
98
90
|
declare const LOCAL_WORKFLOW_TASK_TYPE = "local_workflow";
|
|
99
91
|
declare const LOCAL_BASH_TASK_TYPE = "local_bash";
|
|
100
92
|
declare function isBackgroundAgentTaskType(taskType: string): boolean;
|
|
@@ -152,11 +144,6 @@ declare const workflowPhaseSnapshotSchema: z.ZodObject<{
|
|
|
152
144
|
title: z.ZodString;
|
|
153
145
|
}, z.core.$strip>;
|
|
154
146
|
type WorkflowPhaseSnapshot = z.infer<typeof workflowPhaseSnapshotSchema>;
|
|
155
|
-
/**
|
|
156
|
-
* Full merged workflow state at a point in time. Providers emit progress as
|
|
157
|
-
* delta batches; the adapter folds them by (record type, index) so every
|
|
158
|
-
* persisted snapshot supersedes the previous one.
|
|
159
|
-
*/
|
|
160
147
|
declare const workflowProgressSnapshotSchema: z.ZodObject<{
|
|
161
148
|
agents: z.ZodArray<z.ZodObject<{
|
|
162
149
|
agentType: z.ZodOptional<z.ZodString>;
|
|
@@ -200,19 +187,7 @@ declare const backgroundTaskUsageSchema: z.ZodObject<{
|
|
|
200
187
|
totalTokens: z.ZodNumber;
|
|
201
188
|
}, z.core.$strip>;
|
|
202
189
|
type BackgroundTaskUsage = z.infer<typeof backgroundTaskUsageSchema>;
|
|
203
|
-
/**
|
|
204
|
-
* Canonical derivation from the provider-reported task status to the shared
|
|
205
|
-
* item-status machinery: paused stays pending because a paused workflow is
|
|
206
|
-
* resumable; stopped maps to interrupted (user/system stop, not a failure).
|
|
207
|
-
*/
|
|
208
190
|
declare function backgroundTaskItemStatus(taskStatus: BackgroundTaskStatus): "completed" | "failed" | "interrupted" | "pending";
|
|
209
|
-
/**
|
|
210
|
-
* Whether the provider-reported status already describes a finished task.
|
|
211
|
-
* Settle backstops (thread restart, daemon crash, lease expiry) must preserve
|
|
212
|
-
* these statuses instead of rewriting them to "stopped": a workflow whose
|
|
213
|
-
* completion patch arrived before its terminal notification is completed, not
|
|
214
|
-
* interrupted.
|
|
215
|
-
*/
|
|
216
191
|
declare function isSettledBackgroundTaskStatus(taskStatus: BackgroundTaskStatus): boolean;
|
|
217
192
|
|
|
218
193
|
declare const threadEventItemPresentationSchema: z.ZodObject<{
|
|
@@ -553,12 +528,6 @@ declare const pluginPendingInteractionPayloadSchema: z.ZodObject<{
|
|
|
553
528
|
title: z.ZodString;
|
|
554
529
|
}, z.core.$strip>;
|
|
555
530
|
type PluginPendingInteractionPayload = z.infer<typeof pluginPendingInteractionPayloadSchema>;
|
|
556
|
-
/**
|
|
557
|
-
* The open request family. A plain union rather than a discriminated one
|
|
558
|
-
* because the plugin member's `kind` is a namespace pattern, not a literal;
|
|
559
|
-
* the core literal (`user_question`) contains no "/" so the members never
|
|
560
|
-
* overlap.
|
|
561
|
-
*/
|
|
562
531
|
declare const interactionRequestPayloadSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
563
532
|
kind: z.ZodLiteral<"user_question">;
|
|
564
533
|
questions: z.ZodArray<z.ZodObject<{
|
|
@@ -579,11 +548,6 @@ declare const interactionRequestPayloadSchema: z.ZodUnion<readonly [z.ZodObject<
|
|
|
579
548
|
title: z.ZodString;
|
|
580
549
|
}, z.core.$strip>]>;
|
|
581
550
|
type InteractionRequestPayload = z.infer<typeof interactionRequestPayloadSchema>;
|
|
582
|
-
/**
|
|
583
|
-
* The payload a provider raises through `interaction/request`: an approval,
|
|
584
|
-
* a user question, or a plugin-defined request. A plain union because the
|
|
585
|
-
* plugin member's kind is a namespace pattern, not a literal.
|
|
586
|
-
*/
|
|
587
551
|
declare const pendingInteractionPayloadSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
588
552
|
availableDecisions: z.ZodArray<z.ZodEnum<{
|
|
589
553
|
allow_for_session: "allow_for_session";
|
|
@@ -1199,11 +1163,6 @@ declare const threadEventPlanStepSchema: z.ZodObject<{
|
|
|
1199
1163
|
step: z.ZodString;
|
|
1200
1164
|
}, z.core.$strip>;
|
|
1201
1165
|
type ThreadEventPlanStep = z.infer<typeof threadEventPlanStepSchema>;
|
|
1202
|
-
/**
|
|
1203
|
-
* How a `search` item looked for things: `content` searches inside files
|
|
1204
|
-
* (grep, Claude `Grep`), `path` matches file names (Claude `Glob`, `fd`),
|
|
1205
|
-
* `list` enumerates a directory (`ls`, codex `list_dir`).
|
|
1206
|
-
*/
|
|
1207
1166
|
declare const threadEventSearchModeSchema: z.ZodEnum<{
|
|
1208
1167
|
content: "content";
|
|
1209
1168
|
list: "list";
|
|
@@ -1246,17 +1205,6 @@ declare const providerRawEventSchema: z.ZodObject<{
|
|
|
1246
1205
|
}, z.core.$strip>;
|
|
1247
1206
|
type ProviderRawEvent = z.infer<typeof providerRawEventSchema>;
|
|
1248
1207
|
|
|
1249
|
-
/**
|
|
1250
|
-
* Order is load-bearing: `reasoningRank` (index) drives model-switch
|
|
1251
|
-
* reconciliation. "none" (no extended thinking) sits at the bottom — only
|
|
1252
|
-
* providers that expose a thinking-off variant list it (currently Cursor and
|
|
1253
|
-
* Pi models whose `thinkingLevelMap` advertises `off`).
|
|
1254
|
-
* "ultracode" sits between "xhigh" and "max" because its underlying effort IS
|
|
1255
|
-
* xhigh (plus standing workflow orchestration) — a model without ultracode
|
|
1256
|
-
* support should reconcile down to xhigh, not up to max.
|
|
1257
|
-
* "ultra" is a Codex-native top tier (max effort plus automatic task
|
|
1258
|
-
* delegation) exposed only by some models; it ranks above "max".
|
|
1259
|
-
*/
|
|
1260
1208
|
declare const reasoningLevelValues: readonly ["none", "low", "medium", "high", "xhigh", "ultracode", "max", "ultra"];
|
|
1261
1209
|
declare const reasoningLevelSchema: z.ZodEnum<{
|
|
1262
1210
|
high: "high";
|
|
@@ -1274,13 +1222,6 @@ declare const serviceTierSchema: z.ZodEnum<{
|
|
|
1274
1222
|
fast: "fast";
|
|
1275
1223
|
}>;
|
|
1276
1224
|
type ServiceTier = z.infer<typeof serviceTierSchema>;
|
|
1277
|
-
/**
|
|
1278
|
-
* Controls how a provider should incorporate server-owned instructions into its
|
|
1279
|
-
* system prompt.
|
|
1280
|
-
*
|
|
1281
|
-
* - `append`: keep the provider's preset system prompt and append instructions.
|
|
1282
|
-
* - `replace`: use the provided instructions as the full system prompt.
|
|
1283
|
-
*/
|
|
1284
1225
|
declare const instructionModeValues: readonly ["append", "replace"];
|
|
1285
1226
|
declare const instructionModeSchema: z.ZodEnum<{
|
|
1286
1227
|
append: "append";
|
|
@@ -1389,10 +1330,6 @@ interface PromptCommandSelector {
|
|
|
1389
1330
|
trigger: PromptMentionCommandTrigger;
|
|
1390
1331
|
name: string;
|
|
1391
1332
|
}
|
|
1392
|
-
/**
|
|
1393
|
-
* Whether input consists solely of one selected built-in `/compact` mention.
|
|
1394
|
-
* Raw matching text and project/user commands intentionally do not qualify.
|
|
1395
|
-
*/
|
|
1396
1333
|
declare function isStandaloneBuiltinCompactCommand(input: readonly PromptInput[]): boolean;
|
|
1397
1334
|
declare function removeCommandMentionsFromPromptInput(input: readonly PromptInput[], selector: PromptCommandSelector): PromptInput[];
|
|
1398
1335
|
declare const runtimePermissionScopeValues: readonly ["workspace", "full"];
|
|
@@ -1428,10 +1365,8 @@ type RuntimePermissionPolicy = z.infer<typeof runtimePermissionPolicySchema>;
|
|
|
1428
1365
|
declare const clientTurnRequestIdSchema: z.ZodString;
|
|
1429
1366
|
type ClientTurnRequestId = z.infer<typeof clientTurnRequestIdSchema>;
|
|
1430
1367
|
|
|
1431
|
-
/** A namespaced extension kind, `"<pluginId>/<name>"`. */
|
|
1432
1368
|
type ExtensionKind = `${string}/${string}`;
|
|
1433
1369
|
declare function isExtensionKind(value: string): value is ExtensionKind;
|
|
1434
|
-
/** Parses to the {@link ExtensionKind} type, so consumers can split it. */
|
|
1435
1370
|
declare const extensionKindSchema: z.ZodString & z.ZodType<`${string}/${string}`, string, z.core.$ZodTypeInternals<`${string}/${string}`, string>>;
|
|
1436
1371
|
|
|
1437
1372
|
declare const modelReasoningEffortSchema: z.ZodObject<{
|
|
@@ -1480,32 +1415,6 @@ declare const availableModelSchema: z.ZodObject<{
|
|
|
1480
1415
|
}, z.core.$strip>>;
|
|
1481
1416
|
}, z.core.$strip>;
|
|
1482
1417
|
type AvailableModel = z.infer<typeof availableModelSchema>;
|
|
1483
|
-
/**
|
|
1484
|
-
* Typed recovery hints a provider bridge raises instead of error text the
|
|
1485
|
-
* runtime would otherwise have to pattern-match (`provider/recovery`, see
|
|
1486
|
-
* `providerRecoveryNotificationSchema` in @bb/provider-bridge-protocol).
|
|
1487
|
-
*
|
|
1488
|
-
* - `sessionArchived`: the provider refused because its session is archived;
|
|
1489
|
-
* the runtime unarchives and retries.
|
|
1490
|
-
* - `authRequired`: credentials are missing or expired; typed error plus a
|
|
1491
|
-
* health refresh.
|
|
1492
|
-
* - `restartRecommended`: the bridge wants a fresh process; the runtime
|
|
1493
|
-
* restarts it and resumes the session.
|
|
1494
|
-
* - `staleTurn`: the steer or stop named a turn that is no longer live; the
|
|
1495
|
-
* runtime drops it.
|
|
1496
|
-
* - `rateLimited`: the provider throttled the request; the runtime schedules
|
|
1497
|
-
* a retry.
|
|
1498
|
-
*
|
|
1499
|
-
* Consumed by `sendCommand` in packages/agent-runtime/src/runtime.ts, which
|
|
1500
|
-
* reads the hint off the bridge's rejection and acts on it (unarchive and
|
|
1501
|
-
* retry, typed `auth_required` / `rate_limited` errors, bridge restart,
|
|
1502
|
-
* rate-limit retry); `steerTurn` there claims `staleTurn`. The hints the
|
|
1503
|
-
* runtime cannot fully act on itself (`authRequired`, `restartRecommended`,
|
|
1504
|
-
* and a `rateLimited` that is terminal or ends the retry ladder), plus every
|
|
1505
|
-
* hint raised as a notification, are also forwarded to the daemon through
|
|
1506
|
-
* `onProviderRecovery`, which is where the health re-check after
|
|
1507
|
-
* `authRequired` happens.
|
|
1508
|
-
*/
|
|
1509
1418
|
declare const providerRecoveryKindValues: readonly ["sessionArchived", "authRequired", "restartRecommended", "staleTurn", "rateLimited"];
|
|
1510
1419
|
declare const providerRecoveryKindSchema: z.ZodEnum<{
|
|
1511
1420
|
authRequired: "authRequired";
|
|
@@ -1515,20 +1424,6 @@ declare const providerRecoveryKindSchema: z.ZodEnum<{
|
|
|
1515
1424
|
staleTurn: "staleTurn";
|
|
1516
1425
|
}>;
|
|
1517
1426
|
type ProviderRecoveryKind = z.infer<typeof providerRecoveryKindSchema>;
|
|
1518
|
-
/**
|
|
1519
|
-
* A bb-injected tool handed to a provider bridge at session construction.
|
|
1520
|
-
*
|
|
1521
|
-
* `presentation` is how a call to this tool reads as a timeline row (grammar
|
|
1522
|
-
* v3, docs/provider-plugin-api.md §3): the bridge stamps it on the
|
|
1523
|
-
* `item.open`/`item.close` for the call beside `server: "bb"`, so no core
|
|
1524
|
-
* table of bb tool names is needed to label the row. The server resolves it
|
|
1525
|
-
* once, at its boundary, for every tool it injects — from the owning
|
|
1526
|
-
* plugin's declaration, falling back to a generic label and the plugin's
|
|
1527
|
-
* glyph. Optional on the wire while the grammar migrates (A1, additive then
|
|
1528
|
-
* delete): a definition recorded before the field existed carries none, and
|
|
1529
|
-
* a bridge then presents the call generically; the stabilization pass makes
|
|
1530
|
-
* it required.
|
|
1531
|
-
*/
|
|
1532
1427
|
declare const dynamicToolSchema: z.ZodObject<{
|
|
1533
1428
|
description: z.ZodString;
|
|
1534
1429
|
inputSchema: z.ZodUnknown;
|
|
@@ -1560,93 +1455,35 @@ declare const ULTRACODE_REASONING_EFFORT: ModelReasoningEffort;
|
|
|
1560
1455
|
declare const MAX_REASONING_EFFORT: ModelReasoningEffort;
|
|
1561
1456
|
declare function reasoningEffortsForLevels(levels: readonly ReasoningLevel[]): ModelReasoningEffort[];
|
|
1562
1457
|
|
|
1563
|
-
/**
|
|
1564
|
-
* Shared adapter utilities.
|
|
1565
|
-
*
|
|
1566
|
-
* Functions and constants duplicated across the claude-code, pi, and codex
|
|
1567
|
-
* adapters are extracted here so each adapter imports from one place.
|
|
1568
|
-
*/
|
|
1569
|
-
|
|
1570
1458
|
declare function toOptionalString(value: unknown): string | undefined;
|
|
1571
1459
|
declare function toOptionalRecord(value: unknown): Record<string, unknown> | undefined;
|
|
1572
|
-
/**
|
|
1573
|
-
* The environment overrides a bridge may hand its provider: the requested
|
|
1574
|
-
* variables minus any name a shell would refuse. A rejected name is dropped,
|
|
1575
|
-
* never passed through — a provider that inherits an unquotable name can fail
|
|
1576
|
-
* its whole session on one bad key.
|
|
1577
|
-
*/
|
|
1578
1460
|
declare function buildShellEnvOverrides(envVars?: Record<string, string>): Record<string, string>;
|
|
1579
1461
|
declare function toNonNegativeNumber(value: unknown): number;
|
|
1580
1462
|
declare function normalizeProviderCommandOutput(args: {
|
|
1581
1463
|
emptyPlaceholders: readonly string[];
|
|
1582
1464
|
text: string;
|
|
1583
1465
|
}): string | undefined;
|
|
1584
|
-
/**
|
|
1585
|
-
* Extracts text from tool result content.
|
|
1586
|
-
* Handles strings, arrays of text blocks, and `{ content: [...] }` wrappers.
|
|
1587
|
-
*/
|
|
1588
1466
|
declare function extractResultText(content: unknown): string;
|
|
1589
|
-
/** The empty breakdown a bridge's per-session usage accumulator starts from. */
|
|
1590
1467
|
declare const ZERO_TOKEN_USAGE: ThreadEventTokenUsageBreakdown;
|
|
1591
|
-
/**
|
|
1592
|
-
* Sum a turn's usage into a running total, field by field. The `usage` delta
|
|
1593
|
-
* carries both the turn's usage and the session total; a provider that only
|
|
1594
|
-
* reports per-turn usage keeps the total itself with this, starting from
|
|
1595
|
-
* {@link ZERO_TOKEN_USAGE} at every session construction (the same boundary
|
|
1596
|
-
* as the `session.reset` delta).
|
|
1597
|
-
*/
|
|
1598
1468
|
declare function addTokenUsage(total: ThreadEventTokenUsageBreakdown, last: ThreadEventTokenUsageBreakdown): ThreadEventTokenUsageBreakdown;
|
|
1599
1469
|
|
|
1600
1470
|
interface BoundedLineReaderArgs {
|
|
1601
1471
|
input: NodeJS.ReadableStream;
|
|
1602
|
-
/** Complete lines, without their terminator. */
|
|
1603
1472
|
onLine: (line: string) => void;
|
|
1604
|
-
/**
|
|
1605
|
-
* An oversized line was discarded (bytes counted so far when the cap was
|
|
1606
|
-
* passed). Reading continues from the next terminator, so one runaway
|
|
1607
|
-
* message costs its own content and nothing else.
|
|
1608
|
-
*/
|
|
1609
1473
|
onOverflow: (bytes: number) => void;
|
|
1610
1474
|
onClose?: () => void;
|
|
1611
1475
|
maxLineBytes?: number;
|
|
1612
1476
|
}
|
|
1613
|
-
/**
|
|
1614
|
-
* Newline-delimited reader with a hard per-line cap — `readline` with the
|
|
1615
|
-
* bound it lacks. CR is stripped so a CRLF producer parses as JSON.
|
|
1616
|
-
*/
|
|
1617
1477
|
declare function readBoundedLines(args: BoundedLineReaderArgs): void;
|
|
1618
1478
|
|
|
1619
|
-
/**
|
|
1620
|
-
* JSON-RPC error codes on the bridge wire.
|
|
1621
|
-
*
|
|
1622
|
-
* The hygiene rules these back (from #853): an undecodable request is
|
|
1623
|
-
* answered with `INVALID_PARAMS` carrying the validation issues — never
|
|
1624
|
-
* silently dropped; an unrecognized method is answered with
|
|
1625
|
-
* `METHOD_NOT_FOUND`; request vs response is discriminated on the presence of
|
|
1626
|
-
* `method`, never on result-shape guessing.
|
|
1627
|
-
*/
|
|
1628
1479
|
declare const BRIDGE_JSON_RPC_ERRORS: {
|
|
1629
|
-
/** Standard JSON-RPC: params failed schema validation. */
|
|
1630
1480
|
readonly INVALID_PARAMS: -32602;
|
|
1631
|
-
/** Standard JSON-RPC: method not implemented by this bridge. */
|
|
1632
1481
|
readonly METHOD_NOT_FOUND: -32601;
|
|
1633
|
-
/** Generic bridge failure. */
|
|
1634
1482
|
readonly BRIDGE_ERROR: -32000;
|
|
1635
|
-
/** A turn/steer arrived but the session has no active turn. */
|
|
1636
1483
|
readonly NO_ACTIVE_TURN: -32001;
|
|
1637
|
-
/** thread/resume for a session the provider can no longer restore. */
|
|
1638
1484
|
readonly SESSION_NOT_RESTORABLE: -32002;
|
|
1639
|
-
/** thread/fork with a checkpoint on a bridge that only forks at the tip. */
|
|
1640
1485
|
readonly FORK_CHECKPOINT_UNSUPPORTED: -32003;
|
|
1641
1486
|
};
|
|
1642
|
-
/**
|
|
1643
|
-
* A typed recovery hint: what went wrong in the provider's own terms and
|
|
1644
|
-
* whether the runtime may retry after acting on it. One payload, two
|
|
1645
|
-
* carriers: a rejected request carries it as `error.data.recovery` (the
|
|
1646
|
-
* JSON-RPC id is the correlation); a condition with no request to ride on
|
|
1647
|
-
* (a terminal 401 mid-turn) rides the `provider/recovery` notification.
|
|
1648
|
-
* Never both for one event. The runtime keys on `kind` and matches no text.
|
|
1649
|
-
*/
|
|
1650
1487
|
declare const providerRecoveryHintSchema: z.ZodObject<{
|
|
1651
1488
|
kind: z.ZodEnum<{
|
|
1652
1489
|
authRequired: "authRequired";
|
|
@@ -1659,10 +1496,6 @@ declare const providerRecoveryHintSchema: z.ZodObject<{
|
|
|
1659
1496
|
retryable: z.ZodBoolean;
|
|
1660
1497
|
}, z.core.$strip>;
|
|
1661
1498
|
type ProviderRecoveryHint = z.infer<typeof providerRecoveryHintSchema>;
|
|
1662
|
-
/**
|
|
1663
|
-
* Optional `error.data` on any bridge → runtime JSON-RPC error response.
|
|
1664
|
-
* Additive: a response without `data` is a plain failure.
|
|
1665
|
-
*/
|
|
1666
1499
|
declare const bridgeErrorDataSchema: z.ZodObject<{
|
|
1667
1500
|
recovery: z.ZodOptional<z.ZodObject<{
|
|
1668
1501
|
kind: z.ZodEnum<{
|
|
@@ -1686,12 +1519,6 @@ type BridgeJsonRpcResponse$1 = {
|
|
|
1686
1519
|
} | {
|
|
1687
1520
|
jsonrpc: "2.0";
|
|
1688
1521
|
id: BridgeJsonRpcId;
|
|
1689
|
-
/**
|
|
1690
|
-
* `data` is JSON-RPC 2.0's own slot for structured detail beside the
|
|
1691
|
-
* human-readable `message`. bb uses it to carry a typed recovery hint,
|
|
1692
|
-
* so the runtime reads what went wrong instead of matching the
|
|
1693
|
-
* message text.
|
|
1694
|
-
*/
|
|
1695
1522
|
error: {
|
|
1696
1523
|
code: number;
|
|
1697
1524
|
message: string;
|
|
@@ -1699,14 +1526,6 @@ type BridgeJsonRpcResponse$1 = {
|
|
|
1699
1526
|
};
|
|
1700
1527
|
};
|
|
1701
1528
|
type BridgeSendError = (id: BridgeJsonRpcId, code: number, message: string, data?: BridgeErrorData) => void;
|
|
1702
|
-
/**
|
|
1703
|
-
* Throw this from a request handler to reject the request with a typed
|
|
1704
|
-
* recovery hint: `runBridgeRequest` answers with `error.data.recovery`, the
|
|
1705
|
-
* same way a `ProviderRequestDecodeError` becomes `INVALID_PARAMS`. A handler
|
|
1706
|
-
* that answers by hand passes the hint to `sendError` as `data` instead.
|
|
1707
|
-
* Rejecting a request? Put the hint here. No request to reject? Send the
|
|
1708
|
-
* `provider/recovery` notification. Never both for one event.
|
|
1709
|
-
*/
|
|
1710
1529
|
declare class BridgeRecoveryError extends Error {
|
|
1711
1530
|
readonly code: number;
|
|
1712
1531
|
readonly recovery: ProviderRecoveryHint;
|
|
@@ -1740,43 +1559,13 @@ interface BridgeRecorderChildStreams {
|
|
|
1740
1559
|
stdin?: Writable | null;
|
|
1741
1560
|
stdout?: Readable | null;
|
|
1742
1561
|
}
|
|
1743
|
-
/**
|
|
1744
|
-
* Whether this process records. A bridge whose provider pipe is owned by an
|
|
1745
|
-
* SDK (Claude's Agent SDK) checks this to decide whether to take the spawn
|
|
1746
|
-
* over; bridges that spawn their child themselves just call
|
|
1747
|
-
* `experimental_recordProviderChildIo`.
|
|
1748
|
-
*/
|
|
1749
1562
|
declare function experimental_isProviderBridgeRecording(): boolean;
|
|
1750
|
-
/**
|
|
1751
|
-
* Tee the provider child a bridge just spawned into the recording, scoped to
|
|
1752
|
-
* the bb thread it serves (null for process-level children such as a
|
|
1753
|
-
* model-list probe). A no-op unless record mode is on, so bridges call it
|
|
1754
|
-
* unconditionally right after `spawn()`.
|
|
1755
|
-
*/
|
|
1756
1563
|
declare function experimental_recordProviderChildIo(child: BridgeRecorderChildStreams, scope: {
|
|
1757
1564
|
threadId: string | null;
|
|
1758
1565
|
}): void;
|
|
1759
1566
|
|
|
1760
|
-
/**
|
|
1761
|
-
* The environment a bridge hands its provider child when it wants the child
|
|
1762
|
-
* to see the bridge's own environment (ACP agents and the Claude CLI need
|
|
1763
|
-
* `BB_CLI` and friends so `bb` works inside their shells). Two variables are
|
|
1764
|
-
* bridge-process facts that must never leak downward: the Electron node flag,
|
|
1765
|
-
* and the record-mode directory — a recorded provider child that happened to
|
|
1766
|
-
* be a bb bridge itself would otherwise start recording too.
|
|
1767
|
-
*/
|
|
1768
1567
|
declare function withoutBridgeRuntimeEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
1769
1568
|
|
|
1770
|
-
/**
|
|
1771
|
-
* Shared tool call helpers for bridge processes.
|
|
1772
|
-
*
|
|
1773
|
-
* Both claude-code and pi bridges forward tool calls from the provider SDK
|
|
1774
|
-
* to the host-daemon and feed responses back. This module provides:
|
|
1775
|
-
* - The JSON-RPC request type for forwarding tool calls
|
|
1776
|
-
* - Response decoding for tool call results from the host-daemon
|
|
1777
|
-
* - Generic JSON-RPC response decoding (for matching tool call responses)
|
|
1778
|
-
*/
|
|
1779
|
-
|
|
1780
1569
|
interface BridgeToolCallRequest {
|
|
1781
1570
|
jsonrpc: "2.0";
|
|
1782
1571
|
id: string | number;
|
|
@@ -1812,16 +1601,10 @@ declare const jsonRpcErrorResponseSchema: z.ZodObject<{
|
|
|
1812
1601
|
}, z.core.$strip>;
|
|
1813
1602
|
type BridgeJsonRpcResponse = z.infer<typeof jsonRpcSuccessResponseSchema> | z.infer<typeof jsonRpcErrorResponseSchema>;
|
|
1814
1603
|
declare function decodeBridgeJsonRpcResponse(input: unknown): BridgeJsonRpcResponse | null;
|
|
1815
|
-
/** An image on a tool call result, split out of an `inputImage` data URL. */
|
|
1816
1604
|
interface BridgeToolCallImage {
|
|
1817
1605
|
data: string;
|
|
1818
1606
|
mimeType: string;
|
|
1819
1607
|
}
|
|
1820
|
-
/**
|
|
1821
|
-
* A tool result block in the one shape every consumer already accepts: MCP's
|
|
1822
|
-
* `CallToolResult.content` (claude-code and acp) and pi's `AgentToolResult.content`
|
|
1823
|
-
* declare the same two members with the same field names.
|
|
1824
|
-
*/
|
|
1825
1608
|
type BridgeToolCallContent = {
|
|
1826
1609
|
type: "text";
|
|
1827
1610
|
text: string;
|
|
@@ -1836,26 +1619,12 @@ declare function decodeToolCallResponsePayload(result: unknown): {
|
|
|
1836
1619
|
images: BridgeToolCallImage[];
|
|
1837
1620
|
isError: boolean;
|
|
1838
1621
|
};
|
|
1839
|
-
/**
|
|
1840
|
-
* Renders a decoded payload as tool result blocks, dropping empty text so an
|
|
1841
|
-
* image-only result carries the image alone.
|
|
1842
|
-
*/
|
|
1843
1622
|
declare function buildBridgeToolCallContent(result: {
|
|
1844
1623
|
content: string;
|
|
1845
1624
|
contentBlocks?: BridgeToolCallContent[];
|
|
1846
1625
|
images?: BridgeToolCallImage[];
|
|
1847
1626
|
}): BridgeToolCallContent[];
|
|
1848
1627
|
|
|
1849
|
-
/**
|
|
1850
|
-
* Structural contracts shared by the runtime's generic adapter and the bridge
|
|
1851
|
-
* implementations that translate a provider's native protocol.
|
|
1852
|
-
*
|
|
1853
|
-
* These are the shapes a bridge produces or consumes while it maps its
|
|
1854
|
-
* provider onto the canonical protocol. They live in the kit (rather than in
|
|
1855
|
-
* `@bb/agent-runtime`) so a bridge shipped from a plugin never depends on the
|
|
1856
|
-
* runtime package.
|
|
1857
|
-
*/
|
|
1858
|
-
|
|
1859
1628
|
interface ProviderRequestCommandPlan {
|
|
1860
1629
|
kind: "request";
|
|
1861
1630
|
method: string;
|
|
@@ -1870,25 +1639,12 @@ interface DecodedInteractiveRequest {
|
|
|
1870
1639
|
requestId: string | number;
|
|
1871
1640
|
method: string;
|
|
1872
1641
|
providerThreadId: string;
|
|
1873
|
-
/**
|
|
1874
|
-
* Non-empty BB turn id when known. Use null as the canonical unresolved
|
|
1875
|
-
* value so the runtime can resolve from the active turn; empty strings are
|
|
1876
|
-
* malformed adapter output.
|
|
1877
|
-
*/
|
|
1878
1642
|
turnId: string | null;
|
|
1879
1643
|
payload: PendingInteractionPayload;
|
|
1880
1644
|
threadId?: string;
|
|
1881
1645
|
}
|
|
1882
1646
|
interface PreparedProviderCommandDispatch {
|
|
1883
1647
|
rollback(): void;
|
|
1884
|
-
/**
|
|
1885
|
-
* Claims the prepared correlation if no provider event has consumed it yet,
|
|
1886
|
-
* proving this dispatch still owns unstarted work. Returns true (and drops
|
|
1887
|
-
* the correlation, so nothing can consume it twice) when the provider never
|
|
1888
|
-
* started a turn for this dispatch; false once it did. Callers use it to
|
|
1889
|
-
* settle a prompt the provider accepted and finished without emitting any
|
|
1890
|
-
* turn activity, without fabricating a turn from a late signal.
|
|
1891
|
-
*/
|
|
1892
1648
|
claim(): boolean;
|
|
1893
1649
|
}
|
|
1894
1650
|
interface BuildInteractiveResponseArgs {
|
|
@@ -1942,79 +1698,32 @@ declare function mimeTypeFromExtension(filePath: string): string;
|
|
|
1942
1698
|
|
|
1943
1699
|
interface BridgeToolCallResult {
|
|
1944
1700
|
content: string;
|
|
1945
|
-
/** Ordered provider result blocks; absent on local transport failures. */
|
|
1946
1701
|
contentBlocks?: BridgeToolCallContent[];
|
|
1947
|
-
/** Absent on the failure paths below, which have no image to report. */
|
|
1948
1702
|
images?: BridgeToolCallImage[];
|
|
1949
1703
|
isError?: boolean;
|
|
1950
1704
|
}
|
|
1951
1705
|
interface ForwardBridgeToolCallArgs {
|
|
1952
1706
|
arguments: Record<string, unknown>;
|
|
1953
1707
|
providerThreadId: string;
|
|
1954
|
-
/**
|
|
1955
|
-
* The session the pending call belongs to. `resolvePendingToolCalls`
|
|
1956
|
-
* error-resolves by scope identity, so a bridge passes its own session
|
|
1957
|
-
* object and settles that session's calls on close/replace without touching
|
|
1958
|
-
* calls minted by a successor session under the same thread id.
|
|
1959
|
-
*/
|
|
1960
1708
|
scope: object;
|
|
1961
1709
|
threadId: string;
|
|
1962
1710
|
toolName: string;
|
|
1963
1711
|
}
|
|
1964
1712
|
interface PendingToolCallTracker {
|
|
1965
|
-
/**
|
|
1966
|
-
* Mints an `item/tool/call` JSON-RPC request toward the runtime and returns
|
|
1967
|
-
* a promise settled by the matching response (or by
|
|
1968
|
-
* `resolvePendingToolCalls`). Never rejects: failures resolve as
|
|
1969
|
-
* `isError: true` results.
|
|
1970
|
-
*/
|
|
1971
1713
|
forwardToolCall: (args: ForwardBridgeToolCallArgs) => Promise<BridgeToolCallResult>;
|
|
1972
|
-
/** Returns true when the response settled a pending tool call. */
|
|
1973
1714
|
handleToolCallResponse: (response: BridgeJsonRpcResponse) => boolean;
|
|
1974
|
-
/** Error-resolves every pending call minted under `scope`. */
|
|
1975
1715
|
resolvePendingToolCalls: (scope: object, message: string) => void;
|
|
1976
1716
|
}
|
|
1977
|
-
/**
|
|
1978
|
-
* Tracks the bridge's outgoing tool-call requests: mints request ids, sends
|
|
1979
|
-
* the `item/tool/call` envelope, and matches responses back to their waiting
|
|
1980
|
-
* promise via `decodeToolCallResponsePayload`.
|
|
1981
|
-
*/
|
|
1982
1717
|
declare function createPendingToolCallTracker(options: {
|
|
1983
1718
|
sendToolCall: (request: BridgeToolCallRequest) => void;
|
|
1984
1719
|
}): PendingToolCallTracker;
|
|
1985
1720
|
|
|
1986
|
-
/**
|
|
1987
|
-
* The single statement of when an interactive provider request is answered
|
|
1988
|
-
* without ever reaching the user.
|
|
1989
|
-
*
|
|
1990
|
-
* Both sides of the bridge boundary enforce it and they must agree: a bridge
|
|
1991
|
-
* auto-denies its provider's own permission prompts, and the runtime
|
|
1992
|
-
* auto-denies the inbound requests that still arrive (a bridge whose provider
|
|
1993
|
-
* only learns the policy after the prompt is already in flight). Stating it
|
|
1994
|
-
* twice is how the two sides drift, so it lives in the kit — the one place a
|
|
1995
|
-
* plugin-shipped bridge and `@bb/agent-runtime` can both import from.
|
|
1996
|
-
*/
|
|
1997
|
-
|
|
1998
1721
|
interface InteractiveRequestPolicyInput {
|
|
1999
1722
|
permissionEscalation: PermissionEscalation | null;
|
|
2000
1723
|
}
|
|
2001
1724
|
declare function shouldAutoDenyInteractiveRequest(policy: InteractiveRequestPolicyInput): boolean;
|
|
2002
1725
|
|
|
2003
1726
|
declare const THREAD_DELTA_NOTIFICATION_METHOD = "thread/delta";
|
|
2004
|
-
/**
|
|
2005
|
-
* Declarative presentation a bridge attaches to an item at `item.open` (and
|
|
2006
|
-
* re-states on `item.close`, whose item is the full terminal shape). The
|
|
2007
|
-
* assembler persists it on the canonical item so the row renders after the
|
|
2008
|
-
* plugin is uninstalled or upgraded, and so mobile renders every kind without
|
|
2009
|
-
* plugin code. The same schema as the persisted field
|
|
2010
|
-
* (`threadEventItemPresentationSchema` in @bb/domain) — one vocabulary, no
|
|
2011
|
-
* translation.
|
|
2012
|
-
*
|
|
2013
|
-
* Optional in grammar v3 while rows persisted before bridges stamped it are
|
|
2014
|
-
* upgraded at read time; it becomes required together with the
|
|
2015
|
-
* `legacy-tool-item-backfill` migration that stamps those rows and retires
|
|
2016
|
-
* that adapter.
|
|
2017
|
-
*/
|
|
2018
1727
|
declare const deltaPresentationSchema: z.ZodObject<{
|
|
2019
1728
|
detail: z.ZodOptional<z.ZodString>;
|
|
2020
1729
|
icon: z.ZodObject<{
|
|
@@ -2032,31 +1741,12 @@ declare const deltaPresentationSchema: z.ZodObject<{
|
|
|
2032
1741
|
title: z.ZodOptional<z.ZodString>;
|
|
2033
1742
|
}, z.core.$strip>;
|
|
2034
1743
|
type DeltaPresentation = z.infer<typeof deltaPresentationSchema>;
|
|
2035
|
-
/**
|
|
2036
|
-
* Provider-native join key for an item. `providerItemId` is the provider's
|
|
2037
|
-
* own id (a tool-call id); `channel` distinguishes provider-anonymous item
|
|
2038
|
-
* families (e.g. compaction); `parentRef` is the provider-native id of the
|
|
2039
|
-
* parent tool call for nested items. The assembler translates all of these to
|
|
2040
|
-
* bb-minted ids.
|
|
2041
|
-
*/
|
|
2042
1744
|
declare const deltaItemKeySchema: z.ZodObject<{
|
|
2043
1745
|
channel: z.ZodOptional<z.ZodString>;
|
|
2044
1746
|
parentRef: z.ZodOptional<z.ZodString>;
|
|
2045
1747
|
providerItemId: z.ZodOptional<z.ZodString>;
|
|
2046
1748
|
}, z.core.$strip>;
|
|
2047
1749
|
type DeltaItemKey = z.infer<typeof deltaItemKeySchema>;
|
|
2048
|
-
/**
|
|
2049
|
-
* The parsed item shapes a bridge classifies its provider's tool traffic
|
|
2050
|
-
* into. Everything richer (diffs, pending statuses, echoed fields on close)
|
|
2051
|
-
* is assembler-owned construction. Output-ish optional fields (aggregated
|
|
2052
|
-
* output, exit code, results) exist for providers whose native item payloads
|
|
2053
|
-
* carry them wholesale (codex). When both a shape field and its generic close
|
|
2054
|
-
* counterpart are present, precedence is per-shape: for `command` the generic
|
|
2055
|
-
* close fields (`aggregatedOutput`, `exitCode`) win over the shape's, but for
|
|
2056
|
-
* `tool` the shape's `result` wins over the close's `resultText`. The
|
|
2057
|
-
* asymmetry is deliberate — it preserves byte-equivalence with the original
|
|
2058
|
-
* codex-vs-pi translator conversions.
|
|
2059
|
-
*/
|
|
2060
1750
|
declare const deltaFileChangeSchema: z.ZodObject<{
|
|
2061
1751
|
diff: z.ZodOptional<z.ZodString>;
|
|
2062
1752
|
kind: z.ZodEnum<{
|
|
@@ -2070,15 +1760,6 @@ declare const deltaFileChangeSchema: z.ZodObject<{
|
|
|
2070
1760
|
path: z.ZodString;
|
|
2071
1761
|
}, z.core.$strip>;
|
|
2072
1762
|
type DeltaFileChange = z.infer<typeof deltaFileChangeSchema>;
|
|
2073
|
-
/**
|
|
2074
|
-
* A provider background task (claude workflows, backgrounded shells and
|
|
2075
|
-
* subagents). The full snapshot is re-embedded per event — the bridge owns the
|
|
2076
|
-
* dialect fold (per-index workflow records, generation counting) and the
|
|
2077
|
-
* assembler only re-emits it. The family's canonical events are structurally
|
|
2078
|
-
* thread-scoped by the domain grammar (`item/backgroundTask/progress` and
|
|
2079
|
-
* `item/backgroundTask/completed`), so its progress/close deltas need no open
|
|
2080
|
-
* turn; only the spawning `item.open` (→ `item/started`) is turn-scoped.
|
|
2081
|
-
*/
|
|
2082
1763
|
declare const deltaBackgroundTaskShapeSchema: z.ZodObject<{
|
|
2083
1764
|
description: z.ZodString;
|
|
2084
1765
|
error: z.ZodOptional<z.ZodString>;
|
|
@@ -2147,29 +1828,12 @@ declare const deltaBackgroundTaskShapeSchema: z.ZodObject<{
|
|
|
2147
1828
|
workflowName: z.ZodOptional<z.ZodString>;
|
|
2148
1829
|
}, z.core.$strip>;
|
|
2149
1830
|
type DeltaBackgroundTaskShape = z.infer<typeof deltaBackgroundTaskShapeSchema>;
|
|
2150
|
-
/**
|
|
2151
|
-
* A file the agent read (grammar v3). Claude `Read` is the top generic tool in
|
|
2152
|
-
* the production corpus — 7,568 calls rendered as opaque `tool` rows — and
|
|
2153
|
-
* codex reads files through `cat`/`sed -n` commands the bridge already
|
|
2154
|
-
* classifies as read intents. `cmd` carries that native shell form when the
|
|
2155
|
-
* read ran through a command rather than a structured tool.
|
|
2156
|
-
*/
|
|
2157
1831
|
declare const deltaFileReadShapeSchema: z.ZodObject<{
|
|
2158
1832
|
cmd: z.ZodOptional<z.ZodString>;
|
|
2159
1833
|
path: z.ZodString;
|
|
2160
1834
|
type: z.ZodLiteral<"fileRead">;
|
|
2161
1835
|
}, z.core.$strip>;
|
|
2162
1836
|
type DeltaFileReadShape = z.infer<typeof deltaFileReadShapeSchema>;
|
|
2163
|
-
/**
|
|
2164
|
-
* Grep, glob and directory listing as one shape (grammar v3), discriminated
|
|
2165
|
-
* by `mode`: `content` searches inside files (Claude `Grep`, `rg`), `path`
|
|
2166
|
-
* matches file names (Claude `Glob`, `fd`), `list` enumerates a directory
|
|
2167
|
-
* (`ls`, codex `list_dir`). `query` is the pattern — text or a regex for
|
|
2168
|
-
* `content`, a glob for `path`, an optional filter for `list` (empty when the
|
|
2169
|
-
* whole directory is listed); `path` is the root the search ran under when
|
|
2170
|
-
* the provider named one; `cmd` is the native shell form when it ran through
|
|
2171
|
-
* a command.
|
|
2172
|
-
*/
|
|
2173
1837
|
declare const deltaSearchShapeSchema: z.ZodObject<{
|
|
2174
1838
|
cmd: z.ZodOptional<z.ZodString>;
|
|
2175
1839
|
mode: z.ZodEnum<{
|
|
@@ -2182,18 +1846,6 @@ declare const deltaSearchShapeSchema: z.ZodObject<{
|
|
|
2182
1846
|
type: z.ZodLiteral<"search">;
|
|
2183
1847
|
}, z.core.$strip>;
|
|
2184
1848
|
type DeltaSearchShape = z.infer<typeof deltaSearchShapeSchema>;
|
|
2185
|
-
/**
|
|
2186
|
-
* Delegated work (grammar v3): one shape for the three encodings in the
|
|
2187
|
-
* production data — codex `spawnAgent`/`wait` tool calls, the Claude `Agent`
|
|
2188
|
-
* tool with nested child turns, and backgrounded `local_agent` background
|
|
2189
|
-
* tasks — and for what the `thread/openWork` notification used to report,
|
|
2190
|
-
* since an open delegation IS open work. `childRef` is the provider-native child id; the
|
|
2191
|
-
* child's own deltas link back through `parentRef`. `background: true` marks
|
|
2192
|
-
* a delegation that outlives its turn: the assembler routes its progress and
|
|
2193
|
-
* close to the thread-scoped `item/delegation/*` events exactly as it does
|
|
2194
|
-
* for `backgroundTask`. The terminal `status` rides `item.close`, as
|
|
2195
|
-
* for `command` and `tool`; `summary` is the child's terminal summary.
|
|
2196
|
-
*/
|
|
2197
1849
|
declare const deltaDelegationShapeSchema: z.ZodObject<{
|
|
2198
1850
|
background: z.ZodBoolean;
|
|
2199
1851
|
childRef: z.ZodString;
|
|
@@ -2202,15 +1854,6 @@ declare const deltaDelegationShapeSchema: z.ZodObject<{
|
|
|
2202
1854
|
type: z.ZodLiteral<"delegation">;
|
|
2203
1855
|
}, z.core.$strip>;
|
|
2204
1856
|
type DeltaDelegationShape = z.infer<typeof deltaDelegationShapeSchema>;
|
|
2205
|
-
/**
|
|
2206
|
-
* A structured plan snapshot as an item (grammar v3): codex `update_plan`
|
|
2207
|
-
* (295 production threads, discarded by the UI while it only rode the
|
|
2208
|
-
* turn-level `turn.plan`), ACP `plan` updates, and Claude
|
|
2209
|
-
* `TaskCreate`/`TaskUpdate`/`TodoWrite`. Each snapshot carries the full step
|
|
2210
|
-
* list and supersedes the previous one. The turn-level `turn.plan` delta is
|
|
2211
|
-
* gone: every in-repo bridge speaks this form, and the persisted
|
|
2212
|
-
* `turn/plan/updated` event type stays as read-only history.
|
|
2213
|
-
*/
|
|
2214
1857
|
declare const deltaPlanStepsShapeSchema: z.ZodObject<{
|
|
2215
1858
|
explanation: z.ZodOptional<z.ZodString>;
|
|
2216
1859
|
steps: z.ZodArray<z.ZodObject<{
|
|
@@ -2225,21 +1868,6 @@ declare const deltaPlanStepsShapeSchema: z.ZodObject<{
|
|
|
2225
1868
|
type: z.ZodLiteral<"planSteps">;
|
|
2226
1869
|
}, z.core.$strip>;
|
|
2227
1870
|
type DeltaPlanStepsShape = z.infer<typeof deltaPlanStepsShapeSchema>;
|
|
2228
|
-
/**
|
|
2229
|
-
* A plugin-defined item kind outside the core vocabulary (grammar v3).
|
|
2230
|
-
* `kind` is the namespaced `"<pluginId>/<name>"` the plugin declared in its
|
|
2231
|
-
* provider registration (`extensionKinds`); only the namespace shape is
|
|
2232
|
-
* validated here. The payload is opaque JSON at this layer: the assembler
|
|
2233
|
-
* copies it onto the canonical item, and the server validates it against the
|
|
2234
|
-
* plugin's declared item schema for `kind` at ingest, persisting a
|
|
2235
|
-
* `provider/unhandled` in its place on a miss.
|
|
2236
|
-
*
|
|
2237
|
-
* The shape carries no presentation of its own: presentation lives in ONE
|
|
2238
|
-
* place, the `item.open`/`item.close` delta's `presentation` field, and for
|
|
2239
|
-
* an extension shape that field is REQUIRED (enforced by the delta schema
|
|
2240
|
-
* below) — an extension item has no core renderer, so the declarative base
|
|
2241
|
-
* is the only thing every client can show.
|
|
2242
|
-
*/
|
|
2243
1871
|
declare const deltaExtensionShapeSchema: z.ZodObject<{
|
|
2244
1872
|
kind: z.ZodString & z.ZodType<`${string}/${string}`, string, z.core.$ZodTypeInternals<`${string}/${string}`, string>>;
|
|
2245
1873
|
payload: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
@@ -2403,12 +2031,6 @@ declare const deltaItemShapeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2403
2031
|
}, z.core.$strip>], "type">;
|
|
2404
2032
|
type DeltaItemShape = z.infer<typeof deltaItemShapeSchema>;
|
|
2405
2033
|
type DeltaItemShapeType = DeltaItemShape["type"];
|
|
2406
|
-
/**
|
|
2407
|
-
* The re-embedded snapshot an `item.progress` may carry for work that
|
|
2408
|
-
* outlives its turn. `backgroundTask` is the v2 form; `delegation` joins it in
|
|
2409
|
-
* v3 for background delegations (the assembler routes it to
|
|
2410
|
-
* `item/delegation/progress`).
|
|
2411
|
-
*/
|
|
2412
2034
|
declare const deltaProgressSnapshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2413
2035
|
description: z.ZodString;
|
|
2414
2036
|
error: z.ZodOptional<z.ZodString>;
|
|
@@ -2483,13 +2105,6 @@ declare const deltaProgressSnapshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
2483
2105
|
type: z.ZodLiteral<"delegation">;
|
|
2484
2106
|
}, z.core.$strip>], "type">;
|
|
2485
2107
|
type DeltaProgressSnapshot = z.infer<typeof deltaProgressSnapshotSchema>;
|
|
2486
|
-
/**
|
|
2487
|
-
* The streamed-text channels: which text item a stream feeds and which of its
|
|
2488
|
-
* fields the text lands in. `agentMessage` and `plan` items have one text;
|
|
2489
|
-
* a `reasoning` item has `summary` (`reasoningSummary`) and `content`
|
|
2490
|
-
* (`reasoningText`). A delta for an unknown item key synthesizes the
|
|
2491
|
-
* channel's `item/started`.
|
|
2492
|
-
*/
|
|
2493
2108
|
declare const deltaTextChannelSchema: z.ZodEnum<{
|
|
2494
2109
|
agentMessage: "agentMessage";
|
|
2495
2110
|
plan: "plan";
|
|
@@ -2497,26 +2112,11 @@ declare const deltaTextChannelSchema: z.ZodEnum<{
|
|
|
2497
2112
|
reasoningText: "reasoningText";
|
|
2498
2113
|
}>;
|
|
2499
2114
|
type DeltaTextChannel = z.infer<typeof deltaTextChannelSchema>;
|
|
2500
|
-
/**
|
|
2501
|
-
* Item-keyed output channels (codex): channels that NEVER synthesize an open
|
|
2502
|
-
* — fabricating a commandExecution without its command would be worse than
|
|
2503
|
-
* the anomaly. The structural split between `item.textDelta` and
|
|
2504
|
-
* `item.outputDelta` is what encodes that rule.
|
|
2505
|
-
*/
|
|
2506
2115
|
declare const deltaOutputChannelSchema: z.ZodEnum<{
|
|
2507
2116
|
command: "command";
|
|
2508
2117
|
fileChange: "fileChange";
|
|
2509
2118
|
}>;
|
|
2510
2119
|
type DeltaOutputChannel = z.infer<typeof deltaOutputChannelSchema>;
|
|
2511
|
-
/**
|
|
2512
|
-
* Turnless fallback: item/stream deltas never open turns — only `turn.open`,
|
|
2513
|
-
* a claiming `turn.boundary`, and accepted-input lifecycle settlement do.
|
|
2514
|
-
* When a turn-scoped delta arrives with no turn to attach to, the assembler
|
|
2515
|
-
* surfaces this raw payload as a thread-scoped `provider/unhandled` (the
|
|
2516
|
-
* bridges' old "no active turn" guard, applied centrally). Absent, the
|
|
2517
|
-
* turnless delta is dropped silently. Irrelevant for deltas carrying a
|
|
2518
|
-
* `providerTurnId` (a vouched turn always resolves).
|
|
2519
|
-
*/
|
|
2520
2120
|
declare const deltaNoTurnFallbackSchema: z.ZodObject<{
|
|
2521
2121
|
raw: z.ZodObject<{
|
|
2522
2122
|
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
@@ -3309,7 +2909,6 @@ declare const threadDeltaSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
3309
2909
|
}, z.core.$strip>], "kind">;
|
|
3310
2910
|
type ThreadDelta = z.infer<typeof threadDeltaSchema>;
|
|
3311
2911
|
type ThreadDeltaKind = ThreadDelta["kind"];
|
|
3312
|
-
/** `thread/delta` notification params: batched deltas for one thread. */
|
|
3313
2912
|
declare const threadDeltaNotificationParamsSchema: z.ZodObject<{
|
|
3314
2913
|
deltas: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3315
2914
|
clientRequestId: z.ZodString;
|
|
@@ -4095,90 +3694,43 @@ declare const threadDeltaNotificationParamsSchema: z.ZodObject<{
|
|
|
4095
3694
|
}, z.core.$loose>;
|
|
4096
3695
|
type ThreadDeltaNotificationParams = z.infer<typeof threadDeltaNotificationParamsSchema>;
|
|
4097
3696
|
|
|
4098
|
-
/**
|
|
4099
|
-
* The first non-empty line of `text`, capped at
|
|
4100
|
-
* {@link PRESENTATION_TITLE_MAX_LENGTH} with an ellipsis; undefined when
|
|
4101
|
-
* there is nothing to headline, so the row carries no `title` at all.
|
|
4102
|
-
*/
|
|
4103
3697
|
declare function presentationTitle(text: string): string | undefined;
|
|
4104
|
-
/** Row details are capped by the persisted presentation schema. */
|
|
4105
3698
|
declare function presentationDetail(text: string): string;
|
|
4106
|
-
/** `presentation` with `title` stamped on it, or untouched when there is none. */
|
|
4107
3699
|
declare function withTitle(presentation: DeltaPresentation, title: string | undefined): DeltaPresentation;
|
|
4108
|
-
/** The last path segment — a headline names the file, not its directory. */
|
|
4109
3700
|
declare function presentationFileName(path: string): string;
|
|
4110
3701
|
declare const COMPACTION_PRESENTATION: DeltaPresentation;
|
|
4111
3702
|
declare const REASONING_PRESENTATION: DeltaPresentation;
|
|
4112
3703
|
declare function fileReadPresentation(path: string): DeltaPresentation;
|
|
4113
|
-
/** `content` searches inside files; `path` matches file names. */
|
|
4114
3704
|
declare function searchPresentation(args: {
|
|
4115
3705
|
mode: "content" | "path";
|
|
4116
3706
|
query: string;
|
|
4117
3707
|
}): DeltaPresentation;
|
|
4118
|
-
/** A web search; `query` is the headline, or undefined when the agent sent none. */
|
|
4119
3708
|
declare function webSearchPresentation(query: string | undefined): DeltaPresentation;
|
|
4120
3709
|
declare function webFetchPresentation(url: string): DeltaPresentation;
|
|
4121
|
-
/**
|
|
4122
|
-
* A plan-steps snapshot. The headline is the step in progress — what the
|
|
4123
|
-
* agent is doing now. Collapsed by default: the todo banner reads the
|
|
4124
|
-
* snapshot; the row is bookkeeping.
|
|
4125
|
-
*/
|
|
4126
3710
|
declare function planStepsPresentation(steps: readonly {
|
|
4127
3711
|
step: string;
|
|
4128
3712
|
status?: string;
|
|
4129
3713
|
}[]): DeltaPresentation;
|
|
4130
|
-
/**
|
|
4131
|
-
* A tool with no core kind and no presentation of its own — a provider's
|
|
4132
|
-
* own dynamic tool, an unknown built-in, or a bb-injected tool whose
|
|
4133
|
-
* definition predates the field: a generic label under bb's own glyph.
|
|
4134
|
-
*/
|
|
4135
3714
|
declare function toolPresentation(tool: string): DeltaPresentation;
|
|
4136
3715
|
|
|
4137
|
-
/**
|
|
4138
|
-
* The bridge export shape.
|
|
4139
|
-
*
|
|
4140
|
-
* A provider bridge is a module inside its plugin's `bb.host` artifact that
|
|
4141
|
-
* *exports* its surface instead of starting itself: the daemon-side bootstrap
|
|
4142
|
-
* imports the artifact, finds this export, and owns the process boundary
|
|
4143
|
-
* (argv, plugin-scoped directories, stdin framing, signals). That inversion is
|
|
4144
|
-
* what lets one artifact carry both a bridge and a host RPC entry, and what
|
|
4145
|
-
* lets a bridge be imported by tests without taking over stdio.
|
|
4146
|
-
*/
|
|
4147
|
-
/** The name a bridge must export from its plugin's host artifact. */
|
|
4148
3716
|
declare const PROVIDER_BRIDGE_EXPORT_NAME = "experimental_providerBridge";
|
|
4149
|
-
/** Where this bridge process may keep files, scoped to the owning plugin. */
|
|
4150
3717
|
interface ProviderBridgeContext {
|
|
4151
|
-
/** The plugin that ships this bridge. */
|
|
4152
3718
|
pluginId: string;
|
|
4153
|
-
/** Persistent, per-plugin, survives daemon restarts and plugin updates. */
|
|
4154
3719
|
dataDir: string;
|
|
4155
|
-
/** This process only; removed when it exits. */
|
|
4156
3720
|
tempDir: string;
|
|
4157
3721
|
}
|
|
4158
3722
|
interface ProviderBridgeDefinition {
|
|
4159
|
-
/** One decoded stdin line of the Provider Bridge Protocol. */
|
|
4160
3723
|
handleLine: (line: string) => void;
|
|
4161
|
-
/**
|
|
4162
|
-
* Called once before the first line is read, with the process's
|
|
4163
|
-
* plugin-scoped directories. Omit it when the bridge keeps no files.
|
|
4164
|
-
*/
|
|
4165
3724
|
start?: (context: ProviderBridgeContext) => void;
|
|
4166
|
-
/** Stdin closed: the runtime is gone and the bridge must shut down. */
|
|
4167
3725
|
onClose?: () => void;
|
|
4168
3726
|
onSigterm?: () => void;
|
|
4169
3727
|
onSigint?: () => void;
|
|
4170
3728
|
}
|
|
4171
3729
|
interface ProviderBridgeEntry extends ProviderBridgeDefinition {
|
|
4172
|
-
/** Bumped when the bootstrap↔bridge contract changes incompatibly. */
|
|
4173
3730
|
experimental_apiVersion: 1;
|
|
4174
3731
|
}
|
|
4175
3732
|
declare function experimental_defineProviderBridge(definition: ProviderBridgeDefinition): ProviderBridgeEntry;
|
|
4176
3733
|
|
|
4177
|
-
/**
|
|
4178
|
-
* Sessionless provider maintenance query. `providerOptions` carries the same
|
|
4179
|
-
* provider-scoped statics as model/list (notably an ACP launch spec), while
|
|
4180
|
-
* `providerId` lets one bridge implementation serve several provider ids.
|
|
4181
|
-
*/
|
|
4182
3734
|
declare const providerMaintenanceParamsSchema: z.ZodObject<{
|
|
4183
3735
|
cwd: z.ZodOptional<z.ZodString>;
|
|
4184
3736
|
providerId: z.ZodString;
|
|
@@ -4198,11 +3750,6 @@ declare const providerInstallationStatusParamsSchema: z.ZodObject<{
|
|
|
4198
3750
|
}>>;
|
|
4199
3751
|
}, z.core.$loose>;
|
|
4200
3752
|
type ProviderInstallationStatusParams = z.infer<typeof providerInstallationStatusParamsSchema>;
|
|
4201
|
-
/**
|
|
4202
|
-
* Cheap, host-local readiness reported by a provider implementation. Network
|
|
4203
|
-
* usage and update checks deliberately live outside this result so choosing a
|
|
4204
|
-
* provider for the composer never waits on them.
|
|
4205
|
-
*/
|
|
4206
3753
|
declare const providerHealthSchema: z.ZodObject<{
|
|
4207
3754
|
accountEmail: z.ZodNullable<z.ZodString>;
|
|
4208
3755
|
canInstall: z.ZodBoolean;
|
|
@@ -4222,7 +3769,6 @@ declare const providerHealthSchema: z.ZodObject<{
|
|
|
4222
3769
|
statusMessage: z.ZodNullable<z.ZodString>;
|
|
4223
3770
|
}, z.core.$loose>;
|
|
4224
3771
|
type ProviderHealth = z.infer<typeof providerHealthSchema>;
|
|
4225
|
-
/** One usage window reported by a provider subscription. */
|
|
4226
3772
|
declare const providerUsageWindowSchema: z.ZodObject<{
|
|
4227
3773
|
cost: z.ZodOptional<z.ZodObject<{
|
|
4228
3774
|
limitUsdCents: z.ZodNumber;
|
|
@@ -4233,7 +3779,6 @@ declare const providerUsageWindowSchema: z.ZodObject<{
|
|
|
4233
3779
|
usedPercent: z.ZodNumber;
|
|
4234
3780
|
}, z.core.$loose>;
|
|
4235
3781
|
type ProviderUsageWindow = z.infer<typeof providerUsageWindowSchema>;
|
|
4236
|
-
/** Live usage for one provider, normalized by that provider's bridge. */
|
|
4237
3782
|
declare const providerUsageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4238
3783
|
accountEmail: z.ZodNullable<z.ZodString>;
|
|
4239
3784
|
planLabel: z.ZodNullable<z.ZodString>;
|
|
@@ -4320,11 +3865,6 @@ declare const providerInstallationActionKindSchema: z.ZodEnum<{
|
|
|
4320
3865
|
update: "update";
|
|
4321
3866
|
}>;
|
|
4322
3867
|
type ProviderInstallationActionKind = z.infer<typeof providerInstallationActionKindSchema>;
|
|
4323
|
-
/**
|
|
4324
|
-
* An installation action that a provider currently knows how to perform.
|
|
4325
|
-
* Only the display command crosses the product boundary; the executable plan
|
|
4326
|
-
* is resolved afresh by `provider/installation/run` on the host.
|
|
4327
|
-
*/
|
|
4328
3868
|
declare const providerInstallationActionSchema: z.ZodObject<{
|
|
4329
3869
|
command: z.ZodString;
|
|
4330
3870
|
kind: z.ZodEnum<{
|
|
@@ -4343,7 +3883,6 @@ declare const providerInstallationSourceSchema: z.ZodEnum<{
|
|
|
4343
3883
|
npmGlobal: "npmGlobal";
|
|
4344
3884
|
}>;
|
|
4345
3885
|
type ProviderInstallationSource = z.infer<typeof providerInstallationSourceSchema>;
|
|
4346
|
-
/** Provider-owned installation and update state for one host. */
|
|
4347
3886
|
declare const providerInstallationStatusSchema: z.ZodObject<{
|
|
4348
3887
|
currentVersion: z.ZodNullable<z.ZodString>;
|
|
4349
3888
|
executableName: z.ZodString;
|
|
@@ -4383,10 +3922,6 @@ declare const providerInstallationRunParamsSchema: z.ZodObject<{
|
|
|
4383
3922
|
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
4384
3923
|
}, z.core.$loose>;
|
|
4385
3924
|
type ProviderInstallationRunParams = z.infer<typeof providerInstallationRunParamsSchema>;
|
|
4386
|
-
/**
|
|
4387
|
-
* A typed process plan. The provider chooses the executable and arguments;
|
|
4388
|
-
* the daemon chooses the environment and cwd and owns process supervision.
|
|
4389
|
-
*/
|
|
4390
3925
|
declare const providerInstallationCommandSchema: z.ZodObject<{
|
|
4391
3926
|
args: z.ZodArray<z.ZodString>;
|
|
4392
3927
|
command: z.ZodString;
|
|
@@ -4403,10 +3938,6 @@ declare const providerInstallationVerificationSchema: z.ZodDiscriminatedUnion<[z
|
|
|
4403
3938
|
version: z.ZodString;
|
|
4404
3939
|
}, z.core.$loose>], "kind">;
|
|
4405
3940
|
type ProviderInstallationVerification = z.infer<typeof providerInstallationVerificationSchema>;
|
|
4406
|
-
/**
|
|
4407
|
-
* `available: false` handles a stale action safely: status may have changed
|
|
4408
|
-
* between rendering a button and the daemon resolving the execution plan.
|
|
4409
|
-
*/
|
|
4410
3941
|
declare const providerInstallationRunResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4411
3942
|
available: z.ZodLiteral<false>;
|
|
4412
3943
|
message: z.ZodString;
|
|
@@ -4429,70 +3960,27 @@ declare const providerInstallationRunResultSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
4429
3960
|
}, z.core.$loose>], "available">;
|
|
4430
3961
|
type ProviderInstallationRunResult = z.infer<typeof providerInstallationRunResultSchema>;
|
|
4431
3962
|
|
|
4432
|
-
/**
|
|
4433
|
-
* The executable's absolute path: the path itself when `command` is
|
|
4434
|
-
* absolute and executable (a launch seam may name one), otherwise the first
|
|
4435
|
-
* `which`/`where` hit; null when the host has no such command.
|
|
4436
|
-
*/
|
|
4437
3963
|
declare function resolveExecutablePath(command: string): Promise<string | null>;
|
|
4438
|
-
/**
|
|
4439
|
-
* `<command> <args>` stdout and stderr, trimmed, within the installation
|
|
4440
|
-
* check budget; null when the command is missing, fails or times out.
|
|
4441
|
-
*/
|
|
4442
3964
|
declare function commandOutput(command: string, args: readonly string[]): Promise<string | null>;
|
|
4443
|
-
/** The first `x.y.z[-prerelease]` token in `value` (an optional `v` prefix dropped). */
|
|
4444
3965
|
declare function versionFrom(value: string | null): string | null;
|
|
4445
|
-
/**
|
|
4446
|
-
* `<command> --version` → the version it printed (stdout or stderr), null
|
|
4447
|
-
* when the command is missing or does not answer within the probe budget.
|
|
4448
|
-
*/
|
|
4449
3966
|
declare function readCliVersion(command: string): Promise<string | null>;
|
|
4450
|
-
/**
|
|
4451
|
-
* Semver-style compare: numeric core first, then a prerelease sorts before
|
|
4452
|
-
* its release (`1.2.0-beta.1` < `1.2.0`). Anything that is not `x.y.z[-pre]`
|
|
4453
|
-
* reads as `0.0.0`.
|
|
4454
|
-
*/
|
|
4455
3967
|
declare function compareVersions(left: string, right: string): number;
|
|
4456
|
-
/** The npm executable for this platform. */
|
|
4457
3968
|
declare function npmCommand(): string;
|
|
4458
|
-
/** A command line for display: each argument single-quoted unless it is plain. */
|
|
4459
3969
|
declare function formatCommand(command: string, args: readonly string[]): string;
|
|
4460
|
-
/**
|
|
4461
|
-
* `npm install -g <package>@latest`: the install action for an npm-published
|
|
4462
|
-
* CLI, and the update action for one without a self-updater.
|
|
4463
|
-
*/
|
|
4464
3970
|
declare function npmGlobalInstallCommand(npmPackage: string): ProviderInstallationCommand;
|
|
4465
|
-
/** The registry's latest version of the package (`npm view <package> version`). */
|
|
4466
3971
|
declare function npmLatestVersion(npmPackage: string): Promise<string | null>;
|
|
4467
3972
|
interface NpmGlobalPackageProbe {
|
|
4468
|
-
/** npm's global bin directory (`npm prefix -g`, plus `bin` off Windows); null when npm is absent. */
|
|
4469
3973
|
npmBin: string | null;
|
|
4470
|
-
/** The version npm has installed globally for the package; null when none. */
|
|
4471
3974
|
npmGlobalPackageVersion: string | null;
|
|
4472
3975
|
}
|
|
4473
|
-
/** What npm knows about a globally installed package. */
|
|
4474
3976
|
declare function probeNpmGlobalPackage(npmPackage: string): Promise<NpmGlobalPackageProbe>;
|
|
4475
|
-
/**
|
|
4476
|
-
* Where an installed CLI came from: inside npm's global bin directory it is
|
|
4477
|
-
* npm's (`npmGlobal`), anywhere else it is the user's own (`external`).
|
|
4478
|
-
*/
|
|
4479
3977
|
declare function npmGlobalInstallSource(args: {
|
|
4480
3978
|
installed: boolean;
|
|
4481
3979
|
executablePath: string | null;
|
|
4482
3980
|
npmBin: string | null;
|
|
4483
3981
|
}): ProviderInstallationSource;
|
|
4484
|
-
/**
|
|
4485
|
-
* How the runtime verifies an install run: an install is done once the
|
|
4486
|
-
* executable exists; an update is done once the version reaches the latest
|
|
4487
|
-
* the status saw, or — when the registry was unreachable — once it changed.
|
|
4488
|
-
*/
|
|
4489
3982
|
declare function installationVerification(status: Pick<ProviderInstallationStatus, "currentVersion" | "latestVersion">, action: "install" | "update"): ProviderInstallationVerification;
|
|
4490
|
-
/**
|
|
4491
|
-
* A vendor's `curl | bash` installer, run from a temp file so a truncated
|
|
4492
|
-
* download never executes half a script.
|
|
4493
|
-
*/
|
|
4494
3983
|
declare function downloadedInstallerCommand(url: string): ProviderInstallationCommand;
|
|
4495
|
-
/** A usage percentage as the integer 0–100 the usage surfaces render. */
|
|
4496
3984
|
declare function clampPercent(value: number): number;
|
|
4497
3985
|
|
|
4498
3986
|
type JsonRpcObject = Record<string, unknown>;
|
|
@@ -4544,13 +4032,6 @@ declare function getRecordProperty(value: StringRecord, key: string): StringReco
|
|
|
4544
4032
|
declare function getStringProperty(value: StringRecord, key: string): string | undefined;
|
|
4545
4033
|
declare function getRawSdkMessage(event: JsonRpcMessage): StringRecord | null;
|
|
4546
4034
|
|
|
4547
|
-
/**
|
|
4548
|
-
* Zod schemas for well-known tool arguments used by both Claude Code and Pi
|
|
4549
|
-
* bridges.
|
|
4550
|
-
*
|
|
4551
|
-
* These tools genuinely use different arg names across SDK versions, so the
|
|
4552
|
-
* schemas express the real variants rather than picking one.
|
|
4553
|
-
*/
|
|
4554
4035
|
declare const bashArgsSchema: z.ZodObject<{
|
|
4555
4036
|
command: z.ZodOptional<z.ZodString>;
|
|
4556
4037
|
cwd: z.ZodOptional<z.ZodString>;
|
|
@@ -4560,80 +4041,17 @@ declare const textBlockSchema: z.ZodObject<{
|
|
|
4560
4041
|
type: z.ZodLiteral<"text">;
|
|
4561
4042
|
}, z.core.$strip>;
|
|
4562
4043
|
|
|
4563
|
-
/**
|
|
4564
|
-
* The bb Provider Bridge Protocol version.
|
|
4565
|
-
*
|
|
4566
|
-
* Negotiated in both directions during `initialize`. Bump only for changes an
|
|
4567
|
-
* older bridge or runtime cannot tolerate: removing a method, changing the
|
|
4568
|
-
* meaning of an existing field, or tightening a previously lenient parse.
|
|
4569
|
-
* Additive changes (new optional capability, new method a bridge may not
|
|
4570
|
-
* implement, new notification the runtime may not understand) do NOT bump the
|
|
4571
|
-
* version — unknown methods answer -32601, unknown notifications are ignored,
|
|
4572
|
-
* and unknown capability fields pass through. That tolerance is the point of
|
|
4573
|
-
* the protocol: bridges version with their plugin, not with the daemon.
|
|
4574
|
-
*
|
|
4575
|
-
* Version history:
|
|
4576
|
-
* - 2 (2026-08): the narrow-grammar cutover. `thread/event` is gone; the
|
|
4577
|
-
* timeline rides `thread/delta` exclusively and the runtime assembles
|
|
4578
|
-
* canonical events. A version-1 bridge still emits `thread/event`
|
|
4579
|
-
* notifications the runtime no longer understands, so the runtime rejects
|
|
4580
|
-
* a mismatched handshake instead of silently showing an empty timeline.
|
|
4581
|
-
* - 1: the original dialect — bridges emitted finished `ThreadEvent`s on
|
|
4582
|
-
* `thread/event`.
|
|
4583
|
-
*/
|
|
4584
4044
|
declare const PROVIDER_BRIDGE_PROTOCOL_VERSION: 2;
|
|
4585
|
-
/**
|
|
4586
|
-
* The `thread/delta` grammar versions. The grammar is versioned separately
|
|
4587
|
-
* from the JSON-RPC envelope (see `grammarVersions` in handshake.ts): v2 was
|
|
4588
|
-
* the narrow grammar that shipped with protocol version 2; v3 adds the core
|
|
4589
|
-
* item kinds `fileRead`, `search`, `delegation` and `planSteps`, declarative
|
|
4590
|
-
* `presentation` on `item.open`/`item.close`, plugin extension kinds
|
|
4591
|
-
* (`extension` items, `extension.state`), and replaces v2's two streaming
|
|
4592
|
-
* dialects and two usage dialects with one of each (`item.textDelta`/
|
|
4593
|
-
* `item.textClose`, `usage` + `contextWindow`). A bridge reports the range
|
|
4594
|
-
* it speaks; the runtime reports the range its assembler accepts; both emit
|
|
4595
|
-
* the highest common version. The runtime's assembler speaks v3 only; a
|
|
4596
|
-
* bridge that predates `grammarVersions` reads as `[2, 2]` and is refused at
|
|
4597
|
-
* the handshake.
|
|
4598
|
-
*/
|
|
4599
4045
|
declare const THREAD_DELTA_GRAMMAR_V2: 2;
|
|
4600
4046
|
declare const THREAD_DELTA_GRAMMAR_V3: 3;
|
|
4601
4047
|
|
|
4602
|
-
/**
|
|
4603
|
-
* The inclusive `[min, max]` range of `thread/delta` grammar versions a bridge
|
|
4604
|
-
* speaks. Distinct from the JSON-RPC `protocolVersion`: the envelope can stay
|
|
4605
|
-
* put while the delta vocabulary grows, and a bridge that speaks both v2 and
|
|
4606
|
-
* v3 says so here instead of forcing a daemon bump.
|
|
4607
|
-
*/
|
|
4608
4048
|
declare const bridgeGrammarVersionsSchema: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
4609
4049
|
type BridgeGrammarVersions = z.infer<typeof bridgeGrammarVersionsSchema>;
|
|
4610
|
-
/**
|
|
4611
|
-
* How the bridge delivers `turn/steer` while a turn is live. `inject` feeds
|
|
4612
|
-
* the steer text into the running model loop (claude, codex); `queue` holds
|
|
4613
|
-
* it for the next prompt boundary (ACP v1 cancels the live prompt and
|
|
4614
|
-
* re-prompts with the queued text). The runtime sends `turn/steer` either
|
|
4615
|
-
* way and drops a steer whose turn is gone on the bridge's `staleTurn`
|
|
4616
|
-
* recovery hint whatever the mode; nothing reads the mode yet (see
|
|
4617
|
-
* `steerMode` below).
|
|
4618
|
-
*/
|
|
4619
4050
|
declare const bridgeSteerModeSchema: z.ZodEnum<{
|
|
4620
4051
|
inject: "inject";
|
|
4621
4052
|
queue: "queue";
|
|
4622
4053
|
}>;
|
|
4623
4054
|
type BridgeSteerMode = z.infer<typeof bridgeSteerModeSchema>;
|
|
4624
|
-
/**
|
|
4625
|
-
* Session-behavior facts the bridge reports at `initialize`. These are
|
|
4626
|
-
* deliberately NOT provider declarations: the code that implements a feature
|
|
4627
|
-
* is the code that reports it, so a handshake fact cannot drift from behavior
|
|
4628
|
-
* the way a declared boolean can.
|
|
4629
|
-
*
|
|
4630
|
-
* Every field defaults on parse so an older bridge that omits a capability is
|
|
4631
|
-
* read as not having it — absence is a definite "no", never an error, and the
|
|
4632
|
-
* parsed object always carries explicit values internally.
|
|
4633
|
-
*
|
|
4634
|
-
* The schema is loose: unknown capability fields from a newer bridge pass
|
|
4635
|
-
* through untouched so a newer plugin works against an older runtime.
|
|
4636
|
-
*/
|
|
4637
4055
|
declare const bridgeCapabilitiesSchema: z.ZodObject<{
|
|
4638
4056
|
approvalEnforcedBy: z.ZodDefault<z.ZodEnum<{
|
|
4639
4057
|
provider: "provider";
|
|
@@ -4658,7 +4076,6 @@ declare const bridgeCapabilitiesSchema: z.ZodObject<{
|
|
|
4658
4076
|
threadRename: z.ZodDefault<z.ZodBoolean>;
|
|
4659
4077
|
}, z.core.$loose>;
|
|
4660
4078
|
type BridgeCapabilities = z.infer<typeof bridgeCapabilitiesSchema>;
|
|
4661
|
-
/** Runtime → bridge `initialize` params. */
|
|
4662
4079
|
declare const initializeParamsSchema: z.ZodObject<{
|
|
4663
4080
|
client: z.ZodObject<{
|
|
4664
4081
|
name: z.ZodString;
|
|
@@ -4667,7 +4084,6 @@ declare const initializeParamsSchema: z.ZodObject<{
|
|
|
4667
4084
|
grammarVersions: z.ZodDefault<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
4668
4085
|
protocolVersion: z.ZodNumber;
|
|
4669
4086
|
}, z.core.$loose>;
|
|
4670
|
-
/** Bridge → runtime `initialize` result. */
|
|
4671
4087
|
declare const initializeResultSchema: z.ZodObject<{
|
|
4672
4088
|
capabilities: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodObject<{
|
|
4673
4089
|
approvalEnforcedBy: z.ZodDefault<z.ZodEnum<{
|
|
@@ -4696,20 +4112,6 @@ declare const initializeResultSchema: z.ZodObject<{
|
|
|
4696
4112
|
}, z.core.$loose>;
|
|
4697
4113
|
type InitializeResult = z.infer<typeof initializeResultSchema>;
|
|
4698
4114
|
|
|
4699
|
-
/**
|
|
4700
|
-
* The canonical execution options carried on session and turn commands.
|
|
4701
|
-
*
|
|
4702
|
-
* Deliberately provider-agnostic: there are no provider-specific fields here
|
|
4703
|
-
* and none may be added. Provider-flavored knobs (Claude's plan mode, memory
|
|
4704
|
-
* and subagent toggles, mock-CLI traffic, …) travel in `providerOptions` — an
|
|
4705
|
-
* opaque bag the provider's own plugin derives from its settings and only its
|
|
4706
|
-
* bridge interprets. The runtime and server pass it through untouched.
|
|
4707
|
-
*
|
|
4708
|
-
* The runtime never diffs these options. They ride every command; the bridge
|
|
4709
|
-
* reconciles internally (apply live where it can, rebuild its provider
|
|
4710
|
-
* session where it must) and a rebuild is always reported via the
|
|
4711
|
-
* `session/replaced` notification — never silent.
|
|
4712
|
-
*/
|
|
4713
4115
|
declare const bridgeExecutionOptionsSchema: z.ZodIntersection<z.ZodObject<{
|
|
4714
4116
|
envVars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4715
4117
|
instructions: z.ZodOptional<z.ZodString>;
|
|
@@ -4754,13 +4156,6 @@ declare const bridgeExecutionOptionsSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
4754
4156
|
}, z.core.$strip>], "permissionMode">>;
|
|
4755
4157
|
type BridgeExecutionOptions = z.infer<typeof bridgeExecutionOptionsSchema>;
|
|
4756
4158
|
|
|
4757
|
-
/**
|
|
4758
|
-
* Canonical runtime → bridge request methods. One vocabulary for every
|
|
4759
|
-
* provider: a bridge maps these to its provider's native dialect internally
|
|
4760
|
-
* (codex `thread/stop` → `turn/interrupt`, `thread/discard` →
|
|
4761
|
-
* `thread/archive`, …). Methods gated by a handshake capability are simply
|
|
4762
|
-
* never sent to a bridge that did not advertise them.
|
|
4763
|
-
*/
|
|
4764
4159
|
declare const BRIDGE_REQUEST_METHODS: {
|
|
4765
4160
|
readonly initialize: "initialize";
|
|
4766
4161
|
readonly modelList: "model/list";
|
|
@@ -5371,13 +4766,6 @@ declare const turnSteerParamsSchema: z.ZodObject<{
|
|
|
5371
4766
|
providerThreadId: z.ZodString;
|
|
5372
4767
|
threadId: z.ZodString;
|
|
5373
4768
|
}, z.core.$loose>;
|
|
5374
|
-
/**
|
|
5375
|
-
* The canonical skill-injection payload. One shape for every provider: the
|
|
5376
|
-
* staged roots plus their skills. Each bridge transforms a root into its
|
|
5377
|
-
* provider's native form (a Claude local plugin, a codex extra skills root, a
|
|
5378
|
-
* pi additional skill path, an ACP prompt listing) — the per-provider shapes
|
|
5379
|
-
* never cross the wire.
|
|
5380
|
-
*/
|
|
5381
4769
|
declare const skillsConfigureParamsSchema: z.ZodObject<{
|
|
5382
4770
|
roots: z.ZodArray<z.ZodObject<{
|
|
5383
4771
|
id: z.ZodString;
|
|
@@ -5389,13 +4777,6 @@ declare const skillsConfigureParamsSchema: z.ZodObject<{
|
|
|
5389
4777
|
}, z.core.$loose>>;
|
|
5390
4778
|
}, z.core.$loose>;
|
|
5391
4779
|
|
|
5392
|
-
/**
|
|
5393
|
-
* Bridge → runtime notifications. Everything timeline-bound (assistant text,
|
|
5394
|
-
* tool calls, token usage, context-window usage, …) rides `thread/delta`
|
|
5395
|
-
* (see thread-delta.ts) as parsed semantic deltas the runtime's assembler
|
|
5396
|
-
* turns into canonical `ThreadEvent`s. The notifications here are runtime
|
|
5397
|
-
* signals that are not timeline events.
|
|
5398
|
-
*/
|
|
5399
4780
|
declare const BRIDGE_NOTIFICATION_METHODS: {
|
|
5400
4781
|
readonly threadIdentity: "thread/identity";
|
|
5401
4782
|
readonly sessionReplaced: "session/replaced";
|
|
@@ -5403,26 +4784,6 @@ declare const BRIDGE_NOTIFICATION_METHODS: {
|
|
|
5403
4784
|
readonly providerRecovery: "provider/recovery";
|
|
5404
4785
|
readonly error: "error";
|
|
5405
4786
|
};
|
|
5406
|
-
/**
|
|
5407
|
-
* A typed recovery hint: the bridge tells the runtime WHAT went wrong in the
|
|
5408
|
-
* runtime's own vocabulary, so the runtime never matches provider error text
|
|
5409
|
-
* (the codex regex set, the account-restart list, the archive idempotency
|
|
5410
|
-
* string match all go away in WS4). A runtime signal, not a timeline item —
|
|
5411
|
-
* the user-visible consequence, when there is one, is the `provider/error`
|
|
5412
|
-
* delta the bridge emits alongside, and the timeline stays free of
|
|
5413
|
-
* "restarting the bridge" noise. Lives here with `session/replaced` rather
|
|
5414
|
-
* than in `thread/delta` for the same reason `provider/raw` does: it is
|
|
5415
|
-
* consumed by the runtime's recovery logic, never persisted.
|
|
5416
|
-
*
|
|
5417
|
-
* `threadId` is absent for provider-wide conditions (`authRequired`,
|
|
5418
|
-
* `rateLimited` at the account level) and present when the hint is about one
|
|
5419
|
-
* session (`sessionArchived`, `staleTurn`). `retryable` says whether the
|
|
5420
|
-
* runtime may retry the failed command after acting on the hint.
|
|
5421
|
-
*
|
|
5422
|
-
* Unsolicited hints only: a condition that is the reason a runtime request
|
|
5423
|
-
* failed rides that request's error response as `error.data.recovery`
|
|
5424
|
-
* (see `bridgeErrorDataSchema`), never this notification as well.
|
|
5425
|
-
*/
|
|
5426
4787
|
declare const providerRecoveryNotificationSchema: z.ZodObject<{
|
|
5427
4788
|
kind: z.ZodEnum<{
|
|
5428
4789
|
authRequired: "authRequired";
|
|
@@ -5437,11 +4798,6 @@ declare const providerRecoveryNotificationSchema: z.ZodObject<{
|
|
|
5437
4798
|
}, z.core.$loose>;
|
|
5438
4799
|
type ProviderRecoveryNotification = z.infer<typeof providerRecoveryNotificationSchema>;
|
|
5439
4800
|
|
|
5440
|
-
/**
|
|
5441
|
-
* Bridge → runtime requests: the two channels where the provider needs an
|
|
5442
|
-
* answer from bb mid-turn. Both carry canonical bb shapes — the bridge maps
|
|
5443
|
-
* its provider's native forms in both directions.
|
|
5444
|
-
*/
|
|
5445
4801
|
declare const BRIDGE_INBOUND_REQUEST_METHODS: {
|
|
5446
4802
|
readonly toolCall: "item/tool/call";
|
|
5447
4803
|
readonly interactionRequest: "interaction/request";
|
|
@@ -5449,22 +4805,8 @@ declare const BRIDGE_INBOUND_REQUEST_METHODS: {
|
|
|
5449
4805
|
|
|
5450
4806
|
interface SanitizeInheritedChildProcessEnvArgs {
|
|
5451
4807
|
env: NodeJS.ProcessEnv;
|
|
5452
|
-
/**
|
|
5453
|
-
* The user's login-shell PATH, substituted for the inherited one. Omit to
|
|
5454
|
-
* keep the parent's PATH: that is a real distinction, not a default. A
|
|
5455
|
-
* daemon started by launchd or systemd inherits a minimal PATH that finds
|
|
5456
|
-
* none of the user's tools, so anything spawning user-facing executables
|
|
5457
|
-
* (plugin hosts, provider bridges) passes the resolved shell PATH, while a
|
|
5458
|
-
* child that must run exactly what the parent runs must not.
|
|
5459
|
-
*/
|
|
5460
4808
|
shellPath?: string;
|
|
5461
4809
|
}
|
|
5462
|
-
/**
|
|
5463
|
-
* The one answer to "what does a bb-spawned child process inherit": the
|
|
5464
|
-
* parent's env minus bb runtime-owned variables (`BB_*`) and `NODE_ENV`,
|
|
5465
|
-
* optionally with the user's login-shell PATH substituted. Callers overlay
|
|
5466
|
-
* only the child-specific bb env they intentionally expose afterward.
|
|
5467
|
-
*/
|
|
5468
4810
|
declare function sanitizeInheritedChildProcessEnv(args: SanitizeInheritedChildProcessEnvArgs): NodeJS.ProcessEnv;
|
|
5469
4811
|
|
|
5470
4812
|
declare const acpLaunchSpecSchema: z.ZodObject<{
|
|
@@ -5576,13 +4918,6 @@ declare const acpLaunchSpecSchema: z.ZodObject<{
|
|
|
5576
4918
|
}, z.core.$strict>>;
|
|
5577
4919
|
}, z.core.$strict>;
|
|
5578
4920
|
type AcpLaunchSpec = z.infer<typeof acpLaunchSpecSchema>;
|
|
5579
|
-
/**
|
|
5580
|
-
* The spec with its empty optional parts dropped: a `modelCli` that lists
|
|
5581
|
-
* nothing, a `permissionCli` that names no mode, and every absent field.
|
|
5582
|
-
* Two specs that launch the same agent then compare equal field by field,
|
|
5583
|
-
* which is what the SDK's `normalizeHostDaemonAcpLaunchSpec` (0.4.x) promised
|
|
5584
|
-
* a bridge; nothing in this repository keys on the normalized form any more.
|
|
5585
|
-
*/
|
|
5586
4921
|
declare function normalizeAcpLaunchSpec(spec: AcpLaunchSpec): AcpLaunchSpec;
|
|
5587
4922
|
|
|
5588
4923
|
/**
|