@roll-agent/protocol 0.4.0 → 0.5.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/dist/index.js CHANGED
@@ -4,10 +4,14 @@ export const SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V12 = [
4
4
  "1.2",
5
5
  ...SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V11,
6
6
  ];
7
- export const SUPPORTED_RUNTIME_PROTOCOL_VERSIONS = [
7
+ export const SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V13 = [
8
8
  "1.3",
9
9
  ...SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V12,
10
10
  ];
11
+ export const SUPPORTED_RUNTIME_PROTOCOL_VERSIONS = [
12
+ "1.4",
13
+ ...SUPPORTED_RUNTIME_PROTOCOL_VERSIONS_V13,
14
+ ];
11
15
  export const RUNTIME_PROTOCOL_VERSION = SUPPORTED_RUNTIME_PROTOCOL_VERSIONS[0];
12
16
  export const RUNTIME_EVENT_NOTIFICATION = "runtime.event";
13
17
  export const RUNTIME_SERVER_REQUEST_CANCEL_NOTIFICATION = "runtime.serverRequest.cancel";
@@ -35,6 +39,25 @@ export const USER_INPUT_DESCRIPTION_MAX_CHARS = 500;
35
39
  export const USER_INPUT_CHOICE_OPTION_MAX_COUNT = 50;
36
40
  export const USER_INPUT_TEXT_MAX_CHARS = 10_000;
37
41
  export const USER_INPUT_CANCEL_REASON_MAX_CHARS = 500;
42
+ export const RUNTIME_V14_MAX_ATTACHMENT_BYTES = 16 * 1_024 * 1_024;
43
+ export const RUNTIME_V14_MAX_TURN_ATTACHMENTS = 8;
44
+ /**
45
+ * Chunk payloads are raw bytes before base64 framing. 2 MiB of raw data grows to about 2.7 MiB of
46
+ * base64 text, which keeps a full attachment.chunk request inside the 4 MiB stdio frame limit.
47
+ */
48
+ export const RUNTIME_V14_MAX_ATTACHMENT_CHUNK_BYTES = 2 * 1_024 * 1_024;
49
+ export const RUNTIME_V14_MAX_STAGED_ATTACHMENTS = 16;
50
+ export const ATTACHMENT_FILE_NAME_MAX_CHARS = 255;
51
+ export const SUPPORTED_ATTACHMENT_MEDIA_TYPES = [
52
+ "image/png",
53
+ "image/jpeg",
54
+ "image/gif",
55
+ "image/webp",
56
+ "application/pdf",
57
+ "text/plain",
58
+ "text/markdown",
59
+ ];
60
+ export const ATTACHMENT_SOURCES = ["local-path", "chunks"];
38
61
  export const INTERACTION_SENSITIVITIES = ["normal"];
39
62
  export const RUNTIME_SERVER_REQUEST_METHODS = {
40
63
  approvalRequest: "approval.request",
@@ -56,6 +79,13 @@ export const USER_INPUT_CONTROL_TYPES = {
56
79
  choice: "choice",
57
80
  };
58
81
  export const RUNTIME_PROTOCOL_CAPABILITIES = {
82
+ "1.4": {
83
+ serverRequests: true,
84
+ serverRequestCapabilityNegotiation: true,
85
+ approvalResolvedEvents: true,
86
+ clientApprovalResponses: false,
87
+ requiredServerRequestMethods: [],
88
+ },
59
89
  "1.2": {
60
90
  serverRequests: true,
61
91
  serverRequestCapabilityNegotiation: true,
@@ -86,6 +116,7 @@ export const RUNTIME_PROTOCOL_CAPABILITIES = {
86
116
  },
87
117
  };
88
118
  export const REQUIRED_RUNTIME_SERVER_REQUEST_METHODS_BY_VERSION = {
119
+ "1.4": RUNTIME_PROTOCOL_CAPABILITIES["1.4"].requiredServerRequestMethods,
89
120
  "1.3": RUNTIME_PROTOCOL_CAPABILITIES["1.3"].requiredServerRequestMethods,
90
121
  "1.2": RUNTIME_PROTOCOL_CAPABILITIES["1.2"].requiredServerRequestMethods,
91
122
  "1.1": RUNTIME_PROTOCOL_CAPABILITIES["1.1"].requiredServerRequestMethods,
@@ -113,8 +144,12 @@ export const RUNTIME_METHODS = {
113
144
  turnCancel: "turn.cancel",
114
145
  approvalRespond: "approval.respond",
115
146
  operationGet: "operation.get",
147
+ attachmentStage: "attachment.stage",
148
+ attachmentChunk: "attachment.chunk",
149
+ attachmentCommit: "attachment.commit",
150
+ attachmentRelease: "attachment.release",
116
151
  };
117
- export const RUNTIME_FEATURES = [
152
+ export const RUNTIME_FEATURES_V13 = [
118
153
  "thread-management",
119
154
  "snapshots",
120
155
  "turns",
@@ -124,6 +159,8 @@ export const RUNTIME_FEATURES = [
124
159
  "operation-projection",
125
160
  "process-local-sequence",
126
161
  ];
162
+ export const RUNTIME_FEATURES_V14 = [...RUNTIME_FEATURES_V13, "attachments"];
163
+ export const RUNTIME_FEATURES = RUNTIME_FEATURES_V14;
127
164
  export const RUNTIME_ERROR_CODES_V11 = {
128
165
  protocolVersionUnsupported: "PROTOCOL_VERSION_UNSUPPORTED",
129
166
  initializeRequired: "INITIALIZE_REQUIRED",
@@ -143,12 +180,24 @@ export const RUNTIME_ERROR_CODES_V12 = {
143
180
  ...RUNTIME_ERROR_CODES_V11,
144
181
  capabilityRevisionConflict: "CAPABILITY_REVISION_CONFLICT",
145
182
  };
146
- export const RUNTIME_ERROR_CODES = {
183
+ export const RUNTIME_ERROR_CODES_V13 = {
147
184
  ...RUNTIME_ERROR_CODES_V12,
148
185
  eventCursorExpired: "EVENT_CURSOR_EXPIRED",
149
186
  eventCursorGap: "EVENT_CURSOR_GAP",
150
187
  };
151
- export const RUNTIME_ERROR_CODES_V13 = RUNTIME_ERROR_CODES;
188
+ /** Runtime Protocol 1.4 error registry. Keep this object frozen. */
189
+ export const RUNTIME_ERROR_CODES_V14 = {
190
+ ...RUNTIME_ERROR_CODES_V13,
191
+ attachmentNotFound: "ATTACHMENT_NOT_FOUND",
192
+ attachmentNotCommitted: "ATTACHMENT_NOT_COMMITTED",
193
+ attachmentTooLarge: "ATTACHMENT_TOO_LARGE",
194
+ attachmentTypeUnsupported: "ATTACHMENT_TYPE_UNSUPPORTED",
195
+ attachmentHashMismatch: "ATTACHMENT_HASH_MISMATCH",
196
+ attachmentQuotaExceeded: "ATTACHMENT_QUOTA_EXCEEDED",
197
+ attachmentUploadIncomplete: "ATTACHMENT_UPLOAD_INCOMPLETE",
198
+ attachmentPathRejected: "ATTACHMENT_PATH_REJECTED",
199
+ };
200
+ export const RUNTIME_ERROR_CODES = RUNTIME_ERROR_CODES_V14;
152
201
  export const TOOL_OUTCOME_KINDS = [
153
202
  "success",
154
203
  "user_rejected",
@@ -166,6 +215,7 @@ export const requestIdSchema = z.string().uuid().brand();
166
215
  export const streamIdSchema = z.string().uuid().brand();
167
216
  export const operationIdSchema = z.string().uuid().brand();
168
217
  export const runtimeEventIdSchema = z.string().uuid().brand();
218
+ export const attachmentIdSchema = z.string().uuid().brand();
169
219
  export const runtimeEventCursorSchema = z
170
220
  .string()
171
221
  .max(128)
@@ -279,7 +329,24 @@ export const runtimeLimitsV13Schema = z
279
329
  })
280
330
  .strict()
281
331
  .readonly();
282
- export const runtimeLimitsSchema = z.union([runtimeLimitsV13Schema, runtimeLimitsV12Schema]);
332
+ export const runtimeLimitsV14Schema = z
333
+ .object({
334
+ maxFrameBytes: z.number().int().positive(),
335
+ maxPageSize: z.number().int().positive(),
336
+ eventReplay: z.literal(true),
337
+ idempotencyCacheEntries: z.number().int().positive(),
338
+ maxAttachmentBytes: z.number().int().positive(),
339
+ maxAttachmentChunkBytes: z.number().int().positive(),
340
+ maxTurnAttachments: z.number().int().positive(),
341
+ maxStagedAttachments: z.number().int().positive(),
342
+ })
343
+ .strict()
344
+ .readonly();
345
+ export const runtimeLimitsSchema = z.union([
346
+ runtimeLimitsV14Schema,
347
+ runtimeLimitsV13Schema,
348
+ runtimeLimitsV12Schema,
349
+ ]);
283
350
  export const initializeParamsSchema = z
284
351
  .object({
285
352
  protocolVersions: z.array(z.string().min(1)).min(1),
@@ -290,7 +357,12 @@ export const initializeParamsSchema = z
290
357
  const initializeResultCommonFields = {
291
358
  runtimeInstanceId: runtimeInstanceIdSchema,
292
359
  server: runtimeServerInfoSchema,
293
- features: z.array(z.enum(RUNTIME_FEATURES)),
360
+ features: z.array(z.enum(RUNTIME_FEATURES_V13)),
361
+ };
362
+ const initializeResultV14Fields = {
363
+ runtimeInstanceId: runtimeInstanceIdSchema,
364
+ server: runtimeServerInfoSchema,
365
+ features: z.array(z.enum(RUNTIME_FEATURES_V14)),
294
366
  };
295
367
  /** Runtime Protocol 1.1/1.0 initialize result. Keep this schema frozen. */
296
368
  export const initializeResultV11Schema = z
@@ -318,8 +390,17 @@ export const initializeResultV13Schema = z
318
390
  })
319
391
  .strict()
320
392
  .readonly();
393
+ export const initializeResultV14Schema = z
394
+ .object({
395
+ protocolVersion: z.literal("1.4"),
396
+ ...initializeResultV14Fields,
397
+ limits: runtimeLimitsV14Schema,
398
+ })
399
+ .strict()
400
+ .readonly();
321
401
  /** Any currently supported Runtime Protocol initialize result. */
322
402
  export const initializeResultSchema = z.union([
403
+ initializeResultV14Schema,
323
404
  initializeResultV13Schema,
324
405
  initializeResultV12Schema,
325
406
  initializeResultV11Schema,
@@ -389,6 +470,20 @@ export const uiMessagePartSchema = z
389
470
  })
390
471
  .strict()
391
472
  .readonly();
473
+ /**
474
+ * Safe attachment metadata inside a projected message. Carries no binary content and no
475
+ * filesystem path; bytes are derived from the persisted model message.
476
+ */
477
+ export const uiMessageAttachmentPartSchema = z
478
+ .object({
479
+ type: z.literal("attachment"),
480
+ mediaType: z.string().min(1),
481
+ bytes: z.number().int().nonnegative(),
482
+ displayName: z.string().min(1).max(ATTACHMENT_FILE_NAME_MAX_CHARS).optional(),
483
+ })
484
+ .strict()
485
+ .readonly();
486
+ export const uiMessagePartV14Schema = z.union([uiMessagePartSchema, uiMessageAttachmentPartSchema]);
392
487
  export const uiMessageSchema = z
393
488
  .object({
394
489
  sequence: z.number().int().nonnegative(),
@@ -398,6 +493,15 @@ export const uiMessageSchema = z
398
493
  })
399
494
  .strict()
400
495
  .readonly();
496
+ export const uiMessageV14Schema = z
497
+ .object({
498
+ sequence: z.number().int().nonnegative(),
499
+ role: z.enum(["user", "assistant"]),
500
+ createdAt: timestampSchema,
501
+ parts: z.array(uiMessagePartV14Schema),
502
+ })
503
+ .strict()
504
+ .readonly();
401
505
  export const toolOutcomeSchema = z
402
506
  .object({
403
507
  kind: z.enum(TOOL_OUTCOME_KINDS),
@@ -454,6 +558,13 @@ export const messagePageSchema = z
454
558
  })
455
559
  .strict()
456
560
  .readonly();
561
+ export const messagePageV14Schema = z
562
+ .object({
563
+ items: z.array(uiMessageV14Schema),
564
+ nextBeforeSequence: z.number().int().nonnegative().nullable(),
565
+ })
566
+ .strict()
567
+ .readonly();
457
568
  export const operationPageSchema = z
458
569
  .object({
459
570
  items: z.array(operationViewSchema),
@@ -790,8 +901,20 @@ export const threadSnapshotV13Schema = z.union([
790
901
  threadSnapshotV13FullSchema,
791
902
  threadRecoverySnapshotV13Schema,
792
903
  ]);
904
+ export const threadSnapshotV14FullSchema = z
905
+ .object({
906
+ ...threadSnapshotV12Fields,
907
+ messages: messagePageV14Schema,
908
+ eventCursor: runtimeEventCursorSchema.nullable(),
909
+ })
910
+ .strict()
911
+ .readonly();
912
+ export const threadSnapshotV14Schema = z.union([
913
+ threadSnapshotV14FullSchema,
914
+ threadRecoverySnapshotV13Schema,
915
+ ]);
793
916
  /** Latest Runtime Protocol snapshot. Use versioned schemas for compatibility. */
794
- export const threadSnapshotSchema = threadSnapshotV13Schema;
917
+ export const threadSnapshotSchema = threadSnapshotV14Schema;
795
918
  const pageSizeSchema = z.number().int().min(1).max(500).default(100);
796
919
  const requestFields = { requestId: requestIdSchema };
797
920
  const threadRequestFields = { threadId: threadIdSchema };
@@ -898,6 +1021,105 @@ export const threadCapabilitiesResultSchema = z
898
1021
  })
899
1022
  .strict()
900
1023
  .readonly();
1024
+ export const attachmentSourceSchema = z.enum(ATTACHMENT_SOURCES);
1025
+ export const attachmentMediaTypeSchema = z.enum(SUPPORTED_ATTACHMENT_MEDIA_TYPES);
1026
+ export const attachmentSha256Schema = z.string().regex(/^[a-f0-9]{64}$/u);
1027
+ export const attachmentFileNameSchema = z.string().min(1).max(ATTACHMENT_FILE_NAME_MAX_CHARS);
1028
+ export const ATTACHMENT_STATES = ["staged", "committed"];
1029
+ export const attachmentStateSchema = z.enum(ATTACHMENT_STATES);
1030
+ /**
1031
+ * Safe attachment metadata. Never carries client filesystem paths or inline binary content; the
1032
+ * displayName is a server-sanitized rendering of the client-declared fileName.
1033
+ */
1034
+ export const attachmentDescriptorSchema = z
1035
+ .object({
1036
+ attachmentId: attachmentIdSchema,
1037
+ fileName: attachmentFileNameSchema,
1038
+ displayName: attachmentFileNameSchema,
1039
+ mediaType: attachmentMediaTypeSchema,
1040
+ bytes: z.number().int().positive().max(RUNTIME_V14_MAX_ATTACHMENT_BYTES),
1041
+ sha256: attachmentSha256Schema,
1042
+ source: attachmentSourceSchema,
1043
+ createdAt: timestampSchema,
1044
+ })
1045
+ .strict()
1046
+ .readonly();
1047
+ export const attachmentStageParamsSchema = z
1048
+ .object({
1049
+ ...requestFields,
1050
+ ...threadRequestFields,
1051
+ fileName: attachmentFileNameSchema,
1052
+ mediaType: attachmentMediaTypeSchema,
1053
+ bytes: z.number().int().positive().max(RUNTIME_V14_MAX_ATTACHMENT_BYTES),
1054
+ sha256: attachmentSha256Schema,
1055
+ source: attachmentSourceSchema,
1056
+ sourcePath: z.string().min(1).optional(),
1057
+ })
1058
+ .strict()
1059
+ .refine((params) => (params.source === "local-path" ? params.sourcePath !== undefined : true), {
1060
+ message: "source 为 local-path 时必须提供 sourcePath",
1061
+ })
1062
+ .refine((params) => (params.source === "chunks" ? params.sourcePath === undefined : true), {
1063
+ message: "source 为 chunks 时不能提供 sourcePath",
1064
+ })
1065
+ .readonly();
1066
+ export const attachmentStageResultSchema = z
1067
+ .object({
1068
+ attachmentId: attachmentIdSchema,
1069
+ state: attachmentStateSchema,
1070
+ descriptor: attachmentDescriptorSchema.optional(),
1071
+ })
1072
+ .strict()
1073
+ .readonly();
1074
+ export const attachmentChunkParamsSchema = z
1075
+ .object({
1076
+ ...requestFields,
1077
+ ...threadRequestFields,
1078
+ attachmentId: attachmentIdSchema,
1079
+ sequence: z.number().int().nonnegative(),
1080
+ dataBase64: z
1081
+ .string()
1082
+ .min(1)
1083
+ .max(Math.ceil(RUNTIME_V14_MAX_ATTACHMENT_CHUNK_BYTES / 3) * 4 + 4)
1084
+ .regex(/^[A-Za-z0-9+/]+={0,2}$/u),
1085
+ })
1086
+ .strict()
1087
+ .readonly();
1088
+ export const attachmentChunkResultSchema = z
1089
+ .object({
1090
+ receivedBytes: z.number().int().nonnegative(),
1091
+ nextSequence: z.number().int().nonnegative(),
1092
+ })
1093
+ .strict()
1094
+ .readonly();
1095
+ export const attachmentCommitParamsSchema = z
1096
+ .object({
1097
+ ...requestFields,
1098
+ ...threadRequestFields,
1099
+ attachmentId: attachmentIdSchema,
1100
+ })
1101
+ .strict()
1102
+ .readonly();
1103
+ export const attachmentCommitResultSchema = z
1104
+ .object({
1105
+ descriptor: attachmentDescriptorSchema,
1106
+ })
1107
+ .strict()
1108
+ .readonly();
1109
+ export const attachmentReleaseParamsSchema = z
1110
+ .object({
1111
+ ...requestFields,
1112
+ ...threadRequestFields,
1113
+ attachmentId: attachmentIdSchema,
1114
+ })
1115
+ .strict()
1116
+ .readonly();
1117
+ export const attachmentReleaseResultSchema = z
1118
+ .object({
1119
+ released: z.boolean(),
1120
+ })
1121
+ .strict()
1122
+ .readonly();
901
1123
  export const turnStartParamsSchema = z
902
1124
  .object({
903
1125
  ...requestFields,
@@ -912,6 +1134,28 @@ export const turnStartParamsSchema = z
912
1134
  })
913
1135
  .strict()
914
1136
  .readonly();
1137
+ export const turnStartParamsV14Schema = z
1138
+ .object({
1139
+ ...requestFields,
1140
+ ...threadRequestFields,
1141
+ turnId: turnIdSchema,
1142
+ input: z
1143
+ .object({
1144
+ text: z.string(),
1145
+ attachments: z
1146
+ .array(attachmentIdSchema)
1147
+ .min(1)
1148
+ .max(RUNTIME_V14_MAX_TURN_ATTACHMENTS)
1149
+ .optional(),
1150
+ })
1151
+ .strict()
1152
+ .refine((input) => input.text.length > 0 || input.attachments !== undefined, {
1153
+ message: "input.text 为空时必须至少引用一个附件",
1154
+ })
1155
+ .readonly(),
1156
+ })
1157
+ .strict()
1158
+ .readonly();
915
1159
  export const turnStartResultSchema = z
916
1160
  .object({
917
1161
  accepted: z.literal(true),
@@ -1252,8 +1496,35 @@ export const runtimeEventEnvelopeV13Schema = z.discriminatedUnion("durability",
1252
1496
  runtimeDurableEventEnvelopeV13Schema,
1253
1497
  runtimeEphemeralEventEnvelopeV13Schema,
1254
1498
  ]);
1499
+ export const runtimeDurableEventEnvelopeV14Schema = z
1500
+ .object({
1501
+ protocolVersion: z.literal("1.4"),
1502
+ ...runtimeEventEnvelopeFields,
1503
+ durability: z.literal("durable"),
1504
+ eventId: runtimeEventIdSchema,
1505
+ cursor: runtimeEventCursorSchema,
1506
+ event: runtimeDurableEventV13Schema,
1507
+ })
1508
+ .strict()
1509
+ .superRefine(validateRuntimeEventCapabilities)
1510
+ .readonly();
1511
+ export const runtimeEphemeralEventEnvelopeV14Schema = z
1512
+ .object({
1513
+ protocolVersion: z.literal("1.4"),
1514
+ ...runtimeEventEnvelopeFields,
1515
+ durability: z.literal("ephemeral"),
1516
+ event: runtimeEphemeralEventV13Schema,
1517
+ })
1518
+ .strict()
1519
+ .superRefine(validateRuntimeEventCapabilities)
1520
+ .readonly();
1521
+ export const runtimeEventEnvelopeV14Schema = z.discriminatedUnion("durability", [
1522
+ runtimeDurableEventEnvelopeV14Schema,
1523
+ runtimeEphemeralEventEnvelopeV14Schema,
1524
+ ]);
1255
1525
  /** Any currently supported Runtime Event envelope. */
1256
1526
  export const runtimeEventEnvelopeSchema = z.union([
1527
+ runtimeEventEnvelopeV14Schema,
1257
1528
  runtimeEventEnvelopeV13Schema,
1258
1529
  runtimeEventEnvelopeV12Schema,
1259
1530
  runtimeEventEnvelopeV11Schema,
@@ -1284,6 +1555,14 @@ export const runtimeProtocolErrorDataV13Schema = z
1284
1555
  })
1285
1556
  .strict()
1286
1557
  .readonly();
1558
+ export const runtimeProtocolErrorDataV14Schema = z
1559
+ .object({
1560
+ rollCode: z.enum(Object.values(RUNTIME_ERROR_CODES_V14)),
1561
+ retryable: z.boolean(),
1562
+ details: jsonValueSchema.optional(),
1563
+ })
1564
+ .strict()
1565
+ .readonly();
1287
1566
  export const runtimeMethodSchemasV11 = {
1288
1567
  [RUNTIME_METHODS.initialize]: {
1289
1568
  params: initializeParamsSchema,
@@ -1366,19 +1645,54 @@ export const runtimeMethodSchemasV13 = {
1366
1645
  },
1367
1646
  [RUNTIME_METHODS.threadOpen]: {
1368
1647
  params: threadOpenParamsSchema,
1369
- result: threadOpenResultSchema,
1648
+ result: threadSnapshotV13Schema,
1370
1649
  },
1371
1650
  [RUNTIME_METHODS.threadSnapshot]: {
1372
1651
  params: threadSnapshotParamsV13Schema,
1373
- result: threadSnapshotResultSchema,
1652
+ result: threadSnapshotV13Schema,
1374
1653
  },
1375
1654
  [RUNTIME_METHODS.runtimeEventsResume]: {
1376
1655
  params: runtimeEventsResumeParamsSchema,
1377
1656
  result: runtimeEventsResumeResultSchema,
1378
1657
  },
1379
1658
  };
1659
+ export const runtimeMethodSchemasV14 = {
1660
+ ...runtimeMethodSchemasV13,
1661
+ [RUNTIME_METHODS.initialize]: {
1662
+ params: initializeParamsSchema,
1663
+ result: initializeResultV14Schema,
1664
+ },
1665
+ [RUNTIME_METHODS.threadOpen]: {
1666
+ params: threadOpenParamsSchema,
1667
+ result: threadSnapshotV14Schema,
1668
+ },
1669
+ [RUNTIME_METHODS.threadSnapshot]: {
1670
+ params: threadSnapshotParamsV13Schema,
1671
+ result: threadSnapshotV14Schema,
1672
+ },
1673
+ [RUNTIME_METHODS.turnStart]: {
1674
+ params: turnStartParamsV14Schema,
1675
+ result: turnStartResultSchema,
1676
+ },
1677
+ [RUNTIME_METHODS.attachmentStage]: {
1678
+ params: attachmentStageParamsSchema,
1679
+ result: attachmentStageResultSchema,
1680
+ },
1681
+ [RUNTIME_METHODS.attachmentChunk]: {
1682
+ params: attachmentChunkParamsSchema,
1683
+ result: attachmentChunkResultSchema,
1684
+ },
1685
+ [RUNTIME_METHODS.attachmentCommit]: {
1686
+ params: attachmentCommitParamsSchema,
1687
+ result: attachmentCommitResultSchema,
1688
+ },
1689
+ [RUNTIME_METHODS.attachmentRelease]: {
1690
+ params: attachmentReleaseParamsSchema,
1691
+ result: attachmentReleaseResultSchema,
1692
+ },
1693
+ };
1380
1694
  /** Latest Runtime method registry. Use the version registry for negotiated availability. */
1381
- export const runtimeMethodSchemas = runtimeMethodSchemasV13;
1695
+ export const runtimeMethodSchemas = runtimeMethodSchemasV14;
1382
1696
  export const runtimeServerRequestSchemasV10 = {};
1383
1697
  export const runtimeServerRequestSchemasV11 = {
1384
1698
  [RUNTIME_SERVER_REQUEST_METHODS.approvalRequest]: {
@@ -1400,6 +1714,14 @@ export const runtimeServerRequestSchemasV13 = runtimeServerRequestSchemasV12;
1400
1714
  /** Protocol 1.1 compatibility facade. Prefer the version registry in new code. */
1401
1715
  export const runtimeServerRequestSchemas = runtimeServerRequestSchemasV11;
1402
1716
  export const RUNTIME_PROTOCOL_REGISTRY = {
1717
+ "1.4": {
1718
+ methods: runtimeMethodSchemasV14,
1719
+ serverRequests: runtimeServerRequestSchemasV13,
1720
+ serverRequestMethods: RUNTIME_SERVER_REQUEST_METHOD_VALUES,
1721
+ serverRequestCancelParamsSchema: runtimeServerRequestCancelParamsV12Schema,
1722
+ eventEnvelopeSchema: runtimeEventEnvelopeV14Schema,
1723
+ errorDataSchema: runtimeProtocolErrorDataV14Schema,
1724
+ },
1403
1725
  "1.3": {
1404
1726
  methods: runtimeMethodSchemasV13,
1405
1727
  serverRequests: runtimeServerRequestSchemasV13,
@@ -1632,8 +1954,36 @@ export function parseRuntimeMethodParams(method, value) {
1632
1954
  export function parseRuntimeMethodResult(method, value) {
1633
1955
  return runtimeMethodSchemasV11[method].result.parse(value);
1634
1956
  }
1957
+ export function parseLatestRuntimeMethodParams(method, value) {
1958
+ return runtimeMethodSchemas[method].params.parse(value);
1959
+ }
1960
+ export function parseLatestRuntimeMethodResult(method, value) {
1961
+ return runtimeMethodSchemas[method].result.parse(value);
1962
+ }
1963
+ function projectUiMessagePageToTextParts(page) {
1964
+ return {
1965
+ items: page.items.map((message) => ({
1966
+ ...message,
1967
+ parts: message.parts.filter((part) => part.type === "text"),
1968
+ })),
1969
+ nextBeforeSequence: page.nextBeforeSequence,
1970
+ };
1971
+ }
1635
1972
  export function projectThreadSnapshotForVersion(version, value) {
1636
- const latest = threadSnapshotV13Schema.safeParse(value);
1973
+ const latestV14 = threadSnapshotV14Schema.safeParse(value);
1974
+ if (version === "1.4") {
1975
+ if (!latestV14.success) {
1976
+ throw latestV14.error;
1977
+ }
1978
+ return latestV14.data;
1979
+ }
1980
+ const v13Candidate = latestV14.success && !("recoveryProjection" in latestV14.data)
1981
+ ? {
1982
+ ...latestV14.data,
1983
+ messages: projectUiMessagePageToTextParts(latestV14.data.messages),
1984
+ }
1985
+ : value;
1986
+ const latest = threadSnapshotV13Schema.safeParse(v13Candidate);
1637
1987
  if (version === "1.3") {
1638
1988
  if (!latest.success) {
1639
1989
  throw latest.error;
@@ -1650,7 +2000,7 @@ export function projectThreadSnapshotForVersion(version, value) {
1650
2000
  pendingInteractions: latest.data.pendingInteractions,
1651
2001
  transcriptCompleteness: latest.data.transcriptCompleteness,
1652
2002
  })
1653
- : threadSnapshotV12Schema.parse(value);
2003
+ : threadSnapshotV12Schema.parse(v13Candidate);
1654
2004
  if (version === "1.2") {
1655
2005
  return v12;
1656
2006
  }
@@ -1672,8 +2022,17 @@ export function projectThreadSnapshotForVersion(version, value) {
1672
2022
  }
1673
2023
  export function projectRuntimeEventEnvelopeForVersion(version, value) {
1674
2024
  const source = runtimeEventEnvelopeSchema.parse(value);
2025
+ if (version === "1.4") {
2026
+ return runtimeEventEnvelopeV14Schema.parse({
2027
+ ...source,
2028
+ protocolVersion: version,
2029
+ });
2030
+ }
1675
2031
  if (version === "1.3") {
1676
- return runtimeEventEnvelopeV13Schema.parse(source);
2032
+ return runtimeEventEnvelopeV13Schema.parse({
2033
+ ...source,
2034
+ protocolVersion: version,
2035
+ });
1677
2036
  }
1678
2037
  const projectedEnvelopeFields = {
1679
2038
  runtimeInstanceId: source.runtimeInstanceId,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://roll-agent.dev/schemas/runtime-protocol/1.0",
3
+ "$id": "urn:roll-agent:schema:runtime-protocol:1.0",
4
4
  "title": "Roll Runtime Protocol v1.0",
5
5
  "description": "Bidirectional JSON-RPC requests, responses, and notifications for Roll Runtime Protocol.",
6
6
  "oneOf": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://roll-agent.dev/schemas/runtime-protocol/1.1",
3
+ "$id": "urn:roll-agent:schema:runtime-protocol:1.1",
4
4
  "title": "Roll Runtime Protocol v1.1",
5
5
  "description": "Bidirectional JSON-RPC requests, responses, and notifications for Roll Runtime Protocol.",
6
6
  "oneOf": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://roll-agent.dev/schemas/runtime-protocol/1.2",
3
+ "$id": "urn:roll-agent:schema:runtime-protocol:1.2",
4
4
  "title": "Roll Runtime Protocol v1.2",
5
5
  "description": "Bidirectional JSON-RPC requests, responses, and notifications for Roll Runtime Protocol.",
6
6
  "oneOf": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://roll-agent.dev/schemas/runtime-protocol/1.3",
3
+ "$id": "urn:roll-agent:schema:runtime-protocol:1.3",
4
4
  "title": "Roll Runtime Protocol v1.3",
5
5
  "description": "Bidirectional JSON-RPC requests, responses, and notifications for Roll Runtime Protocol.",
6
6
  "oneOf": [