@nimbus-sh/core 0.5.0 → 0.6.0

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.
Files changed (62) hide show
  1. package/dist/_shared/cache-stats.d.ts +23 -1
  2. package/dist/_shared/cache-stats.d.ts.map +1 -1
  3. package/dist/_shared/cache-stats.js +13 -1
  4. package/dist/_shared/exports-resolver.d.ts +1 -1
  5. package/dist/_shared/exports-resolver.js +1 -1
  6. package/dist/_shared/retry.js +1 -1
  7. package/dist/constants.d.ts +5 -11
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +16 -56
  10. package/dist/runtime/assets-loader.js +1 -1
  11. package/dist/runtime/virtual-socket-kernel.generated.d.ts +1 -1
  12. package/dist/runtime/virtual-socket-kernel.generated.js +1 -1
  13. package/dist/vfs/seed-project.d.ts.map +1 -1
  14. package/dist/vfs/seed-project.js +1 -1
  15. package/dist/vfs/sqlite-vfs.d.ts +2 -30
  16. package/dist/vfs/sqlite-vfs.d.ts.map +1 -1
  17. package/dist/vfs/sqlite-vfs.js +7 -6
  18. package/package.json +3 -2
  19. package/src/_shared/cache-stats.ts +27 -1
  20. package/src/_shared/exports-resolver.ts +1 -1
  21. package/src/_shared/retry.ts +1 -1
  22. package/src/constants.ts +30 -60
  23. package/src/runtime/assets-loader.ts +1 -1
  24. package/src/runtime/virtual-socket-kernel.generated.ts +1 -1
  25. package/src/vfs/seed-project.ts +3 -3
  26. package/src/vfs/sqlite-vfs.ts +24 -41
  27. package/dist/_shared/install-phase.d.ts +0 -47
  28. package/dist/_shared/install-phase.d.ts.map +0 -1
  29. package/dist/_shared/install-phase.js +0 -1
  30. package/dist/_shared/rpc-dispose.d.ts +0 -4
  31. package/dist/_shared/rpc-dispose.d.ts.map +0 -1
  32. package/dist/_shared/rpc-dispose.js +0 -30
  33. package/dist/_shared/w7-frame.d.ts +0 -79
  34. package/dist/_shared/w7-frame.d.ts.map +0 -1
  35. package/dist/_shared/w7-frame.js +0 -840
  36. package/dist/_shared/weighted-credit-pool.d.ts +0 -61
  37. package/dist/_shared/weighted-credit-pool.d.ts.map +0 -1
  38. package/dist/_shared/weighted-credit-pool.js +0 -196
  39. package/dist/observability/diag-counters.d.ts +0 -236
  40. package/dist/observability/diag-counters.d.ts.map +0 -1
  41. package/dist/observability/diag-counters.js +0 -195
  42. package/dist/observability/heap-estimate.d.ts +0 -225
  43. package/dist/observability/heap-estimate.d.ts.map +0 -1
  44. package/dist/observability/heap-estimate.js +0 -185
  45. package/dist/observability/heavy-alloc-coord.d.ts +0 -93
  46. package/dist/observability/heavy-alloc-coord.d.ts.map +0 -1
  47. package/dist/observability/heavy-alloc-coord.js +0 -181
  48. package/dist/observability/oom-classify.d.ts +0 -138
  49. package/dist/observability/oom-classify.d.ts.map +0 -1
  50. package/dist/observability/oom-classify.js +0 -268
  51. package/dist/observability/oom-discriminator.d.ts +0 -176
  52. package/dist/observability/oom-discriminator.d.ts.map +0 -1
  53. package/dist/observability/oom-discriminator.js +0 -272
  54. package/src/_shared/install-phase.ts +0 -56
  55. package/src/_shared/rpc-dispose.ts +0 -31
  56. package/src/_shared/w7-frame.ts +0 -1013
  57. package/src/_shared/weighted-credit-pool.ts +0 -244
  58. package/src/observability/diag-counters.ts +0 -343
  59. package/src/observability/heap-estimate.ts +0 -331
  60. package/src/observability/heavy-alloc-coord.ts +0 -241
  61. package/src/observability/oom-classify.ts +0 -260
  62. package/src/observability/oom-discriminator.ts +0 -405
package/src/constants.ts CHANGED
@@ -1,7 +1,32 @@
1
1
  /**
2
2
  * constants.ts — Single source of truth for all Nimbus configuration.
3
+ *
4
+ * Nimbus POLICY only. The measured platform limits these policies are
5
+ * derived from (tx bounds, the RPC envelope, supervisor budgets) live in
6
+ * `@nimbus-sh/platform/limits.js`.
3
7
  */
4
8
 
9
+ import { MAX_RPC_SAFE_PAYLOAD_BYTES } from '@nimbus-sh/platform/limits.js';
10
+
11
+ // Published-surface forwarding: @nimbus-sh/core@0.5.0 exports these from
12
+ // this module and real consumers import them here (Proteus merge-back.ts
13
+ // pulls CHUNK_SIZE and the MAX_TX_* set). The platform split moved the
14
+ // definitions to @nimbus-sh/platform/limits.js, which stays the single
15
+ // source of truth; core's own modules import platform directly.
16
+ export {
17
+ CHUNK_SIZE,
18
+ MAX_GLOBAL_WRITE_STREAM_CREDIT_BYTES,
19
+ MAX_RPC_SAFE_PAYLOAD_BYTES,
20
+ MAX_TX_BLOB_BYTES,
21
+ MAX_TX_LOGICAL_ROWS,
22
+ MAX_TX_SQL_EXECS,
23
+ PRE_BUNDLE_CONCURRENCY,
24
+ PRE_BUNDLE_SLICE_CAP_BYTES,
25
+ SUPERVISOR_HEAP_CEILING_BYTES,
26
+ SUPERVISOR_IN_FLIGHT_ALLOCATION_BUDGET_BYTES,
27
+ SUPERVISOR_READ_RESERVE_BYTES,
28
+ } from '@nimbus-sh/platform/limits.js';
29
+
5
30
  // ── Versions ────────────────────────────────────────────────────────────
6
31
  export const NIMBUS_VERSION = '2.0.0';
7
32
  //
@@ -55,19 +80,11 @@ export const SQLJS_VERSION = '1.14.1';
55
80
  export const OPENCODE_VERSION = '1.16.2';
56
81
 
57
82
  // ── VFS Constants ───────────────────────────────────────────────────────
58
- export const CHUNK_SIZE = 65_536; // 64KB per content chunk
83
+ // The chunk size itself (CHUNK_SIZE) and the transaction bounds are
84
+ // platform limits — see @nimbus-sh/platform/limits.js.
59
85
  export const LRU_MAX_ENTRIES = 512; // 512 × 64KB = 32MB hot cache
60
86
  export const BATCH_SIZE = 64; // rows per batch INSERT
61
87
  export const VFS_CAPACITY = 10 * 1024 * 1024 * 1024; // 10 GB
62
- export const MAX_TX_BLOB_BYTES = 1 * 1024 * 1024;
63
- export const MAX_TX_LOGICAL_ROWS = 256;
64
- export const MAX_TX_SQL_EXECS = 64;
65
- export const MAX_GLOBAL_WRITE_STREAM_CREDIT_BYTES = 8 * 1024 * 1024;
66
-
67
- // Largest byte payload Nimbus sends through an ordinary Workers RPC value.
68
- // The platform limit is 32 MiB; 28 MiB leaves room for structured-clone
69
- // metadata and matches the proven on-demand facet transfer envelope.
70
- export const MAX_RPC_SAFE_PAYLOAD_BYTES = 28 * 1024 * 1024;
71
88
 
72
89
  // ── Batched filesystem reads ────────────────────────────────────────────
73
90
  // A round trip costs an order of magnitude more than the SQLite lookup
@@ -201,11 +218,12 @@ export const PREFETCH_CACHE_MAX_BYTES = 16 * 1024 * 1024;
201
218
  export const CWD_SNAPSHOT_MAX_FILE_BYTES = 2 * 1024 * 1024;
202
219
 
203
220
  // ── npm Constants ───────────────────────────────────────────────────────
221
+ // The pre-bundle admission envelope (PRE_BUNDLE_SLICE_CAP_BYTES,
222
+ // PRE_BUNDLE_CONCURRENCY) is a measured platform envelope — see
223
+ // @nimbus-sh/platform/limits.js.
204
224
  export const NPM_REGISTRY = 'https://registry.npmjs.org';
205
225
  export const NPM_CONCURRENCY = 12;
206
226
  export const NPM_DECOMPRESS_TIMEOUT = 15_000;
207
- export const PRE_BUNDLE_SLICE_CAP_BYTES = MAX_RPC_SAFE_PAYLOAD_BYTES;
208
- export const PRE_BUNDLE_CONCURRENCY = 1;
209
227
 
210
228
  // ── Dev Server Constants ────────────────────────────────────────────────
211
229
  export const DEFAULT_VITE_PORT = 5173;
@@ -225,54 +243,6 @@ export const NIMBUS_AI_GATEWAY_PORT = 8790;
225
243
  // ── Compatibility ───────────────────────────────────────────────────────
226
244
  export const CF_COMPAT_DATE = '2026-04-01';
227
245
 
228
- // ── Supervisor heap budget [C'.1] ───────────────────────────────────────
229
- //
230
- // Three distinct memory regimes, not one shared pool:
231
- //
232
- // - Supervisor DO isolate: 128 MiB HARD platform ceiling ("Each isolate
233
- // can consume up to 128 MB of memory" —
234
- // https://developers.cloudflare.com/workers/platform/limits/).
235
- // - Facets: ~208-256 MiB EACH, measured — memory independent of the
236
- // supervisor and of each other (1,664 MiB live across 8 facets +
237
- // parent) but CPU SHARED across the actor thread. See
238
- // packages/worker/src/loaders/process-fabric.ts.
239
- // - Peer DOs: independent memory AND CPU budgets, measured 1.2 GiB
240
- // live across 8 peers.
241
- //
242
- // Nimbus targets HALF of the supervisor's 128 MiB as a self-imposed soft
243
- // ceiling so the supervisor always has runway when workerd LRU-evicts
244
- // neighbours or AIR (Asynchronous Isolate Recreation) folds growing
245
- // isolates.
246
- //
247
- // 64 MiB is a soft admission budget, not a measurement — the right value
248
- // is unmeasured — and nothing enforces it directly.
249
- // src/observability/heap-estimate.ts sums the INSTRUMENTED contributors —
250
- // the supervisor baseline, VFS LRU and in-flight writes, pre-bundle
251
- // slices, streaming RPC buffers, and the prefetch-bundle build lease and
252
- // cache gauge — which is a lower bound, not full coverage; allocation
253
- // sites known to be missing are listed in HEAP_BLIND_SPOTS. Read a low
254
- // percentOfCeiling accordingly.
255
- export const SUPERVISOR_HEAP_CEILING_BYTES = 64 * 1024 * 1024;
256
-
257
- // Shared allowance for transient allocations in the supervisor DO. With the
258
- // VFS LRU shrunk to 8 MiB during an active reservation, 40 MiB of admitted
259
- // payload plus the 9 MiB bundle baseline stays below the 64 MiB soft ceiling
260
- // with 7 MiB left for metadata, structured-clone overhead, and runtime state.
261
- // This is 31.25% of the platform's 128 MiB hard isolate ceiling.
262
- export const SUPERVISOR_IN_FLIGHT_ALLOCATION_BUDGET_BYTES = 40 * 1024 * 1024;
263
-
264
- // Reserved slice of that allowance for chunk-sized filesystem reads, so a
265
- // read is never queued behind a multi-megabyte owner for a wait that has
266
- // nothing to do with its own cost. A read only draws on this when the shared
267
- // budget is already contended — which is exactly when the VFS LRU is shrunk
268
- // to 8 MiB — so peak accounting is 40 + 1 admitted, 8 LRU, 9 bundle baseline:
269
- // 58 MiB, still under the 64 MiB soft ceiling.
270
- //
271
- // 1 MiB is 16 concurrent READ_STREAM_CHUNK_BYTES reads. The point is not
272
- // depth, it is that a read loop keeps moving while a heavy owner works
273
- // instead of stopping dead for the duration.
274
- export const SUPERVISOR_READ_RESERVE_BYTES = 1024 * 1024;
275
-
276
246
  // ── OS Defaults ─────────────────────────────────────────────────────────
277
247
  export const DEFAULT_HOSTNAME = 'nimbus';
278
248
  export const DEFAULT_HOME = '/home/user';
@@ -35,7 +35,7 @@
35
35
  * same content.
36
36
  */
37
37
 
38
- import { disposeRpcResource } from '../_shared/rpc-dispose.js';
38
+ import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
39
39
 
40
40
  /**
41
41
  * Per-isolate cache. Keys are asset paths (e.g. `/_assets/foo.js`).
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Self-contained IIFE that installs globalThis.__nimbusVirtualSockets.
8
8
  * Consumed by python-runner.ts and ruby-runner.ts: spliced into the
9
- * socket process worker module source passed to NimbusLoaderPool.
9
+ * socket process worker module source passed to NimbusIsolatePool.
10
10
  *
11
11
  * Size: 33.76 KiB
12
12
  */
@@ -18,12 +18,12 @@
18
18
  * - Basename injection (commit 2) handles the /preview/ basepath wiring.
19
19
  */
20
20
 
21
+ import type { SqliteVFS } from './sqlite-vfs.js';
21
22
  import type {
22
- SqliteVFS,
23
23
  BatchInodeEntry,
24
24
  BatchChunkEntry,
25
- } from './sqlite-vfs.js';
26
- import { CHUNK_SIZE } from '../constants.js';
25
+ } from '@nimbus-sh/platform/w7-frame.js';
26
+ import { CHUNK_SIZE } from '@nimbus-sh/platform/limits.js';
27
27
  import { enc } from '../_shared/bytes.js';
28
28
  import { errorText } from '../_shared/error-text.js';
29
29
  import { CRED_KERNEL } from '../runtime/os-contracts.js';
@@ -43,27 +43,33 @@
43
43
  import { VfsEventEmitter, type VfsEventType } from './events.js';
44
44
  import { normalizeVfsPath } from './path.js';
45
45
  import {
46
- CHUNK_SIZE,
47
46
  LRU_MAX_ENTRIES,
48
47
  BATCH_SIZE,
48
+ FS_LIST_PAGE_LIMIT,
49
+ } from '../constants.js';
50
+ import {
51
+ CHUNK_SIZE,
49
52
  MAX_TX_BLOB_BYTES,
50
53
  MAX_TX_LOGICAL_ROWS,
51
54
  MAX_TX_SQL_EXECS,
52
55
  MAX_GLOBAL_WRITE_STREAM_CREDIT_BYTES,
53
- FS_LIST_PAGE_LIMIT,
54
- } from '../constants.js';
55
- import { recordFailure } from '../observability/oom-discriminator.js';
56
- import { classifyError } from '../observability/oom-classify.js';
57
- import { acquireSupervisorAllocation } from '../observability/heavy-alloc-coord.js';
56
+ } from '@nimbus-sh/platform/limits.js';
57
+ import { recordFailure } from '@nimbus-sh/platform/oom-discriminator.js';
58
+ import { classifyError } from '@nimbus-sh/platform/oom-classify.js';
59
+ import { acquireSupervisorAllocation } from '@nimbus-sh/platform/heavy-alloc-coord.js';
58
60
  import { enc, dec } from '../_shared/bytes.js';
59
61
  import {
60
62
  decodeWriteBatchStream,
63
+ type BatchChunkEntry,
64
+ type BatchInodeEntry,
65
+ type BatchWritePayload,
66
+ type VfsInodeKind,
61
67
  type W7DecodedRecord,
62
- } from '../_shared/w7-frame.js';
68
+ } from '@nimbus-sh/platform/w7-frame.js';
63
69
  import {
64
70
  WeightedCreditPool,
65
71
  type CreditLease,
66
- } from '../_shared/weighted-credit-pool.js';
72
+ } from '@nimbus-sh/platform/weighted-credit-pool.js';
67
73
  import { LEGACY_SYMLINK_REGISTRY_PATH } from './symlink-registry.js';
68
74
  import {
69
75
  CRED_KERNEL,
@@ -104,8 +110,16 @@ function installPipelineDiagEnabled(): boolean {
104
110
  }
105
111
 
106
112
  // ── Types ───────────────────────────────────────────────────────────────────
107
-
108
- export type VfsInodeKind = 'file' | 'directory' | 'symlink';
113
+ // VfsInodeKind and the writeBatch payload types (BatchInodeEntry,
114
+ // BatchChunkEntry, BatchWritePayload) live with the wire format that encodes
115
+ // them: @nimbus-sh/platform/w7-frame.js. Forwarded here because core@0.5.0
116
+ // published them from this module; platform stays the definition.
117
+ export type {
118
+ BatchChunkEntry,
119
+ BatchInodeEntry,
120
+ BatchWritePayload,
121
+ VfsInodeKind,
122
+ } from '@nimbus-sh/platform/w7-frame.js';
109
123
 
110
124
  export interface ExclusiveMutationLease {
111
125
  readonly root: string;
@@ -133,22 +147,6 @@ interface INode {
133
147
  contentId: string | null;
134
148
  }
135
149
 
136
- /** Entry for bulk inode creation via writeBatch(). */
137
- export interface BatchInodeEntry {
138
- path: string;
139
- parentPath: string;
140
- /** Defaults to isDir ? directory : file for legacy/non-symlink producers. */
141
- kind?: VfsInodeKind;
142
- isDir: boolean;
143
- size: number;
144
- atime?: number;
145
- mtime: number;
146
- mode: number;
147
- uid?: number;
148
- gid?: number;
149
- chunkCount: number;
150
- }
151
-
152
150
  export interface VfsStat {
153
151
  type: VfsInodeKind;
154
152
  size: number;
@@ -233,21 +231,6 @@ export interface CredentialedVfs {
233
231
  readonly epoch: string;
234
232
  }
235
233
 
236
- /** Entry for bulk chunk creation via writeBatch(). */
237
- export interface BatchChunkEntry {
238
- path: string;
239
- chunkId: number;
240
- data: Uint8Array;
241
- }
242
-
243
- /** Payload for writeBatch() — all inodes + chunks written in ONE transactionSync(). */
244
- export interface BatchWritePayload {
245
- inodes: BatchInodeEntry[];
246
- chunks: BatchChunkEntry[];
247
- /** Paths to delete before writing (for clean reinstall). */
248
- deletePaths?: string[];
249
- }
250
-
251
234
  export interface WriteBatchStreamProgress {
252
235
  /** 1-based sequence of the last durable publish group; zero means none. */
253
236
  committedGroupSequence: number;
@@ -1,47 +0,0 @@
1
- /**
2
- * _shared/install-phase.ts — single source of truth for the npm-install
3
- * state-machine phase enum.
4
- *
5
- * History: CLN-1 (2026-05-11) — consolidated from two diverged copies.
6
- * - `npm/installer.ts:93-95` was the progress-event variant. Included
7
- * 'lock-check' (a real progress event emitted while parsing
8
- * package-lock.json) but lacked 'idle'.
9
- * - `observability/diag-counters.ts:33-35` was the counter-state variant.
10
- * Included 'idle' (the resting state when no install is in flight)
11
- * but lacked 'lock-check'. The diag-counter's `setInstallPhase()`
12
- * was actually called with 'idle' (installer.ts:184,201) — passing
13
- * a value not declared in installer.ts's local type. The type check
14
- * fell through to diag-counters' type because installer.ts imports
15
- * setInstallPhase from there; the local `InstallPhase` definition
16
- * in installer.ts was only used by `InstallProgress.phase`.
17
- *
18
- * Going forward both consumers import from this module; any new phase
19
- * value added here is automatically available everywhere.
20
- *
21
- * Phase semantics (chronological order for a single install run):
22
- *
23
- * idle resting state, no install in flight
24
- * ↓
25
- * lock-check parsing existing package-lock.json (if present)
26
- * ↓
27
- * resolve walking the dep tree, fetching packuments
28
- * ↓
29
- * hoist hoisting peer-deps + flattening node_modules
30
- * ↓
31
- * diff comparing target tree against current install state
32
- * ↓
33
- * fetch downloading missing tarballs
34
- * ↓
35
- * write extracting tarballs into the VFS
36
- * ↓
37
- * link-bins creating bin/ symlinks
38
- * ↓
39
- * bundle (post-install) pre-bundling for esbuild fast path
40
- * ↓
41
- * done install complete; about to return to 'idle'
42
- *
43
- * The phase strings are surfaced via /api/_diag/install-pipeline and
44
- * displayed in the install-progress UI; treat them as a public API.
45
- */
46
- export type InstallPhase = 'idle' | 'lock-check' | 'resolve' | 'hoist' | 'diff' | 'fetch' | 'write' | 'link-bins' | 'bundle' | 'done';
47
- //# sourceMappingURL=install-phase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install-phase.d.ts","sourceRoot":"","sources":["../../src/_shared/install-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,YAAY,GACZ,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,OAAO,GACP,WAAW,GACX,QAAQ,GACR,MAAM,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export declare function disposeRpcResource(value: unknown): boolean;
2
- export declare function disposeRpcResources(values: Iterable<unknown>): void;
3
- export declare function useRpcResource<T, R>(promise: Promise<T>, use: (value: T) => R | Promise<R>): Promise<R>;
4
- //# sourceMappingURL=rpc-dispose.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpc-dispose.d.ts","sourceRoot":"","sources":["../../src/_shared/rpc-dispose.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAY1D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAEnE;AAED,wBAAsB,cAAc,CAAC,CAAC,EAAE,CAAC,EACvC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAChC,OAAO,CAAC,CAAC,CAAC,CAOZ"}
@@ -1,30 +0,0 @@
1
- export function disposeRpcResource(value) {
2
- if ((typeof value !== 'object' && typeof value !== 'function') || value === null)
3
- return false;
4
- const disposerKey = Symbol.dispose;
5
- if (!disposerKey)
6
- return false;
7
- const disposer = Reflect.get(value, disposerKey);
8
- if (typeof disposer !== 'function')
9
- return false;
10
- try {
11
- Reflect.apply(disposer, value, []);
12
- return true;
13
- }
14
- catch {
15
- return false;
16
- }
17
- }
18
- export function disposeRpcResources(values) {
19
- for (const value of values)
20
- disposeRpcResource(value);
21
- }
22
- export async function useRpcResource(promise, use) {
23
- const value = await promise;
24
- try {
25
- return await use(value);
26
- }
27
- finally {
28
- disposeRpcResource(value);
29
- }
30
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * W7 v3 — incremental typed records for streamed bulk filesystem writes.
3
- * The format is internal: every producer and consumer deploys together.
4
- */
5
- import type { BatchInodeEntry, BatchWritePayload } from '../vfs/sqlite-vfs.js';
6
- export declare const W7_MAGIC: Uint8Array<ArrayBuffer>;
7
- export declare const W7_MAX_PATHS_PER_BATCH = 128;
8
- export declare const W7_MAX_OWNED_PATH_BYTES: number;
9
- export declare const W7_MAX_RECORD_BYTES: number;
10
- declare const MODE: "path-atomic-committed-prefix";
11
- export interface W7BatchSummary {
12
- recordCount: number;
13
- pathCount: number;
14
- deleteCount: number;
15
- directoryCount: number;
16
- fileCount: number;
17
- chunkCount: number;
18
- byteCount: number;
19
- check: number;
20
- }
21
- export interface W7ChunkRetention {
22
- readonly bytes: number;
23
- release(): void;
24
- }
25
- export interface W7DecodeOptions {
26
- signal?: AbortSignal;
27
- retainChunk?: (byteLength: number, signal?: AbortSignal) => Promise<W7ChunkRetention>;
28
- }
29
- type W7DirectoryInode = BatchInodeEntry & {
30
- kind: 'directory';
31
- isDir: true;
32
- };
33
- type W7ContentInode = BatchInodeEntry & {
34
- kind: 'file' | 'symlink';
35
- isDir: false;
36
- };
37
- export type W7DecodedRecord = {
38
- type: 'delete';
39
- path: string;
40
- } | {
41
- type: 'directory';
42
- inode: W7DirectoryInode;
43
- } | {
44
- type: 'file-begin';
45
- streamContentId: string;
46
- inode: W7ContentInode;
47
- } | {
48
- type: 'file-chunk';
49
- streamContentId: string;
50
- path: string;
51
- chunkId: number;
52
- data: Uint8Array;
53
- retention: W7ChunkRetention;
54
- } | {
55
- type: 'file-end';
56
- streamContentId: string;
57
- path: string;
58
- size: number;
59
- chunkCount: number;
60
- check: number;
61
- } | {
62
- type: 'batch-end';
63
- summary: W7BatchSummary;
64
- };
65
- export interface W7DecodedStream {
66
- readonly batchId: string;
67
- readonly mode: typeof MODE;
68
- readonly records: AsyncIterable<W7DecodedRecord>;
69
- }
70
- /** Encode one bounded record per pull; no batch-sized metadata header exists. */
71
- export declare function encodeWriteBatchStream(payload: BatchWritePayload): ReadableStream<Uint8Array>;
72
- /**
73
- * Parse the v3 preamble eagerly, then expose validated operation records
74
- * incrementally. Chunk credit is acquired after its bounded header validates
75
- * and before its payload bytes are read or copied.
76
- */
77
- export declare function decodeWriteBatchStream(stream: ReadableStream<Uint8Array>, options?: W7DecodeOptions): Promise<W7DecodedStream>;
78
- export {};
79
- //# sourceMappingURL=w7-frame.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"w7-frame.d.ts","sourceRoot":"","sources":["../../src/_shared/w7-frame.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAG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