@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
package/dist/provider-bridge.js
CHANGED
|
@@ -740,7 +740,10 @@ var BridgeRecoveryError = class extends Error {
|
|
|
740
740
|
code;
|
|
741
741
|
recovery;
|
|
742
742
|
constructor(args) {
|
|
743
|
-
super(
|
|
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(
|
|
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({
|
|
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({
|
|
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,8 +2569,6 @@ 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(
|
|
@@ -2665,11 +2612,6 @@ var systemProviderTurnWatchdogEventDataSchema = z14.object({
|
|
|
2665
2612
|
activeTurnId: z14.string().min(1),
|
|
2666
2613
|
activeTurnStartedAt: z14.number().int().nonnegative(),
|
|
2667
2614
|
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
2615
|
lastActivityEventType: z14.string().min(1),
|
|
2674
2616
|
lastActivityEventAt: z14.number().int().nonnegative(),
|
|
2675
2617
|
providerId: z14.string().min(1),
|
|
@@ -2932,7 +2874,6 @@ var providerRateLimitStatusSchema = z17.enum([
|
|
|
2932
2874
|
"unknown"
|
|
2933
2875
|
]);
|
|
2934
2876
|
var providerRateLimitWindowSchema = z17.object({
|
|
2935
|
-
/** Opaque provider-issued key. New provider windows must not break parsing. */
|
|
2936
2877
|
providerKey: z17.string().min(1).nullable(),
|
|
2937
2878
|
label: z17.string().min(1).nullable(),
|
|
2938
2879
|
status: providerRateLimitStatusSchema,
|
|
@@ -3017,11 +2958,9 @@ var threadEventDelegationItemSchema = z17.object({
|
|
|
3017
2958
|
type: z17.literal("delegation"),
|
|
3018
2959
|
id: z17.string(),
|
|
3019
2960
|
childRef: z17.string().min(1),
|
|
3020
|
-
/** Human label for the delegated work (the child's description). */
|
|
3021
2961
|
label: z17.string(),
|
|
3022
2962
|
status: threadEventItemStatusSchema,
|
|
3023
2963
|
background: z17.boolean(),
|
|
3024
|
-
/** Terminal summary from the child; absent while it runs. */
|
|
3025
2964
|
summary: z17.string().optional(),
|
|
3026
2965
|
...itemPresentationField,
|
|
3027
2966
|
parentToolCallId: z17.string().optional()
|
|
@@ -3082,10 +3021,6 @@ var threadEventWarningCategorySchema = z17.enum([
|
|
|
3082
3021
|
"deprecation",
|
|
3083
3022
|
"config",
|
|
3084
3023
|
"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
3024
|
"compaction-skipped"
|
|
3090
3025
|
]);
|
|
3091
3026
|
var providerRawEventSchema = z17.object({
|
|
@@ -3114,28 +3049,15 @@ var toolCallProgressEventSchema = z17.object({
|
|
|
3114
3049
|
var threadEventBackgroundTaskItemSchema = z17.object({
|
|
3115
3050
|
type: z17.literal("backgroundTask"),
|
|
3116
3051
|
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
3052
|
familyId: z17.string().optional(),
|
|
3125
|
-
/** Raw SDK task discriminant (e.g. "local_workflow"); "unknown" when the provider omitted it. */
|
|
3126
3053
|
taskType: z17.string(),
|
|
3127
3054
|
description: z17.string(),
|
|
3128
3055
|
status: threadEventItemStatusSchema,
|
|
3129
3056
|
taskStatus: backgroundTaskStatusSchema,
|
|
3130
|
-
/** Ambient/housekeeping task; consumers hide it from the inline transcript. */
|
|
3131
3057
|
skipTranscript: z17.boolean(),
|
|
3132
|
-
/** meta.name of the workflow script; only present for workflow tasks. */
|
|
3133
3058
|
workflowName: z17.string().optional(),
|
|
3134
|
-
/** Merged workflow tree; absent until the provider reports progress records. */
|
|
3135
3059
|
workflow: workflowProgressSnapshotSchema.optional(),
|
|
3136
|
-
/** Absent until the provider reports usage. */
|
|
3137
3060
|
usage: backgroundTaskUsageSchema.optional(),
|
|
3138
|
-
/** Terminal summary from the provider; absent while the task runs. */
|
|
3139
3061
|
summary: z17.string().optional(),
|
|
3140
3062
|
error: z17.string().optional(),
|
|
3141
3063
|
outputFile: z17.string().optional(),
|
|
@@ -3143,7 +3065,6 @@ var threadEventBackgroundTaskItemSchema = z17.object({
|
|
|
3143
3065
|
parentToolCallId: z17.string().optional()
|
|
3144
3066
|
});
|
|
3145
3067
|
var threadEventItemSchema = z17.discriminatedUnion("type", [
|
|
3146
|
-
// bb authors user messages itself, so they carry no bridge presentation.
|
|
3147
3068
|
z17.object({
|
|
3148
3069
|
type: z17.literal("userMessage"),
|
|
3149
3070
|
id: z17.string(),
|
|
@@ -3165,10 +3086,6 @@ var threadEventItemSchema = z17.discriminatedUnion("type", [
|
|
|
3165
3086
|
cwd: z17.string(),
|
|
3166
3087
|
status: threadEventItemStatusSchema,
|
|
3167
3088
|
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
3089
|
aggregatedOutput: z17.string().optional(),
|
|
3173
3090
|
exitCode: z17.number().optional(),
|
|
3174
3091
|
durationMs: z17.number().optional(),
|
|
@@ -3201,10 +3118,6 @@ var threadEventItemSchema = z17.discriminatedUnion("type", [
|
|
|
3201
3118
|
error: z17.string().optional(),
|
|
3202
3119
|
durationMs: z17.number().optional(),
|
|
3203
3120
|
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
3121
|
...itemPresentationField,
|
|
3209
3122
|
parentToolCallId: z17.string().optional()
|
|
3210
3123
|
}),
|
|
@@ -3253,12 +3166,9 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
|
|
|
3253
3166
|
z17.object({
|
|
3254
3167
|
type: z17.literal("turn/completed"),
|
|
3255
3168
|
threadId: z17.string(),
|
|
3256
|
-
// Server reconciliation can synthesize interrupted completions when the
|
|
3257
|
-
// original provider thread id was never persisted.
|
|
3258
3169
|
providerThreadId: z17.string().nullable(),
|
|
3259
3170
|
status: threadEventTurnStatusSchema,
|
|
3260
3171
|
error: z17.object({ message: z17.string() }).optional(),
|
|
3261
|
-
/** Provider-native point through which a replacement branch should retain history. */
|
|
3262
3172
|
providerCheckpointId: z17.string().min(1).optional()
|
|
3263
3173
|
}),
|
|
3264
3174
|
z17.object({
|
|
@@ -3325,10 +3235,6 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
|
|
|
3325
3235
|
providerThreadId: z17.string(),
|
|
3326
3236
|
itemId: z17.string(),
|
|
3327
3237
|
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
3238
|
reset: z17.boolean().optional(),
|
|
3333
3239
|
parentToolCallId: z17.string().optional()
|
|
3334
3240
|
}),
|
|
@@ -3373,49 +3279,24 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
|
|
|
3373
3279
|
parentToolCallId: z17.string().optional()
|
|
3374
3280
|
}),
|
|
3375
3281
|
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
3282
|
z17.object({
|
|
3384
3283
|
type: z17.literal("item/backgroundTask/progress"),
|
|
3385
3284
|
threadId: z17.string(),
|
|
3386
3285
|
providerThreadId: z17.string(),
|
|
3387
3286
|
item: threadEventBackgroundTaskItemSchema
|
|
3388
3287
|
}),
|
|
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
3288
|
z17.object({
|
|
3395
3289
|
type: z17.literal("item/backgroundTask/completed"),
|
|
3396
3290
|
threadId: z17.string(),
|
|
3397
3291
|
providerThreadId: z17.string(),
|
|
3398
3292
|
item: threadEventBackgroundTaskItemSchema
|
|
3399
3293
|
}),
|
|
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
3294
|
z17.object({
|
|
3408
3295
|
type: z17.literal("item/delegation/progress"),
|
|
3409
3296
|
threadId: z17.string(),
|
|
3410
3297
|
providerThreadId: z17.string(),
|
|
3411
3298
|
item: threadEventDelegationItemSchema
|
|
3412
3299
|
}),
|
|
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
3300
|
z17.object({
|
|
3420
3301
|
type: z17.literal("item/delegation/completed"),
|
|
3421
3302
|
threadId: z17.string(),
|
|
@@ -3462,16 +3343,6 @@ var unscopedProviderEventSchema = z17.discriminatedUnion("type", [
|
|
|
3462
3343
|
providerThreadId: z17.string(),
|
|
3463
3344
|
rateLimits: providerRateLimitStateSchema
|
|
3464
3345
|
}),
|
|
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
3346
|
z17.object({
|
|
3476
3347
|
type: z17.literal("thread/extensionState/updated"),
|
|
3477
3348
|
threadId: z17.string(),
|
|
@@ -3632,8 +3503,6 @@ var availableModelSchema = z19.object({
|
|
|
3632
3503
|
id: z19.string(),
|
|
3633
3504
|
model: z19.string(),
|
|
3634
3505
|
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
3506
|
routeProviderId: z19.string().min(1).optional(),
|
|
3638
3507
|
description: z19.string(),
|
|
3639
3508
|
supportedReasoningEfforts: z19.array(modelReasoningEffortSchema),
|
|
@@ -3647,20 +3516,8 @@ var providerCapabilitiesSchema = z19.object({
|
|
|
3647
3516
|
supportsServiceTier: z19.boolean(),
|
|
3648
3517
|
supportsNativeUserQuestion: z19.boolean(),
|
|
3649
3518
|
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
3519
|
supportsSessionRewind: z19.boolean(),
|
|
3656
3520
|
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
3521
|
modelCatalogScope: providerModelCatalogScopeSchema
|
|
3665
3522
|
});
|
|
3666
3523
|
var providerComposerCommandSchema = z19.object({
|
|
@@ -3683,17 +3540,11 @@ var providerComposerActionSchema = z19.discriminatedUnion("kind", [
|
|
|
3683
3540
|
})
|
|
3684
3541
|
]);
|
|
3685
3542
|
var providerStringsSchema = z19.object({
|
|
3686
|
-
/** How to sign in on the host ("Run `claude` on the machine to sign in."). */
|
|
3687
3543
|
signInHint: z19.string().min(1),
|
|
3688
|
-
/** Shown when a session's credentials expired. */
|
|
3689
3544
|
expiredHint: z19.string().min(1),
|
|
3690
|
-
/** Where to install the agent. */
|
|
3691
3545
|
installUrl: z19.string().min(1),
|
|
3692
|
-
/** Brand prefix stripped from model display names ("Claude "). */
|
|
3693
3546
|
brandPrefix: z19.string().min(1).optional(),
|
|
3694
|
-
/** Plan-mode banner copy for providers that declare the `plan` action. */
|
|
3695
3547
|
planModeCopy: z19.string().min(1).optional(),
|
|
3696
|
-
/** Per-theme tint for the provider icon. */
|
|
3697
3548
|
iconTint: z19.object({ light: z19.string().min(1), dark: z19.string().min(1) }).optional()
|
|
3698
3549
|
});
|
|
3699
3550
|
var providerOptionDescriptorSchema = z19.object({
|
|
@@ -3711,31 +3562,11 @@ var providerExtensionKindsSchema = z19.record(
|
|
|
3711
3562
|
);
|
|
3712
3563
|
var providerInfoSchema = z19.object({
|
|
3713
3564
|
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
3565
|
pluginId: z19.string().min(1),
|
|
3720
3566
|
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
3567
|
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
3568
|
icon: z19.object({ glyph: z19.string().min(1) }).optional(),
|
|
3737
3569
|
logoUrl: z19.string().min(1).nullable(),
|
|
3738
|
-
/** Sessionless maintenance requests the provider's bridge implements. */
|
|
3739
3570
|
maintenance: z19.object({
|
|
3740
3571
|
health: z19.boolean(),
|
|
3741
3572
|
usage: z19.boolean(),
|
|
@@ -3744,13 +3575,6 @@ var providerInfoSchema = z19.object({
|
|
|
3744
3575
|
capabilities: providerCapabilitiesSchema,
|
|
3745
3576
|
composerActions: z19.array(providerComposerActionSchema),
|
|
3746
3577
|
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
3578
|
strings: providerStringsSchema.optional(),
|
|
3755
3579
|
serviceTiers: z19.array(providerOptionDescriptorSchema).optional(),
|
|
3756
3580
|
reasoningLevels: z19.array(providerOptionDescriptorSchema).optional(),
|
|
@@ -4084,16 +3908,10 @@ import { z as z21 } from "zod";
|
|
|
4084
3908
|
var normalizedToolCallRequestSchema = z21.object({
|
|
4085
3909
|
providerThreadId: z21.string().min(1),
|
|
4086
3910
|
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
3911
|
turnId: z21.union([z21.string().min(1), z21.null()]),
|
|
4090
3912
|
callId: z21.string().min(1),
|
|
4091
3913
|
tool: z21.string().min(1),
|
|
4092
3914
|
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
3915
|
providerNativeIds: z21.boolean().optional()
|
|
4098
3916
|
});
|
|
4099
3917
|
|
|
@@ -4114,17 +3932,11 @@ import { z as z23 } from "zod";
|
|
|
4114
3932
|
// ../provider-bridge-protocol/src/errors.ts
|
|
4115
3933
|
import { z as z22 } from "zod";
|
|
4116
3934
|
var BRIDGE_JSON_RPC_ERRORS = {
|
|
4117
|
-
/** Standard JSON-RPC: params failed schema validation. */
|
|
4118
3935
|
INVALID_PARAMS: -32602,
|
|
4119
|
-
/** Standard JSON-RPC: method not implemented by this bridge. */
|
|
4120
3936
|
METHOD_NOT_FOUND: -32601,
|
|
4121
|
-
/** Generic bridge failure. */
|
|
4122
3937
|
BRIDGE_ERROR: -32e3,
|
|
4123
|
-
/** A turn/steer arrived but the session has no active turn. */
|
|
4124
3938
|
NO_ACTIVE_TURN: -32001,
|
|
4125
|
-
/** thread/resume for a session the provider can no longer restore. */
|
|
4126
3939
|
SESSION_NOT_RESTORABLE: -32002,
|
|
4127
|
-
/** thread/fork with a checkpoint on a bridge that only forks at the tip. */
|
|
4128
3940
|
FORK_CHECKPOINT_UNSUPPORTED: -32003
|
|
4129
3941
|
};
|
|
4130
3942
|
var providerRecoveryHintSchema = z22.object({
|
|
@@ -4164,88 +3976,22 @@ var bridgeGrammarVersionsSchema = z24.tuple([z24.number().int().positive(), z24.
|
|
|
4164
3976
|
});
|
|
4165
3977
|
var bridgeSteerModeSchema = z24.enum(["inject", "queue"]);
|
|
4166
3978
|
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
3979
|
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
3980
|
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
3981
|
threadRename: z24.boolean().default(false),
|
|
4186
|
-
/** The bridge supports thread/goal/clear. */
|
|
4187
3982
|
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
3983
|
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
3984
|
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
3985
|
grammarVersions: bridgeGrammarVersionsSchema.default([
|
|
4215
3986
|
PROVIDER_BRIDGE_PROTOCOL_VERSION,
|
|
4216
3987
|
PROVIDER_BRIDGE_PROTOCOL_VERSION
|
|
4217
3988
|
]),
|
|
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
3989
|
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
3990
|
skills: z24.object({ configure: z24.boolean().default(false) }).default({ configure: false })
|
|
4240
3991
|
}).passthrough();
|
|
4241
3992
|
var initializeParamsSchema = z24.object({
|
|
4242
3993
|
protocolVersion: z24.number().int().positive(),
|
|
4243
3994
|
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
3995
|
grammarVersions: bridgeGrammarVersionsSchema.default([
|
|
4250
3996
|
PROVIDER_BRIDGE_PROTOCOL_VERSION,
|
|
4251
3997
|
PROVIDER_BRIDGE_PROTOCOL_VERSION
|
|
@@ -4253,8 +3999,6 @@ var initializeParamsSchema = z24.object({
|
|
|
4253
3999
|
}).passthrough();
|
|
4254
4000
|
var initializeResultSchema = z24.object({
|
|
4255
4001
|
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
4002
|
capabilities: z24.preprocess(
|
|
4259
4003
|
(value) => value ?? {},
|
|
4260
4004
|
bridgeCapabilitiesSchema
|
|
@@ -4267,16 +4011,9 @@ var bridgeExecutionOptionsSchema = z25.object({
|
|
|
4267
4011
|
model: z25.string().min(1).optional(),
|
|
4268
4012
|
serviceTier: serviceTierSchema.optional(),
|
|
4269
4013
|
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
4014
|
promptMode: promptModeSchema.optional(),
|
|
4276
|
-
/** Frozen for the life of a provider session; applied at construction. */
|
|
4277
4015
|
instructions: z25.string().optional(),
|
|
4278
4016
|
envVars: z25.record(z25.string(), z25.string()).optional(),
|
|
4279
|
-
/** Provider-scoped session options. Opaque outside the owning bridge. */
|
|
4280
4017
|
providerOptions: z25.record(z25.string(), z25.unknown()).optional()
|
|
4281
4018
|
}).and(runtimePermissionPolicySchema);
|
|
4282
4019
|
|
|
@@ -4287,9 +4024,7 @@ var providerMaintenanceParamsSchema = z26.object({
|
|
|
4287
4024
|
cwd: z26.string().min(1).optional(),
|
|
4288
4025
|
providerOptions: z26.record(z26.string(), z26.unknown()).optional()
|
|
4289
4026
|
}).passthrough();
|
|
4290
|
-
var providerInstallationRequirementSchema = z26.enum([
|
|
4291
|
-
"thread_rewind"
|
|
4292
|
-
]);
|
|
4027
|
+
var providerInstallationRequirementSchema = z26.enum(["thread_rewind"]);
|
|
4293
4028
|
var providerInstallationStatusParamsSchema = providerMaintenanceParamsSchema.extend({
|
|
4294
4029
|
requirement: providerInstallationRequirementSchema.optional()
|
|
4295
4030
|
});
|
|
@@ -4337,26 +4072,20 @@ var providerUsageSchema = z26.discriminatedUnion("status", [
|
|
|
4337
4072
|
accountEmail: z26.string().nullable().default(null)
|
|
4338
4073
|
}).passthrough()
|
|
4339
4074
|
]);
|
|
4340
|
-
var providerHealthResultSchema = z26.discriminatedUnion(
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
z26.object({
|
|
4355
|
-
supported: z26.literal(true),
|
|
4356
|
-
usage: providerUsageSchema
|
|
4357
|
-
}).passthrough()
|
|
4358
|
-
]
|
|
4359
|
-
);
|
|
4075
|
+
var providerHealthResultSchema = z26.discriminatedUnion("supported", [
|
|
4076
|
+
z26.object({ supported: z26.literal(false) }).passthrough(),
|
|
4077
|
+
z26.object({
|
|
4078
|
+
supported: z26.literal(true),
|
|
4079
|
+
health: providerHealthSchema
|
|
4080
|
+
}).passthrough()
|
|
4081
|
+
]);
|
|
4082
|
+
var providerUsageResultSchema = z26.discriminatedUnion("supported", [
|
|
4083
|
+
z26.object({ supported: z26.literal(false) }).passthrough(),
|
|
4084
|
+
z26.object({
|
|
4085
|
+
supported: z26.literal(true),
|
|
4086
|
+
usage: providerUsageSchema
|
|
4087
|
+
}).passthrough()
|
|
4088
|
+
]);
|
|
4360
4089
|
var providerInstallationActionKindSchema = z26.enum([
|
|
4361
4090
|
"install",
|
|
4362
4091
|
"update"
|
|
@@ -4393,28 +4122,34 @@ var providerInstallationCommandSchema = z26.object({
|
|
|
4393
4122
|
args: z26.array(z26.string()).max(64),
|
|
4394
4123
|
displayCommand: z26.string().min(1)
|
|
4395
4124
|
}).passthrough();
|
|
4396
|
-
var providerInstallationVerificationSchema = z26.discriminatedUnion(
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
kind: z26.literal("
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4125
|
+
var providerInstallationVerificationSchema = z26.discriminatedUnion(
|
|
4126
|
+
"kind",
|
|
4127
|
+
[
|
|
4128
|
+
z26.object({ kind: z26.literal("installed") }).passthrough(),
|
|
4129
|
+
z26.object({
|
|
4130
|
+
kind: z26.literal("version_changed"),
|
|
4131
|
+
previousVersion: z26.string().min(1)
|
|
4132
|
+
}).passthrough(),
|
|
4133
|
+
z26.object({
|
|
4134
|
+
kind: z26.literal("version_at_least"),
|
|
4135
|
+
version: z26.string().min(1)
|
|
4136
|
+
}).passthrough()
|
|
4137
|
+
]
|
|
4138
|
+
);
|
|
4139
|
+
var providerInstallationRunResultSchema = z26.discriminatedUnion(
|
|
4140
|
+
"available",
|
|
4141
|
+
[
|
|
4142
|
+
z26.object({
|
|
4143
|
+
available: z26.literal(false),
|
|
4144
|
+
message: z26.string().min(1)
|
|
4145
|
+
}).passthrough(),
|
|
4146
|
+
z26.object({
|
|
4147
|
+
available: z26.literal(true),
|
|
4148
|
+
command: providerInstallationCommandSchema,
|
|
4149
|
+
verification: providerInstallationVerificationSchema
|
|
4150
|
+
}).passthrough()
|
|
4151
|
+
]
|
|
4152
|
+
);
|
|
4418
4153
|
|
|
4419
4154
|
// ../provider-bridge-protocol/src/requests.ts
|
|
4420
4155
|
import { z as z27 } from "zod";
|
|
@@ -4458,24 +4193,12 @@ var threadResumeParamsSchema = z27.object({
|
|
|
4458
4193
|
var threadForkParamsSchema = z27.object({
|
|
4459
4194
|
...sessionConstructionFields,
|
|
4460
4195
|
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
4196
|
sourceProviderCheckpointId: z27.string().min(1).optional()
|
|
4467
4197
|
}).passthrough();
|
|
4468
4198
|
var threadStopParamsSchema = z27.object({
|
|
4469
4199
|
threadId: z27.string().min(1),
|
|
4470
4200
|
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
4201
|
intent: z27.enum(["interrupt", "release"]),
|
|
4478
|
-
/** Non-null when the stop interrupts an active provider turn. */
|
|
4479
4202
|
activeTurnId: z27.string().min(1).nullable()
|
|
4480
4203
|
}).passthrough();
|
|
4481
4204
|
var threadRefParams = z27.object({
|
|
@@ -4518,7 +4241,6 @@ var skillsConfigureParamsSchema = z27.object({
|
|
|
4518
4241
|
}).passthrough();
|
|
4519
4242
|
var threadIdentityResultSchema = z27.object({
|
|
4520
4243
|
providerThreadId: z27.string().min(1),
|
|
4521
|
-
/** Refines the handshake's `sessionRestore` for this session. */
|
|
4522
4244
|
sessionRestorable: z27.boolean().optional()
|
|
4523
4245
|
}).passthrough();
|
|
4524
4246
|
var modelListResultSchema = z27.object({
|
|
@@ -4538,16 +4260,12 @@ var BRIDGE_NOTIFICATION_METHODS = {
|
|
|
4538
4260
|
var threadIdentityNotificationSchema = z28.object({
|
|
4539
4261
|
threadId: z28.string().min(1),
|
|
4540
4262
|
providerThreadId: z28.string().min(1),
|
|
4541
|
-
/** Refines the handshake's `sessionRestore` for this session. */
|
|
4542
4263
|
sessionRestorable: z28.boolean().optional()
|
|
4543
4264
|
}).passthrough();
|
|
4544
4265
|
var sessionReplacedNotificationSchema = z28.object({
|
|
4545
4266
|
threadId: z28.string().min(1),
|
|
4546
|
-
/** Identity of the replacement session (may equal the old identity). */
|
|
4547
4267
|
providerThreadId: z28.string().min(1).nullable(),
|
|
4548
|
-
/** Human-readable cause, shown in the timeline. */
|
|
4549
4268
|
reason: z28.string().min(1),
|
|
4550
|
-
/** True when provider-side context did not survive the replacement. */
|
|
4551
4269
|
contextLost: z28.boolean().default(false)
|
|
4552
4270
|
}).passthrough();
|
|
4553
4271
|
var providerRawNotificationSchema = z28.object({
|
|
@@ -4595,14 +4313,6 @@ var interactionRequestParamsSchema = z29.object({
|
|
|
4595
4313
|
threadId: z29.string().min(1).optional(),
|
|
4596
4314
|
turnId: z29.union([z29.string().min(1), z29.null()]),
|
|
4597
4315
|
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
4316
|
providerNativeIds: z29.boolean().optional()
|
|
4607
4317
|
}).passthrough();
|
|
4608
4318
|
|
|
@@ -4622,24 +4332,14 @@ var deltaItemKeySchema = z30.object({
|
|
|
4622
4332
|
var providerTurnIdSchema = deltaKeyPartSchema;
|
|
4623
4333
|
var deltaFileChangeSchema = z30.object({
|
|
4624
4334
|
path: z30.string(),
|
|
4625
|
-
/** The bridge states the change kind; the assembler never derives it. */
|
|
4626
4335
|
kind: z30.enum(["add", "update", "delete"]),
|
|
4627
4336
|
movePath: z30.string().optional(),
|
|
4628
|
-
/** Provider-supplied unified diff; preferred over old/new text building. */
|
|
4629
4337
|
diff: z30.string().optional(),
|
|
4630
4338
|
oldText: z30.string().optional(),
|
|
4631
|
-
/** When present the assembler builds the unified diff from old/new text. */
|
|
4632
4339
|
newText: z30.string().optional()
|
|
4633
4340
|
});
|
|
4634
4341
|
var deltaBackgroundTaskShapeSchema = z30.object({
|
|
4635
4342
|
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
4343
|
familyId: z30.string().min(1),
|
|
4644
4344
|
taskType: z30.string(),
|
|
4645
4345
|
description: z30.string(),
|
|
@@ -4693,20 +4393,8 @@ var deltaItemShapeSchema = z30.discriminatedUnion("type", [
|
|
|
4693
4393
|
}),
|
|
4694
4394
|
z30.object({
|
|
4695
4395
|
type: z30.literal("fileChange"),
|
|
4696
|
-
/** Empty while a path is not yet known, including bare close fallbacks. */
|
|
4697
4396
|
changes: z30.array(deltaFileChangeSchema)
|
|
4698
4397
|
}),
|
|
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
4398
|
z30.object({
|
|
4711
4399
|
type: z30.literal("tool"),
|
|
4712
4400
|
tool: z30.string(),
|
|
@@ -4736,7 +4424,6 @@ var deltaItemShapeSchema = z30.discriminatedUnion("type", [
|
|
|
4736
4424
|
}),
|
|
4737
4425
|
z30.object({ type: z30.literal("imageView"), path: z30.string() }),
|
|
4738
4426
|
deltaBackgroundTaskShapeSchema,
|
|
4739
|
-
// Grammar v3 shapes. Every existing shape above is kept unchanged.
|
|
4740
4427
|
deltaFileReadShapeSchema,
|
|
4741
4428
|
deltaSearchShapeSchema,
|
|
4742
4429
|
deltaDelegationShapeSchema,
|
|
@@ -4770,51 +4457,21 @@ function requireExtensionPresentation(delta, ctx) {
|
|
|
4770
4457
|
}
|
|
4771
4458
|
}
|
|
4772
4459
|
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
4460
|
z30.object({
|
|
4780
4461
|
kind: z30.literal("input.accepted"),
|
|
4781
4462
|
clientRequestId: clientTurnRequestIdSchema,
|
|
4782
4463
|
providerTurnId: providerTurnIdSchema.optional()
|
|
4783
4464
|
}),
|
|
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
4465
|
z30.object({
|
|
4794
4466
|
kind: z30.literal("input.provider"),
|
|
4795
4467
|
text: z30.string().min(1),
|
|
4796
4468
|
parentRef: deltaKeyPartSchema.optional()
|
|
4797
4469
|
}),
|
|
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
4470
|
z30.object({
|
|
4806
4471
|
kind: z30.literal("turn.open"),
|
|
4807
4472
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
4808
|
-
/** Provider-native parent tool-call id for delegated child turns. */
|
|
4809
4473
|
parentRef: deltaKeyPartSchema.optional()
|
|
4810
4474
|
}),
|
|
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
4475
|
z30.object({
|
|
4819
4476
|
kind: z30.literal("turn.boundary"),
|
|
4820
4477
|
status: threadEventTurnStatusSchema,
|
|
@@ -4823,40 +4480,15 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4823
4480
|
claimIfIdle: z30.boolean().optional(),
|
|
4824
4481
|
providerTurnId: providerTurnIdSchema.optional()
|
|
4825
4482
|
}),
|
|
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
4483
|
z30.object({
|
|
4834
4484
|
kind: z30.literal("item.open"),
|
|
4835
4485
|
key: deltaItemKeySchema,
|
|
4836
4486
|
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
4487
|
presentation: deltaPresentationSchema.optional(),
|
|
4843
4488
|
attach: deltaAttachSchema.optional(),
|
|
4844
4489
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
4845
4490
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4846
4491
|
}).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
4492
|
z30.object({
|
|
4861
4493
|
kind: z30.literal("item.close"),
|
|
4862
4494
|
key: deltaItemKeySchema,
|
|
@@ -4864,32 +4496,12 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4864
4496
|
resultText: z30.string().optional(),
|
|
4865
4497
|
exitCode: z30.number().optional(),
|
|
4866
4498
|
aggregatedOutput: z30.string().optional(),
|
|
4867
|
-
/** Terminal approval verdict (codex declined → denied). Default null. */
|
|
4868
4499
|
approvalStatus: z30.literal("denied").optional(),
|
|
4869
4500
|
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
4501
|
presentation: deltaPresentationSchema.optional(),
|
|
4877
4502
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
4878
4503
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4879
4504
|
}).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
4505
|
z30.object({
|
|
4894
4506
|
kind: z30.literal("item.progress"),
|
|
4895
4507
|
key: deltaItemKeySchema,
|
|
@@ -4899,17 +4511,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4899
4511
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
4900
4512
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4901
4513
|
}),
|
|
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
4514
|
z30.object({
|
|
4914
4515
|
kind: z30.literal("item.textDelta"),
|
|
4915
4516
|
key: deltaItemKeySchema,
|
|
@@ -4918,18 +4519,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4918
4519
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
4919
4520
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4920
4521
|
}),
|
|
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
4522
|
z30.object({
|
|
4934
4523
|
kind: z30.literal("item.textClose"),
|
|
4935
4524
|
key: deltaItemKeySchema,
|
|
@@ -4938,10 +4527,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4938
4527
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
4939
4528
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4940
4529
|
}),
|
|
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
4530
|
z30.object({
|
|
4946
4531
|
kind: z30.literal("item.outputDelta"),
|
|
4947
4532
|
key: deltaItemKeySchema,
|
|
@@ -4950,26 +4535,12 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4950
4535
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
4951
4536
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4952
4537
|
}),
|
|
4953
|
-
/**
|
|
4954
|
-
* Cumulative command output snapshot (pi bash). The assembler diffs
|
|
4955
|
-
* consecutive snapshots into `outputDelta`/`reset` events.
|
|
4956
|
-
*/
|
|
4957
4538
|
z30.object({
|
|
4958
4539
|
kind: z30.literal("command.outputSnapshot"),
|
|
4959
4540
|
key: deltaItemKeySchema,
|
|
4960
4541
|
text: z30.string(),
|
|
4961
4542
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4962
4543
|
}),
|
|
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
4544
|
z30.object({
|
|
4974
4545
|
kind: z30.literal("usage"),
|
|
4975
4546
|
total: threadEventTokenUsageBreakdownSchema,
|
|
@@ -4977,13 +4548,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4977
4548
|
modelContextWindow: z30.number().nullable(),
|
|
4978
4549
|
providerTurnId: providerTurnIdSchema.optional()
|
|
4979
4550
|
}),
|
|
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
4551
|
z30.object({
|
|
4988
4552
|
kind: z30.literal("contextWindow"),
|
|
4989
4553
|
used: z30.number().nullable(),
|
|
@@ -4998,54 +4562,26 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
4998
4562
|
noTurnFallback: deltaNoTurnFallbackSchema.optional()
|
|
4999
4563
|
}),
|
|
5000
4564
|
z30.object({ kind: z30.literal("context.cleared") }),
|
|
5001
|
-
/** The aggregate working-tree diff for a turn (codex turn/diff/updated). */
|
|
5002
4565
|
z30.object({
|
|
5003
4566
|
kind: z30.literal("turn.diff"),
|
|
5004
4567
|
diff: z30.string(),
|
|
5005
4568
|
providerTurnId: providerTurnIdSchema.optional()
|
|
5006
4569
|
}),
|
|
5007
|
-
// Thread metadata (codex thread lifecycle notifications).
|
|
5008
4570
|
z30.object({ kind: z30.literal("thread.started") }),
|
|
5009
4571
|
z30.object({
|
|
5010
4572
|
kind: z30.literal("thread.identity"),
|
|
5011
4573
|
providerThreadId: z30.string().min(1)
|
|
5012
4574
|
}),
|
|
5013
4575
|
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
4576
|
z30.object({
|
|
5028
4577
|
kind: z30.literal("extension.state"),
|
|
5029
4578
|
extensionKind: extensionKindSchema,
|
|
5030
4579
|
payload: jsonValueSchema
|
|
5031
4580
|
}),
|
|
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
4581
|
z30.object({
|
|
5039
4582
|
kind: z30.literal("provider.rateLimits"),
|
|
5040
4583
|
rateLimits: providerRateLimitStateSchema
|
|
5041
4584
|
}),
|
|
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
4585
|
z30.object({
|
|
5050
4586
|
kind: z30.literal("provider.error"),
|
|
5051
4587
|
message: z30.string(),
|
|
@@ -5057,13 +4593,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
5057
4593
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
5058
4594
|
threadScoped: z30.boolean().optional()
|
|
5059
4595
|
}),
|
|
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
4596
|
z30.object({
|
|
5068
4597
|
kind: z30.literal("provider.modelFallback"),
|
|
5069
4598
|
originalModel: z30.string().min(1),
|
|
@@ -5071,10 +4600,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
5071
4600
|
reason: z30.enum(["refusal", "provider"]),
|
|
5072
4601
|
message: z30.string()
|
|
5073
4602
|
}),
|
|
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
4603
|
z30.object({
|
|
5079
4604
|
kind: z30.literal("provider.warning"),
|
|
5080
4605
|
summary: z30.string().optional(),
|
|
@@ -5082,15 +4607,6 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
5082
4607
|
category: threadEventWarningCategorySchema.optional(),
|
|
5083
4608
|
vouchedTurn: z30.boolean().optional()
|
|
5084
4609
|
}),
|
|
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
4610
|
z30.object({
|
|
5095
4611
|
kind: z30.literal("unhandled"),
|
|
5096
4612
|
raw: providerRawEventSchema,
|
|
@@ -5100,18 +4616,7 @@ var threadDeltaSchema = z30.discriminatedUnion("kind", [
|
|
|
5100
4616
|
parentRef: deltaKeyPartSchema.optional(),
|
|
5101
4617
|
providerTurnId: providerTurnIdSchema.optional()
|
|
5102
4618
|
}),
|
|
5103
|
-
/**
|
|
5104
|
-
* Lifecycle settlement: the session was interrupted. The assembler closes
|
|
5105
|
-
* the open turn and open items as interrupted.
|
|
5106
|
-
*/
|
|
5107
4619
|
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
4620
|
z30.object({ kind: z30.literal("session.reset") })
|
|
5116
4621
|
]);
|
|
5117
4622
|
var threadDeltaNotificationParamsSchema = z30.object({
|