@get-bb/plugin-sdk 0.4.24 → 0.4.28

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.
@@ -740,7 +740,10 @@ var BridgeRecoveryError = class extends Error {
740
740
  code;
741
741
  recovery;
742
742
  constructor(args) {
743
- super(args.message, args.cause === void 0 ? void 0 : { cause: args.cause });
743
+ super(
744
+ args.message,
745
+ args.cause === void 0 ? void 0 : { cause: args.cause }
746
+ );
744
747
  this.name = "BridgeRecoveryError";
745
748
  this.code = args.code;
746
749
  this.recovery = args.recovery;
@@ -759,8 +762,6 @@ function createBridgeIo({
759
762
  send({
760
763
  jsonrpc: "2.0",
761
764
  id,
762
- // Omitted rather than `undefined`: an error response without
763
- // structured detail keeps the exact shape it has always had.
764
765
  error: { code, message, ...data === void 0 ? {} : { data } }
765
766
  });
766
767
  },
@@ -798,12 +799,7 @@ function runBridgeRequest(args) {
798
799
  }
799
800
 
800
801
  // ../provider-bridge-protocol/src/bridge-kit/bridge-recorder.ts
801
- import {
802
- closeSync,
803
- mkdirSync,
804
- openSync,
805
- writeSync
806
- } from "node:fs";
802
+ import { closeSync, mkdirSync, openSync, writeSync } from "node:fs";
807
803
  import { join, resolve } from "node:path";
808
804
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
809
805
  var PROVIDER_BRIDGE_RECORD_DIR_ENV = "BB_PROVIDER_BRIDGE_RECORD_DIR";
@@ -886,7 +882,10 @@ function createBridgeRecorder(args) {
886
882
  }
887
883
  const scopeDir = join(dir, scope);
888
884
  mkdirSync(scopeDir, { recursive: true });
889
- const fd = openSync(join(scopeDir, bridgeRecordingFileName(direction)), "a");
885
+ const fd = openSync(
886
+ join(scopeDir, bridgeRecordingFileName(direction)),
887
+ "a"
888
+ );
890
889
  fds.set(key, fd);
891
890
  return fd;
892
891
  }
@@ -937,13 +936,21 @@ function createBridgeRecorder(args) {
937
936
  const { stdin, stdout } = child;
938
937
  if (stdout) {
939
938
  const splitter = createRecordingLineSplitter(
940
- (line) => record({ direction: "provider\u2192bridge", line, threadId: scope.threadId })
939
+ (line) => record({
940
+ direction: "provider\u2192bridge",
941
+ line,
942
+ threadId: scope.threadId
943
+ })
941
944
  );
942
945
  stdout.on("data", (chunk) => splitter.push(chunk));
943
946
  }
944
947
  if (stdin) {
945
948
  const splitter = createRecordingLineSplitter(
946
- (line) => record({ direction: "bridge\u2192provider", line, threadId: scope.threadId })
949
+ (line) => record({
950
+ direction: "bridge\u2192provider",
951
+ line,
952
+ threadId: scope.threadId
953
+ })
947
954
  );
948
955
  const originalWrite = stdin.write.bind(stdin);
949
956
  stdin.write = ((chunk, ...rest) => {
@@ -1111,9 +1118,6 @@ function decodeToolCallResponsePayload(result) {
1111
1118
  };
1112
1119
  }
1113
1120
  return {
1114
- // Keep the legacy aggregate fields for provider bridges that already use
1115
- // this published helper. New consumers use contentBlocks so interleaved
1116
- // text and images retain the plugin result's order.
1117
1121
  content: text,
1118
1122
  contentBlocks,
1119
1123
  images,
@@ -1402,16 +1406,7 @@ var canonicalPromptMentionResourceSchema = z6.discriminatedUnion("kind", [
1402
1406
  z6.object({
1403
1407
  kind: z6.literal("plugin"),
1404
1408
  pluginId: z6.string(),
1405
- /**
1406
- * Named shared-UI icon hint supplied by the plugin mention item. Omitted
1407
- * by mentions persisted before icon hints were stored.
1408
- */
1409
1409
  icon: z6.string().nullable().optional(),
1410
- /**
1411
- * Opaque item reference minted by the server's mention search
1412
- * (`<providerId>:<provider item id>`); resolved back through the same
1413
- * plugin's mention provider at send time (plugin design §4.9).
1414
- */
1415
1410
  itemId: z6.string(),
1416
1411
  label: z6.string()
1417
1412
  })
@@ -1450,21 +1445,11 @@ var promptInputSchema = z6.discriminatedUnion("type", [
1450
1445
  }),
1451
1446
  z6.object({
1452
1447
  type: z6.literal("localImage"),
1453
- /**
1454
- * Absolute paths and URI-like values are passed through to the runtime.
1455
- * Relative paths are server-managed attachment references, not workspace
1456
- * relative files.
1457
- */
1458
1448
  path: z6.string(),
1459
1449
  ...promptInputVisibilityFields
1460
1450
  }),
1461
1451
  z6.object({
1462
1452
  type: z6.literal("localFile"),
1463
- /**
1464
- * Absolute paths and URI-like values are passed through to the runtime.
1465
- * Relative paths are server-managed attachment references, not workspace
1466
- * relative files.
1467
- */
1468
1453
  path: z6.string(),
1469
1454
  name: z6.string().optional(),
1470
1455
  sizeBytes: z6.number().int().nonnegative().optional(),
@@ -1604,13 +1589,7 @@ var runtimeThreadExecutionBaseOptionsSchema = z6.object({
1604
1589
  model: z6.string().min(1),
1605
1590
  serviceTier: serviceTierSchema,
1606
1591
  reasoningLevel: reasoningLevelSchema,
1607
- /** Present only when the prompt entered a BB prompt mode. */
1608
1592
  promptMode: promptModeSchema.optional(),
1609
- /**
1610
- * Plugin-derived, provider-scoped options. Always present — an empty
1611
- * object when the provider derives none — so the daemon never has to
1612
- * guess whether the server ran the hook.
1613
- */
1614
1593
  providerOptions: jsonObjectSchema
1615
1594
  });
1616
1595
  var runtimeThreadExecutionOptionsSchema = runtimeThreadExecutionBaseOptionsSchema.and(runtimePermissionPolicySchema);
@@ -1916,7 +1895,6 @@ var workflowAgentStateValues = [
1916
1895
  ];
1917
1896
  var workflowAgentStateSchema = z9.enum(workflowAgentStateValues);
1918
1897
  var workflowAgentSnapshotSchema = z9.object({
1919
- /** 1-based agent counter; the stable identity for fold/replace semantics. */
1920
1898
  index: z9.number().int().positive(),
1921
1899
  label: z9.string(),
1922
1900
  state: workflowAgentStateSchema,
@@ -1940,10 +1918,8 @@ var workflowAgentSnapshotSchema = z9.object({
1940
1918
  durationMs: z9.number().optional()
1941
1919
  });
1942
1920
  var workflowPhaseSnapshotSchema = z9.object({
1943
- /** 1-based phase counter; meta.phases are seeded before any agent runs. */
1944
1921
  index: z9.number().int().positive(),
1945
1922
  title: z9.string(),
1946
- /** "child" marks a nested workflow() sub-run group. */
1947
1923
  kind: z9.string().optional()
1948
1924
  });
1949
1925
  var workflowProgressSnapshotSchema = z9.object({
@@ -1994,9 +1970,7 @@ function jsonByteLength(value) {
1994
1970
  import { z as z10 } from "zod";
1995
1971
  var THREAD_EVENT_ITEM_PRESENTATION_DETAIL_MAX_LENGTH = 280;
1996
1972
  var threadEventItemPresentationLabelSchema = z10.object({
1997
- /** Present-tense row title while the item is in flight ("Reading file"). */
1998
1973
  pending: z10.string().min(1),
1999
- /** Past-tense row title once the item settled ("Read file"). */
2000
1974
  completed: z10.string().min(1)
2001
1975
  });
2002
1976
  var threadEventItemPresentationIconSchema = z10.object({
@@ -2009,16 +1983,9 @@ var threadEventItemPresentationTintSchema = z10.object({
2009
1983
  var threadEventItemPresentationSchema = z10.object({
2010
1984
  label: threadEventItemPresentationLabelSchema,
2011
1985
  icon: threadEventItemPresentationIconSchema,
2012
- /** Row headline beside the label (a path, a query, a child thread title). */
2013
1986
  title: z10.string().optional(),
2014
- /**
2015
- * Short Markdown summary shown in the row body. Length-capped here so a
2016
- * bridge cannot turn the persisted row into a transcript.
2017
- */
2018
1987
  detail: z10.string().max(THREAD_EVENT_ITEM_PRESENTATION_DETAIL_MAX_LENGTH).optional(),
2019
- /** Low-value rows (TodoWrite, ToolSearch) clients collapse by default. */
2020
1988
  suppress: z10.boolean().optional(),
2021
- /** Accent colour per theme; omitted rows use the neutral row tint. */
2022
1989
  tint: threadEventItemPresentationTintSchema.optional()
2023
1990
  });
2024
1991
 
@@ -2138,9 +2105,7 @@ var pendingInteractionPermissionGrantApprovalSubjectSchema = z12.object({
2138
2105
  var pendingInteractionPlanApprovalSubjectSchema = z12.object({
2139
2106
  kind: z12.literal("plan"),
2140
2107
  itemId: z12.string().min(1),
2141
- /** The plan body, as Markdown. */
2142
2108
  plan: z12.string().min(1),
2143
- /** Where the provider saved the plan, or null when it kept it in memory. */
2144
2109
  planFilePath: z12.string().min(1).nullable()
2145
2110
  });
2146
2111
  var pendingInteractionToolUseApprovalSubjectSchema = z12.object({
@@ -2457,21 +2422,13 @@ var systemEventTypeValues = [
2457
2422
  "client/turn/rejected",
2458
2423
  "client/turn/start",
2459
2424
  "system/error",
2460
- // Legacy persisted user-visible system event from a removed runtime path.
2461
- // Retained for read/decode/render compatibility only.
2462
2425
  "system/manager/user_message",
2463
2426
  "system/thread/interrupted",
2464
2427
  "system/operation",
2465
2428
  "system/interaction/lifecycle",
2466
- // Legacy persisted per-shape interaction events; every status change now
2467
- // appends one `system/interaction/lifecycle`. Retained for read/decode
2468
- // only: `convertLegacyStoredThreadEvent` projects a stored row into the
2469
- // lifecycle event, so no consumer sees these types.
2470
2429
  "system/permissionGrant/lifecycle",
2471
2430
  "system/userQuestion/lifecycle",
2472
2431
  "system/thread-provisioning",
2473
- // Legacy persisted watchdog diagnostic; retained for read/decode/render
2474
- // only, with no current producer.
2475
2432
  "system/provider-turn-watchdog"
2476
2433
  ];
2477
2434
  var threadTurnInitiatorValues = ["user", "agent", "system"];
@@ -2523,18 +2480,10 @@ var clientTurnLifecycleEventDataSchema = z14.object({
2523
2480
  var turnRequestEventDataSchema = z14.object({
2524
2481
  direction: z14.literal("outbound"),
2525
2482
  requestId: clientTurnRequestIdSchema,
2526
- /** Failed request resumed by a guarded system continuation, when present. */
2527
2483
  continuationOfRequestId: clientTurnRequestIdSchema.optional(),
2528
2484
  source: z14.enum(["spawn", "tell"]),
2529
2485
  initiator: threadTurnInitiatorSchema,
2530
- // Non-null only when initiator === "agent". The invariant is enforced by
2531
- // writer typings rather than a schema refine so legacy persisted events
2532
- // (initiator: "agent", senderThreadId: null from before the field
2533
- // existed) still parse — the stored variant defaults both fields.
2534
2486
  senderThreadId: z14.string().nullable(),
2535
- // Family-B system-message taxonomy fields. Optional at the persisted-event
2536
- // level: legacy events (pre-taxonomy) lack them and must still parse. The
2537
- // projection defaults absent values to `unlabeled` / `null`.
2538
2487
  systemMessageKind: systemMessageKindSchema.optional(),
2539
2488
  systemMessageSubject: systemMessageSubjectSchema.nullable().optional(),
2540
2489
  input: z14.array(promptInputSchema),
@@ -2620,15 +2569,14 @@ var systemUserQuestionLifecycleEventDataSchema = z14.object({
2620
2569
  var systemThreadInterruptedReasonValues = [
2621
2570
  "manual-stop",
2622
2571
  "host-daemon-restarted",
2623
- // Legacy persisted watchdog interruption; retained for read/replay only,
2624
- // with no current producer.
2625
2572
  "provider-turn-idle"
2626
2573
  ];
2627
2574
  var systemThreadInterruptedReasonSchema = z14.enum(
2628
2575
  systemThreadInterruptedReasonValues
2629
2576
  );
2630
2577
  var systemThreadInterruptedEventDataSchema = z14.object({
2631
- reason: systemThreadInterruptedReasonSchema
2578
+ reason: systemThreadInterruptedReasonSchema,
2579
+ cause: z14.literal("host-connection-lost").optional()
2632
2580
  });
2633
2581
  var provisioningTranscriptEntrySchema = z14.object({
2634
2582
  type: z14.enum(["step", "output"]),
@@ -2665,11 +2613,6 @@ var systemProviderTurnWatchdogEventDataSchema = z14.object({
2665
2613
  activeTurnId: z14.string().min(1),
2666
2614
  activeTurnStartedAt: z14.number().int().nonnegative(),
2667
2615
  lastActivityEventSequence: z14.number().int().positive(),
2668
- /**
2669
- * Diagnostic label only (the UI interpolates it verbatim). A plain string —
2670
- * not the activity enum — so editing event classifications never makes
2671
- * previously persisted watchdog events unparseable.
2672
- */
2673
2616
  lastActivityEventType: z14.string().min(1),
2674
2617
  lastActivityEventAt: z14.number().int().nonnegative(),
2675
2618
  providerId: z14.string().min(1),
@@ -2932,7 +2875,6 @@ var providerRateLimitStatusSchema = z17.enum([
2932
2875
  "unknown"
2933
2876
  ]);
2934
2877
  var providerRateLimitWindowSchema = z17.object({
2935
- /** Opaque provider-issued key. New provider windows must not break parsing. */
2936
2878
  providerKey: z17.string().min(1).nullable(),
2937
2879
  label: z17.string().min(1).nullable(),
2938
2880
  status: providerRateLimitStatusSchema,
@@ -3017,11 +2959,9 @@ var threadEventDelegationItemSchema = z17.object({
3017
2959
  type: z17.literal("delegation"),
3018
2960
  id: z17.string(),
3019
2961
  childRef: z17.string().min(1),
3020
- /** Human label for the delegated work (the child's description). */
3021
2962
  label: z17.string(),
3022
2963
  status: threadEventItemStatusSchema,
3023
2964
  background: z17.boolean(),
3024
- /** Terminal summary from the child; absent while it runs. */
3025
2965
  summary: z17.string().optional(),
3026
2966
  ...itemPresentationField,
3027
2967
  parentToolCallId: z17.string().optional()
@@ -3082,10 +3022,6 @@ var threadEventWarningCategorySchema = z17.enum([
3082
3022
  "deprecation",
3083
3023
  "config",
3084
3024
  "general",
3085
- /**
3086
- * The provider declined a compaction that bb asked for because there was
3087
- * nothing to compact. The warning settles the pending compaction row.
3088
- */
3089
3025
  "compaction-skipped"
3090
3026
  ]);
3091
3027
  var providerRawEventSchema = z17.object({
@@ -3114,28 +3050,15 @@ var toolCallProgressEventSchema = z17.object({
3114
3050
  var threadEventBackgroundTaskItemSchema = z17.object({
3115
3051
  type: z17.literal("backgroundTask"),
3116
3052
  id: z17.string(),
3117
- /**
3118
- * The provider's stable task id, shared by every generation (restart) of
3119
- * the same task; consumers use it to correlate a restarted task with its
3120
- * earlier generations. Absent only on events persisted before the field
3121
- * existed — those encoded the family in the item id's legacy `#N`
3122
- * generation suffix instead.
3123
- */
3124
3053
  familyId: z17.string().optional(),
3125
- /** Raw SDK task discriminant (e.g. "local_workflow"); "unknown" when the provider omitted it. */
3126
3054
  taskType: z17.string(),
3127
3055
  description: z17.string(),
3128
3056
  status: threadEventItemStatusSchema,
3129
3057
  taskStatus: backgroundTaskStatusSchema,
3130
- /** Ambient/housekeeping task; consumers hide it from the inline transcript. */
3131
3058
  skipTranscript: z17.boolean(),
3132
- /** meta.name of the workflow script; only present for workflow tasks. */
3133
3059
  workflowName: z17.string().optional(),
3134
- /** Merged workflow tree; absent until the provider reports progress records. */
3135
3060
  workflow: workflowProgressSnapshotSchema.optional(),
3136
- /** Absent until the provider reports usage. */
3137
3061
  usage: backgroundTaskUsageSchema.optional(),
3138
- /** Terminal summary from the provider; absent while the task runs. */
3139
3062
  summary: z17.string().optional(),
3140
3063
  error: z17.string().optional(),
3141
3064
  outputFile: z17.string().optional(),
@@ -3143,7 +3066,6 @@ var threadEventBackgroundTaskItemSchema = z17.object({
3143
3066
  parentToolCallId: z17.string().optional()
3144
3067
  });
3145
3068
  var threadEventItemSchema = z17.discriminatedUnion("type", [
3146
- // bb authors user messages itself, so they carry no bridge presentation.
3147
3069
  z17.object({
3148
3070
  type: z17.literal("userMessage"),
3149
3071
  id: z17.string(),
@@ -3165,10 +3087,6 @@ var threadEventItemSchema = z17.discriminatedUnion("type", [
3165
3087
  cwd: z17.string(),
3166
3088
  status: threadEventItemStatusSchema,
3167
3089
  approvalStatus: threadEventItemApprovalStatusSchema,
3168
- /**
3169
- * Omitted when the process produced no stdout/stderr. Adapters should omit
3170
- * this field instead of emitting an empty string placeholder.
3171
- */
3172
3090
  aggregatedOutput: z17.string().optional(),
3173
3091
  exitCode: z17.number().optional(),
3174
3092
  durationMs: z17.number().optional(),
@@ -3201,10 +3119,6 @@ var threadEventItemSchema = z17.discriminatedUnion("type", [
3201
3119
  error: z17.string().optional(),
3202
3120
  durationMs: z17.number().optional(),
3203
3121
  truncation: threadEventItemTruncationSchema.optional(),
3204
- /**
3205
- * The escape hatch for tools with no core kind: the bridge says how the
3206
- * row reads (label, glyph, headline, suppression).
3207
- */
3208
3122
  ...itemPresentationField,
3209
3123
  parentToolCallId: z17.string().optional()
3210
3124
  }),
@@ -3253,12 +3167,9 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
3253
3167
  z17.object({
3254
3168
  type: z17.literal("turn/completed"),
3255
3169
  threadId: z17.string(),
3256
- // Server reconciliation can synthesize interrupted completions when the
3257
- // original provider thread id was never persisted.
3258
3170
  providerThreadId: z17.string().nullable(),
3259
3171
  status: threadEventTurnStatusSchema,
3260
3172
  error: z17.object({ message: z17.string() }).optional(),
3261
- /** Provider-native point through which a replacement branch should retain history. */
3262
3173
  providerCheckpointId: z17.string().min(1).optional()
3263
3174
  }),
3264
3175
  z17.object({
@@ -3325,10 +3236,6 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
3325
3236
  providerThreadId: z17.string(),
3326
3237
  itemId: z17.string(),
3327
3238
  delta: z17.string(),
3328
- /**
3329
- * When true, this delta replaces previously accumulated command output
3330
- * instead of appending to it. Omission means the delta appends.
3331
- */
3332
3239
  reset: z17.boolean().optional(),
3333
3240
  parentToolCallId: z17.string().optional()
3334
3241
  }),
@@ -3373,49 +3280,24 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
3373
3280
  parentToolCallId: z17.string().optional()
3374
3281
  }),
3375
3282
  toolCallProgressEventSchema,
3376
- /**
3377
- * Superseding state snapshot for an in-flight background task. Thread-scoped
3378
- * (not turn-scoped) because tasks outlive their spawning turn: late events
3379
- * must not interleave into later turns' sequence-contiguous windows. Each
3380
- * progress event carries the full current item state; consumers replace, not
3381
- * merge. The item is placed in the timeline by its turn-scoped item/started.
3382
- */
3383
3283
  z17.object({
3384
3284
  type: z17.literal("item/backgroundTask/progress"),
3385
3285
  threadId: z17.string(),
3386
3286
  providerThreadId: z17.string(),
3387
3287
  item: threadEventBackgroundTaskItemSchema
3388
3288
  }),
3389
- /**
3390
- * Terminal state for a background task, carrying the full final item
3391
- * payload. Dedicated event (instead of the generic turn-scoped
3392
- * item/completed) because it may arrive turns after the item/started.
3393
- */
3394
3289
  z17.object({
3395
3290
  type: z17.literal("item/backgroundTask/completed"),
3396
3291
  threadId: z17.string(),
3397
3292
  providerThreadId: z17.string(),
3398
3293
  item: threadEventBackgroundTaskItemSchema
3399
3294
  }),
3400
- /**
3401
- * Superseding snapshot for an in-flight background delegation (`background:
3402
- * true`). Thread-scoped for the same reason as `item/backgroundTask/
3403
- * progress`: a background child outlives its spawning turn, and late events
3404
- * must not interleave into later turns' sequence-contiguous windows. The
3405
- * item is placed in the timeline by its turn-scoped `item/started`.
3406
- */
3407
3295
  z17.object({
3408
3296
  type: z17.literal("item/delegation/progress"),
3409
3297
  threadId: z17.string(),
3410
3298
  providerThreadId: z17.string(),
3411
3299
  item: threadEventDelegationItemSchema
3412
3300
  }),
3413
- /**
3414
- * Terminal state for a background delegation, carrying the full final item.
3415
- * Dedicated event (instead of the turn-scoped `item/completed`) because it
3416
- * may arrive turns after the `item/started`. Foreground delegations settle
3417
- * through `item/completed`.
3418
- */
3419
3301
  z17.object({
3420
3302
  type: z17.literal("item/delegation/completed"),
3421
3303
  threadId: z17.string(),
@@ -3462,16 +3344,6 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
3462
3344
  providerThreadId: z17.string(),
3463
3345
  rateLimits: providerRateLimitStateSchema
3464
3346
  }),
3465
- /**
3466
- * Plugin-declared thread state (grammar v3): a `"<pluginId>/<name>"` kind
3467
- * beside the core thread-state family (usage, context window, rate limits,
3468
- * model fallback, context cleared). Latest snapshot wins per `kind`: a
3469
- * bridge re-sends the whole state, never a diff, and a consumer keeps one
3470
- * value per kind. The server validated `payload` against the owning
3471
- * plugin's declared `state` schema at ingest; a payload that failed that
3472
- * check was persisted as `provider/unhandled` instead, so every stored row
3473
- * of this type carries a payload its plugin vouched for.
3474
- */
3475
3347
  z17.object({
3476
3348
  type: z17.literal("thread/extensionState/updated"),
3477
3349
  threadId: z17.string(),
@@ -3632,8 +3504,6 @@ var availableModelSchema = z19.object({
3632
3504
  id: z19.string(),
3633
3505
  model: z19.string(),
3634
3506
  displayName: z19.string(),
3635
- /** Provider route used to run this model when it is distinct from the
3636
- * selected agent provider (for example, a model provider nested under Pi). */
3637
3507
  routeProviderId: z19.string().min(1).optional(),
3638
3508
  description: z19.string(),
3639
3509
  supportedReasoningEfforts: z19.array(modelReasoningEffortSchema),
@@ -3647,20 +3517,8 @@ var providerCapabilitiesSchema = z19.object({
3647
3517
  supportsServiceTier: z19.boolean(),
3648
3518
  supportsNativeUserQuestion: z19.boolean(),
3649
3519
  supportsFork: z19.boolean(),
3650
- /**
3651
- * The provider can recreate a session at an earlier point, which is what
3652
- * edit-past-message rewind needs. Separate from `supportsFork`: ACP clones
3653
- * whole sessions (tip-only) and cannot stop at a checkpoint.
3654
- */
3655
3520
  supportsSessionRewind: z19.boolean(),
3656
3521
  permissionModes: z19.array(permissionModeSchema).min(1),
3657
- /**
3658
- * How far one `model/list` answer travels: `"host"` when the bridge answers
3659
- * from account or agent state and ignores the workspace path, so bb probes
3660
- * once per machine; `"workspace"` when project configuration can change the
3661
- * answer. Declared by the provider's plugin — core never infers it from an
3662
- * id.
3663
- */
3664
3522
  modelCatalogScope: providerModelCatalogScopeSchema
3665
3523
  });
3666
3524
  var providerComposerCommandSchema = z19.object({
@@ -3683,17 +3541,11 @@ var providerComposerActionSchema = z19.discriminatedUnion("kind", [
3683
3541
  })
3684
3542
  ]);
3685
3543
  var providerStringsSchema = z19.object({
3686
- /** How to sign in on the host ("Run `claude` on the machine to sign in."). */
3687
3544
  signInHint: z19.string().min(1),
3688
- /** Shown when a session's credentials expired. */
3689
3545
  expiredHint: z19.string().min(1),
3690
- /** Where to install the agent. */
3691
3546
  installUrl: z19.string().min(1),
3692
- /** Brand prefix stripped from model display names ("Claude "). */
3693
3547
  brandPrefix: z19.string().min(1).optional(),
3694
- /** Plan-mode banner copy for providers that declare the `plan` action. */
3695
3548
  planModeCopy: z19.string().min(1).optional(),
3696
- /** Per-theme tint for the provider icon. */
3697
3549
  iconTint: z19.object({ light: z19.string().min(1), dark: z19.string().min(1) }).optional()
3698
3550
  });
3699
3551
  var providerOptionDescriptorSchema = z19.object({
@@ -3711,31 +3563,11 @@ var providerExtensionKindsSchema = z19.record(
3711
3563
  );
3712
3564
  var providerInfoSchema = z19.object({
3713
3565
  id: z19.string(),
3714
- /**
3715
- * The plugin that registered the provider (`bb.providers.register`). The
3716
- * owner of the provider's extension-kind namespace, and the bundle the
3717
- * app loads on the first thread of this provider.
3718
- */
3719
3566
  pluginId: z19.string().min(1),
3720
3567
  displayName: z19.string(),
3721
- /**
3722
- * Declared grouping key shared by related providers (the ACP agents).
3723
- * Absent when the provider declared none. Grouping only.
3724
- */
3725
3568
  family: z19.string().min(1).optional(),
3726
- /**
3727
- * The declared icon, projected by form. A plugin-relative asset path
3728
- * (`icon: "./icons/agent.svg"`) is served by the provider-logo route and
3729
- * arrives here as `logoUrl`; a named host glyph (`icon: "Zap"`) has no
3730
- * bytes to serve and arrives as `icon.glyph`, the same vocabulary an
3731
- * item presentation's `icon` uses. A declaration names at most one form,
3732
- * so at most one of the two is set; `icon` is absent when the declaration
3733
- * named a path or nothing. Clients draw a vendored brand mark first, then
3734
- * `logoUrl`, then `icon.glyph`, then the display name's initial.
3735
- */
3736
3569
  icon: z19.object({ glyph: z19.string().min(1) }).optional(),
3737
3570
  logoUrl: z19.string().min(1).nullable(),
3738
- /** Sessionless maintenance requests the provider's bridge implements. */
3739
3571
  maintenance: z19.object({
3740
3572
  health: z19.boolean(),
3741
3573
  usage: z19.boolean(),
@@ -3744,13 +3576,6 @@ var providerInfoSchema = z19.object({
3744
3576
  capabilities: providerCapabilitiesSchema,
3745
3577
  composerActions: z19.array(providerComposerActionSchema),
3746
3578
  available: z19.boolean(),
3747
- // -------------------------------------------------------------------------
3748
- // Target-state projection (docs/provider-plugin-api.md §1). Optional and
3749
- // unfilled until WS2a projects them from the plugin declaration; absence
3750
- // means "the provider declared none", never a default. The
3751
- // `capabilities.supports*` fields above stay until WS2a stabilizes the
3752
- // surface as one unit.
3753
- // -------------------------------------------------------------------------
3754
3579
  strings: providerStringsSchema.optional(),
3755
3580
  serviceTiers: z19.array(providerOptionDescriptorSchema).optional(),
3756
3581
  reasoningLevels: z19.array(providerOptionDescriptorSchema).optional(),
@@ -4084,16 +3909,10 @@ import { z as z21 } from "zod";
4084
3909
  var normalizedToolCallRequestSchema = z21.object({
4085
3910
  providerThreadId: z21.string().min(1),
4086
3911
  threadId: z21.string().min(1).optional(),
4087
- // Canonical bridge wire form: required string when known, required null when
4088
- // the provider cannot resolve the BB turn id itself.
4089
3912
  turnId: z21.union([z21.string().min(1), z21.null()]),
4090
3913
  callId: z21.string().min(1),
4091
3914
  tool: z21.string().min(1),
4092
3915
  arguments: z21.unknown(),
4093
- /**
4094
- * turnId/callId are provider-native (thread/delta bridges hold no bb ids);
4095
- * the runtime adapter translates them through the delta assembler's maps.
4096
- */
4097
3916
  providerNativeIds: z21.boolean().optional()
4098
3917
  });
4099
3918
 
@@ -4114,17 +3933,11 @@ import { z as z23 } from "zod";
4114
3933
  // ../provider-bridge-protocol/src/errors.ts
4115
3934
  import { z as z22 } from "zod";
4116
3935
  var BRIDGE_JSON_RPC_ERRORS = {
4117
- /** Standard JSON-RPC: params failed schema validation. */
4118
3936
  INVALID_PARAMS: -32602,
4119
- /** Standard JSON-RPC: method not implemented by this bridge. */
4120
3937
  METHOD_NOT_FOUND: -32601,
4121
- /** Generic bridge failure. */
4122
3938
  BRIDGE_ERROR: -32e3,
4123
- /** A turn/steer arrived but the session has no active turn. */
4124
3939
  NO_ACTIVE_TURN: -32001,
4125
- /** thread/resume for a session the provider can no longer restore. */
4126
3940
  SESSION_NOT_RESTORABLE: -32002,
4127
- /** thread/fork with a checkpoint on a bridge that only forks at the tip. */
4128
3941
  FORK_CHECKPOINT_UNSUPPORTED: -32003
4129
3942
  };
4130
3943
  var providerRecoveryHintSchema = z22.object({
@@ -4164,88 +3977,22 @@ var bridgeGrammarVersionsSchema = z24.tuple([z24.number().int().positive(), z24.
4164
3977
  });
4165
3978
  var bridgeSteerModeSchema = z24.enum(["inject", "queue"]);
4166
3979
  var bridgeCapabilitiesSchema = z24.object({
4167
- /**
4168
- * A released session can be re-attached later from its persisted
4169
- * providerThreadId. The per-session `sessionRestorable` flag on
4170
- * thread-identity results refines this (an agent update can drop restore
4171
- * support mid-flight); this handshake value is the default for sessions
4172
- * that do not say.
4173
- */
4174
3980
  sessionRestore: z24.boolean().default(false),
4175
- /**
4176
- * The bridge mirrors bb archive state into the provider's own session
4177
- * list. When false the runtime never sends thread/archive or
4178
- * thread/unarchive.
4179
- */
4180
3981
  threadArchive: z24.boolean().default(false),
4181
- /**
4182
- * The bridge pushes bb thread titles to the provider. When false the
4183
- * runtime never sends thread/name/set.
4184
- */
4185
3982
  threadRename: z24.boolean().default(false),
4186
- /** The bridge supports thread/goal/clear. */
4187
3983
  threadGoalClear: z24.boolean().default(false),
4188
- /**
4189
- * Session cloning support ({@link providerForkSchema} — the same
4190
- * vocabulary the provider declaration uses). The declaration is a ceiling
4191
- * for UI affordances; this is the operative truth, and it may only narrow
4192
- * the declaration, never widen it.
4193
- */
4194
3984
  fork: providerForkSchema.default("none"),
4195
- /**
4196
- * Where the thread's approval policy is enforced. "runtime" bridges
4197
- * forward every approval request and the runtime applies the thread
4198
- * policy (including auto-deny). "provider" bridges enforce policy before
4199
- * forwarding, so every forwarded request is already known to need user
4200
- * input and the runtime must not reclassify it against mutable thread
4201
- * settings.
4202
- */
4203
3985
  approvalEnforcedBy: z24.enum(["runtime", "provider"]).default("runtime"),
4204
- /**
4205
- * The `thread/delta` grammar range this bridge speaks. A bridge that says
4206
- * nothing is read as speaking exactly the protocol version it negotiated,
4207
- * so the default is `[2, 2]` — never a wider range it never claimed.
4208
- * Every bridge in this repo emits v3 and reports `[3, 3]`, and the
4209
- * runtime's assembler speaks `[3, 3]` only (`ASSEMBLER_GRAMMAR_VERSIONS`),
4210
- * so a bridge that takes the default is refused at startup: the two
4211
- * ranges must intersect ({@link negotiateGrammarVersion}) and both sides
4212
- * emit the highest common version.
4213
- */
4214
3986
  grammarVersions: bridgeGrammarVersionsSchema.default([
4215
3987
  PROVIDER_BRIDGE_PROTOCOL_VERSION,
4216
3988
  PROVIDER_BRIDGE_PROTOCOL_VERSION
4217
3989
  ]),
4218
- /**
4219
- * Mid-turn steer delivery ({@link bridgeSteerModeSchema}). Defaults to
4220
- * `queue`, the conservative reading: absence is the definite "no" the
4221
- * rest of this handshake uses, and `inject` is the stronger promise (the
4222
- * steer reaches the model before the turn ends) a bridge must make
4223
- * explicitly. Nothing in the runtime, server, or clients reads it today:
4224
- * `turn/steer` is sent either way, and a steer whose turn is gone is
4225
- * dropped on the bridge's `staleTurn` recovery hint or `NO_ACTIVE_TURN`
4226
- * error (`steerTurn` in @bb/agent-runtime), whatever the mode. claude,
4227
- * codex, and pi declare `inject`; ACP and the echo example declare
4228
- * `queue`.
4229
- */
4230
3990
  steerMode: bridgeSteerModeSchema.default("queue"),
4231
- /**
4232
- * Which optional requests the bridge handles. `skills.configure`: the
4233
- * bridge accepts `skills/configure` (bb's injected skill roots). When
4234
- * false the runtime never sends it, so a bridge that answers unknown
4235
- * methods with METHOD_NOT_FOUND — as the protocol instructs — still
4236
- * starts threads; it simply runs without injected skills. A bridge that
4237
- * handles the request declares it; the runtime never probes.
4238
- */
4239
3991
  skills: z24.object({ configure: z24.boolean().default(false) }).default({ configure: false })
4240
3992
  }).passthrough();
4241
3993
  var initializeParamsSchema = z24.object({
4242
3994
  protocolVersion: z24.number().int().positive(),
4243
3995
  client: z24.object({ name: z24.string().min(1), version: z24.string().min(1) }),
4244
- /**
4245
- * The `thread/delta` grammar range the runtime's assembler accepts (see
4246
- * {@link negotiateGrammarVersion}). A runtime that predates the field
4247
- * reads as speaking exactly its protocol version.
4248
- */
4249
3996
  grammarVersions: bridgeGrammarVersionsSchema.default([
4250
3997
  PROVIDER_BRIDGE_PROTOCOL_VERSION,
4251
3998
  PROVIDER_BRIDGE_PROTOCOL_VERSION
@@ -4253,8 +4000,6 @@ var initializeParamsSchema = z24.object({
4253
4000
  }).passthrough();
4254
4001
  var initializeResultSchema = z24.object({
4255
4002
  protocolVersion: z24.number().int().positive(),
4256
- // An absent capabilities block reads as "no capabilities" via the inner
4257
- // per-field defaults, so older bridges parse to explicit values.
4258
4003
  capabilities: z24.preprocess(
4259
4004
  (value) => value ?? {},
4260
4005
  bridgeCapabilitiesSchema
@@ -4267,16 +4012,9 @@ var bridgeExecutionOptionsSchema = z25.object({
4267
4012
  model: z25.string().min(1).optional(),
4268
4013
  serviceTier: serviceTierSchema.optional(),
4269
4014
  reasoningLevel: reasoningLevelSchema.optional(),
4270
- /**
4271
- * BB prompt mode (`"plan"`), present only when the prompt entered one
4272
- * through the provider's declared composer action. Each bridge maps it
4273
- * onto the agent's native equivalent.
4274
- */
4275
4015
  promptMode: promptModeSchema.optional(),
4276
- /** Frozen for the life of a provider session; applied at construction. */
4277
4016
  instructions: z25.string().optional(),
4278
4017
  envVars: z25.record(z25.string(), z25.string()).optional(),
4279
- /** Provider-scoped session options. Opaque outside the owning bridge. */
4280
4018
  providerOptions: z25.record(z25.string(), z25.unknown()).optional()
4281
4019
  }).and(runtimePermissionPolicySchema);
4282
4020
 
@@ -4287,9 +4025,7 @@ var providerMaintenanceParamsSchema = z26.object({
4287
4025
  cwd: z26.string().min(1).optional(),
4288
4026
  providerOptions: z26.record(z26.string(), z26.unknown()).optional()
4289
4027
  }).passthrough();
4290
- var providerInstallationRequirementSchema = z26.enum([
4291
- "thread_rewind"
4292
- ]);
4028
+ var providerInstallationRequirementSchema = z26.enum(["thread_rewind"]);
4293
4029
  var providerInstallationStatusParamsSchema = providerMaintenanceParamsSchema.extend({
4294
4030
  requirement: providerInstallationRequirementSchema.optional()
4295
4031
  });
@@ -4337,26 +4073,20 @@ var providerUsageSchema = z26.discriminatedUnion("status", [
4337
4073
  accountEmail: z26.string().nullable().default(null)
4338
4074
  }).passthrough()
4339
4075
  ]);
4340
- var providerHealthResultSchema = z26.discriminatedUnion(
4341
- "supported",
4342
- [
4343
- z26.object({ supported: z26.literal(false) }).passthrough(),
4344
- z26.object({
4345
- supported: z26.literal(true),
4346
- health: providerHealthSchema
4347
- }).passthrough()
4348
- ]
4349
- );
4350
- var providerUsageResultSchema = z26.discriminatedUnion(
4351
- "supported",
4352
- [
4353
- z26.object({ supported: z26.literal(false) }).passthrough(),
4354
- z26.object({
4355
- supported: z26.literal(true),
4356
- usage: providerUsageSchema
4357
- }).passthrough()
4358
- ]
4359
- );
4076
+ var providerHealthResultSchema = z26.discriminatedUnion("supported", [
4077
+ z26.object({ supported: z26.literal(false) }).passthrough(),
4078
+ z26.object({
4079
+ supported: z26.literal(true),
4080
+ health: providerHealthSchema
4081
+ }).passthrough()
4082
+ ]);
4083
+ var providerUsageResultSchema = z26.discriminatedUnion("supported", [
4084
+ z26.object({ supported: z26.literal(false) }).passthrough(),
4085
+ z26.object({
4086
+ supported: z26.literal(true),
4087
+ usage: providerUsageSchema
4088
+ }).passthrough()
4089
+ ]);
4360
4090
  var providerInstallationActionKindSchema = z26.enum([
4361
4091
  "install",
4362
4092
  "update"
@@ -4393,28 +4123,34 @@ var providerInstallationCommandSchema = z26.object({
4393
4123
  args: z26.array(z26.string()).max(64),
4394
4124
  displayCommand: z26.string().min(1)
4395
4125
  }).passthrough();
4396
- var providerInstallationVerificationSchema = z26.discriminatedUnion("kind", [
4397
- z26.object({ kind: z26.literal("installed") }).passthrough(),
4398
- z26.object({
4399
- kind: z26.literal("version_changed"),
4400
- previousVersion: z26.string().min(1)
4401
- }).passthrough(),
4402
- z26.object({
4403
- kind: z26.literal("version_at_least"),
4404
- version: z26.string().min(1)
4405
- }).passthrough()
4406
- ]);
4407
- var providerInstallationRunResultSchema = z26.discriminatedUnion("available", [
4408
- z26.object({
4409
- available: z26.literal(false),
4410
- message: z26.string().min(1)
4411
- }).passthrough(),
4412
- z26.object({
4413
- available: z26.literal(true),
4414
- command: providerInstallationCommandSchema,
4415
- verification: providerInstallationVerificationSchema
4416
- }).passthrough()
4417
- ]);
4126
+ var providerInstallationVerificationSchema = z26.discriminatedUnion(
4127
+ "kind",
4128
+ [
4129
+ z26.object({ kind: z26.literal("installed") }).passthrough(),
4130
+ z26.object({
4131
+ kind: z26.literal("version_changed"),
4132
+ previousVersion: z26.string().min(1)
4133
+ }).passthrough(),
4134
+ z26.object({
4135
+ kind: z26.literal("version_at_least"),
4136
+ version: z26.string().min(1)
4137
+ }).passthrough()
4138
+ ]
4139
+ );
4140
+ var providerInstallationRunResultSchema = z26.discriminatedUnion(
4141
+ "available",
4142
+ [
4143
+ z26.object({
4144
+ available: z26.literal(false),
4145
+ message: z26.string().min(1)
4146
+ }).passthrough(),
4147
+ z26.object({
4148
+ available: z26.literal(true),
4149
+ command: providerInstallationCommandSchema,
4150
+ verification: providerInstallationVerificationSchema
4151
+ }).passthrough()
4152
+ ]
4153
+ );
4418
4154
 
4419
4155
  // ../provider-bridge-protocol/src/requests.ts
4420
4156
  import { z as z27 } from "zod";
@@ -4458,24 +4194,12 @@ var threadResumeParamsSchema = z27.object({
4458
4194
  var threadForkParamsSchema = z27.object({
4459
4195
  ...sessionConstructionFields,
4460
4196
  sourceProviderThreadId: z27.string().min(1),
4461
- /**
4462
- * Absent means fork at the tip. Bridges whose handshake advertises
4463
- * `fork: "tip"` reject a request carrying a checkpoint instead of
4464
- * silently cloning more history than the bb timeline shows.
4465
- */
4466
4197
  sourceProviderCheckpointId: z27.string().min(1).optional()
4467
4198
  }).passthrough();
4468
4199
  var threadStopParamsSchema = z27.object({
4469
4200
  threadId: z27.string().min(1),
4470
4201
  providerThreadId: z27.string().min(1),
4471
- /**
4472
- * "interrupt" stops an active turn and settles it as interrupted.
4473
- * "release" detaches an idle session so its resources can be reclaimed;
4474
- * it must never fabricate an interruption. One verb serving both intents
4475
- * is the #1584 incident — the field is required.
4476
- */
4477
4202
  intent: z27.enum(["interrupt", "release"]),
4478
- /** Non-null when the stop interrupts an active provider turn. */
4479
4203
  activeTurnId: z27.string().min(1).nullable()
4480
4204
  }).passthrough();
4481
4205
  var threadRefParams = z27.object({
@@ -4518,7 +4242,6 @@ var skillsConfigureParamsSchema = z27.object({
4518
4242
  }).passthrough();
4519
4243
  var threadIdentityResultSchema = z27.object({
4520
4244
  providerThreadId: z27.string().min(1),
4521
- /** Refines the handshake's `sessionRestore` for this session. */
4522
4245
  sessionRestorable: z27.boolean().optional()
4523
4246
  }).passthrough();
4524
4247
  var modelListResultSchema = z27.object({
@@ -4538,16 +4261,12 @@ var BRIDGE_NOTIFICATION_METHODS = {
4538
4261
  var threadIdentityNotificationSchema = z28.object({
4539
4262
  threadId: z28.string().min(1),
4540
4263
  providerThreadId: z28.string().min(1),
4541
- /** Refines the handshake's `sessionRestore` for this session. */
4542
4264
  sessionRestorable: z28.boolean().optional()
4543
4265
  }).passthrough();
4544
4266
  var sessionReplacedNotificationSchema = z28.object({
4545
4267
  threadId: z28.string().min(1),
4546
- /** Identity of the replacement session (may equal the old identity). */
4547
4268
  providerThreadId: z28.string().min(1).nullable(),
4548
- /** Human-readable cause, shown in the timeline. */
4549
4269
  reason: z28.string().min(1),
4550
- /** True when provider-side context did not survive the replacement. */
4551
4270
  contextLost: z28.boolean().default(false)
4552
4271
  }).passthrough();
4553
4272
  var providerRawNotificationSchema = z28.object({
@@ -4595,14 +4314,6 @@ var interactionRequestParamsSchema = z29.object({
4595
4314
  threadId: z29.string().min(1).optional(),
4596
4315
  turnId: z29.union([z29.string().min(1), z29.null()]),
4597
4316
  payload: pendingInteractionPayloadSchema,
4598
- /**
4599
- * The request's turn id and approval-subject item ids are in the
4600
- * provider's native id space (a `thread/delta` bridge holds no bb ids):
4601
- * the runtime adapter translates them through the delta assembler's maps
4602
- * before the interaction reaches the app. Omission means the ids are
4603
- * already app-visible (bridges whose approval subjects never referenced
4604
- * timeline ids — ACP's approval ids never matched timeline ids).
4605
- */
4606
4317
  providerNativeIds: z29.boolean().optional()
4607
4318
  }).passthrough();
4608
4319
 
@@ -4622,24 +4333,14 @@ var deltaItemKeySchema = z30.object({
4622
4333
  var providerTurnIdSchema = deltaKeyPartSchema;
4623
4334
  var deltaFileChangeSchema = z30.object({
4624
4335
  path: z30.string(),
4625
- /** The bridge states the change kind; the assembler never derives it. */
4626
4336
  kind: z30.enum(["add", "update", "delete"]),
4627
4337
  movePath: z30.string().optional(),
4628
- /** Provider-supplied unified diff; preferred over old/new text building. */
4629
4338
  diff: z30.string().optional(),
4630
4339
  oldText: z30.string().optional(),
4631
- /** When present the assembler builds the unified diff from old/new text. */
4632
4340
  newText: z30.string().optional()
4633
4341
  });
4634
4342
  var deltaBackgroundTaskShapeSchema = z30.object({
4635
4343
  type: z30.literal("backgroundTask"),
4636
- /**
4637
- * The provider's stable task id, shared by every generation (restart) of
4638
- * the same task. Rides through to the canonical item so consumers can
4639
- * correlate a restarted task with its earlier generations — the assembler
4640
- * mints fresh item ids per generation, so identity must travel as data,
4641
- * never as id text.
4642
- */
4643
4344
  familyId: z30.string().min(1),
4644
4345
  taskType: z30.string(),
4645
4346
  description: z30.string(),
@@ -4693,20 +4394,8 @@ var deltaItemShapeSchema = z30.discriminatedUnion("type", [
4693
4394
  }),
4694
4395
  z30.object({
4695
4396
  type: z30.literal("fileChange"),
4696
- /** Empty while a path is not yet known, including bare close fallbacks. */
4697
4397
  changes: z30.array(deltaFileChangeSchema)
4698
4398
  }),
4699
- /**
4700
- * The generic tool call: the escape hatch for tools with no core kind. In
4701
- * grammar v3 the bridge says how the row reads through the delta's
4702
- * `presentation` (label, icon, suppression) instead of core keeping a
4703
- * tool-name table. A `tool` item without presentation is read as legacy
4704
- * data: `@bb/domain`'s `upgradeLegacyToolItem` reshapes read/grep/glob/
4705
- * find/ls by name and suppresses the Task- and Todo-family bookkeeping
4706
- * calls when the stored row is parsed, and any other name renders with
4707
- * the generic tool row — until the backfill migration, after which
4708
- * `presentation` is required.
4709
- */
4710
4399
  z30.object({
4711
4400
  type: z30.literal("tool"),
4712
4401
  tool: z30.string(),
@@ -4736,7 +4425,6 @@ var deltaItemShapeSchema = z30.discriminatedUnion("type", [
4736
4425
  }),
4737
4426
  z30.object({ type: z30.literal("imageView"), path: z30.string() }),
4738
4427
  deltaBackgroundTaskShapeSchema,
4739
- // Grammar v3 shapes. Every existing shape above is kept unchanged.
4740
4428
  deltaFileReadShapeSchema,
4741
4429
  deltaSearchShapeSchema,
4742
4430
  deltaDelegationShapeSchema,
@@ -4770,51 +4458,21 @@ function requireExtensionPresentation(delta, ctx) {
4770
4458
  }
4771
4459
  }
4772
4460
  var threadDeltaSchema = z30.discriminatedUnion("kind", [
4773
- /**
4774
- * The provider consumed an input (immediate or steered). The assembler owns
4775
- * the queue-until-turn-opens behavior and the terminal-turn invariant.
4776
- * With `providerTurnId` the acceptance is emitted against that vouched turn
4777
- * directly (codex correlates acceptance to a named native turn).
4778
- */
4779
4461
  z30.object({
4780
4462
  kind: z30.literal("input.accepted"),
4781
4463
  clientRequestId: clientTurnRequestIdSchema,
4782
4464
  providerTurnId: providerTurnIdSchema.optional()
4783
4465
  }),
4784
- /**
4785
- * Input the provider itself injected into the conversation, with no bb
4786
- * client request behind it (a pi extension's `sendMessage` custom message
4787
- * that triggered or steered a turn). The assembler records it as a
4788
- * `userMessage` item in the open turn so the transcript shows what the
4789
- * model was answering. Dropped silently when no turn is open: the provider
4790
- * appended it to its own context without running the agent, so there is no
4791
- * bb turn to attach it to.
4792
- */
4793
4466
  z30.object({
4794
4467
  kind: z30.literal("input.provider"),
4795
4468
  text: z30.string().min(1),
4796
4469
  parentRef: deltaKeyPartSchema.optional()
4797
4470
  }),
4798
- /**
4799
- * An explicit provider signal opened work (pi `agent_start`, codex
4800
- * `turn/started`). With `providerTurnId` the turn lives in the keyed
4801
- * provider-turn space: several may be open at once (codex multiplexes
4802
- * subagent child turns onto one thread) and none of the current-turn
4803
- * machinery is touched.
4804
- */
4805
4471
  z30.object({
4806
4472
  kind: z30.literal("turn.open"),
4807
4473
  providerTurnId: providerTurnIdSchema.optional(),
4808
- /** Provider-native parent tool-call id for delegated child turns. */
4809
4474
  parentRef: deltaKeyPartSchema.optional()
4810
4475
  }),
4811
- /**
4812
- * The bridge's conclusion that the turn settled. `claimIfIdle: true` marks
4813
- * fallback closers that own a turn only if accepted input is pending
4814
- * (the old bridge-kit terminal-turn rule, applied centrally); an open turn is
4815
- * always settled. A keyed boundary (`providerTurnId`) always emits — the
4816
- * provider named the turn — and settles only that turn.
4817
- */
4818
4476
  z30.object({
4819
4477
  kind: z30.literal("turn.boundary"),
4820
4478
  status: threadEventTurnStatusSchema,
@@ -4823,40 +4481,15 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4823
4481
  claimIfIdle: z30.boolean().optional(),
4824
4482
  providerTurnId: providerTurnIdSchema.optional()
4825
4483
  }),
4826
- /**
4827
- * A parsed item opened. `attach: "currentOrLast"` pins the item to the turn
4828
- * that is open or just closed without opening a new one (pi threshold
4829
- * compaction); the default attaches to the open turn only. A known
4830
- * `providerItemId` reuses its minted bb id (an explicit open reopens the
4831
- * same item, codex's settle/reopen rule).
4832
- */
4833
4484
  z30.object({
4834
4485
  kind: z30.literal("item.open"),
4835
4486
  key: deltaItemKeySchema,
4836
4487
  item: deltaItemShapeSchema,
4837
- /**
4838
- * Grammar v3: how the row reads, persisted with the opened item. The
4839
- * one place presentation travels. Optional for core shapes while v2
4840
- * deltas are accepted; REQUIRED for `extension` shapes.
4841
- */
4842
4488
  presentation: deltaPresentationSchema.optional(),
4843
4489
  attach: deltaAttachSchema.optional(),
4844
4490
  providerTurnId: providerTurnIdSchema.optional(),
4845
4491
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4846
4492
  }).superRefine(requireExtensionPresentation),
4847
- /**
4848
- * The item settled. `item` is REQUIRED and always carries the full terminal
4849
- * item shape (Michael's uniform close rule, 2026-08-18): the assembler
4850
- * builds the completed item from it. With a same-shaped item open under the
4851
- * key, the terminal shape wins and the opened item contributes only its
4852
- * minted id; with a different-shaped item open, the assembler closes the
4853
- * opened shape and then emits the terminal shape (ACP's dual-complete);
4854
- * with nothing open it builds the bare completed item.
4855
- *
4856
- * Provider-identified closes (`key.providerItemId`) dedup: a repeated close
4857
- * for a settled id is dropped and an explicit `item.open` reopens the id
4858
- * (codex retries the terminal notification after approvals).
4859
- */
4860
4493
  z30.object({
4861
4494
  kind: z30.literal("item.close"),
4862
4495
  key: deltaItemKeySchema,
@@ -4864,32 +4497,12 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4864
4497
  resultText: z30.string().optional(),
4865
4498
  exitCode: z30.number().optional(),
4866
4499
  aggregatedOutput: z30.string().optional(),
4867
- /** Terminal approval verdict (codex declined → denied). Default null. */
4868
4500
  approvalStatus: z30.literal("denied").optional(),
4869
4501
  item: deltaItemShapeSchema,
4870
- /**
4871
- * Grammar v3: the terminal presentation. Like `item`, the close carries
4872
- * the full terminal form; when absent the opened item's presentation
4873
- * survives onto the completed item (close-echo). REQUIRED for an
4874
- * `extension` shape, which has nothing to echo without it.
4875
- */
4876
4502
  presentation: deltaPresentationSchema.optional(),
4877
4503
  providerTurnId: providerTurnIdSchema.optional(),
4878
4504
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4879
4505
  }).superRefine(requireExtensionPresentation),
4880
- /**
4881
- * Free-form progress on an open item (non-command tool updates), or — with
4882
- * `snapshot` — a re-embedded snapshot of work that outlives its turn: a
4883
- * background task (`item/backgroundTask/progress`) or, in grammar v3, a
4884
- * background delegation (`item/delegation/progress`); both thread-scoped,
4885
- * no turn required.
4886
- *
4887
- * Progress is throttled centrally by the assembler (one emission per item
4888
- * key per policy interval, 500ms default; the newest suppressed snapshot is
4889
- * flushed trailing-edge on the thread's next traffic once the window
4890
- * elapses, and an `item.close` supersedes it). `flush: true` bypasses the
4891
- * throttle and resets the window — status transitions must land immediately.
4892
- */
4893
4506
  z30.object({
4894
4507
  kind: z30.literal("item.progress"),
4895
4508
  key: deltaItemKeySchema,
@@ -4899,17 +4512,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4899
4512
  providerTurnId: providerTurnIdSchema.optional(),
4900
4513
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4901
4514
  }),
4902
- /**
4903
- * Streamed text — the one streaming dialect. Every text stream is keyed
4904
- * like every other item: by the provider's own item id when the provider
4905
- * names its message items (codex), or by a bridge-chosen `key.channel`
4906
- * (`"assistant"`, `"thinking-2"`) plus `key.parentRef` for providers whose
4907
- * streams are anonymous (claude, pi, acp). The first delta for an unknown
4908
- * key synthesizes the channel's `item/started`; later deltas (and deltas
4909
- * for a provider id already opened or settled) reuse the mapped id. The
4910
- * assembler accumulates the stream text per open item so `item.textClose`
4911
- * can settle without a provider-final text.
4912
- */
4913
4515
  z30.object({
4914
4516
  kind: z30.literal("item.textDelta"),
4915
4517
  key: deltaItemKeySchema,
@@ -4918,18 +4520,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4918
4520
  providerTurnId: providerTurnIdSchema.optional(),
4919
4521
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4920
4522
  }),
4921
- /**
4922
- * Settle a text stream. `text` present: the provider's final text, preferred
4923
- * over the accumulated stream (and enough on its own — a close for a key
4924
- * nothing streamed under completes a fresh item). `text` absent: settle
4925
- * with the accumulated stream text, completing nothing when the stream only
4926
- * ever received whitespace. Either way the key is released, so later text
4927
- * mints a fresh item. `channel` says which item to mint for a bare close
4928
- * and where a provider-final `text` lands on a reasoning item. Providers
4929
- * that name their message items may instead settle through `item.close`
4930
- * with the full terminal shape (the uniform close rule) — that is the same
4931
- * item lifecycle, not a second streaming dialect.
4932
- */
4933
4523
  z30.object({
4934
4524
  kind: z30.literal("item.textClose"),
4935
4525
  key: deltaItemKeySchema,
@@ -4938,10 +4528,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4938
4528
  providerTurnId: providerTurnIdSchema.optional(),
4939
4529
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4940
4530
  }),
4941
- /**
4942
- * Item-keyed exact output append (codex command/fileChange output deltas).
4943
- * Never synthesizes an open and never diffs — the text is already a delta.
4944
- */
4945
4531
  z30.object({
4946
4532
  kind: z30.literal("item.outputDelta"),
4947
4533
  key: deltaItemKeySchema,
@@ -4950,26 +4536,12 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4950
4536
  providerTurnId: providerTurnIdSchema.optional(),
4951
4537
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4952
4538
  }),
4953
- /**
4954
- * Cumulative command output snapshot (pi bash). The assembler diffs
4955
- * consecutive snapshots into `outputDelta`/`reset` events.
4956
- */
4957
4539
  z30.object({
4958
4540
  kind: z30.literal("command.outputSnapshot"),
4959
4541
  key: deltaItemKeySchema,
4960
4542
  text: z30.string(),
4961
4543
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4962
4544
  }),
4963
- /**
4964
- * Provider-reported usage — the one usage dialect. `total` is the running
4965
- * session total and `last` the most recent turn's usage; a provider that
4966
- * reports exact cumulative totals (codex) forwards both verbatim, and a
4967
- * provider that reports per-turn usage (claude, pi) sums `last` into
4968
- * `total` itself (`addTokenUsage` in the bridge kit), resetting at every
4969
- * session construction alongside `session.reset`. Emits
4970
- * `thread/tokenUsage/updated` only: a provider whose usage also measures
4971
- * the context window sends the `contextWindow` delta beside it.
4972
- */
4973
4545
  z30.object({
4974
4546
  kind: z30.literal("usage"),
4975
4547
  total: threadEventTokenUsageBreakdownSchema,
@@ -4977,13 +4549,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4977
4549
  modelContextWindow: z30.number().nullable(),
4978
4550
  providerTurnId: providerTurnIdSchema.optional()
4979
4551
  }),
4980
- /**
4981
- * Context-window meter. `attach: "currentOrLast"` legalizes post-turn
4982
- * attachment (pi reports after `agent_end` for the turn that just closed);
4983
- * a `providerTurnId` scopes the reading to that vouched turn instead
4984
- * (codex measures the window per native turn) and `attach` is then
4985
- * irrelevant.
4986
- */
4987
4552
  z30.object({
4988
4553
  kind: z30.literal("contextWindow"),
4989
4554
  used: z30.number().nullable(),
@@ -4998,54 +4563,26 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
4998
4563
  noTurnFallback: deltaNoTurnFallbackSchema.optional()
4999
4564
  }),
5000
4565
  z30.object({ kind: z30.literal("context.cleared") }),
5001
- /** The aggregate working-tree diff for a turn (codex turn/diff/updated). */
5002
4566
  z30.object({
5003
4567
  kind: z30.literal("turn.diff"),
5004
4568
  diff: z30.string(),
5005
4569
  providerTurnId: providerTurnIdSchema.optional()
5006
4570
  }),
5007
- // Thread metadata (codex thread lifecycle notifications).
5008
4571
  z30.object({ kind: z30.literal("thread.started") }),
5009
4572
  z30.object({
5010
4573
  kind: z30.literal("thread.identity"),
5011
4574
  providerThreadId: z30.string().min(1)
5012
4575
  }),
5013
4576
  z30.object({ kind: z30.literal("thread.name"), name: z30.string().min(1) }),
5014
- /**
5015
- * Plugin-declared thread state (grammar v3): `"<pluginId>/<name>"` kinds
5016
- * beside the core thread-state family (usage, context window, rate limits,
5017
- * model fallback, context cleared). Latest snapshot wins per kind — the
5018
- * assembler and the timeline keep one value per `kind`, so a bridge re-sends
5019
- * the whole state, never a diff. Codex goals ride this way (the codex
5020
- * plugin's `provider-codex/goal`, a null payload once cleared). The payload
5021
- * is opaque here; the server validates it against the plugin's declared
5022
- * `state` schema at ingest (the same site as extension items).
5023
- * The namespaced kind travels as `extensionKind` only because `kind` is
5024
- * this union's discriminator; the item shape and the persisted item call
5025
- * the same value `kind`.
5026
- */
5027
4577
  z30.object({
5028
4578
  kind: z30.literal("extension.state"),
5029
4579
  extensionKind: extensionKindSchema,
5030
4580
  payload: jsonValueSchema
5031
4581
  }),
5032
- /**
5033
- * Normalized rate-limit snapshot. The provider-dialect merge (codex's
5034
- * sticky rateLimitReachedType over sparse rolling updates) stays
5035
- * bridge-side — it is seeded from a per-child post-initialize read the
5036
- * assembler never sees.
5037
- */
5038
4582
  z30.object({
5039
4583
  kind: z30.literal("provider.rateLimits"),
5040
4584
  rateLimits: providerRateLimitStateSchema
5041
4585
  }),
5042
- /**
5043
- * Provider-reported error. `settlesTurn: true` also closes the turn that
5044
- * owns the error as failed (an open turn, or one claimed through pending
5045
- * accepted input). A `providerTurnId` scopes the error to that vouched
5046
- * turn; `threadScoped: true` pins thread scope (codex errors without a
5047
- * native turn id never attach to whatever turn happens to be open).
5048
- */
5049
4586
  z30.object({
5050
4587
  kind: z30.literal("provider.error"),
5051
4588
  message: z30.string(),
@@ -5057,13 +4594,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
5057
4594
  providerTurnId: providerTurnIdSchema.optional(),
5058
4595
  threadScoped: z30.boolean().optional()
5059
4596
  }),
5060
- /**
5061
- * The provider switched models mid-flight (claude model fallback). Scoped to
5062
- * the open-or-just-closed turn when one exists, thread scope otherwise (the
5063
- * claude translator's currentOrLast rule). Cross-message dedup of the early
5064
- * assistant fallback block against the later system duplicate stays
5065
- * bridge-side — it is keyed by the bridge's own segment tracking.
5066
- */
5067
4597
  z30.object({
5068
4598
  kind: z30.literal("provider.modelFallback"),
5069
4599
  originalModel: z30.string().min(1),
@@ -5071,10 +4601,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
5071
4601
  reason: z30.enum(["refusal", "provider"]),
5072
4602
  message: z30.string()
5073
4603
  }),
5074
- /**
5075
- * `vouchedTurn: true` scopes the warning to the open turn when one exists
5076
- * (ACP warnings are turn-scoped mid-turn); default is thread scope.
5077
- */
5078
4604
  z30.object({
5079
4605
  kind: z30.literal("provider.warning"),
5080
4606
  summary: z30.string().optional(),
@@ -5082,15 +4608,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
5082
4608
  category: threadEventWarningCategorySchema.optional(),
5083
4609
  vouchedTurn: z30.boolean().optional()
5084
4610
  }),
5085
- /**
5086
- * The bridge's visibility classification decided this raw event is unknown.
5087
- * `vouchedTurn: true` scopes it to the open turn if one exists — the
5088
- * only-caller-vouched-turn-ids rule — and `providerTurnId` scopes it to
5089
- * that vouched provider turn. `onlyIfNoTurn: true` inverts the guard: the
5090
- * event surfaces only when NO turn is open (the old translators'
5091
- * "known event, no active turn" visibility fallback for events that
5092
- * otherwise translate to silence) and is dropped entirely mid-turn.
5093
- */
5094
4611
  z30.object({
5095
4612
  kind: z30.literal("unhandled"),
5096
4613
  raw: providerRawEventSchema,
@@ -5100,18 +4617,7 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
5100
4617
  parentRef: deltaKeyPartSchema.optional(),
5101
4618
  providerTurnId: providerTurnIdSchema.optional()
5102
4619
  }),
5103
- /**
5104
- * Lifecycle settlement: the session was interrupted. The assembler closes
5105
- * the open turn and open items as interrupted.
5106
- */
5107
4620
  z30.object({ kind: z30.literal("session.ended") }),
5108
- /**
5109
- * Provider-native id-space boundary: a new provider session was constructed
5110
- * for this thread (start/resume/fork/rebuild), so its native turn/item ids
5111
- * may repeat. Drops ALL assembly state for the thread — id maps, settled
5112
- * sets, open items and streams; the bridge settles any open work first
5113
- * (nothing is in flight at any construction site).
5114
- */
5115
4621
  z30.object({ kind: z30.literal("session.reset") })
5116
4622
  ]);
5117
4623
  var threadDeltaNotificationParamsSchema = z30.object({