@nimbus-sh/worker 0.9.0 → 0.11.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 (286) hide show
  1. package/NOTICE.md +5 -0
  2. package/README.md +10 -0
  3. package/dist/_shared/session-router.d.ts +7 -0
  4. package/dist/_shared/session-router.d.ts.map +1 -1
  5. package/dist/_shared/session-router.js +7 -0
  6. package/dist/bindings/body.d.ts +6 -0
  7. package/dist/bindings/body.d.ts.map +1 -0
  8. package/dist/bindings/body.js +37 -0
  9. package/dist/bindings/kv.d.ts +0 -2
  10. package/dist/bindings/kv.d.ts.map +1 -1
  11. package/dist/bindings/kv.js +3 -42
  12. package/dist/bindings/r2.d.ts +0 -2
  13. package/dist/bindings/r2.d.ts.map +1 -1
  14. package/dist/bindings/r2.js +4 -44
  15. package/dist/esbuild-cli-artifact.generated.d.ts +18 -0
  16. package/dist/esbuild-cli-artifact.generated.d.ts.map +1 -0
  17. package/dist/esbuild-cli-artifact.generated.js +17 -0
  18. package/dist/esbuild-wasm-bundle.generated.d.ts +24 -24
  19. package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
  20. package/dist/esbuild-wasm-bundle.generated.js +24 -24
  21. package/dist/facets/cirrus-real.d.ts.map +1 -1
  22. package/dist/facets/cirrus-real.js +11 -6
  23. package/dist/facets/compose.d.ts +11 -7
  24. package/dist/facets/compose.d.ts.map +1 -1
  25. package/dist/facets/compose.js +8 -31
  26. package/dist/facets/data-plan.d.ts +79 -0
  27. package/dist/facets/data-plan.d.ts.map +1 -0
  28. package/dist/facets/data-plan.js +477 -0
  29. package/dist/facets/esbuild-bundle-pool.d.ts +1 -1
  30. package/dist/facets/esbuild-bundle-pool.js +3 -3
  31. package/dist/facets/esbuild-transform.d.ts +38 -8
  32. package/dist/facets/esbuild-transform.d.ts.map +1 -1
  33. package/dist/facets/esbuild-transform.js +219 -19
  34. package/dist/facets/exec-telemetry.d.ts +7 -3
  35. package/dist/facets/exec-telemetry.d.ts.map +1 -1
  36. package/dist/facets/manager.d.ts +198 -69
  37. package/dist/facets/manager.d.ts.map +1 -1
  38. package/dist/facets/manager.js +1276 -652
  39. package/dist/facets/opencode-staging.d.ts +0 -2
  40. package/dist/facets/opencode-staging.d.ts.map +1 -1
  41. package/dist/facets/opencode-staging.js +5 -11
  42. package/dist/facets/process.d.ts +4 -0
  43. package/dist/facets/process.d.ts.map +1 -1
  44. package/dist/facets/process.js +3 -0
  45. package/dist/facets/read-profile.d.ts +149 -0
  46. package/dist/facets/read-profile.d.ts.map +1 -0
  47. package/dist/facets/read-profile.js +483 -0
  48. package/dist/facets/real-vite-hmr.d.ts +2 -0
  49. package/dist/facets/real-vite-hmr.d.ts.map +1 -1
  50. package/dist/facets/real-vite-hmr.js +3 -2
  51. package/dist/facets/resident-identity.d.ts +0 -1
  52. package/dist/facets/resident-identity.d.ts.map +1 -1
  53. package/dist/facets/resident-identity.js +0 -3
  54. package/dist/facets/wasm-swap-registry.d.ts +34 -25
  55. package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
  56. package/dist/facets/wasm-swap-registry.js +62 -56
  57. package/dist/facets/ws-terminal.d.ts +4 -4
  58. package/dist/facets/ws-terminal.d.ts.map +1 -1
  59. package/dist/facets/ws-terminal.js +4 -5
  60. package/dist/git/commands.d.ts +33 -10
  61. package/dist/git/commands.d.ts.map +1 -1
  62. package/dist/git/commands.js +1891 -197
  63. package/dist/git/network-facet.d.ts +12 -2
  64. package/dist/git/network-facet.d.ts.map +1 -1
  65. package/dist/git/network-facet.js +69 -18
  66. package/dist/git/unified-diff.d.ts +74 -0
  67. package/dist/git/unified-diff.d.ts.map +1 -0
  68. package/dist/git/unified-diff.js +676 -0
  69. package/dist/git-bundle.generated.d.ts +7 -11
  70. package/dist/git-bundle.generated.d.ts.map +1 -1
  71. package/dist/git-bundle.generated.js +7 -11
  72. package/dist/hosted/commands.d.ts.map +1 -1
  73. package/dist/hosted/commands.js +64 -245
  74. package/dist/hosted/runtime.d.ts +22 -15
  75. package/dist/hosted/runtime.d.ts.map +1 -1
  76. package/dist/hosted/runtime.js +72 -14
  77. package/dist/hosted/services.d.ts +8 -1
  78. package/dist/hosted/services.d.ts.map +1 -1
  79. package/dist/hosted/services.js +12 -13
  80. package/dist/hosted/session.d.ts +165 -0
  81. package/dist/hosted/session.d.ts.map +1 -0
  82. package/dist/hosted/session.js +132 -0
  83. package/dist/loaders/generated-workers.d.ts +6 -3
  84. package/dist/loaders/generated-workers.d.ts.map +1 -1
  85. package/dist/loaders/generated-workers.js +8 -5
  86. package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
  87. package/dist/loaders/npm-resolve-preamble.js +0 -27
  88. package/dist/loaders/pre-bundle-preamble.d.ts +6 -3
  89. package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
  90. package/dist/loaders/pre-bundle-preamble.js +13 -8
  91. package/dist/node-shims-artifact.generated.d.ts +13 -4
  92. package/dist/node-shims-artifact.generated.d.ts.map +1 -1
  93. package/dist/node-shims-artifact.generated.js +16 -7
  94. package/dist/npm/bin-links.d.ts +3 -1
  95. package/dist/npm/bin-links.d.ts.map +1 -1
  96. package/dist/npm/bin-links.js +32 -8
  97. package/dist/npm/cache.d.ts +11 -1
  98. package/dist/npm/cache.d.ts.map +1 -1
  99. package/dist/npm/cache.js +21 -7
  100. package/dist/npm/install-batch-facet.d.ts +4 -2
  101. package/dist/npm/install-batch-facet.d.ts.map +1 -1
  102. package/dist/npm/install-batch-facet.js +32 -18
  103. package/dist/npm/installer.d.ts +23 -3
  104. package/dist/npm/installer.d.ts.map +1 -1
  105. package/dist/npm/installer.js +330 -131
  106. package/dist/npm/npx-install.d.ts +3 -1
  107. package/dist/npm/npx-install.d.ts.map +1 -1
  108. package/dist/npm/npx-install.js +4 -1
  109. package/dist/npm/package-lock.d.ts +32 -0
  110. package/dist/npm/package-lock.d.ts.map +1 -0
  111. package/dist/npm/package-lock.js +65 -0
  112. package/dist/npm/placement.d.ts +16 -0
  113. package/dist/npm/placement.d.ts.map +1 -0
  114. package/dist/npm/placement.js +33 -0
  115. package/dist/npm/pre-bundle-facet.d.ts +1 -30
  116. package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
  117. package/dist/npm/pre-bundle-facet.js +3 -5
  118. package/dist/npm/r2-cache.d.ts +12 -6
  119. package/dist/npm/r2-cache.d.ts.map +1 -1
  120. package/dist/npm/r2-cache.js +34 -16
  121. package/dist/npm/resolve-one-facet.d.ts +3 -0
  122. package/dist/npm/resolve-one-facet.d.ts.map +1 -1
  123. package/dist/npm/resolve-one-facet.js +15 -3
  124. package/dist/npm/resolver.d.ts +11 -13
  125. package/dist/npm/resolver.d.ts.map +1 -1
  126. package/dist/npm/resolver.js +12 -25
  127. package/dist/opencode-artifact.generated.js +2 -2
  128. package/dist/replica/routing.d.ts +2 -38
  129. package/dist/replica/routing.d.ts.map +1 -1
  130. package/dist/replica/routing.js +3 -55
  131. package/dist/router/index.d.ts.map +1 -1
  132. package/dist/router/index.js +15 -2
  133. package/dist/router/public-directory.d.ts +18 -0
  134. package/dist/router/public-directory.d.ts.map +1 -1
  135. package/dist/router/public-directory.js +1 -1
  136. package/dist/router/remote-api.d.ts +3 -1
  137. package/dist/router/remote-api.d.ts.map +1 -1
  138. package/dist/router/remote-api.js +42 -79
  139. package/dist/runtime/bash-repl.js +2 -2
  140. package/dist/runtime/bun-repl.d.ts.map +1 -1
  141. package/dist/runtime/bun-repl.js +2 -13
  142. package/dist/runtime/cpython-resident.d.ts.map +1 -1
  143. package/dist/runtime/cpython-resident.js +2 -10
  144. package/dist/runtime/esbuild-wasm-bytes.d.ts +37 -18
  145. package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
  146. package/dist/runtime/esbuild-wasm-bytes.js +66 -92
  147. package/dist/runtime/facet-loader-host.d.ts.map +1 -1
  148. package/dist/runtime/facet-loader-host.js +0 -7
  149. package/dist/runtime/git-bundle-artifact.d.ts +17 -0
  150. package/dist/runtime/git-bundle-artifact.d.ts.map +1 -0
  151. package/dist/runtime/git-bundle-artifact.js +25 -0
  152. package/dist/runtime/node-repl.d.ts.map +1 -1
  153. package/dist/runtime/node-repl.js +2 -13
  154. package/dist/runtime/node-shims-artifact.d.ts +22 -23
  155. package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
  156. package/dist/runtime/node-shims-artifact.js +48 -78
  157. package/dist/runtime/node-shims.d.ts.map +1 -1
  158. package/dist/runtime/node-shims.js +2358 -996
  159. package/dist/runtime/opencode-artifact.d.ts.map +1 -1
  160. package/dist/runtime/opencode-artifact.js +17 -53
  161. package/dist/runtime/opencode-facet-runner.d.ts +3 -6
  162. package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
  163. package/dist/runtime/opencode-facet-runner.js +45 -10
  164. package/dist/runtime/opentui-wasm-bytes.d.ts.map +1 -1
  165. package/dist/runtime/opentui-wasm-bytes.js +16 -49
  166. package/dist/runtime/package-manager.d.ts +0 -2
  167. package/dist/runtime/package-manager.d.ts.map +1 -1
  168. package/dist/runtime/package-manager.js +0 -3
  169. package/dist/runtime/python-repl.d.ts.map +1 -1
  170. package/dist/runtime/python-repl.js +4 -35
  171. package/dist/runtime/repl-session.d.ts +10 -0
  172. package/dist/runtime/repl-session.d.ts.map +1 -1
  173. package/dist/runtime/repl-session.js +7 -0
  174. package/dist/runtime/ruby-repl.d.ts.map +1 -1
  175. package/dist/runtime/ruby-repl.js +2 -2
  176. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  177. package/dist/runtime/ruby-resident.js +41 -51
  178. package/dist/runtime/runtime-catalog.d.ts +10 -3
  179. package/dist/runtime/runtime-catalog.d.ts.map +1 -1
  180. package/dist/runtime/runtime-catalog.js +125 -15
  181. package/dist/runtime/sqlite-wasm-bytes.d.ts +4 -4
  182. package/dist/runtime/sqlite-wasm-bytes.d.ts.map +1 -1
  183. package/dist/runtime/sqlite-wasm-bytes.js +21 -57
  184. package/dist/runtime/staged-source.d.ts +67 -0
  185. package/dist/runtime/staged-source.d.ts.map +1 -0
  186. package/dist/runtime/staged-source.js +113 -0
  187. package/dist/runtime/wasi/preamble.d.ts +0 -22
  188. package/dist/runtime/wasi/preamble.d.ts.map +1 -1
  189. package/dist/runtime/wasi/preamble.js +98 -1425
  190. package/dist/runtime-catalog.generated.js +1 -1
  191. package/dist/session/agent.d.ts +14 -2
  192. package/dist/session/agent.d.ts.map +1 -1
  193. package/dist/session/agent.js +57 -19
  194. package/dist/session/ai.d.ts +0 -11
  195. package/dist/session/ai.d.ts.map +1 -1
  196. package/dist/session/ai.js +0 -4
  197. package/dist/session/fs-watch.d.ts +0 -11
  198. package/dist/session/fs-watch.d.ts.map +1 -1
  199. package/dist/session/fs-watch.js +0 -21
  200. package/dist/session/hibernation.d.ts +68 -2
  201. package/dist/session/hibernation.d.ts.map +1 -1
  202. package/dist/session/hibernation.js +95 -1
  203. package/dist/session/init-phases.d.ts +1 -2
  204. package/dist/session/init-phases.d.ts.map +1 -1
  205. package/dist/session/init-phases.js +1 -2
  206. package/dist/session/init.d.ts.map +1 -1
  207. package/dist/session/init.js +7 -20
  208. package/dist/session/keys.d.ts +0 -3
  209. package/dist/session/keys.d.ts.map +1 -1
  210. package/dist/session/keys.js +0 -3
  211. package/dist/session/legacy-reset.d.ts +11 -0
  212. package/dist/session/legacy-reset.d.ts.map +1 -0
  213. package/dist/session/legacy-reset.js +16 -0
  214. package/dist/session/nimbus-session.d.ts +50 -16
  215. package/dist/session/nimbus-session.d.ts.map +1 -1
  216. package/dist/session/nimbus-session.js +77 -71
  217. package/dist/session/npm-install-port.d.ts.map +1 -1
  218. package/dist/session/npm-install-port.js +2 -0
  219. package/dist/session/programmatic.d.ts +13 -18
  220. package/dist/session/programmatic.d.ts.map +1 -1
  221. package/dist/session/programmatic.js +53 -39
  222. package/dist/session/replica-routes.d.ts +2 -3
  223. package/dist/session/replica-routes.d.ts.map +1 -1
  224. package/dist/session/replica-routes.js +3 -10
  225. package/dist/session/routes.d.ts.map +1 -1
  226. package/dist/session/routes.js +11 -12
  227. package/dist/session/rpc.d.ts +108 -21
  228. package/dist/session/rpc.d.ts.map +1 -1
  229. package/dist/session/rpc.js +194 -39
  230. package/dist/session/start-real-vite.js +2 -2
  231. package/dist/session/state-store.d.ts +1 -17
  232. package/dist/session/state-store.d.ts.map +1 -1
  233. package/dist/session/state-store.js +3 -53
  234. package/dist/session/supervisor-op.d.ts +7 -0
  235. package/dist/session/supervisor-op.d.ts.map +1 -1
  236. package/dist/session/supervisor-op.js +6 -1
  237. package/dist/session/supervisor-rpc.d.ts +116 -19
  238. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  239. package/dist/session/supervisor-rpc.js +194 -84
  240. package/dist/session/vite-command.d.ts.map +1 -1
  241. package/dist/session/vite-command.js +17 -14
  242. package/dist/session/ws.d.ts.map +1 -1
  243. package/dist/session/ws.js +20 -8
  244. package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
  245. package/dist/shell/npm-bin-entrypoints.js +30 -5
  246. package/dist/vfs/facet-resident-limits.d.ts +33 -0
  247. package/dist/vfs/facet-resident-limits.d.ts.map +1 -0
  248. package/dist/vfs/facet-resident-limits.js +33 -0
  249. package/dist/vfs/facet-resident-store.d.ts +2 -10
  250. package/dist/vfs/facet-resident-store.d.ts.map +1 -1
  251. package/dist/vfs/facet-resident-store.js +1594 -219
  252. package/dist/workspace-host.d.ts +3 -1
  253. package/dist/workspace-host.d.ts.map +1 -1
  254. package/dist/workspace-host.js +2 -0
  255. package/dist/wrangler/nimbus-wrangler.d.ts +0 -2
  256. package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
  257. package/dist/wrangler/nimbus-wrangler.js +8 -22
  258. package/package.json +34 -7
  259. package/public/_assets/esbuild-0.24.2.js +2380 -0
  260. package/public/_assets/opencode/1.16.2/index-attach.js +2 -2
  261. package/public/_assets/runtime/esbuild-cli-c4fda380d52befc1.js +6892 -0
  262. package/public/_assets/runtime/git-de3e60c9f3ff006a.js +103 -0
  263. package/public/_assets/runtime/{node-shims-acaa037e6d26ec0d.js → node-shims-06565b121555c194.js} +2879 -992
  264. package/public/_assets/runtime/resident-store-6ffb1939c53d982f.js +2264 -0
  265. package/public/_assets/runtime/vfs-write-ledger-e501e8fc793bc2c1.js +889 -0
  266. package/scripts/build-opencode-attach-entry.mjs +51 -1
  267. package/scripts/bundle-esbuild-wasm.mjs +55 -39
  268. package/scripts/bundle-facet-workers.mjs +159 -10
  269. package/scripts/bundle-git.mjs +88 -27
  270. package/scripts/bundle-node-shims.mjs +72 -46
  271. package/scripts/bundle-runtime.mjs +18 -421
  272. package/scripts/cf-git-patch.mjs +137 -0
  273. package/scripts/patch-install-deps.mjs +49 -96
  274. package/scripts/runtime-specs.mjs +435 -0
  275. package/vendor/git-http.generated.d.ts +82 -0
  276. package/vendor/git-upstream.generated.d.ts +4378 -0
  277. package/vendor/git.LICENSE +7 -0
  278. package/vendor/git.generated.d.mts +21 -0
  279. package/vendor/git.generated.mjs +103 -0
  280. package/dist/replica/suspension.d.ts +0 -36
  281. package/dist/replica/suspension.d.ts.map +0 -1
  282. package/dist/replica/suspension.js +0 -49
  283. package/dist/runtime/static-server.d.ts +0 -3
  284. package/dist/runtime/static-server.d.ts.map +0 -1
  285. package/dist/runtime/static-server.js +0 -133
  286. package/scripts/clean-dist.mjs +0 -7
@@ -1,5 +1,5 @@
1
1
  /**
2
- * git-network-facet.ts — Facet-based git clone/fetch/pull.
2
+ * git/network-facet.ts — Facet-based git clone/fetch/pull.
3
3
  *
4
4
  * Runs isomorphic-git's network operations (clone/fetch/pull) inside a
5
5
  * dynamic worker (LOADER.load) to escape the supervisor DO's CPU budget
@@ -33,6 +33,8 @@ export interface GitNetworkOpts {
33
33
  dir: string;
34
34
  /** For clone: repository URL */
35
35
  url?: string;
36
+ /** `git clone -q`: no progress on the terminal; the result is unchanged. */
37
+ quiet?: boolean;
36
38
  /** For fetch/pull: remote name (default "origin") */
37
39
  remote?: string;
38
40
  /** For clone: branch to clone (default remote HEAD); for pull: branch name (default current) */
@@ -44,10 +46,18 @@ export interface GitNetworkOpts {
44
46
  username: string;
45
47
  password: string;
46
48
  };
47
- /** Author (for pull merges) */
49
+ /** Author and committer (for pull merges), as the supervisor's git resolved them. */
48
50
  author?: {
49
51
  name: string;
50
52
  email: string;
53
+ timestamp?: number;
54
+ timezoneOffset?: number;
55
+ };
56
+ committer?: {
57
+ name: string;
58
+ email: string;
59
+ timestamp?: number;
60
+ timezoneOffset?: number;
51
61
  };
52
62
  /** Total operation budget (ms). Clone default 30 min; other ops default 5 min. */
53
63
  timeout?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"network-facet.d.ts","sourceRoot":"","sources":["../../src/git/network-facet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAcH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,YAAY,CAAC;IACjB,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC;IACZ,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,IAAI,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,+BAA+B;IAC/B,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,OAAO,CAA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  /**
2
- * git-network-facet.ts — Facet-based git clone/fetch/pull.
2
+ * git/network-facet.ts — Facet-based git clone/fetch/pull.
3
3
  *
4
4
  * Runs isomorphic-git's network operations (clone/fetch/pull) inside a
5
5
  * dynamic worker (LOADER.load) to escape the supervisor DO's CPU budget
@@ -25,9 +25,10 @@
25
25
  * in the PR that introduced this file.
26
26
  */
27
27
  import { getCtxExports } from '@nimbus-sh/fabric/composition.js';
28
+ import { supervisorBindingProps } from '@nimbus-sh/fabric/supervisor-props.js';
28
29
  import { CF_COMPAT_DATE } from '@nimbus-sh/core/constants.js';
29
30
  import { MAX_RPC_SAFE_PAYLOAD_BYTES } from '@nimbus-sh/platform/limits.js';
30
- import { GIT_BUNDLE_CODE } from '../git-bundle.generated.js';
31
+ import { fetchGitBundleSource } from '../runtime/git-bundle-artifact.js';
31
32
  import { W7_FRAME_PREAMBLE } from '../loaders/generated-workers.js';
32
33
  import { ESBUILD_NAME_GLOBAL_SHIM } from '@nimbus-sh/core/_shared/esbuild-facet-shim.js';
33
34
  import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
@@ -407,7 +408,7 @@ export async function execGitNetwork(ctx, env, opts) {
407
408
  const ctxExports = getCtxExports();
408
409
  const supervisorBinding = ctxExports?.SupervisorRPC
409
410
  ? ctxExports.SupervisorRPC({
410
- props: { doId: ctx.id.toString(), pid: opts.pid, mutationOwner },
411
+ props: { ...supervisorBindingProps(ctx, opts.pid), mutationOwner },
411
412
  })
412
413
  : undefined;
413
414
  if (!supervisorBinding) {
@@ -424,6 +425,7 @@ export async function execGitNetwork(ctx, env, opts) {
424
425
  let worker;
425
426
  let entrypoint;
426
427
  try {
428
+ const gitBundleSource = await fetchGitBundleSource(env);
427
429
  const loadedWorker = env.LOADER.load({
428
430
  compatibilityDate: CF_COMPAT_DATE,
429
431
  compatibilityFlags: ['nodejs_compat'],
@@ -436,10 +438,11 @@ export async function execGitNetwork(ctx, env, opts) {
436
438
  // `preamble` option provides for npm install. This is the
437
439
  // W7 v3 emits one bounded record per pull; the receiver owns
438
440
  // the aggregate 8 MiB payload-credit and transaction limits.
439
- // - the pre-bundled isomorphic-git (git-bundle.js)
441
+ // - the pre-bundled isomorphic-git (git-bundle.js), the staged
442
+ // copy of vendor/git.generated.mjs (runtime/git-bundle-artifact.ts)
440
443
  modules: {
441
444
  'git-network-worker.js': assembleGitNetworkFacetSource(),
442
- 'git-bundle.js': GIT_BUNDLE_CODE,
445
+ 'git-bundle.js': gitBundleSource,
443
446
  },
444
447
  env: { SUPERVISOR: supervisorBinding },
445
448
  });
@@ -482,7 +485,8 @@ export async function execGitNetwork(ctx, env, opts) {
482
485
  ? prepare.result.error
483
486
  : 'clone-prepare returned an invalid result', prepare.diagnostic);
484
487
  }
485
- await writeClonePhaseProgress(supervisorBinding, prepare.diagnostic);
488
+ if (!opts.quiet)
489
+ await writeClonePhaseProgress(supervisorBinding, prepare.diagnostic);
486
490
  let checkoutCursor = null;
487
491
  let checkoutChunk = 0;
488
492
  do {
@@ -513,7 +517,9 @@ export async function execGitNetwork(ctx, env, opts) {
513
517
  budgetContext.chunksCompleted++;
514
518
  budgetContext.processedEntries += progress.treeEntriesVisited;
515
519
  budgetContext.decodedBytes += progress.decodedBytes;
516
- await writeCloneChunkProgress(supervisorBinding, checkout.diagnostic, checkoutChunk, progress);
520
+ if (!opts.quiet) {
521
+ await writeCloneChunkProgress(supervisorBinding, checkout.diagnostic, checkoutChunk, progress);
522
+ }
517
523
  } while (checkoutCursor !== null);
518
524
  return {
519
525
  success: true,
@@ -550,7 +556,8 @@ export async function execGitNetwork(ctx, env, opts) {
550
556
  const abort = await invokeFacet(entrypoint, 'clone-abort', crypto.randomUUID(), { ...facetOpts, jobId, optionsHash }, Date.now() + CLONE_ABORT_TIMEOUT_MS, CLONE_ABORT_TIMEOUT_MS);
551
557
  phases.push(abort.diagnostic);
552
558
  accountResult(abort.result);
553
- await writeClonePhaseProgress(supervisorBinding, abort.diagnostic);
559
+ if (!opts.quiet)
560
+ await writeClonePhaseProgress(supervisorBinding, abort.diagnostic);
554
561
  if (abort.result.success !== true) {
555
562
  cleanupError = typeof abort.result.error === 'string'
556
563
  ? abort.result.error
@@ -1077,6 +1084,18 @@ function enotdir(filepath) {
1077
1084
  return err;
1078
1085
  }
1079
1086
 
1087
+ function eisdir(filepath) {
1088
+ const err = new Error('EISDIR: illegal operation on a directory, ' + filepath);
1089
+ err.code = 'EISDIR'; err.errno = -21;
1090
+ return err;
1091
+ }
1092
+
1093
+ function enotempty(filepath) {
1094
+ const err = new Error('ENOTEMPTY: directory not empty, ' + filepath);
1095
+ err.code = 'ENOTEMPTY'; err.errno = -39;
1096
+ return err;
1097
+ }
1098
+
1080
1099
  function einval(filepath) {
1081
1100
  const err = new Error('EINVAL: invalid argument, ' + filepath);
1082
1101
  err.code = 'EINVAL'; err.errno = -22;
@@ -1132,7 +1151,9 @@ function convertSupervisorStat(st) {
1132
1151
  mtimeMs, mtime: new Date(mtimeMs),
1133
1152
  ctimeMs, ctime: new Date(ctimeMs),
1134
1153
  atimeMs, atime: new Date(atimeMs),
1135
- uid: 1000, gid: 1000, dev: 0, ino: 0, nlink: 1,
1154
+ // The supervisor's git reports these same fields, so an index either side wrote stays warm.
1155
+ uid: Number(st.uid) || 0, gid: Number(st.gid) || 0,
1156
+ dev: Number(st.dev) || 0, ino: Number(st.ino) || 0, nlink: 1,
1136
1157
  };
1137
1158
  }
1138
1159
 
@@ -1171,7 +1192,7 @@ function emptyMetadataOverlayStats() {
1171
1192
  * Files + all their parent directories become inodes; file content is
1172
1193
  * chunked at CHUNK_SIZE boundaries to match sqlite-vfs.
1173
1194
  */
1174
- function buildPayload(writeBuffer, dirBuffer, deleteSet, metadata, authoritativeRoot) {
1195
+ function buildPayload(writeBuffer, dirBuffer, deleteSet, metadata, authoritativeRoot, worktreeRoot) {
1175
1196
  const inodes = [];
1176
1197
  const chunks = [];
1177
1198
  const dirs = new Set();
@@ -1179,12 +1200,12 @@ function buildPayload(writeBuffer, dirBuffer, deleteSet, metadata, authoritative
1179
1200
 
1180
1201
  // Collect all parent directories for files.
1181
1202
  for (const [path] of writeBuffer) {
1182
- collectDirectoryPaths(dirs, parentOf(path), authoritativeRoot);
1203
+ collectDirectoryPaths(dirs, parentOf(path), authoritativeRoot, worktreeRoot);
1183
1204
  }
1184
1205
  // Explicit mkdir entries
1185
1206
  for (const d of dirBuffer) {
1186
1207
  if (!d) continue;
1187
- collectDirectoryPaths(dirs, d, authoritativeRoot);
1208
+ collectDirectoryPaths(dirs, d, authoritativeRoot, worktreeRoot);
1188
1209
  }
1189
1210
 
1190
1211
  const orderedDirs = [...dirs].sort((left, right) => {
@@ -1259,12 +1280,19 @@ function buildPayload(writeBuffer, dirBuffer, deleteSet, metadata, authoritative
1259
1280
  return { inodes, chunks, deletePaths };
1260
1281
  }
1261
1282
 
1262
- function collectDirectoryPaths(paths, path, authoritativeRoot) {
1283
+ // A clone publishes the directories it creates, up to and including its
1284
+ // authoritative root. An operation in an existing worktree (worktreeRoot)
1285
+ // publishes only directories below its top: the top and everything above it
1286
+ // already exist, are followed as git follows them, and are not the worktree's
1287
+ // to rewrite — republishing home is EACCES for the session user, and would
1288
+ // replace a linked ancestor with an empty directory.
1289
+ function collectDirectoryPaths(paths, path, authoritativeRoot, worktreeRoot = null) {
1263
1290
  let current = path;
1264
1291
  while (current) {
1265
1292
  if (authoritativeRoot &&
1266
1293
  current !== authoritativeRoot &&
1267
1294
  !current.startsWith(authoritativeRoot + '/')) break;
1295
+ if (worktreeRoot !== null && !current.startsWith(worktreeRoot + '/')) break;
1268
1296
  paths.add(current);
1269
1297
  if (current === authoritativeRoot) break;
1270
1298
  current = parentOf(current);
@@ -1274,6 +1302,14 @@ function collectDirectoryPaths(paths, path, authoritativeRoot) {
1274
1302
  /**
1275
1303
  * Create the buffered fs adapter isomorphic-git will use.
1276
1304
  * Writes buffer in-memory; reads check buffer then fall back to supervisor.
1305
+ *
1306
+ * With a worktreeRoot (fetch, pull, push in an existing repository) the
1307
+ * adapter writes that worktree the way git's checkout does (entry.c
1308
+ * create_directories, has_symlink_leading_path): below its top, .git
1309
+ * aside, a leading component that is not a real directory (a link, dangling
1310
+ * or not, or a file) is deleted and replaced by a directory rather than
1311
+ * followed, and a file replaces a link at its own path rather than writing
1312
+ * through it.
1277
1313
  */
1278
1314
  function createBufferedFs(
1279
1315
  supervisor,
@@ -1285,6 +1321,7 @@ function createBufferedFs(
1285
1321
  phaseDeadline = null,
1286
1322
  authoritativeFallbackPaths = [],
1287
1323
  authoritativeFallbackRoots = [],
1324
+ worktreeRoot = null,
1288
1325
  ) {
1289
1326
  const writeBuffer = new Map(); // path → Uint8Array (insertion ordered = FIFO)
1290
1327
  const pendingWriteMetadata = new Map();
@@ -1477,16 +1514,16 @@ function createBufferedFs(
1477
1514
  const paths = new Set(deleteBuffer);
1478
1515
  for (const path of dirBuffer) {
1479
1516
  if (!path) continue;
1480
- collectDirectoryPaths(paths, path, authoritativeRoot);
1517
+ collectDirectoryPaths(paths, path, authoritativeRoot, worktreeRoot);
1481
1518
  }
1482
1519
  for (const path of writeBuffer.keys()) {
1483
1520
  paths.add(path);
1484
- collectDirectoryPaths(paths, parentOf(path), authoritativeRoot);
1521
+ collectDirectoryPaths(paths, parentOf(path), authoritativeRoot, worktreeRoot);
1485
1522
  }
1486
1523
  if (extraPath) {
1487
1524
  paths.add(extraPath);
1488
1525
  if (includeParents) {
1489
- collectDirectoryPaths(paths, parentOf(extraPath), authoritativeRoot);
1526
+ collectDirectoryPaths(paths, parentOf(extraPath), authoritativeRoot, worktreeRoot);
1490
1527
  }
1491
1528
  }
1492
1529
  let pathBytes = 0;
@@ -1574,6 +1611,7 @@ function createBufferedFs(
1574
1611
  deleteBuffer,
1575
1612
  waveMetadata,
1576
1613
  authoritativeRoot,
1614
+ worktreeRoot,
1577
1615
  );
1578
1616
  // Snapshot stats counters BEFORE clearing the buffers so the increments
1579
1617
  // below see the wave's true size, not zero.
@@ -1857,9 +1895,14 @@ function createBufferedFs(
1857
1895
  });
1858
1896
  },
1859
1897
 
1898
+ // unlink(2) and rmdir(2): a buffered delete removes the whole subtree at
1899
+ // its path, so neither may take a directory it would not take on disk.
1900
+ // unlink refuses a directory; rmdir refuses a non-directory and a
1901
+ // directory that still holds anything (untracked files a checkout leaves).
1860
1902
  async unlink(filepath) {
1861
1903
  assertFlushHealthy();
1862
1904
  const p = normalizePath(filepath);
1905
+ if ((await fs.promises.lstat(filepath)).isDirectory()) throw eisdir(filepath);
1863
1906
  return bufferMutation(p, 0, false, async () => {
1864
1907
  if (writeBuffer.has(p)) {
1865
1908
  bufferBytes -= writeBuffer.get(p).length;
@@ -1935,9 +1978,13 @@ function createBufferedFs(
1935
1978
  });
1936
1979
  },
1937
1980
 
1938
- async rmdir(filepath) {
1981
+ async rmdir(filepath, options) {
1939
1982
  assertFlushHealthy();
1940
1983
  const p = normalizePath(filepath);
1984
+ if (!(options && options.recursive)) {
1985
+ if (!(await fs.promises.lstat(filepath)).isDirectory()) throw enotdir(filepath);
1986
+ if ((await fs.promises.readdir(filepath)).length > 0) throw enotempty(filepath);
1987
+ }
1941
1988
  return bufferMutation(p, 0, false, async () => {
1942
1989
  dirBuffer.delete(p);
1943
1990
  deleteBuffer.add(p);
@@ -2185,13 +2232,14 @@ export default {
2185
2232
  }
2186
2233
  }
2187
2234
  const log = (msg) => {
2235
+ if (opts.quiet) return;
2188
2236
  stats.supervisorRpc.stdout++;
2189
2237
  try { useRpcResult(supervisor.stdout(new TextEncoder().encode(msg)), () => undefined).catch(() => {}); } catch {}
2190
2238
  };
2191
2239
 
2192
2240
  // Import the pre-bundled isomorphic-git + http/web.
2193
2241
  // The bundle is provided via LOADER.load()'s modules record;
2194
- // see scripts/bundle-git.mjs and src/git-bundle.generated.ts.
2242
+ // see scripts/bundle-git.mjs and src/runtime/git-bundle-artifact.ts.
2195
2243
  let git, http;
2196
2244
  try {
2197
2245
  const bundle = await import('./git-bundle.js');
@@ -2375,6 +2423,8 @@ export default {
2375
2423
  phase === 'clone-checkout'
2376
2424
  ? [normalizePath(opts.dir) + '/.git/nimbus-checkout-index']
2377
2425
  : [],
2426
+ // fetch, pull and push work in a repository that already exists.
2427
+ phase === 'operation' ? normalizePath(opts.dir) : null,
2378
2428
  );
2379
2429
  const fs = bufferedFs.fs;
2380
2430
  flushWave = bufferedFs.flushWave;
@@ -2601,6 +2651,7 @@ export default {
2601
2651
  ref: opts.ref,
2602
2652
  singleBranch: true,
2603
2653
  author: opts.author || { name: 'user', email: 'user@nimbus.dev' },
2654
+ committer: opts.committer,
2604
2655
  onProgress,
2605
2656
  onAuth,
2606
2657
  });
@@ -0,0 +1,74 @@
1
+ export declare const DEFAULT_CONTEXT = 3;
2
+ /** One side of a file pair: git's diff_filespec. */
3
+ export interface DiffSpec {
4
+ /** Repo-relative path, or the path as given to --no-index ('/dev/null' for an absent side). */
5
+ path: string;
6
+ /** False on the absent side of an add or a delete. */
7
+ valid: boolean;
8
+ oid: string;
9
+ mode: number;
10
+ data: Uint8Array;
11
+ }
12
+ export interface DiffPair {
13
+ one: DiffSpec;
14
+ two: DiffSpec;
15
+ /** Set when rename detection paired `one` with `two`: similarity out of MAX_SCORE. */
16
+ renameScore?: number;
17
+ }
18
+ export declare function absentSpec(path: string): DiffSpec;
19
+ /** diff_resolve_rename_copy's status letter. */
20
+ export declare function pairStatus(pair: DiffPair): 'A' | 'D' | 'T' | 'R' | 'M';
21
+ export declare function binaryFromBytes(bytes: Uint8Array): string;
22
+ export declare function bytesFromBinary(text: string): Uint8Array;
23
+ /** A path's UTF-8 bytes as a binary string. */
24
+ export declare function binaryPath(path: string): string;
25
+ /** A path as git prints it on a '\n'-ended line: C-quoted if any byte needs it. */
26
+ export declare function quotePath(path: string): string;
27
+ /** One entry of a path list: quoted and '\n'-ended, or raw and NUL-ended under -z. */
28
+ export declare function pathLine(path: string, z: boolean): string;
29
+ /** buffer_is_binary: a NUL in the first 8000 bytes. */
30
+ export declare function isBinary(data: Uint8Array): boolean;
31
+ /** One file's `diff --git` section, exactly as `git diff` prints it without color. */
32
+ export declare function formatPatch(pair: DiffPair, context?: number): string;
33
+ export declare function formatNameOnly(pair: DiffPair, z: boolean): string;
34
+ export declare function formatNameStatus(pair: DiffPair, z: boolean): string;
35
+ export interface StatFile {
36
+ /** Display name: quoted path, or `from => to` when the two sides are named differently. */
37
+ name: string;
38
+ added: number;
39
+ deleted: number;
40
+ binary: boolean;
41
+ }
42
+ export declare function statFile(pair: DiffPair): StatFile;
43
+ /** The --stat block for `columns` terminal columns (git's term_columns: $COLUMNS, else 80). */
44
+ export declare function formatStat(files: readonly StatFile[], columns: number): string;
45
+ export declare const MAX_SCORE = 60000;
46
+ export declare const DEFAULT_RENAME_SCORE = 30000;
47
+ export declare function similarityIndex(score: number): number;
48
+ /** parse_rename_score (`5`, `50%` and `.5` are all 50%), or null when anything follows the number. */
49
+ export declare function parseRenameScore(text: string): number | null;
50
+ export interface RenameSide {
51
+ path: string;
52
+ oid: string;
53
+ mode: number;
54
+ }
55
+ export interface QueuedPair<S extends RenameSide> {
56
+ one: S | null;
57
+ two: S | null;
58
+ renameScore?: number;
59
+ }
60
+ /**
61
+ * git diff's default rename detection over a path-ordered queue: exact
62
+ * renames, then unique basenames at a higher bar, then the similarity
63
+ * matrix, skipped (as git skips it) past `renameLimit` squared pairs. A
64
+ * rename takes its destination's place in the queue. `neededRenameLimit`
65
+ * is non-zero when the matrix was skipped.
66
+ */
67
+ export declare function detectRenames<S extends RenameSide>(queue: readonly QueuedPair<S>[], read: (side: S) => Promise<Uint8Array>, { minimumScore, renameLimit }?: {
68
+ minimumScore?: number | undefined;
69
+ renameLimit?: number | undefined;
70
+ }): Promise<{
71
+ queue: QueuedPair<S>[];
72
+ neededRenameLimit: number;
73
+ }>;
74
+ //# sourceMappingURL=unified-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified-diff.d.ts","sourceRoot":"","sources":["../../src/git/unified-diff.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe,I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