@vzn/vx-reapi 0.0.595 → 0.0.596
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/package.json +2 -2
- package/src/executor.ts +34 -73
- package/src/merkle.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vzn/vx-reapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.596",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Bazel Remote Execution API plugin for vx — remote cache (ActionCache + CAS) against NativeLink, BuildBuddy, Buildbarn or bazel-remote.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@vzn/vx": "^0.0.
|
|
42
|
+
"@vzn/vx": "^0.0.596"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
package/src/executor.ts
CHANGED
|
@@ -23,12 +23,14 @@ import {
|
|
|
23
23
|
import type { ExecuteRequest, ExecuteResult, TaskExecutor, TaskPlacement } from '@vzn/vx'
|
|
24
24
|
import {
|
|
25
25
|
buildInputTree,
|
|
26
|
+
decodeDigestBytes,
|
|
26
27
|
decodeTreeWithBytes,
|
|
27
28
|
digestWith,
|
|
28
29
|
encodeAction,
|
|
29
30
|
encodeCommand,
|
|
30
31
|
encodeTree,
|
|
31
32
|
mapBounded,
|
|
33
|
+
readVarintAt,
|
|
32
34
|
sha256,
|
|
33
35
|
type Blob,
|
|
34
36
|
type FileGraft,
|
|
@@ -203,12 +205,12 @@ export function decodeExecuteResponseBytes(buf: Uint8Array): DecodedExecuteRespo
|
|
|
203
205
|
const out: DecodedExecuteResponse = { serverLogs: [] }
|
|
204
206
|
let i = 0
|
|
205
207
|
while (i < buf.length) {
|
|
206
|
-
const [key, k] =
|
|
208
|
+
const [key, k] = readVarintAt(buf, i)
|
|
207
209
|
i = k
|
|
208
210
|
const field = key >>> 3
|
|
209
211
|
const wire = key & 7
|
|
210
212
|
if (wire === 2) {
|
|
211
|
-
const [len, l] =
|
|
213
|
+
const [len, l] = readVarintAt(buf, i)
|
|
212
214
|
i = l
|
|
213
215
|
const slice = buf.subarray(i, i + len)
|
|
214
216
|
i += len
|
|
@@ -219,7 +221,7 @@ export function decodeExecuteResponseBytes(buf: Uint8Array): DecodedExecuteRespo
|
|
|
219
221
|
if (entry !== undefined) out.serverLogs.push(entry)
|
|
220
222
|
} else if (field === 5) out.message = new TextDecoder().decode(slice)
|
|
221
223
|
} else if (wire === 0) {
|
|
222
|
-
const [v, n] =
|
|
224
|
+
const [v, n] = readVarintAt(buf, i)
|
|
223
225
|
i = n
|
|
224
226
|
if (field === 2) out.cachedResult = v === 1
|
|
225
227
|
} else if (wire === 5) i += 4
|
|
@@ -234,16 +236,16 @@ function decodeRpcStatus(buf: Uint8Array): { code: number; message: string } {
|
|
|
234
236
|
const st = { code: 0, message: '' }
|
|
235
237
|
let i = 0
|
|
236
238
|
while (i < buf.length) {
|
|
237
|
-
const [key, k] =
|
|
239
|
+
const [key, k] = readVarintAt(buf, i)
|
|
238
240
|
i = k
|
|
239
241
|
const field = key >>> 3
|
|
240
242
|
const wire = key & 7
|
|
241
243
|
if (wire === 0) {
|
|
242
|
-
const [v, n] =
|
|
244
|
+
const [v, n] = readVarintAt(buf, i)
|
|
243
245
|
i = n
|
|
244
246
|
if (field === 1) st.code = v
|
|
245
247
|
} else if (wire === 2) {
|
|
246
|
-
const [len, l] =
|
|
248
|
+
const [len, l] = readVarintAt(buf, i)
|
|
247
249
|
i = l
|
|
248
250
|
if (field === 2) st.message = new TextDecoder().decode(buf.subarray(i, i + len))
|
|
249
251
|
i += len
|
|
@@ -261,10 +263,10 @@ function decodeLogEntry(
|
|
|
261
263
|
let humanReadable = false
|
|
262
264
|
let i = 0
|
|
263
265
|
while (i < buf.length) {
|
|
264
|
-
const [key, k] =
|
|
266
|
+
const [key, k] = readVarintAt(buf, i)
|
|
265
267
|
i = k
|
|
266
268
|
if ((key & 7) !== 2) break
|
|
267
|
-
const [len, l] =
|
|
269
|
+
const [len, l] = readVarintAt(buf, i)
|
|
268
270
|
i = l
|
|
269
271
|
const slice = buf.subarray(i, i + len)
|
|
270
272
|
i += len
|
|
@@ -272,15 +274,15 @@ function decodeLogEntry(
|
|
|
272
274
|
else if (key >>> 3 === 2) {
|
|
273
275
|
let j = 0
|
|
274
276
|
while (j < slice.length) {
|
|
275
|
-
const [k2, j2] =
|
|
277
|
+
const [k2, j2] = readVarintAt(slice, j)
|
|
276
278
|
j = j2
|
|
277
279
|
if ((k2 & 7) === 2) {
|
|
278
|
-
const [len2, j3] =
|
|
280
|
+
const [len2, j3] = readVarintAt(slice, j)
|
|
279
281
|
j = j3
|
|
280
|
-
if (k2 >>> 3 === 1) digest =
|
|
282
|
+
if (k2 >>> 3 === 1) digest = decodeDigestBytes(slice.subarray(j, j + len2))
|
|
281
283
|
j += len2
|
|
282
284
|
} else if ((k2 & 7) === 0) {
|
|
283
|
-
const [v, j3] =
|
|
285
|
+
const [v, j3] = readVarintAt(slice, j)
|
|
284
286
|
j = j3
|
|
285
287
|
if (k2 >>> 3 === 2) humanReadable = v === 1
|
|
286
288
|
} else break
|
|
@@ -295,16 +297,16 @@ function decodeActionResult(buf: Uint8Array): ActionResult {
|
|
|
295
297
|
const legacyLinks: { path: string; target: string }[] = []
|
|
296
298
|
let i = 0
|
|
297
299
|
while (i < buf.length) {
|
|
298
|
-
const [key, k] =
|
|
300
|
+
const [key, k] = readVarintAt(buf, i)
|
|
299
301
|
i = k
|
|
300
302
|
const field = key >>> 3
|
|
301
303
|
const wire = key & 7
|
|
302
304
|
if (wire === 0) {
|
|
303
|
-
const [v, n] =
|
|
305
|
+
const [v, n] = readVarintAt(buf, i)
|
|
304
306
|
i = n
|
|
305
307
|
if (field === 4) res.exit_code = v | 0
|
|
306
308
|
} else if (wire === 2) {
|
|
307
|
-
const [len, l] =
|
|
309
|
+
const [len, l] = readVarintAt(buf, i)
|
|
308
310
|
i = l
|
|
309
311
|
const slice = buf.subarray(i, i + len)
|
|
310
312
|
i += len
|
|
@@ -315,9 +317,9 @@ function decodeActionResult(buf: Uint8Array): ActionResult {
|
|
|
315
317
|
if (field === 2) (res.output_files ??= []).push(decodeOutputFile(slice))
|
|
316
318
|
else if (field === 3) (res.output_directories ??= []).push(decodeOutputDirectory(slice))
|
|
317
319
|
else if (field === 5) res.stdout_raw = slice
|
|
318
|
-
else if (field === 6) res.stdout_digest =
|
|
320
|
+
else if (field === 6) res.stdout_digest = decodeDigestBytes(slice)
|
|
319
321
|
else if (field === 7) res.stderr_raw = slice
|
|
320
|
-
else if (field === 8) res.stderr_digest =
|
|
322
|
+
else if (field === 8) res.stderr_digest = decodeDigestBytes(slice)
|
|
321
323
|
else if (field === 9) res.execution_metadata = decodeExecutedActionMetadata(slice)
|
|
322
324
|
else if (field === 12) (res.output_symlinks ??= []).push(decodeOutputSymlink(slice))
|
|
323
325
|
// output_file_symlinks (10) and output_directory_symlinks (11): all a
|
|
@@ -347,20 +349,20 @@ function decodeOutputFile(buf: Uint8Array): {
|
|
|
347
349
|
}
|
|
348
350
|
let i = 0
|
|
349
351
|
while (i < buf.length) {
|
|
350
|
-
const [key, k] =
|
|
352
|
+
const [key, k] = readVarintAt(buf, i)
|
|
351
353
|
i = k
|
|
352
354
|
const field = key >>> 3
|
|
353
355
|
const wire = key & 7
|
|
354
356
|
if (wire === 2) {
|
|
355
|
-
const [len, l] =
|
|
357
|
+
const [len, l] = readVarintAt(buf, i)
|
|
356
358
|
i = l
|
|
357
359
|
const slice = buf.subarray(i, i + len)
|
|
358
360
|
i += len
|
|
359
361
|
if (field === 1) out.path = PATH_UTF8.decode(slice)
|
|
360
|
-
else if (field === 2) out.digest =
|
|
362
|
+
else if (field === 2) out.digest = decodeDigestBytes(slice)
|
|
361
363
|
else if (field === 5 && len > 0) out.contents = slice
|
|
362
364
|
} else if (wire === 0) {
|
|
363
|
-
const [v, n] =
|
|
365
|
+
const [v, n] = readVarintAt(buf, i)
|
|
364
366
|
i = n
|
|
365
367
|
if (field === 4) out.is_executable = v === 1
|
|
366
368
|
} else break
|
|
@@ -373,10 +375,10 @@ function decodeOutputSymlink(buf: Uint8Array): { path: string; target: string }
|
|
|
373
375
|
const out = { path: '', target: '' }
|
|
374
376
|
let i = 0
|
|
375
377
|
while (i < buf.length) {
|
|
376
|
-
const [key, k] =
|
|
378
|
+
const [key, k] = readVarintAt(buf, i)
|
|
377
379
|
i = k
|
|
378
380
|
if ((key & 7) !== 2) break
|
|
379
|
-
const [len, l] =
|
|
381
|
+
const [len, l] = readVarintAt(buf, i)
|
|
380
382
|
i = l
|
|
381
383
|
const slice = buf.subarray(i, i + len)
|
|
382
384
|
i += len
|
|
@@ -398,12 +400,12 @@ function decodeExecutedActionMetadata(
|
|
|
398
400
|
const meta: NonNullable<ActionResult['execution_metadata']> = {}
|
|
399
401
|
let i = 0
|
|
400
402
|
while (i < buf.length) {
|
|
401
|
-
const [key, k] =
|
|
403
|
+
const [key, k] = readVarintAt(buf, i)
|
|
402
404
|
i = k
|
|
403
405
|
const field = key >>> 3
|
|
404
406
|
const wire = key & 7
|
|
405
407
|
if (wire === 2) {
|
|
406
|
-
const [len, l] =
|
|
408
|
+
const [len, l] = readVarintAt(buf, i)
|
|
407
409
|
i = l
|
|
408
410
|
const slice = buf.subarray(i, i + len)
|
|
409
411
|
i += len
|
|
@@ -411,7 +413,7 @@ function decodeExecutedActionMetadata(
|
|
|
411
413
|
else if (field === 7) meta.execution_start_timestamp = decodeTimestamp(slice)
|
|
412
414
|
else if (field === 8) meta.execution_completed_timestamp = decodeTimestamp(slice)
|
|
413
415
|
} else if (wire === 0) {
|
|
414
|
-
const [, n] =
|
|
416
|
+
const [, n] = readVarintAt(buf, i)
|
|
415
417
|
i = n
|
|
416
418
|
} else break
|
|
417
419
|
}
|
|
@@ -423,10 +425,10 @@ function decodeTimestamp(buf: Uint8Array): { seconds?: string; nanos?: number }
|
|
|
423
425
|
const ts: { seconds?: string; nanos?: number } = {}
|
|
424
426
|
let i = 0
|
|
425
427
|
while (i < buf.length) {
|
|
426
|
-
const [key, k] =
|
|
428
|
+
const [key, k] = readVarintAt(buf, i)
|
|
427
429
|
i = k
|
|
428
430
|
if ((key & 7) !== 0) break
|
|
429
|
-
const [v, n] =
|
|
431
|
+
const [v, n] = readVarintAt(buf, i)
|
|
430
432
|
i = n
|
|
431
433
|
if (key >>> 3 === 1) ts.seconds = String(v)
|
|
432
434
|
else if (key >>> 3 === 2) ts.nanos = v
|
|
@@ -441,67 +443,26 @@ function decodeOutputDirectory(buf: Uint8Array): { path: string; tree_digest: Di
|
|
|
441
443
|
const out = { path: '', tree_digest: { hash: '', size_bytes: 0 } }
|
|
442
444
|
let i = 0
|
|
443
445
|
while (i < buf.length) {
|
|
444
|
-
const [key, k] =
|
|
446
|
+
const [key, k] = readVarintAt(buf, i)
|
|
445
447
|
i = k
|
|
446
448
|
const field = key >>> 3
|
|
447
449
|
const wire = key & 7
|
|
448
450
|
if (wire === 0) {
|
|
449
|
-
const [, n] =
|
|
451
|
+
const [, n] = readVarintAt(buf, i)
|
|
450
452
|
i = n
|
|
451
453
|
continue
|
|
452
454
|
}
|
|
453
455
|
if (wire !== 2) break
|
|
454
|
-
const [len, l] =
|
|
456
|
+
const [len, l] = readVarintAt(buf, i)
|
|
455
457
|
i = l
|
|
456
458
|
const slice = buf.subarray(i, i + len)
|
|
457
459
|
i += len
|
|
458
460
|
if (field === 1) out.path = PATH_UTF8.decode(slice)
|
|
459
|
-
else if (field === 3) out.tree_digest =
|
|
461
|
+
else if (field === 3) out.tree_digest = decodeDigestBytes(slice)
|
|
460
462
|
}
|
|
461
463
|
return out
|
|
462
464
|
}
|
|
463
465
|
|
|
464
|
-
function decodeDigest(buf: Uint8Array): Digest {
|
|
465
|
-
const d: Digest = { hash: '', size_bytes: 0 }
|
|
466
|
-
let i = 0
|
|
467
|
-
while (i < buf.length) {
|
|
468
|
-
const [key, k] = readVarint(buf, i)
|
|
469
|
-
i = k
|
|
470
|
-
const field = key >>> 3
|
|
471
|
-
const wire = key & 7
|
|
472
|
-
if (wire === 2) {
|
|
473
|
-
const [len, l] = readVarint(buf, i)
|
|
474
|
-
i = l
|
|
475
|
-
if (field === 1) d.hash = new TextDecoder().decode(buf.subarray(i, i + len))
|
|
476
|
-
i += len
|
|
477
|
-
} else if (wire === 0) {
|
|
478
|
-
const [v, n] = readVarint(buf, i)
|
|
479
|
-
i = n
|
|
480
|
-
if (field === 2) d.size_bytes = v
|
|
481
|
-
} else break
|
|
482
|
-
}
|
|
483
|
-
return d
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function readVarint(buf: Uint8Array, at: number): [number, number] {
|
|
487
|
-
let result = 0
|
|
488
|
-
let low = 0
|
|
489
|
-
let shift = 0
|
|
490
|
-
let i = at
|
|
491
|
-
for (;;) {
|
|
492
|
-
const byte = buf[i++]
|
|
493
|
-
if (byte === undefined) break
|
|
494
|
-
// Added, not OR-ed: a size of 4 GiB or more wrapped to 32 bits (F-43).
|
|
495
|
-
// Past 2^53 the value is a negative int32 sent as ten bytes (an exit
|
|
496
|
-
// code): its low 32 bits, which `| 0` reads back as the negative.
|
|
497
|
-
result += (byte & 0x7f) * 2 ** shift
|
|
498
|
-
if (shift < 32) low |= (byte & 0x7f) << shift
|
|
499
|
-
if ((byte & 0x80) === 0) break
|
|
500
|
-
shift += 7
|
|
501
|
-
}
|
|
502
|
-
return [result <= Number.MAX_SAFE_INTEGER ? result : low >>> 0, i]
|
|
503
|
-
}
|
|
504
|
-
|
|
505
466
|
/**
|
|
506
467
|
* Backstop for an action the server never finishes. Generous on purpose: it
|
|
507
468
|
* exists so a wedged remote cannot hang a run forever, not to police slow
|
package/src/merkle.ts
CHANGED
|
@@ -828,7 +828,7 @@ function decodeSymlinkNode(buf: Uint8Array): SymlinkNode {
|
|
|
828
828
|
return sl
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
function decodeDigestBytes(buf: Uint8Array): Digest {
|
|
831
|
+
export function decodeDigestBytes(buf: Uint8Array): Digest {
|
|
832
832
|
const d: Digest = { hash: '', size_bytes: 0 }
|
|
833
833
|
let i = 0
|
|
834
834
|
while (i < buf.length) {
|
|
@@ -850,7 +850,7 @@ function decodeDigestBytes(buf: Uint8Array): Digest {
|
|
|
850
850
|
return d
|
|
851
851
|
}
|
|
852
852
|
|
|
853
|
-
function readVarintAt(buf: Uint8Array, at: number): [number, number] {
|
|
853
|
+
export function readVarintAt(buf: Uint8Array, at: number): [number, number] {
|
|
854
854
|
let result = 0
|
|
855
855
|
let low = 0
|
|
856
856
|
let shift = 0
|