@roll-agent/protocol 0.9.0 → 0.10.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
@@ -253,22 +253,29 @@ export const TOOL_OUTCOME_KINDS = [
253
253
  "cancelled",
254
254
  "tool_failed",
255
255
  ];
256
- export const threadIdSchema = z.string().uuid().brand();
257
- export const turnIdSchema = z.string().uuid().brand();
258
- export const approvalIdSchema = z.string().uuid().brand();
259
- export const interactionIdSchema = z.string().uuid().brand();
260
- export const runtimeInstanceIdSchema = z.string().uuid().brand();
261
- export const requestIdSchema = z.string().uuid().brand();
262
- export const streamIdSchema = z.string().uuid().brand();
263
- export const operationIdSchema = z.string().uuid().brand();
264
- export const runtimeEventIdSchema = z.string().uuid().brand();
265
- export const attachmentIdSchema = z.string().uuid().brand();
256
+ // Wire formats are owned by Protocol: dependency upgrades must not broaden UUIDs or
257
+ // reject timestamps that existing clients could send (including minute precision).
258
+ export const uuidSchema = z
259
+ .string()
260
+ .check(z.stringFormat("uuid", /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/));
261
+ export const timestampSchema = z
262
+ .string()
263
+ .check(z.stringFormat("datetime", /^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-]\d{2}:\d{2})))$/));
264
+ export const threadIdSchema = uuidSchema.clone().brand();
265
+ export const turnIdSchema = uuidSchema.clone().brand();
266
+ export const approvalIdSchema = uuidSchema.clone().brand();
267
+ export const interactionIdSchema = uuidSchema.clone().brand();
268
+ export const runtimeInstanceIdSchema = uuidSchema.clone().brand();
269
+ export const requestIdSchema = uuidSchema.clone().brand();
270
+ export const streamIdSchema = uuidSchema.clone().brand();
271
+ export const operationIdSchema = uuidSchema.clone().brand();
272
+ export const runtimeEventIdSchema = uuidSchema.clone().brand();
273
+ export const attachmentIdSchema = uuidSchema.clone().brand();
266
274
  export const runtimeEventCursorSchema = z
267
275
  .string()
268
276
  .max(128)
269
277
  .regex(/^rte1:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}:(?:0|[1-9]\d*):[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/u)
270
278
  .brand();
271
- export const timestampSchema = z.string().datetime({ offset: true });
272
279
  export const jsonValueSchema = z.json();
273
280
  export const jsonRpcIdSchema = z.union([z.string(), z.number()]);
274
281
  export const runtimeProtocolVersionSchema = z.enum(SUPPORTED_RUNTIME_PROTOCOL_VERSIONS);
@@ -934,14 +941,8 @@ const recoveryThreadSummarySchema = z
934
941
  id: threadIdSchema,
935
942
  title: z.string().max(RUNTIME_V13_RECOVERY_SNAPSHOT_METADATA_MAX_CHARS).optional(),
936
943
  model: z.string().max(RUNTIME_V13_RECOVERY_SNAPSHOT_METADATA_MAX_CHARS).optional(),
937
- createdAt: z
938
- .string()
939
- .max(RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS)
940
- .datetime({ offset: true }),
941
- updatedAt: z
942
- .string()
943
- .max(RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS)
944
- .datetime({ offset: true }),
944
+ createdAt: timestampSchema.max(RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS),
945
+ updatedAt: timestampSchema.max(RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS),
945
946
  messageCount: z.number().int().nonnegative(),
946
947
  })
947
948
  .strict()
@@ -964,10 +965,7 @@ const recoveryActiveTurnSchema = z
964
965
  .object({
965
966
  id: turnIdSchema,
966
967
  status: z.enum(["running", "cancelling", "waiting-for-user"]),
967
- startedAt: z
968
- .string()
969
- .max(RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS)
970
- .datetime({ offset: true }),
968
+ startedAt: timestampSchema.max(RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS),
971
969
  })
972
970
  .strict()
973
971
  .readonly();
@@ -1016,7 +1014,7 @@ export const threadSnapshotV15Schema = z.union([
1016
1014
  /** Bounded Harness state only; no model-authored recovery notes or fact contents cross the wire. */
1017
1015
  export const contextRecoveryViewSchema = z
1018
1016
  .object({
1019
- checkpointId: z.string().uuid(),
1017
+ checkpointId: uuidSchema.clone(),
1020
1018
  required: z.boolean(),
1021
1019
  unextracted: z.boolean(),
1022
1020
  requiredItemCount: z.number().int().nonnegative(),
@@ -1744,16 +1742,27 @@ export const runtimeEventEnvelopeV15Schema = z.discriminatedUnion("durability",
1744
1742
  runtimeEphemeralEventEnvelopeV15Schema,
1745
1743
  ]);
1746
1744
  /** Any currently supported Runtime Event envelope. */
1747
- export const runtimeDurableEventEnvelopeV16Schema = runtimeDurableEventEnvelopeV15Schema.def.innerType
1748
- .extend({
1745
+ export const runtimeDurableEventEnvelopeV16Schema = z
1746
+ .object({
1749
1747
  protocolVersion: z.literal("1.6"),
1748
+ ...runtimeEventEnvelopeFields,
1749
+ durability: z.literal("durable"),
1750
+ eventId: runtimeEventIdSchema,
1751
+ cursor: runtimeEventCursorSchema,
1750
1752
  event: runtimeDurableEventV16Schema,
1751
1753
  })
1754
+ .strict()
1755
+ .superRefine(validateRuntimeEventCapabilities)
1752
1756
  .readonly();
1753
- export const runtimeEphemeralEventEnvelopeV16Schema = runtimeEphemeralEventEnvelopeV15Schema.def.innerType
1754
- .extend({
1757
+ export const runtimeEphemeralEventEnvelopeV16Schema = z
1758
+ .object({
1755
1759
  protocolVersion: z.literal("1.6"),
1760
+ ...runtimeEventEnvelopeFields,
1761
+ durability: z.literal("ephemeral"),
1762
+ event: runtimeEphemeralEventV13Schema,
1756
1763
  })
1764
+ .strict()
1765
+ .superRefine(validateRuntimeEventCapabilities)
1757
1766
  .readonly();
1758
1767
  export const runtimeEventEnvelopeV16Schema = z.discriminatedUnion("durability", [
1759
1768
  runtimeDurableEventEnvelopeV16Schema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roll-agent/protocol",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "fixtures"
43
43
  ],
44
44
  "dependencies": {
45
- "zod": "3.25.76"
45
+ "zod": "4.6.6"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^22.0.0",