@agimon-ai/po 0.0.0-alpha.128 → 0.0.0-alpha.129

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.
@@ -2,7 +2,7 @@
2
2
  "version": 1,
3
3
  "packages": {
4
4
  "@agimon-ai/po": {
5
- "version": "0.0.0-alpha.128",
5
+ "version": "0.0.0-alpha.129",
6
6
  "dependencies": [
7
7
  "@agimon-ai/po-approval",
8
8
  "@agimon-ai/po-artifact",
@@ -28,14 +28,14 @@
28
28
  ]
29
29
  },
30
30
  "@agimon-ai/po-approval": {
31
- "version": "0.0.0-alpha.127",
31
+ "version": "0.0.0-alpha.128",
32
32
  "dependencies": [
33
33
  "@agimon-ai/po-core",
34
34
  "@agimon-ai/po-web-components"
35
35
  ]
36
36
  },
37
37
  "@agimon-ai/po-artifact": {
38
- "version": "0.0.0-alpha.126",
38
+ "version": "0.0.0-alpha.127",
39
39
  "dependencies": [
40
40
  "@agimon-ai/po-core",
41
41
  "@agimon-ai/po-web-components",
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  },
45
45
  "@agimon-ai/po-author": {
46
- "version": "0.0.0-alpha.127",
46
+ "version": "0.0.0-alpha.128",
47
47
  "dependencies": [
48
48
  "@agimon-ai/po-artifact",
49
49
  "@agimon-ai/po-core",
@@ -53,7 +53,7 @@
53
53
  ]
54
54
  },
55
55
  "@agimon-ai/po-autocompact": {
56
- "version": "0.0.0-alpha.127",
56
+ "version": "0.0.0-alpha.128",
57
57
  "dependencies": [
58
58
  "@agimon-ai/po-artifact",
59
59
  "@agimon-ai/po-config",
@@ -62,13 +62,13 @@
62
62
  ]
63
63
  },
64
64
  "@agimon-ai/po-autostop": {
65
- "version": "0.0.0-alpha.127",
65
+ "version": "0.0.0-alpha.128",
66
66
  "dependencies": [
67
67
  "@agimon-ai/po-core"
68
68
  ]
69
69
  },
70
70
  "@agimon-ai/po-browse": {
71
- "version": "0.0.1-alpha.125",
71
+ "version": "0.0.1-alpha.126",
72
72
  "dependencies": [
73
73
  "@agimon-ai/po-config",
74
74
  "@agimon-ai/po-core",
@@ -76,11 +76,11 @@
76
76
  ]
77
77
  },
78
78
  "@agimon-ai/po-build": {
79
- "version": "0.0.0-alpha.127",
79
+ "version": "0.0.0-alpha.128",
80
80
  "dependencies": []
81
81
  },
82
82
  "@agimon-ai/po-cache": {
83
- "version": "0.0.0-alpha.127",
83
+ "version": "0.0.0-alpha.128",
84
84
  "dependencies": [
85
85
  "@agimon-ai/po-config",
86
86
  "@agimon-ai/po-core",
@@ -88,7 +88,7 @@
88
88
  ]
89
89
  },
90
90
  "@agimon-ai/po-calendar": {
91
- "version": "0.0.1-alpha.86",
91
+ "version": "0.0.1-alpha.87",
92
92
  "dependencies": [
93
93
  "@agimon-ai/po-config",
94
94
  "@agimon-ai/po-core",
@@ -100,11 +100,11 @@
100
100
  ]
101
101
  },
102
102
  "@agimon-ai/po-claude-bridge": {
103
- "version": "0.1.1-alpha.107",
103
+ "version": "0.1.1-alpha.108",
104
104
  "dependencies": []
105
105
  },
106
106
  "@agimon-ai/po-codemode": {
107
- "version": "0.0.1-alpha.100",
107
+ "version": "0.0.1-alpha.101",
108
108
  "dependencies": [
109
109
  "@agimon-ai/po-config",
110
110
  "@agimon-ai/po-core",
@@ -112,7 +112,7 @@
112
112
  ]
113
113
  },
114
114
  "@agimon-ai/po-computer-use": {
115
- "version": "0.0.0-alpha.127",
115
+ "version": "0.0.0-alpha.128",
116
116
  "dependencies": [
117
117
  "@agimon-ai/po-config",
118
118
  "@agimon-ai/po-core",
@@ -122,26 +122,26 @@
122
122
  ]
123
123
  },
124
124
  "@agimon-ai/po-config": {
125
- "version": "0.0.0-alpha.127",
125
+ "version": "0.0.0-alpha.128",
126
126
  "dependencies": [
127
127
  "@agimon-ai/po-core",
128
128
  "@agimon-ai/po-web-components"
129
129
  ]
130
130
  },
131
131
  "@agimon-ai/po-core": {
132
- "version": "0.0.0-alpha.127",
132
+ "version": "0.0.0-alpha.128",
133
133
  "dependencies": [
134
134
  "@agimon-ai/po-web-security"
135
135
  ]
136
136
  },
137
137
  "@agimon-ai/po-db": {
138
- "version": "0.0.0-alpha.127",
138
+ "version": "0.0.0-alpha.128",
139
139
  "dependencies": [
140
140
  "@agimon-ai/po-core"
141
141
  ]
142
142
  },
143
143
  "@agimon-ai/po-domain": {
144
- "version": "0.0.0-alpha.127",
144
+ "version": "0.0.0-alpha.128",
145
145
  "dependencies": [
146
146
  "@agimon-ai/po-config",
147
147
  "@agimon-ai/po-core",
@@ -151,7 +151,7 @@
151
151
  ]
152
152
  },
153
153
  "@agimon-ai/po-edit": {
154
- "version": "0.0.0-alpha.127",
154
+ "version": "0.0.0-alpha.128",
155
155
  "dependencies": [
156
156
  "@agimon-ai/po-core",
157
157
  "@agimon-ai/po-hashline",
@@ -160,7 +160,7 @@
160
160
  ]
161
161
  },
162
162
  "@agimon-ai/po-file-edit": {
163
- "version": "0.0.0-alpha.127",
163
+ "version": "0.0.0-alpha.128",
164
164
  "dependencies": [
165
165
  "@agimon-ai/po-config",
166
166
  "@agimon-ai/po-core",
@@ -170,13 +170,13 @@
170
170
  ]
171
171
  },
172
172
  "@agimon-ai/po-gateway": {
173
- "version": "0.0.1-alpha.6",
173
+ "version": "0.0.1-alpha.7",
174
174
  "dependencies": [
175
175
  "@agimon-ai/po-core"
176
176
  ]
177
177
  },
178
178
  "@agimon-ai/po-git": {
179
- "version": "0.0.0-alpha.127",
179
+ "version": "0.0.0-alpha.128",
180
180
  "dependencies": [
181
181
  "@agimon-ai/po-core",
182
182
  "@agimon-ai/po-session",
@@ -185,7 +185,7 @@
185
185
  ]
186
186
  },
187
187
  "@agimon-ai/po-goal": {
188
- "version": "0.0.0-alpha.127",
188
+ "version": "0.0.0-alpha.128",
189
189
  "dependencies": [
190
190
  "@agimon-ai/po-core",
191
191
  "@agimon-ai/po-minor-mode",
@@ -194,7 +194,7 @@
194
194
  ]
195
195
  },
196
196
  "@agimon-ai/po-grep": {
197
- "version": "0.0.0-alpha.127",
197
+ "version": "0.0.0-alpha.128",
198
198
  "dependencies": [
199
199
  "@agimon-ai/po-core",
200
200
  "@agimon-ai/po-hashline",
@@ -203,11 +203,11 @@
203
203
  ]
204
204
  },
205
205
  "@agimon-ai/po-hashline": {
206
- "version": "0.0.0-alpha.127",
206
+ "version": "0.0.0-alpha.128",
207
207
  "dependencies": []
208
208
  },
209
209
  "@agimon-ai/po-help": {
210
- "version": "0.0.0-alpha.127",
210
+ "version": "0.0.0-alpha.128",
211
211
  "dependencies": [
212
212
  "@agimon-ai/po-core",
213
213
  "@agimon-ai/po-minor-mode",
@@ -216,14 +216,14 @@
216
216
  ]
217
217
  },
218
218
  "@agimon-ai/po-identity": {
219
- "version": "0.0.2-alpha.74",
219
+ "version": "0.0.2-alpha.75",
220
220
  "dependencies": [
221
221
  "@agimon-ai/po-core",
222
222
  "@agimon-ai/po-web-security"
223
223
  ]
224
224
  },
225
225
  "@agimon-ai/po-image-gen": {
226
- "version": "0.0.0-alpha.126",
226
+ "version": "0.0.0-alpha.127",
227
227
  "dependencies": [
228
228
  "@agimon-ai/po-core",
229
229
  "@agimon-ai/po-web-components",
@@ -231,7 +231,7 @@
231
231
  ]
232
232
  },
233
233
  "@agimon-ai/po-ios": {
234
- "version": "0.0.1-alpha.62",
234
+ "version": "0.0.1-alpha.63",
235
235
  "dependencies": [
236
236
  "@agimon-ai/po-artifact",
237
237
  "@agimon-ai/po-config",
@@ -241,7 +241,7 @@
241
241
  ]
242
242
  },
243
243
  "@agimon-ai/po-log": {
244
- "version": "0.0.0-alpha.127",
244
+ "version": "0.0.0-alpha.128",
245
245
  "dependencies": [
246
246
  "@agimon-ai/po-core",
247
247
  "@agimon-ai/po-web-components",
@@ -249,7 +249,7 @@
249
249
  ]
250
250
  },
251
251
  "@agimon-ai/po-major-mode": {
252
- "version": "0.0.0-alpha.127",
252
+ "version": "0.0.0-alpha.128",
253
253
  "dependencies": [
254
254
  "@agimon-ai/po-config",
255
255
  "@agimon-ai/po-core",
@@ -257,7 +257,7 @@
257
257
  ]
258
258
  },
259
259
  "@agimon-ai/po-mcp": {
260
- "version": "0.0.0-alpha.127",
260
+ "version": "0.0.0-alpha.128",
261
261
  "dependencies": [
262
262
  "@agimon-ai/po-config",
263
263
  "@agimon-ai/po-core",
@@ -268,44 +268,44 @@
268
268
  ]
269
269
  },
270
270
  "@agimon-ai/po-mcp-proxy": {
271
- "version": "0.0.1-alpha.106",
271
+ "version": "0.0.1-alpha.107",
272
272
  "dependencies": []
273
273
  },
274
274
  "@agimon-ai/po-minor-mode": {
275
- "version": "0.0.0-alpha.127",
275
+ "version": "0.0.0-alpha.128",
276
276
  "dependencies": [
277
277
  "@agimon-ai/po-core"
278
278
  ]
279
279
  },
280
280
  "@agimon-ai/po-model-guidance": {
281
- "version": "0.0.0-alpha.127",
281
+ "version": "0.0.0-alpha.128",
282
282
  "dependencies": [
283
283
  "@agimon-ai/po-config",
284
284
  "@agimon-ai/po-core"
285
285
  ]
286
286
  },
287
287
  "@agimon-ai/po-native-components": {
288
- "version": "0.0.0-alpha.127",
288
+ "version": "0.0.0-alpha.128",
289
289
  "dependencies": [
290
290
  "@agimon-ai/po-web-components"
291
291
  ]
292
292
  },
293
293
  "@agimon-ai/po-network": {
294
- "version": "0.0.2-alpha.74",
294
+ "version": "0.0.2-alpha.75",
295
295
  "dependencies": [
296
296
  "@agimon-ai/po-core",
297
297
  "@agimon-ai/po-web-security"
298
298
  ]
299
299
  },
300
300
  "@agimon-ai/po-notification": {
301
- "version": "0.0.0-alpha.127",
301
+ "version": "0.0.0-alpha.128",
302
302
  "dependencies": [
303
303
  "@agimon-ai/po-autostop",
304
304
  "@agimon-ai/po-core"
305
305
  ]
306
306
  },
307
307
  "@agimon-ai/po-plan": {
308
- "version": "0.0.0-alpha.127",
308
+ "version": "0.0.0-alpha.128",
309
309
  "dependencies": [
310
310
  "@agimon-ai/po-config",
311
311
  "@agimon-ai/po-core",
@@ -315,7 +315,7 @@
315
315
  ]
316
316
  },
317
317
  "@agimon-ai/po-profile": {
318
- "version": "0.0.0-alpha.127",
318
+ "version": "0.0.0-alpha.128",
319
319
  "dependencies": [
320
320
  "@agimon-ai/po-config",
321
321
  "@agimon-ai/po-core",
@@ -323,7 +323,7 @@
323
323
  ]
324
324
  },
325
325
  "@agimon-ai/po-prompt": {
326
- "version": "0.0.0-alpha.127",
326
+ "version": "0.0.0-alpha.128",
327
327
  "dependencies": [
328
328
  "@agimon-ai/po-core",
329
329
  "@agimon-ai/po-web-components",
@@ -331,7 +331,7 @@
331
331
  ]
332
332
  },
333
333
  "@agimon-ai/po-read": {
334
- "version": "0.0.0-alpha.127",
334
+ "version": "0.0.0-alpha.128",
335
335
  "dependencies": [
336
336
  "@agimon-ai/po-config",
337
337
  "@agimon-ai/po-core",
@@ -341,7 +341,7 @@
341
341
  ]
342
342
  },
343
343
  "@agimon-ai/po-runner": {
344
- "version": "0.0.0-alpha.127",
344
+ "version": "0.0.0-alpha.128",
345
345
  "dependencies": [
346
346
  "@agimon-ai/po-core",
347
347
  "@agimon-ai/po-ui",
@@ -350,13 +350,13 @@
350
350
  ]
351
351
  },
352
352
  "@agimon-ai/po-sandbox": {
353
- "version": "0.0.0-alpha.127",
353
+ "version": "0.0.0-alpha.128",
354
354
  "dependencies": [
355
355
  "@agimon-ai/po-core"
356
356
  ]
357
357
  },
358
358
  "@agimon-ai/po-session": {
359
- "version": "0.0.0-alpha.127",
359
+ "version": "0.0.0-alpha.128",
360
360
  "dependencies": [
361
361
  "@agimon-ai/po-config",
362
362
  "@agimon-ai/po-core",
@@ -364,7 +364,7 @@
364
364
  ]
365
365
  },
366
366
  "@agimon-ai/po-skill": {
367
- "version": "0.0.0-alpha.127",
367
+ "version": "0.0.0-alpha.128",
368
368
  "dependencies": [
369
369
  "@agimon-ai/po-config",
370
370
  "@agimon-ai/po-core",
@@ -373,7 +373,7 @@
373
373
  ]
374
374
  },
375
375
  "@agimon-ai/po-style-system": {
376
- "version": "0.0.0-alpha.127",
376
+ "version": "0.0.0-alpha.128",
377
377
  "dependencies": [
378
378
  "@agimon-ai/po-core",
379
379
  "@agimon-ai/po-web-components",
@@ -381,7 +381,7 @@
381
381
  ]
382
382
  },
383
383
  "@agimon-ai/po-task": {
384
- "version": "0.0.0-alpha.127",
384
+ "version": "0.0.0-alpha.128",
385
385
  "dependencies": [
386
386
  "@agimon-ai/po-core",
387
387
  "@agimon-ai/po-ui",
@@ -389,7 +389,7 @@
389
389
  ]
390
390
  },
391
391
  "@agimon-ai/po-team": {
392
- "version": "0.0.0-alpha.127",
392
+ "version": "0.0.0-alpha.128",
393
393
  "dependencies": [
394
394
  "@agimon-ai/po-cache",
395
395
  "@agimon-ai/po-config",
@@ -401,7 +401,7 @@
401
401
  ]
402
402
  },
403
403
  "@agimon-ai/po-template-advanced": {
404
- "version": "0.0.0-alpha.127",
404
+ "version": "0.0.0-alpha.128",
405
405
  "dependencies": [
406
406
  "@agimon-ai/po-core",
407
407
  "@agimon-ai/po-web-components",
@@ -409,7 +409,7 @@
409
409
  ]
410
410
  },
411
411
  "@agimon-ai/po-template-elegant": {
412
- "version": "0.0.0-alpha.127",
412
+ "version": "0.0.0-alpha.128",
413
413
  "dependencies": [
414
414
  "@agimon-ai/po-core",
415
415
  "@agimon-ai/po-web-components",
@@ -417,7 +417,7 @@
417
417
  ]
418
418
  },
419
419
  "@agimon-ai/po-ui": {
420
- "version": "0.0.0-alpha.127",
420
+ "version": "0.0.0-alpha.128",
421
421
  "dependencies": [
422
422
  "@agimon-ai/po-core",
423
423
  "@agimon-ai/po-hashline",
@@ -426,7 +426,7 @@
426
426
  ]
427
427
  },
428
428
  "@agimon-ai/po-user-feedback": {
429
- "version": "0.0.0-alpha.127",
429
+ "version": "0.0.0-alpha.128",
430
430
  "dependencies": [
431
431
  "@agimon-ai/po-core",
432
432
  "@agimon-ai/po-minor-mode",
@@ -435,7 +435,7 @@
435
435
  ]
436
436
  },
437
437
  "@agimon-ai/po-vault": {
438
- "version": "0.0.0-alpha.127",
438
+ "version": "0.0.0-alpha.128",
439
439
  "dependencies": [
440
440
  "@agimon-ai/po-core",
441
441
  "@agimon-ai/po-db",
@@ -444,7 +444,7 @@
444
444
  ]
445
445
  },
446
446
  "@agimon-ai/po-vibe-lint": {
447
- "version": "0.0.1-alpha.96",
447
+ "version": "0.0.1-alpha.97",
448
448
  "dependencies": [
449
449
  "@agimon-ai/po-config",
450
450
  "@agimon-ai/po-core",
@@ -454,7 +454,7 @@
454
454
  ]
455
455
  },
456
456
  "@agimon-ai/po-voice": {
457
- "version": "0.0.0-alpha.127",
457
+ "version": "0.0.0-alpha.128",
458
458
  "dependencies": [
459
459
  "@agimon-ai/po-config",
460
460
  "@agimon-ai/po-core",
@@ -467,11 +467,11 @@
467
467
  ]
468
468
  },
469
469
  "@agimon-ai/po-web-components": {
470
- "version": "0.0.0-alpha.127",
470
+ "version": "0.0.0-alpha.128",
471
471
  "dependencies": []
472
472
  },
473
473
  "@agimon-ai/po-web-dashboard": {
474
- "version": "0.0.0-alpha.127",
474
+ "version": "0.0.0-alpha.128",
475
475
  "dependencies": [
476
476
  "@agimon-ai/po-core",
477
477
  "@agimon-ai/po-web-components",
@@ -479,18 +479,18 @@
479
479
  ]
480
480
  },
481
481
  "@agimon-ai/po-web-search": {
482
- "version": "0.0.0-alpha.126",
482
+ "version": "0.0.0-alpha.127",
483
483
  "dependencies": [
484
484
  "@agimon-ai/po-core",
485
485
  "@agimon-ai/po-web-components"
486
486
  ]
487
487
  },
488
488
  "@agimon-ai/po-web-security": {
489
- "version": "0.0.0-alpha.127",
489
+ "version": "0.0.0-alpha.128",
490
490
  "dependencies": []
491
491
  },
492
492
  "@agimon-ai/po-workflow": {
493
- "version": "0.0.0-alpha.127",
493
+ "version": "0.0.0-alpha.128",
494
494
  "dependencies": [
495
495
  "@agimon-ai/po-core",
496
496
  "@agimon-ai/po-ui",
package/dist/package.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.0-alpha.128";
2
+ var version = "0.0.0-alpha.129";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
package/dist/package.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.0-alpha.128";
2
+ var version = "0.0.0-alpha.129";
3
3
  //#endregion
4
4
  export { version };
5
5
 
@@ -1,4 +1,5 @@
1
1
  const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ const require_packageUrl = require("../server/packageUrl.cjs");
2
3
  const require_webPluginScan = require("../web/webPluginScan.cjs");
3
4
  const require_index = require("../web/index.cjs");
4
5
  let node_module = require("node:module");
@@ -6,6 +7,8 @@ let node_path = require("node:path");
6
7
  node_path = require_runtime.__toESM(node_path, 1);
7
8
  let node_fs_promises = require("node:fs/promises");
8
9
  node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
10
+ let _agimon_ai_po_core_nodePlatform = require("@agimon-ai/po-core/nodePlatform");
11
+ let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
9
12
  let node_crypto = require("node:crypto");
10
13
  node_crypto = require_runtime.__toESM(node_crypto, 1);
11
14
  let _agimon_ai_po_core_native = require("@agimon-ai/po-core/native");
@@ -15,15 +18,32 @@ let _agimon_ai_po_web_security = require("@agimon-ai/po-web-security");
15
18
  * The global native build: each package's `poNative` client bundled into its own CommonJS module
16
19
  * the po-native shell verifies and evaluates against its own host modules, one plugin at a time.
17
20
  *
18
- * It shares the web build's key, temporary directory, rename and `build.json` handling, and
21
+ * It shares the web build's temporary directory, rename and `build.json` handling, and
19
22
  * runs rolldown in process: the input is already built per package, so each bundle only joins
20
23
  * that package's files and checks that every bare import is one the shell provides.
21
24
  */
22
25
  /** Bumped when build output or package-copy admission changes, so an old record is never reused. */
23
- const GLOBAL_NATIVE_BUILD_FORMAT = "global-native-5";
26
+ const GLOBAL_NATIVE_BUILD_FORMAT = "global-native-6";
24
27
  const PLUGINS_DIRECTORY = "plugins";
25
28
  const UI_MODULE = "@agimon-ai/po-native-components";
26
29
  const HOST_MODULES = new Set(_agimon_ai_po_core_native.NATIVE_HOST_MODULE_IDS);
30
+ /** Native keys use package-relative paths and bytes, never installation paths or mtimes. */
31
+ async function nativeBuildKey(plugins, files = (0, _agimon_ai_po_core_nodePlatform.createNodePlatform)().env(process.cwd())) {
32
+ const hash = node_crypto.default.createHash("sha256").update(GLOBAL_NATIVE_BUILD_FORMAT).update(JSON.stringify(_agimon_ai_po_core_native.NATIVE_HOST_MODULE_IDS));
33
+ for (const plugin of plugins) {
34
+ hash.update(JSON.stringify([
35
+ plugin.pluginId,
36
+ plugin.packageName,
37
+ plugin.client.entry,
38
+ plugin.isHost
39
+ ])).update("\0");
40
+ for (const file of await require_packageUrl.snapshotFiles(plugin.packageDir, node_path.default.join(plugin.packageDir, plugin.client.entry), files)) {
41
+ hash.update(file).update("\0");
42
+ hash.update((0, _agimon_ai_po_core_platform.getOrThrow)(await files.readBinaryFile(node_path.default.join(plugin.packageDir, file), _agimon_ai_po_core_platform.BACKGROUND_CONTEXT))).update("\0");
43
+ }
44
+ }
45
+ return hash.digest("hex").slice(0, 32);
46
+ }
27
47
  /** The build key for these plugin roots and where its build lives, without building anything. */
28
48
  async function resolveGlobalNativeBuild(input) {
29
49
  const pluginRoots = [...new Set(input.pluginRoots.map((root) => node_path.default.resolve(root)))].sort();
@@ -49,7 +69,7 @@ async function resolveGlobalNativeBuild(input) {
49
69
  scopes: []
50
70
  };
51
71
  });
52
- key = await require_index.globalBuildKey(`${GLOBAL_NATIVE_BUILD_FORMAT}:${JSON.stringify(_agimon_ai_po_core_native.NATIVE_HOST_MODULE_IDS)}`, void 0, [...plugins, ...uiPackages], input.files);
72
+ key = await nativeBuildKey([...plugins, ...uiPackages], input.files);
53
73
  } catch (error) {
54
74
  return {
55
75
  status: "failed",
@@ -252,10 +272,28 @@ async function ensureGlobalNativeBuild(input) {
252
272
  if (resolved.status !== "resolved") return resolved;
253
273
  const { plugins, key, buildsRoot, directory, uiEntry } = resolved;
254
274
  const existing = await readBuildRecord(directory, input.files);
255
- if (existing !== void 0) return {
256
- status: "cached",
257
- build: existing
258
- };
275
+ if (existing !== void 0) {
276
+ const currentPlugins = plugins.map(({ pluginId, packageDir, isHost }) => ({
277
+ pluginId,
278
+ packageDir,
279
+ isHost
280
+ }));
281
+ if (JSON.stringify(existing.plugins) !== JSON.stringify(currentPlugins)) {
282
+ existing.plugins = currentPlugins;
283
+ const { pluginsDirectory: _pluginsDirectory, ...record } = existing;
284
+ const temporary = node_path.default.join(directory, `.${require_index.BUILD_RECORD}.${node_crypto.default.randomUUID()}`);
285
+ try {
286
+ await node_fs_promises.default.writeFile(temporary, JSON.stringify(record));
287
+ await node_fs_promises.default.rename(temporary, node_path.default.join(directory, require_index.BUILD_RECORD));
288
+ } finally {
289
+ await node_fs_promises.default.rm(temporary, { force: true });
290
+ }
291
+ }
292
+ return {
293
+ status: "cached",
294
+ build: existing
295
+ };
296
+ }
259
297
  return require_index.singleFlightBuild(key, async () => {
260
298
  try {
261
299
  await require_index.buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["NATIVE_HOST_MODULE_IDS","path","scanWebPlugins","createRequire","globalBuildKey","readBuildJson","crypto","fs","NATIVE_COMPOSITION_MAX_BYTES","singleFlightBuild","buildKeyDirectory","mountWebPluginIds"],"sources":["../../../../src/builders/native/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { NATIVE_HOST_MODULE_IDS } from '@agimon-ai/po-core/native';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { GlobalNativeBuild } from '@agimon-ai/po-core/webCompositions';\nimport { NATIVE_COMPOSITION_MAX_BYTES } from '@agimon-ai/po-web-security';\nimport type { PluginContext } from 'rolldown';\n\nimport { buildKeyDirectory, globalBuildKey, mountWebPluginIds, readBuildJson, singleFlightBuild } from '../web';\nimport type { DeclaredWebPlugin } from '../web/webPluginManifest';\nimport { scanWebPlugins } from '../web/webPluginScan';\n\n/**\n * The global native build: each package's `poNative` client bundled into its own CommonJS module\n * the po-native shell verifies and evaluates against its own host modules, one plugin at a time.\n *\n * It shares the web build's key, temporary directory, rename and `build.json` handling, and\n * runs rolldown in process: the input is already built per package, so each bundle only joins\n * that package's files and checks that every bare import is one the shell provides.\n */\n\n/** Bumped when build output or package-copy admission changes, so an old record is never reused. */\nconst GLOBAL_NATIVE_BUILD_FORMAT = 'global-native-5';\nconst PLUGINS_DIRECTORY = 'plugins';\nconst UI_MODULE = '@agimon-ai/po-native-components';\nconst HOST_MODULES: ReadonlySet<string> = new Set(NATIVE_HOST_MODULE_IDS);\n\n/** One build's record: the publishable build plus each plugin's package, for resolving a mount's plugins. */\nexport interface GlobalNativeBuildRecord extends GlobalNativeBuild {\n plugins: { pluginId: string; packageDir: string; isHost: boolean }[];\n}\n\nexport interface GlobalNativeBuildInput {\n /** Po's global home; builds land in `<home>/build/native/<key>/`. */\n poHome: string;\n files?: FileSystem;\n /** The union of every scope's package roots; roots without a poNative block are ignored. */\n pluginRoots: readonly string[];\n onNotice?: (message: string) => void;\n}\n\nexport type GlobalNativeBuildResult =\n | { status: 'built' | 'cached'; build: GlobalNativeBuildRecord }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\ntype ResolvedGlobalNativeBuild =\n | {\n status: 'resolved';\n plugins: DeclaredWebPlugin[];\n key: string;\n uiEntry: string;\n buildsRoot: string;\n directory: string;\n }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/** The build key for these plugin roots and where its build lives, without building anything. */\nasync function resolveGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<ResolvedGlobalNativeBuild> {\n const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();\n let plugins: DeclaredWebPlugin[];\n let key: string;\n try {\n plugins = await scanWebPlugins(undefined, pluginRoots, input.onNotice ?? ((): void => {}), 'poNative');\n if (plugins.length === 0)\n return { status: 'skipped', reason: 'no package declares a native plugin; no native composition is published' };\n const resolve = createRequire(import.meta.url).resolve;\n const uiPackages = [UI_MODULE, '@agimon-ai/po-web-components'].map((name) => {\n const packageDir = path.dirname(resolve(`${name}/package.json`));\n return {\n pluginId: name,\n slot: name,\n registrationOrder: 0,\n packageDir,\n packageName: name,\n isHost: false,\n client: { entry: path.relative(packageDir, resolve(name)) },\n scopes: [],\n } satisfies DeclaredWebPlugin;\n });\n key = await globalBuildKey(\n `${GLOBAL_NATIVE_BUILD_FORMAT}:${JSON.stringify(NATIVE_HOST_MODULE_IDS)}`,\n undefined,\n [...plugins, ...uiPackages],\n input.files,\n );\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n const buildsRoot = path.join(input.poHome, 'build', 'native');\n return {\n status: 'resolved',\n plugins,\n key,\n buildsRoot,\n directory: path.join(buildsRoot, key),\n uiEntry: createRequire(import.meta.url).resolve(UI_MODULE),\n };\n}\n\nasync function readBuildRecord(directory: string, files?: FileSystem): Promise<GlobalNativeBuildRecord | undefined> {\n const record = await readBuildJson<Omit<GlobalNativeBuildRecord, 'pluginsDirectory'>>(directory, files);\n if (record === undefined) return undefined;\n return { ...record, pluginsDirectory: path.join(directory, PLUGINS_DIRECTORY) };\n}\n\n/** The complete global native build of one key, or undefined when it is not there. Never builds. */\nexport async function readGlobalNativeBuildRecord(\n poHome: string,\n key: string,\n files?: FileSystem,\n): Promise<GlobalNativeBuildRecord | undefined> {\n return readBuildRecord(path.join(poHome, 'build', 'native', key), files);\n}\n\nconst isBareSpecifier = (source: string): boolean =>\n !source.startsWith('.') && !source.startsWith('\\0') && !path.isAbsolute(source);\n\n/** One plugin's module file name: a hash of its id, so any id is a safe top-level asset path. */\nconst pluginModuleFile = (pluginId: string): string =>\n `${crypto.createHash('sha256').update(pluginId).digest('hex').slice(0, 32)}.js`;\n\n/** Checks the tree-shaken ESM imports before the CommonJS body can run, including on older shells. */\nfunction nativeImportGuard(program: ReturnType<PluginContext['parse']>): string {\n const requirements = new Map<string, Set<string>>();\n const namespaces = new Map<string, string>();\n const requireExport = (module: string, name?: string) => {\n const names = requirements.get(module) ?? new Set<string>();\n if (name !== undefined) names.add(name);\n requirements.set(module, names);\n };\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n const module = statement.source.value;\n requireExport(module);\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportNamespaceSpecifier') namespaces.set(specifier.local.name, module);\n else\n requireExport(\n module,\n specifier.type === 'ImportDefaultSpecifier'\n ? 'default'\n : specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value,\n );\n }\n } else if (statement.type === 'ExportNamedDeclaration' && statement.source !== null) {\n for (const specifier of statement.specifiers)\n requireExport(\n statement.source.value,\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value,\n );\n } else if (statement.type === 'ExportAllDeclaration') {\n throw new Error('Native modules must name their external re-exports.');\n }\n }\n const visit = (value: unknown, parent?: Record<string, unknown>, key?: string): void => {\n if (Array.isArray(value)) {\n for (const item of value) visit(item, parent, key);\n return;\n }\n if (typeof value !== 'object' || value === null) return;\n const node = value as Record<string, unknown>;\n if (node.type === 'ImportExpression')\n throw new Error('Native external dynamic imports are unsupported; use named ESM imports.');\n if (\n node.type === 'CallExpression' &&\n /^(?:__)?require(?:\\$\\d+)?$/u.test(String((node.callee as { name?: string })?.name))\n ) {\n throw new Error('Native external CommonJS require is unsupported; use named ESM imports.');\n }\n if (node.type === 'Identifier' && namespaces.has(String(node.name))) {\n const module = namespaces.get(String(node.name))!;\n if (\n parent?.type === 'ImportNamespaceSpecifier' ||\n (key === 'property' && parent?.computed === false) ||\n (key === 'key' && parent?.computed === false)\n )\n return;\n if (parent?.type !== 'MemberExpression' || key !== 'object') {\n throw new Error(`Native namespace '${String(node.name)}' must use static member access.`);\n }\n const property = parent.property as { type: string; name?: string; value?: unknown };\n const name = parent.computed === false ? property.name : property.type === 'Literal' ? property.value : undefined;\n if (typeof name !== 'string')\n throw new Error(`Native namespace '${String(node.name)}' has dynamic member access.`);\n requireExport(module, name);\n }\n for (const [childKey, child] of Object.entries(node))\n if (childKey !== 'start' && childKey !== 'end') visit(child, node, childKey);\n };\n visit(program);\n const entries = [...requirements].map(([module, names]) => [module, [...names].sort()]);\n return `;(function(requirements) {\n function fail(id, name) {\n var error = new Error('Update Po: missing ' + id + (name === null ? '' : '.' + name));\n error.name = 'PoIncompatible';\n error.code = 'PO_INCOMPATIBLE';\n error.module = id;\n error.export = name;\n throw error;\n }\n for (var i = 0; i < requirements.length; i++) {\n var id = requirements[i][0], names = requirements[i][1], value;\n try { value = require(id); } catch (cause) { fail(id, null); }\n for (var j = 0; j < names.length; j++) {\n var name = names[j];\n if (value == null || (name === 'default' ? value.__esModule && value.default === undefined : value[name] === undefined)) fail(id, name);\n }\n }\n})(${JSON.stringify(entries)});\\n`;\n}\n\n/** Bundles a native module. Only the shared UI module may bundle ordinary JS dependencies. */\nasync function bundleNativeModule(entry: string, ui: boolean, onNotice: (message: string) => void): Promise<string> {\n // Loaded here so status and cache readers never start rolldown's native thread pool.\n const { rolldown } = await import('rolldown');\n let guard = '';\n const bundle = await rolldown({\n input: await fs.realpath(entry),\n cwd: path.dirname(entry),\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id) && !(ui && id === UI_MODULE),\n onLog: (level, log) => {\n if (level === 'warn') onNotice(log.message);\n },\n plugins: [\n {\n name: 'po-native-host-modules',\n resolveId(source, importer) {\n if (importer === undefined || !isBareSpecifier(source) || ui) return null;\n if (HOST_MODULES.has(source)) return { id: source, external: true };\n this.error(\n `'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${NATIVE_HOST_MODULE_IDS.join(', ')}.`,\n );\n },\n renderChunk(code, _chunk, options) {\n if (options.format === 'es') guard = nativeImportGuard(this.parse(code));\n return null;\n },\n },\n ],\n });\n try {\n const esm = await bundle.generate({ format: 'es', codeSplitting: false, exports: 'named' });\n const [entryChunk] = esm.output;\n if (esm.output.length !== 1 || entryChunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n // .mjs inputs force Node default-import semantics. Our require map instead supplies Metro modules.\n const commonjs = await rolldown({\n input: '\\0po-native-module.js',\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id),\n plugins: [\n {\n name: 'po-native-commonjs',\n resolveId: (id) => (id === '\\0po-native-module.js' ? id : null),\n load: (id) => (id === '\\0po-native-module.js' ? entryChunk.code : null),\n },\n ],\n });\n let code: string;\n try {\n const { output } = await commonjs.generate({ format: 'cjs', codeSplitting: false, exports: 'named' });\n const [chunk] = output;\n if (output.length !== 1 || chunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n code = chunk.code;\n } finally {\n await commonjs.close();\n }\n const source = guard + code;\n const bytes = Buffer.byteLength(source);\n if (bytes > NATIVE_COMPOSITION_MAX_BYTES)\n throw new Error(\n `The native plugin is ${String(bytes)} bytes, over the ${String(NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`,\n );\n return source;\n } finally {\n await bundle.close();\n }\n}\n\n/**\n * Bundles each plugin into `<outDir>/plugins/<hash>.js` and returns `pluginId -> module file`. A plugin\n * that fails to bundle is named in a notice and left out; the build fails only when none bundles.\n */\nasync function bundleNativePlugins(\n plugins: readonly DeclaredWebPlugin[],\n outDir: string,\n onNotice: (message: string) => void,\n): Promise<Record<string, string>> {\n const pluginsDirectory = path.join(outDir, PLUGINS_DIRECTORY);\n await fs.mkdir(pluginsDirectory, { recursive: true });\n const entries: Record<string, string> = {};\n const failures: string[] = [];\n const bundled = new Set<string>();\n for (const plugin of plugins) {\n if (bundled.has(plugin.pluginId)) continue;\n bundled.add(plugin.pluginId);\n try {\n const file = pluginModuleFile(plugin.pluginId);\n await fs.writeFile(\n path.join(pluginsDirectory, file),\n await bundleNativeModule(path.join(plugin.packageDir, plugin.client.entry), false, onNotice),\n );\n entries[plugin.pluginId] = file;\n } catch (error) {\n const message = `native plugin '${plugin.pluginId}' could not be built: ${error instanceof Error ? error.message : String(error)}`;\n failures.push(message);\n onNotice(message);\n }\n }\n if (Object.keys(entries).length === 0) throw new Error(failures.join('\\n'));\n return entries;\n}\n\n/** Whether the global native build for these plugin roots exists, for a check that must not build. */\nexport async function readGlobalNativeBuildStatus(\n input: GlobalNativeBuildInput,\n): Promise<\n | { status: 'current' | 'missing'; key: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string }\n> {\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n return {\n status: (await readBuildRecord(resolved.directory, input.files)) === undefined ? 'missing' : 'current',\n key: resolved.key,\n };\n}\n\n/**\n * Ensures the one global native build for the given plugin roots exists and returns it.\n *\n * The output is `<home>/build/native/<key>/plugins/<hash>.js`, one module per plugin, built in a\n * temporary directory and renamed into place; an existing key builds nothing.\n */\nexport async function ensureGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<GlobalNativeBuildResult> {\n const notice = input.onNotice ?? ((): void => {});\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n const { plugins, key, buildsRoot, directory, uiEntry } = resolved;\n const existing = await readBuildRecord(directory, input.files);\n if (existing !== undefined) return { status: 'cached', build: existing };\n return singleFlightBuild(key, async (): Promise<GlobalNativeBuildResult> => {\n try {\n await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {\n const pluginEntries = await bundleNativePlugins(plugins, temporary, notice);\n const uiFile = 'ui.js';\n const uiSource = await bundleNativeModule(uiEntry, true, notice);\n await fs.writeFile(path.join(temporary, PLUGINS_DIRECTORY, uiFile), uiSource);\n notice(`native UI module: ${String(Buffer.byteLength(uiSource))} bytes`);\n return {\n key,\n pluginEntries,\n uiEntry: uiFile,\n plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost })),\n };\n });\n const build = await readBuildRecord(directory, input.files);\n if (build === undefined) throw new Error(`The native build '${key}' was not recorded.`);\n return { status: 'built', build };\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n });\n}\n\n/** The `poNative.pluginId` values a mount runs: those of its own package roots. */\nexport const mountNativePluginIds: (build: GlobalNativeBuildRecord, packageRoots: readonly string[]) => string[] =\n mountWebPluginIds;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,6BAA6B;AACnC,MAAM,oBAAoB;AAC1B,MAAM,YAAY;AAClB,MAAM,eAAoC,IAAI,IAAIA,0BAAAA,sBAAsB;;AAkCxE,eAAe,yBAAyB,OAAmE;CACzG,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,MAAM,YAAY,KAAK,SAASC,UAAAA,QAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;CAC3F,IAAI;CACJ,IAAI;CACJ,IAAI;EACF,UAAU,MAAMC,sBAAAA,eAAe,KAAA,GAAW,aAAa,MAAM,mBAAyB,CAAC,IAAI,UAAU;EACrG,IAAI,QAAQ,WAAW,GACrB,OAAO;GAAE,QAAQ;GAAW,QAAQ;EAA0E;EAChH,MAAM,WAAA,GAAUC,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B,CAAC,CAAC;EAC/C,MAAM,aAAa,CAAC,WAAW,8BAA8B,CAAC,CAAC,KAAK,SAAS;GAC3E,MAAM,aAAaF,UAAAA,QAAK,QAAQ,QAAQ,GAAG,KAAK,cAAc,CAAC;GAC/D,OAAO;IACL,UAAU;IACV,MAAM;IACN,mBAAmB;IACnB;IACA,aAAa;IACb,QAAQ;IACR,QAAQ,EAAE,OAAOA,UAAAA,QAAK,SAAS,YAAY,QAAQ,IAAI,CAAC,EAAE;IAC1D,QAAQ,CAAC;GACX;EACF,CAAC;EACD,MAAM,MAAMG,cAAAA,eACV,GAAG,2BAA2B,GAAG,KAAK,UAAUJ,0BAAAA,sBAAsB,KACtE,K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K,YAAY,WAAW,YAAY;CACzD,MAAM,WAAW,MAAM,gBAAgB,WAAW,MAAM,KAAK;CAC7D,IAAI,aAAa,KAAA,GAAW,OAAO;EAAE,QAAQ;EAAU,OAAO;CAAS;CACvE,OAAOQ,cAAAA,kBAAkB,KAAK,YAA8C;EAC1E,IAAI;GACF,MAAMC,cAAAA,kBAAkB,YAAY,KAAK,WAAW,OAAO,cAAc;IACvE,MAAM,gBAAgB,MAAM,oBAAoB,SAAS,WAAW,MAAM;IAC1E,MAAM,SAAS;IACf,MAAM,WAAW,MAAM,mBAAmB,SAAS,MAAM,MAAM;IAC/D,MAAMH,iBAAAA,QAAG,UAAUN,UAAAA,QAAK,KAAK,WAAW,mBAAmB,MAAM,GAAG,QAAQ;IAC5E,OAAO,qBAAqB,OAAO,OAAO,WAAW,QAAQ,CAAC,EAAE,OAAO;IACvE,OAAO;KACL;KACA;KACA,SAAS;KACT,SAAS,QAAQ,KAAK,EAAE,UAAU,YAAY,cAAc;MAAE;MAAU;MAAY;KAAO,EAAE;IAC/F;GACF,CAAC;GACD,MAAM,QAAQ,MAAM,gBAAgB,WAAW,MAAM,KAAK;GAC1D,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,oBAAoB;GACtF,OAAO;IAAE,QAAQ;IAAS;GAAM;EAClC,SAAS,OAAO;GACd,OAAO;IAAE,QAAQ;IAAU,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAAE;EAC5F;CACF,CAAC;AACH;;AAGA,MAAa,uBACXU,cAAAA"}
1
+ {"version":3,"file":"index.cjs","names":["NATIVE_HOST_MODULE_IDS","createNodePlatform","crypto","snapshotFiles","path","getOrThrow","BACKGROUND_CONTEXT","scanWebPlugins","createRequire","readBuildJson","fs","NATIVE_COMPOSITION_MAX_BYTES","BUILD_RECORD","singleFlightBuild","buildKeyDirectory","mountWebPluginIds"],"sources":["../../../../src/builders/native/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { NATIVE_HOST_MODULE_IDS } from '@agimon-ai/po-core/native';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { BACKGROUND_CONTEXT, type FileSystem, getOrThrow } from '@agimon-ai/po-core/platform';\nimport type { GlobalNativeBuild } from '@agimon-ai/po-core/webCompositions';\nimport { NATIVE_COMPOSITION_MAX_BYTES } from '@agimon-ai/po-web-security';\nimport type { PluginContext } from 'rolldown';\n\nimport { snapshotFiles } from '../server/packageUrl';\nimport { BUILD_RECORD, buildKeyDirectory, mountWebPluginIds, readBuildJson, singleFlightBuild } from '../web';\nimport type { DeclaredWebPlugin } from '../web/webPluginManifest';\nimport { scanWebPlugins } from '../web/webPluginScan';\n\n/**\n * The global native build: each package's `poNative` client bundled into its own CommonJS module\n * the po-native shell verifies and evaluates against its own host modules, one plugin at a time.\n *\n * It shares the web build's temporary directory, rename and `build.json` handling, and\n * runs rolldown in process: the input is already built per package, so each bundle only joins\n * that package's files and checks that every bare import is one the shell provides.\n */\n\n/** Bumped when build output or package-copy admission changes, so an old record is never reused. */\nconst GLOBAL_NATIVE_BUILD_FORMAT = 'global-native-6';\nconst PLUGINS_DIRECTORY = 'plugins';\nconst UI_MODULE = '@agimon-ai/po-native-components';\nconst HOST_MODULES: ReadonlySet<string> = new Set(NATIVE_HOST_MODULE_IDS);\n\n/** One build's record: the publishable build plus each plugin's package, for resolving a mount's plugins. */\nexport interface GlobalNativeBuildRecord extends GlobalNativeBuild {\n plugins: { pluginId: string; packageDir: string; isHost: boolean }[];\n}\n\nexport interface GlobalNativeBuildInput {\n /** Po's global home; builds land in `<home>/build/native/<key>/`. */\n poHome: string;\n files?: FileSystem;\n /** The union of every scope's package roots; roots without a poNative block are ignored. */\n pluginRoots: readonly string[];\n onNotice?: (message: string) => void;\n}\n\nexport type GlobalNativeBuildResult =\n | { status: 'built' | 'cached'; build: GlobalNativeBuildRecord }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\ntype ResolvedGlobalNativeBuild =\n | {\n status: 'resolved';\n plugins: DeclaredWebPlugin[];\n key: string;\n uiEntry: string;\n buildsRoot: string;\n directory: string;\n }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/** Native keys use package-relative paths and bytes, never installation paths or mtimes. */\nasync function nativeBuildKey(\n plugins: readonly DeclaredWebPlugin[],\n files: FileSystem = createNodePlatform().env(process.cwd()),\n): Promise<string> {\n const hash = crypto\n .createHash('sha256')\n .update(GLOBAL_NATIVE_BUILD_FORMAT)\n .update(JSON.stringify(NATIVE_HOST_MODULE_IDS));\n // Keep build order: the first copy of a plugin id supplies its module.\n for (const plugin of plugins) {\n hash.update(JSON.stringify([plugin.pluginId, plugin.packageName, plugin.client.entry, plugin.isHost])).update('\\0');\n for (const file of await snapshotFiles(\n plugin.packageDir,\n path.join(plugin.packageDir, plugin.client.entry),\n files,\n )) {\n hash.update(file).update('\\0');\n hash\n .update(getOrThrow(await files.readBinaryFile(path.join(plugin.packageDir, file), BACKGROUND_CONTEXT)))\n .update('\\0');\n }\n }\n return hash.digest('hex').slice(0, 32);\n}\n\n/** The build key for these plugin roots and where its build lives, without building anything. */\nasync function resolveGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<ResolvedGlobalNativeBuild> {\n const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();\n let plugins: DeclaredWebPlugin[];\n let key: string;\n try {\n plugins = await scanWebPlugins(undefined, pluginRoots, input.onNotice ?? ((): void => {}), 'poNative');\n if (plugins.length === 0)\n return { status: 'skipped', reason: 'no package declares a native plugin; no native composition is published' };\n const resolve = createRequire(import.meta.url).resolve;\n const uiPackages = [UI_MODULE, '@agimon-ai/po-web-components'].map((name) => {\n const packageDir = path.dirname(resolve(`${name}/package.json`));\n return {\n pluginId: name,\n slot: name,\n registrationOrder: 0,\n packageDir,\n packageName: name,\n isHost: false,\n client: { entry: path.relative(packageDir, resolve(name)) },\n scopes: [],\n } satisfies DeclaredWebPlugin;\n });\n key = await nativeBuildKey([...plugins, ...uiPackages], input.files);\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n const buildsRoot = path.join(input.poHome, 'build', 'native');\n return {\n status: 'resolved',\n plugins,\n key,\n buildsRoot,\n directory: path.join(buildsRoot, key),\n uiEntry: createRequire(import.meta.url).resolve(UI_MODULE),\n };\n}\n\nasync function readBuildRecord(directory: string, files?: FileSystem): Promise<GlobalNativeBuildRecord | undefined> {\n const record = await readBuildJson<Omit<GlobalNativeBuildRecord, 'pluginsDirectory'>>(directory, files);\n if (record === undefined) return undefined;\n return { ...record, pluginsDirectory: path.join(directory, PLUGINS_DIRECTORY) };\n}\n\n/** The complete global native build of one key, or undefined when it is not there. Never builds. */\nexport async function readGlobalNativeBuildRecord(\n poHome: string,\n key: string,\n files?: FileSystem,\n): Promise<GlobalNativeBuildRecord | undefined> {\n return readBuildRecord(path.join(poHome, 'build', 'native', key), files);\n}\n\nconst isBareSpecifier = (source: string): boolean =>\n !source.startsWith('.') && !source.startsWith('\\0') && !path.isAbsolute(source);\n\n/** One plugin's module file name: a hash of its id, so any id is a safe top-level asset path. */\nconst pluginModuleFile = (pluginId: string): string =>\n `${crypto.createHash('sha256').update(pluginId).digest('hex').slice(0, 32)}.js`;\n\n/** Checks the tree-shaken ESM imports before the CommonJS body can run, including on older shells. */\nfunction nativeImportGuard(program: ReturnType<PluginContext['parse']>): string {\n const requirements = new Map<string, Set<string>>();\n const namespaces = new Map<string, string>();\n const requireExport = (module: string, name?: string) => {\n const names = requirements.get(module) ?? new Set<string>();\n if (name !== undefined) names.add(name);\n requirements.set(module, names);\n };\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n const module = statement.source.value;\n requireExport(module);\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportNamespaceSpecifier') namespaces.set(specifier.local.name, module);\n else\n requireExport(\n module,\n specifier.type === 'ImportDefaultSpecifier'\n ? 'default'\n : specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value,\n );\n }\n } else if (statement.type === 'ExportNamedDeclaration' && statement.source !== null) {\n for (const specifier of statement.specifiers)\n requireExport(\n statement.source.value,\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value,\n );\n } else if (statement.type === 'ExportAllDeclaration') {\n throw new Error('Native modules must name their external re-exports.');\n }\n }\n const visit = (value: unknown, parent?: Record<string, unknown>, key?: string): void => {\n if (Array.isArray(value)) {\n for (const item of value) visit(item, parent, key);\n return;\n }\n if (typeof value !== 'object' || value === null) return;\n const node = value as Record<string, unknown>;\n if (node.type === 'ImportExpression')\n throw new Error('Native external dynamic imports are unsupported; use named ESM imports.');\n if (\n node.type === 'CallExpression' &&\n /^(?:__)?require(?:\\$\\d+)?$/u.test(String((node.callee as { name?: string })?.name))\n ) {\n throw new Error('Native external CommonJS require is unsupported; use named ESM imports.');\n }\n if (node.type === 'Identifier' && namespaces.has(String(node.name))) {\n const module = namespaces.get(String(node.name))!;\n if (\n parent?.type === 'ImportNamespaceSpecifier' ||\n (key === 'property' && parent?.computed === false) ||\n (key === 'key' && parent?.computed === false)\n )\n return;\n if (parent?.type !== 'MemberExpression' || key !== 'object') {\n throw new Error(`Native namespace '${String(node.name)}' must use static member access.`);\n }\n const property = parent.property as { type: string; name?: string; value?: unknown };\n const name = parent.computed === false ? property.name : property.type === 'Literal' ? property.value : undefined;\n if (typeof name !== 'string')\n throw new Error(`Native namespace '${String(node.name)}' has dynamic member access.`);\n requireExport(module, name);\n }\n for (const [childKey, child] of Object.entries(node))\n if (childKey !== 'start' && childKey !== 'end') visit(child, node, childKey);\n };\n visit(program);\n const entries = [...requirements].map(([module, names]) => [module, [...names].sort()]);\n return `;(function(requirements) {\n function fail(id, name) {\n var error = new Error('Update Po: missing ' + id + (name === null ? '' : '.' + name));\n error.name = 'PoIncompatible';\n error.code = 'PO_INCOMPATIBLE';\n error.module = id;\n error.export = name;\n throw error;\n }\n for (var i = 0; i < requirements.length; i++) {\n var id = requirements[i][0], names = requirements[i][1], value;\n try { value = require(id); } catch (cause) { fail(id, null); }\n for (var j = 0; j < names.length; j++) {\n var name = names[j];\n if (value == null || (name === 'default' ? value.__esModule && value.default === undefined : value[name] === undefined)) fail(id, name);\n }\n }\n})(${JSON.stringify(entries)});\\n`;\n}\n\n/** Bundles a native module. Only the shared UI module may bundle ordinary JS dependencies. */\nasync function bundleNativeModule(entry: string, ui: boolean, onNotice: (message: string) => void): Promise<string> {\n // Loaded here so status and cache readers never start rolldown's native thread pool.\n const { rolldown } = await import('rolldown');\n let guard = '';\n const bundle = await rolldown({\n input: await fs.realpath(entry),\n cwd: path.dirname(entry),\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id) && !(ui && id === UI_MODULE),\n onLog: (level, log) => {\n if (level === 'warn') onNotice(log.message);\n },\n plugins: [\n {\n name: 'po-native-host-modules',\n resolveId(source, importer) {\n if (importer === undefined || !isBareSpecifier(source) || ui) return null;\n if (HOST_MODULES.has(source)) return { id: source, external: true };\n this.error(\n `'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${NATIVE_HOST_MODULE_IDS.join(', ')}.`,\n );\n },\n renderChunk(code, _chunk, options) {\n if (options.format === 'es') guard = nativeImportGuard(this.parse(code));\n return null;\n },\n },\n ],\n });\n try {\n const esm = await bundle.generate({ format: 'es', codeSplitting: false, exports: 'named' });\n const [entryChunk] = esm.output;\n if (esm.output.length !== 1 || entryChunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n // .mjs inputs force Node default-import semantics. Our require map instead supplies Metro modules.\n const commonjs = await rolldown({\n input: '\\0po-native-module.js',\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id),\n plugins: [\n {\n name: 'po-native-commonjs',\n resolveId: (id) => (id === '\\0po-native-module.js' ? id : null),\n load: (id) => (id === '\\0po-native-module.js' ? entryChunk.code : null),\n },\n ],\n });\n let code: string;\n try {\n const { output } = await commonjs.generate({ format: 'cjs', codeSplitting: false, exports: 'named' });\n const [chunk] = output;\n if (output.length !== 1 || chunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n code = chunk.code;\n } finally {\n await commonjs.close();\n }\n const source = guard + code;\n const bytes = Buffer.byteLength(source);\n if (bytes > NATIVE_COMPOSITION_MAX_BYTES)\n throw new Error(\n `The native plugin is ${String(bytes)} bytes, over the ${String(NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`,\n );\n return source;\n } finally {\n await bundle.close();\n }\n}\n\n/**\n * Bundles each plugin into `<outDir>/plugins/<hash>.js` and returns `pluginId -> module file`. A plugin\n * that fails to bundle is named in a notice and left out; the build fails only when none bundles.\n */\nasync function bundleNativePlugins(\n plugins: readonly DeclaredWebPlugin[],\n outDir: string,\n onNotice: (message: string) => void,\n): Promise<Record<string, string>> {\n const pluginsDirectory = path.join(outDir, PLUGINS_DIRECTORY);\n await fs.mkdir(pluginsDirectory, { recursive: true });\n const entries: Record<string, string> = {};\n const failures: string[] = [];\n const bundled = new Set<string>();\n for (const plugin of plugins) {\n if (bundled.has(plugin.pluginId)) continue;\n bundled.add(plugin.pluginId);\n try {\n const file = pluginModuleFile(plugin.pluginId);\n await fs.writeFile(\n path.join(pluginsDirectory, file),\n await bundleNativeModule(path.join(plugin.packageDir, plugin.client.entry), false, onNotice),\n );\n entries[plugin.pluginId] = file;\n } catch (error) {\n const message = `native plugin '${plugin.pluginId}' could not be built: ${error instanceof Error ? error.message : String(error)}`;\n failures.push(message);\n onNotice(message);\n }\n }\n if (Object.keys(entries).length === 0) throw new Error(failures.join('\\n'));\n return entries;\n}\n\n/** Whether the global native build for these plugin roots exists, for a check that must not build. */\nexport async function readGlobalNativeBuildStatus(\n input: GlobalNativeBuildInput,\n): Promise<\n | { status: 'current' | 'missing'; key: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string }\n> {\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n return {\n status: (await readBuildRecord(resolved.directory, input.files)) === undefined ? 'missing' : 'current',\n key: resolved.key,\n };\n}\n\n/**\n * Ensures the one global native build for the given plugin roots exists and returns it.\n *\n * The output is `<home>/build/native/<key>/plugins/<hash>.js`, one module per plugin, built in a\n * temporary directory and renamed into place; an existing key builds nothing.\n */\nexport async function ensureGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<GlobalNativeBuildResult> {\n const notice = input.onNotice ?? ((): void => {});\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n const { plugins, key, buildsRoot, directory, uiEntry } = resolved;\n const existing = await readBuildRecord(directory, input.files);\n if (existing !== undefined) {\n const currentPlugins = plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost }));\n if (JSON.stringify(existing.plugins) !== JSON.stringify(currentPlugins)) {\n // Admission roots are location-specific metadata, not part of the bundled bytes.\n existing.plugins = currentPlugins;\n const { pluginsDirectory: _pluginsDirectory, ...record } = existing;\n const temporary = path.join(directory, `.${BUILD_RECORD}.${crypto.randomUUID()}`);\n try {\n await fs.writeFile(temporary, JSON.stringify(record));\n await fs.rename(temporary, path.join(directory, BUILD_RECORD));\n } finally {\n await fs.rm(temporary, { force: true });\n }\n }\n return { status: 'cached', build: existing };\n }\n return singleFlightBuild(key, async (): Promise<GlobalNativeBuildResult> => {\n try {\n await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {\n const pluginEntries = await bundleNativePlugins(plugins, temporary, notice);\n const uiFile = 'ui.js';\n const uiSource = await bundleNativeModule(uiEntry, true, notice);\n await fs.writeFile(path.join(temporary, PLUGINS_DIRECTORY, uiFile), uiSource);\n notice(`native UI module: ${String(Buffer.byteLength(uiSource))} bytes`);\n return {\n key,\n pluginEntries,\n uiEntry: uiFile,\n plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost })),\n };\n });\n const build = await readBuildRecord(directory, input.files);\n if (build === undefined) throw new Error(`The native build '${key}' was not recorded.`);\n return { status: 'built', build };\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n });\n}\n\n/** The `poNative.pluginId` values a mount runs: those of its own package roots. */\nexport const mountNativePluginIds: (build: GlobalNativeBuildRecord, packageRoots: readonly string[]) => string[] =\n mountWebPluginIds;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,6BAA6B;AACnC,MAAM,oBAAoB;AAC1B,MAAM,YAAY;AAClB,MAAM,eAAoC,IAAI,IAAIA,0BAAAA,sBAAsB;;AAkCxE,eAAe,eACb,SACA,SAAA,GAAoBC,gCAAAA,mBAAAA,CAAmB,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC,GACzC;CACjB,MAAM,OAAOC,YAAAA,QACV,WAAW,QAAQ,CAAC,CACpB,OAAO,0BAA0B,CAAC,CAClC,OAAO,KAAK,UAAUF,0BAAAA,sBAAsB,CAAC;CAEhD,KAAK,MAAM,UAAU,SAAS;EAC5B,KAAK,OAAO,KAAK,UAAU;GAAC,OAAO;GAAU,OAAO;GAAa,OAAO,OAAO;GAAO,OAAO;EAAM,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI;EAClH,KAAK,MAAM,QAAQ,MAAMG,mBAAAA,cACvB,OAAO,YACPC,UAAAA,QAAK,KAAK,OAAO,YAAY,OAAO,OAAO,KAAK,GAChD,KACF,GAAG;GACD,KAAK,OAAO,IAAI,CAAC,CAAC,OAAO,IAAI;GAC7B,KACG,QAAA,GAAOC,4BAAAA,WAAAA,CAAW,MAAM,MAAM,eAAeD,UAAAA,QAAK,KAAK,OAAO,YAAY,IAAI,GAAGE,4BAAAA,kBAAkB,CAAC,CAAC,CAAC,CACtG,OAAO,IAAI;EAChB;CACF;CACA,OAAO,KAAK,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AACvC;;AAGA,eAAe,yBAAyB,OAAmE;CACzG,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,MA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,YAAY;;YAGF;EACN;EAA4B,OAAO;;EACnC;EAAmB;;EACnB;EAAkB;;;;;;;;wBAuSF,wBAAwB,OAAO,yBAAyB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/builders/native/index.ts"],"mappings":";;;;iBAiCiB,gCAAgC;EAC/C;IAAW;IAAkB;IAAoB;;;iBAGlC;;EAEf;EACA,QAAQ;;EAER;EACA,YAAY;;YAGF;EACN;EAA4B,OAAO;;EACnC;EAAmB;;EACnB;EAAkB;;;;;;;;wBA4TF,wBAAwB,OAAO,yBAAyB,QAAQ"}
@@ -1,8 +1,11 @@
1
+ import { snapshotFiles } from "../server/packageUrl.mjs";
1
2
  import { scanWebPlugins } from "../web/webPluginScan.mjs";
2
- import { buildKeyDirectory, globalBuildKey, mountWebPluginIds, readBuildJson, singleFlightBuild } from "../web/index.mjs";
3
+ import { BUILD_RECORD, buildKeyDirectory, mountWebPluginIds, readBuildJson, singleFlightBuild } from "../web/index.mjs";
3
4
  import { createRequire } from "node:module";
4
5
  import path from "node:path";
5
6
  import fs from "node:fs/promises";
7
+ import { createNodePlatform } from "@agimon-ai/po-core/nodePlatform";
8
+ import { BACKGROUND_CONTEXT, getOrThrow } from "@agimon-ai/po-core/platform";
6
9
  import crypto from "node:crypto";
7
10
  import { NATIVE_HOST_MODULE_IDS } from "@agimon-ai/po-core/native";
8
11
  import { NATIVE_COMPOSITION_MAX_BYTES } from "@agimon-ai/po-web-security";
@@ -11,15 +14,32 @@ import { NATIVE_COMPOSITION_MAX_BYTES } from "@agimon-ai/po-web-security";
11
14
  * The global native build: each package's `poNative` client bundled into its own CommonJS module
12
15
  * the po-native shell verifies and evaluates against its own host modules, one plugin at a time.
13
16
  *
14
- * It shares the web build's key, temporary directory, rename and `build.json` handling, and
17
+ * It shares the web build's temporary directory, rename and `build.json` handling, and
15
18
  * runs rolldown in process: the input is already built per package, so each bundle only joins
16
19
  * that package's files and checks that every bare import is one the shell provides.
17
20
  */
18
21
  /** Bumped when build output or package-copy admission changes, so an old record is never reused. */
19
- const GLOBAL_NATIVE_BUILD_FORMAT = "global-native-5";
22
+ const GLOBAL_NATIVE_BUILD_FORMAT = "global-native-6";
20
23
  const PLUGINS_DIRECTORY = "plugins";
21
24
  const UI_MODULE = "@agimon-ai/po-native-components";
22
25
  const HOST_MODULES = new Set(NATIVE_HOST_MODULE_IDS);
26
+ /** Native keys use package-relative paths and bytes, never installation paths or mtimes. */
27
+ async function nativeBuildKey(plugins, files = createNodePlatform().env(process.cwd())) {
28
+ const hash = crypto.createHash("sha256").update(GLOBAL_NATIVE_BUILD_FORMAT).update(JSON.stringify(NATIVE_HOST_MODULE_IDS));
29
+ for (const plugin of plugins) {
30
+ hash.update(JSON.stringify([
31
+ plugin.pluginId,
32
+ plugin.packageName,
33
+ plugin.client.entry,
34
+ plugin.isHost
35
+ ])).update("\0");
36
+ for (const file of await snapshotFiles(plugin.packageDir, path.join(plugin.packageDir, plugin.client.entry), files)) {
37
+ hash.update(file).update("\0");
38
+ hash.update(getOrThrow(await files.readBinaryFile(path.join(plugin.packageDir, file), BACKGROUND_CONTEXT))).update("\0");
39
+ }
40
+ }
41
+ return hash.digest("hex").slice(0, 32);
42
+ }
23
43
  /** The build key for these plugin roots and where its build lives, without building anything. */
24
44
  async function resolveGlobalNativeBuild(input) {
25
45
  const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();
@@ -45,7 +65,7 @@ async function resolveGlobalNativeBuild(input) {
45
65
  scopes: []
46
66
  };
47
67
  });
48
- key = await globalBuildKey(`${GLOBAL_NATIVE_BUILD_FORMAT}:${JSON.stringify(NATIVE_HOST_MODULE_IDS)}`, void 0, [...plugins, ...uiPackages], input.files);
68
+ key = await nativeBuildKey([...plugins, ...uiPackages], input.files);
49
69
  } catch (error) {
50
70
  return {
51
71
  status: "failed",
@@ -248,10 +268,28 @@ async function ensureGlobalNativeBuild(input) {
248
268
  if (resolved.status !== "resolved") return resolved;
249
269
  const { plugins, key, buildsRoot, directory, uiEntry } = resolved;
250
270
  const existing = await readBuildRecord(directory, input.files);
251
- if (existing !== void 0) return {
252
- status: "cached",
253
- build: existing
254
- };
271
+ if (existing !== void 0) {
272
+ const currentPlugins = plugins.map(({ pluginId, packageDir, isHost }) => ({
273
+ pluginId,
274
+ packageDir,
275
+ isHost
276
+ }));
277
+ if (JSON.stringify(existing.plugins) !== JSON.stringify(currentPlugins)) {
278
+ existing.plugins = currentPlugins;
279
+ const { pluginsDirectory: _pluginsDirectory, ...record } = existing;
280
+ const temporary = path.join(directory, `.${BUILD_RECORD}.${crypto.randomUUID()}`);
281
+ try {
282
+ await fs.writeFile(temporary, JSON.stringify(record));
283
+ await fs.rename(temporary, path.join(directory, BUILD_RECORD));
284
+ } finally {
285
+ await fs.rm(temporary, { force: true });
286
+ }
287
+ }
288
+ return {
289
+ status: "cached",
290
+ build: existing
291
+ };
292
+ }
255
293
  return singleFlightBuild(key, async () => {
256
294
  try {
257
295
  await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/builders/native/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { NATIVE_HOST_MODULE_IDS } from '@agimon-ai/po-core/native';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { GlobalNativeBuild } from '@agimon-ai/po-core/webCompositions';\nimport { NATIVE_COMPOSITION_MAX_BYTES } from '@agimon-ai/po-web-security';\nimport type { PluginContext } from 'rolldown';\n\nimport { buildKeyDirectory, globalBuildKey, mountWebPluginIds, readBuildJson, singleFlightBuild } from '../web';\nimport type { DeclaredWebPlugin } from '../web/webPluginManifest';\nimport { scanWebPlugins } from '../web/webPluginScan';\n\n/**\n * The global native build: each package's `poNative` client bundled into its own CommonJS module\n * the po-native shell verifies and evaluates against its own host modules, one plugin at a time.\n *\n * It shares the web build's key, temporary directory, rename and `build.json` handling, and\n * runs rolldown in process: the input is already built per package, so each bundle only joins\n * that package's files and checks that every bare import is one the shell provides.\n */\n\n/** Bumped when build output or package-copy admission changes, so an old record is never reused. */\nconst GLOBAL_NATIVE_BUILD_FORMAT = 'global-native-5';\nconst PLUGINS_DIRECTORY = 'plugins';\nconst UI_MODULE = '@agimon-ai/po-native-components';\nconst HOST_MODULES: ReadonlySet<string> = new Set(NATIVE_HOST_MODULE_IDS);\n\n/** One build's record: the publishable build plus each plugin's package, for resolving a mount's plugins. */\nexport interface GlobalNativeBuildRecord extends GlobalNativeBuild {\n plugins: { pluginId: string; packageDir: string; isHost: boolean }[];\n}\n\nexport interface GlobalNativeBuildInput {\n /** Po's global home; builds land in `<home>/build/native/<key>/`. */\n poHome: string;\n files?: FileSystem;\n /** The union of every scope's package roots; roots without a poNative block are ignored. */\n pluginRoots: readonly string[];\n onNotice?: (message: string) => void;\n}\n\nexport type GlobalNativeBuildResult =\n | { status: 'built' | 'cached'; build: GlobalNativeBuildRecord }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\ntype ResolvedGlobalNativeBuild =\n | {\n status: 'resolved';\n plugins: DeclaredWebPlugin[];\n key: string;\n uiEntry: string;\n buildsRoot: string;\n directory: string;\n }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/** The build key for these plugin roots and where its build lives, without building anything. */\nasync function resolveGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<ResolvedGlobalNativeBuild> {\n const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();\n let plugins: DeclaredWebPlugin[];\n let key: string;\n try {\n plugins = await scanWebPlugins(undefined, pluginRoots, input.onNotice ?? ((): void => {}), 'poNative');\n if (plugins.length === 0)\n return { status: 'skipped', reason: 'no package declares a native plugin; no native composition is published' };\n const resolve = createRequire(import.meta.url).resolve;\n const uiPackages = [UI_MODULE, '@agimon-ai/po-web-components'].map((name) => {\n const packageDir = path.dirname(resolve(`${name}/package.json`));\n return {\n pluginId: name,\n slot: name,\n registrationOrder: 0,\n packageDir,\n packageName: name,\n isHost: false,\n client: { entry: path.relative(packageDir, resolve(name)) },\n scopes: [],\n } satisfies DeclaredWebPlugin;\n });\n key = await globalBuildKey(\n `${GLOBAL_NATIVE_BUILD_FORMAT}:${JSON.stringify(NATIVE_HOST_MODULE_IDS)}`,\n undefined,\n [...plugins, ...uiPackages],\n input.files,\n );\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n const buildsRoot = path.join(input.poHome, 'build', 'native');\n return {\n status: 'resolved',\n plugins,\n key,\n buildsRoot,\n directory: path.join(buildsRoot, key),\n uiEntry: createRequire(import.meta.url).resolve(UI_MODULE),\n };\n}\n\nasync function readBuildRecord(directory: string, files?: FileSystem): Promise<GlobalNativeBuildRecord | undefined> {\n const record = await readBuildJson<Omit<GlobalNativeBuildRecord, 'pluginsDirectory'>>(directory, files);\n if (record === undefined) return undefined;\n return { ...record, pluginsDirectory: path.join(directory, PLUGINS_DIRECTORY) };\n}\n\n/** The complete global native build of one key, or undefined when it is not there. Never builds. */\nexport async function readGlobalNativeBuildRecord(\n poHome: string,\n key: string,\n files?: FileSystem,\n): Promise<GlobalNativeBuildRecord | undefined> {\n return readBuildRecord(path.join(poHome, 'build', 'native', key), files);\n}\n\nconst isBareSpecifier = (source: string): boolean =>\n !source.startsWith('.') && !source.startsWith('\\0') && !path.isAbsolute(source);\n\n/** One plugin's module file name: a hash of its id, so any id is a safe top-level asset path. */\nconst pluginModuleFile = (pluginId: string): string =>\n `${crypto.createHash('sha256').update(pluginId).digest('hex').slice(0, 32)}.js`;\n\n/** Checks the tree-shaken ESM imports before the CommonJS body can run, including on older shells. */\nfunction nativeImportGuard(program: ReturnType<PluginContext['parse']>): string {\n const requirements = new Map<string, Set<string>>();\n const namespaces = new Map<string, string>();\n const requireExport = (module: string, name?: string) => {\n const names = requirements.get(module) ?? new Set<string>();\n if (name !== undefined) names.add(name);\n requirements.set(module, names);\n };\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n const module = statement.source.value;\n requireExport(module);\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportNamespaceSpecifier') namespaces.set(specifier.local.name, module);\n else\n requireExport(\n module,\n specifier.type === 'ImportDefaultSpecifier'\n ? 'default'\n : specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value,\n );\n }\n } else if (statement.type === 'ExportNamedDeclaration' && statement.source !== null) {\n for (const specifier of statement.specifiers)\n requireExport(\n statement.source.value,\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value,\n );\n } else if (statement.type === 'ExportAllDeclaration') {\n throw new Error('Native modules must name their external re-exports.');\n }\n }\n const visit = (value: unknown, parent?: Record<string, unknown>, key?: string): void => {\n if (Array.isArray(value)) {\n for (const item of value) visit(item, parent, key);\n return;\n }\n if (typeof value !== 'object' || value === null) return;\n const node = value as Record<string, unknown>;\n if (node.type === 'ImportExpression')\n throw new Error('Native external dynamic imports are unsupported; use named ESM imports.');\n if (\n node.type === 'CallExpression' &&\n /^(?:__)?require(?:\\$\\d+)?$/u.test(String((node.callee as { name?: string })?.name))\n ) {\n throw new Error('Native external CommonJS require is unsupported; use named ESM imports.');\n }\n if (node.type === 'Identifier' && namespaces.has(String(node.name))) {\n const module = namespaces.get(String(node.name))!;\n if (\n parent?.type === 'ImportNamespaceSpecifier' ||\n (key === 'property' && parent?.computed === false) ||\n (key === 'key' && parent?.computed === false)\n )\n return;\n if (parent?.type !== 'MemberExpression' || key !== 'object') {\n throw new Error(`Native namespace '${String(node.name)}' must use static member access.`);\n }\n const property = parent.property as { type: string; name?: string; value?: unknown };\n const name = parent.computed === false ? property.name : property.type === 'Literal' ? property.value : undefined;\n if (typeof name !== 'string')\n throw new Error(`Native namespace '${String(node.name)}' has dynamic member access.`);\n requireExport(module, name);\n }\n for (const [childKey, child] of Object.entries(node))\n if (childKey !== 'start' && childKey !== 'end') visit(child, node, childKey);\n };\n visit(program);\n const entries = [...requirements].map(([module, names]) => [module, [...names].sort()]);\n return `;(function(requirements) {\n function fail(id, name) {\n var error = new Error('Update Po: missing ' + id + (name === null ? '' : '.' + name));\n error.name = 'PoIncompatible';\n error.code = 'PO_INCOMPATIBLE';\n error.module = id;\n error.export = name;\n throw error;\n }\n for (var i = 0; i < requirements.length; i++) {\n var id = requirements[i][0], names = requirements[i][1], value;\n try { value = require(id); } catch (cause) { fail(id, null); }\n for (var j = 0; j < names.length; j++) {\n var name = names[j];\n if (value == null || (name === 'default' ? value.__esModule && value.default === undefined : value[name] === undefined)) fail(id, name);\n }\n }\n})(${JSON.stringify(entries)});\\n`;\n}\n\n/** Bundles a native module. Only the shared UI module may bundle ordinary JS dependencies. */\nasync function bundleNativeModule(entry: string, ui: boolean, onNotice: (message: string) => void): Promise<string> {\n // Loaded here so status and cache readers never start rolldown's native thread pool.\n const { rolldown } = await import('rolldown');\n let guard = '';\n const bundle = await rolldown({\n input: await fs.realpath(entry),\n cwd: path.dirname(entry),\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id) && !(ui && id === UI_MODULE),\n onLog: (level, log) => {\n if (level === 'warn') onNotice(log.message);\n },\n plugins: [\n {\n name: 'po-native-host-modules',\n resolveId(source, importer) {\n if (importer === undefined || !isBareSpecifier(source) || ui) return null;\n if (HOST_MODULES.has(source)) return { id: source, external: true };\n this.error(\n `'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${NATIVE_HOST_MODULE_IDS.join(', ')}.`,\n );\n },\n renderChunk(code, _chunk, options) {\n if (options.format === 'es') guard = nativeImportGuard(this.parse(code));\n return null;\n },\n },\n ],\n });\n try {\n const esm = await bundle.generate({ format: 'es', codeSplitting: false, exports: 'named' });\n const [entryChunk] = esm.output;\n if (esm.output.length !== 1 || entryChunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n // .mjs inputs force Node default-import semantics. Our require map instead supplies Metro modules.\n const commonjs = await rolldown({\n input: '\\0po-native-module.js',\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id),\n plugins: [\n {\n name: 'po-native-commonjs',\n resolveId: (id) => (id === '\\0po-native-module.js' ? id : null),\n load: (id) => (id === '\\0po-native-module.js' ? entryChunk.code : null),\n },\n ],\n });\n let code: string;\n try {\n const { output } = await commonjs.generate({ format: 'cjs', codeSplitting: false, exports: 'named' });\n const [chunk] = output;\n if (output.length !== 1 || chunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n code = chunk.code;\n } finally {\n await commonjs.close();\n }\n const source = guard + code;\n const bytes = Buffer.byteLength(source);\n if (bytes > NATIVE_COMPOSITION_MAX_BYTES)\n throw new Error(\n `The native plugin is ${String(bytes)} bytes, over the ${String(NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`,\n );\n return source;\n } finally {\n await bundle.close();\n }\n}\n\n/**\n * Bundles each plugin into `<outDir>/plugins/<hash>.js` and returns `pluginId -> module file`. A plugin\n * that fails to bundle is named in a notice and left out; the build fails only when none bundles.\n */\nasync function bundleNativePlugins(\n plugins: readonly DeclaredWebPlugin[],\n outDir: string,\n onNotice: (message: string) => void,\n): Promise<Record<string, string>> {\n const pluginsDirectory = path.join(outDir, PLUGINS_DIRECTORY);\n await fs.mkdir(pluginsDirectory, { recursive: true });\n const entries: Record<string, string> = {};\n const failures: string[] = [];\n const bundled = new Set<string>();\n for (const plugin of plugins) {\n if (bundled.has(plugin.pluginId)) continue;\n bundled.add(plugin.pluginId);\n try {\n const file = pluginModuleFile(plugin.pluginId);\n await fs.writeFile(\n path.join(pluginsDirectory, file),\n await bundleNativeModule(path.join(plugin.packageDir, plugin.client.entry), false, onNotice),\n );\n entries[plugin.pluginId] = file;\n } catch (error) {\n const message = `native plugin '${plugin.pluginId}' could not be built: ${error instanceof Error ? error.message : String(error)}`;\n failures.push(message);\n onNotice(message);\n }\n }\n if (Object.keys(entries).length === 0) throw new Error(failures.join('\\n'));\n return entries;\n}\n\n/** Whether the global native build for these plugin roots exists, for a check that must not build. */\nexport async function readGlobalNativeBuildStatus(\n input: GlobalNativeBuildInput,\n): Promise<\n | { status: 'current' | 'missing'; key: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string }\n> {\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n return {\n status: (await readBuildRecord(resolved.directory, input.files)) === undefined ? 'missing' : 'current',\n key: resolved.key,\n };\n}\n\n/**\n * Ensures the one global native build for the given plugin roots exists and returns it.\n *\n * The output is `<home>/build/native/<key>/plugins/<hash>.js`, one module per plugin, built in a\n * temporary directory and renamed into place; an existing key builds nothing.\n */\nexport async function ensureGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<GlobalNativeBuildResult> {\n const notice = input.onNotice ?? ((): void => {});\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n const { plugins, key, buildsRoot, directory, uiEntry } = resolved;\n const existing = await readBuildRecord(directory, input.files);\n if (existing !== undefined) return { status: 'cached', build: existing };\n return singleFlightBuild(key, async (): Promise<GlobalNativeBuildResult> => {\n try {\n await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {\n const pluginEntries = await bundleNativePlugins(plugins, temporary, notice);\n const uiFile = 'ui.js';\n const uiSource = await bundleNativeModule(uiEntry, true, notice);\n await fs.writeFile(path.join(temporary, PLUGINS_DIRECTORY, uiFile), uiSource);\n notice(`native UI module: ${String(Buffer.byteLength(uiSource))} bytes`);\n return {\n key,\n pluginEntries,\n uiEntry: uiFile,\n plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost })),\n };\n });\n const build = await readBuildRecord(directory, input.files);\n if (build === undefined) throw new Error(`The native build '${key}' was not recorded.`);\n return { status: 'built', build };\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n });\n}\n\n/** The `poNative.pluginId` values a mount runs: those of its own package roots. */\nexport const mountNativePluginIds: (build: GlobalNativeBuildRecord, packageRoots: readonly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,QAAQ,KAAK,EAAE,UAAU,YAAY,cAAc;MAAE;MAAU;MAAY;KAAO,EAAE;IAC/F;GACF,CAAC;GACD,MAAM,QAAQ,MAAM,gBAAgB,WAAW,MAAM,KAAK;GAC1D,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,oBAAoB;GACtF,OAAO;IAAE,QAAQ;IAAS;GAAM;EAClC,SAAS,OAAO;GACd,OAAO;IAAE,QAAQ;IAAU,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAAE;EAC5F;CACF,CAAC;AACH;;AAGA,MAAa,uBACX"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/builders/native/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { NATIVE_HOST_MODULE_IDS } from '@agimon-ai/po-core/native';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { BACKGROUND_CONTEXT, type FileSystem, getOrThrow } from '@agimon-ai/po-core/platform';\nimport type { GlobalNativeBuild } from '@agimon-ai/po-core/webCompositions';\nimport { NATIVE_COMPOSITION_MAX_BYTES } from '@agimon-ai/po-web-security';\nimport type { PluginContext } from 'rolldown';\n\nimport { snapshotFiles } from '../server/packageUrl';\nimport { BUILD_RECORD, buildKeyDirectory, mountWebPluginIds, readBuildJson, singleFlightBuild } from '../web';\nimport type { DeclaredWebPlugin } from '../web/webPluginManifest';\nimport { scanWebPlugins } from '../web/webPluginScan';\n\n/**\n * The global native build: each package's `poNative` client bundled into its own CommonJS module\n * the po-native shell verifies and evaluates against its own host modules, one plugin at a time.\n *\n * It shares the web build's temporary directory, rename and `build.json` handling, and\n * runs rolldown in process: the input is already built per package, so each bundle only joins\n * that package's files and checks that every bare import is one the shell provides.\n */\n\n/** Bumped when build output or package-copy admission changes, so an old record is never reused. */\nconst GLOBAL_NATIVE_BUILD_FORMAT = 'global-native-6';\nconst PLUGINS_DIRECTORY = 'plugins';\nconst UI_MODULE = '@agimon-ai/po-native-components';\nconst HOST_MODULES: ReadonlySet<string> = new Set(NATIVE_HOST_MODULE_IDS);\n\n/** One build's record: the publishable build plus each plugin's package, for resolving a mount's plugins. */\nexport interface GlobalNativeBuildRecord extends GlobalNativeBuild {\n plugins: { pluginId: string; packageDir: string; isHost: boolean }[];\n}\n\nexport interface GlobalNativeBuildInput {\n /** Po's global home; builds land in `<home>/build/native/<key>/`. */\n poHome: string;\n files?: FileSystem;\n /** The union of every scope's package roots; roots without a poNative block are ignored. */\n pluginRoots: readonly string[];\n onNotice?: (message: string) => void;\n}\n\nexport type GlobalNativeBuildResult =\n | { status: 'built' | 'cached'; build: GlobalNativeBuildRecord }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\ntype ResolvedGlobalNativeBuild =\n | {\n status: 'resolved';\n plugins: DeclaredWebPlugin[];\n key: string;\n uiEntry: string;\n buildsRoot: string;\n directory: string;\n }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/** Native keys use package-relative paths and bytes, never installation paths or mtimes. */\nasync function nativeBuildKey(\n plugins: readonly DeclaredWebPlugin[],\n files: FileSystem = createNodePlatform().env(process.cwd()),\n): Promise<string> {\n const hash = crypto\n .createHash('sha256')\n .update(GLOBAL_NATIVE_BUILD_FORMAT)\n .update(JSON.stringify(NATIVE_HOST_MODULE_IDS));\n // Keep build order: the first copy of a plugin id supplies its module.\n for (const plugin of plugins) {\n hash.update(JSON.stringify([plugin.pluginId, plugin.packageName, plugin.client.entry, plugin.isHost])).update('\\0');\n for (const file of await snapshotFiles(\n plugin.packageDir,\n path.join(plugin.packageDir, plugin.client.entry),\n files,\n )) {\n hash.update(file).update('\\0');\n hash\n .update(getOrThrow(await files.readBinaryFile(path.join(plugin.packageDir, file), BACKGROUND_CONTEXT)))\n .update('\\0');\n }\n }\n return hash.digest('hex').slice(0, 32);\n}\n\n/** The build key for these plugin roots and where its build lives, without building anything. */\nasync function resolveGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<ResolvedGlobalNativeBuild> {\n const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();\n let plugins: DeclaredWebPlugin[];\n let key: string;\n try {\n plugins = await scanWebPlugins(undefined, pluginRoots, input.onNotice ?? ((): void => {}), 'poNative');\n if (plugins.length === 0)\n return { status: 'skipped', reason: 'no package declares a native plugin; no native composition is published' };\n const resolve = createRequire(import.meta.url).resolve;\n const uiPackages = [UI_MODULE, '@agimon-ai/po-web-components'].map((name) => {\n const packageDir = path.dirname(resolve(`${name}/package.json`));\n return {\n pluginId: name,\n slot: name,\n registrationOrder: 0,\n packageDir,\n packageName: name,\n isHost: false,\n client: { entry: path.relative(packageDir, resolve(name)) },\n scopes: [],\n } satisfies DeclaredWebPlugin;\n });\n key = await nativeBuildKey([...plugins, ...uiPackages], input.files);\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n const buildsRoot = path.join(input.poHome, 'build', 'native');\n return {\n status: 'resolved',\n plugins,\n key,\n buildsRoot,\n directory: path.join(buildsRoot, key),\n uiEntry: createRequire(import.meta.url).resolve(UI_MODULE),\n };\n}\n\nasync function readBuildRecord(directory: string, files?: FileSystem): Promise<GlobalNativeBuildRecord | undefined> {\n const record = await readBuildJson<Omit<GlobalNativeBuildRecord, 'pluginsDirectory'>>(directory, files);\n if (record === undefined) return undefined;\n return { ...record, pluginsDirectory: path.join(directory, PLUGINS_DIRECTORY) };\n}\n\n/** The complete global native build of one key, or undefined when it is not there. Never builds. */\nexport async function readGlobalNativeBuildRecord(\n poHome: string,\n key: string,\n files?: FileSystem,\n): Promise<GlobalNativeBuildRecord | undefined> {\n return readBuildRecord(path.join(poHome, 'build', 'native', key), files);\n}\n\nconst isBareSpecifier = (source: string): boolean =>\n !source.startsWith('.') && !source.startsWith('\\0') && !path.isAbsolute(source);\n\n/** One plugin's module file name: a hash of its id, so any id is a safe top-level asset path. */\nconst pluginModuleFile = (pluginId: string): string =>\n `${crypto.createHash('sha256').update(pluginId).digest('hex').slice(0, 32)}.js`;\n\n/** Checks the tree-shaken ESM imports before the CommonJS body can run, including on older shells. */\nfunction nativeImportGuard(program: ReturnType<PluginContext['parse']>): string {\n const requirements = new Map<string, Set<string>>();\n const namespaces = new Map<string, string>();\n const requireExport = (module: string, name?: string) => {\n const names = requirements.get(module) ?? new Set<string>();\n if (name !== undefined) names.add(name);\n requirements.set(module, names);\n };\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n const module = statement.source.value;\n requireExport(module);\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportNamespaceSpecifier') namespaces.set(specifier.local.name, module);\n else\n requireExport(\n module,\n specifier.type === 'ImportDefaultSpecifier'\n ? 'default'\n : specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value,\n );\n }\n } else if (statement.type === 'ExportNamedDeclaration' && statement.source !== null) {\n for (const specifier of statement.specifiers)\n requireExport(\n statement.source.value,\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value,\n );\n } else if (statement.type === 'ExportAllDeclaration') {\n throw new Error('Native modules must name their external re-exports.');\n }\n }\n const visit = (value: unknown, parent?: Record<string, unknown>, key?: string): void => {\n if (Array.isArray(value)) {\n for (const item of value) visit(item, parent, key);\n return;\n }\n if (typeof value !== 'object' || value === null) return;\n const node = value as Record<string, unknown>;\n if (node.type === 'ImportExpression')\n throw new Error('Native external dynamic imports are unsupported; use named ESM imports.');\n if (\n node.type === 'CallExpression' &&\n /^(?:__)?require(?:\\$\\d+)?$/u.test(String((node.callee as { name?: string })?.name))\n ) {\n throw new Error('Native external CommonJS require is unsupported; use named ESM imports.');\n }\n if (node.type === 'Identifier' && namespaces.has(String(node.name))) {\n const module = namespaces.get(String(node.name))!;\n if (\n parent?.type === 'ImportNamespaceSpecifier' ||\n (key === 'property' && parent?.computed === false) ||\n (key === 'key' && parent?.computed === false)\n )\n return;\n if (parent?.type !== 'MemberExpression' || key !== 'object') {\n throw new Error(`Native namespace '${String(node.name)}' must use static member access.`);\n }\n const property = parent.property as { type: string; name?: string; value?: unknown };\n const name = parent.computed === false ? property.name : property.type === 'Literal' ? property.value : undefined;\n if (typeof name !== 'string')\n throw new Error(`Native namespace '${String(node.name)}' has dynamic member access.`);\n requireExport(module, name);\n }\n for (const [childKey, child] of Object.entries(node))\n if (childKey !== 'start' && childKey !== 'end') visit(child, node, childKey);\n };\n visit(program);\n const entries = [...requirements].map(([module, names]) => [module, [...names].sort()]);\n return `;(function(requirements) {\n function fail(id, name) {\n var error = new Error('Update Po: missing ' + id + (name === null ? '' : '.' + name));\n error.name = 'PoIncompatible';\n error.code = 'PO_INCOMPATIBLE';\n error.module = id;\n error.export = name;\n throw error;\n }\n for (var i = 0; i < requirements.length; i++) {\n var id = requirements[i][0], names = requirements[i][1], value;\n try { value = require(id); } catch (cause) { fail(id, null); }\n for (var j = 0; j < names.length; j++) {\n var name = names[j];\n if (value == null || (name === 'default' ? value.__esModule && value.default === undefined : value[name] === undefined)) fail(id, name);\n }\n }\n})(${JSON.stringify(entries)});\\n`;\n}\n\n/** Bundles a native module. Only the shared UI module may bundle ordinary JS dependencies. */\nasync function bundleNativeModule(entry: string, ui: boolean, onNotice: (message: string) => void): Promise<string> {\n // Loaded here so status and cache readers never start rolldown's native thread pool.\n const { rolldown } = await import('rolldown');\n let guard = '';\n const bundle = await rolldown({\n input: await fs.realpath(entry),\n cwd: path.dirname(entry),\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id) && !(ui && id === UI_MODULE),\n onLog: (level, log) => {\n if (level === 'warn') onNotice(log.message);\n },\n plugins: [\n {\n name: 'po-native-host-modules',\n resolveId(source, importer) {\n if (importer === undefined || !isBareSpecifier(source) || ui) return null;\n if (HOST_MODULES.has(source)) return { id: source, external: true };\n this.error(\n `'${source}' imported by ${importer} is not a native host module; a native plugin may import only: ${NATIVE_HOST_MODULE_IDS.join(', ')}.`,\n );\n },\n renderChunk(code, _chunk, options) {\n if (options.format === 'es') guard = nativeImportGuard(this.parse(code));\n return null;\n },\n },\n ],\n });\n try {\n const esm = await bundle.generate({ format: 'es', codeSplitting: false, exports: 'named' });\n const [entryChunk] = esm.output;\n if (esm.output.length !== 1 || entryChunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n // .mjs inputs force Node default-import semantics. Our require map instead supplies Metro modules.\n const commonjs = await rolldown({\n input: '\\0po-native-module.js',\n platform: 'neutral',\n external: (id) => HOST_MODULES.has(id),\n plugins: [\n {\n name: 'po-native-commonjs',\n resolveId: (id) => (id === '\\0po-native-module.js' ? id : null),\n load: (id) => (id === '\\0po-native-module.js' ? entryChunk.code : null),\n },\n ],\n });\n let code: string;\n try {\n const { output } = await commonjs.generate({ format: 'cjs', codeSplitting: false, exports: 'named' });\n const [chunk] = output;\n if (output.length !== 1 || chunk.type !== 'chunk') throw new Error('A native module must be one JS file.');\n code = chunk.code;\n } finally {\n await commonjs.close();\n }\n const source = guard + code;\n const bytes = Buffer.byteLength(source);\n if (bytes > NATIVE_COMPOSITION_MAX_BYTES)\n throw new Error(\n `The native plugin is ${String(bytes)} bytes, over the ${String(NATIVE_COMPOSITION_MAX_BYTES)} byte limit.`,\n );\n return source;\n } finally {\n await bundle.close();\n }\n}\n\n/**\n * Bundles each plugin into `<outDir>/plugins/<hash>.js` and returns `pluginId -> module file`. A plugin\n * that fails to bundle is named in a notice and left out; the build fails only when none bundles.\n */\nasync function bundleNativePlugins(\n plugins: readonly DeclaredWebPlugin[],\n outDir: string,\n onNotice: (message: string) => void,\n): Promise<Record<string, string>> {\n const pluginsDirectory = path.join(outDir, PLUGINS_DIRECTORY);\n await fs.mkdir(pluginsDirectory, { recursive: true });\n const entries: Record<string, string> = {};\n const failures: string[] = [];\n const bundled = new Set<string>();\n for (const plugin of plugins) {\n if (bundled.has(plugin.pluginId)) continue;\n bundled.add(plugin.pluginId);\n try {\n const file = pluginModuleFile(plugin.pluginId);\n await fs.writeFile(\n path.join(pluginsDirectory, file),\n await bundleNativeModule(path.join(plugin.packageDir, plugin.client.entry), false, onNotice),\n );\n entries[plugin.pluginId] = file;\n } catch (error) {\n const message = `native plugin '${plugin.pluginId}' could not be built: ${error instanceof Error ? error.message : String(error)}`;\n failures.push(message);\n onNotice(message);\n }\n }\n if (Object.keys(entries).length === 0) throw new Error(failures.join('\\n'));\n return entries;\n}\n\n/** Whether the global native build for these plugin roots exists, for a check that must not build. */\nexport async function readGlobalNativeBuildStatus(\n input: GlobalNativeBuildInput,\n): Promise<\n | { status: 'current' | 'missing'; key: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string }\n> {\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n return {\n status: (await readBuildRecord(resolved.directory, input.files)) === undefined ? 'missing' : 'current',\n key: resolved.key,\n };\n}\n\n/**\n * Ensures the one global native build for the given plugin roots exists and returns it.\n *\n * The output is `<home>/build/native/<key>/plugins/<hash>.js`, one module per plugin, built in a\n * temporary directory and renamed into place; an existing key builds nothing.\n */\nexport async function ensureGlobalNativeBuild(input: GlobalNativeBuildInput): Promise<GlobalNativeBuildResult> {\n const notice = input.onNotice ?? ((): void => {});\n const resolved = await resolveGlobalNativeBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n const { plugins, key, buildsRoot, directory, uiEntry } = resolved;\n const existing = await readBuildRecord(directory, input.files);\n if (existing !== undefined) {\n const currentPlugins = plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost }));\n if (JSON.stringify(existing.plugins) !== JSON.stringify(currentPlugins)) {\n // Admission roots are location-specific metadata, not part of the bundled bytes.\n existing.plugins = currentPlugins;\n const { pluginsDirectory: _pluginsDirectory, ...record } = existing;\n const temporary = path.join(directory, `.${BUILD_RECORD}.${crypto.randomUUID()}`);\n try {\n await fs.writeFile(temporary, JSON.stringify(record));\n await fs.rename(temporary, path.join(directory, BUILD_RECORD));\n } finally {\n await fs.rm(temporary, { force: true });\n }\n }\n return { status: 'cached', build: existing };\n }\n return singleFlightBuild(key, async (): Promise<GlobalNativeBuildResult> => {\n try {\n await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {\n const pluginEntries = await bundleNativePlugins(plugins, temporary, notice);\n const uiFile = 'ui.js';\n const uiSource = await bundleNativeModule(uiEntry, true, notice);\n await fs.writeFile(path.join(temporary, PLUGINS_DIRECTORY, uiFile), uiSource);\n notice(`native UI module: ${String(Buffer.byteLength(uiSource))} bytes`);\n return {\n key,\n pluginEntries,\n uiEntry: uiFile,\n plugins: plugins.map(({ pluginId, packageDir, isHost }) => ({ pluginId, packageDir, isHost })),\n };\n });\n const build = await readBuildRecord(directory, input.files);\n if (build === undefined) throw new Error(`The native build '${key}' was not recorded.`);\n return { status: 'built', build };\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n });\n}\n\n/** The `poNative.pluginId` values a mount runs: those of its own package roots. */\nexport const mountNativePluginIds: (build: GlobalNativeBuildRecord, packageRoots: readonly string[]) => string[] =\n mountWebPluginIds;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,6BAA6B;AACnC,MAAM,oBAAoB;AAC1B,MAAM,YAAY;AAClB,MAAM,eAAoC,IAAI,IAAI,sBAAsB;;AAkCxE,eAAe,eACb,SACA,QAAoB,mBAAmB,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC,GACzC;CACjB,MAAM,OAAO,OACV,WAAW,QAAQ,CAAC,CACpB,OAAO,0BAA0B,CAAC,CAClC,OAAO,KAAK,UAAU,sBAAsB,CAAC;CAEhD,KAAK,MAAM,UAAU,SAAS;EAC5B,KAAK,OAAO,KAAK,UAAU;GAAC,OAAO;GAAU,OAAO;GAAa,OAAO,OAAO;GAAO,OAAO;EAAM,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI;EAClH,KAAK,MAAM,QAAQ,MAAM,cACvB,OAAO,YACP,KAAK,KAAK,OAAO,Y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D,MAAM,GAAG,OAAO,WAAW,KAAK,KAAK,WAAW,YAAY,CAAC;GAC/D,UAAU;IACR,MAAM,GAAG,GAAG,WAAW,EAAE,OAAO,KAAK,CAAC;GACxC;EACF;EACA,OAAO;GAAE,QAAQ;GAAU,OAAO;EAAS;CAC7C;CACA,OAAO,kBAAkB,KAAK,YAA8C;EAC1E,IAAI;GACF,MAAM,kBAAkB,YAAY,KAAK,WAAW,OAAO,cAAc;IACvE,MAAM,gBAAgB,MAAM,oBAAoB,SAAS,WAAW,MAAM;IAC1E,MAAM,SAAS;IACf,MAAM,WAAW,MAAM,mBAAmB,SAAS,MAAM,MAAM;IAC/D,MAAM,GAAG,UAAU,KAAK,KAAK,WAAW,mBAAmB,MAAM,GAAG,QAAQ;IAC5E,OAAO,qBAAqB,OAAO,OAAO,WAAW,QAAQ,CAAC,EAAE,OAAO;IACvE,OAAO;KACL;KACA;KACA,SAAS;KACT,SAAS,QAAQ,KAAK,EAAE,UAAU,YAAY,cAAc;MAAE;MAAU;MAAY;KAAO,EAAE;IAC/F;GACF,CAAC;GACD,MAAM,QAAQ,MAAM,gBAAgB,WAAW,MAAM,KAAK;GAC1D,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,oBAAoB;GACtF,OAAO;IAAE,QAAQ;IAAS;GAAM;EAClC,SAAS,OAAO;GACd,OAAO;IAAE,QAAQ;IAAU,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAAE;EAC5F;CACF,CAAC;AACH;;AAGA,MAAa,uBACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po",
3
- "version": "0.0.0-alpha.128",
3
+ "version": "0.0.0-alpha.129",
4
4
  "description": "Opinionated, composable agent harness for scoped tools, skills, MCP servers, and developer workflows.",
5
5
  "keywords": [
6
6
  "agent-harness",
@@ -177,28 +177,28 @@
177
177
  "registry": "https://registry.npmjs.org/"
178
178
  },
179
179
  "dependencies": {
180
- "@agimon-ai/po-approval": "0.0.0-alpha.127",
181
- "@agimon-ai/po-artifact": "0.0.0-alpha.126",
182
- "@agimon-ai/po-autostop": "0.0.0-alpha.127",
183
- "@agimon-ai/po-cache": "0.0.0-alpha.127",
184
- "@agimon-ai/po-config": "0.0.0-alpha.127",
185
- "@agimon-ai/po-core": "0.0.0-alpha.127",
186
- "@agimon-ai/po-db": "0.0.0-alpha.127",
187
- "@agimon-ai/po-domain": "0.0.0-alpha.127",
188
- "@agimon-ai/po-logsink": "0.0.1-alpha.109",
189
- "@agimon-ai/po-major-mode": "0.0.0-alpha.127",
190
- "@agimon-ai/po-mcp-proxy": "0.0.1-alpha.106",
191
- "@agimon-ai/po-minor-mode": "0.0.0-alpha.127",
192
- "@agimon-ai/po-native-components": "0.0.0-alpha.127",
193
- "@agimon-ai/po-network": "0.0.2-alpha.74",
194
- "@agimon-ai/po-notification": "0.0.0-alpha.127",
195
- "@agimon-ai/po-profile": "0.0.0-alpha.127",
196
- "@agimon-ai/po-session": "0.0.0-alpha.127",
197
- "@agimon-ai/po-skill": "0.0.0-alpha.127",
198
- "@agimon-ai/po-ui": "0.0.0-alpha.127",
199
- "@agimon-ai/po-vault": "0.0.0-alpha.127",
200
- "@agimon-ai/po-web-components": "0.0.0-alpha.127",
201
- "@agimon-ai/po-web-security": "0.0.0-alpha.127",
180
+ "@agimon-ai/po-approval": "0.0.0-alpha.128",
181
+ "@agimon-ai/po-artifact": "0.0.0-alpha.127",
182
+ "@agimon-ai/po-autostop": "0.0.0-alpha.128",
183
+ "@agimon-ai/po-cache": "0.0.0-alpha.128",
184
+ "@agimon-ai/po-config": "0.0.0-alpha.128",
185
+ "@agimon-ai/po-core": "0.0.0-alpha.128",
186
+ "@agimon-ai/po-db": "0.0.0-alpha.128",
187
+ "@agimon-ai/po-domain": "0.0.0-alpha.128",
188
+ "@agimon-ai/po-logsink": "0.0.1-alpha.110",
189
+ "@agimon-ai/po-major-mode": "0.0.0-alpha.128",
190
+ "@agimon-ai/po-mcp-proxy": "0.0.1-alpha.107",
191
+ "@agimon-ai/po-minor-mode": "0.0.0-alpha.128",
192
+ "@agimon-ai/po-native-components": "0.0.0-alpha.128",
193
+ "@agimon-ai/po-network": "0.0.2-alpha.75",
194
+ "@agimon-ai/po-notification": "0.0.0-alpha.128",
195
+ "@agimon-ai/po-profile": "0.0.0-alpha.128",
196
+ "@agimon-ai/po-session": "0.0.0-alpha.128",
197
+ "@agimon-ai/po-skill": "0.0.0-alpha.128",
198
+ "@agimon-ai/po-ui": "0.0.0-alpha.128",
199
+ "@agimon-ai/po-vault": "0.0.0-alpha.128",
200
+ "@agimon-ai/po-web-components": "0.0.0-alpha.128",
201
+ "@agimon-ai/po-web-security": "0.0.0-alpha.128",
202
202
  "@deepseek-ai/cordis": "4.0.5",
203
203
  "@earendil-works/pi-agent-core": "1.5.0",
204
204
  "@earendil-works/pi-coding-agent": "1.5.0",
@@ -220,10 +220,10 @@
220
220
  "yaml": "2.9.1"
221
221
  },
222
222
  "devDependencies": {
223
- "@agimon-ai/po-calendar": "0.0.1-alpha.86",
224
- "@agimon-ai/po-identity": "0.0.2-alpha.74",
225
- "@agimon-ai/po-runner": "0.0.0-alpha.127",
226
- "@agimon-ai/vibe-lint-plugin-po-cli": "0.0.0-alpha.127",
223
+ "@agimon-ai/po-calendar": "0.0.1-alpha.87",
224
+ "@agimon-ai/po-identity": "0.0.2-alpha.75",
225
+ "@agimon-ai/po-runner": "0.0.0-alpha.128",
226
+ "@agimon-ai/vibe-lint-plugin-po-cli": "0.0.0-alpha.128",
227
227
  "@earendil-works/pi-ai": "1.5.0",
228
228
  "@modelcontextprotocol/ext-apps": "2.0.3",
229
229
  "@modelcontextprotocol/server": "2.3.1",