@roll-agent/protocol 0.8.1 → 0.9.0
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/README.md +17 -1
- package/dist/index.d.ts +8895 -5123
- package/dist/index.js +146 -7
- package/dist/schema/roll-runtime-protocol-v1.6.schema.json +7186 -0
- package/dist/schema/roll-runtime-protocol-v1.schema.json +326 -11
- package/fixtures/v1.6/valid-context-recovery-event.json +23 -0
- package/fixtures/v1.6/valid-context-recovery-snapshot-response.json +30 -0
- package/fixtures/v1.6/valid-initialize-response.json +36 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -14,10 +14,14 @@ export const SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V14 = [
|
|
|
14
14
|
"1.4",
|
|
15
15
|
...SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V13,
|
|
16
16
|
];
|
|
17
|
-
export const
|
|
17
|
+
export const SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V15 = [
|
|
18
18
|
"1.5",
|
|
19
19
|
...SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V14,
|
|
20
20
|
];
|
|
21
|
+
export const SUPPORTED_RUNTIME_PROTOCOL_VERSIONS = [
|
|
22
|
+
"1.6",
|
|
23
|
+
...SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V15,
|
|
24
|
+
];
|
|
21
25
|
export const RUNTIME_PROTOCOL_VERSION = SUPPORTED_RUNTIME_PROTOCOL_VERSIONS[0];
|
|
22
26
|
export const RUNTIME_EVENT_NOTIFICATION = "runtime.event";
|
|
23
27
|
export const RUNTIME_SERVER_REQUEST_CANCEL_NOTIFICATION = "runtime.serverRequest.cancel";
|
|
@@ -89,6 +93,13 @@ export const USER_INPUT_CONTROL_TYPES = {
|
|
|
89
93
|
choice: "choice",
|
|
90
94
|
};
|
|
91
95
|
export const RUNTIME_PROTOCOL_CAPABILITIES = {
|
|
96
|
+
"1.6": {
|
|
97
|
+
serverRequests: true,
|
|
98
|
+
serverRequestCapabilityNegotiation: true,
|
|
99
|
+
approvalResolvedEvents: true,
|
|
100
|
+
clientApprovalResponses: false,
|
|
101
|
+
requiredServerRequestMethods: [],
|
|
102
|
+
},
|
|
92
103
|
"1.5": {
|
|
93
104
|
serverRequests: true,
|
|
94
105
|
serverRequestCapabilityNegotiation: true,
|
|
@@ -133,6 +144,7 @@ export const RUNTIME_PROTOCOL_CAPABILITIES = {
|
|
|
133
144
|
},
|
|
134
145
|
};
|
|
135
146
|
export const REQUIRED_RUNTIME_SERVER_REQUEST_METHODS_BY_VERSION = {
|
|
147
|
+
"1.6": RUNTIME_PROTOCOL_CAPABILITIES["1.6"].requiredServerRequestMethods,
|
|
136
148
|
"1.5": RUNTIME_PROTOCOL_CAPABILITIES["1.5"].requiredServerRequestMethods,
|
|
137
149
|
"1.4": RUNTIME_PROTOCOL_CAPABILITIES["1.4"].requiredServerRequestMethods,
|
|
138
150
|
"1.3": RUNTIME_PROTOCOL_CAPABILITIES["1.3"].requiredServerRequestMethods,
|
|
@@ -175,6 +187,7 @@ export const RUNTIME_METHODS = {
|
|
|
175
187
|
turnStart: "turn.start",
|
|
176
188
|
turnCancel: "turn.cancel",
|
|
177
189
|
approvalRespond: "approval.respond",
|
|
190
|
+
approvalPreview: "approval.preview",
|
|
178
191
|
operationGet: "operation.get",
|
|
179
192
|
attachmentStage: "attachment.stage",
|
|
180
193
|
attachmentChunk: "attachment.chunk",
|
|
@@ -193,7 +206,8 @@ export const RUNTIME_FEATURES_V13 = [
|
|
|
193
206
|
];
|
|
194
207
|
export const RUNTIME_FEATURES_V14 = [...RUNTIME_FEATURES_V13, "attachments"];
|
|
195
208
|
export const RUNTIME_FEATURES_V15 = [...RUNTIME_FEATURES_V14, "app-output"];
|
|
196
|
-
export const
|
|
209
|
+
export const RUNTIME_FEATURES_V16 = [...RUNTIME_FEATURES_V15, "context-recovery"];
|
|
210
|
+
export const RUNTIME_FEATURES = RUNTIME_FEATURES_V16;
|
|
197
211
|
export const RUNTIME_ERROR_CODES_V11 = {
|
|
198
212
|
protocolVersionUnsupported: "PROTOCOL_VERSION_UNSUPPORTED",
|
|
199
213
|
initializeRequired: "INITIALIZE_REQUIRED",
|
|
@@ -285,6 +299,8 @@ export const fileChangeDiffSchema = z
|
|
|
285
299
|
hunks: z.number().int().nonnegative(),
|
|
286
300
|
unified: z.string().max(FILE_CHANGE_DIFF_UNIFIED_MAX_CHARS).optional(),
|
|
287
301
|
truncated: z.boolean(),
|
|
302
|
+
/** True when the counts describe whole before/after files rather than a line diff. */
|
|
303
|
+
coarse: z.boolean().optional(),
|
|
288
304
|
})
|
|
289
305
|
.readonly();
|
|
290
306
|
export const fileChangeDisplaySchema = z
|
|
@@ -457,8 +473,15 @@ export const initializeResultV15Schema = z
|
|
|
457
473
|
})
|
|
458
474
|
.strict()
|
|
459
475
|
.readonly();
|
|
476
|
+
export const initializeResultV16Schema = initializeResultV15Schema.def.innerType
|
|
477
|
+
.extend({
|
|
478
|
+
protocolVersion: z.literal("1.6"),
|
|
479
|
+
features: z.array(z.enum(RUNTIME_FEATURES_V16)),
|
|
480
|
+
})
|
|
481
|
+
.readonly();
|
|
460
482
|
/** Any currently supported Runtime Protocol initialize result. */
|
|
461
483
|
export const initializeResultSchema = z.union([
|
|
484
|
+
initializeResultV16Schema,
|
|
462
485
|
initializeResultV15Schema,
|
|
463
486
|
initializeResultV14Schema,
|
|
464
487
|
initializeResultV13Schema,
|
|
@@ -990,7 +1013,31 @@ export const threadSnapshotV15Schema = z.union([
|
|
|
990
1013
|
threadSnapshotV15FullSchema,
|
|
991
1014
|
threadRecoverySnapshotV13Schema,
|
|
992
1015
|
]);
|
|
993
|
-
|
|
1016
|
+
/** Bounded Harness state only; no model-authored recovery notes or fact contents cross the wire. */
|
|
1017
|
+
export const contextRecoveryViewSchema = z
|
|
1018
|
+
.object({
|
|
1019
|
+
checkpointId: z.string().uuid(),
|
|
1020
|
+
required: z.boolean(),
|
|
1021
|
+
unextracted: z.boolean(),
|
|
1022
|
+
requiredItemCount: z.number().int().nonnegative(),
|
|
1023
|
+
})
|
|
1024
|
+
.strict()
|
|
1025
|
+
.readonly();
|
|
1026
|
+
export const threadSnapshotV16FullSchema = threadSnapshotV15FullSchema.def.innerType
|
|
1027
|
+
.extend({
|
|
1028
|
+
contextRecovery: contextRecoveryViewSchema.nullable(),
|
|
1029
|
+
})
|
|
1030
|
+
.readonly();
|
|
1031
|
+
export const threadRecoverySnapshotV16Schema = threadRecoverySnapshotV13Schema.def.innerType
|
|
1032
|
+
.extend({
|
|
1033
|
+
contextRecovery: contextRecoveryViewSchema.nullable(),
|
|
1034
|
+
})
|
|
1035
|
+
.readonly();
|
|
1036
|
+
export const threadSnapshotV16Schema = z.union([
|
|
1037
|
+
threadSnapshotV16FullSchema,
|
|
1038
|
+
threadRecoverySnapshotV16Schema,
|
|
1039
|
+
]);
|
|
1040
|
+
export const threadSnapshotSchema = threadSnapshotV16Schema;
|
|
994
1041
|
const pageSizeSchema = z.number().int().min(1).max(500).default(100);
|
|
995
1042
|
const requestFields = { requestId: requestIdSchema };
|
|
996
1043
|
const threadRequestFields = { threadId: threadIdSchema };
|
|
@@ -1264,6 +1311,25 @@ export const approvalRespondResultSchema = z
|
|
|
1264
1311
|
.object({ resolved: z.literal(true) })
|
|
1265
1312
|
.strict()
|
|
1266
1313
|
.readonly();
|
|
1314
|
+
/** Offsets count UTF-16 code units in the stable, redacted review text. */
|
|
1315
|
+
export const approvalPreviewParamsSchema = z
|
|
1316
|
+
.object({
|
|
1317
|
+
...threadRequestFields,
|
|
1318
|
+
turnId: turnIdSchema,
|
|
1319
|
+
approvalId: approvalIdSchema,
|
|
1320
|
+
offset: z.number().int().nonnegative().default(0),
|
|
1321
|
+
maxChars: z.number().int().min(1).max(32_000).default(12_000),
|
|
1322
|
+
})
|
|
1323
|
+
.strict()
|
|
1324
|
+
.readonly();
|
|
1325
|
+
export const approvalPreviewResultSchema = z
|
|
1326
|
+
.object({
|
|
1327
|
+
text: z.string().max(32_000),
|
|
1328
|
+
totalChars: z.number().int().nonnegative(),
|
|
1329
|
+
nextOffset: z.number().int().nonnegative().nullable(),
|
|
1330
|
+
})
|
|
1331
|
+
.strict()
|
|
1332
|
+
.readonly();
|
|
1267
1333
|
export const approvalRequestParamsSchema = z
|
|
1268
1334
|
.object({
|
|
1269
1335
|
threadId: threadIdSchema,
|
|
@@ -1545,8 +1611,23 @@ export const runtimeEventV15Schema = z.union([
|
|
|
1545
1611
|
runtimeDurableEventV15Schema,
|
|
1546
1612
|
runtimeEphemeralEventV13Schema,
|
|
1547
1613
|
]);
|
|
1614
|
+
export const contextRecoveryChangedEventSchema = z
|
|
1615
|
+
.object({
|
|
1616
|
+
type: z.literal("context.recovery.changed"),
|
|
1617
|
+
contextRecovery: contextRecoveryViewSchema.nullable(),
|
|
1618
|
+
})
|
|
1619
|
+
.strict()
|
|
1620
|
+
.readonly();
|
|
1621
|
+
export const runtimeDurableEventV16Schema = z.discriminatedUnion("type", [
|
|
1622
|
+
...runtimeDurableEventV15Schema.options,
|
|
1623
|
+
contextRecoveryChangedEventSchema,
|
|
1624
|
+
]);
|
|
1625
|
+
export const runtimeEventV16Schema = z.union([
|
|
1626
|
+
runtimeDurableEventV16Schema,
|
|
1627
|
+
runtimeEphemeralEventV13Schema,
|
|
1628
|
+
]);
|
|
1548
1629
|
/** Latest Runtime Protocol event payloads. */
|
|
1549
|
-
export const runtimeEventSchema =
|
|
1630
|
+
export const runtimeEventSchema = runtimeEventV16Schema;
|
|
1550
1631
|
const runtimeEventEnvelopeFields = {
|
|
1551
1632
|
runtimeInstanceId: runtimeInstanceIdSchema,
|
|
1552
1633
|
sequence: z.number().int().nonnegative(),
|
|
@@ -1663,7 +1744,23 @@ export const runtimeEventEnvelopeV15Schema = z.discriminatedUnion("durability",
|
|
|
1663
1744
|
runtimeEphemeralEventEnvelopeV15Schema,
|
|
1664
1745
|
]);
|
|
1665
1746
|
/** Any currently supported Runtime Event envelope. */
|
|
1747
|
+
export const runtimeDurableEventEnvelopeV16Schema = runtimeDurableEventEnvelopeV15Schema.def.innerType
|
|
1748
|
+
.extend({
|
|
1749
|
+
protocolVersion: z.literal("1.6"),
|
|
1750
|
+
event: runtimeDurableEventV16Schema,
|
|
1751
|
+
})
|
|
1752
|
+
.readonly();
|
|
1753
|
+
export const runtimeEphemeralEventEnvelopeV16Schema = runtimeEphemeralEventEnvelopeV15Schema.def.innerType
|
|
1754
|
+
.extend({
|
|
1755
|
+
protocolVersion: z.literal("1.6"),
|
|
1756
|
+
})
|
|
1757
|
+
.readonly();
|
|
1758
|
+
export const runtimeEventEnvelopeV16Schema = z.discriminatedUnion("durability", [
|
|
1759
|
+
runtimeDurableEventEnvelopeV16Schema,
|
|
1760
|
+
runtimeEphemeralEventEnvelopeV16Schema,
|
|
1761
|
+
]);
|
|
1666
1762
|
export const runtimeEventEnvelopeSchema = z.union([
|
|
1763
|
+
runtimeEventEnvelopeV16Schema,
|
|
1667
1764
|
runtimeEventEnvelopeV15Schema,
|
|
1668
1765
|
runtimeEventEnvelopeV14Schema,
|
|
1669
1766
|
runtimeEventEnvelopeV13Schema,
|
|
@@ -1853,7 +1950,23 @@ export const runtimeMethodSchemasV15 = {
|
|
|
1853
1950
|
result: operationResultGetResultSchema,
|
|
1854
1951
|
},
|
|
1855
1952
|
};
|
|
1856
|
-
export const
|
|
1953
|
+
export const runtimeMethodSchemasV16 = {
|
|
1954
|
+
...runtimeMethodSchemasV15,
|
|
1955
|
+
[RUNTIME_METHODS.approvalPreview]: {
|
|
1956
|
+
params: approvalPreviewParamsSchema,
|
|
1957
|
+
result: approvalPreviewResultSchema,
|
|
1958
|
+
},
|
|
1959
|
+
[RUNTIME_METHODS.initialize]: {
|
|
1960
|
+
params: initializeParamsSchema,
|
|
1961
|
+
result: initializeResultV16Schema,
|
|
1962
|
+
},
|
|
1963
|
+
[RUNTIME_METHODS.threadOpen]: { params: threadOpenParamsSchema, result: threadSnapshotV16Schema },
|
|
1964
|
+
[RUNTIME_METHODS.threadSnapshot]: {
|
|
1965
|
+
params: threadSnapshotParamsV13Schema,
|
|
1966
|
+
result: threadSnapshotV16Schema,
|
|
1967
|
+
},
|
|
1968
|
+
};
|
|
1969
|
+
export const runtimeMethodSchemas = runtimeMethodSchemasV16;
|
|
1857
1970
|
export const runtimeServerRequestSchemasV10 = {};
|
|
1858
1971
|
export const runtimeServerRequestSchemasV11 = {
|
|
1859
1972
|
[RUNTIME_SERVER_REQUEST_METHODS.approvalRequest]: {
|
|
@@ -1875,6 +1988,14 @@ export const runtimeServerRequestSchemasV13 = runtimeServerRequestSchemasV12;
|
|
|
1875
1988
|
/** Protocol 1.1 compatibility facade. Prefer the version registry in new code. */
|
|
1876
1989
|
export const runtimeServerRequestSchemas = runtimeServerRequestSchemasV11;
|
|
1877
1990
|
export const RUNTIME_PROTOCOL_REGISTRY = {
|
|
1991
|
+
"1.6": {
|
|
1992
|
+
methods: runtimeMethodSchemasV16,
|
|
1993
|
+
serverRequests: runtimeServerRequestSchemasV13,
|
|
1994
|
+
serverRequestMethods: RUNTIME_SERVER_REQUEST_METHOD_VALUES,
|
|
1995
|
+
serverRequestCancelParamsSchema: runtimeServerRequestCancelParamsV12Schema,
|
|
1996
|
+
eventEnvelopeSchema: runtimeEventEnvelopeV16Schema,
|
|
1997
|
+
errorDataSchema: runtimeProtocolErrorDataV14Schema,
|
|
1998
|
+
},
|
|
1878
1999
|
"1.5": {
|
|
1879
2000
|
methods: runtimeMethodSchemasV15,
|
|
1880
2001
|
serverRequests: runtimeServerRequestSchemasV13,
|
|
@@ -2152,7 +2273,7 @@ function projectUiMessagePageToTextParts(page) {
|
|
|
2152
2273
|
}
|
|
2153
2274
|
export function projectOperationViewForVersion(version, value) {
|
|
2154
2275
|
const current = operationViewV15Schema.safeParse(value);
|
|
2155
|
-
if (version === "1.5") {
|
|
2276
|
+
if (version === "1.5" || version === "1.6") {
|
|
2156
2277
|
return current.success
|
|
2157
2278
|
? current.data
|
|
2158
2279
|
: operationViewV15Schema.parse({
|
|
@@ -2166,6 +2287,14 @@ export function projectOperationViewForVersion(version, value) {
|
|
|
2166
2287
|
return operationViewSchema.parse(legacy);
|
|
2167
2288
|
}
|
|
2168
2289
|
export function projectThreadSnapshotForVersion(version, value) {
|
|
2290
|
+
if (version === "1.6") {
|
|
2291
|
+
return threadSnapshotV16Schema.parse(value);
|
|
2292
|
+
}
|
|
2293
|
+
const latestV16 = threadSnapshotV16Schema.safeParse(value);
|
|
2294
|
+
if (latestV16.success) {
|
|
2295
|
+
const { contextRecovery: _contextRecovery, ...legacy } = latestV16.data;
|
|
2296
|
+
value = legacy;
|
|
2297
|
+
}
|
|
2169
2298
|
const latestV15 = threadSnapshotV15Schema.safeParse(value);
|
|
2170
2299
|
if (version === "1.5") {
|
|
2171
2300
|
return threadSnapshotV15Schema.parse(value);
|
|
@@ -2230,7 +2359,17 @@ export function projectThreadSnapshotForVersion(version, value) {
|
|
|
2230
2359
|
});
|
|
2231
2360
|
}
|
|
2232
2361
|
export function projectRuntimeEventEnvelopeForVersion(version, value) {
|
|
2233
|
-
const
|
|
2362
|
+
const latest = runtimeEventEnvelopeSchema.parse(value);
|
|
2363
|
+
if (version === "1.6") {
|
|
2364
|
+
return runtimeEventEnvelopeV16Schema.parse({
|
|
2365
|
+
...latest,
|
|
2366
|
+
protocolVersion: version,
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
// Preserve durable cursor continuity for old clients; the available tool set changed.
|
|
2370
|
+
const parsedSource = latest.event.type === "context.recovery.changed"
|
|
2371
|
+
? { ...latest, event: { type: "capabilities.changed" } }
|
|
2372
|
+
: latest;
|
|
2234
2373
|
if (version === "1.5") {
|
|
2235
2374
|
return runtimeEventEnvelopeV15Schema.parse({
|
|
2236
2375
|
...parsedSource,
|