@myagentroam/protocol 0.9.69 → 0.9.71

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.
@@ -9,7 +9,6 @@ const resourceIdentifierSchema = z.string().trim().min(1).max(512);
9
9
  const relativePathSchema = z.string().min(1).max(4096);
10
10
  const safeIntegerSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
11
11
  const timestampSchema = z.number().int().positive();
12
- const sha256Schema = z.string().regex(/^[a-f0-9]{64}$/u);
13
12
  const fingerprintSchema = z.string().regex(/^sha-256(?: [A-F0-9]{2}(?::[A-F0-9]{2}){31})$/u);
14
13
  const sdpSchema = z
15
14
  .string()
@@ -18,10 +17,11 @@ const sdpSchema = z
18
17
  const candidateSchema = z.string().min(1).max(4096);
19
18
  export const workspaceDirectTransferCapabilitySchema = z
20
19
  .object({
21
- apiVersion: z.literal(1),
22
- probe: z.boolean(),
20
+ apiVersion: z.union([z.literal(2), z.literal(3)]),
21
+ transport: z.boolean(),
23
22
  upload: z.boolean(),
24
23
  download: z.boolean(),
24
+ range: z.boolean(),
25
25
  gitCommitBlob: z.boolean(),
26
26
  maxChunkBytes: z
27
27
  .number()
@@ -30,9 +30,8 @@ export const workspaceDirectTransferCapabilitySchema = z
30
30
  .max(1024 * 1024)
31
31
  })
32
32
  .strict();
33
- export const directTransferPurposeSchema = z.enum(['PROBE', 'TRANSFER']);
33
+ export const directTransferPurposeSchema = z.enum(['TRANSPORT', 'TRANSFER']);
34
34
  export const directTransferDirectionSchema = z.enum(['UPLOAD', 'DOWNLOAD']);
35
- export const directTransferProbeResultSchema = z.enum(['DIRECT_AVAILABLE', 'RELAY_ONLY', 'STALE']);
36
35
  const workspaceFileResourceSchema = z
37
36
  .object({
38
37
  kind: z.literal('WORKSPACE_FILE'),
@@ -55,13 +54,16 @@ export const directTransferResourceSchema = z.discriminatedUnion('kind', [
55
54
  workspaceFileResourceSchema,
56
55
  gitCommitBlobResourceSchema
57
56
  ]);
58
- export const directTransferDescriptorSchema = z
57
+ const directTransferDescriptorBaseSchema = z
59
58
  .object({
60
- direction: directTransferDirectionSchema,
61
59
  resource: directTransferResourceSchema,
62
60
  fileName: z.string().trim().min(1).max(512),
63
- size: safeIntegerSchema,
64
- sha256: sha256Schema,
61
+ size: safeIntegerSchema
62
+ })
63
+ .strict();
64
+ const directUploadDescriptorSchema = directTransferDescriptorBaseSchema
65
+ .extend({
66
+ direction: z.literal('UPLOAD'),
65
67
  overwrite: z.boolean().optional(),
66
68
  resumeOffset: safeIntegerSchema.optional(),
67
69
  composerAttachment: z
@@ -80,20 +82,41 @@ export const directTransferDescriptorSchema = z
80
82
  path: ['resumeOffset'],
81
83
  message: 'resume offset cannot exceed the file size'
82
84
  });
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
85
  if (descriptor.composerAttachment !== undefined &&
90
- (descriptor.direction !== 'UPLOAD' || descriptor.resource.kind !== 'WORKSPACE_FILE'))
86
+ descriptor.resource.kind !== 'WORKSPACE_FILE')
91
87
  context.addIssue({
92
88
  code: 'custom',
93
89
  path: ['composerAttachment'],
94
90
  message: 'composer attachments are supported only for Workspace uploads'
95
91
  });
96
92
  });
93
+ const directDownloadDescriptorSchema = directTransferDescriptorBaseSchema
94
+ .extend({
95
+ direction: z.literal('DOWNLOAD'),
96
+ revision: z.string().trim().min(1).max(512),
97
+ range: z
98
+ .object({
99
+ offset: safeIntegerSchema,
100
+ length: safeIntegerSchema
101
+ })
102
+ .strict()
103
+ .optional()
104
+ })
105
+ .strict()
106
+ .superRefine((descriptor, context) => {
107
+ if (descriptor.range !== undefined &&
108
+ (descriptor.range.length === 0 ||
109
+ descriptor.range.offset + descriptor.range.length > descriptor.size))
110
+ context.addIssue({
111
+ code: 'custom',
112
+ path: ['range'],
113
+ message: 'download range must be non-empty and fit within the file size'
114
+ });
115
+ });
116
+ export const directTransferDescriptorSchema = z.union([
117
+ directUploadDescriptorSchema,
118
+ directDownloadDescriptorSchema
119
+ ]);
97
120
  const directPrepareBaseSchema = z
98
121
  .object({
99
122
  type: z.literal('direct.prepare'),
@@ -103,10 +126,11 @@ const directPrepareBaseSchema = z
103
126
  })
104
127
  .strict();
105
128
  export const directPrepareRequestSchema = z.discriminatedUnion('purpose', [
106
- directPrepareBaseSchema.extend({ purpose: z.literal('PROBE') }).strict(),
129
+ directPrepareBaseSchema.extend({ purpose: z.literal('TRANSPORT') }).strict(),
107
130
  directPrepareBaseSchema
108
131
  .extend({
109
132
  purpose: z.literal('TRANSFER'),
133
+ transportSessionId: identifierSchema,
110
134
  transfer: directTransferDescriptorSchema
111
135
  })
112
136
  .strict()
@@ -151,8 +175,7 @@ export const directBrowserMessageSchema = z.union([
151
175
  directSessionIdentitySchema
152
176
  .extend({
153
177
  type: z.literal('direct.complete'),
154
- size: safeIntegerSchema,
155
- sha256: sha256Schema
178
+ size: safeIntegerSchema
156
179
  })
157
180
  .strict(),
158
181
  directSessionIdentitySchema
@@ -172,6 +195,7 @@ export const directServerMessageSchema = z.discriminatedUnion('type', [
172
195
  nodeGeneration: identifierSchema,
173
196
  purpose: directTransferPurposeSchema,
174
197
  expiresAt: timestampSchema,
198
+ transportSessionId: identifierSchema.optional(),
175
199
  resumeOffset: safeIntegerSchema.optional()
176
200
  })
177
201
  .strict(),
@@ -186,13 +210,6 @@ export const directServerMessageSchema = z.discriminatedUnion('type', [
186
210
  expiresAt: timestampSchema
187
211
  })
188
212
  .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
213
  directSessionIdentitySchema
197
214
  .extend({
198
215
  type: z.literal('direct.heartbeat'),
@@ -209,8 +226,7 @@ export const directServerMessageSchema = z.discriminatedUnion('type', [
209
226
  directSessionIdentitySchema
210
227
  .extend({
211
228
  type: z.literal('direct.complete'),
212
- size: safeIntegerSchema,
213
- sha256: sha256Schema
229
+ size: safeIntegerSchema
214
230
  })
215
231
  .strict(),
216
232
  directSessionIdentitySchema
@@ -229,16 +245,28 @@ export const directServerMessageSchema = z.discriminatedUnion('type', [
229
245
  })
230
246
  .strict()
231
247
  ]);
232
- export const directNodeCommandSchema = z.discriminatedUnion('type', [
248
+ export const directNodeCommandSchema = z.union([
233
249
  z
234
250
  .object({
235
251
  type: z.literal('direct.prepare'),
236
252
  directSessionId: identifierSchema,
237
253
  workbenchConnectionId: identifierSchema,
238
254
  nodeGeneration: identifierSchema,
239
- purpose: directTransferPurposeSchema,
255
+ purpose: z.literal('TRANSPORT'),
256
+ expiresAt: timestampSchema,
257
+ userAuthorization: z.unknown()
258
+ })
259
+ .strict(),
260
+ z
261
+ .object({
262
+ type: z.literal('direct.prepare'),
263
+ directSessionId: identifierSchema,
264
+ transportSessionId: identifierSchema,
265
+ workbenchConnectionId: identifierSchema,
266
+ nodeGeneration: identifierSchema,
267
+ purpose: z.literal('TRANSFER'),
240
268
  expiresAt: timestampSchema,
241
- transfer: directTransferDescriptorSchema.optional(),
269
+ transfer: directTransferDescriptorSchema,
242
270
  userAuthorization: z.unknown()
243
271
  })
244
272
  .strict(),
@@ -248,6 +276,7 @@ export const directNodeCommandSchema = z.discriminatedUnion('type', [
248
276
  directSessionIdentitySchema
249
277
  .extend({
250
278
  type: z.literal('direct.grant'),
279
+ transportSessionId: identifierSchema,
251
280
  grant: z.string().min(32).max(4096),
252
281
  browserFingerprint: fingerprintSchema,
253
282
  nodeFingerprint: fingerprintSchema,
@@ -255,7 +284,9 @@ export const directNodeCommandSchema = z.discriminatedUnion('type', [
255
284
  expiresAt: timestampSchema
256
285
  })
257
286
  .strict(),
258
- directSessionIdentitySchema.extend({ type: z.literal('direct.heartbeat') }).strict(),
287
+ directSessionIdentitySchema
288
+ .extend({ type: z.literal('direct.heartbeat'), expiresAt: timestampSchema })
289
+ .strict(),
259
290
  directSessionIdentitySchema
260
291
  .extend({
261
292
  type: z.literal('direct.cancel'),
@@ -268,13 +299,6 @@ export const directNodeEventSchema = z.discriminatedUnion('type', [
268
299
  .extend({ type: z.literal('direct.signal'), signal: directSignalSchema })
269
300
  .strict(),
270
301
  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
302
  directSessionIdentitySchema
279
303
  .extend({
280
304
  type: z.literal('direct.opened'),
@@ -284,8 +308,7 @@ export const directNodeEventSchema = z.discriminatedUnion('type', [
284
308
  directSessionIdentitySchema
285
309
  .extend({
286
310
  type: z.literal('direct.complete'),
287
- size: safeIntegerSchema,
288
- sha256: sha256Schema
311
+ size: safeIntegerSchema
289
312
  })
290
313
  .strict(),
291
314
  directSessionIdentitySchema
@@ -312,8 +335,7 @@ export const directDataAckFrameSchema = z
312
335
  export const directDataCompleteFrameSchema = z
313
336
  .object({
314
337
  type: z.literal('COMPLETE'),
315
- size: safeIntegerSchema,
316
- sha256: sha256Schema
338
+ size: safeIntegerSchema
317
339
  })
318
340
  .strict();
319
341
  export const directDataErrorFrameSchema = z
@@ -224,9 +224,9 @@ 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";
228
227
  eventType: string;
229
228
  occurredAt: number;
229
+ result: "SUCCESS" | "DENIED" | "FAILED";
230
230
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
231
231
  workspaceId?: string | null | undefined;
232
232
  requestId?: string | null | undefined;
@@ -250,9 +250,9 @@ 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";
254
253
  eventType: string;
255
254
  occurredAt: number;
255
+ result: "SUCCESS" | "DENIED" | "FAILED";
256
256
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
257
257
  workspaceId?: string | null | undefined;
258
258
  requestId?: string | null | undefined;
@@ -357,9 +357,9 @@ export declare const auditEventDetailSchema: z.ZodObject<{
357
357
  }>>;
358
358
  }, "strict", z.ZodTypeAny, {
359
359
  id: string;
360
- result: "SUCCESS" | "DENIED" | "FAILED";
361
360
  eventType: string;
362
361
  occurredAt: number;
362
+ result: "SUCCESS" | "DENIED" | "FAILED";
363
363
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
364
364
  workspaceId?: string | null | undefined;
365
365
  requestId?: string | null | undefined;
@@ -389,9 +389,9 @@ export declare const auditEventDetailSchema: z.ZodObject<{
389
389
  } | undefined;
390
390
  }, {
391
391
  id: string;
392
- result: "SUCCESS" | "DENIED" | "FAILED";
393
392
  eventType: string;
394
393
  occurredAt: number;
394
+ result: "SUCCESS" | "DENIED" | "FAILED";
395
395
  authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
396
396
  workspaceId?: string | null | undefined;
397
397
  requestId?: string | null | undefined;