@aexhq/sdk 0.39.0 → 0.40.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.
- package/README.md +22 -16
- package/dist/_contracts/api-key.d.ts +49 -0
- package/dist/_contracts/api-key.js +87 -0
- package/dist/_contracts/bundle-manifest.d.ts +86 -0
- package/dist/_contracts/bundle-manifest.js +157 -0
- package/dist/_contracts/error-codes.d.ts +26 -0
- package/dist/_contracts/error-codes.js +79 -0
- package/dist/_contracts/error-factory.d.ts +32 -0
- package/dist/_contracts/error-factory.js +142 -0
- package/dist/_contracts/event-envelope.d.ts +33 -10
- package/dist/_contracts/event-envelope.js +46 -10
- package/dist/_contracts/event-view.d.ts +123 -0
- package/dist/_contracts/event-view.js +120 -0
- package/dist/_contracts/http.js +12 -3
- package/dist/_contracts/index.d.ts +8 -4
- package/dist/_contracts/index.js +11 -7
- package/dist/_contracts/models.d.ts +15 -0
- package/dist/_contracts/models.js +33 -0
- package/dist/_contracts/operations.d.ts +53 -2
- package/dist/_contracts/operations.js +119 -7
- package/dist/_contracts/run-record.d.ts +3 -2
- package/dist/_contracts/runtime-types.d.ts +126 -36
- package/dist/_contracts/runtime-types.js +33 -1
- package/dist/_contracts/sdk-errors.d.ts +61 -2
- package/dist/_contracts/sdk-errors.js +83 -3
- package/dist/_contracts/sdk-secrets.js +31 -6
- package/dist/_contracts/stable.d.ts +14 -0
- package/dist/_contracts/stable.js +14 -0
- package/dist/_contracts/status.d.ts +28 -1
- package/dist/_contracts/status.js +48 -3
- package/dist/_contracts/submission.d.ts +79 -2
- package/dist/_contracts/submission.js +148 -5
- package/dist/_contracts/suggest.d.ts +15 -0
- package/dist/_contracts/suggest.js +54 -0
- package/dist/asset-upload.d.ts +26 -0
- package/dist/asset-upload.js +218 -3
- package/dist/asset-upload.js.map +1 -1
- package/dist/bundle.d.ts +14 -3
- package/dist/bundle.js +34 -14
- package/dist/bundle.js.map +1 -1
- package/dist/canonical-zip.d.ts +68 -0
- package/dist/canonical-zip.js +307 -0
- package/dist/canonical-zip.js.map +1 -0
- package/dist/cli.mjs +1923 -338
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +217 -58
- package/dist/client.js +749 -261
- package/dist/client.js.map +1 -1
- package/dist/file.d.ts +33 -6
- package/dist/file.js +120 -54
- package/dist/file.js.map +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.js +26 -9
- package/dist/index.js.map +1 -1
- package/dist/node-fs.d.ts +26 -9
- package/dist/node-fs.js +13 -38
- package/dist/node-fs.js.map +1 -1
- package/dist/node-walk.d.ts +69 -0
- package/dist/node-walk.js +146 -0
- package/dist/node-walk.js.map +1 -0
- package/dist/retry.d.ts +9 -13
- package/dist/retry.js +18 -17
- package/dist/retry.js.map +1 -1
- package/dist/skill.d.ts +16 -4
- package/dist/skill.js +18 -9
- package/dist/skill.js.map +1 -1
- package/dist/tool.d.ts +14 -2
- package/dist/tool.js +33 -7
- package/dist/tool.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/authentication.md +29 -5
- package/docs/billing.md +6 -0
- package/docs/concepts/agent-tools.md +11 -0
- package/docs/defaults.md +1 -0
- package/docs/errors.md +64 -4
- package/docs/events.md +84 -49
- package/docs/limits-and-quotas.md +24 -0
- package/docs/networking.md +7 -1
- package/docs/outputs.md +36 -7
- package/docs/quickstart.md +17 -7
- package/docs/run-config.md +3 -3
- package/docs/secrets.md +14 -0
- package/examples/feature-tour.ts +4 -6
- package/examples/spike-settle-latency.ts +125 -0
- package/package.json +4 -3
- package/dist/_contracts/event-guards.d.ts +0 -67
- package/dist/_contracts/event-guards.js +0 -36
package/dist/bundle.js
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { zipSync } from "fflate";
|
|
2
|
-
import { SKILL_BUNDLE_LIMITS, validateSkillBundleEntry } from "./_contracts/index.js";
|
|
2
|
+
import { RESERVED_META_ENTRY, SKILL_BUNDLE_LIMITS, bundleManifestIsEmpty, serializeBundleManifest, validateSkillBundleEntry } from "./_contracts/index.js";
|
|
3
3
|
const TEXT = new TextEncoder();
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Build the ordered {@link Zippable} for a collected content map: content entries
|
|
6
|
+
* sorted lexicographically, then (when `meta` carries any exec/symlink) the
|
|
7
|
+
* canonical `.aexmeta.json` sidecar appended LAST. Insertion order is the zip
|
|
8
|
+
* order (fflate iterates keys in insertion order), so the sidecar is always the
|
|
9
|
+
* final entry and a metadata-free bundle is byte-identical to today's output.
|
|
10
|
+
*/
|
|
11
|
+
function buildCanonicalZippable(collected, meta) {
|
|
12
|
+
const sorted = [...collected.entries()].sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
13
|
+
const zippable = {};
|
|
14
|
+
for (const [path, bytes] of sorted) {
|
|
15
|
+
zippable[path] = [bytes, { mtime: ZIP_EPOCH }];
|
|
16
|
+
}
|
|
17
|
+
if (meta && !bundleManifestIsEmpty(meta)) {
|
|
18
|
+
const sidecar = serializeBundleManifest({ v: 1, exec: meta.exec ?? [], symlinks: meta.symlinks ?? [] });
|
|
19
|
+
zippable[RESERVED_META_ENTRY] = [sidecar, { mtime: ZIP_EPOCH }];
|
|
20
|
+
}
|
|
21
|
+
return zippable;
|
|
22
|
+
}
|
|
23
|
+
/** Reject a user file colliding with the reserved sidecar name (matches the `tool.json` precedent). */
|
|
24
|
+
function assertNotReservedMetaPath(path, kind) {
|
|
25
|
+
if (path === RESERVED_META_ENTRY) {
|
|
26
|
+
throw new Error(`${kind} files must not include reserved "${RESERVED_META_ENTRY}"; fidelity metadata is emitted by the SDK`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function bundleSkillFiles(files, meta) {
|
|
5
30
|
if (!files || typeof files !== "object") {
|
|
6
31
|
throw new Error("Skill files map is required");
|
|
7
32
|
}
|
|
@@ -21,6 +46,7 @@ export function bundleSkillFiles(files) {
|
|
|
21
46
|
throw new Error(`Skill file "${rawPath}" must be a string or Uint8Array`);
|
|
22
47
|
}
|
|
23
48
|
const entry = validateSkillBundleEntry({ path: rawPath, size: bytes.byteLength });
|
|
49
|
+
assertNotReservedMetaPath(entry.path, "Skill bundle");
|
|
24
50
|
if (entry.path === "SKILL.md") {
|
|
25
51
|
hasSkillMd = true;
|
|
26
52
|
}
|
|
@@ -41,19 +67,16 @@ export function bundleSkillFiles(files) {
|
|
|
41
67
|
// Sort entries and pin every mtime to the epoch so the byte output is
|
|
42
68
|
// identical across machines and re-runs (the BFF re-canonicalises and
|
|
43
69
|
// recomputes the canonical hash, so this is for retry-safety / debug
|
|
44
|
-
// reproducibility rather than a wire-shape contract).
|
|
45
|
-
|
|
46
|
-
const zippable =
|
|
47
|
-
for (const [path, bytes] of sorted) {
|
|
48
|
-
zippable[path] = [bytes, { mtime: ZIP_EPOCH }];
|
|
49
|
-
}
|
|
70
|
+
// reproducibility rather than a wire-shape contract). The fidelity sidecar,
|
|
71
|
+
// when present, is appended LAST so a metadata-free bundle is byte-identical.
|
|
72
|
+
const zippable = buildCanonicalZippable(collected, meta);
|
|
50
73
|
const zip = zipSync(zippable, { level: 6 });
|
|
51
74
|
if (zip.byteLength > SKILL_BUNDLE_LIMITS.maxCompressedBytes) {
|
|
52
75
|
throw new Error(`Skill bundle exceeds compressed cap of ${SKILL_BUNDLE_LIMITS.maxCompressedBytes} bytes (got ${zip.byteLength})`);
|
|
53
76
|
}
|
|
54
77
|
return { zip, fileCount: entries.length, compressedSize: zip.byteLength };
|
|
55
78
|
}
|
|
56
|
-
export function bundleToolFiles(files, manifest) {
|
|
79
|
+
export function bundleToolFiles(files, manifest, meta) {
|
|
57
80
|
if (!files || typeof files !== "object") {
|
|
58
81
|
throw new Error("Tool files map is required");
|
|
59
82
|
}
|
|
@@ -74,6 +97,7 @@ export function bundleToolFiles(files, manifest) {
|
|
|
74
97
|
throw new Error(`Tool file "${rawPath}" must be a string or Uint8Array`);
|
|
75
98
|
}
|
|
76
99
|
const entry = validateSkillBundleEntry({ path: rawPath, size: bytes.byteLength });
|
|
100
|
+
assertNotReservedMetaPath(entry.path, "Tool bundle");
|
|
77
101
|
totalDecompressed += bytes.byteLength;
|
|
78
102
|
if (totalDecompressed > SKILL_BUNDLE_LIMITS.maxDecompressedBytes) {
|
|
79
103
|
throw new Error(`Tool bundle exceeds decompressed cap of ${SKILL_BUNDLE_LIMITS.maxDecompressedBytes} bytes`);
|
|
@@ -93,11 +117,7 @@ export function bundleToolFiles(files, manifest) {
|
|
|
93
117
|
throw new Error('Tool bundle files must not include reserved "tool.json"; pass manifest fields to Tool.fromFiles instead');
|
|
94
118
|
}
|
|
95
119
|
collected.set("tool.json", manifestBytes);
|
|
96
|
-
const
|
|
97
|
-
const zippable = {};
|
|
98
|
-
for (const [path, bytes] of sorted) {
|
|
99
|
-
zippable[path] = [bytes, { mtime: ZIP_EPOCH }];
|
|
100
|
-
}
|
|
120
|
+
const zippable = buildCanonicalZippable(collected, meta);
|
|
101
121
|
const zip = zipSync(zippable, { level: 6 });
|
|
102
122
|
if (zip.byteLength > SKILL_BUNDLE_LIMITS.maxCompressedBytes) {
|
|
103
123
|
throw new Error(`Tool bundle exceeds compressed cap of ${SKILL_BUNDLE_LIMITS.maxCompressedBytes} bytes (got ${zip.byteLength})`);
|
package/dist/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EAGzB,MAAM,kBAAkB,CAAC;AAuB1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IAAI,GAAG,IAAI,CAAC,CAAC,CAAW,CAAC;QAC/B,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical zip framer — the deterministic, content-addressed zip layer the
|
|
3
|
+
* asset upload path dedups on. Two canonical forms, both byte-stable:
|
|
4
|
+
*
|
|
5
|
+
* Canonical A (the ~99% case: every entry ≤ {@link ENTRY_RAM_CAP}) — a custom
|
|
6
|
+
* per-entry framer that reproduces fflate's `zipSync(..., {level:6})` output
|
|
7
|
+
* BYTE-FOR-BYTE (sorted entries, epoch mtime, per-entry crc32, per-entry
|
|
8
|
+
* one-shot `deflateSync` level 6, real sizes in a flag-0 local header) while
|
|
9
|
+
* holding only ONE entry in memory at a time. Because it equals `zipSync`, a
|
|
10
|
+
* streamed large bundle dedups against a small in-memory bundle of the same
|
|
11
|
+
* content — no dedup seam. Pinned forever by a golden byte-identity test.
|
|
12
|
+
*
|
|
13
|
+
* Canonical B (a bundle containing ANY entry > {@link ENTRY_RAM_CAP}, e.g. a
|
|
14
|
+
* lone multi-GB dataset file) — fflate's streaming `Zip`/`ZipDeflate` driven
|
|
15
|
+
* with a PINNED {@link CANONICAL_B_PUSH_BYTES} push size. It does NOT equal
|
|
16
|
+
* `zipSync` (it emits streaming data descriptors, GP-flag bit 3), but it IS
|
|
17
|
+
* internally deterministic: same input → same bytes every time (pinned chunk
|
|
18
|
+
* size + pinned fflate version). Its own second canonical / dedup namespace,
|
|
19
|
+
* pinned by its own golden determinism test. A single giant entry cannot be
|
|
20
|
+
* both `zipSync`-identical AND framed in O(part) memory, so this is the
|
|
21
|
+
* accepted tradeoff (such a file has no small twin to dedup against).
|
|
22
|
+
*
|
|
23
|
+
* Browser-safe: this module imports ONLY fflate (no `node:*`). The node-only
|
|
24
|
+
* streaming SHA-256 + multipart sink live in the callers (file.ts / asset-upload).
|
|
25
|
+
*/
|
|
26
|
+
/** Epoch every entry mtime is pinned to (matches the pre-streaming `zipSync` path). */
|
|
27
|
+
export declare const ZIP_EPOCH: Date;
|
|
28
|
+
/**
|
|
29
|
+
* Per-entry raw-byte ceiling for Canonical A. A single entry above this cannot be
|
|
30
|
+
* one-shot `deflateSync`-ed within a bounded memory budget, so a bundle carrying
|
|
31
|
+
* any such entry falls to Canonical B. A memory-budget knob, NOT a correctness
|
|
32
|
+
* boundary (the golden tests pin both forms).
|
|
33
|
+
*/
|
|
34
|
+
export declare const ENTRY_RAM_CAP: number;
|
|
35
|
+
/** Pinned push size for Canonical B's streaming deflate. LOAD-BEARING for determinism. */
|
|
36
|
+
export declare const CANONICAL_B_PUSH_BYTES: number;
|
|
37
|
+
/** One-shot CRC-32 over `bytes`. */
|
|
38
|
+
export declare function crc32(bytes: Uint8Array): number;
|
|
39
|
+
/** A byte sink; may apply backpressure (pass-2 multipart) or run sync (pass-1 hash). */
|
|
40
|
+
export type ByteSink = (chunk: Uint8Array) => void | Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* One bundle entry to frame, in FINAL canonical order. `name` is the forward-slash
|
|
43
|
+
* bundle-relative path; `size` its raw byte length (from `stat` or the in-memory
|
|
44
|
+
* bytes). `read()` yields the whole entry (Canonical A / small); `openStream()` is
|
|
45
|
+
* required only when `size > ENTRY_RAM_CAP` (Canonical B).
|
|
46
|
+
*/
|
|
47
|
+
export interface ZipEntrySource {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly size: number;
|
|
50
|
+
read(): Uint8Array | Promise<Uint8Array>;
|
|
51
|
+
openStream?(): AsyncIterable<Uint8Array>;
|
|
52
|
+
}
|
|
53
|
+
/** True when the bundle must use Canonical B (some entry exceeds the RAM cap). */
|
|
54
|
+
export declare function bundleNeedsCanonicalB(entries: readonly {
|
|
55
|
+
readonly size: number;
|
|
56
|
+
}[]): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Stream the canonical zip of `entries` (FINAL canonical order) into `sink`.
|
|
59
|
+
* Picks Canonical A (byte-identical to `zipSync`) unless an entry exceeds
|
|
60
|
+
* {@link ENTRY_RAM_CAP}, in which case the whole bundle uses Canonical B.
|
|
61
|
+
*/
|
|
62
|
+
export declare function streamBundleZip(entries: readonly ZipEntrySource[], sink: ByteSink): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Synchronous Canonical-A convenience — frame an ordered `[name, bytes]` list to
|
|
65
|
+
* a single buffer. Used by the golden byte-identity test (`=== zipSync`) and by
|
|
66
|
+
* callers that already hold all bytes in memory. NOT for giant entries.
|
|
67
|
+
*/
|
|
68
|
+
export declare function frameCanonicalZipSync(entries: ReadonlyArray<readonly [string, Uint8Array]>): Uint8Array;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical zip framer — the deterministic, content-addressed zip layer the
|
|
3
|
+
* asset upload path dedups on. Two canonical forms, both byte-stable:
|
|
4
|
+
*
|
|
5
|
+
* Canonical A (the ~99% case: every entry ≤ {@link ENTRY_RAM_CAP}) — a custom
|
|
6
|
+
* per-entry framer that reproduces fflate's `zipSync(..., {level:6})` output
|
|
7
|
+
* BYTE-FOR-BYTE (sorted entries, epoch mtime, per-entry crc32, per-entry
|
|
8
|
+
* one-shot `deflateSync` level 6, real sizes in a flag-0 local header) while
|
|
9
|
+
* holding only ONE entry in memory at a time. Because it equals `zipSync`, a
|
|
10
|
+
* streamed large bundle dedups against a small in-memory bundle of the same
|
|
11
|
+
* content — no dedup seam. Pinned forever by a golden byte-identity test.
|
|
12
|
+
*
|
|
13
|
+
* Canonical B (a bundle containing ANY entry > {@link ENTRY_RAM_CAP}, e.g. a
|
|
14
|
+
* lone multi-GB dataset file) — fflate's streaming `Zip`/`ZipDeflate` driven
|
|
15
|
+
* with a PINNED {@link CANONICAL_B_PUSH_BYTES} push size. It does NOT equal
|
|
16
|
+
* `zipSync` (it emits streaming data descriptors, GP-flag bit 3), but it IS
|
|
17
|
+
* internally deterministic: same input → same bytes every time (pinned chunk
|
|
18
|
+
* size + pinned fflate version). Its own second canonical / dedup namespace,
|
|
19
|
+
* pinned by its own golden determinism test. A single giant entry cannot be
|
|
20
|
+
* both `zipSync`-identical AND framed in O(part) memory, so this is the
|
|
21
|
+
* accepted tradeoff (such a file has no small twin to dedup against).
|
|
22
|
+
*
|
|
23
|
+
* Browser-safe: this module imports ONLY fflate (no `node:*`). The node-only
|
|
24
|
+
* streaming SHA-256 + multipart sink live in the callers (file.ts / asset-upload).
|
|
25
|
+
*/
|
|
26
|
+
import { deflateSync, strToU8, Zip, ZipDeflate } from "fflate";
|
|
27
|
+
/** Epoch every entry mtime is pinned to (matches the pre-streaming `zipSync` path). */
|
|
28
|
+
export const ZIP_EPOCH = new Date(Date.UTC(1980, 0, 1));
|
|
29
|
+
/**
|
|
30
|
+
* Per-entry raw-byte ceiling for Canonical A. A single entry above this cannot be
|
|
31
|
+
* one-shot `deflateSync`-ed within a bounded memory budget, so a bundle carrying
|
|
32
|
+
* any such entry falls to Canonical B. A memory-budget knob, NOT a correctness
|
|
33
|
+
* boundary (the golden tests pin both forms).
|
|
34
|
+
*/
|
|
35
|
+
export const ENTRY_RAM_CAP = 512 * 1024 * 1024;
|
|
36
|
+
/** Pinned push size for Canonical B's streaming deflate. LOAD-BEARING for determinism. */
|
|
37
|
+
export const CANONICAL_B_PUSH_BYTES = 1024 * 1024;
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// CRC-32 (IEEE, poly 0xEDB88320) — matches zlib/fflate, verified byte-identical.
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
const CRC_TABLE = (() => {
|
|
42
|
+
const table = new Uint32Array(256);
|
|
43
|
+
for (let n = 0; n < 256; n++) {
|
|
44
|
+
let c = n;
|
|
45
|
+
for (let k = 0; k < 8; k++)
|
|
46
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
47
|
+
table[n] = c >>> 0;
|
|
48
|
+
}
|
|
49
|
+
return table;
|
|
50
|
+
})();
|
|
51
|
+
/** One-shot CRC-32 over `bytes`. */
|
|
52
|
+
export function crc32(bytes) {
|
|
53
|
+
let c = 0xffffffff;
|
|
54
|
+
for (let i = 0; i < bytes.length; i++)
|
|
55
|
+
c = (CRC_TABLE[(c ^ bytes[i]) & 0xff] ^ (c >>> 8)) >>> 0;
|
|
56
|
+
return (c ^ 0xffffffff) >>> 0;
|
|
57
|
+
}
|
|
58
|
+
/** True when the bundle must use Canonical B (some entry exceeds the RAM cap). */
|
|
59
|
+
export function bundleNeedsCanonicalB(entries) {
|
|
60
|
+
return entries.some((e) => e.size > ENTRY_RAM_CAP);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Reorder entries into the EXACT order `zipSync` emits them. `zipSync` iterates
|
|
64
|
+
* its input object with `for..in`, so integer-index-like keys (e.g. a file
|
|
65
|
+
* literally named `"1"`) enumerate FIRST in ascending numeric order, then the
|
|
66
|
+
* rest in insertion order. Delegating to `Object.keys` reproduces that engine
|
|
67
|
+
* rule verbatim, so the framer stays byte-identical for every input (the callers
|
|
68
|
+
* pass entries already sorted, which becomes the insertion order for non-integer
|
|
69
|
+
* keys). Duplicate names collapse to the last occurrence, matching object build.
|
|
70
|
+
*/
|
|
71
|
+
function canonicalOrder(entries) {
|
|
72
|
+
const marker = {};
|
|
73
|
+
const byName = new Map();
|
|
74
|
+
for (const e of entries) {
|
|
75
|
+
marker[e.name] = true;
|
|
76
|
+
byName.set(e.name, e);
|
|
77
|
+
}
|
|
78
|
+
return Object.keys(marker).map((name) => byName.get(name));
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Little-endian header writers.
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
function pushU16(out, v) {
|
|
84
|
+
out.push(v & 0xff, (v >>> 8) & 0xff);
|
|
85
|
+
}
|
|
86
|
+
function pushU32(out, v) {
|
|
87
|
+
const u = v >>> 0;
|
|
88
|
+
out.push(u & 0xff, (u >>> 8) & 0xff, (u >>> 16) & 0xff, (u >>> 24) & 0xff);
|
|
89
|
+
}
|
|
90
|
+
/** DOS mod-time / mod-date words for a UTC Date (matches fflate's encoding). */
|
|
91
|
+
function dosTimeDate(dt) {
|
|
92
|
+
const time = (dt.getUTCHours() << 11) | (dt.getUTCMinutes() << 5) | (dt.getUTCSeconds() >> 1);
|
|
93
|
+
const date = ((dt.getUTCFullYear() - 1980) << 9) | ((dt.getUTCMonth() + 1) << 5) | dt.getUTCDate();
|
|
94
|
+
return { time: time & 0xffff, date: date & 0xffff };
|
|
95
|
+
}
|
|
96
|
+
const { time: DOS_TIME, date: DOS_DATE } = dosTimeDate(ZIP_EPOCH);
|
|
97
|
+
/** Frame one Canonical-A entry: local header (flag 0, real sizes) + deflate-L6 payload. */
|
|
98
|
+
function frameEntryA(name, raw, offset) {
|
|
99
|
+
// Encode the name with fflate's OWN `strToU8` (what `zipSync` uses) so the
|
|
100
|
+
// filename bytes are byte-identical to `zipSync` for every input, including
|
|
101
|
+
// edge unicode (lone surrogates etc.) where TextEncoder would diverge.
|
|
102
|
+
const nameBytes = strToU8(name);
|
|
103
|
+
const payload = deflateSync(raw, { level: 6 });
|
|
104
|
+
const crc = crc32(raw);
|
|
105
|
+
// GP flag: low byte = dbf(level 6) << 1 = 0; high byte = 0x08 (bit 11, UTF-8)
|
|
106
|
+
// when the name is non-ASCII — fflate sets it iff the encoded byte length
|
|
107
|
+
// differs from the JS string length. Matching it keeps unicode names identical.
|
|
108
|
+
const gpFlag = nameBytes.length !== name.length ? 0x0800 : 0;
|
|
109
|
+
const local = [];
|
|
110
|
+
pushU32(local, 0x04034b50);
|
|
111
|
+
pushU16(local, 20); // version needed
|
|
112
|
+
pushU16(local, gpFlag); // GP flag
|
|
113
|
+
pushU16(local, 8); // method: deflate
|
|
114
|
+
pushU16(local, DOS_TIME);
|
|
115
|
+
pushU16(local, DOS_DATE);
|
|
116
|
+
pushU32(local, crc);
|
|
117
|
+
pushU32(local, payload.length);
|
|
118
|
+
pushU32(local, raw.length);
|
|
119
|
+
pushU16(local, nameBytes.length);
|
|
120
|
+
pushU16(local, 0); // extra len
|
|
121
|
+
const header = Uint8Array.from(local);
|
|
122
|
+
const localBytes = new Uint8Array(header.length + nameBytes.length + payload.length);
|
|
123
|
+
localBytes.set(header, 0);
|
|
124
|
+
localBytes.set(nameBytes, header.length);
|
|
125
|
+
localBytes.set(payload, header.length + nameBytes.length);
|
|
126
|
+
const central = [];
|
|
127
|
+
pushU32(central, 0x02014b50);
|
|
128
|
+
pushU16(central, 20); // version made by
|
|
129
|
+
pushU16(central, 20); // version needed
|
|
130
|
+
pushU16(central, gpFlag); // GP flag
|
|
131
|
+
pushU16(central, 8); // method
|
|
132
|
+
pushU16(central, DOS_TIME);
|
|
133
|
+
pushU16(central, DOS_DATE);
|
|
134
|
+
pushU32(central, crc);
|
|
135
|
+
pushU32(central, payload.length);
|
|
136
|
+
pushU32(central, raw.length);
|
|
137
|
+
pushU16(central, nameBytes.length);
|
|
138
|
+
pushU16(central, 0); // extra len
|
|
139
|
+
pushU16(central, 0); // comment len
|
|
140
|
+
pushU16(central, 0); // disk number
|
|
141
|
+
pushU16(central, 0); // internal attrs
|
|
142
|
+
pushU32(central, 0); // external attrs
|
|
143
|
+
pushU32(central, offset); // local header offset
|
|
144
|
+
const centralHeader = Uint8Array.from(central);
|
|
145
|
+
const centralBytes = new Uint8Array(centralHeader.length + nameBytes.length);
|
|
146
|
+
centralBytes.set(centralHeader, 0);
|
|
147
|
+
centralBytes.set(nameBytes, centralHeader.length);
|
|
148
|
+
return { local: localBytes, central: centralBytes, length: localBytes.length };
|
|
149
|
+
}
|
|
150
|
+
function eocd(recordCount, cdSize, cdOffset) {
|
|
151
|
+
const out = [];
|
|
152
|
+
pushU32(out, 0x06054b50);
|
|
153
|
+
pushU16(out, 0); // this disk
|
|
154
|
+
pushU16(out, 0); // cd start disk
|
|
155
|
+
pushU16(out, recordCount);
|
|
156
|
+
pushU16(out, recordCount);
|
|
157
|
+
pushU32(out, cdSize);
|
|
158
|
+
pushU32(out, cdOffset);
|
|
159
|
+
pushU16(out, 0); // comment len
|
|
160
|
+
return Uint8Array.from(out);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Stream a Canonical-A zip of `entries` (in FINAL canonical order) into `sink`,
|
|
164
|
+
* holding only one entry's raw + compressed bytes in memory at a time. Output is
|
|
165
|
+
* byte-identical to `zipSync(<same ordered entries>, {level:6})`.
|
|
166
|
+
*/
|
|
167
|
+
async function streamBundleZipA(entries, sink) {
|
|
168
|
+
const centrals = [];
|
|
169
|
+
let offset = 0;
|
|
170
|
+
for (const entry of entries) {
|
|
171
|
+
const raw = await entry.read();
|
|
172
|
+
const framed = frameEntryA(entry.name, raw, offset);
|
|
173
|
+
await sink(framed.local);
|
|
174
|
+
centrals.push(framed.central);
|
|
175
|
+
offset += framed.length;
|
|
176
|
+
}
|
|
177
|
+
let cdSize = 0;
|
|
178
|
+
for (const c of centrals)
|
|
179
|
+
cdSize += c.length;
|
|
180
|
+
for (const c of centrals)
|
|
181
|
+
await sink(c);
|
|
182
|
+
await sink(eocd(centrals.length, cdSize, offset));
|
|
183
|
+
}
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
// Canonical B — fflate streaming Zip with pinned push size (giant single entry).
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
/**
|
|
188
|
+
* Stream a Canonical-B zip into `sink` using fflate's streaming `Zip`, pushing
|
|
189
|
+
* each entry in fixed {@link CANONICAL_B_PUSH_BYTES} chunks. Deterministic for a
|
|
190
|
+
* given input + fflate version. Entries are added in the given (canonical) order.
|
|
191
|
+
*/
|
|
192
|
+
async function streamBundleZipB(entries, sink) {
|
|
193
|
+
const pending = [];
|
|
194
|
+
const zip = new Zip();
|
|
195
|
+
zip.ondata = (err, chunk) => {
|
|
196
|
+
if (err)
|
|
197
|
+
throw err;
|
|
198
|
+
if (chunk && chunk.length) {
|
|
199
|
+
// Copy: fflate may reuse the chunk buffer after ondata returns.
|
|
200
|
+
const copy = new Uint8Array(chunk.length);
|
|
201
|
+
copy.set(chunk);
|
|
202
|
+
pending.push(copy);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const drain = async () => {
|
|
206
|
+
while (pending.length > 0) {
|
|
207
|
+
const chunk = pending.shift();
|
|
208
|
+
await sink(chunk);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
for (const entry of entries) {
|
|
212
|
+
const file = new ZipDeflate(entry.name, { level: 6 });
|
|
213
|
+
file.mtime = ZIP_EPOCH; // pin mtime (not a constructor option in the fflate types)
|
|
214
|
+
zip.add(file);
|
|
215
|
+
if (entry.size === 0 || entry.size <= ENTRY_RAM_CAP) {
|
|
216
|
+
// Small entry inside a Canonical-B bundle: one push (still deterministic).
|
|
217
|
+
const raw = await entry.read();
|
|
218
|
+
file.push(raw, true);
|
|
219
|
+
await drain();
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
// Giant entry: pinned-chunk streaming from its byte stream. Buffer incoming
|
|
223
|
+
// chunks in a queue and assemble EXACTLY-`CANONICAL_B_PUSH_BYTES` pushes
|
|
224
|
+
// (last push carries the remainder) — O(total) copying regardless of the
|
|
225
|
+
// source's chunk sizes, and byte-identical push boundaries → deterministic.
|
|
226
|
+
const openStream = entry.openStream;
|
|
227
|
+
if (!openStream) {
|
|
228
|
+
throw new Error(`canonical-zip: entry ${JSON.stringify(entry.name)} exceeds ENTRY_RAM_CAP but has no openStream()`);
|
|
229
|
+
}
|
|
230
|
+
const queue = [];
|
|
231
|
+
let buffered = 0;
|
|
232
|
+
const emitPush = (size, last) => {
|
|
233
|
+
const buf = new Uint8Array(size);
|
|
234
|
+
let off = 0;
|
|
235
|
+
while (off < size) {
|
|
236
|
+
const head = queue[0];
|
|
237
|
+
const take = Math.min(head.length, size - off);
|
|
238
|
+
buf.set(head.subarray(0, take), off);
|
|
239
|
+
off += take;
|
|
240
|
+
if (take === head.length)
|
|
241
|
+
queue.shift();
|
|
242
|
+
else
|
|
243
|
+
queue[0] = head.subarray(take);
|
|
244
|
+
}
|
|
245
|
+
buffered -= size;
|
|
246
|
+
file.push(buf, last);
|
|
247
|
+
};
|
|
248
|
+
for await (const raw of openStream()) {
|
|
249
|
+
if (raw.length === 0)
|
|
250
|
+
continue;
|
|
251
|
+
queue.push(raw);
|
|
252
|
+
buffered += raw.length;
|
|
253
|
+
while (buffered >= CANONICAL_B_PUSH_BYTES) {
|
|
254
|
+
emitPush(CANONICAL_B_PUSH_BYTES, false);
|
|
255
|
+
await drain();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Final push carries the (< push size) remainder, and flags stream end.
|
|
259
|
+
emitPush(buffered, true);
|
|
260
|
+
await drain();
|
|
261
|
+
}
|
|
262
|
+
zip.end();
|
|
263
|
+
await drain();
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Stream the canonical zip of `entries` (FINAL canonical order) into `sink`.
|
|
267
|
+
* Picks Canonical A (byte-identical to `zipSync`) unless an entry exceeds
|
|
268
|
+
* {@link ENTRY_RAM_CAP}, in which case the whole bundle uses Canonical B.
|
|
269
|
+
*/
|
|
270
|
+
export async function streamBundleZip(entries, sink) {
|
|
271
|
+
const ordered = canonicalOrder(entries);
|
|
272
|
+
return bundleNeedsCanonicalB(ordered) ? streamBundleZipB(ordered, sink) : streamBundleZipA(ordered, sink);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Synchronous Canonical-A convenience — frame an ordered `[name, bytes]` list to
|
|
276
|
+
* a single buffer. Used by the golden byte-identity test (`=== zipSync`) and by
|
|
277
|
+
* callers that already hold all bytes in memory. NOT for giant entries.
|
|
278
|
+
*/
|
|
279
|
+
export function frameCanonicalZipSync(entries) {
|
|
280
|
+
const ordered = canonicalOrder(entries.map(([name, bytes]) => ({ name, bytes })));
|
|
281
|
+
const chunks = [];
|
|
282
|
+
const centrals = [];
|
|
283
|
+
let offset = 0;
|
|
284
|
+
for (const { name, bytes: raw } of ordered) {
|
|
285
|
+
const framed = frameEntryA(name, raw, offset);
|
|
286
|
+
chunks.push(framed.local);
|
|
287
|
+
centrals.push(framed.central);
|
|
288
|
+
offset += framed.length;
|
|
289
|
+
}
|
|
290
|
+
let cdSize = 0;
|
|
291
|
+
for (const c of centrals) {
|
|
292
|
+
cdSize += c.length;
|
|
293
|
+
chunks.push(c);
|
|
294
|
+
}
|
|
295
|
+
chunks.push(eocd(centrals.length, cdSize, offset));
|
|
296
|
+
let total = 0;
|
|
297
|
+
for (const c of chunks)
|
|
298
|
+
total += c.length;
|
|
299
|
+
const out = new Uint8Array(total);
|
|
300
|
+
let o = 0;
|
|
301
|
+
for (const c of chunks) {
|
|
302
|
+
out.set(c, o);
|
|
303
|
+
o += c.length;
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
//# sourceMappingURL=canonical-zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-zip.js","sourceRoot":"","sources":["../src/canonical-zip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE/D,uFAAuF;AACvF,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,8EAA8E;AAC9E,iFA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