@parcha/agentrun-computer 0.1.0-beta.43 → 0.1.0-beta.45
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/README.md +98 -12
- package/box/Dockerfile +2 -1
- package/box/build-daytona.py +12 -2
- package/box/install.sh +19 -5
- package/box/recipe.mjs +1 -1
- package/dist/attach.d.ts +13 -3
- package/dist/attach.js +182 -15
- package/dist/cloudflare.d.ts +4 -2
- package/dist/cloudflare.js +7 -3
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +2 -2
- package/dist/conformance/cases/files.js +7 -1
- package/dist/conformance/cases/isolation.js +4 -0
- package/dist/conformance/cases/mount.js +155 -2
- package/dist/conformance/cases/provider.js +3 -1
- package/dist/conformance/daytona.d.ts +15 -1
- package/dist/conformance/daytona.js +19 -4
- package/dist/conformance/types.d.ts +1 -1
- package/dist/daytona.d.ts +11 -2
- package/dist/daytona.js +47 -15
- package/dist/descriptor.d.ts +34 -4
- package/dist/descriptor.js +40 -6
- package/dist/descriptors/cloudflare.d.ts +14 -1
- package/dist/descriptors/cloudflare.js +7 -3
- package/dist/descriptors/daytona.d.ts +21 -3
- package/dist/descriptors/daytona.js +15 -8
- package/dist/descriptors/e2b.d.ts +1 -0
- package/dist/descriptors/e2b.js +2 -1
- package/dist/descriptors/fly.d.ts +14 -1
- package/dist/descriptors/fly.js +6 -3
- package/dist/descriptors/index.d.ts +64 -2
- package/dist/descriptors/modal.d.ts +16 -2
- package/dist/descriptors/modal.js +10 -6
- package/dist/descriptors/orgo.d.ts +3 -0
- package/dist/descriptors/orgo.js +3 -1
- package/dist/e2b.d.ts +9 -4
- package/dist/e2b.js +8 -8
- package/dist/env-proxy.d.ts +26 -0
- package/dist/env-proxy.js +97 -0
- package/dist/fly.d.ts +4 -3
- package/dist/fly.js +7 -4
- package/dist/hosted/provider.d.ts +2 -1
- package/dist/hosted/provider.js +133 -54
- package/dist/hosted/scripts.d.ts +3 -2
- package/dist/hosted/scripts.js +12 -7
- package/dist/hosted/values.d.ts +2 -5
- package/dist/hosted/values.js +2 -9
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/kinds.d.ts +4 -2
- package/dist/kinds.js +10 -1
- package/dist/modal.d.ts +5 -2
- package/dist/modal.js +8 -2
- package/dist/morph.js +15 -7
- package/dist/mount-archil.d.ts +33 -17
- package/dist/mount-archil.js +83 -36
- package/dist/mount.d.ts +16 -7
- package/dist/mount.js +13 -8
- package/dist/orgo.js +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/sync-folder.d.ts +82 -0
- package/dist/sync-folder.js +494 -0
- package/dist/tar.d.ts +34 -0
- package/dist/tar.js +203 -0
- package/package.json +1 -1
- package/dist/conformance/tar.d.ts +0 -13
- package/dist/conformance/tar.js +0 -105
package/dist/tar.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// Just enough tar to move a folder through computerd's tar.push and tar.pull without the host's tar, streaming both
|
|
2
|
+
// ways: ustar out, with a pax header for a name or a link target past ustar's 100 bytes; ustar, pax and GNU long names
|
|
3
|
+
// in, one entry at a time, each with its whole body, so what is held is one entry, never the archive.
|
|
4
|
+
const BLOCK = 512;
|
|
5
|
+
const END = Buffer.alloc(2 * BLOCK);
|
|
6
|
+
const TYPE_FLAG = { file: "0", dir: "5", symlink: "2", other: "0" };
|
|
7
|
+
const pad = (length) => Buffer.alloc((BLOCK - (length % BLOCK)) % BLOCK);
|
|
8
|
+
function header(name, type, mode, size, link) {
|
|
9
|
+
const block = Buffer.alloc(BLOCK);
|
|
10
|
+
const field = (at, length, value) => block.write(value, at, length, "utf8");
|
|
11
|
+
const octal = (value, width) => `${value.toString(8).padStart(width - 1, "0")}\0`;
|
|
12
|
+
field(0, 100, name);
|
|
13
|
+
field(100, 8, octal(mode, 8));
|
|
14
|
+
field(108, 8, octal(0, 8));
|
|
15
|
+
field(116, 8, octal(0, 8));
|
|
16
|
+
field(124, 12, octal(size, 12));
|
|
17
|
+
field(136, 12, octal(Math.floor(Date.now() / 1000), 12));
|
|
18
|
+
field(148, 8, " ");
|
|
19
|
+
field(156, 1, type);
|
|
20
|
+
field(157, 100, link);
|
|
21
|
+
field(257, 6, "ustar\0");
|
|
22
|
+
field(263, 2, "00");
|
|
23
|
+
let sum = 0;
|
|
24
|
+
for (const byte of block)
|
|
25
|
+
sum += byte;
|
|
26
|
+
field(148, 8, `${sum.toString(8).padStart(6, "0")}\0 `);
|
|
27
|
+
return block;
|
|
28
|
+
}
|
|
29
|
+
/** One pax record, "<length> key=value\n", its length counting its own digits. */
|
|
30
|
+
function record(key, value) {
|
|
31
|
+
const rest = Buffer.byteLength(` ${key}=${value}\n`);
|
|
32
|
+
let length = rest + String(rest).length;
|
|
33
|
+
if (String(length).length !== String(rest).length)
|
|
34
|
+
length = rest + String(length).length;
|
|
35
|
+
return `${length} ${key}=${value}\n`;
|
|
36
|
+
}
|
|
37
|
+
/** One entry's blocks: a pax header first where its name or link does not fit ustar's 100 bytes, then its own, its body and the padding. */
|
|
38
|
+
export function tarEntry(entry) {
|
|
39
|
+
const body = entry.type === "file" ? Buffer.from(entry.body ?? new Uint8Array()) : Buffer.alloc(0);
|
|
40
|
+
const link = entry.link ?? "";
|
|
41
|
+
const records = [...(Buffer.byteLength(entry.name) > 100 ? [record("path", entry.name)] : []), ...(Buffer.byteLength(link) > 100 ? [record("linkpath", link)] : [])].join("");
|
|
42
|
+
const blocks = [];
|
|
43
|
+
if (records !== "") {
|
|
44
|
+
const pax = Buffer.from(records);
|
|
45
|
+
blocks.push(header("././@PaxHeader", "x", 0o644, pax.length, ""), pax, pad(pax.length));
|
|
46
|
+
}
|
|
47
|
+
blocks.push(header(entry.name, TYPE_FLAG[entry.type], entry.mode, body.length, link), body, pad(body.length));
|
|
48
|
+
return blocks;
|
|
49
|
+
}
|
|
50
|
+
/** A whole archive of these entries. */
|
|
51
|
+
export function tarOf(entries) {
|
|
52
|
+
return Buffer.concat([...entries.flatMap(tarEntry), END]);
|
|
53
|
+
}
|
|
54
|
+
/** An archive of these entries as it is made: each entry's blocks as it comes, then the end. */
|
|
55
|
+
export async function* tarStream(entries) {
|
|
56
|
+
for await (const entry of entries)
|
|
57
|
+
yield* tarEntry(entry);
|
|
58
|
+
yield END;
|
|
59
|
+
}
|
|
60
|
+
const text = (block, at, length) => {
|
|
61
|
+
const raw = block.subarray(at, at + length);
|
|
62
|
+
const end = raw.indexOf(0);
|
|
63
|
+
return raw.subarray(0, end < 0 ? raw.length : end).toString("utf8");
|
|
64
|
+
};
|
|
65
|
+
const number = (block, at, length) => Number.parseInt(text(block, at, length).trim() || "0", 8);
|
|
66
|
+
/** A size an entry can have: a whole number of bytes, 0 or more (a negative or unreadable one would never be consumed). */
|
|
67
|
+
const sized = (size) => Number.isSafeInteger(size) && size >= 0;
|
|
68
|
+
/** Reads pax records: "<len> key=value\n" each. */
|
|
69
|
+
function pax(body) {
|
|
70
|
+
const records = {};
|
|
71
|
+
let at = 0;
|
|
72
|
+
while (at < body.length) {
|
|
73
|
+
const space = body.indexOf(0x20, at);
|
|
74
|
+
if (space < 0)
|
|
75
|
+
break;
|
|
76
|
+
const length = Number.parseInt(body.subarray(at, space).toString("utf8"), 10);
|
|
77
|
+
if (!(length > 0))
|
|
78
|
+
break;
|
|
79
|
+
const line = body.subarray(space + 1, at + length - 1).toString("utf8");
|
|
80
|
+
const equals = line.indexOf("=");
|
|
81
|
+
if (equals > 0)
|
|
82
|
+
records[line.slice(0, equals)] = line.slice(equals + 1);
|
|
83
|
+
at += length;
|
|
84
|
+
}
|
|
85
|
+
return records;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* An archive read as its bytes come: push() takes a chunk and answers the entries it finished, each whole. Bytes are
|
|
89
|
+
* joined only once an entry's are all here, so a large body is copied once. Throws in words on a header whose checksum
|
|
90
|
+
* is wrong; finish() throws where the bytes end inside an entry. `take`, where given, is asked for each entry's size at
|
|
91
|
+
* its header, before its bytes are held: false throws in words, so a reader never holds more than `take` allows.
|
|
92
|
+
*/
|
|
93
|
+
export class TarReader {
|
|
94
|
+
#parts = [];
|
|
95
|
+
#length = 0;
|
|
96
|
+
#next = {};
|
|
97
|
+
#ended = false;
|
|
98
|
+
#take;
|
|
99
|
+
/** Whether the header held now was given to take. */
|
|
100
|
+
#taken = false;
|
|
101
|
+
constructor(options = {}) {
|
|
102
|
+
this.#take = options.take;
|
|
103
|
+
}
|
|
104
|
+
/** The first n bytes held, joined, or undefined while fewer are here. */
|
|
105
|
+
#peek(n) {
|
|
106
|
+
if (this.#length < n)
|
|
107
|
+
return undefined;
|
|
108
|
+
if ((this.#parts[0]?.length ?? 0) < n)
|
|
109
|
+
this.#parts = [Buffer.concat(this.#parts, this.#length)];
|
|
110
|
+
return this.#parts[0].subarray(0, n);
|
|
111
|
+
}
|
|
112
|
+
#drop(n) {
|
|
113
|
+
const first = this.#parts[0];
|
|
114
|
+
this.#parts[0] = first.subarray(n);
|
|
115
|
+
if (this.#parts[0].length === 0)
|
|
116
|
+
this.#parts.shift();
|
|
117
|
+
this.#length -= n;
|
|
118
|
+
}
|
|
119
|
+
push(chunk) {
|
|
120
|
+
if (this.#ended || chunk.length === 0)
|
|
121
|
+
return [];
|
|
122
|
+
this.#parts.push(Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
|
123
|
+
this.#length += chunk.length;
|
|
124
|
+
const entries = [];
|
|
125
|
+
for (;;) {
|
|
126
|
+
const head = this.#peek(BLOCK);
|
|
127
|
+
if (head === undefined)
|
|
128
|
+
return entries;
|
|
129
|
+
if (head.every((byte) => byte === 0)) {
|
|
130
|
+
this.#ended = true;
|
|
131
|
+
this.#parts = [];
|
|
132
|
+
this.#length = 0;
|
|
133
|
+
return entries;
|
|
134
|
+
}
|
|
135
|
+
let sum = 0;
|
|
136
|
+
for (let at = 0; at < BLOCK; at++)
|
|
137
|
+
sum += at >= 148 && at < 156 ? 0x20 : head[at];
|
|
138
|
+
if (sum !== number(head, 148, 8))
|
|
139
|
+
throw new Error(`the archive has a header whose checksum is not its bytes' (${JSON.stringify(text(head, 0, 100))})`);
|
|
140
|
+
const flag = text(head, 156, 1) || "0";
|
|
141
|
+
const size = flag === "x" || flag === "g" || flag === "L" || flag === "K" ? number(head, 124, 12) : (this.#next.size ?? number(head, 124, 12));
|
|
142
|
+
if (!sized(size))
|
|
143
|
+
throw new Error(`the archive has a header whose size is no count of bytes (${JSON.stringify(text(head, 0, 100))})`);
|
|
144
|
+
if (!this.#taken && this.#take !== undefined && !this.#take(size))
|
|
145
|
+
throw new Error(`the archive has an entry of ${size} bytes, more than may be read (${JSON.stringify(this.#next.path ?? text(head, 0, 100))})`);
|
|
146
|
+
this.#taken = true;
|
|
147
|
+
const whole = this.#peek(BLOCK + size + ((BLOCK - (size % BLOCK)) % BLOCK));
|
|
148
|
+
if (whole === undefined)
|
|
149
|
+
return entries;
|
|
150
|
+
const body = Buffer.from(whole.subarray(BLOCK, BLOCK + size));
|
|
151
|
+
const block = Buffer.from(head);
|
|
152
|
+
this.#drop(whole.length);
|
|
153
|
+
this.#taken = false;
|
|
154
|
+
const entry = this.#entry(block, flag, body);
|
|
155
|
+
if (entry !== undefined)
|
|
156
|
+
entries.push(entry);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
#entry(block, flag, body) {
|
|
160
|
+
if (flag === "x") {
|
|
161
|
+
const records = pax(body);
|
|
162
|
+
const size = records.size === undefined ? this.#next.size : /^\d+$/.test(records.size) ? Number(records.size) : Number.NaN;
|
|
163
|
+
if (size !== undefined && !sized(size))
|
|
164
|
+
throw new Error(`the archive has a pax size that is no count of bytes (${JSON.stringify(records.size)})`);
|
|
165
|
+
this.#next = { path: records.path ?? this.#next.path, linkpath: records.linkpath ?? this.#next.linkpath, ...(size === undefined ? {} : { size }) };
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
if (flag === "g")
|
|
169
|
+
return undefined;
|
|
170
|
+
if (flag === "L" || flag === "K") {
|
|
171
|
+
const value = body.toString("utf8").replace(/\0+$/, "");
|
|
172
|
+
this.#next = flag === "L" ? { ...this.#next, path: value } : { ...this.#next, linkpath: value };
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
const prefix = text(block, 345, 155);
|
|
176
|
+
const name = this.#next.path ?? (prefix ? `${prefix}/${text(block, 0, 100)}` : text(block, 0, 100));
|
|
177
|
+
const link = this.#next.linkpath ?? text(block, 157, 100);
|
|
178
|
+
this.#next = {};
|
|
179
|
+
const type = flag === "0" || flag === "7" ? "file" : flag === "5" ? "dir" : flag === "2" ? "symlink" : "other";
|
|
180
|
+
const mode = number(block, 100, 8) & 0o7777;
|
|
181
|
+
return { name, type, mode, ...(type === "file" ? { body } : {}), ...(type === "symlink" ? { link } : {}) };
|
|
182
|
+
}
|
|
183
|
+
/** Throws in words where the bytes ended inside an entry; a short tail of no whole header, or none, is the end. */
|
|
184
|
+
finish() {
|
|
185
|
+
const head = this.#ended ? undefined : this.#peek(BLOCK);
|
|
186
|
+
if (head !== undefined)
|
|
187
|
+
throw new Error(`the archive ends inside ${this.#next.path ?? text(head, 0, 100)}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Every entry of an archive, in order. Throws in words on an archive it cannot read. */
|
|
191
|
+
export function untar(bytes) {
|
|
192
|
+
const reader = new TarReader();
|
|
193
|
+
const entries = reader.push(bytes);
|
|
194
|
+
reader.finish();
|
|
195
|
+
return entries;
|
|
196
|
+
}
|
|
197
|
+
/** The entries of an archive as its chunks come, each whole (`take` as TarReader's). Throws in words on an archive it cannot read. */
|
|
198
|
+
export async function* untarStream(chunks, options = {}) {
|
|
199
|
+
const reader = new TarReader(options);
|
|
200
|
+
for await (const chunk of chunks)
|
|
201
|
+
yield* reader.push(chunk);
|
|
202
|
+
reader.finish();
|
|
203
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-computer",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.45",
|
|
4
4
|
"description": "The open platform's computer protocol: a daemon in every computer, and one provisioner per vendor, starting with Docker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface TarEntry {
|
|
2
|
-
name: string;
|
|
3
|
-
type: "file" | "dir" | "symlink" | "other";
|
|
4
|
-
mode: number;
|
|
5
|
-
body?: Uint8Array;
|
|
6
|
-
link?: string;
|
|
7
|
-
}
|
|
8
|
-
/** A ustar archive of these entries, names as given (each under 100 bytes). */
|
|
9
|
-
export declare function tarOf(entries: TarEntry[]): Buffer;
|
|
10
|
-
/** Every entry of an archive, in order. Throws in words on an archive it cannot read. */
|
|
11
|
-
export declare function untar(bytes: Uint8Array): TarEntry[];
|
|
12
|
-
/** An entry as one comparable line: its name without "./" or a trailing "/", type, mode, and content hash or target. */
|
|
13
|
-
export declare function describeEntry(entry: TarEntry): string;
|
package/dist/conformance/tar.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// Just enough tar for the suite to build archives and read them back without the host's tar: ustar out; ustar, pax
|
|
2
|
-
// and GNU long names in.
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
const TYPE_FLAG = { file: "0", dir: "5", symlink: "2", other: "0" };
|
|
5
|
-
function header(name, type, mode, size, link) {
|
|
6
|
-
const block = Buffer.alloc(512);
|
|
7
|
-
const field = (at, length, value) => block.write(value, at, length, "utf8");
|
|
8
|
-
const octal = (value, width) => `${value.toString(8).padStart(width - 1, "0")}\0`;
|
|
9
|
-
field(0, 100, name);
|
|
10
|
-
field(100, 8, octal(mode, 8));
|
|
11
|
-
field(108, 8, octal(0, 8));
|
|
12
|
-
field(116, 8, octal(0, 8));
|
|
13
|
-
field(124, 12, octal(size, 12));
|
|
14
|
-
field(136, 12, octal(Math.floor(Date.now() / 1000), 12));
|
|
15
|
-
field(148, 8, " ");
|
|
16
|
-
field(156, 1, type);
|
|
17
|
-
field(157, 100, link);
|
|
18
|
-
field(257, 6, "ustar\0");
|
|
19
|
-
field(263, 2, "00");
|
|
20
|
-
let sum = 0;
|
|
21
|
-
for (const byte of block)
|
|
22
|
-
sum += byte;
|
|
23
|
-
field(148, 8, `${sum.toString(8).padStart(6, "0")}\0 `);
|
|
24
|
-
return block;
|
|
25
|
-
}
|
|
26
|
-
const pad = (length) => Buffer.alloc((512 - (length % 512)) % 512);
|
|
27
|
-
/** A ustar archive of these entries, names as given (each under 100 bytes). */
|
|
28
|
-
export function tarOf(entries) {
|
|
29
|
-
const parts = [];
|
|
30
|
-
for (const entry of entries) {
|
|
31
|
-
const body = entry.type === "file" ? Buffer.from(entry.body ?? new Uint8Array()) : Buffer.alloc(0);
|
|
32
|
-
parts.push(header(entry.name, TYPE_FLAG[entry.type], entry.mode, body.length, entry.link ?? ""), body, pad(body.length));
|
|
33
|
-
}
|
|
34
|
-
parts.push(Buffer.alloc(1024));
|
|
35
|
-
return Buffer.concat(parts);
|
|
36
|
-
}
|
|
37
|
-
const text = (block, at, length) => {
|
|
38
|
-
const raw = block.subarray(at, at + length);
|
|
39
|
-
const end = raw.indexOf(0);
|
|
40
|
-
return raw.subarray(0, end < 0 ? raw.length : end).toString("utf8");
|
|
41
|
-
};
|
|
42
|
-
const number = (block, at, length) => Number.parseInt(text(block, at, length).trim() || "0", 8);
|
|
43
|
-
/** Reads pax records: "<len> key=value\n" each. */
|
|
44
|
-
function pax(body) {
|
|
45
|
-
const records = {};
|
|
46
|
-
let at = 0;
|
|
47
|
-
while (at < body.length) {
|
|
48
|
-
const space = body.indexOf(0x20, at);
|
|
49
|
-
if (space < 0)
|
|
50
|
-
break;
|
|
51
|
-
const length = Number.parseInt(body.subarray(at, space).toString("utf8"), 10);
|
|
52
|
-
if (!(length > 0))
|
|
53
|
-
break;
|
|
54
|
-
const record = body.subarray(space + 1, at + length - 1).toString("utf8");
|
|
55
|
-
const equals = record.indexOf("=");
|
|
56
|
-
if (equals > 0)
|
|
57
|
-
records[record.slice(0, equals)] = record.slice(equals + 1);
|
|
58
|
-
at += length;
|
|
59
|
-
}
|
|
60
|
-
return records;
|
|
61
|
-
}
|
|
62
|
-
/** Every entry of an archive, in order. Throws in words on an archive it cannot read. */
|
|
63
|
-
export function untar(bytes) {
|
|
64
|
-
const archive = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
65
|
-
const entries = [];
|
|
66
|
-
let next = {};
|
|
67
|
-
let at = 0;
|
|
68
|
-
while (at + 512 <= archive.length) {
|
|
69
|
-
const block = archive.subarray(at, at + 512);
|
|
70
|
-
if (block.every((byte) => byte === 0))
|
|
71
|
-
break;
|
|
72
|
-
const size = number(block, 124, 12);
|
|
73
|
-
const flag = text(block, 156, 1) || "0";
|
|
74
|
-
const body = archive.subarray(at + 512, at + 512 + size);
|
|
75
|
-
if (body.length < size)
|
|
76
|
-
throw new Error(`the archive ends inside ${text(block, 0, 100)}`);
|
|
77
|
-
at += 512 + size + ((512 - (size % 512)) % 512);
|
|
78
|
-
if (flag === "x") {
|
|
79
|
-
const records = pax(body);
|
|
80
|
-
next = { path: records.path ?? next.path, linkpath: records.linkpath ?? next.linkpath };
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (flag === "g")
|
|
84
|
-
continue;
|
|
85
|
-
if (flag === "L" || flag === "K") {
|
|
86
|
-
const value = body.toString("utf8").replace(/\0+$/, "");
|
|
87
|
-
next = flag === "L" ? { ...next, path: value } : { ...next, linkpath: value };
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
const prefix = text(block, 345, 155);
|
|
91
|
-
const name = next.path ?? (prefix ? `${prefix}/${text(block, 0, 100)}` : text(block, 0, 100));
|
|
92
|
-
const link = next.linkpath ?? text(block, 157, 100);
|
|
93
|
-
next = {};
|
|
94
|
-
const type = flag === "0" || flag === "7" ? "file" : flag === "5" ? "dir" : flag === "2" ? "symlink" : "other";
|
|
95
|
-
const mode = number(block, 100, 8) & 0o7777;
|
|
96
|
-
entries.push({ name, type, mode, ...(type === "file" ? { body } : {}), ...(type === "symlink" ? { link } : {}) });
|
|
97
|
-
}
|
|
98
|
-
return entries;
|
|
99
|
-
}
|
|
100
|
-
/** An entry as one comparable line: its name without "./" or a trailing "/", type, mode, and content hash or target. */
|
|
101
|
-
export function describeEntry(entry) {
|
|
102
|
-
const name = entry.name.replace(/^\.\//, "").replace(/\/$/, "");
|
|
103
|
-
const what = entry.type === "file" ? createHash("sha256").update(entry.body ?? new Uint8Array()).digest("hex") : entry.type === "symlink" ? `-> ${entry.link}` : "";
|
|
104
|
-
return `${name} ${entry.type} ${entry.mode.toString(8)} ${what}`.trimEnd();
|
|
105
|
-
}
|