@myagentroam/protocol 0.9.67 → 0.9.69

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.
@@ -0,0 +1,330 @@
1
+ import { z } from 'zod';
2
+ const identifierSchema = z
3
+ .string()
4
+ .trim()
5
+ .min(8)
6
+ .max(128)
7
+ .regex(/^[A-Za-z0-9_-]+$/u);
8
+ const resourceIdentifierSchema = z.string().trim().min(1).max(512);
9
+ const relativePathSchema = z.string().min(1).max(4096);
10
+ const safeIntegerSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
11
+ const timestampSchema = z.number().int().positive();
12
+ const sha256Schema = z.string().regex(/^[a-f0-9]{64}$/u);
13
+ const fingerprintSchema = z.string().regex(/^sha-256(?: [A-F0-9]{2}(?::[A-F0-9]{2}){31})$/u);
14
+ const sdpSchema = z
15
+ .string()
16
+ .min(1)
17
+ .max(64 * 1024);
18
+ const candidateSchema = z.string().min(1).max(4096);
19
+ export const workspaceDirectTransferCapabilitySchema = z
20
+ .object({
21
+ apiVersion: z.literal(1),
22
+ probe: z.boolean(),
23
+ upload: z.boolean(),
24
+ download: z.boolean(),
25
+ gitCommitBlob: z.boolean(),
26
+ maxChunkBytes: z
27
+ .number()
28
+ .int()
29
+ .min(16 * 1024)
30
+ .max(1024 * 1024)
31
+ })
32
+ .strict();
33
+ export const directTransferPurposeSchema = z.enum(['PROBE', 'TRANSFER']);
34
+ export const directTransferDirectionSchema = z.enum(['UPLOAD', 'DOWNLOAD']);
35
+ export const directTransferProbeResultSchema = z.enum(['DIRECT_AVAILABLE', 'RELAY_ONLY', 'STALE']);
36
+ const workspaceFileResourceSchema = z
37
+ .object({
38
+ kind: z.literal('WORKSPACE_FILE'),
39
+ workspaceId: resourceIdentifierSchema,
40
+ path: relativePathSchema,
41
+ worktreePath: relativePathSchema.optional()
42
+ })
43
+ .strict();
44
+ const gitCommitBlobResourceSchema = z
45
+ .object({
46
+ kind: z.literal('GIT_COMMIT_BLOB'),
47
+ workspaceId: resourceIdentifierSchema,
48
+ commit: z.string().min(1).max(256),
49
+ path: relativePathSchema,
50
+ repositoryPath: z.string().max(4096).optional(),
51
+ worktreePath: z.string().max(4096).optional()
52
+ })
53
+ .strict();
54
+ export const directTransferResourceSchema = z.discriminatedUnion('kind', [
55
+ workspaceFileResourceSchema,
56
+ gitCommitBlobResourceSchema
57
+ ]);
58
+ export const directTransferDescriptorSchema = z
59
+ .object({
60
+ direction: directTransferDirectionSchema,
61
+ resource: directTransferResourceSchema,
62
+ fileName: z.string().trim().min(1).max(512),
63
+ size: safeIntegerSchema,
64
+ sha256: sha256Schema,
65
+ overwrite: z.boolean().optional(),
66
+ resumeOffset: safeIntegerSchema.optional(),
67
+ composerAttachment: z
68
+ .object({
69
+ id: identifierSchema,
70
+ mime: z.string().trim().min(1).max(256)
71
+ })
72
+ .strict()
73
+ .optional()
74
+ })
75
+ .strict()
76
+ .superRefine((descriptor, context) => {
77
+ if (descriptor.resumeOffset !== undefined && descriptor.resumeOffset > descriptor.size)
78
+ context.addIssue({
79
+ code: 'custom',
80
+ path: ['resumeOffset'],
81
+ message: 'resume offset cannot exceed the file size'
82
+ });
83
+ if (descriptor.direction === 'DOWNLOAD' && descriptor.overwrite !== undefined)
84
+ context.addIssue({
85
+ code: 'custom',
86
+ path: ['overwrite'],
87
+ message: 'download descriptors cannot request overwrite'
88
+ });
89
+ if (descriptor.composerAttachment !== undefined &&
90
+ (descriptor.direction !== 'UPLOAD' || descriptor.resource.kind !== 'WORKSPACE_FILE'))
91
+ context.addIssue({
92
+ code: 'custom',
93
+ path: ['composerAttachment'],
94
+ message: 'composer attachments are supported only for Workspace uploads'
95
+ });
96
+ });
97
+ const directPrepareBaseSchema = z
98
+ .object({
99
+ type: z.literal('direct.prepare'),
100
+ requestId: identifierSchema,
101
+ nodeId: resourceIdentifierSchema,
102
+ nodeGeneration: identifierSchema
103
+ })
104
+ .strict();
105
+ export const directPrepareRequestSchema = z.discriminatedUnion('purpose', [
106
+ directPrepareBaseSchema.extend({ purpose: z.literal('PROBE') }).strict(),
107
+ directPrepareBaseSchema
108
+ .extend({
109
+ purpose: z.literal('TRANSFER'),
110
+ transfer: directTransferDescriptorSchema
111
+ })
112
+ .strict()
113
+ ]);
114
+ export const directIceCandidateSchema = z
115
+ .object({
116
+ candidate: candidateSchema,
117
+ sdpMid: z.string().max(256).nullable(),
118
+ sdpMLineIndex: z.number().int().min(0).max(1024).nullable()
119
+ })
120
+ .strict();
121
+ export const directSignalSchema = z.discriminatedUnion('kind', [
122
+ z
123
+ .object({
124
+ kind: z.literal('OFFER'),
125
+ sdp: sdpSchema,
126
+ fingerprint: fingerprintSchema
127
+ })
128
+ .strict(),
129
+ z
130
+ .object({
131
+ kind: z.literal('ANSWER'),
132
+ sdp: sdpSchema,
133
+ fingerprint: fingerprintSchema
134
+ })
135
+ .strict(),
136
+ z.object({ kind: z.literal('CANDIDATE'), candidate: directIceCandidateSchema }).strict(),
137
+ z.object({ kind: z.literal('END_OF_CANDIDATES') }).strict()
138
+ ]);
139
+ const directSessionIdentitySchema = z
140
+ .object({
141
+ directSessionId: identifierSchema
142
+ })
143
+ .strict();
144
+ export const directBrowserMessageSchema = z.union([
145
+ directPrepareRequestSchema,
146
+ directSessionIdentitySchema
147
+ .extend({ type: z.literal('direct.signal'), signal: directSignalSchema })
148
+ .strict(),
149
+ directSessionIdentitySchema.extend({ type: z.literal('direct.connected') }).strict(),
150
+ directSessionIdentitySchema.extend({ type: z.literal('direct.heartbeat') }).strict(),
151
+ directSessionIdentitySchema
152
+ .extend({
153
+ type: z.literal('direct.complete'),
154
+ size: safeIntegerSchema,
155
+ sha256: sha256Schema
156
+ })
157
+ .strict(),
158
+ directSessionIdentitySchema
159
+ .extend({
160
+ type: z.literal('direct.cancel'),
161
+ reason: z.string().trim().min(1).max(128).optional()
162
+ })
163
+ .strict()
164
+ ]);
165
+ export const directServerMessageSchema = z.discriminatedUnion('type', [
166
+ z
167
+ .object({
168
+ type: z.literal('direct.prepared'),
169
+ requestId: identifierSchema,
170
+ directSessionId: identifierSchema,
171
+ nodeId: resourceIdentifierSchema,
172
+ nodeGeneration: identifierSchema,
173
+ purpose: directTransferPurposeSchema,
174
+ expiresAt: timestampSchema,
175
+ resumeOffset: safeIntegerSchema.optional()
176
+ })
177
+ .strict(),
178
+ directSessionIdentitySchema
179
+ .extend({ type: z.literal('direct.signal'), signal: directSignalSchema })
180
+ .strict(),
181
+ directSessionIdentitySchema
182
+ .extend({
183
+ type: z.literal('direct.grant'),
184
+ grant: z.string().min(32).max(4096),
185
+ openExpiresAt: timestampSchema,
186
+ expiresAt: timestampSchema
187
+ })
188
+ .strict(),
189
+ directSessionIdentitySchema
190
+ .extend({
191
+ type: z.literal('direct.probe-result'),
192
+ result: z.enum(['DIRECT_AVAILABLE', 'RELAY_ONLY']),
193
+ routingHint: z.string().min(8).max(512).optional()
194
+ })
195
+ .strict(),
196
+ directSessionIdentitySchema
197
+ .extend({
198
+ type: z.literal('direct.heartbeat'),
199
+ alive: z.literal(true),
200
+ expiresAt: timestampSchema
201
+ })
202
+ .strict(),
203
+ directSessionIdentitySchema
204
+ .extend({
205
+ type: z.literal('direct.opened'),
206
+ offset: safeIntegerSchema
207
+ })
208
+ .strict(),
209
+ directSessionIdentitySchema
210
+ .extend({
211
+ type: z.literal('direct.complete'),
212
+ size: safeIntegerSchema,
213
+ sha256: sha256Schema
214
+ })
215
+ .strict(),
216
+ directSessionIdentitySchema
217
+ .extend({
218
+ type: z.literal('direct.closed'),
219
+ code: z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/u)
220
+ })
221
+ .strict(),
222
+ z
223
+ .object({
224
+ type: z.literal('direct.error'),
225
+ requestId: identifierSchema.optional(),
226
+ directSessionId: identifierSchema.optional(),
227
+ code: z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/u),
228
+ message: z.string().trim().min(1).max(1000)
229
+ })
230
+ .strict()
231
+ ]);
232
+ export const directNodeCommandSchema = z.discriminatedUnion('type', [
233
+ z
234
+ .object({
235
+ type: z.literal('direct.prepare'),
236
+ directSessionId: identifierSchema,
237
+ workbenchConnectionId: identifierSchema,
238
+ nodeGeneration: identifierSchema,
239
+ purpose: directTransferPurposeSchema,
240
+ expiresAt: timestampSchema,
241
+ transfer: directTransferDescriptorSchema.optional(),
242
+ userAuthorization: z.unknown()
243
+ })
244
+ .strict(),
245
+ directSessionIdentitySchema
246
+ .extend({ type: z.literal('direct.signal'), signal: directSignalSchema })
247
+ .strict(),
248
+ directSessionIdentitySchema
249
+ .extend({
250
+ type: z.literal('direct.grant'),
251
+ grant: z.string().min(32).max(4096),
252
+ browserFingerprint: fingerprintSchema,
253
+ nodeFingerprint: fingerprintSchema,
254
+ openExpiresAt: timestampSchema,
255
+ expiresAt: timestampSchema
256
+ })
257
+ .strict(),
258
+ directSessionIdentitySchema.extend({ type: z.literal('direct.heartbeat') }).strict(),
259
+ directSessionIdentitySchema
260
+ .extend({
261
+ type: z.literal('direct.cancel'),
262
+ code: z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/u)
263
+ })
264
+ .strict()
265
+ ]);
266
+ export const directNodeEventSchema = z.discriminatedUnion('type', [
267
+ directSessionIdentitySchema
268
+ .extend({ type: z.literal('direct.signal'), signal: directSignalSchema })
269
+ .strict(),
270
+ directSessionIdentitySchema.extend({ type: z.literal('direct.connected') }).strict(),
271
+ directSessionIdentitySchema
272
+ .extend({
273
+ type: z.literal('direct.probe-result'),
274
+ result: z.enum(['DIRECT_AVAILABLE', 'RELAY_ONLY']),
275
+ routingHint: z.string().min(8).max(512).optional()
276
+ })
277
+ .strict(),
278
+ directSessionIdentitySchema
279
+ .extend({
280
+ type: z.literal('direct.opened'),
281
+ offset: safeIntegerSchema
282
+ })
283
+ .strict(),
284
+ directSessionIdentitySchema
285
+ .extend({
286
+ type: z.literal('direct.complete'),
287
+ size: safeIntegerSchema,
288
+ sha256: sha256Schema
289
+ })
290
+ .strict(),
291
+ directSessionIdentitySchema
292
+ .extend({
293
+ type: z.literal('direct.error'),
294
+ code: z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/u),
295
+ message: z.string().trim().min(1).max(1000)
296
+ })
297
+ .strict()
298
+ ]);
299
+ export const directDataOpenFrameSchema = z
300
+ .object({
301
+ type: z.literal('OPEN'),
302
+ directSessionId: identifierSchema,
303
+ grant: z.string().min(32).max(4096)
304
+ })
305
+ .strict();
306
+ export const directDataAckFrameSchema = z
307
+ .object({
308
+ type: z.literal('ACK'),
309
+ offset: safeIntegerSchema
310
+ })
311
+ .strict();
312
+ export const directDataCompleteFrameSchema = z
313
+ .object({
314
+ type: z.literal('COMPLETE'),
315
+ size: safeIntegerSchema,
316
+ sha256: sha256Schema
317
+ })
318
+ .strict();
319
+ export const directDataErrorFrameSchema = z
320
+ .object({
321
+ type: z.literal('ERROR'),
322
+ code: z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/u)
323
+ })
324
+ .strict();
325
+ export const directDataControlFrameSchema = z.discriminatedUnion('type', [
326
+ directDataOpenFrameSchema,
327
+ directDataAckFrameSchema,
328
+ directDataCompleteFrameSchema,
329
+ directDataErrorFrameSchema
330
+ ]);
@@ -84,8 +84,8 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
84
84
  targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
85
85
  grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
86
86
  createdByUserId: number;
87
- nodeId?: string | undefined;
88
87
  workspaceId?: string | undefined;
88
+ nodeId?: string | undefined;
89
89
  modelId?: string | undefined;
90
90
  templateId?: string | undefined;
91
91
  targetUserId?: number | undefined;
@@ -98,8 +98,8 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
98
98
  targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
99
99
  grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
100
100
  createdByUserId: number;
101
- nodeId?: string | undefined;
102
101
  workspaceId?: string | undefined;
102
+ nodeId?: string | undefined;
103
103
  modelId?: string | undefined;
104
104
  templateId?: string | undefined;
105
105
  targetUserId?: number | undefined;
@@ -112,8 +112,8 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
112
112
  targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
113
113
  grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
114
114
  createdByUserId: number;
115
- nodeId?: string | undefined;
116
115
  workspaceId?: string | undefined;
116
+ nodeId?: string | undefined;
117
117
  modelId?: string | undefined;
118
118
  templateId?: string | undefined;
119
119
  targetUserId?: number | undefined;
@@ -126,8 +126,8 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
126
126
  targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
127
127
  grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
128
128
  createdByUserId: number;
129
- nodeId?: string | undefined;
130
129
  workspaceId?: string | undefined;
130
+ nodeId?: string | undefined;
131
131
  modelId?: string | undefined;
132
132
  templateId?: string | undefined;
133
133
  targetUserId?: number | undefined;
@@ -224,19 +224,19 @@ export declare const auditEventSchema: z.ZodObject<{
224
224
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
225
225
  }, "strict", z.ZodTypeAny, {
226
226
  id: string;
227
+ result: "SUCCESS" | "DENIED" | "FAILED";
227
228
  eventType: string;
228
229
  occurredAt: number;
229
- result: "SUCCESS" | "DENIED" | "FAILED";
230
230
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
231
- organizationId?: number | null | undefined;
232
- nodeId?: string | null | undefined;
233
231
  workspaceId?: string | null | undefined;
232
+ requestId?: string | null | undefined;
233
+ nodeId?: string | null | undefined;
234
+ organizationId?: number | null | undefined;
234
235
  targetType?: string | null | undefined;
235
236
  errorCode?: string | null | undefined;
236
237
  actorUserId?: number | null | undefined;
237
238
  actorUsername?: string | null | undefined;
238
239
  providerId?: string | null | undefined;
239
- requestId?: string | null | undefined;
240
240
  operationId?: string | null | undefined;
241
241
  sessionPublicId?: string | null | undefined;
242
242
  targetId?: string | null | undefined;
@@ -250,19 +250,19 @@ export declare const auditEventSchema: z.ZodObject<{
250
250
  metadata?: Record<string, string | number | boolean | null> | undefined;
251
251
  }, {
252
252
  id: string;
253
+ result: "SUCCESS" | "DENIED" | "FAILED";
253
254
  eventType: string;
254
255
  occurredAt: number;
255
- result: "SUCCESS" | "DENIED" | "FAILED";
256
256
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
257
- organizationId?: number | null | undefined;
258
- nodeId?: string | null | undefined;
259
257
  workspaceId?: string | null | undefined;
258
+ requestId?: string | null | undefined;
259
+ nodeId?: string | null | undefined;
260
+ organizationId?: number | null | undefined;
260
261
  targetType?: string | null | undefined;
261
262
  errorCode?: string | null | undefined;
262
263
  actorUserId?: number | null | undefined;
263
264
  actorUsername?: string | null | undefined;
264
265
  providerId?: string | null | undefined;
265
- requestId?: string | null | undefined;
266
266
  operationId?: string | null | undefined;
267
267
  sessionPublicId?: string | null | undefined;
268
268
  targetId?: string | null | undefined;
@@ -357,19 +357,19 @@ export declare const auditEventDetailSchema: z.ZodObject<{
357
357
  }>>;
358
358
  }, "strict", z.ZodTypeAny, {
359
359
  id: string;
360
+ result: "SUCCESS" | "DENIED" | "FAILED";
360
361
  eventType: string;
361
362
  occurredAt: number;
362
- result: "SUCCESS" | "DENIED" | "FAILED";
363
363
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
364
- organizationId?: number | null | undefined;
365
- nodeId?: string | null | undefined;
366
364
  workspaceId?: string | null | undefined;
365
+ requestId?: string | null | undefined;
366
+ nodeId?: string | null | undefined;
367
+ organizationId?: number | null | undefined;
367
368
  targetType?: string | null | undefined;
368
369
  errorCode?: string | null | undefined;
369
370
  actorUserId?: number | null | undefined;
370
371
  actorUsername?: string | null | undefined;
371
372
  providerId?: string | null | undefined;
372
- requestId?: string | null | undefined;
373
373
  operationId?: string | null | undefined;
374
374
  sessionPublicId?: string | null | undefined;
375
375
  targetId?: string | null | undefined;
@@ -389,19 +389,19 @@ export declare const auditEventDetailSchema: z.ZodObject<{
389
389
  } | undefined;
390
390
  }, {
391
391
  id: string;
392
+ result: "SUCCESS" | "DENIED" | "FAILED";
392
393
  eventType: string;
393
394
  occurredAt: number;
394
- result: "SUCCESS" | "DENIED" | "FAILED";
395
395
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
396
- organizationId?: number | null | undefined;
397
- nodeId?: string | null | undefined;
398
396
  workspaceId?: string | null | undefined;
397
+ requestId?: string | null | undefined;
398
+ nodeId?: string | null | undefined;
399
+ organizationId?: number | null | undefined;
399
400
  targetType?: string | null | undefined;
400
401
  errorCode?: string | null | undefined;
401
402
  actorUserId?: number | null | undefined;
402
403
  actorUsername?: string | null | undefined;
403
404
  providerId?: string | null | undefined;
404
- requestId?: string | null | undefined;
405
405
  operationId?: string | null | undefined;
406
406
  sessionPublicId?: string | null | undefined;
407
407
  targetId?: string | null | undefined;