@roll-agent/relay-protocol 0.4.2 → 0.5.1

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.
Files changed (35) hide show
  1. package/README.md +4 -0
  2. package/dist/control.d.ts +52 -21
  3. package/dist/control.js +8 -1
  4. package/dist/index.d.ts +2781 -890
  5. package/dist/index.js +96 -6
  6. package/dist/schema/roll-relay-protocol-v1.3.schema.json +4606 -0
  7. package/fixtures/v1.3/invalid-approval-projection-raw-input-leak.json +19 -0
  8. package/fixtures/v1.3/invalid-authentication-local-only.json +12 -0
  9. package/fixtures/v1.3/invalid-context-recovery-notes.json +22 -0
  10. package/fixtures/v1.3/invalid-file-picker-local-only.json +12 -0
  11. package/fixtures/v1.3/invalid-interaction-cancelled-reason-leak.json +10 -0
  12. package/fixtures/v1.3/invalid-interaction-resolved-result-leak.json +18 -0
  13. package/fixtures/v1.3/invalid-legacy-approval-candidate.json +7 -0
  14. package/fixtures/v1.3/invalid-legacy-approval-respond.json +7 -0
  15. package/fixtures/v1.3/invalid-n-minus-one-device-connect.json +6 -0
  16. package/fixtures/v1.3/invalid-non-normal-sensitivity.json +21 -0
  17. package/fixtures/v1.3/invalid-runtime-event-tool-input-leak.json +22 -0
  18. package/fixtures/v1.3/invalid-runtime-event-tool-output-leak.json +21 -0
  19. package/fixtures/v1.3/invalid-user-input-projection-secret-leak.json +22 -0
  20. package/fixtures/v1.3/manifest.json +489 -0
  21. package/fixtures/v1.3/valid-context-recovery.json +21 -0
  22. package/fixtures/v1.3/valid-device-connect.json +6 -0
  23. package/fixtures/v1.3/valid-interaction-cancelled.json +9 -0
  24. package/fixtures/v1.3/valid-interaction-candidate-user-input.json +25 -0
  25. package/fixtures/v1.3/valid-interaction-request-approval.json +17 -0
  26. package/fixtures/v1.3/valid-interaction-request-user-input.json +40 -0
  27. package/fixtures/v1.3/valid-interaction-resolved.json +9 -0
  28. package/fixtures/v1.3/valid-runtime-ack.json +5 -0
  29. package/fixtures/v1.3/valid-runtime-encrypted-interaction.json +10 -0
  30. package/fixtures/v1.3/valid-runtime-event-runtime-n-minus-one.json +16 -0
  31. package/fixtures/v1.3/valid-runtime-event.json +16 -0
  32. package/fixtures/v1.3/valid-runtime-gap.json +7 -0
  33. package/fixtures/v1.3/valid-runtime-request.json +10 -0
  34. package/fixtures/v1.3/valid-runtime-response.json +8 -0
  35. package/package.json +5 -4
package/README.md CHANGED
@@ -165,3 +165,7 @@ Relay 不能为了获得 Wire Schema 而安装 `@roll-agent/companion`。
165
165
 
166
166
  Relay `requestId`、逻辑 `interactionId`、Runtime JSON-RPC `id`、Runtime mutation
167
167
  `requestId` 与 Relay `relaySequence` 是不同的类型和生命周期,不能互相复用。
168
+
169
+ ### Wire 1.3 context recovery
170
+
171
+ Wire 1.3 adds bounded `contextRecovery` snapshots and `context.recovery.changed` timeline events. It retains 1.2 App output semantics. The 1.0/1.1/1.2 wire schemas remain frozen; downgrade maps recovery events to `capabilities.changed` while preserving Relay sequence continuity. This package does not upgrade a deployed cloud Relay service.
package/dist/control.d.ts CHANGED
@@ -36,7 +36,7 @@ export declare const relayClientErrorCodeSchema: z.ZodEnum<{
36
36
  RATE_LIMITED: "RATE_LIMITED";
37
37
  RELAY_INTERNAL_ERROR: "RELAY_INTERNAL_ERROR";
38
38
  }>;
39
- export declare const relayBrowserSessionIdSchema: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
39
+ export declare const relayBrowserSessionIdSchema: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
40
40
  export declare const relaySessionDescriptorSchema: z.ZodReadonly<z.ZodObject<{
41
41
  connectUrl: z.ZodString;
42
42
  expiresAt: z.ZodString;
@@ -56,8 +56,8 @@ export declare const relaySessionReadyControlMessageSchema: z.ZodReadonly<z.ZodO
56
56
  type: z.ZodLiteral<"session.ready">;
57
57
  controlVersion: z.ZodLiteral<"1.0">;
58
58
  relayProtocolVersion: z.ZodLiteral<"1.1">;
59
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
60
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
59
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
60
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
61
61
  workspaceStatus: z.ZodEnum<{
62
62
  online: "online";
63
63
  offline: "offline";
@@ -66,20 +66,41 @@ export declare const relaySessionReadyControlMessageSchema: z.ZodReadonly<z.ZodO
66
66
  export declare const relaySessionReadyControlMessageSchemaV12: z.ZodReadonly<z.ZodObject<{
67
67
  type: z.ZodLiteral<"session.ready">;
68
68
  controlVersion: z.ZodLiteral<"1.0">;
69
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
70
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
69
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
70
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
71
71
  workspaceStatus: z.ZodEnum<{
72
72
  online: "online";
73
73
  offline: "offline";
74
74
  }>;
75
75
  relayProtocolVersion: z.ZodLiteral<"1.2">;
76
76
  }, z.core.$strict>>;
77
+ export declare const relaySessionReadyControlMessageSchemaV13: z.ZodReadonly<z.ZodObject<{
78
+ type: z.ZodLiteral<"session.ready">;
79
+ controlVersion: z.ZodLiteral<"1.0">;
80
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
81
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
82
+ workspaceStatus: z.ZodEnum<{
83
+ online: "online";
84
+ offline: "offline";
85
+ }>;
86
+ relayProtocolVersion: z.ZodLiteral<"1.3">;
87
+ }, z.core.$strict>>;
77
88
  export declare const relaySessionReadyControlMessageSchemaAny: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
89
+ type: z.ZodLiteral<"session.ready">;
90
+ controlVersion: z.ZodLiteral<"1.0">;
91
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
92
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
93
+ workspaceStatus: z.ZodEnum<{
94
+ online: "online";
95
+ offline: "offline";
96
+ }>;
97
+ relayProtocolVersion: z.ZodLiteral<"1.3">;
98
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
78
99
  type: z.ZodLiteral<"session.ready">;
79
100
  controlVersion: z.ZodLiteral<"1.0">;
80
101
  relayProtocolVersion: z.ZodLiteral<"1.1">;
81
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
82
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
102
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
103
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
83
104
  workspaceStatus: z.ZodEnum<{
84
105
  online: "online";
85
106
  offline: "offline";
@@ -87,8 +108,8 @@ export declare const relaySessionReadyControlMessageSchemaAny: z.ZodUnion<readon
87
108
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
88
109
  type: z.ZodLiteral<"session.ready">;
89
110
  controlVersion: z.ZodLiteral<"1.0">;
90
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
91
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
111
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
112
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
92
113
  workspaceStatus: z.ZodEnum<{
93
114
  online: "online";
94
115
  offline: "offline";
@@ -97,7 +118,7 @@ export declare const relaySessionReadyControlMessageSchemaAny: z.ZodUnion<readon
97
118
  }, z.core.$strict>>]>;
98
119
  export declare const relayWorkspaceStatusControlMessageSchema: z.ZodReadonly<z.ZodObject<{
99
120
  type: z.ZodLiteral<"workspace.status">;
100
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
121
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
101
122
  status: z.ZodEnum<{
102
123
  online: "online";
103
124
  offline: "offline";
@@ -116,11 +137,21 @@ export declare const relaySessionErrorControlMessageSchema: z.ZodReadonly<z.ZodO
116
137
  retryable: z.ZodBoolean;
117
138
  }, z.core.$strict>>;
118
139
  export declare const relayBrowserControlMessageSchemaAny: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
140
+ type: z.ZodLiteral<"session.ready">;
141
+ controlVersion: z.ZodLiteral<"1.0">;
142
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
143
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
144
+ workspaceStatus: z.ZodEnum<{
145
+ online: "online";
146
+ offline: "offline";
147
+ }>;
148
+ relayProtocolVersion: z.ZodLiteral<"1.3">;
149
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
119
150
  type: z.ZodLiteral<"session.ready">;
120
151
  controlVersion: z.ZodLiteral<"1.0">;
121
152
  relayProtocolVersion: z.ZodLiteral<"1.1">;
122
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
123
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
153
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
154
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
124
155
  workspaceStatus: z.ZodEnum<{
125
156
  online: "online";
126
157
  offline: "offline";
@@ -128,8 +159,8 @@ export declare const relayBrowserControlMessageSchemaAny: z.ZodUnion<readonly [z
128
159
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
129
160
  type: z.ZodLiteral<"session.ready">;
130
161
  controlVersion: z.ZodLiteral<"1.0">;
131
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
132
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
162
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
163
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
133
164
  workspaceStatus: z.ZodEnum<{
134
165
  online: "online";
135
166
  offline: "offline";
@@ -137,7 +168,7 @@ export declare const relayBrowserControlMessageSchemaAny: z.ZodUnion<readonly [z
137
168
  relayProtocolVersion: z.ZodLiteral<"1.2">;
138
169
  }, z.core.$strict>>]>, z.ZodReadonly<z.ZodObject<{
139
170
  type: z.ZodLiteral<"workspace.status">;
140
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
171
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
141
172
  status: z.ZodEnum<{
142
173
  online: "online";
143
174
  offline: "offline";
@@ -158,15 +189,15 @@ export declare const relayBrowserControlMessageSchema: z.ZodDiscriminatedUnion<[
158
189
  type: z.ZodLiteral<"session.ready">;
159
190
  controlVersion: z.ZodLiteral<"1.0">;
160
191
  relayProtocolVersion: z.ZodLiteral<"1.1">;
161
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
162
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
192
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
193
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
163
194
  workspaceStatus: z.ZodEnum<{
164
195
  online: "online";
165
196
  offline: "offline";
166
197
  }>;
167
198
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
168
199
  type: z.ZodLiteral<"workspace.status">;
169
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
200
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
170
201
  status: z.ZodEnum<{
171
202
  online: "online";
172
203
  offline: "offline";
@@ -182,14 +213,14 @@ export declare const relayBrowserControlMessageSchema: z.ZodDiscriminatedUnion<[
182
213
  RELAY_INTERNAL_ERROR: "RELAY_INTERNAL_ERROR";
183
214
  }>;
184
215
  retryable: z.ZodBoolean;
185
- }, z.core.$strict>>]>;
216
+ }, z.core.$strict>>], "type">;
186
217
  /** Browser WebSocket connections must validate their first received frame with this schema. */
187
218
  export declare const relayBrowserFirstControlFrameSchema: z.ZodReadonly<z.ZodObject<{
188
219
  type: z.ZodLiteral<"session.ready">;
189
220
  controlVersion: z.ZodLiteral<"1.0">;
190
221
  relayProtocolVersion: z.ZodLiteral<"1.1">;
191
- sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId">;
192
- workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
222
+ sessionId: z.core.$ZodBranded<z.ZodString, "RelayBrowserSessionId", "out">;
223
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
193
224
  workspaceStatus: z.ZodEnum<{
194
225
  online: "online";
195
226
  offline: "offline";
package/dist/control.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod/v4";
2
+ import { timestampSchema } from "@roll-agent/protocol";
2
3
  import { RELAY_MESSAGE_TYPES_V11, workspaceIdSchema } from "./index.js";
3
4
  export const RELAY_CONTROL_VERSION = "1.0";
4
5
  export const RELAY_BROWSER_PROTOCOL_VERSION = "1.1";
@@ -45,7 +46,7 @@ const secureWebSocketUrlSchema = z
45
46
  export const relaySessionDescriptorSchema = z
46
47
  .object({
47
48
  connectUrl: secureWebSocketUrlSchema,
48
- expiresAt: z.string().datetime({ offset: true }),
49
+ expiresAt: timestampSchema,
49
50
  })
50
51
  .strict()
51
52
  .readonly();
@@ -78,7 +79,13 @@ export const relaySessionReadyControlMessageSchemaV12 = relaySessionReadyControl
78
79
  })
79
80
  .strict()
80
81
  .readonly();
82
+ export const relaySessionReadyControlMessageSchemaV13 = relaySessionReadyControlMessageSchema.def.innerType
83
+ .extend({
84
+ relayProtocolVersion: z.literal("1.3"),
85
+ })
86
+ .readonly();
81
87
  export const relaySessionReadyControlMessageSchemaAny = z.union([
88
+ relaySessionReadyControlMessageSchemaV13,
82
89
  relaySessionReadyControlMessageSchema,
83
90
  relaySessionReadyControlMessageSchemaV12,
84
91
  ]);