@nimbus-sh/core 0.5.0 → 0.7.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 (145) hide show
  1. package/README.md +47 -26
  2. package/dist/_shared/byte-stream.d.ts +5 -4
  3. package/dist/_shared/byte-stream.d.ts.map +1 -1
  4. package/dist/_shared/cache-stats.d.ts +23 -1
  5. package/dist/_shared/cache-stats.d.ts.map +1 -1
  6. package/dist/_shared/cache-stats.js +13 -1
  7. package/dist/_shared/exports-resolver.d.ts +1 -1
  8. package/dist/_shared/exports-resolver.js +1 -1
  9. package/dist/_shared/real-node-imports.d.ts +7 -0
  10. package/dist/_shared/real-node-imports.d.ts.map +1 -1
  11. package/dist/_shared/real-node-imports.js +8 -0
  12. package/dist/_shared/retry.js +1 -1
  13. package/dist/_shared/tarball.d.ts +23 -5
  14. package/dist/_shared/tarball.d.ts.map +1 -1
  15. package/dist/_shared/tarball.js +38 -5
  16. package/dist/_shared/vfs-write-ledger.d.ts.map +1 -1
  17. package/dist/_shared/vfs-write-ledger.js +22 -16
  18. package/dist/constants.d.ts +5 -11
  19. package/dist/constants.d.ts.map +1 -1
  20. package/dist/constants.js +16 -56
  21. package/dist/runtime/assets-loader.js +1 -1
  22. package/dist/runtime/comment-strip.d.ts +0 -35
  23. package/dist/runtime/comment-strip.d.ts.map +1 -1
  24. package/dist/runtime/comment-strip.js +48 -20
  25. package/dist/runtime/esbuild-service.d.ts +38 -42
  26. package/dist/runtime/esbuild-service.d.ts.map +1 -1
  27. package/dist/runtime/esbuild-service.js +494 -197
  28. package/dist/runtime/javascript-ast.d.ts.map +1 -1
  29. package/dist/runtime/javascript-ast.js +45 -7
  30. package/dist/runtime/opentui-wasm-backend.d.ts.map +1 -1
  31. package/dist/runtime/opentui-wasm-backend.js +18 -16
  32. package/dist/runtime/port-registry.d.ts +4 -2
  33. package/dist/runtime/port-registry.d.ts.map +1 -1
  34. package/dist/runtime/port-registry.js +60 -8
  35. package/dist/runtime/virtual-socket-kernel.generated.d.ts +1 -1
  36. package/dist/runtime/virtual-socket-kernel.generated.js +1 -1
  37. package/dist/shell/stdin-adapter.d.ts +11 -0
  38. package/dist/shell/stdin-adapter.d.ts.map +1 -0
  39. package/dist/shell/stdin-adapter.js +59 -0
  40. package/dist/shell/unix-commands.d.ts +2 -1
  41. package/dist/shell/unix-commands.d.ts.map +1 -1
  42. package/dist/shell/unix-commands.js +1078 -50
  43. package/dist/substrate/lifo/commands/io/dd.js +1 -1
  44. package/dist/substrate/lifo/commands/net/curl.d.ts.map +1 -1
  45. package/dist/substrate/lifo/commands/net/curl.js +270 -54
  46. package/dist/substrate/lifo/commands/system/npm.d.ts +18 -1
  47. package/dist/substrate/lifo/commands/system/npm.d.ts.map +1 -1
  48. package/dist/substrate/lifo/commands/system/npm.js +26 -43
  49. package/dist/substrate/lifo/commands/text/head.d.ts.map +1 -1
  50. package/dist/substrate/lifo/commands/text/head.js +2 -1
  51. package/dist/substrate/lifo/commands/text/sed.d.ts.map +1 -1
  52. package/dist/substrate/lifo/commands/text/sed.js +499 -117
  53. package/dist/substrate/lifo/commands/types.d.ts +8 -4
  54. package/dist/substrate/lifo/commands/types.d.ts.map +1 -1
  55. package/dist/substrate/lifo/node-compat/zlib.d.ts +37 -18
  56. package/dist/substrate/lifo/node-compat/zlib.d.ts.map +1 -1
  57. package/dist/substrate/lifo/node-compat/zlib.js +122 -23
  58. package/dist/substrate/lifo/shell/interpreter.d.ts +9 -1
  59. package/dist/substrate/lifo/shell/interpreter.d.ts.map +1 -1
  60. package/dist/substrate/lifo/shell/interpreter.js +79 -29
  61. package/dist/substrate/lifo/shell/pipe.d.ts +16 -0
  62. package/dist/substrate/lifo/shell/pipe.d.ts.map +1 -1
  63. package/dist/substrate/lifo/shell/pipe.js +62 -18
  64. package/dist/substrate/lifo/shell/terminal-stdin.d.ts +20 -3
  65. package/dist/substrate/lifo/shell/terminal-stdin.d.ts.map +1 -1
  66. package/dist/substrate/lifo/shell/terminal-stdin.js +60 -24
  67. package/dist/vfs/seed-project.d.ts.map +1 -1
  68. package/dist/vfs/seed-project.js +1 -1
  69. package/dist/vfs/sqlite-vfs.d.ts +21 -30
  70. package/dist/vfs/sqlite-vfs.d.ts.map +1 -1
  71. package/dist/vfs/sqlite-vfs.js +113 -29
  72. package/dist/workspace/nimbus-workspace.d.ts +15 -0
  73. package/dist/workspace/nimbus-workspace.d.ts.map +1 -1
  74. package/dist/workspace/nimbus-workspace.js +20 -3
  75. package/dist/workspace/supervisor-op.d.ts +23 -0
  76. package/dist/workspace/supervisor-op.d.ts.map +1 -0
  77. package/dist/workspace/supervisor-op.js +92 -0
  78. package/package.json +3 -2
  79. package/src/_shared/byte-stream.ts +5 -4
  80. package/src/_shared/cache-stats.ts +27 -1
  81. package/src/_shared/exports-resolver.ts +1 -1
  82. package/src/_shared/real-node-imports.ts +8 -0
  83. package/src/_shared/retry.ts +1 -1
  84. package/src/_shared/tarball.ts +56 -5
  85. package/src/_shared/vfs-write-ledger.ts +22 -16
  86. package/src/constants.ts +30 -60
  87. package/src/runtime/assets-loader.ts +1 -1
  88. package/src/runtime/comment-strip.ts +42 -23
  89. package/src/runtime/esbuild-service.ts +566 -217
  90. package/src/runtime/javascript-ast.ts +40 -9
  91. package/src/runtime/opentui-wasm-backend.ts +19 -17
  92. package/src/runtime/port-registry.ts +66 -8
  93. package/src/runtime/virtual-socket-kernel.generated.ts +1 -1
  94. package/src/shell/stdin-adapter.ts +58 -0
  95. package/src/shell/unix-commands.ts +1054 -50
  96. package/src/substrate/lifo/commands/io/dd.ts +2 -2
  97. package/src/substrate/lifo/commands/net/curl.ts +310 -58
  98. package/src/substrate/lifo/commands/system/npm.ts +58 -38
  99. package/src/substrate/lifo/commands/text/head.ts +2 -1
  100. package/src/substrate/lifo/commands/text/sed.ts +519 -109
  101. package/src/substrate/lifo/commands/types.ts +8 -5
  102. package/src/substrate/lifo/node-compat/zlib.ts +155 -26
  103. package/src/substrate/lifo/shell/interpreter.ts +74 -27
  104. package/src/substrate/lifo/shell/pipe.ts +65 -24
  105. package/src/substrate/lifo/shell/terminal-stdin.ts +66 -30
  106. package/src/vfs/seed-project.ts +3 -3
  107. package/src/vfs/sqlite-vfs.ts +128 -64
  108. package/src/workspace/nimbus-workspace.ts +26 -2
  109. package/src/workspace/supervisor-op.ts +117 -0
  110. package/dist/_shared/install-phase.d.ts +0 -47
  111. package/dist/_shared/install-phase.d.ts.map +0 -1
  112. package/dist/_shared/install-phase.js +0 -1
  113. package/dist/_shared/rpc-dispose.d.ts +0 -4
  114. package/dist/_shared/rpc-dispose.d.ts.map +0 -1
  115. package/dist/_shared/rpc-dispose.js +0 -30
  116. package/dist/_shared/w7-frame.d.ts +0 -79
  117. package/dist/_shared/w7-frame.d.ts.map +0 -1
  118. package/dist/_shared/w7-frame.js +0 -840
  119. package/dist/_shared/weighted-credit-pool.d.ts +0 -61
  120. package/dist/_shared/weighted-credit-pool.d.ts.map +0 -1
  121. package/dist/_shared/weighted-credit-pool.js +0 -196
  122. package/dist/observability/diag-counters.d.ts +0 -236
  123. package/dist/observability/diag-counters.d.ts.map +0 -1
  124. package/dist/observability/diag-counters.js +0 -195
  125. package/dist/observability/heap-estimate.d.ts +0 -225
  126. package/dist/observability/heap-estimate.d.ts.map +0 -1
  127. package/dist/observability/heap-estimate.js +0 -185
  128. package/dist/observability/heavy-alloc-coord.d.ts +0 -93
  129. package/dist/observability/heavy-alloc-coord.d.ts.map +0 -1
  130. package/dist/observability/heavy-alloc-coord.js +0 -181
  131. package/dist/observability/oom-classify.d.ts +0 -138
  132. package/dist/observability/oom-classify.d.ts.map +0 -1
  133. package/dist/observability/oom-classify.js +0 -268
  134. package/dist/observability/oom-discriminator.d.ts +0 -176
  135. package/dist/observability/oom-discriminator.d.ts.map +0 -1
  136. package/dist/observability/oom-discriminator.js +0 -272
  137. package/src/_shared/install-phase.ts +0 -56
  138. package/src/_shared/rpc-dispose.ts +0 -31
  139. package/src/_shared/w7-frame.ts +0 -1013
  140. package/src/_shared/weighted-credit-pool.ts +0 -244
  141. package/src/observability/diag-counters.ts +0 -343
  142. package/src/observability/heap-estimate.ts +0 -331
  143. package/src/observability/heavy-alloc-coord.ts +0 -241
  144. package/src/observability/oom-classify.ts +0 -260
  145. package/src/observability/oom-discriminator.ts +0 -405
@@ -1 +1 @@
1
- {"version":3,"file":"javascript-ast.d.ts","sourceRoot":"","sources":["../../src/runtime/javascript-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAa/D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAI9D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAIpF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAItE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEhF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAElF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D"}
1
+ {"version":3,"file":"javascript-ast.d.ts","sourceRoot":"","sources":["../../src/runtime/javascript-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,OAAO,EAAkB,MAAM,OAAO,CAAC;AAEjF,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CA4C/D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAI9D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAIpF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAItE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEhF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAElF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D"}
@@ -1,4 +1,4 @@
1
- import { parse } from 'acorn';
1
+ import { parse, tokenizer, tokTypes } from 'acorn';
2
2
  export function parseJavaScriptModule(source) {
3
3
  return parse(source, {
4
4
  ecmaVersion: 'latest',
@@ -7,17 +7,55 @@ export function parseJavaScriptModule(source) {
7
7
  });
8
8
  }
9
9
  export function hasTopLevelModuleSyntax(source) {
10
- let ast;
11
10
  try {
12
- ast = parseJavaScriptModule(source);
11
+ const tokens = tokenizer(source, {
12
+ ecmaVersion: 'latest',
13
+ sourceType: 'module',
14
+ allowHashBang: true,
15
+ });
16
+ let braceDepth = 0;
17
+ let parenDepth = 0;
18
+ let bracketDepth = 0;
19
+ let previous;
20
+ const updateDepth = (type) => {
21
+ if (type === tokTypes.braceL || type === tokTypes.dollarBraceL)
22
+ braceDepth++;
23
+ else if (type === tokTypes.braceR)
24
+ braceDepth = Math.max(0, braceDepth - 1);
25
+ else if (type === tokTypes.parenL)
26
+ parenDepth++;
27
+ else if (type === tokTypes.parenR)
28
+ parenDepth = Math.max(0, parenDepth - 1);
29
+ else if (type === tokTypes.bracketL)
30
+ bracketDepth++;
31
+ else if (type === tokTypes.bracketR)
32
+ bracketDepth = Math.max(0, bracketDepth - 1);
33
+ };
34
+ while (true) {
35
+ const token = tokens.getToken();
36
+ const type = token.type;
37
+ if (type === tokTypes.eof)
38
+ return false;
39
+ const topLevel = braceDepth === 0 && parenDepth === 0 && bracketDepth === 0;
40
+ if (topLevel && previous !== tokTypes.dot) {
41
+ if (type === tokTypes._export)
42
+ return true;
43
+ if (type === tokTypes._import) {
44
+ const next = tokens.getToken();
45
+ if (next.type !== tokTypes.parenL && next.type !== tokTypes.dot)
46
+ return true;
47
+ updateDepth(next.type);
48
+ previous = next.type;
49
+ continue;
50
+ }
51
+ }
52
+ updateDepth(type);
53
+ previous = type;
54
+ }
13
55
  }
14
56
  catch {
15
57
  return false;
16
58
  }
17
- return nodeList(ast, 'body').some((node) => node.type === 'ImportDeclaration' ||
18
- node.type === 'ExportNamedDeclaration' ||
19
- node.type === 'ExportDefaultDeclaration' ||
20
- node.type === 'ExportAllDeclaration');
21
59
  }
22
60
  export function nodeList(node, key) {
23
61
  const value = node[key];
@@ -1 +1 @@
1
- {"version":3,"file":"opentui-wasm-backend.d.ts","sourceRoot":"","sources":["../../src/runtime/opentui-wasm-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAOH,eAAO,MAAM,iBAAiB,qIAiBpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAIhE,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,GACN,eAAe,GACf,WAAW,GACX,IAAI,GACJ,SAAS,CAAC;AAEd,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAE9D,iFAAiF;AACjF,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wFAAwF;AACxF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAClD,cAAc,CACZ,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACzC,UAAU,E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C;IAKJ,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,iBAAiB;CAiMrE;AAID,wBAAgB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAExD;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,GAAG;IAC/D,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAOA"}
@@ -78,13 +78,12 @@ export class OpenTUIWasmBackend {
78
78
  * semantics), so each `dlopen`'d symbol call frees what was allocated before
79
79
  * it. Without this a per-frame `rgbaPtr(color)` would leak linear memory.
80
80
  *
81
- * `view` is the source ArrayBufferView when the caller passed a writable one:
82
- * native FFI `ptr(view)` yields a live pointer into the view's storage, so
83
- * after the symbol call the view must reflect anything Zig wrote into it. Many
84
- * FFIRenderLib wrappers materialize OUT-buffers this way `getCursorState`,
85
- * `getTerminalCapabilities`, `getRenderStats`, the span-feed's
86
- * `streamDrainSpans(ptr(outBuffer))`, every `editBufferGet*`/`editorViewGet*`
87
- * so the claimed-scratch release copies these back before freeing.
81
+ * `view` is a writable byte view over the caller's original storage.
82
+ * Native `ptr(value)` exposes live memory for both ArrayBuffer and typed-array
83
+ * inputs, so every transient allocation copies back after the symbol call.
84
+ * OpenTUI's struct getters use bare ArrayBuffers (`LogicalCursorStruct`,
85
+ * `VisualCursorStruct`, stats, terminal capabilities), while span-feed drains
86
+ * use typed arrays. Both forms must observe Zig's writes.
88
87
  */
89
88
  #pendingPtrScratch = [];
90
89
  /**
@@ -176,12 +175,10 @@ export class OpenTUIWasmBackend {
176
175
  // allocation as transient scratch that the next symbol call frees (see
177
176
  // `#bindSymbol`). This keeps a per-frame `rgbaPtr(color)` loop leak-free.
178
177
  //
179
- // A writable ArrayBufferView is also an OUT-buffer here: native `ptr(view)` is
180
- // a live pointer into the view's storage, so after the call the view must
181
- // reflect Zig's writes. We record the source view so the claimed-scratch
182
- // release copies it back (the span-feed `streamDrainSpans(ptr(drainBuffer))`
183
- // and every FFIRenderLib `ptr(outBuffer)`/`ptr(cursorBuffer)`/`ptr(statsBuffer)`
184
- // getter depend on this). Read-only ArrayBuffers carry a null view (copy-in only).
178
+ // Every ArrayBuffer and ArrayBufferView is potentially an OUT-buffer:
179
+ // native `ptr(value)` is a live pointer into the same storage. Copy the
180
+ // arena bytes back after the call so bare struct buffers and typed-array
181
+ // windows have identical semantics.
185
182
  ptr(value) {
186
183
  const { bytes, byteOffset, byteLength } = viewBytes(value);
187
184
  const size = byteLength === 0 ? ARENA_ALIGN : byteLength;
@@ -192,7 +189,7 @@ export class OpenTUIWasmBackend {
192
189
  this.#pendingPtrScratch.push({
193
190
  offset,
194
191
  size,
195
- view: ArrayBuffer.isView(value) ? value : null,
192
+ view: ArrayBuffer.isView(value) ? value : new Uint8Array(value),
196
193
  });
197
194
  return offset;
198
195
  }
@@ -336,8 +333,13 @@ export class OpenTUIWasmBackend {
336
333
  scratchBytes += s.size;
337
334
  diag.rec(name, this.#exports.memory.buffer.byteLength - memBefore, marshaled, scratchBytes);
338
335
  }
339
- if (returns === 'u64' || returns === 'i64') {
340
- return typeof result === 'bigint' ? result : BigInt(result);
336
+ if (returns === 'u64') {
337
+ const value = typeof result === 'bigint' ? result : BigInt(result);
338
+ return BigInt.asUintN(64, value);
339
+ }
340
+ if (returns === 'i64') {
341
+ const value = typeof result === 'bigint' ? result : BigInt(result);
342
+ return BigInt.asIntN(64, value);
341
343
  }
342
344
  return result;
343
345
  };
@@ -23,8 +23,9 @@
23
23
  * `request.method` and application headers mirror the outer request,
24
24
  * Nimbus credentials/internal headers are removed, and
25
25
  * `request.body` is a ReadableStream (or null for GET/HEAD) that
26
- * the facet can consume once. The returned Response is returned
27
- * to the outer fetch as-is; its body is streamed directly.
26
+ * the facet can consume once. The returned Response is streamed
27
+ * straight back, with one normalization: the hop speaks identity,
28
+ * so a compressed body is decoded here. See `decodeContentCoding`.
28
29
  */
29
30
  import type { RouteableFacetTarget } from './os-contracts.js';
30
31
  export interface PortEntry {
@@ -44,6 +45,7 @@ export interface PortEntry {
44
45
  */
45
46
  capability: string;
46
47
  }
48
+ export declare function createPortCapability(): string;
47
49
  export declare class PortRegistry {
48
50
  private ports;
49
51
  private facetStubsByPid;
@@ -1 +1 @@
1
- {"version":3,"file":"port-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/port-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAOD,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,eAAe,CAA2C;IAClE,OAAO,CAAC,gBAAgB,CAAsC;IAE9D,uEAAuE;IACvE,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAQpD;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAYzC,yBAAyB;IACzB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC,oDAAoD;IACpD,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAYpC,4BAA4B;IAC5B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIxC,8EAA8E;IAC9E,OAAO,CAAC,oBAAoB;IAW5B,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,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;;;;;;OAUG;IACG,sBAAsB,CAC1B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;YAKb,oBAAoB;IA0HlC,IAAI,KAAK;;;;;;MAKR;IAED,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,iBAAiB;CAM1B"}
@@ -23,11 +23,59 @@
23
23
  * `request.method` and application headers mirror the outer request,
24
24
  * Nimbus credentials/internal headers are removed, and
25
25
  * `request.body` is a ReadableStream (or null for GET/HEAD) that
26
- * the facet can consume once. The returned Response is returned
27
- * to the outer fetch as-is; its body is streamed directly.
26
+ * the facet can consume once. The returned Response is streamed
27
+ * straight back, with one normalization: the hop speaks identity,
28
+ * so a compressed body is decoded here. See `decodeContentCoding`.
28
29
  */
29
30
  import { sanitizeUntrustedHeaders } from '../_shared/untrusted-request.js';
30
- function createPortCapability() {
31
+ /**
32
+ * Content codings this hop can undo. `DecompressionStream` decodes exactly
33
+ * these; brotli and zstd have no decoder in the runtime, so a body in one of
34
+ * those cannot be repaired here.
35
+ */
36
+ const DECODABLE_CONTENT_CODINGS = new Map([
37
+ ['gzip', 'gzip'],
38
+ ['x-gzip', 'gzip'],
39
+ ['deflate', 'deflate'],
40
+ ]);
41
+ /**
42
+ * Hand back a port target's response with its bytes and its headers in
43
+ * agreement.
44
+ *
45
+ * A `Response` a facet builds always holds an identity body. The runtime
46
+ * treats the bytes a `Response` is constructed from as unencoded and runs its
47
+ * own content negotiation on the way out: it drops a `Content-Encoding` the
48
+ * client did not ask for, and compresses again when the client did. Either
49
+ * way a guest server's `Content-Encoding` is a label with nothing behind it,
50
+ * and the browser renders compressed bytes as text.
51
+ *
52
+ * The forwarded request asks the target for `identity`, so this decode covers
53
+ * the server that compresses whatever the client said. A coding with no
54
+ * decoder answers 502: an honest failure beats a page of mojibake.
55
+ */
56
+ function decodeContentCoding(response, port) {
57
+ const coding = response.headers.get('Content-Encoding')?.trim().toLowerCase();
58
+ if (!coding || coding === 'identity' || response.body === null)
59
+ return response;
60
+ const format = DECODABLE_CONTENT_CODINGS.get(coding);
61
+ if (!format) {
62
+ void response.body.cancel().catch(() => { });
63
+ return new Response(JSON.stringify({
64
+ error: `port proxy: target answered Content-Encoding "${coding}", which this hop cannot decode`,
65
+ port,
66
+ }), { status: 502, headers: { 'Content-Type': 'application/json' } });
67
+ }
68
+ const headers = new Headers(response.headers);
69
+ headers.delete('Content-Encoding');
70
+ // The decoded body has a different length; the Response re-derives it.
71
+ headers.delete('Content-Length');
72
+ return new Response(response.body.pipeThrough(new DecompressionStream(format)), {
73
+ status: response.status,
74
+ statusText: response.statusText,
75
+ headers,
76
+ });
77
+ }
78
+ export function createPortCapability() {
31
79
  const bytes = crypto.getRandomValues(new Uint8Array(12));
32
80
  return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
33
81
  }
@@ -217,6 +265,10 @@ export class PortRegistry {
217
265
  if (authorization)
218
266
  headers.set('authorization', authorization);
219
267
  headers.set('X-Nimbus-Port', String(port));
268
+ // A Response cannot carry an encoded body across this hop, so the
269
+ // target is asked for the one coding that survives it. See
270
+ // `decodeContentCoding` for the server that compresses anyway.
271
+ headers.set('Accept-Encoding', 'identity');
220
272
  // `duplex: 'half'` is required by workerd when body is a
221
273
  // ReadableStream — otherwise `new Request(…)` throws. It's not
222
274
  // part of the published @cloudflare/workers-types RequestInit,
@@ -255,12 +307,12 @@ export class PortRegistry {
255
307
  headers: { 'Content-Type': 'application/json' },
256
308
  });
257
309
  }
258
- // Return the facet's Response as-is. Body is streamed; headers,
259
- // status, and status-text pass through unchanged. We do NOT
260
- // inject Access-Control-Allow-Origin — a port proxy forwards
261
- // whatever CORS policy the user's HTTP server chose (audit C3
310
+ // Stream the facet's Response back. Status, status-text, and every
311
+ // header pass through; only a content coding the hop cannot carry is
312
+ // undone. We do NOT inject Access-Control-Allow-Origin — a port proxy
313
+ // forwards whatever CORS policy the user's HTTP server chose (audit C3
262
314
  // discourages gratuitous wildcards on non-static routes).
263
- return response;
315
+ return decodeContentCoding(response, port);
264
316
  }
265
317
  catch (error) {
266
318
  // Server-side triage — users see only the 502 body, operators
@@ -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
  */
@@ -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
  */
@@ -0,0 +1,11 @@
1
+ import type { CommandInputStream } from '../substrate/lifo/commands/types.js';
2
+ /**
3
+ * One consuming source behind the full reader contract, byte-accurate:
4
+ * the text is encoded once and every offset is a byte offset, so
5
+ * readBytes(1) over `é` yields exactly one UTF-8 byte per call and mixed
6
+ * text/byte consumption never diverges. Worker pure-builtin adapters hold
7
+ * stdin as a plain string; without this they can only offer readAll, and
8
+ * streaming commands see an empty pipe.
9
+ */
10
+ export declare function staticStdinReader(text: string): CommandInputStream;
11
+ //# sourceMappingURL=stdin-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-adapter.d.ts","sourceRoot":"","sources":["../../src/shell/stdin-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CA+ClE"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * One consuming source behind the full reader contract, byte-accurate:
3
+ * the text is encoded once and every offset is a byte offset, so
4
+ * readBytes(1) over `é` yields exactly one UTF-8 byte per call and mixed
5
+ * text/byte consumption never diverges. Worker pure-builtin adapters hold
6
+ * stdin as a plain string; without this they can only offer readAll, and
7
+ * streaming commands see an empty pipe.
8
+ */
9
+ export function staticStdinReader(text) {
10
+ const bytes = new TextEncoder().encode(text);
11
+ const decoder = new TextDecoder('utf-8');
12
+ let offset = 0;
13
+ const pull = (max) => {
14
+ if (offset >= bytes.length)
15
+ return null;
16
+ const end = Math.min(offset + max, bytes.length);
17
+ const chunk = bytes.subarray(offset, end);
18
+ offset = end;
19
+ return chunk;
20
+ };
21
+ return {
22
+ readBytes: async (maxLength) => {
23
+ if (maxLength <= 0)
24
+ return new Uint8Array(0);
25
+ return pull(maxLength);
26
+ },
27
+ read: async () => {
28
+ while (offset < bytes.length) {
29
+ const end = Math.min(offset + 65536, bytes.length);
30
+ const text2 = decoder.decode(bytes.subarray(offset, end), { stream: true });
31
+ offset = end;
32
+ if (text2.length > 0)
33
+ return text2;
34
+ }
35
+ const tail = decoder.decode();
36
+ return tail.length > 0 ? tail : null;
37
+ },
38
+ readAll: async () => {
39
+ if (offset >= bytes.length)
40
+ return '';
41
+ const out = decoder.decode(bytes.subarray(offset));
42
+ offset = bytes.length;
43
+ return out;
44
+ },
45
+ readLine: async () => {
46
+ if (offset >= bytes.length)
47
+ return null;
48
+ const newline = bytes.indexOf(0x0a, offset);
49
+ if (newline === -1) {
50
+ const line = decoder.decode(bytes.subarray(offset));
51
+ offset = bytes.length;
52
+ return line;
53
+ }
54
+ const line = decoder.decode(bytes.subarray(offset, newline));
55
+ offset = newline + 1;
56
+ return line;
57
+ },
58
+ };
59
+ }
@@ -8,7 +8,8 @@
8
8
  * uptime, tree, find, grep -r, head, tail, wc, diff, sort, uniq,
9
9
  * sed (s///), awk (field extract), xargs, tee, chown, ln -s,
10
10
  * du, man/help, basename, dirname, printf, true, false, seq, sleep,
11
- * touch, stat, file, xxd, base64, sha256sum, id, hostname, realpath
11
+ * touch, stat, file, xxd, od, hexdump, base64, sha256sum, id, hostname,
12
+ * realpath
12
13
  */
13
14
  import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
14
15
  import type { Command } from '../substrate/lifo/commands/types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"unix-commands.d.ts","sourceRoot":"","sources":["../../src/shell/unix-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAavE,OAAO,KAAK,EAAE,OAAO,EAAsB,MAAM,qCAAqC,CAAC;AAoFvF;;;;;;GAMG;AACH,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAgmIF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,SAAS,GACnB,IAAI,CAoKN"}
1
+ {"version":3,"file":"unix-commands.d.ts","sourceRoot":"","sources":["../../src/shell/unix-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAavE,OAAO,KAAK,EAAE,OAAO,EAAsB,MAAM,qCAAqC,CAAC;AAoFvF;;;;;;GAMG;AACH,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAskKF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,SAAS,GACnB,IAAI,CAyKN"}