@jami-studio/core 0.92.17 → 0.92.18

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.
@@ -1,5 +1,11 @@
1
1
  # @agent-native/core
2
2
 
3
+ ## 0.92.18
4
+
5
+ ### Patch Changes
6
+
7
+ - 1c340cc: Fix three Cloudflare Pages worker module-init crashes surfaced by serving the unified workspace artifact under wrangler pages dev: stub `sharp` (its native loader threw at require time), expose functional overrides like `os.tmpdir()` through the node-builtin stub default export (a bare throwing proxy killed workers that call overridden members via `import os from "os"`), and patch remaining `import.meta.url` occurrences in worker bundles (wrangler's re-bundle empties inner `import.meta`, so `fileURLToPath(import.meta.url)` threw at module init). Also default `RAYON_NUM_THREADS` to 1 on Windows workspace builds — 2 threads still hit the rolldown rayon access-violation race in full 14-app sequences.
8
+
3
9
  ## 0.92.17
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.92.17",
3
+ "version": "0.92.18",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/studio-jami/jami-studio#readme",
6
6
  "bugs": {
@@ -119,6 +119,16 @@ export const CLOUDFLARE_WORKER_STUB_MODULES: Record<string, string> = {
119
119
  ].join("\n"),
120
120
  "better-sqlite3":
121
121
  "export default {}; export const Database = class {}; export const watch = () => ({ close() {} });\n",
122
+ // sharp loads its native binary (@img/sharp-<platform>) at require time and
123
+ // throws "Could not load the sharp module using the linux- runtime" at
124
+ // worker module init. Stub it with a callable that throws at call time —
125
+ // image processing can't run on workerd regardless.
126
+ sharp: [
127
+ "const unavailable = () => { throw new Error('sharp unavailable in Cloudflare Pages worker'); };",
128
+ "const sharp = new Proxy(unavailable, { get: (_t, prop) => (prop === 'default' ? sharp : unavailable), apply: unavailable });",
129
+ "export default sharp;",
130
+ "",
131
+ ].join("\n"),
122
132
  "node-pty":
123
133
  "export default {}; export const watch = () => ({ close() {} });\n",
124
134
  chokidar: "export default {}; export const watch = () => ({ close() {} });\n",
@@ -274,13 +284,20 @@ function cloudflareNodeBuiltinStubSource(
274
284
  const exports = Array.from(new Set(namedExports))
275
285
  .filter((name) => !overridden.has(name))
276
286
  .sort();
287
+ // The default export must expose the SAME members as the named exports —
288
+ // including functional overrides like os.tmpdir() — because most consumers
289
+ // use the default import (`import os from "os"; os.tmpdir()`). A bare
290
+ // throwing proxy here killed workers at module init whenever a dependency
291
+ // called an overridden member through the default export.
292
+ const allNames = Array.from(new Set([...overridden, ...exports])).sort();
277
293
  return [
278
294
  `const unavailable = (name) => (..._args) => { throw new Error(name + " is unavailable in Cloudflare Pages workers"); };`,
279
- `const proxy = new Proxy({}, { get(_target, prop) { return unavailable("${moduleName}." + String(prop)); } });`,
280
295
  ...overrides,
281
296
  ...exports.map(
282
297
  (name) => `export const ${name} = unavailable("${moduleName}.${name}");`,
283
298
  ),
299
+ `const __members = { ${allNames.join(", ")} };`,
300
+ `const proxy = new Proxy(__members, { get(target, prop) { return prop in target ? target[prop] : unavailable("${moduleName}." + String(prop)); } });`,
284
301
  "export default proxy;",
285
302
  "",
286
303
  ].join("\n");
@@ -1882,6 +1899,13 @@ async function buildCloudflarePages() {
1882
1899
  "var $1 = function() { return typeof require !== 'undefined' ? require : function(m) { throw new Error('require not supported: ' + m); }; };",
1883
1900
  );
1884
1901
 
1902
+ // Patch remaining import.meta.url occurrences — when wrangler/Pages
1903
+ // re-bundles the worker, inner modules get an emptied import.meta, so
1904
+ // fileURLToPath(import.meta.url) throws at module init ("path" argument
1905
+ // must be string, received undefined). Same treatment as the Vite
1906
+ // server-build path: replace with a stable synthetic file URL.
1907
+ code = code.replace(/\bimport\.meta\.url\b/g, '"file:///worker.mjs"');
1908
+
1885
1909
  // Patch setInterval/setTimeout at module scope — CF Workers disallows timers in global scope.
1886
1910
  // Some dependencies (e.g. Anthropic SDK rate limiter) call setInterval at module init.
1887
1911
  // With code splitting, chunks evaluate before the entry, so the shim must be in every file.
@@ -228,10 +228,12 @@ function buildOneApp(
228
228
  // intermittently (and for some apps deterministically) kills the build
229
229
  // with an access violation (0xC0000005). Capping the pool avoids the
230
230
  // race entirely; verified: chat's cloudflare_pages build crashed 100%
231
- // in-sequence at default threads and passes at 2. Respect an explicit
232
- // operator override.
231
+ // in-sequence at default threads and STILL crashed at 2 (forms died at
232
+ // 2 in a full 14-app sequence) — only a single rayon thread has proven
233
+ // green across the whole workspace. Respect an explicit operator
234
+ // override.
233
235
  ...(process.platform === "win32"
234
- ? { RAYON_NUM_THREADS: process.env.RAYON_NUM_THREADS ?? "2" }
236
+ ? { RAYON_NUM_THREADS: process.env.RAYON_NUM_THREADS ?? "1" }
235
237
  : {}),
236
238
  AGENT_NATIVE_WORKSPACE: "1",
237
239
  AGENT_NATIVE_WORKSPACE_APP_ID: app,
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAmCH,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,6BAA6B,UAiBzC,CAAC;AAEF,eAAO,MAAM,mCAAmC,UAiB/C,CAAC;AACF,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwHjE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,UAUnC,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAaxB;AA6BD,eAAO,MAAM,2CAA2C,EAAE,MAAM,CAC9D,MAAM,EACN,MAAM,CAmSP,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,qBAAqB,CAAC,EAAE,OAAO,CA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;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAkBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iCAAiC,YAAI,KAAK,CAAU,CAAC;AAElE;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,GACnB,IAAI,GAAG,SAAS,MAAM,EAAE,CAK1B"}
@@ -82,6 +82,16 @@ export const CLOUDFLARE_WORKER_STUB_MODULES = {
82
82
  "",
83
83
  ].join("\n"),
84
84
  "better-sqlite3": "export default {}; export const Database = class {}; export const watch = () => ({ close() {} });\n",
85
+ // sharp loads its native binary (@img/sharp-<platform>) at require time and
86
+ // throws "Could not load the sharp module using the linux- runtime" at
87
+ // worker module init. Stub it with a callable that throws at call time —
88
+ // image processing can't run on workerd regardless.
89
+ sharp: [
90
+ "const unavailable = () => { throw new Error('sharp unavailable in Cloudflare Pages worker'); };",
91
+ "const sharp = new Proxy(unavailable, { get: (_t, prop) => (prop === 'default' ? sharp : unavailable), apply: unavailable });",
92
+ "export default sharp;",
93
+ "",
94
+ ].join("\n"),
85
95
  "node-pty": "export default {}; export const watch = () => ({ close() {} });\n",
86
96
  chokidar: "export default {}; export const watch = () => ({ close() {} });\n",
87
97
  fsevents: "export default {}; export const watch = () => ({ close() {} });\n",
@@ -215,11 +225,18 @@ function cloudflareNodeBuiltinStubSource(moduleName, namedExports, overrides = [
215
225
  const exports = Array.from(new Set(namedExports))
216
226
  .filter((name) => !overridden.has(name))
217
227
  .sort();
228
+ // The default export must expose the SAME members as the named exports —
229
+ // including functional overrides like os.tmpdir() — because most consumers
230
+ // use the default import (`import os from "os"; os.tmpdir()`). A bare
231
+ // throwing proxy here killed workers at module init whenever a dependency
232
+ // called an overridden member through the default export.
233
+ const allNames = Array.from(new Set([...overridden, ...exports])).sort();
218
234
  return [
219
235
  `const unavailable = (name) => (..._args) => { throw new Error(name + " is unavailable in Cloudflare Pages workers"); };`,
220
- `const proxy = new Proxy({}, { get(_target, prop) { return unavailable("${moduleName}." + String(prop)); } });`,
221
236
  ...overrides,
222
237
  ...exports.map((name) => `export const ${name} = unavailable("${moduleName}.${name}");`),
238
+ `const __members = { ${allNames.join(", ")} };`,
239
+ `const proxy = new Proxy(__members, { get(target, prop) { return prop in target ? target[prop] : unavailable("${moduleName}." + String(prop)); } });`,
223
240
  "export default proxy;",
224
241
  "",
225
242
  ].join("\n");
@@ -1542,6 +1559,12 @@ async function buildCloudflarePages() {
1542
1559
  // Matches both `from "module"` and `from "node:module"` — with the node:
1543
1560
  // prefix preserved (for nodejs_compat_v2), the latter is what esbuild now emits.
1544
1561
  code = code.replace(/\bimport\s*\{\s*createRequire\s+as\s+([\w$]+)\s*\}\s*from\s*["'](?:node:)?module["']\s*;/g, "var $1 = function() { return typeof require !== 'undefined' ? require : function(m) { throw new Error('require not supported: ' + m); }; };");
1562
+ // Patch remaining import.meta.url occurrences — when wrangler/Pages
1563
+ // re-bundles the worker, inner modules get an emptied import.meta, so
1564
+ // fileURLToPath(import.meta.url) throws at module init ("path" argument
1565
+ // must be string, received undefined). Same treatment as the Vite
1566
+ // server-build path: replace with a stable synthetic file URL.
1567
+ code = code.replace(/\bimport\.meta\.url\b/g, '"file:///worker.mjs"');
1545
1568
  // Patch setInterval/setTimeout at module scope — CF Workers disallows timers in global scope.
1546
1569
  // Some dependencies (e.g. Anthropic SDK rate limiter) call setInterval at module init.
1547
1570
  // With code splitting, chunks evaluate before the entry, so the shim must be in every file.