@agimon-ai/po 0.0.0-alpha.130 → 0.0.0-alpha.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.cjs","names":["builtinApiContract"],"sources":["../src/exports/apiContracts.ts"],"sourcesContent":["import { builtinApiContract } from '@agimon-ai/po-core/apiContracts';\n\nexport const apiContracts = builtinApiContract;\nexport default apiContracts;\n"],"mappings":";;;;;AAEA,MAAa,wDAAeA,CAAAA,CAAAA"}
1
+ {"version":3,"file":"apiContracts.cjs","names":["builtinApiContract"],"sources":["../src/exports/apiContracts.ts"],"sourcesContent":["import { builtinApiContract } from '@agimon-ai/po-core/apiContracts';\n\nexport const apiContracts = builtinApiContract;\nexport default apiContracts;\n"],"mappings":";;;;;AAEA,MAAa,e,yCAAeA,CAAAA,CAAAA"}
@@ -2,7 +2,7 @@
2
2
  "version": 1,
3
3
  "packages": {
4
4
  "@agimon-ai/po": {
5
- "version": "0.0.0-alpha.130",
5
+ "version": "0.0.0-alpha.132",
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.129",
31
+ "version": "0.0.0-alpha.131",
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.128",
38
+ "version": "0.0.0-alpha.130",
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.129",
46
+ "version": "0.0.0-alpha.131",
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.129",
56
+ "version": "0.0.0-alpha.131",
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.129",
65
+ "version": "0.0.0-alpha.131",
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.127",
71
+ "version": "0.0.1-alpha.129",
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.129",
79
+ "version": "0.0.0-alpha.131",
80
80
  "dependencies": []
81
81
  },
82
82
  "@agimon-ai/po-cache": {
83
- "version": "0.0.0-alpha.129",
83
+ "version": "0.0.0-alpha.131",
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.88",
91
+ "version": "0.0.1-alpha.90",
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.109",
103
+ "version": "0.1.1-alpha.111",
104
104
  "dependencies": []
105
105
  },
106
106
  "@agimon-ai/po-codemode": {
107
- "version": "0.0.1-alpha.102",
107
+ "version": "0.0.1-alpha.104",
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.129",
115
+ "version": "0.0.0-alpha.131",
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.129",
125
+ "version": "0.0.0-alpha.131",
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.129",
132
+ "version": "0.0.0-alpha.131",
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.129",
138
+ "version": "0.0.0-alpha.131",
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.129",
144
+ "version": "0.0.0-alpha.131",
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.129",
154
+ "version": "0.0.0-alpha.131",
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.129",
163
+ "version": "0.0.0-alpha.131",
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.8",
173
+ "version": "0.0.1-alpha.10",
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.129",
179
+ "version": "0.0.0-alpha.131",
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.129",
188
+ "version": "0.0.0-alpha.131",
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.129",
197
+ "version": "0.0.0-alpha.131",
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.129",
206
+ "version": "0.0.0-alpha.131",
207
207
  "dependencies": []
208
208
  },
209
209
  "@agimon-ai/po-help": {
210
- "version": "0.0.0-alpha.129",
210
+ "version": "0.0.0-alpha.131",
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.76",
219
+ "version": "0.0.2-alpha.78",
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.128",
226
+ "version": "0.0.0-alpha.130",
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.64",
234
+ "version": "0.0.1-alpha.66",
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.129",
244
+ "version": "0.0.0-alpha.131",
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.129",
252
+ "version": "0.0.0-alpha.131",
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.129",
260
+ "version": "0.0.0-alpha.131",
261
261
  "dependencies": [
262
262
  "@agimon-ai/po-config",
263
263
  "@agimon-ai/po-core",
@@ -268,44 +268,52 @@
268
268
  ]
269
269
  },
270
270
  "@agimon-ai/po-mcp-proxy": {
271
- "version": "0.0.1-alpha.108",
271
+ "version": "0.0.1-alpha.110",
272
272
  "dependencies": []
273
273
  },
274
274
  "@agimon-ai/po-minor-mode": {
275
- "version": "0.0.0-alpha.129",
275
+ "version": "0.0.0-alpha.131",
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.129",
281
+ "version": "0.0.0-alpha.131",
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.129",
288
+ "version": "0.0.0-alpha.131",
289
289
  "dependencies": [
290
290
  "@agimon-ai/po-web-components"
291
291
  ]
292
292
  },
293
+ "@agimon-ai/po-native-dashboard": {
294
+ "version": "0.0.0-alpha.3",
295
+ "dependencies": [
296
+ "@agimon-ai/po-core",
297
+ "@agimon-ai/po-native-components",
298
+ "@agimon-ai/po-web-dashboard"
299
+ ]
300
+ },
293
301
  "@agimon-ai/po-network": {
294
- "version": "0.0.2-alpha.76",
302
+ "version": "0.0.2-alpha.78",
295
303
  "dependencies": [
296
304
  "@agimon-ai/po-core",
297
305
  "@agimon-ai/po-web-security"
298
306
  ]
299
307
  },
300
308
  "@agimon-ai/po-notification": {
301
- "version": "0.0.0-alpha.129",
309
+ "version": "0.0.0-alpha.131",
302
310
  "dependencies": [
303
311
  "@agimon-ai/po-autostop",
304
312
  "@agimon-ai/po-core"
305
313
  ]
306
314
  },
307
315
  "@agimon-ai/po-plan": {
308
- "version": "0.0.0-alpha.129",
316
+ "version": "0.0.0-alpha.131",
309
317
  "dependencies": [
310
318
  "@agimon-ai/po-config",
311
319
  "@agimon-ai/po-core",
@@ -315,7 +323,7 @@
315
323
  ]
316
324
  },
317
325
  "@agimon-ai/po-profile": {
318
- "version": "0.0.0-alpha.129",
326
+ "version": "0.0.0-alpha.131",
319
327
  "dependencies": [
320
328
  "@agimon-ai/po-config",
321
329
  "@agimon-ai/po-core",
@@ -323,7 +331,7 @@
323
331
  ]
324
332
  },
325
333
  "@agimon-ai/po-prompt": {
326
- "version": "0.0.0-alpha.129",
334
+ "version": "0.0.0-alpha.131",
327
335
  "dependencies": [
328
336
  "@agimon-ai/po-core",
329
337
  "@agimon-ai/po-web-components",
@@ -331,7 +339,7 @@
331
339
  ]
332
340
  },
333
341
  "@agimon-ai/po-read": {
334
- "version": "0.0.0-alpha.129",
342
+ "version": "0.0.0-alpha.131",
335
343
  "dependencies": [
336
344
  "@agimon-ai/po-config",
337
345
  "@agimon-ai/po-core",
@@ -341,7 +349,7 @@
341
349
  ]
342
350
  },
343
351
  "@agimon-ai/po-runner": {
344
- "version": "0.0.0-alpha.129",
352
+ "version": "0.0.0-alpha.131",
345
353
  "dependencies": [
346
354
  "@agimon-ai/po-core",
347
355
  "@agimon-ai/po-ui",
@@ -350,13 +358,13 @@
350
358
  ]
351
359
  },
352
360
  "@agimon-ai/po-sandbox": {
353
- "version": "0.0.0-alpha.129",
361
+ "version": "0.0.0-alpha.131",
354
362
  "dependencies": [
355
363
  "@agimon-ai/po-core"
356
364
  ]
357
365
  },
358
366
  "@agimon-ai/po-session": {
359
- "version": "0.0.0-alpha.129",
367
+ "version": "0.0.0-alpha.131",
360
368
  "dependencies": [
361
369
  "@agimon-ai/po-config",
362
370
  "@agimon-ai/po-core",
@@ -364,7 +372,7 @@
364
372
  ]
365
373
  },
366
374
  "@agimon-ai/po-skill": {
367
- "version": "0.0.0-alpha.129",
375
+ "version": "0.0.0-alpha.131",
368
376
  "dependencies": [
369
377
  "@agimon-ai/po-config",
370
378
  "@agimon-ai/po-core",
@@ -373,7 +381,7 @@
373
381
  ]
374
382
  },
375
383
  "@agimon-ai/po-style-system": {
376
- "version": "0.0.0-alpha.129",
384
+ "version": "0.0.0-alpha.131",
377
385
  "dependencies": [
378
386
  "@agimon-ai/po-core",
379
387
  "@agimon-ai/po-web-components",
@@ -381,7 +389,7 @@
381
389
  ]
382
390
  },
383
391
  "@agimon-ai/po-task": {
384
- "version": "0.0.0-alpha.129",
392
+ "version": "0.0.0-alpha.131",
385
393
  "dependencies": [
386
394
  "@agimon-ai/po-core",
387
395
  "@agimon-ai/po-ui",
@@ -389,7 +397,7 @@
389
397
  ]
390
398
  },
391
399
  "@agimon-ai/po-team": {
392
- "version": "0.0.0-alpha.129",
400
+ "version": "0.0.0-alpha.131",
393
401
  "dependencies": [
394
402
  "@agimon-ai/po-cache",
395
403
  "@agimon-ai/po-config",
@@ -401,7 +409,7 @@
401
409
  ]
402
410
  },
403
411
  "@agimon-ai/po-template-advanced": {
404
- "version": "0.0.0-alpha.129",
412
+ "version": "0.0.0-alpha.131",
405
413
  "dependencies": [
406
414
  "@agimon-ai/po-core",
407
415
  "@agimon-ai/po-web-components",
@@ -409,7 +417,7 @@
409
417
  ]
410
418
  },
411
419
  "@agimon-ai/po-template-elegant": {
412
- "version": "0.0.0-alpha.129",
420
+ "version": "0.0.0-alpha.131",
413
421
  "dependencies": [
414
422
  "@agimon-ai/po-core",
415
423
  "@agimon-ai/po-web-components",
@@ -417,7 +425,7 @@
417
425
  ]
418
426
  },
419
427
  "@agimon-ai/po-ui": {
420
- "version": "0.0.0-alpha.129",
428
+ "version": "0.0.0-alpha.131",
421
429
  "dependencies": [
422
430
  "@agimon-ai/po-core",
423
431
  "@agimon-ai/po-hashline",
@@ -426,7 +434,7 @@
426
434
  ]
427
435
  },
428
436
  "@agimon-ai/po-user-feedback": {
429
- "version": "0.0.0-alpha.129",
437
+ "version": "0.0.0-alpha.131",
430
438
  "dependencies": [
431
439
  "@agimon-ai/po-core",
432
440
  "@agimon-ai/po-minor-mode",
@@ -435,7 +443,7 @@
435
443
  ]
436
444
  },
437
445
  "@agimon-ai/po-vault": {
438
- "version": "0.0.0-alpha.129",
446
+ "version": "0.0.0-alpha.131",
439
447
  "dependencies": [
440
448
  "@agimon-ai/po-core",
441
449
  "@agimon-ai/po-db",
@@ -444,7 +452,7 @@
444
452
  ]
445
453
  },
446
454
  "@agimon-ai/po-vibe-lint": {
447
- "version": "0.0.1-alpha.98",
455
+ "version": "0.0.1-alpha.100",
448
456
  "dependencies": [
449
457
  "@agimon-ai/po-config",
450
458
  "@agimon-ai/po-core",
@@ -454,7 +462,7 @@
454
462
  ]
455
463
  },
456
464
  "@agimon-ai/po-voice": {
457
- "version": "0.0.0-alpha.129",
465
+ "version": "0.0.0-alpha.131",
458
466
  "dependencies": [
459
467
  "@agimon-ai/po-config",
460
468
  "@agimon-ai/po-core",
@@ -467,11 +475,11 @@
467
475
  ]
468
476
  },
469
477
  "@agimon-ai/po-web-components": {
470
- "version": "0.0.0-alpha.129",
478
+ "version": "0.0.0-alpha.131",
471
479
  "dependencies": []
472
480
  },
473
481
  "@agimon-ai/po-web-dashboard": {
474
- "version": "0.0.0-alpha.129",
482
+ "version": "0.0.0-alpha.131",
475
483
  "dependencies": [
476
484
  "@agimon-ai/po-core",
477
485
  "@agimon-ai/po-web-components",
@@ -479,18 +487,18 @@
479
487
  ]
480
488
  },
481
489
  "@agimon-ai/po-web-search": {
482
- "version": "0.0.0-alpha.128",
490
+ "version": "0.0.0-alpha.130",
483
491
  "dependencies": [
484
492
  "@agimon-ai/po-core",
485
493
  "@agimon-ai/po-web-components"
486
494
  ]
487
495
  },
488
496
  "@agimon-ai/po-web-security": {
489
- "version": "0.0.0-alpha.129",
497
+ "version": "0.0.0-alpha.131",
490
498
  "dependencies": []
491
499
  },
492
500
  "@agimon-ai/po-workflow": {
493
- "version": "0.0.0-alpha.129",
501
+ "version": "0.0.0-alpha.131",
494
502
  "dependencies": [
495
503
  "@agimon-ai/po-core",
496
504
  "@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.130";
2
+ var version = "0.0.0-alpha.132";
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.130";
2
+ var version = "0.0.0-alpha.132";
3
3
  //#endregion
4
4
  export { version };
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["promisify","execFile","fs","path","pathToFileURL","parseApiContract","crypto","parseCompiledContracts","globalPoConfigDirectory","resolvePoConfigurationRoot","serverPackageCandidates","rootCompositions","loadMajorModesConfig","resolveLayers","createApiDocuments","canonicalContractJson"],"sources":["../../../../src/builders/apiContractExport/index.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { promisify } from 'node:util';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { loadMajorModesConfig, resolveLayers } from '@agimon-ai/po-config/majorModes';\nimport {\n canonicalContractJson,\n createApiDocuments,\n parseApiContract,\n parseCompiledContracts,\n type ApiContractSelection,\n type ApiDocuments,\n type PoCompiledContracts,\n type PoPackageContract,\n} from '@agimon-ai/po-core/apiContracts';\n\nimport { resolvePoConfigurationRoot } from '../../composition/repository';\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { serverPackageCandidates, type ServerPackageCandidate } from '../server';\n\nconst execute = promisify(execFile);\n/** Imports one built contract module and prints its default export as strict JSON. */\nconst CONTRACT_PRINTER =\n 'try { const m = await import(process.argv[1]); process.stdout.write(JSON.stringify(m.default, (_key, value) => { if (typeof value === \"function\" || typeof value === \"bigint\" || typeof value === \"undefined\" || (typeof value === \"number\" && !Number.isFinite(value))) throw new Error(\"Contract contains non-JSON data\"); return value; })); } catch (error) { process.stderr.write(error instanceof Error ? `${error.name}: ${error.message}` : String(error)); process.exitCode = 1; }';\n\nfunction problemOf(error: unknown): string {\n const stderr =\n error !== null && typeof error === 'object' && 'stderr' in error && typeof error.stderr === 'string'\n ? error.stderr.trim()\n : '';\n return (stderr || (error instanceof Error ? error.message : String(error))).slice(0, 1000);\n}\n\n/**\n * Reads each server package's built `poServer.contracts.dist` straight from its installed package.\n *\n * Contracts have their own entry so exporting never imports a server plugin, and each one is\n * imported in a bounded child process so its module graph, timers and errors stay out of here.\n * A package without a readable contract is recorded as a gap rather than failing the export.\n */\nasync function collectApiContracts(candidates: readonly ServerPackageCandidate[]): Promise<PoCompiledContracts> {\n const packages: PoPackageContract[] = [];\n for (const { declaration, owners } of candidates) {\n const root = declaration.packageDir;\n const manifest = JSON.parse(await fs.readFile(path.join(root, 'package.json'), 'utf8')) as {\n version?: string;\n poServer?: { contracts?: { entry?: string; dist?: string } };\n };\n const entry: PoPackageContract = {\n packageName: declaration.packageName,\n packageVersion: manifest.version ?? 'unknown',\n scopes: declaration.scopes,\n owners: [...owners],\n };\n packages.push(entry);\n try {\n const contracts = manifest.poServer?.contracts;\n if (!contracts) throw new Error('No poServer.contracts declaration');\n for (const value of [contracts.entry, contracts.dist]) {\n if (typeof value !== 'string' || !value.startsWith('./') || value.includes('..') || /[\\\\%?#]/u.test(value))\n throw new Error('Contract entry and dist must be contained package-relative files');\n }\n const built = await fs.realpath(path.join(root, contracts.dist!));\n const relative = path.relative(await fs.realpath(root), built);\n if (relative.startsWith('..') || path.isAbsolute(relative)) throw new Error('Contract entry escapes package');\n const { stdout } = await execute(\n process.execPath,\n ['--input-type=module', '-e', CONTRACT_PRINTER, pathToFileURL(built).href],\n { timeout: 10_000, maxBuffer: 16 * 1024 * 1024 },\n );\n entry.contract = parseApiContract(JSON.parse(stdout));\n } catch (error) {\n entry.problem = problemOf(error);\n }\n }\n const fingerprint = crypto\n .createHash('sha256')\n .update(JSON.stringify(packages.map(({ packageName, packageVersion }) => [packageName, packageVersion])))\n .digest('hex');\n return parseCompiledContracts({ version: 1, generation: 'live', fingerprint, packages });\n}\n\n/** Reads the installed packages of the global root and the workspace. Export never builds or installs a package. */\nexport async function exportApiContracts(options: {\n cwd: string;\n homeDirectory: string;\n outputDirectory: string;\n majorMode?: string;\n environment?: NodeJS.ProcessEnv;\n}): Promise<ApiDocuments['manifest']> {\n const environment = options.environment ?? process.env;\n const globalRoot = globalPoConfigDirectory(options.homeDirectory);\n const workspaceRoot = await resolvePoConfigurationRoot(options.cwd, options.homeDirectory);\n const read = async (root: string) => ({\n compiled: await collectApiContracts(\n await serverPackageCandidates(rootCompositions({ root, homeDirectory: options.homeDirectory, environment })),\n ),\n config: loadMajorModesConfig(root, options.homeDirectory, environment),\n });\n const global = await read(globalRoot);\n const workspace = globalRoot === workspaceRoot ? global : await read(workspaceRoot);\n const sessionMode = options.majorMode ?? workspace.config.defaultMajorMode;\n const selection = (\n source: typeof global,\n scope: ApiContractSelection['scope'],\n majorMode: string,\n ): ApiContractSelection => ({\n scope,\n majorMode,\n activeLayers: resolveLayers(source.config, majorMode),\n compiled: source.compiled,\n });\n // A typo must not silently export an empty session surface.\n if (!Object.hasOwn(workspace.config.majorMode, sessionMode)) throw new Error(`Unknown major mode '${sessionMode}'`);\n const documents = createApiDocuments([\n selection(global, 'global', global.config.defaultMajorMode),\n selection(workspace, 'workspace', workspace.config.defaultMajorMode),\n selection(workspace, 'session', sessionMode),\n ]);\n const files = {\n 'openapi.json': canonicalContractJson(documents.openapi),\n 'asyncapi.json': canonicalContractJson(documents.asyncapi),\n };\n const manifest = {\n ...documents.manifest,\n artifacts: Object.fromEntries(\n Object.entries(files).map(([name, bytes]) => [\n name,\n {\n sha256: crypto.createHash('sha256').update(bytes).digest('hex'),\n },\n ]),\n ),\n };\n await fs.mkdir(options.outputDirectory, { recursive: true });\n // Write the manifest last. Consumers verify both checksums before accepting the bundle.\n for (const [name, bytes] of Object.entries({ ...files, 'manifest.json': canonicalContractJson(manifest) })) {\n const target = path.join(options.outputDirectory, name);\n const temporary = `${target}.${crypto.randomUUID()}.tmp`;\n try {\n await fs.writeFile(temporary, bytes, { flag: 'wx' });\n await fs.rename(temporary, target);\n } finally {\n await fs.rm(temporary, { force: true });\n }\n }\n return documents.manifest;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,WAAA,sBAAUA,CAAAA,CAAAA,UAAAA,CAAUC,mBAAAA,QAAQ;;AAElC,MAAM,mBACJ;AAEF,SAAS,UAAU,OAAwB;CAKzC,SAHE,UAAU,QAAQ,OAAO,UAAU,YAAY,YAAY,SAAS,OAAO,MAAM,WAAW,WACxF,MAAM,OAAO,KAAK,IAClB,QACa,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAA,CAAI,MAAM,GAAG,GAAI;AAC3F;;;;;;;;AASA,eAAe,oBAAoB,YAA6E;CAC9G,MAAM,WAAgC,CAAC;CACvC,KAAK,MAAM,EAAE,aAAa,YAAY,YAAY;EAChD,MAAM,OAAO,YAAY;EACzB,MAAM,WAAW,KAAK,MAAM,MAAMC,iBAAAA,QAAG,SAASC,UAAAA,QAAK,KAAK,MAAM,cAAc,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QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAC3C,MACA,EACE,QAAQT,YAAAA,QAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK,EAChE,CACF,CAAC,CACH;CACF;CACA,MAAMJ,iBAAAA,QAAG,MAAM,QAAQ,iBAAiB,EAAE,WAAW,KAAK,CAAC;CAE3D,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ;EAAE,GAAG;EAAO,kBAAA,GAAiBa,gCAAAA,sBAAAA,CAAsB,QAAQ;CAAE,CAAC,GAAG;EAC1G,MAAM,SAASZ,UAAAA,QAAK,KAAK,QAAQ,iBAAiB,IAAI;EACtD,MAAM,YAAY,GAAG,OAAO,GAAGG,YAAAA,QAAO,WAAW,EAAE;EACnD,IAAI;GACF,MAAMJ,iBAAAA,QAAG,UAAU,WAAW,OAAO,EAAE,MAAM,KAAK,CAAC;GACnD,MAAMA,iBAAAA,QAAG,OAAO,WAAW,MAAM;EACnC,UAAU;GACR,MAAMA,iBAAAA,QAAG,GAAG,WAAW,EAAE,OAAO,KAAK,CAAC;EACxC;CACF;CACA,OAAO,UAAU;AACnB"}
1
+ {"version":3,"file":"index.cjs","names":["promisify","execFile","fs","path","pathToFileURL","parseApiContract","crypto","parseCompiledContracts","globalPoConfigDirectory","resolvePoConfigurationRoot","serverPackageCandidates","rootCompositions","loadMajorModesConfig","resolveLayers","createApiDocuments","canonicalContractJson"],"sources":["../../../../src/builders/apiContractExport/index.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { promisify } from 'node:util';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { loadMajorModesConfig, resolveLayers } from '@agimon-ai/po-config/majorModes';\nimport {\n canonicalContractJson,\n createApiDocuments,\n parseApiContract,\n parseCompiledContracts,\n type ApiContractSelection,\n type ApiDocuments,\n type PoCompiledContracts,\n type PoPackageContract,\n} from '@agimon-ai/po-core/apiContracts';\n\nimport { resolvePoConfigurationRoot } from '../../composition/repository';\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { serverPackageCandidates, type ServerPackageCandidate } from '../server';\n\nconst execute = promisify(execFile);\n/** Imports one built contract module and prints its default export as strict JSON. */\nconst CONTRACT_PRINTER =\n 'try { const m = await import(process.argv[1]); process.stdout.write(JSON.stringify(m.default, (_key, value) => { if (typeof value === \"function\" || typeof value === \"bigint\" || typeof value === \"undefined\" || (typeof value === \"number\" && !Number.isFinite(value))) throw new Error(\"Contract contains non-JSON data\"); return value; })); } catch (error) { process.stderr.write(error instanceof Error ? `${error.name}: ${error.message}` : String(error)); process.exitCode = 1; }';\n\nfunction problemOf(error: unknown): string {\n const stderr =\n error !== null && typeof error === 'object' && 'stderr' in error && typeof error.stderr === 'string'\n ? error.stderr.trim()\n : '';\n return (stderr || (error instanceof Error ? error.message : String(error))).slice(0, 1000);\n}\n\n/**\n * Reads each server package's built `poServer.contracts.dist` straight from its installed package.\n *\n * Contracts have their own entry so exporting never imports a server plugin, and each one is\n * imported in a bounded child process so its module graph, timers and errors stay out of here.\n * A package without a readable contract is recorded as a gap rather than failing the export.\n */\nasync function collectApiContracts(candidates: readonly ServerPackageCandidate[]): Promise<PoCompiledContracts> {\n const packages: PoPackageContract[] = [];\n for (const { declaration, owners } of candidates) {\n const root = declaration.packageDir;\n const manifest = JSON.parse(await fs.readFile(path.join(root, 'package.json'), 'utf8')) as {\n version?: string;\n poServer?: { contracts?: { entry?: string; dist?: string } };\n };\n const entry: PoPackageContract = {\n packageName: declaration.packageName,\n packageVersion: manifest.version ?? 'unknown',\n scopes: declaration.scopes,\n owners: [...owners],\n };\n packages.push(entry);\n try {\n const contracts = manifest.poServer?.contracts;\n if (!contracts) throw new Error('No poServer.contracts declaration');\n for (const value of [contracts.entry, contracts.dist]) {\n if (typeof value !== 'string' || !value.startsWith('./') || value.includes('..') || /[\\\\%?#]/u.test(value))\n throw new Error('Contract entry and dist must be contained package-relative files');\n }\n const built = await fs.realpath(path.join(root, contracts.dist!));\n const relative = path.relative(await fs.realpath(root), built);\n if (relative.startsWith('..') || path.isAbsolute(relative)) throw new Error('Contract entry escapes package');\n const { stdout } = await execute(\n process.execPath,\n ['--input-type=module', '-e', CONTRACT_PRINTER, pathToFileURL(built).href],\n { timeout: 10_000, maxBuffer: 16 * 1024 * 1024 },\n );\n entry.contract = parseApiContract(JSON.parse(stdout));\n } catch (error) {\n entry.problem = problemOf(error);\n }\n }\n const fingerprint = crypto\n .createHash('sha256')\n .update(JSON.stringify(packages.map(({ packageName, packageVersion }) => [packageName, packageVersion])))\n .digest('hex');\n return parseCompiledContracts({ version: 1, generation: 'live', fingerprint, packages });\n}\n\n/** Reads the installed packages of the global root and the workspace. Export never builds or installs a package. */\nexport async function exportApiContracts(options: {\n cwd: string;\n homeDirectory: string;\n outputDirectory: string;\n majorMode?: string;\n environment?: NodeJS.ProcessEnv;\n}): Promise<ApiDocuments['manifest']> {\n const environment = options.environment ?? process.env;\n const globalRoot = globalPoConfigDirectory(options.homeDirectory);\n const workspaceRoot = await resolvePoConfigurationRoot(options.cwd, options.homeDirectory);\n const read = async (root: string) => ({\n compiled: await collectApiContracts(\n await serverPackageCandidates(rootCompositions({ root, homeDirectory: options.homeDirectory, environment })),\n ),\n config: loadMajorModesConfig(root, options.homeDirectory, environment),\n });\n const global = await read(globalRoot);\n const workspace = globalRoot === workspaceRoot ? global : await read(workspaceRoot);\n const sessionMode = options.majorMode ?? workspace.config.defaultMajorMode;\n const selection = (\n source: typeof global,\n scope: ApiContractSelection['scope'],\n majorMode: string,\n ): ApiContractSelection => ({\n scope,\n majorMode,\n activeLayers: resolveLayers(source.config, majorMode),\n compiled: source.compiled,\n });\n // A typo must not silently export an empty session surface.\n if (!Object.hasOwn(workspace.config.majorMode, sessionMode)) throw new Error(`Unknown major mode '${sessionMode}'`);\n const documents = createApiDocuments([\n selection(global, 'global', global.config.defaultMajorMode),\n selection(workspace, 'workspace', workspace.config.defaultMajorMode),\n selection(workspace, 'session', sessionMode),\n ]);\n const files = {\n 'openapi.json': canonicalContractJson(documents.openapi),\n 'asyncapi.json': canonicalContractJson(documents.asyncapi),\n };\n const manifest = {\n ...documents.manifest,\n artifacts: Object.fromEntries(\n Object.entries(files).map(([name, bytes]) => [\n name,\n {\n sha256: crypto.createHash('sha256').update(bytes).digest('hex'),\n },\n ]),\n ),\n };\n await fs.mkdir(options.outputDirectory, { recursive: true });\n // Write the manifest last. Consumers verify both checksums before accepting the bundle.\n for (const [name, bytes] of Object.entries({ ...files, 'manifest.json': canonicalContractJson(manifest) })) {\n const target = path.join(options.outputDirectory, name);\n const temporary = `${target}.${crypto.randomUUID()}.tmp`;\n try {\n await fs.writeFile(temporary, bytes, { flag: 'wx' });\n await fs.rename(temporary, target);\n } finally {\n await fs.rm(temporary, { force: true });\n }\n }\n return documents.manifest;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,WAAA,G,mBAAUA,CAAAA,CAAAA,UAAAA,CAAUC,mBAAAA,QAAQ;;AAElC,MAAM,mBACJ;AAEF,SAAS,UAAU,OAAwB;CAKzC,SAHE,UAAU,QAAQ,OAAO,UAAU,YAAY,YAAY,SAAS,OAAO,MAAM,WAAW,WACxF,MAAM,OAAO,KAAK,IAClB,QACa,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAA,CAAI,MAAM,GAAG,GAAI;AAC3F;;;;;;;;AASA,eAAe,oBAAoB,YAA6E;CAC9G,MAAM,WAAgC,CAAC;CACvC,KAAK,MAAM,EAAE,aAAa,YAAY,YAAY;EAChD,MAAM,OAAO,YAAY;EACzB,MAAM,WAAW,KAAK,MAAM,MAAMC,iBAAAA,QAAG,SAASC,UAAAA,QAAK,KAAK,MAAM,cAAc,GAAG,MAAM,CAAC;EAItF,MAAM,QAA2B;GAC/B,aAAa,YAAY;GACzB,gBAAgB,SA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YAAAA,QAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK,EAChE,CACF,CAAC,CACH;CACF;CACA,MAAMJ,iBAAAA,QAAG,MAAM,QAAQ,iBAAiB,EAAE,WAAW,KAAK,CAAC;CAE3D,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ;EAAE,GAAG;EAAO,kBAAA,GAAiBa,gCAAAA,sBAAAA,CAAsB,QAAQ;CAAE,CAAC,GAAG;EAC1G,MAAM,SAASZ,UAAAA,QAAK,KAAK,QAAQ,iBAAiB,IAAI;EACtD,MAAM,YAAY,GAAG,OAAO,GAAGG,YAAAA,QAAO,WAAW,EAAE;EACnD,IAAI;GACF,MAAMJ,iBAAAA,QAAG,UAAU,WAAW,OAAO,EAAE,MAAM,KAAK,CAAC;GACnD,MAAMA,iBAAAA,QAAG,OAAO,WAAW,MAAM;EACnC,UAAU;GACR,MAAMA,iBAAAA,QAAG,GAAG,WAAW,EAAE,OAAO,KAAK,CAAC;EACxC;CACF;CACA,OAAO,UAAU;AACnB"}
@@ -8,8 +8,8 @@ node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
8
8
  let node_url = require("node:url");
9
9
  //#region src/builders/web/webPluginGenerate.ts
10
10
  const HEADER = "// Generated by po web builder. Do not edit by hand.";
11
- /** The template po-web renders when a composition names none, so its classes always compile. */
12
- const FALLBACK_TEMPLATE_PACKAGE = "@agimon-ai/po-template-advanced";
11
+ /** The templates po-web bundles: Elegant is the default and Advanced the alternative, so both always compile. */
12
+ const FALLBACK_TEMPLATE_PACKAGES = ["@agimon-ai/po-template-elegant", "@agimon-ai/po-template-advanced"];
13
13
  const BUILTIN_CLIENT_MODULE = node_path.default.join("src", "web", "app", "webPlugins.generated.ts");
14
14
  const BUILTIN_CSS_MODULE = node_path.default.join("src", "web", "styles", "webPluginSources.generated.css");
15
15
  /**
@@ -60,16 +60,16 @@ async function pluginSourceRoot(plugin) {
60
60
  return node_path.default.dirname(node_path.default.join(plugin.packageDir, plugin.client.entry));
61
61
  }
62
62
  /**
63
- * Where Tailwind finds the fallback template's classes. app.css names it by a
63
+ * Where Tailwind finds a bundled template's classes. app.css names it by a
64
64
  * path from its own folder into po-web's node_modules, which holds only in
65
65
  * this repository; an installed po-web has the template beside it instead,
66
66
  * so a sync build that scanned only that path shipped the cockpit without the
67
67
  * template's responsive layout. Resolving it as Node does works in both.
68
68
  */
69
- async function fallbackTemplateSourceRoot(packageRoot) {
69
+ async function fallbackTemplateSourceRoot(packageRoot, name) {
70
70
  let manifest;
71
71
  try {
72
- manifest = (0, node_module.createRequire)(node_path.default.join(packageRoot, "package.json")).resolve(`${FALLBACK_TEMPLATE_PACKAGE}/package.json`);
72
+ manifest = (0, node_module.createRequire)(node_path.default.join(packageRoot, "package.json")).resolve(`${name}/package.json`);
73
73
  } catch {
74
74
  return;
75
75
  }
@@ -79,6 +79,10 @@ async function fallbackTemplateSourceRoot(packageRoot) {
79
79
  throw error;
80
80
  });
81
81
  }
82
+ /** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */
83
+ async function fallbackTemplateSourceRoots(packageRoot) {
84
+ return (await Promise.all(FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)))).filter((root) => root !== void 0);
85
+ }
82
86
  async function renderCssModule(plugins, leadingSourceRoots) {
83
87
  const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source "${root}";`)];
84
88
  for (const plugin of plugins) {
@@ -122,9 +126,9 @@ const pluginStyleEntryName = (slot) => `plugin-${slot}`;
122
126
  async function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
123
127
  const stylesDir = node_path.default.join(generatedDir, "styles");
124
128
  await node_fs_promises.default.mkdir(stylesDir, { recursive: true });
125
- const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);
129
+ const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);
126
130
  const baseSourcesPath = node_path.default.join(generatedDir, "webPluginBaseSources.generated.css");
127
- await node_fs_promises.default.writeFile(baseSourcesPath, await renderCssModule(plugins, [node_path.default.join(packageRoot, "src", "web"), ...fallbackTemplate === void 0 ? [] : [fallbackTemplate]]));
131
+ await node_fs_promises.default.writeFile(baseSourcesPath, await renderCssModule(plugins, [node_path.default.join(packageRoot, "src", "web"), ...fallbackTemplates]));
128
132
  const appCss = relativeImport(await node_fs_promises.default.realpath(stylesDir), await node_fs_promises.default.realpath(node_path.default.join(packageRoot, "src", "web", "styles", "app.css")));
129
133
  const baseEntryPath = node_path.default.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);
130
134
  await node_fs_promises.default.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\n@import '${appCss}';\n`);
@@ -153,8 +157,7 @@ async function writeSyncWebPluginModules(plugins, generatedDir, packageRoot) {
153
157
  await node_fs_promises.default.writeFile(entryPath, `${HEADER}\nexport { webPlugin } from '${specifier}';\n`);
154
158
  slotEntryPaths[plugin.slot] = entryPath;
155
159
  }
156
- const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);
157
- const leadingSourceRoots = [node_path.default.join(packageRoot, "src", "web"), ...fallbackTemplate === void 0 ? [] : [fallbackTemplate]];
160
+ const leadingSourceRoots = [node_path.default.join(packageRoot, "src", "web"), ...await fallbackTemplateSourceRoots(packageRoot)];
158
161
  await node_fs_promises.default.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));
159
162
  const hostPlugins = plugins.filter((plugin) => plugin.isHost);
160
163
  const shell = {
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginGenerate.cjs","names":["path","pathToFileURL","fs","createRequire","scanWebPlugins"],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The template po-web renders when a composition names none, so its classes always compile. */\nconst FALLBACK_TEMPLATE_PACKAGE = '@agimon-ai/po-template-advanced';\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\nasync function renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): Promise<string> {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(await fs.realpath(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n lines.push('', `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`, '');\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: an existence check passes for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nasync function pluginSourceRoot(plugin: DeclaredWebPlugin): Promise<string> {\n for (const root of [path.join(plugin.packageDir, 'src', 'extensions'), path.join(plugin.packageDir, 'src', 'web')]) {\n const exists = await fs.access(root).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n );\n if (exists) return root;\n }\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds the fallback template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nasync function fallbackTemplateSourceRoot(packageRoot: string): Promise<string | undefined> {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(\n `${FALLBACK_TEMPLATE_PACKAGE}/package.json`,\n );\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.access(extensions).then(\n () => extensions,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\nasync function renderCssModule(\n plugins: readonly DeclaredWebPlugin[],\n leadingSourceRoots: readonly string[],\n): Promise<string> {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${await pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport async function renderBuiltinWebPluginModules(packageRoot: string): Promise<Map<string, string>> {\n const plugins = await scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport async function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): Promise<void> {\n const stale: string[] = [];\n for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = await fs.readFile(filePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport async function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<WebPluginStyleEntries> {\n const stylesDir = path.join(generatedDir, 'styles');\n await fs.mkdir(stylesDir, { recursive: true });\n const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n await fs.writeFile(\n baseSourcesPath,\n await renderCssModule(plugins, [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n await fs.realpath(stylesDir),\n await fs.realpath(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport async function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<SyncGeneratedModules> {\n await fs.mkdir(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n await fs.writeFile(clientModulePath, await renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n await fs.mkdir(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(await fs.realpath(path.join(plugin.packageDir, plugin.client.entry))).href;\n await fs.writeFile(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ];\n await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n await fs.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, 'absolute', packageRoot));\n await fs.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,SAAS;;AAEf,MAAM,4BAA4B;AAClC,MAAa,wBAAwBA,UAAAA,QAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqBA,UAAAA,QAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,mBAAmB,GAAG;AACzG;AAEA,SAAS,eAAe,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CACA,MAAME,iBAAAA,QAAG,UAAU,MAAM,kBAAkB,MAAM,mBAAmB,aAAa,YAAY,WAAW,CAAC;CACzG,MAAMA,iBAAAA,QAAG,UAAU,MAAM,eAAe,MAAM,gBAAgB,aAAa,kBAAkB,CAAC;CAC9F,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"webPluginGenerate.cjs","names":["path","pathToFileURL","fs","createRequire","scanWebPlugins"],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The templates po-web bundles: Elegant is the default and Advanced the alternative, so both always compile. */\nconst FALLBACK_TEMPLATE_PACKAGES = ['@agimon-ai/po-template-elegant', '@agimon-ai/po-template-advanced'];\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\nasync function renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): Promise<string> {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(await fs.realpath(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n lines.push('', `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`, '');\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: an existence check passes for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nasync function pluginSourceRoot(plugin: DeclaredWebPlugin): Promise<string> {\n for (const root of [path.join(plugin.packageDir, 'src', 'extensions'), path.join(plugin.packageDir, 'src', 'web')]) {\n const exists = await fs.access(root).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n );\n if (exists) return root;\n }\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds a bundled template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nasync function fallbackTemplateSourceRoot(packageRoot: string, name: string): Promise<string | undefined> {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(`${name}/package.json`);\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.access(extensions).then(\n () => extensions,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\n/** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */\nasync function fallbackTemplateSourceRoots(packageRoot: string): Promise<string[]> {\n const roots = await Promise.all(\n FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)),\n );\n return roots.filter((root) => root !== undefined);\n}\n\nasync function renderCssModule(\n plugins: readonly DeclaredWebPlugin[],\n leadingSourceRoots: readonly string[],\n): Promise<string> {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${await pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport async function renderBuiltinWebPluginModules(packageRoot: string): Promise<Map<string, string>> {\n const plugins = await scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport async function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): Promise<void> {\n const stale: string[] = [];\n for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = await fs.readFile(filePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport async function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<WebPluginStyleEntries> {\n const stylesDir = path.join(generatedDir, 'styles');\n await fs.mkdir(stylesDir, { recursive: true });\n const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n await fs.writeFile(\n baseSourcesPath,\n await renderCssModule(plugins, [path.join(packageRoot, 'src', 'web'), ...fallbackTemplates]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n await fs.realpath(stylesDir),\n await fs.realpath(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport async function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<SyncGeneratedModules> {\n await fs.mkdir(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n await fs.writeFile(clientModulePath, await renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n await fs.mkdir(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(await fs.realpath(path.join(plugin.packageDir, plugin.client.entry))).href;\n await fs.writeFile(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(await fallbackTemplateSourceRoots(packageRoot)),\n ];\n await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n await fs.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, 'absolute', packageRoot));\n await fs.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,SAAS;;AAEf,MAAM,6BAA6B,CAAC,kCAAkC,iCAAiC;AACvG,MAAa,wBAAwBA,UAAAA,QAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqBA,UAAAA,QAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,mBAAmB,GAAG;AACzG;AAEA,SAAS,eAAe,SAAiB,QAAwB;CAC/D,MAAM,OAAOA,UAAAA,QAAK,SAAS,SAAS,MAAM,CAAC,CAAC,MAAMA,UAAAA,QAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACpE,OAAO,KAAK,WAAW,GAAG,IAAI,OAAO,KAAK;AAC5C;AAEA,eAAe,mBACb,SACA,OACA,aACiB;CACjB,MAAM,QAAQ,CAAC,QAAQ,oEAAoE;CAC3F,MAAM,QAAkB,CAAC;CACzB,MAAM,UAAUA,UAAAA,QAAK,KAAK,aAAa,OAAO,OAAO,KAAK;CAC1D,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,OAAO,GAAG,eAAe,OAAO,IAAI,EAAE;EAC5C,MAAM,KAAK,IAAI;EACf,MAAM,QAAQA,UAAAA,QAAK,KAAK,OAAO,YAAY,OAAO,OAAO,KAAK;EAK9D,MAAM,YACJ,UAAU,aAAa,eAAe,SAAS,KAAK,KAAA,GAAIC,SAAAA,cAAAA,CAAc,MA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,qBAClB,sBACA,sBACC,QAAQ;;;;;;wBA4BW,0BACpB,kBAAkB,qBAClB,sBACA,sBACC,QAAQ"}
1
+ {"version":3,"file":"webPluginGenerate.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"mappings":";;qBAWa;qBACA;;wBAsHS,8BAA8B,sBAAsB,QAAQ;;;;;;wBAa5D,gCACpB,aACA;EAEA;EACA;IACE;;iBAwBa;EACf;EACA;;iBAGe,6BAA6B;;EAE5C,gBAAgB;;;;;;;EAOhB,OAAO;;iBAGQ;;EAEf;;EAEA;;EAEA,kBAAkB;;;qBAIP;qBACA,uBAAoB;;wBAGX,2BACpB,kBAAkB,qBAClB,sBACA,sBACC,QAAQ;;;;;;wBAyBW,0BACpB,kBAAkB,qBAClB,sBACA,sBACC,QAAQ"}
@@ -5,8 +5,8 @@ import fs from "node:fs/promises";
5
5
  import { pathToFileURL } from "node:url";
6
6
  //#region src/builders/web/webPluginGenerate.ts
7
7
  const HEADER = "// Generated by po web builder. Do not edit by hand.";
8
- /** The template po-web renders when a composition names none, so its classes always compile. */
9
- const FALLBACK_TEMPLATE_PACKAGE = "@agimon-ai/po-template-advanced";
8
+ /** The templates po-web bundles: Elegant is the default and Advanced the alternative, so both always compile. */
9
+ const FALLBACK_TEMPLATE_PACKAGES = ["@agimon-ai/po-template-elegant", "@agimon-ai/po-template-advanced"];
10
10
  const BUILTIN_CLIENT_MODULE = path.join("src", "web", "app", "webPlugins.generated.ts");
11
11
  const BUILTIN_CSS_MODULE = path.join("src", "web", "styles", "webPluginSources.generated.css");
12
12
  /**
@@ -57,16 +57,16 @@ async function pluginSourceRoot(plugin) {
57
57
  return path.dirname(path.join(plugin.packageDir, plugin.client.entry));
58
58
  }
59
59
  /**
60
- * Where Tailwind finds the fallback template's classes. app.css names it by a
60
+ * Where Tailwind finds a bundled template's classes. app.css names it by a
61
61
  * path from its own folder into po-web's node_modules, which holds only in
62
62
  * this repository; an installed po-web has the template beside it instead,
63
63
  * so a sync build that scanned only that path shipped the cockpit without the
64
64
  * template's responsive layout. Resolving it as Node does works in both.
65
65
  */
66
- async function fallbackTemplateSourceRoot(packageRoot) {
66
+ async function fallbackTemplateSourceRoot(packageRoot, name) {
67
67
  let manifest;
68
68
  try {
69
- manifest = createRequire(path.join(packageRoot, "package.json")).resolve(`${FALLBACK_TEMPLATE_PACKAGE}/package.json`);
69
+ manifest = createRequire(path.join(packageRoot, "package.json")).resolve(`${name}/package.json`);
70
70
  } catch {
71
71
  return;
72
72
  }
@@ -76,6 +76,10 @@ async function fallbackTemplateSourceRoot(packageRoot) {
76
76
  throw error;
77
77
  });
78
78
  }
79
+ /** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */
80
+ async function fallbackTemplateSourceRoots(packageRoot) {
81
+ return (await Promise.all(FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)))).filter((root) => root !== void 0);
82
+ }
79
83
  async function renderCssModule(plugins, leadingSourceRoots) {
80
84
  const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source "${root}";`)];
81
85
  for (const plugin of plugins) {
@@ -119,9 +123,9 @@ const pluginStyleEntryName = (slot) => `plugin-${slot}`;
119
123
  async function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
120
124
  const stylesDir = path.join(generatedDir, "styles");
121
125
  await fs.mkdir(stylesDir, { recursive: true });
122
- const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);
126
+ const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);
123
127
  const baseSourcesPath = path.join(generatedDir, "webPluginBaseSources.generated.css");
124
- await fs.writeFile(baseSourcesPath, await renderCssModule(plugins, [path.join(packageRoot, "src", "web"), ...fallbackTemplate === void 0 ? [] : [fallbackTemplate]]));
128
+ await fs.writeFile(baseSourcesPath, await renderCssModule(plugins, [path.join(packageRoot, "src", "web"), ...fallbackTemplates]));
125
129
  const appCss = relativeImport(await fs.realpath(stylesDir), await fs.realpath(path.join(packageRoot, "src", "web", "styles", "app.css")));
126
130
  const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);
127
131
  await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\n@import '${appCss}';\n`);
@@ -150,8 +154,7 @@ async function writeSyncWebPluginModules(plugins, generatedDir, packageRoot) {
150
154
  await fs.writeFile(entryPath, `${HEADER}\nexport { webPlugin } from '${specifier}';\n`);
151
155
  slotEntryPaths[plugin.slot] = entryPath;
152
156
  }
153
- const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);
154
- const leadingSourceRoots = [path.join(packageRoot, "src", "web"), ...fallbackTemplate === void 0 ? [] : [fallbackTemplate]];
157
+ const leadingSourceRoots = [path.join(packageRoot, "src", "web"), ...await fallbackTemplateSourceRoots(packageRoot)];
155
158
  await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));
156
159
  const hostPlugins = plugins.filter((plugin) => plugin.isHost);
157
160
  const shell = {
@@ -1 +1 @@
1
- {"version":3,"file":"webPluginGenerate.mjs","names":[],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The template po-web renders when a composition names none, so its classes always compile. */\nconst FALLBACK_TEMPLATE_PACKAGE = '@agimon-ai/po-template-advanced';\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\nasync function renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): Promise<string> {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(await fs.realpath(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n lines.push('', `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`, '');\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: an existence check passes for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nasync function pluginSourceRoot(plugin: DeclaredWebPlugin): Promise<string> {\n for (const root of [path.join(plugin.packageDir, 'src', 'extensions'), path.join(plugin.packageDir, 'src', 'web')]) {\n const exists = await fs.access(root).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n );\n if (exists) return root;\n }\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds the fallback template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nasync function fallbackTemplateSourceRoot(packageRoot: string): Promise<string | undefined> {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(\n `${FALLBACK_TEMPLATE_PACKAGE}/package.json`,\n );\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.access(extensions).then(\n () => extensions,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\nasync function renderCssModule(\n plugins: readonly DeclaredWebPlugin[],\n leadingSourceRoots: readonly string[],\n): Promise<string> {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${await pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport async function renderBuiltinWebPluginModules(packageRoot: string): Promise<Map<string, string>> {\n const plugins = await scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport async function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): Promise<void> {\n const stale: string[] = [];\n for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = await fs.readFile(filePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport async function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<WebPluginStyleEntries> {\n const stylesDir = path.join(generatedDir, 'styles');\n await fs.mkdir(stylesDir, { recursive: true });\n const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n await fs.writeFile(\n baseSourcesPath,\n await renderCssModule(plugins, [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n await fs.realpath(stylesDir),\n await fs.realpath(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport async function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<SyncGeneratedModules> {\n await fs.mkdir(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n await fs.writeFile(clientModulePath, await renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n await fs.mkdir(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(await fs.realpath(path.join(plugin.packageDir, plugin.client.entry))).href;\n await fs.writeFile(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const fallbackTemplate = await fallbackTemplateSourceRoot(packageRoot);\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ];\n await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n await fs.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, 'absolute', packageRoot));\n await fs.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;AAQA,MAAM,SAAS;;AAEf,MAAM,4BAA4B;AAClC,MAAa,wBAAwB,KAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqB,KAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,mBAAmB,GAAG;AACzG;AAEA,SAAS,eAAe,SAAiB,QAAwB;CAC/D,MAAM,OAAO,KAAK,SAAS,SAAS,MAAM,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACpE,OAAO,KAAK,WAAW,GAAG,IAAI,OAAO,KAAK;AAC5C;AAEA,eAAe,mBACb,SACA,OACA,aACiB;CACjB,MAAM,QAAQ,CAAC,QAAQ,oEAAoE;CAC3F,MAAM,QAAkB,CAAC;CACzB,MAAM,UAAU,KAAK,KAAK,aAAa,OAAO,OAAO,KAAK;CAC1D,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,OAAO,GAAG,eAAe,OA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,OAAO,QAAQ;CAChC;CACA,MAAM,mBAAmB,MAAM,2BAA2B,WAAW;CACrE,MAAM,qBAAqB,CACzB,KAAK,KAAK,aAAa,OAAO,KAAK,GACnC,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,CAAC,gBAAgB,CAC7D;CACA,MAAM,GAAG,UAAU,eAAe,MAAM,gBAAgB,SAAS,kBAAkB,CAAC;CACpF,MAAM,cAAc,QAAQ,QAAQ,WAAW,OAAO,MAAM;CAC5D,MAAM,QAAQ;EACZ,kBAAkB,KAAK,KAAK,cAAc,6BAA6B;EACvE,eAAe,KAAK,KAAK,cAAc,qCAAqC;CAC9E;CACA,MAAM,GAAG,UAAU,MAAM,kBAAkB,MAAM,mBAAmB,aAAa,YAAY,WAAW,CAAC;CACzG,MAAM,GAAG,UAAU,MAAM,eAAe,MAAM,gBAAgB,aAAa,kBAAkB,CAAC;CAC9F,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"webPluginGenerate.mjs","names":[],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The templates po-web bundles: Elegant is the default and Advanced the alternative, so both always compile. */\nconst FALLBACK_TEMPLATE_PACKAGES = ['@agimon-ai/po-template-elegant', '@agimon-ai/po-template-advanced'];\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\nasync function renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): Promise<string> {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(await fs.realpath(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n lines.push('', `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`, '');\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: an existence check passes for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nasync function pluginSourceRoot(plugin: DeclaredWebPlugin): Promise<string> {\n for (const root of [path.join(plugin.packageDir, 'src', 'extensions'), path.join(plugin.packageDir, 'src', 'web')]) {\n const exists = await fs.access(root).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n );\n if (exists) return root;\n }\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds a bundled template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nasync function fallbackTemplateSourceRoot(packageRoot: string, name: string): Promise<string | undefined> {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(`${name}/package.json`);\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.access(extensions).then(\n () => extensions,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\n/** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */\nasync function fallbackTemplateSourceRoots(packageRoot: string): Promise<string[]> {\n const roots = await Promise.all(\n FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)),\n );\n return roots.filter((root) => root !== undefined);\n}\n\nasync function renderCssModule(\n plugins: readonly DeclaredWebPlugin[],\n leadingSourceRoots: readonly string[],\n): Promise<string> {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${await pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport async function renderBuiltinWebPluginModules(packageRoot: string): Promise<Map<string, string>> {\n const plugins = await scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport async function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): Promise<void> {\n const stale: string[] = [];\n for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = await fs.readFile(filePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport async function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<WebPluginStyleEntries> {\n const stylesDir = path.join(generatedDir, 'styles');\n await fs.mkdir(stylesDir, { recursive: true });\n const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n await fs.writeFile(\n baseSourcesPath,\n await renderCssModule(plugins, [path.join(packageRoot, 'src', 'web'), ...fallbackTemplates]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n await fs.realpath(stylesDir),\n await fs.realpath(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport async function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<SyncGeneratedModules> {\n await fs.mkdir(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n await fs.writeFile(clientModulePath, await renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n await fs.mkdir(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(await fs.realpath(path.join(plugin.packageDir, plugin.client.entry))).href;\n await fs.writeFile(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(await fallbackTemplateSourceRoots(packageRoot)),\n ];\n await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n await fs.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, 'absolute', packageRoot));\n await fs.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;AAQA,MAAM,SAAS;;AAEf,MAAM,6BAA6B,CAAC,kCAAkC,iCAAiC;AACvG,MAAa,wBAAwB,KAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqB,KAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,mBAAmB,GAAG;AACzG;AAEA,SAAS,eAAe,SAAiB,QAAwB;CAC/D,MAAM,OAAO,KAAK,SAAS,SAAS,MAAM,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACpE,OAAO,KAAK,WAAW,GAAG,IAAI,OAAO,KAAK;AAC5C;AAEA,eAAe,mBACb,SACA,OACA,aACiB;CACjB,MAAM,QAAQ,CAAC,QAAQ,oEAAoE;CAC3F,MAAM,QAAkB,CAAC;CACzB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,MAAM,YAAY,KAAK,KAAK,UAAU,GAAG,OAAO,KAAK,IAAI;EACzD,MAAM,YAAY,cAAc,MAAM,GAAG,SAAS,KAAK,KAAK,OAAO,YAAY,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;EACtG,MAAM,GAAG,UAAU,WAAW,GAAG,OAAO,+BAA+B,UAAU,KAAK;EACtF,eAAe,OAAO,QAAQ;CAChC;CACA,MAAM,qBAAqB,CACzB,KAAK,KAAK,aAAa,OAAO,KAAK,GACnC,GAAI,MAAM,4BAA4B,WAAW,CACnD;CACA,MAAM,GAAG,UAAU,eAAe,MAAM,gBAAgB,SAAS,kBAAkB,CAAC;CACpF,MAAM,cAAc,QAAQ,QAAQ,WAAW,OAAO,MAAM;CAC5D,MAAM,QAAQ;EACZ,kBAAkB,KAAK,KAAK,cAAc,6BAA6B;EACvE,eAAe,KAAK,KAAK,cAAc,qCAAqC;CAC9E;CACA,MAAM,GAAG,UAAU,MAAM,kBAAkB,MAAM,mBAAmB,aAAa,YAAY,WAAW,CAAC;CACzG,MAAM,GAAG,UAAU,MAAM,eAAe,MAAM,gBAAgB,aAAa,kBAAkB,CAAC;CAC9F,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"help.cjs","names":["require","createRequire"],"sources":["../../../src/cli/help.ts"],"sourcesContent":["export { initHelp } from './commands/init/help';\nexport { syncHelp } from './commands/sync/help';\nexport { doctorHelp } from './commands/doctor/help';\nimport { createRequire } from 'node:module';\n\n// createRequire rather than a JSON import: this file runs both from src under\n// Node's strip-only TypeScript mode (how pi.sh starts it) and from dist. The\n// package self-reference resolves the same published manifest from either tree.\nconst require = createRequire(import.meta.url);\nconst PACKAGE_MANIFEST = '@agimon-ai/po/package.json';\n\nexport const HARNESS_VERSION = (require(PACKAGE_MANIFEST) as { version: string }).version;\n\nexport function printHelp(): void {\n process.stdout.write(`po\n\nUsage: po [po-web options]\n po --explain | --emit-mcp <dir> [harness options]\n po init\n po sync [matrix options] [--check]\n po api-export --out <directory> [--major-mode <name>] [--strict]\n\nRunning po with no subcommand starts the po-web console (install\n@agimon-ai/po-web next to po) and passes every argument to it.\n\nInitialization:\n po init Fill missing files in ~/.po\n po sync Update packages, build, resolve, and register Po\n in Pi user settings\n po sync --check Exit non-zero when the synced config is out of date\n or report legacy repository-local state to migrate\n\nPo keeps its configuration, builds, and Pi agent directory under ~/.po\n(PO_HOME moves it). Po never removes old or orphaned generated directories\nautomatically.\n\nAfter a sync, run pi directly. The synced session accepts --major-mode,\n--domains, and --profile, and /mode, /domains, and /profile switch\nwithout a restart. Selection defaults come from the selection block in\n.po/config.yaml.\n\n\nHarness options:\n --test Use the local checkout build and <checkout>/.po/test\n (web ports: 7633/7634, also po-web --test or web-test)\n --major-mode <name> Named major mode from .po/modes.yaml\n (default: copilot). Not --mode: Pi owns that one.\n --profile <name> Persona and env from .po/profiles.yaml\n --domains <names> Comma-separated domains (content: plugins, skills)\n --no-domains Load no content domains\n --explain Print the resolved matrix and exit\n --emit-mcp <dir> Write the resolved MCP config to a directory and exit\n --plugin-dir <path> Load an explicit plugin directory, repeatable\n --add-dir <path> Add an accessible directory, repeatable\n --preset <name> default or kimi\n --cwd <path> Run Pi in this directory\n --output-format vibe-lint Read a vibe-lint request from stdin and emit one JSON response\n --allow-protected-writes Allow writes to protected repository paths\n --mcp, --no-mcp Enable or disable MCP configuration\n --agents, --no-agents Enable or disable spawnable agents\n -h, --help Show harness help\n -v, --version Show harness version\n\nInteractive commands:\n /loop Open the loop launcher picker\n /loops List active loops and stop future scheduling\n /effort <level> Set and persist the thinking effort\n /mode Pick a named major mode\n /domains [names] Show the selected domains or pick a different set\n /profile List or switch persona and environment profiles\n\nMinor modes are toggled from the Leader menu, not by a slash command:\n SPC p e Plan mode (repository read-only)\n SPC w e Workflow tools for the agent\n\nAll remaining options are passed to Pi.\n`);\n}\n"],"mappings":";;;AAWA,MAAa,mBAHPA,wBAAUC,CAAAA,CAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAGgBD,CAAAA,CAAQ,4BAAgB,CAAC,CAAyB;AAElF,SAAgB,YAAkB;CAChC,QAAQ,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DtB;AACD"}
1
+ {"version":3,"file":"help.cjs","names":["require","createRequire"],"sources":["../../../src/cli/help.ts"],"sourcesContent":["export { initHelp } from './commands/init/help';\nexport { syncHelp } from './commands/sync/help';\nexport { doctorHelp } from './commands/doctor/help';\nimport { createRequire } from 'node:module';\n\n// createRequire rather than a JSON import: this file runs both from src under\n// Node's strip-only TypeScript mode (how pi.sh starts it) and from dist. The\n// package self-reference resolves the same published manifest from either tree.\nconst require = createRequire(import.meta.url);\nconst PACKAGE_MANIFEST = '@agimon-ai/po/package.json';\n\nexport const HARNESS_VERSION = (require(PACKAGE_MANIFEST) as { version: string }).version;\n\nexport function printHelp(): void {\n process.stdout.write(`po\n\nUsage: po [po-web options]\n po --explain | --emit-mcp <dir> [harness options]\n po init\n po sync [matrix options] [--check]\n po api-export --out <directory> [--major-mode <name>] [--strict]\n\nRunning po with no subcommand starts the po-web console (install\n@agimon-ai/po-web next to po) and passes every argument to it.\n\nInitialization:\n po init Fill missing files in ~/.po\n po sync Update packages, build, resolve, and register Po\n in Pi user settings\n po sync --check Exit non-zero when the synced config is out of date\n or report legacy repository-local state to migrate\n\nPo keeps its configuration, builds, and Pi agent directory under ~/.po\n(PO_HOME moves it). Po never removes old or orphaned generated directories\nautomatically.\n\nAfter a sync, run pi directly. The synced session accepts --major-mode,\n--domains, and --profile, and /mode, /domains, and /profile switch\nwithout a restart. Selection defaults come from the selection block in\n.po/config.yaml.\n\n\nHarness options:\n --test Use the local checkout build and <checkout>/.po/test\n (web ports: 7633/7634, also po-web --test or web-test)\n --major-mode <name> Named major mode from .po/modes.yaml\n (default: copilot). Not --mode: Pi owns that one.\n --profile <name> Persona and env from .po/profiles.yaml\n --domains <names> Comma-separated domains (content: plugins, skills)\n --no-domains Load no content domains\n --explain Print the resolved matrix and exit\n --emit-mcp <dir> Write the resolved MCP config to a directory and exit\n --plugin-dir <path> Load an explicit plugin directory, repeatable\n --add-dir <path> Add an accessible directory, repeatable\n --preset <name> default or kimi\n --cwd <path> Run Pi in this directory\n --output-format vibe-lint Read a vibe-lint request from stdin and emit one JSON response\n --allow-protected-writes Allow writes to protected repository paths\n --mcp, --no-mcp Enable or disable MCP configuration\n --agents, --no-agents Enable or disable spawnable agents\n -h, --help Show harness help\n -v, --version Show harness version\n\nInteractive commands:\n /loop Open the loop launcher picker\n /loops List active loops and stop future scheduling\n /effort <level> Set and persist the thinking effort\n /mode Pick a named major mode\n /domains [names] Show the selected domains or pick a different set\n /profile List or switch persona and environment profiles\n\nMinor modes are toggled from the Leader menu, not by a slash command:\n SPC p e Plan mode (repository read-only)\n SPC w e Workflow tools for the agent\n\nAll remaining options are passed to Pi.\n`);\n}\n"],"mappings":";;;AAWA,MAAa,mBAHPA,G,qBAAUC,CAAAA,CAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAGgBD,CAAAA,CAAQ,4BAAgB,CAAC,CAAyB;AAElF,SAAgB,YAAkB;CAChC,QAAQ,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DtB;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po",
3
- "version": "0.0.0-alpha.130",
3
+ "version": "0.0.0-alpha.132",
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.129",
181
- "@agimon-ai/po-artifact": "0.0.0-alpha.128",
182
- "@agimon-ai/po-autostop": "0.0.0-alpha.129",
183
- "@agimon-ai/po-cache": "0.0.0-alpha.129",
184
- "@agimon-ai/po-config": "0.0.0-alpha.129",
185
- "@agimon-ai/po-core": "0.0.0-alpha.129",
186
- "@agimon-ai/po-db": "0.0.0-alpha.129",
187
- "@agimon-ai/po-domain": "0.0.0-alpha.129",
188
- "@agimon-ai/po-logsink": "0.0.1-alpha.111",
189
- "@agimon-ai/po-major-mode": "0.0.0-alpha.129",
190
- "@agimon-ai/po-mcp-proxy": "0.0.1-alpha.108",
191
- "@agimon-ai/po-minor-mode": "0.0.0-alpha.129",
192
- "@agimon-ai/po-native-components": "0.0.0-alpha.129",
193
- "@agimon-ai/po-network": "0.0.2-alpha.76",
194
- "@agimon-ai/po-notification": "0.0.0-alpha.129",
195
- "@agimon-ai/po-profile": "0.0.0-alpha.129",
196
- "@agimon-ai/po-session": "0.0.0-alpha.129",
197
- "@agimon-ai/po-skill": "0.0.0-alpha.129",
198
- "@agimon-ai/po-ui": "0.0.0-alpha.129",
199
- "@agimon-ai/po-vault": "0.0.0-alpha.129",
200
- "@agimon-ai/po-web-components": "0.0.0-alpha.129",
201
- "@agimon-ai/po-web-security": "0.0.0-alpha.129",
180
+ "@agimon-ai/po-approval": "0.0.0-alpha.131",
181
+ "@agimon-ai/po-artifact": "0.0.0-alpha.130",
182
+ "@agimon-ai/po-autostop": "0.0.0-alpha.131",
183
+ "@agimon-ai/po-cache": "0.0.0-alpha.131",
184
+ "@agimon-ai/po-config": "0.0.0-alpha.131",
185
+ "@agimon-ai/po-core": "0.0.0-alpha.131",
186
+ "@agimon-ai/po-db": "0.0.0-alpha.131",
187
+ "@agimon-ai/po-domain": "0.0.0-alpha.131",
188
+ "@agimon-ai/po-logsink": "0.0.1-alpha.113",
189
+ "@agimon-ai/po-major-mode": "0.0.0-alpha.131",
190
+ "@agimon-ai/po-mcp-proxy": "0.0.1-alpha.110",
191
+ "@agimon-ai/po-minor-mode": "0.0.0-alpha.131",
192
+ "@agimon-ai/po-native-components": "0.0.0-alpha.131",
193
+ "@agimon-ai/po-network": "0.0.2-alpha.78",
194
+ "@agimon-ai/po-notification": "0.0.0-alpha.131",
195
+ "@agimon-ai/po-profile": "0.0.0-alpha.131",
196
+ "@agimon-ai/po-session": "0.0.0-alpha.131",
197
+ "@agimon-ai/po-skill": "0.0.0-alpha.131",
198
+ "@agimon-ai/po-ui": "0.0.0-alpha.131",
199
+ "@agimon-ai/po-vault": "0.0.0-alpha.131",
200
+ "@agimon-ai/po-web-components": "0.0.0-alpha.131",
201
+ "@agimon-ai/po-web-security": "0.0.0-alpha.131",
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.88",
224
- "@agimon-ai/po-identity": "0.0.2-alpha.76",
225
- "@agimon-ai/po-runner": "0.0.0-alpha.129",
226
- "@agimon-ai/vibe-lint-plugin-po-cli": "0.0.0-alpha.129",
223
+ "@agimon-ai/po-calendar": "0.0.1-alpha.90",
224
+ "@agimon-ai/po-identity": "0.0.2-alpha.78",
225
+ "@agimon-ai/po-runner": "0.0.0-alpha.131",
226
+ "@agimon-ai/vibe-lint-plugin-po-cli": "0.0.0-alpha.131",
227
227
  "@earendil-works/pi-ai": "1.5.0",
228
228
  "@modelcontextprotocol/ext-apps": "2.0.3",
229
229
  "@modelcontextprotocol/server": "2.3.1",