@jami-studio/core 0.92.16 → 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.
- package/corpus/core/CHANGELOG.md +13 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/deploy/build.ts +41 -1
- package/corpus/core/src/deploy/workspace-deploy.ts +26 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +40 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/deploy/workspace-deploy.js +21 -1
- package/dist/deploy/workspace-deploy.js.map +1 -1
- package/package.json +1 -1
package/corpus/core/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.92.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 1dd0867: Cloudflare Pages unified deploy fixes found by running the artifact on workerd: (1) `_routes.json` no longer emits rules covered by another rule's splat (Cloudflare rejects overlapping rules — "/apps/new-app" under "/apps/\*" broke every workspace deploy); (2) stub `detect-libc` in the worker bundle — it calls `process.report.getReport()` at require time, which unenv throws on, killing the worker at module init.
|
|
14
|
+
- 950b77d: workspace-deploy: cap rolldown's rayon thread pool on Windows (RAYON_NUM_THREADS=2 unless overridden). The native thread pool has a race that kills app builds with an access violation (0xC0000005) — intermittently for most apps, deterministically for some (chat under cloudflare_pages). Capping the pool eliminates the crash; combined with the native-crash retry this makes unified workspace builds reliable on Windows.
|
|
15
|
+
|
|
3
16
|
## 0.92.16
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/corpus/core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.92.
|
|
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": {
|
|
@@ -101,8 +101,34 @@ export const CLOUDFLARE_WORKER_ESBUILD_EXTERNALS = [
|
|
|
101
101
|
"fsevents",
|
|
102
102
|
];
|
|
103
103
|
export const CLOUDFLARE_WORKER_STUB_MODULES: Record<string, string> = {
|
|
104
|
+
// detect-libc calls process.report.getReport() at require time to sniff
|
|
105
|
+
// musl vs glibc; unenv's process.report stub throws "not implemented",
|
|
106
|
+
// killing the worker at module init. Stub it with static glibc answers —
|
|
107
|
+
// nothing that consults libc can run on workerd anyway.
|
|
108
|
+
"detect-libc": [
|
|
109
|
+
"export const GLIBC = 'glibc';",
|
|
110
|
+
"export const MUSL = 'musl';",
|
|
111
|
+
"export const family = async () => null;",
|
|
112
|
+
"export const familySync = () => null;",
|
|
113
|
+
"export const version = async () => null;",
|
|
114
|
+
"export const versionSync = () => null;",
|
|
115
|
+
"export const isNonGlibcLinux = async () => false;",
|
|
116
|
+
"export const isNonGlibcLinuxSync = () => false;",
|
|
117
|
+
"export default { GLIBC, MUSL, family, familySync, version, versionSync, isNonGlibcLinux, isNonGlibcLinuxSync };",
|
|
118
|
+
"",
|
|
119
|
+
].join("\n"),
|
|
104
120
|
"better-sqlite3":
|
|
105
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"),
|
|
106
132
|
"node-pty":
|
|
107
133
|
"export default {}; export const watch = () => ({ close() {} });\n",
|
|
108
134
|
chokidar: "export default {}; export const watch = () => ({ close() {} });\n",
|
|
@@ -258,13 +284,20 @@ function cloudflareNodeBuiltinStubSource(
|
|
|
258
284
|
const exports = Array.from(new Set(namedExports))
|
|
259
285
|
.filter((name) => !overridden.has(name))
|
|
260
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();
|
|
261
293
|
return [
|
|
262
294
|
`const unavailable = (name) => (..._args) => { throw new Error(name + " is unavailable in Cloudflare Pages workers"); };`,
|
|
263
|
-
`const proxy = new Proxy({}, { get(_target, prop) { return unavailable("${moduleName}." + String(prop)); } });`,
|
|
264
295
|
...overrides,
|
|
265
296
|
...exports.map(
|
|
266
297
|
(name) => `export const ${name} = unavailable("${moduleName}.${name}");`,
|
|
267
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)); } });`,
|
|
268
301
|
"export default proxy;",
|
|
269
302
|
"",
|
|
270
303
|
].join("\n");
|
|
@@ -1866,6 +1899,13 @@ async function buildCloudflarePages() {
|
|
|
1866
1899
|
"var $1 = function() { return typeof require !== 'undefined' ? require : function(m) { throw new Error('require not supported: ' + m); }; };",
|
|
1867
1900
|
);
|
|
1868
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
|
+
|
|
1869
1909
|
// Patch setInterval/setTimeout at module scope — CF Workers disallows timers in global scope.
|
|
1870
1910
|
// Some dependencies (e.g. Anthropic SDK rate limiter) call setInterval at module init.
|
|
1871
1911
|
// With code splitting, chunks evaluate before the entry, so the shim must be in every file.
|
|
@@ -224,6 +224,17 @@ function buildOneApp(
|
|
|
224
224
|
const env: NodeJS.ProcessEnv = {
|
|
225
225
|
...process.env,
|
|
226
226
|
NITRO_PRESET: preset,
|
|
227
|
+
// Windows: rolldown's rayon thread pool has a native race that
|
|
228
|
+
// intermittently (and for some apps deterministically) kills the build
|
|
229
|
+
// with an access violation (0xC0000005). Capping the pool avoids the
|
|
230
|
+
// race entirely; verified: chat's cloudflare_pages build crashed 100%
|
|
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.
|
|
235
|
+
...(process.platform === "win32"
|
|
236
|
+
? { RAYON_NUM_THREADS: process.env.RAYON_NUM_THREADS ?? "1" }
|
|
237
|
+
: {}),
|
|
227
238
|
AGENT_NATIVE_WORKSPACE: "1",
|
|
228
239
|
AGENT_NATIVE_WORKSPACE_APP_ID: app,
|
|
229
240
|
VITE_AGENT_NATIVE_WORKSPACE: "1",
|
|
@@ -415,9 +426,23 @@ function writeCloudflareRoutingManifest(distDir: string, apps: string[]): void {
|
|
|
415
426
|
include.push("/apps/*");
|
|
416
427
|
if (dispatchFaviconAsset) include.push("/favicon.ico");
|
|
417
428
|
}
|
|
429
|
+
// Cloudflare rejects a _routes.json where a splat rule overlaps any other
|
|
430
|
+
// rule (e.g. "/apps/*" + "/apps/new-app"). Drop every rule already covered
|
|
431
|
+
// by another rule's splat, and exact duplicates.
|
|
432
|
+
const splatPrefixes = include
|
|
433
|
+
.filter((r) => r.endsWith("/*"))
|
|
434
|
+
.map((r) => r.slice(0, -1));
|
|
435
|
+
const dedupedInclude = [
|
|
436
|
+
...new Set(
|
|
437
|
+
include.filter(
|
|
438
|
+
(r) =>
|
|
439
|
+
!splatPrefixes.some((p) => r !== `${p}*` && r.startsWith(p)),
|
|
440
|
+
),
|
|
441
|
+
),
|
|
442
|
+
];
|
|
418
443
|
const routes = {
|
|
419
444
|
version: 1,
|
|
420
|
-
include,
|
|
445
|
+
include: dedupedInclude,
|
|
421
446
|
exclude: [],
|
|
422
447
|
};
|
|
423
448
|
fs.writeFileSync(
|
|
@@ -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,
|
|
1
|
+
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xC,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,eAAe,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;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"}
|
package/dist/deploy/build.js
CHANGED
|
@@ -65,7 +65,33 @@ export const CLOUDFLARE_WORKER_ESBUILD_EXTERNALS = [
|
|
|
65
65
|
"fsevents",
|
|
66
66
|
];
|
|
67
67
|
export const CLOUDFLARE_WORKER_STUB_MODULES = {
|
|
68
|
+
// detect-libc calls process.report.getReport() at require time to sniff
|
|
69
|
+
// musl vs glibc; unenv's process.report stub throws "not implemented",
|
|
70
|
+
// killing the worker at module init. Stub it with static glibc answers —
|
|
71
|
+
// nothing that consults libc can run on workerd anyway.
|
|
72
|
+
"detect-libc": [
|
|
73
|
+
"export const GLIBC = 'glibc';",
|
|
74
|
+
"export const MUSL = 'musl';",
|
|
75
|
+
"export const family = async () => null;",
|
|
76
|
+
"export const familySync = () => null;",
|
|
77
|
+
"export const version = async () => null;",
|
|
78
|
+
"export const versionSync = () => null;",
|
|
79
|
+
"export const isNonGlibcLinux = async () => false;",
|
|
80
|
+
"export const isNonGlibcLinuxSync = () => false;",
|
|
81
|
+
"export default { GLIBC, MUSL, family, familySync, version, versionSync, isNonGlibcLinux, isNonGlibcLinuxSync };",
|
|
82
|
+
"",
|
|
83
|
+
].join("\n"),
|
|
68
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"),
|
|
69
95
|
"node-pty": "export default {}; export const watch = () => ({ close() {} });\n",
|
|
70
96
|
chokidar: "export default {}; export const watch = () => ({ close() {} });\n",
|
|
71
97
|
fsevents: "export default {}; export const watch = () => ({ close() {} });\n",
|
|
@@ -199,11 +225,18 @@ function cloudflareNodeBuiltinStubSource(moduleName, namedExports, overrides = [
|
|
|
199
225
|
const exports = Array.from(new Set(namedExports))
|
|
200
226
|
.filter((name) => !overridden.has(name))
|
|
201
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();
|
|
202
234
|
return [
|
|
203
235
|
`const unavailable = (name) => (..._args) => { throw new Error(name + " is unavailable in Cloudflare Pages workers"); };`,
|
|
204
|
-
`const proxy = new Proxy({}, { get(_target, prop) { return unavailable("${moduleName}." + String(prop)); } });`,
|
|
205
236
|
...overrides,
|
|
206
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)); } });`,
|
|
207
240
|
"export default proxy;",
|
|
208
241
|
"",
|
|
209
242
|
].join("\n");
|
|
@@ -1526,6 +1559,12 @@ async function buildCloudflarePages() {
|
|
|
1526
1559
|
// Matches both `from "module"` and `from "node:module"` — with the node:
|
|
1527
1560
|
// prefix preserved (for nodejs_compat_v2), the latter is what esbuild now emits.
|
|
1528
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"');
|
|
1529
1568
|
// Patch setInterval/setTimeout at module scope — CF Workers disallows timers in global scope.
|
|
1530
1569
|
// Some dependencies (e.g. Anthropic SDK rate limiter) call setInterval at module init.
|
|
1531
1570
|
// With code splitting, chunks evaluate before the entry, so the shim must be in every file.
|