@agimon-ai/po 0.0.0-alpha.92 → 0.0.0-alpha.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/index.json +59 -59
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/src/composition/layerPackageInstaller/index.cjs +4 -1
- package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
- package/dist/src/composition/layerPackageInstaller/index.mjs +4 -1
- package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
- package/package.json +27 -27
package/dist/catalog/index.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 1,
|
|
3
3
|
"packages": {
|
|
4
4
|
"@agimon-ai/po": {
|
|
5
|
-
"version": "0.0.0-alpha.
|
|
5
|
+
"version": "0.0.0-alpha.94",
|
|
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.
|
|
31
|
+
"version": "0.0.0-alpha.93",
|
|
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.
|
|
38
|
+
"version": "0.0.0-alpha.92",
|
|
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.
|
|
46
|
+
"version": "0.0.0-alpha.93",
|
|
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.
|
|
56
|
+
"version": "0.0.0-alpha.93",
|
|
57
57
|
"dependencies": [
|
|
58
58
|
"@agimon-ai/po-artifact",
|
|
59
59
|
"@agimon-ai/po-config",
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"@agimon-ai/po-autostop": {
|
|
65
|
-
"version": "0.0.0-alpha.
|
|
65
|
+
"version": "0.0.0-alpha.93",
|
|
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.
|
|
71
|
+
"version": "0.0.1-alpha.91",
|
|
72
72
|
"dependencies": [
|
|
73
73
|
"@agimon-ai/po-core",
|
|
74
74
|
"@agimon-ai/po-web-components"
|
|
75
75
|
]
|
|
76
76
|
},
|
|
77
77
|
"@agimon-ai/po-build": {
|
|
78
|
-
"version": "0.0.0-alpha.
|
|
78
|
+
"version": "0.0.0-alpha.93",
|
|
79
79
|
"dependencies": []
|
|
80
80
|
},
|
|
81
81
|
"@agimon-ai/po-cache": {
|
|
82
|
-
"version": "0.0.0-alpha.
|
|
82
|
+
"version": "0.0.0-alpha.93",
|
|
83
83
|
"dependencies": [
|
|
84
84
|
"@agimon-ai/po-config",
|
|
85
85
|
"@agimon-ai/po-core",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
]
|
|
88
88
|
},
|
|
89
89
|
"@agimon-ai/po-calendar": {
|
|
90
|
-
"version": "0.0.1-alpha.
|
|
90
|
+
"version": "0.0.1-alpha.52",
|
|
91
91
|
"dependencies": [
|
|
92
92
|
"@agimon-ai/po-config",
|
|
93
93
|
"@agimon-ai/po-core",
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
]
|
|
99
99
|
},
|
|
100
100
|
"@agimon-ai/po-claude-bridge": {
|
|
101
|
-
"version": "0.1.1-alpha.
|
|
101
|
+
"version": "0.1.1-alpha.73",
|
|
102
102
|
"dependencies": []
|
|
103
103
|
},
|
|
104
104
|
"@agimon-ai/po-codemode": {
|
|
105
|
-
"version": "0.0.1-alpha.
|
|
105
|
+
"version": "0.0.1-alpha.66",
|
|
106
106
|
"dependencies": [
|
|
107
107
|
"@agimon-ai/po-config",
|
|
108
108
|
"@agimon-ai/po-core",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
112
|
"@agimon-ai/po-computer-use": {
|
|
113
|
-
"version": "0.0.0-alpha.
|
|
113
|
+
"version": "0.0.0-alpha.93",
|
|
114
114
|
"dependencies": [
|
|
115
115
|
"@agimon-ai/po-config",
|
|
116
116
|
"@agimon-ai/po-core",
|
|
@@ -120,26 +120,26 @@
|
|
|
120
120
|
]
|
|
121
121
|
},
|
|
122
122
|
"@agimon-ai/po-config": {
|
|
123
|
-
"version": "0.0.0-alpha.
|
|
123
|
+
"version": "0.0.0-alpha.93",
|
|
124
124
|
"dependencies": [
|
|
125
125
|
"@agimon-ai/po-core",
|
|
126
126
|
"@agimon-ai/po-web-components"
|
|
127
127
|
]
|
|
128
128
|
},
|
|
129
129
|
"@agimon-ai/po-core": {
|
|
130
|
-
"version": "0.0.0-alpha.
|
|
130
|
+
"version": "0.0.0-alpha.93",
|
|
131
131
|
"dependencies": [
|
|
132
132
|
"@agimon-ai/po-web-security"
|
|
133
133
|
]
|
|
134
134
|
},
|
|
135
135
|
"@agimon-ai/po-db": {
|
|
136
|
-
"version": "0.0.0-alpha.
|
|
136
|
+
"version": "0.0.0-alpha.93",
|
|
137
137
|
"dependencies": [
|
|
138
138
|
"@agimon-ai/po-core"
|
|
139
139
|
]
|
|
140
140
|
},
|
|
141
141
|
"@agimon-ai/po-domain": {
|
|
142
|
-
"version": "0.0.0-alpha.
|
|
142
|
+
"version": "0.0.0-alpha.93",
|
|
143
143
|
"dependencies": [
|
|
144
144
|
"@agimon-ai/po-config",
|
|
145
145
|
"@agimon-ai/po-core",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
]
|
|
148
148
|
},
|
|
149
149
|
"@agimon-ai/po-edit": {
|
|
150
|
-
"version": "0.0.0-alpha.
|
|
150
|
+
"version": "0.0.0-alpha.93",
|
|
151
151
|
"dependencies": [
|
|
152
152
|
"@agimon-ai/po-core",
|
|
153
153
|
"@agimon-ai/po-hashline",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
]
|
|
157
157
|
},
|
|
158
158
|
"@agimon-ai/po-file-edit": {
|
|
159
|
-
"version": "0.0.0-alpha.
|
|
159
|
+
"version": "0.0.0-alpha.93",
|
|
160
160
|
"dependencies": [
|
|
161
161
|
"@agimon-ai/po-config",
|
|
162
162
|
"@agimon-ai/po-core",
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
]
|
|
167
167
|
},
|
|
168
168
|
"@agimon-ai/po-git": {
|
|
169
|
-
"version": "0.0.0-alpha.
|
|
169
|
+
"version": "0.0.0-alpha.93",
|
|
170
170
|
"dependencies": [
|
|
171
171
|
"@agimon-ai/po-core",
|
|
172
172
|
"@agimon-ai/po-session",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
]
|
|
176
176
|
},
|
|
177
177
|
"@agimon-ai/po-goal": {
|
|
178
|
-
"version": "0.0.0-alpha.
|
|
178
|
+
"version": "0.0.0-alpha.93",
|
|
179
179
|
"dependencies": [
|
|
180
180
|
"@agimon-ai/po-core",
|
|
181
181
|
"@agimon-ai/po-minor-mode",
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
]
|
|
185
185
|
},
|
|
186
186
|
"@agimon-ai/po-grep": {
|
|
187
|
-
"version": "0.0.0-alpha.
|
|
187
|
+
"version": "0.0.0-alpha.93",
|
|
188
188
|
"dependencies": [
|
|
189
189
|
"@agimon-ai/po-core",
|
|
190
190
|
"@agimon-ai/po-hashline",
|
|
@@ -193,11 +193,11 @@
|
|
|
193
193
|
]
|
|
194
194
|
},
|
|
195
195
|
"@agimon-ai/po-hashline": {
|
|
196
|
-
"version": "0.0.0-alpha.
|
|
196
|
+
"version": "0.0.0-alpha.93",
|
|
197
197
|
"dependencies": []
|
|
198
198
|
},
|
|
199
199
|
"@agimon-ai/po-help": {
|
|
200
|
-
"version": "0.0.0-alpha.
|
|
200
|
+
"version": "0.0.0-alpha.93",
|
|
201
201
|
"dependencies": [
|
|
202
202
|
"@agimon-ai/po-core",
|
|
203
203
|
"@agimon-ai/po-minor-mode",
|
|
@@ -205,14 +205,14 @@
|
|
|
205
205
|
]
|
|
206
206
|
},
|
|
207
207
|
"@agimon-ai/po-identity": {
|
|
208
|
-
"version": "0.0.2-alpha.
|
|
208
|
+
"version": "0.0.2-alpha.40",
|
|
209
209
|
"dependencies": [
|
|
210
210
|
"@agimon-ai/po-core",
|
|
211
211
|
"@agimon-ai/po-web-security"
|
|
212
212
|
]
|
|
213
213
|
},
|
|
214
214
|
"@agimon-ai/po-image-gen": {
|
|
215
|
-
"version": "0.0.0-alpha.
|
|
215
|
+
"version": "0.0.0-alpha.92",
|
|
216
216
|
"dependencies": [
|
|
217
217
|
"@agimon-ai/po-core",
|
|
218
218
|
"@agimon-ai/po-web-components",
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
]
|
|
221
221
|
},
|
|
222
222
|
"@agimon-ai/po-ios": {
|
|
223
|
-
"version": "0.0.1-alpha.
|
|
223
|
+
"version": "0.0.1-alpha.28",
|
|
224
224
|
"dependencies": [
|
|
225
225
|
"@agimon-ai/po-artifact",
|
|
226
226
|
"@agimon-ai/po-config",
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
]
|
|
231
231
|
},
|
|
232
232
|
"@agimon-ai/po-log": {
|
|
233
|
-
"version": "0.0.0-alpha.
|
|
233
|
+
"version": "0.0.0-alpha.93",
|
|
234
234
|
"dependencies": [
|
|
235
235
|
"@agimon-ai/po-core",
|
|
236
236
|
"@agimon-ai/po-web-components",
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
]
|
|
239
239
|
},
|
|
240
240
|
"@agimon-ai/po-major-mode": {
|
|
241
|
-
"version": "0.0.0-alpha.
|
|
241
|
+
"version": "0.0.0-alpha.93",
|
|
242
242
|
"dependencies": [
|
|
243
243
|
"@agimon-ai/po-config",
|
|
244
244
|
"@agimon-ai/po-core",
|
|
@@ -246,7 +246,7 @@
|
|
|
246
246
|
]
|
|
247
247
|
},
|
|
248
248
|
"@agimon-ai/po-mcp": {
|
|
249
|
-
"version": "0.0.0-alpha.
|
|
249
|
+
"version": "0.0.0-alpha.93",
|
|
250
250
|
"dependencies": [
|
|
251
251
|
"@agimon-ai/po-config",
|
|
252
252
|
"@agimon-ai/po-core",
|
|
@@ -257,43 +257,43 @@
|
|
|
257
257
|
]
|
|
258
258
|
},
|
|
259
259
|
"@agimon-ai/po-mcp-proxy": {
|
|
260
|
-
"version": "0.0.1-alpha.
|
|
260
|
+
"version": "0.0.1-alpha.72",
|
|
261
261
|
"dependencies": []
|
|
262
262
|
},
|
|
263
263
|
"@agimon-ai/po-minor-mode": {
|
|
264
|
-
"version": "0.0.0-alpha.
|
|
264
|
+
"version": "0.0.0-alpha.93",
|
|
265
265
|
"dependencies": [
|
|
266
266
|
"@agimon-ai/po-core"
|
|
267
267
|
]
|
|
268
268
|
},
|
|
269
269
|
"@agimon-ai/po-model-guidance": {
|
|
270
|
-
"version": "0.0.0-alpha.
|
|
270
|
+
"version": "0.0.0-alpha.93",
|
|
271
271
|
"dependencies": [
|
|
272
272
|
"@agimon-ai/po-config",
|
|
273
273
|
"@agimon-ai/po-core"
|
|
274
274
|
]
|
|
275
275
|
},
|
|
276
276
|
"@agimon-ai/po-native-components": {
|
|
277
|
-
"version": "0.0.0-alpha.
|
|
277
|
+
"version": "0.0.0-alpha.93",
|
|
278
278
|
"dependencies": [
|
|
279
279
|
"@agimon-ai/po-web-components"
|
|
280
280
|
]
|
|
281
281
|
},
|
|
282
282
|
"@agimon-ai/po-network": {
|
|
283
|
-
"version": "0.0.2-alpha.
|
|
283
|
+
"version": "0.0.2-alpha.40",
|
|
284
284
|
"dependencies": [
|
|
285
285
|
"@agimon-ai/po-core",
|
|
286
286
|
"@agimon-ai/po-web-security"
|
|
287
287
|
]
|
|
288
288
|
},
|
|
289
289
|
"@agimon-ai/po-notification": {
|
|
290
|
-
"version": "0.0.0-alpha.
|
|
290
|
+
"version": "0.0.0-alpha.93",
|
|
291
291
|
"dependencies": [
|
|
292
292
|
"@agimon-ai/po-core"
|
|
293
293
|
]
|
|
294
294
|
},
|
|
295
295
|
"@agimon-ai/po-plan": {
|
|
296
|
-
"version": "0.0.0-alpha.
|
|
296
|
+
"version": "0.0.0-alpha.93",
|
|
297
297
|
"dependencies": [
|
|
298
298
|
"@agimon-ai/po-config",
|
|
299
299
|
"@agimon-ai/po-core",
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
]
|
|
304
304
|
},
|
|
305
305
|
"@agimon-ai/po-profile": {
|
|
306
|
-
"version": "0.0.0-alpha.
|
|
306
|
+
"version": "0.0.0-alpha.93",
|
|
307
307
|
"dependencies": [
|
|
308
308
|
"@agimon-ai/po-config",
|
|
309
309
|
"@agimon-ai/po-core",
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
]
|
|
312
312
|
},
|
|
313
313
|
"@agimon-ai/po-prompt": {
|
|
314
|
-
"version": "0.0.0-alpha.
|
|
314
|
+
"version": "0.0.0-alpha.93",
|
|
315
315
|
"dependencies": [
|
|
316
316
|
"@agimon-ai/po-core",
|
|
317
317
|
"@agimon-ai/po-web-components",
|
|
@@ -319,7 +319,7 @@
|
|
|
319
319
|
]
|
|
320
320
|
},
|
|
321
321
|
"@agimon-ai/po-read": {
|
|
322
|
-
"version": "0.0.0-alpha.
|
|
322
|
+
"version": "0.0.0-alpha.93",
|
|
323
323
|
"dependencies": [
|
|
324
324
|
"@agimon-ai/po-config",
|
|
325
325
|
"@agimon-ai/po-core",
|
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
]
|
|
330
330
|
},
|
|
331
331
|
"@agimon-ai/po-runner": {
|
|
332
|
-
"version": "0.0.0-alpha.
|
|
332
|
+
"version": "0.0.0-alpha.93",
|
|
333
333
|
"dependencies": [
|
|
334
334
|
"@agimon-ai/po-core",
|
|
335
335
|
"@agimon-ai/po-ui",
|
|
@@ -338,13 +338,13 @@
|
|
|
338
338
|
]
|
|
339
339
|
},
|
|
340
340
|
"@agimon-ai/po-sandbox": {
|
|
341
|
-
"version": "0.0.0-alpha.
|
|
341
|
+
"version": "0.0.0-alpha.93",
|
|
342
342
|
"dependencies": [
|
|
343
343
|
"@agimon-ai/po-core"
|
|
344
344
|
]
|
|
345
345
|
},
|
|
346
346
|
"@agimon-ai/po-session": {
|
|
347
|
-
"version": "0.0.0-alpha.
|
|
347
|
+
"version": "0.0.0-alpha.93",
|
|
348
348
|
"dependencies": [
|
|
349
349
|
"@agimon-ai/po-config",
|
|
350
350
|
"@agimon-ai/po-core",
|
|
@@ -352,7 +352,7 @@
|
|
|
352
352
|
]
|
|
353
353
|
},
|
|
354
354
|
"@agimon-ai/po-skill": {
|
|
355
|
-
"version": "0.0.0-alpha.
|
|
355
|
+
"version": "0.0.0-alpha.93",
|
|
356
356
|
"dependencies": [
|
|
357
357
|
"@agimon-ai/po-config",
|
|
358
358
|
"@agimon-ai/po-core",
|
|
@@ -361,7 +361,7 @@
|
|
|
361
361
|
]
|
|
362
362
|
},
|
|
363
363
|
"@agimon-ai/po-style-system": {
|
|
364
|
-
"version": "0.0.0-alpha.
|
|
364
|
+
"version": "0.0.0-alpha.93",
|
|
365
365
|
"dependencies": [
|
|
366
366
|
"@agimon-ai/po-core",
|
|
367
367
|
"@agimon-ai/po-web-components",
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
]
|
|
370
370
|
},
|
|
371
371
|
"@agimon-ai/po-task": {
|
|
372
|
-
"version": "0.0.0-alpha.
|
|
372
|
+
"version": "0.0.0-alpha.93",
|
|
373
373
|
"dependencies": [
|
|
374
374
|
"@agimon-ai/po-core",
|
|
375
375
|
"@agimon-ai/po-ui",
|
|
@@ -377,7 +377,7 @@
|
|
|
377
377
|
]
|
|
378
378
|
},
|
|
379
379
|
"@agimon-ai/po-team": {
|
|
380
|
-
"version": "0.0.0-alpha.
|
|
380
|
+
"version": "0.0.0-alpha.93",
|
|
381
381
|
"dependencies": [
|
|
382
382
|
"@agimon-ai/po-cache",
|
|
383
383
|
"@agimon-ai/po-config",
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
]
|
|
390
390
|
},
|
|
391
391
|
"@agimon-ai/po-template-advanced": {
|
|
392
|
-
"version": "0.0.0-alpha.
|
|
392
|
+
"version": "0.0.0-alpha.93",
|
|
393
393
|
"dependencies": [
|
|
394
394
|
"@agimon-ai/po-core",
|
|
395
395
|
"@agimon-ai/po-web-components",
|
|
@@ -397,7 +397,7 @@
|
|
|
397
397
|
]
|
|
398
398
|
},
|
|
399
399
|
"@agimon-ai/po-template-elegant": {
|
|
400
|
-
"version": "0.0.0-alpha.
|
|
400
|
+
"version": "0.0.0-alpha.93",
|
|
401
401
|
"dependencies": [
|
|
402
402
|
"@agimon-ai/po-core",
|
|
403
403
|
"@agimon-ai/po-web-components",
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
]
|
|
406
406
|
},
|
|
407
407
|
"@agimon-ai/po-ui": {
|
|
408
|
-
"version": "0.0.0-alpha.
|
|
408
|
+
"version": "0.0.0-alpha.93",
|
|
409
409
|
"dependencies": [
|
|
410
410
|
"@agimon-ai/po-core",
|
|
411
411
|
"@agimon-ai/po-hashline",
|
|
@@ -414,7 +414,7 @@
|
|
|
414
414
|
]
|
|
415
415
|
},
|
|
416
416
|
"@agimon-ai/po-user-feedback": {
|
|
417
|
-
"version": "0.0.0-alpha.
|
|
417
|
+
"version": "0.0.0-alpha.93",
|
|
418
418
|
"dependencies": [
|
|
419
419
|
"@agimon-ai/po-core",
|
|
420
420
|
"@agimon-ai/po-minor-mode",
|
|
@@ -423,14 +423,14 @@
|
|
|
423
423
|
]
|
|
424
424
|
},
|
|
425
425
|
"@agimon-ai/po-vault": {
|
|
426
|
-
"version": "0.0.0-alpha.
|
|
426
|
+
"version": "0.0.0-alpha.93",
|
|
427
427
|
"dependencies": [
|
|
428
428
|
"@agimon-ai/po-core",
|
|
429
429
|
"@agimon-ai/po-db"
|
|
430
430
|
]
|
|
431
431
|
},
|
|
432
432
|
"@agimon-ai/po-vibe-lint": {
|
|
433
|
-
"version": "0.0.1-alpha.
|
|
433
|
+
"version": "0.0.1-alpha.62",
|
|
434
434
|
"dependencies": [
|
|
435
435
|
"@agimon-ai/po-config",
|
|
436
436
|
"@agimon-ai/po-core",
|
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
]
|
|
441
441
|
},
|
|
442
442
|
"@agimon-ai/po-voice": {
|
|
443
|
-
"version": "0.0.0-alpha.
|
|
443
|
+
"version": "0.0.0-alpha.93",
|
|
444
444
|
"dependencies": [
|
|
445
445
|
"@agimon-ai/po-config",
|
|
446
446
|
"@agimon-ai/po-core",
|
|
@@ -452,11 +452,11 @@
|
|
|
452
452
|
]
|
|
453
453
|
},
|
|
454
454
|
"@agimon-ai/po-web-components": {
|
|
455
|
-
"version": "0.0.0-alpha.
|
|
455
|
+
"version": "0.0.0-alpha.93",
|
|
456
456
|
"dependencies": []
|
|
457
457
|
},
|
|
458
458
|
"@agimon-ai/po-web-dashboard": {
|
|
459
|
-
"version": "0.0.0-alpha.
|
|
459
|
+
"version": "0.0.0-alpha.93",
|
|
460
460
|
"dependencies": [
|
|
461
461
|
"@agimon-ai/po-core",
|
|
462
462
|
"@agimon-ai/po-web-components",
|
|
@@ -464,18 +464,18 @@
|
|
|
464
464
|
]
|
|
465
465
|
},
|
|
466
466
|
"@agimon-ai/po-web-search": {
|
|
467
|
-
"version": "0.0.0-alpha.
|
|
467
|
+
"version": "0.0.0-alpha.92",
|
|
468
468
|
"dependencies": [
|
|
469
469
|
"@agimon-ai/po-core",
|
|
470
470
|
"@agimon-ai/po-web-components"
|
|
471
471
|
]
|
|
472
472
|
},
|
|
473
473
|
"@agimon-ai/po-web-security": {
|
|
474
|
-
"version": "0.0.0-alpha.
|
|
474
|
+
"version": "0.0.0-alpha.93",
|
|
475
475
|
"dependencies": []
|
|
476
476
|
},
|
|
477
477
|
"@agimon-ai/po-workflow": {
|
|
478
|
-
"version": "0.0.0-alpha.
|
|
478
|
+
"version": "0.0.0-alpha.93",
|
|
479
479
|
"dependencies": [
|
|
480
480
|
"@agimon-ai/po-core",
|
|
481
481
|
"@agimon-ai/po-ui",
|
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
|
@@ -600,6 +600,7 @@ async function ensureLayerPackages(options, dependencies = {}) {
|
|
|
600
600
|
const homeDirectory = environment.HOME ?? node_os.default.homedir();
|
|
601
601
|
const poHome = (0, _agimon_ai_po_core_runtimePiSettings.poHomeDirectory)(homeDirectory, environment);
|
|
602
602
|
const runtimeDirectory = (0, _agimon_ai_po_core_runtimePiSettings.poRuntimeDirectory)(homeDirectory, environment);
|
|
603
|
+
const npmrcFiles = [node_path.default.join(options.repoRoot, ".npmrc")];
|
|
603
604
|
const resolvers = dependencies.resolvers ?? require_builders_cli_extensionAssembler_index.createLayerResolvers(options.repoRoot, environment);
|
|
604
605
|
const external = (specifier) => (0, _agimon_ai_po_core_moduleResolution.testPackageRoot)(packageName(specifier), environment) === void 0;
|
|
605
606
|
const configured = configuredPackageSpecifiers(options.config, options.layers).filter(external);
|
|
@@ -629,7 +630,8 @@ async function ensureLayerPackages(options, dependencies = {}) {
|
|
|
629
630
|
const registrySources = sources.filter((source) => !fixedNames.has(packageName(source)));
|
|
630
631
|
const { updated, unchecked } = options.refresh ? await resolveUpdates(runtimeDirectory, registrySources, dependencies.publishedVersion ?? ((name) => (0, _agimon_ai_po_core_runtimePackages.resolveNewest)(name, {
|
|
631
632
|
dir: runtimeDirectory,
|
|
632
|
-
poHome
|
|
633
|
+
poHome,
|
|
634
|
+
npmrcFiles
|
|
633
635
|
})), options.onProgress) : {
|
|
634
636
|
updated: [],
|
|
635
637
|
unchecked: []
|
|
@@ -650,6 +652,7 @@ async function ensureLayerPackages(options, dependencies = {}) {
|
|
|
650
652
|
await installWithOfflineRetry(dependencies.install ?? _agimon_ai_po_core_runtimePackages.installRuntimePackages, {
|
|
651
653
|
dir: runtimeDirectory,
|
|
652
654
|
poHome,
|
|
655
|
+
npmrcFiles,
|
|
653
656
|
preferOffline: options.refresh !== true,
|
|
654
657
|
log: (message, level) => {
|
|
655
658
|
if (level === "warn") options.onProgress?.(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isLocalPackageSpecifier","fs","path","writeFileAtomic","createNodePlatform","BACKGROUND_CONTEXT","splitPackageSpecifier","poPackageRoot","consumerPackageEntry","crypto","zlib","os","poHomeDirectory","poRuntimeDirectory","createLayerResolvers","testPackageRoot","resolveNewest","installRuntimePackages"],"sources":["../../../../src/composition/layerPackageInstaller/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { isLocalPackageSpecifier, type MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nimport { consumerPackageEntry, splitPackageSpecifier, testPackageRoot } from '@agimon-ai/po-core/moduleResolution';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { BACKGROUND_CONTEXT, writeFileAtomic } from '@agimon-ai/po-core/platform';\nimport {\n installRuntimePackages,\n type InstallRuntimePackagesOptions,\n resolveNewest,\n} from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { createLayerResolvers, type ExtensionLayerResolvers } from '../../builders/cli/extensionAssembler';\n\nconst NPM_SOURCE_PREFIX = 'npm:';\nconst FILE_SPECIFIER_PREFIX = 'file:';\nconst WORKSPACE_SPECIFIER_PREFIX = 'workspace:';\n/** Root target of a staged catalogue archive: always the staged workspace, never the registry. */\nconst CATALOG_WORKSPACE_TARGET = 'workspace:*';\n/** Where catalogue archives are unpacked inside the runtime, one directory per archive hash. */\nconst CATALOG_STAGING_DIRECTORY = 'catalog';\nconst RUNTIME_PACKAGE_NAME = 'po-runtime';\nconst UNPINNED_PACKAGE_RANGE = '*';\nconst PACKAGE_MANIFEST = 'package.json';\nconst NODE_MODULES = 'node_modules';\nconst PACKAGE_CATALOG_ENV = 'PO_PACKAGE_CATALOG';\n/** The registry catalogue a release writes into the CLI package: `<package root>/dist/catalog/index.json`. */\nconst BUNDLED_CATALOG_SEGMENTS = ['dist', 'catalog', 'index.json'] as const;\n/** upm error codes that mean the registry could not be reached, so the store may still answer. */\nconst NETWORK_FAILURE_CODES = new Set(['ENETWORK', 'ETIMEDOUT', 'EREGISTRY']);\n\nfunction overridePackageName(selector: string): string {\n const separatorIndex = selector.indexOf('@', selector.startsWith('@') ? 1 : 0);\n return separatorIndex === -1 ? selector : selector.slice(0, separatorIndex);\n}\n\n/**\n * Runtime compatibility pins and same-major patches for current foundation packages.\n * Package managers only honor overrides from the install root, so published extensions\n * cannot carry these fixes in their own manifests.\n */\nexport const SAFE_TRANSITIVE_OVERRIDES = {\n // ponytail: Pin for Pi 1.4.0's declaration API; advance with the host's Pi version.\n '@earendil-works/pi-codemode': '1.4.0',\n '@hono/node-server@2.0.0 - 2.0.9': '^2.0.10',\n '@opentelemetry/core@2.0.0 - 2.7.999': '2.8.0',\n 'brace-expansion@1.0.0 - 1.1.20': '^1.1.21',\n 'brace-expansion@5.0.0 - 5.0.11': '^5.0.12',\n 'hono@4.0.0 - 4.13.7': '4.13.8',\n 'js-yaml@4.0.0 - 4.3.1': '^4.3.2',\n 'js-yaml@5.0.0 - 5.2.1': '^5.2.2',\n 'liquidjs@10.0.0 - 10.27.1': '^10.27.2',\n 'protobufjs@8.0.0 - 8.7.1': '^8.7.2',\n 'undici@7.0.0 - 7.29.0': '^7.29.1',\n} as const satisfies Readonly<Record<string, string>>;\n\nconst SAFE_TRANSITIVE_PACKAGE_NAMES = new Set(Object.keys(SAFE_TRANSITIVE_OVERRIDES).map(overridePackageName));\n\nexport interface EnsureLayerPackagesOptions {\n /**\n * The Po root whose layers name the packages. Its own node_modules chain is\n * resolved first; what it cannot provide is installed into the one runtime\n * every root shares, `<po home>/runtime`.\n */\n repoRoot: string;\n config: MajorModesConfig;\n layers: readonly string[];\n environment?: NodeJS.ProcessEnv;\n /**\n * Move every managed package to its newest published version.\n *\n * Launch installs what a selection needs and nothing more, so a session never\n * pays for a registry round trip. Sync is the explicit maintenance command and\n * is the only caller that asks for this.\n */\n refresh?: boolean;\n /**\n * Packages installed into the runtime whatever the root resolves itself, such as the\n * catalogue's `install` list. A `name@version` specifier pins that exact version; a\n * catalogue archive for the name still wins. Refresh never moves a pinned name.\n */\n specifiers?: readonly string[];\n /**\n * Make the runtime manifest declare exactly this run's packages (the specifiers, the\n * selected names and their catalogue dependencies), so pruning can drop anything else.\n * Without it the manifest only grows.\n */\n exactManifest?: boolean;\n /** Receives one human-readable line per package decision. */\n onProgress?: (message: string) => void;\n}\n\nexport interface LayerPackageInstallerDependencies {\n /** Install seam; the default installs `<po home>/runtime` with upm. */\n install?: (options: InstallRuntimePackagesOptions) => Promise<unknown>;\n resolvers?: ExtensionLayerResolvers;\n /** Registry lookup seam; the default resolves the newest allowed version with upm. */\n publishedVersion?: (name: string) => Promise<string>;\n}\n\n/** One managed package moving from the installed version to the newest published one. */\nexport interface LayerPackageUpdate {\n name: string;\n from: string;\n to: string;\n}\n\nexport interface LayerPackageResult {\n /** Sources installed because a configured extension could not be resolved. */\n installed: string[];\n /** Packages this run moved to a newer published version. */\n updated: LayerPackageUpdate[];\n /** Packages left at the installed version because the registry could not be read. */\n unchecked: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction recordValue(value: unknown): Record<string, unknown> {\n return isRecord(value) ? { ...value } : {};\n}\n\nfunction withoutConflictingTransitiveOverrides(value: unknown): Record<string, unknown> {\n const overrides = recordValue(value);\n for (const [selector, replacement] of Object.entries(overrides)) {\n if (SAFE_TRANSITIVE_PACKAGE_NAMES.has(overridePackageName(selector))) {\n delete overrides[selector];\n } else if (isRecord(replacement)) {\n overrides[selector] = withoutConflictingTransitiveOverrides(replacement);\n }\n }\n return overrides;\n}\n\n/** Earlier versions overrode catalog packages with relative `file:` targets; any other override is not Po's. */\nfunction withoutCatalogOverrides(overrides: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(overrides).filter(\n ([, replacement]) => !(typeof replacement === 'string' && replacement.startsWith(FILE_SPECIFIER_PREFIX)),\n ),\n );\n}\n\n/** The published (non-local, required) package specifiers the default and the given layers name. */\nfunction configuredPackageSpecifiers(config: MajorModesConfig, layers: readonly string[]): string[] {\n const specifiers = new Set<string>();\n const selectedDefinitions = [\n ...(config.default ? [config.default] : []),\n ...layers.map((layerName) => {\n const layer = config.layers[layerName];\n if (!layer) throw new Error(`Unknown layer: ${layerName}`);\n return layer;\n }),\n ];\n for (const layer of selectedDefinitions) {\n for (const configured of layer.packages ?? []) {\n const specifier = typeof configured === 'string' ? configured : configured.name;\n const optional = typeof configured !== 'string' && configured.optional === true;\n if (!optional && !isLocalPackageSpecifier(specifier)) specifiers.add(specifier);\n }\n }\n return [...specifiers];\n}\n\nfunction resolvePackageEntries(resolvers: ExtensionLayerResolvers, specifier: string): string[] | undefined {\n const entries = resolvers.optionalPackageEntries?.(specifier);\n if (entries !== undefined) return entries;\n const entry = resolvers.optionalPackageEntry(specifier);\n return entry ? [entry] : undefined;\n}\n\nasync function readRuntimeManifest(\n manifestPath: string,\n): Promise<{ current: string | undefined; manifest: Record<string, unknown> }> {\n const current = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (current === undefined) return { current, manifest: { name: RUNTIME_PACKAGE_NAME, private: true } };\n const parsed: unknown = JSON.parse(current);\n if (!isRecord(parsed)) throw new Error(`Po runtime package manifest at ${manifestPath} must be a JSON object.`);\n return { current, manifest: parsed };\n}\n\n/** Names the runtime manifest already declares: what earlier runs, from any root, installed there. */\nasync function declaredRuntimePackages(runtimeDirectory: string): Promise<Set<string>> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n return new Set(Object.keys(recordValue((await readRuntimeManifest(manifestPath)).manifest.dependencies)));\n}\n\n/**\n * Adds a package set and the patched transitive policy to the shared runtime manifest.\n *\n * `targets` pins names to exact versions or `workspace:*`. `catalogWorkspaces` maps each\n * staged catalogue archive's name to its directory relative to the runtime; the manifest\n * lists exactly those directories as its `workspaces`, so a catalogue package's dependency\n * on another one links the staged copy instead of reaching the registry. Both `overrides` and\n * `pnpm.overrides` are written; upm reads both.\n * With `exact`, declared names outside `sources` are dropped instead of kept.\n */\nexport async function ensureManagedPackageManifest(\n runtimeDirectory: string,\n sources: readonly string[],\n targets: ReadonlyMap<string, string> = new Map(),\n catalogWorkspaces: Readonly<Record<string, string>> = {},\n exact = false,\n): Promise<boolean> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n const { current, manifest } = await readRuntimeManifest(manifestPath);\n\n const declared = recordValue(manifest.dependencies);\n const sourceNames = new Set(sources.map(packageName));\n const dependencies = exact\n ? Object.fromEntries(Object.entries(declared).filter(([name]) => sourceNames.has(name)))\n : declared;\n // Every root shares this manifest, so a catalog archive another process staged (a desktop\n // build, say) may not exist for this one: without a staged copy here it falls back to the\n // registry, which keeps the whole set installable. `file:` targets are what earlier\n // versions wrote for archives.\n for (const [name, declared] of Object.entries(dependencies)) {\n if (Object.hasOwn(catalogWorkspaces, name)) {\n dependencies[name] = CATALOG_WORKSPACE_TARGET;\n } else if (\n typeof declared === 'string' &&\n (declared.startsWith(FILE_SPECIFIER_PREFIX) || declared.startsWith(WORKSPACE_SPECIFIER_PREFIX))\n ) {\n dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n }\n for (const source of sources) {\n const name = packageName(source);\n const target = targets.get(name);\n // An exact target is what makes an update reach the store: a package manager keeps a\n // locked version whenever the recorded range still admits it.\n if (target !== undefined) dependencies[name] = target;\n else if (!Object.hasOwn(dependencies, name)) dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n manifest.dependencies = dependencies;\n // Po owns the runtime's workspaces: exactly the staged archives, which reach only each other.\n const workspaces = Object.values(catalogWorkspaces).sort();\n if (workspaces.length > 0) manifest.workspaces = workspaces;\n else delete manifest.workspaces;\n // Nested and overlapping consumer rules can take precedence in cases that retain\n // vulnerable versions, so Po owns these package-specific selectors recursively.\n manifest.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(manifest.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n const pnpm = recordValue(manifest.pnpm);\n pnpm.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(pnpm.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n manifest.pnpm = pnpm;\n\n const serialized = `${JSON.stringify(manifest, null, 2)}\\n`;\n if (serialized === current) return false;\n await fs.mkdir(runtimeDirectory, { recursive: true });\n await writeFileAtomic(createNodePlatform().env(runtimeDirectory), manifestPath, serialized, BACKGROUND_CONTEXT);\n return true;\n}\n\n/** Finds required npm packages selected by defaults and active layers that Po cannot resolve. */\nexport function missingLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n resolvers: ExtensionLayerResolvers,\n): string[] {\n return configuredPackageSpecifiers(config, layers).filter(\n (specifier) => resolvePackageEntries(resolvers, specifier) === undefined,\n );\n}\n\n/** Whether `root`'s own node_modules chain holds the package, walked the way Node looks it up from `root`. */\nasync function ownsPackage(name: string, root: string): Promise<boolean> {\n for (let directory = path.resolve(root); ; directory = path.dirname(directory)) {\n if (\n await fs.access(path.join(directory, NODE_MODULES, name, PACKAGE_MANIFEST)).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n )\n )\n return true;\n if (path.dirname(directory) === directory) return false;\n }\n}\n\n/**\n * The required npm packages the default and the given layers name that `root` does not get\n * from its own node_modules chain: what the shared runtime provides for it, whether it does so\n * already or not yet. Sync declares exactly these, over every root, in the runtime manifest; a\n * name the runtime already provides still counts, or the next exact manifest would drop it.\n */\nexport async function runtimeLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n root: string,\n): Promise<string[]> {\n const specifiers = configuredPackageSpecifiers(config, layers);\n const owned = await Promise.all(\n specifiers.map((specifier) => ownsPackage(splitPackageSpecifier(specifier).name, root)),\n );\n return specifiers.filter((_specifier, index) => !owned[index]);\n}\n\nfunction packageName(source: string): string {\n const specifier = source.startsWith(NPM_SOURCE_PREFIX) ? source.slice(NPM_SOURCE_PREFIX.length) : source;\n if (specifier.startsWith('@')) {\n const slash = specifier.indexOf('/');\n const version = slash === -1 ? -1 : specifier.indexOf('@', slash);\n return version === -1 ? specifier : specifier.slice(0, version);\n }\n const version = specifier.indexOf('@');\n return version === -1 ? specifier : specifier.slice(0, version);\n}\n\ninterface PackageCatalogEntry {\n /** Absolute path of the bundled archive; it takes precedence over `version`. */\n archive?: string;\n /** Exact registry version, pinned when the entry has no archive. */\n version?: string;\n dependencies: readonly string[];\n}\n\ninterface PackageCatalog {\n packages: ReadonlyMap<string, PackageCatalogEntry>;\n /** Feature packages Po installs out of the box, by name. */\n install: readonly string[];\n}\n\nconst EMPTY_CATALOG: PackageCatalog = { packages: new Map(), install: [] };\n\nfunction stringList(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const strings = value.filter((item): item is string => typeof item === 'string');\n return strings.length === value.length ? strings : undefined;\n}\n\nfunction defaultBundledCatalogPath(): string | undefined {\n try {\n return path.join(poPackageRoot(), ...BUNDLED_CATALOG_SEGMENTS);\n } catch {\n // A bundle with no locatable Po package root has no bundled catalogue to read.\n return undefined;\n }\n}\n\n/**\n * The first catalogue present: `PO_PACKAGE_CATALOG` (desktop's archives), then the one\n * a release bundles into the CLI. With neither, the runtime installs only what roots name.\n */\nasync function packageCatalogPath(environment: NodeJS.ProcessEnv): Promise<string | undefined> {\n const configured = environment[PACKAGE_CATALOG_ENV]?.trim();\n if (configured) return configured;\n const bundledCatalogPath = defaultBundledCatalogPath();\n if (bundledCatalogPath === undefined) return undefined;\n return fs.access(bundledCatalogPath).then(\n () => bundledCatalogPath,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\nasync function readPackageCatalog(manifestPath: string | undefined): Promise<PackageCatalog> {\n if (!manifestPath) return EMPTY_CATALOG;\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n if (!isRecord(parsed) || parsed.version !== 1 || !isRecord(parsed.packages)) {\n throw new Error(`Unsupported Po package catalog: ${manifestPath}`);\n }\n const packages = new Map<string, PackageCatalogEntry>();\n for (const [name, value] of Object.entries(parsed.packages)) {\n if (\n !isRecord(value) ||\n !Array.isArray(value.dependencies) ||\n (value.archive !== undefined && typeof value.archive !== 'string') ||\n (value.version !== undefined && typeof value.version !== 'string') ||\n (value.archive === undefined && value.version === undefined)\n ) {\n throw new Error(`Invalid package entry for ${name} in ${manifestPath}`);\n }\n const dependencies = stringList(value.dependencies);\n if (!dependencies) throw new Error(`Invalid dependencies for ${name} in ${manifestPath}`);\n const version = typeof value.version === 'string' ? value.version : undefined;\n if (typeof value.archive !== 'string') {\n packages.set(name, { version, dependencies });\n continue;\n }\n const archive = path.resolve(path.dirname(manifestPath), value.archive);\n await fs.access(archive).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive is missing: ${archive}`);\n throw error;\n });\n packages.set(name, { archive, version, dependencies });\n }\n const install = parsed.install === undefined ? [] : stringList(parsed.install);\n if (!install) throw new Error(`Invalid install list in ${manifestPath}`);\n const unknown = install.filter((name) => !packages.has(name));\n if (unknown.length > 0) throw new Error(`Po package catalog installs unlisted package(s): ${unknown.join(', ')}`);\n return { packages, install };\n}\n\n/**\n * The catalogue's `install` list as exact `name@version` specifiers for\n * `EnsureLayerPackagesOptions.specifiers`; empty when no catalogue is present.\n */\nexport async function catalogInstallSpecifiers(environment: NodeJS.ProcessEnv = process.env): Promise<string[]> {\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n return catalog.install.map((name) => {\n const version = catalog.packages.get(name)?.version;\n return version ? `${name}@${version}` : name;\n });\n}\n\n/**\n * The installed package roots of the catalogue's `install` list, resolved the way a root\n * resolves a bare name (its own node_modules, then the shared runtime). The global web build\n * covers them, so every first-party plugin has a slot; a name not installed yet is left out.\n */\nexport async function catalogPackageRoots(\n globalRoot: string,\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<string[]> {\n const roots: string[] = [];\n for (const name of (await readPackageCatalog(await packageCatalogPath(environment))).install) {\n const manifest = consumerPackageEntry(`${name}/${PACKAGE_MANIFEST}`, globalRoot, environment);\n if (manifest !== undefined) roots.push(path.dirname(await fs.realpath(manifest)));\n }\n return roots;\n}\n\n/** SHA-256 of the catalogue file in use, or `none` when no catalogue is present. */\nexport async function packageCatalogHash(environment: NodeJS.ProcessEnv = process.env): Promise<string> {\n const catalogPath = await packageCatalogPath(environment);\n if (!catalogPath) return 'none';\n return crypto\n .createHash('sha256')\n .update(await fs.readFile(catalogPath))\n .digest('hex');\n}\n\n/** Exact target per catalogue name: its staged workspace for an archive, else its registry version. */\nfunction catalogTargets(catalog: PackageCatalog): Map<string, string> {\n return new Map(\n [...catalog.packages].flatMap(([name, entry]) => {\n if (entry.archive !== undefined) return [[name, CATALOG_WORKSPACE_TARGET] as const];\n return entry.version !== undefined ? [[name, entry.version] as const] : [];\n }),\n );\n}\n\nconst TAR_BLOCK_SIZE = 512;\nconst TAR_EXECUTABLE_BITS = 0o111;\n\nfunction tarString(block: Buffer, start: number, length: number): string {\n const field = block.subarray(start, start + length);\n const end = field.indexOf(0);\n return field.subarray(0, end === -1 ? field.length : end).toString('utf8');\n}\n\nfunction tarNumber(block: Buffer, start: number, length: number): number {\n const field = block.subarray(start, start + length);\n // GNU base-256: the high bit of the first byte marks a big-endian binary number.\n if ((field[0]! & 0x80) !== 0) return field.subarray(1).reduce((value, byte) => value * 256 + byte, field[0]! & 0x7f);\n const text = tarString(block, start, length).trim();\n return text === '' ? 0 : Number.parseInt(text, 8);\n}\n\n/** The `path` record of a pax extended header, if it has one. */\nfunction paxPath(data: Buffer): string | undefined {\n let found: string | undefined;\n let offset = 0;\n while (offset < data.length) {\n const space = data.indexOf(0x20, offset);\n if (space === -1) break;\n const length = Number.parseInt(data.subarray(offset, space).toString('utf8'), 10);\n if (!Number.isFinite(length) || length <= 0) break;\n const record = data.subarray(space + 1, offset + length - 1).toString('utf8');\n const separator = record.indexOf('=');\n if (record.slice(0, separator) === 'path') found = record.slice(separator + 1);\n offset += length;\n }\n return found;\n}\n\n/**\n * Unpacks a gzipped npm package archive into `destination`, dropping the archive's top\n * directory (`package/`) as npm does. Only files and directories are written: npm package\n * archives carry no links, and an entry that would land outside `destination` is refused.\n */\nasync function extractPackageArchive(archive: string, destination: string): Promise<void> {\n const data = zlib.gunzipSync(await fs.readFile(archive));\n let offset = 0;\n let nextPath: string | undefined;\n while (offset + TAR_BLOCK_SIZE <= data.length) {\n const header = data.subarray(offset, offset + TAR_BLOCK_SIZE);\n if (header.every((byte) => byte === 0)) break;\n const size = tarNumber(header, 124, 12);\n const type = String.fromCharCode(header[156]!);\n const body = data.subarray(offset + TAR_BLOCK_SIZE, offset + TAR_BLOCK_SIZE + size);\n offset += TAR_BLOCK_SIZE + Math.ceil(size / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;\n if (type === 'x' || type === 'L') {\n nextPath = type === 'x' ? (paxPath(body) ?? nextPath) : tarString(body, 0, body.length);\n continue;\n }\n if (type === 'g') continue;\n const prefix = tarString(header, 345, 155);\n const name = nextPath ?? (prefix ? `${prefix}/${tarString(header, 0, 100)}` : tarString(header, 0, 100));\n nextPath = undefined;\n if (type !== '0' && type !== '\\0' && type !== '5') continue;\n const relative = name.split('/').slice(1).join('/');\n if (relative === '') continue;\n const target = path.resolve(destination, relative);\n if (!target.startsWith(`${destination}${path.sep}`)) {\n throw new Error(`Po package catalog archive ${archive} has an entry outside the package: ${name}`);\n }\n if (type === '5') {\n await fs.mkdir(target, { recursive: true });\n continue;\n }\n await fs.mkdir(path.dirname(target), { recursive: true });\n const executable = (tarNumber(header, 100, 8) & TAR_EXECUTABLE_BITS) !== 0;\n await fs.writeFile(target, body, { mode: executable ? 0o755 : 0o644 });\n }\n}\n\n/** Dependency fields of a staged manifest that may name another catalogue package. */\nconst STAGED_DEPENDENCY_FIELDS = ['dependencies', 'optionalDependencies', 'peerDependencies'] as const;\n\n/**\n * Unpacks one catalogue archive into `<runtime>/catalog/<hash>` and returns that directory\n * relative to the runtime, with the catalogue names its manifest depends on.\n *\n * upm only installs a package from a directory as a workspace: a `file:` archive takes its own\n * dependencies from the registry, so one catalogue archive could not depend on another. In the\n * staged manifest every dependency on another catalogue archive becomes `workspace:*`, so the\n * catalogue's copy wins whatever range the package declared, and `devDependencies`, which a\n * workspace would otherwise install, are dropped. The hash covers the archive bytes and the\n * catalogue's archive names, everything that rewrite reads, so a staged directory is reused.\n */\nasync function stageCatalogArchive(\n runtimeDirectory: string,\n archive: string,\n archiveNames: ReadonlySet<string>,\n): Promise<{ relative: string; dependencies: string[] }> {\n const hash = crypto\n .createHash('sha256')\n .update(await fs.readFile(archive))\n .update(`\\0${[...archiveNames].sort().join('\\n')}`)\n .digest('hex');\n const relative = `${CATALOG_STAGING_DIRECTORY}/${hash}`;\n const directory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY, hash);\n const stagedManifest = path.join(directory, PACKAGE_MANIFEST);\n const existing = await fs.readFile(stagedManifest, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === undefined) {\n const temporary = `${directory}.${String(process.pid)}.${crypto.randomUUID()}.tmp`;\n try {\n await extractPackageArchive(archive, temporary);\n const manifestPath = path.join(temporary, PACKAGE_MANIFEST);\n const bytes = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive has no package.json: ${archive}`);\n throw error;\n });\n const manifest: unknown = JSON.parse(bytes);\n if (!isRecord(manifest)) throw new Error(`Po package catalog archive has an invalid package.json: ${archive}`);\n delete manifest.devDependencies;\n for (const field of STAGED_DEPENDENCY_FIELDS) {\n if (!isRecord(manifest[field])) continue;\n const declared = { ...manifest[field] };\n for (const name of Object.keys(declared)) {\n if (archiveNames.has(name)) declared[name] = CATALOG_WORKSPACE_TARGET;\n }\n manifest[field] = declared;\n }\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`);\n try {\n await fs.rename(temporary, directory);\n } catch (error) {\n // Another process staged the same bytes first; its copy is identical.\n await fs.access(stagedManifest).catch(() => {\n throw error;\n });\n }\n } finally {\n await fs.rm(temporary, { recursive: true, force: true });\n }\n }\n const staged = recordValue(JSON.parse(existing ?? (await fs.readFile(stagedManifest, 'utf8'))));\n const dependencies = STAGED_DEPENDENCY_FIELDS.flatMap((field) => Object.keys(recordValue(staged[field])));\n return { relative, dependencies: dependencies.filter((name) => archiveNames.has(name)) };\n}\n\n/**\n * Stages the archive of every named catalogue package and of every catalogue package those\n * name in turn, since a staged manifest's `workspace:*` needs that workspace present. The\n * result, name to staged directory, feeds `ensureManagedPackageManifest`.\n */\nasync function stageCatalogArchives(\n runtimeDirectory: string,\n catalog: PackageCatalog,\n names: Iterable<string>,\n): Promise<Record<string, string>> {\n const archiveNames = new Set(\n [...catalog.packages].flatMap(([name, entry]) => (entry.archive === undefined ? [] : [name])),\n );\n const staged: Record<string, string> = {};\n const pending = [...names].filter((name) => archiveNames.has(name));\n while (pending.length > 0) {\n const name = pending.shift()!;\n if (Object.hasOwn(staged, name)) continue;\n const { relative, dependencies } = await stageCatalogArchive(\n runtimeDirectory,\n catalog.packages.get(name)!.archive!,\n archiveNames,\n );\n staged[name] = relative;\n pending.push(...dependencies);\n }\n return staged;\n}\n\n/**\n * Removes staged archives the runtime manifest no longer lists as workspaces, and returns their\n * folder names. An install never calls this: a running server imports from these folders (its\n * `.po-snapshots` live there), so sync prunes them under the same gate as the runtime store.\n */\nexport async function pruneStagedCatalogArchives(runtimeDirectory: string): Promise<string[]> {\n const stagingDirectory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY);\n const entries = await fs.readdir(stagingDirectory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const { manifest } = await readRuntimeManifest(path.join(runtimeDirectory, PACKAGE_MANIFEST));\n const kept = new Set((stringList(manifest.workspaces) ?? []).map((relative) => path.basename(relative)));\n return Promise.all(\n entries\n .filter((entry) => !kept.has(entry))\n .map(async (entry) => {\n await fs.rm(path.join(stagingDirectory, entry), { recursive: true, force: true });\n return entry;\n }),\n );\n}\n\n/** Splits `name@version` (scoped or not); the version is absent for a bare name or subpath. */\nfunction splitVersionedSpecifier(specifier: string): { name: string; version?: string } {\n const separator = specifier.indexOf('@', specifier.startsWith('@') ? 1 : 0);\n if (separator === -1) return { name: splitPackageSpecifier(specifier).name };\n return { name: specifier.slice(0, separator), version: specifier.slice(separator + 1) };\n}\n\nfunction npmSources(\n specifiers: readonly string[],\n catalog: PackageCatalog,\n targets: ReadonlyMap<string, string>,\n includeCatalogDependencies = false,\n): string[] {\n const names = [...new Set(specifiers.map((specifier) => splitPackageSpecifier(specifier).name))];\n if (includeCatalogDependencies) {\n for (let index = 0; index < names.length; index += 1) {\n for (const dependency of catalog.packages.get(names[index]!)?.dependencies ?? []) {\n if (!names.includes(dependency)) names.push(dependency);\n }\n }\n }\n return names.map((name) => {\n const target = targets.get(name);\n return `${NPM_SOURCE_PREFIX}${name}${target ? `@${target}` : ''}`;\n });\n}\n\nfunction pluralize(count: number, noun: string): string {\n return `${count} ${noun}${count === 1 ? '' : 's'}`;\n}\n\n/** Version of a package inside the shared runtime, absent when Po did not install it there. */\nasync function managedPackageVersion(runtimeDirectory: string, name: string): Promise<string | undefined> {\n const manifestPath = path.join(runtimeDirectory, NODE_MODULES, name, PACKAGE_MANIFEST);\n try {\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n return isRecord(parsed) && typeof parsed.version === 'string' ? parsed.version : undefined;\n } catch {\n // An unreadable manifest carries the same meaning as an absent one: nothing\n // usable is installed, so the caller treats the package as uninstalled.\n return undefined;\n }\n}\n\nfunction errorCode(error: unknown): unknown {\n return typeof error === 'object' && error !== null ? (error as { code?: unknown }).code : undefined;\n}\n\n/**\n * Installs the runtime, and when the registry cannot be reached installs it again offline:\n * an unchanged lockfile whose packages the store already holds needs no network.\n */\nasync function installWithOfflineRetry(\n install: NonNullable<LayerPackageInstallerDependencies['install']>,\n options: InstallRuntimePackagesOptions,\n onProgress: ((message: string) => void) | undefined,\n): Promise<void> {\n try {\n await install(options);\n } catch (error) {\n const code = errorCode(error);\n if (typeof code !== 'string' || !NETWORK_FAILURE_CODES.has(code)) throw error;\n onProgress?.(`the registry is unreachable (${code}); installing offline from the store`);\n try {\n await install({ ...options, preferOffline: false, offline: true });\n } catch {\n // The offline attempt only ever narrows the original failure: the network error\n // explains why the install could not complete, an EOFFLINE miss does not.\n throw error;\n }\n }\n}\n\ninterface CheckedPackage {\n name: string;\n from: string;\n to?: string;\n failure?: string;\n}\n\n/**\n * Compares every package sync installed against the registry.\n *\n * Only the shared runtime is consulted: a package that resolves from the\n * repository's own modules is not sync's to move, and a package that is not\n * installed yet is already covered by the missing-package path.\n */\nasync function resolveUpdates(\n runtimeDirectory: string,\n sources: readonly string[],\n publishedVersion: (name: string) => Promise<string>,\n onProgress: ((message: string) => void) | undefined,\n): Promise<Pick<LayerPackageResult, 'updated' | 'unchecked'>> {\n const managed = (\n await Promise.all(\n sources.map(async (source) => ({\n name: packageName(source),\n from: await managedPackageVersion(runtimeDirectory, packageName(source)),\n })),\n )\n ).filter((entry): entry is { name: string; from: string } => entry.from !== undefined);\n const checked: CheckedPackage[] = await Promise.all(\n managed.map(async (entry) => {\n try {\n return { ...entry, to: await publishedVersion(entry.name) };\n } catch (error) {\n return { ...entry, failure: (error instanceof Error ? error.message : String(error)).split('\\n')[0] };\n }\n }),\n );\n\n const updated: LayerPackageUpdate[] = [];\n const unchecked: string[] = [];\n for (const entry of checked) {\n if (entry.to === undefined) {\n unchecked.push(entry.name);\n onProgress?.(`kept ${entry.name} ${entry.from}: ${entry.failure ?? 'no published version'}`);\n continue;\n }\n if (entry.to === entry.from) continue;\n updated.push({ name: entry.name, from: entry.from, to: entry.to });\n onProgress?.(`${entry.name} ${entry.from} -> ${entry.to}`);\n }\n return { updated, unchecked };\n}\n\n/**\n * Installs the selected layer packages a root cannot resolve into the shared runtime,\n * `<po home>/runtime`, and verifies they now resolve.\n *\n * The runtime manifest is the union of what every root asked for. A root adds the\n * packages it is missing; a package it already resolves from its own node_modules stays\n * out unless an earlier run put it there. One name has one version: an exact target\n * (a sync update, a catalog archive or registry pin) replaces the declared range, last\n * writer wins, and a plain `*` never replaces a range already declared.\n *\n * `specifiers` and `exactManifest` only add behaviour: without them, and without a\n * catalogue, a run behaves as it always has.\n */\nexport async function ensureLayerPackages(\n options: EnsureLayerPackagesOptions,\n dependencies: LayerPackageInstallerDependencies = {},\n): Promise<LayerPackageResult> {\n const environment = options.environment ?? process.env;\n const homeDirectory = environment.HOME ?? os.homedir();\n const poHome = poHomeDirectory(homeDirectory, environment);\n const runtimeDirectory = poRuntimeDirectory(homeDirectory, environment);\n const resolvers = dependencies.resolvers ?? createLayerResolvers(options.repoRoot, environment);\n const external = (specifier: string): boolean => testPackageRoot(packageName(specifier), environment) === undefined;\n const configured = configuredPackageSpecifiers(options.config, options.layers).filter(external);\n const missing = configured.filter((specifier) => resolvePackageEntries(resolvers, specifier) === undefined);\n const declared = await declaredRuntimePackages(runtimeDirectory);\n const managed = configured.filter(\n (specifier) => missing.includes(specifier) || declared.has(splitPackageSpecifier(specifier).name),\n );\n const requested = (options.specifiers ?? []).filter(external).map(splitVersionedSpecifier);\n if (managed.length === 0 && requested.length === 0 && options.exactManifest !== true) {\n return { installed: [], updated: [], unchecked: [] };\n }\n\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n const pins = catalogTargets(catalog);\n for (const { name, version } of requested) {\n if (version !== undefined && catalog.packages.get(name)?.archive === undefined) pins.set(name, version);\n }\n // A requested package is missing until the runtime holds it at the version it is pinned to.\n const requestedMissing: string[] = [];\n for (const { name, version } of requested) {\n const installed = await managedPackageVersion(runtimeDirectory, name);\n const entry = catalog.packages.get(name);\n const expected = entry?.archive === undefined ? version : entry.version;\n if (installed === undefined || (expected !== undefined && installed !== expected)) requestedMissing.push(name);\n }\n const missingSources = npmSources([...missing, ...requestedMissing], catalog, pins);\n const sources = npmSources([...managed, ...requested.map(({ name }) => name)], catalog, pins, true).filter(external);\n const missingCount = missing.length + requestedMissing.length;\n\n // Refresh never moves a pinned name: catalogue entries and versioned specifiers stay put.\n const fixedNames = new Set([\n ...catalog.packages.keys(),\n ...requested.filter(({ version }) => version !== undefined).map(({ name }) => name),\n ]);\n const registrySources = sources.filter((source) => !fixedNames.has(packageName(source)));\n const { updated, unchecked } = options.refresh\n ? await resolveUpdates(\n runtimeDirectory,\n registrySources,\n dependencies.publishedVersion ?? ((name) => resolveNewest(name, { dir: runtimeDirectory, poHome })),\n options.onProgress,\n )\n : { updated: [], unchecked: [] };\n const targets = new Map(\n sources.flatMap((source) => {\n const target = pins.get(packageName(source));\n return target ? [[packageName(source), target] as const] : [];\n }),\n );\n for (const update of updated) targets.set(update.name, update.to);\n // A kept manifest still declares names earlier runs added; their archives are staged too.\n const stagedNames = new Set([...sources.map(packageName), ...(options.exactManifest === true ? [] : declared)]);\n const staged = await stageCatalogArchives(runtimeDirectory, catalog, stagedNames);\n const manifestChanged = await ensureManagedPackageManifest(\n runtimeDirectory,\n sources,\n targets,\n staged,\n options.exactManifest === true,\n );\n if (missingCount === 0 && !manifestChanged) return { installed: [], updated: [], unchecked };\n\n options.onProgress?.(\n `installing ${\n updated.length > 0\n ? pluralize(updated.length, 'update')\n : missingCount > 0\n ? pluralize(missingCount, 'missing package')\n : 'the package manifest'\n }`,\n );\n try {\n // One install reconciles the complete dependency set written to package.json.\n await installWithOfflineRetry(\n dependencies.install ?? installRuntimePackages,\n {\n dir: runtimeDirectory,\n poHome,\n // A launch never waits on registry revalidation; sync is the command that refreshes.\n preferOffline: options.refresh !== true,\n log: (message, level) => {\n if (level === 'warn') options.onProgress?.(message);\n },\n },\n options.onProgress,\n );\n } catch (error) {\n const attempted = manifestChanged ? sources : missingSources;\n throw new Error(\n `Failed to reconcile Po layer package(s): ${attempted.join(', ')}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n\n const unresolved = missing.filter((specifier) => !resolvePackageEntries(resolvers, specifier)?.length);\n if (unresolved.length > 0) {\n throw new Error(\n `Installed Po layer package(s) did not expose the configured Pi extension: ${unresolved.join(', ')}`,\n );\n }\n return { installed: missingSources, updated, unchecked };\n}\n\n/** One selector per name in the shared runtime. Caller holds the sync lock throughout. */\nexport async function ensureRuntimeImportPackage(\n name: string,\n version: string,\n options: { homeDirectory: string; environment: Readonly<Record<string, string | undefined>> },\n): Promise<void> {\n const environment = { ...options.environment, HOME: options.homeDirectory };\n const poHome = poHomeDirectory(options.homeDirectory, environment);\n const directory = poRuntimeDirectory(options.homeDirectory, environment);\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n const { manifest } = await readRuntimeManifest(manifestPath);\n const declared = recordValue(manifest.dependencies);\n const imports = recordValue(manifest.poCodemodeDependencies);\n const imported = recordValue(imports[name]);\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n if (catalog.packages.has(name) || (Object.hasOwn(declared, name) && declared[name] !== imported.selector)) {\n throw new Error(\n `Cannot import ${name}: Po manages this runtime dependency (${JSON.stringify(declared[name] ?? 'catalogue')}).`,\n );\n }\n if (Object.hasOwn(imports, name) && imported.selector !== version) {\n throw new Error(`Cannot import ${name}@${version}: the hub already uses ${name}@${String(imported.selector)}.`);\n }\n const installed = await managedPackageVersion(directory, name);\n if (declared[name] === version && installed !== undefined && imported.resolved === installed) return;\n // Only a successful reconciliation is cacheable, not the manifest upm writes ahead of a failed install.\n manifest.poCodemodeDependencies = { ...imports, [name]: { selector: version } };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(manifest, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n const pins = new Map([[name, version]]);\n const sources = npmSources([`${name}@${version}`], catalog, pins, true);\n const staged = await stageCatalogArchives(\n directory,\n catalog,\n new Set([...sources.map(packageName), ...Object.keys(declared)]),\n );\n await ensureManagedPackageManifest(directory, sources, pins, staged);\n await installWithOfflineRetry(installRuntimePackages, { dir: directory, poHome, preferOffline: true }, undefined);\n const resolved = await managedPackageVersion(directory, name);\n if (resolved === undefined) throw new Error(`Runtime import ${name}@${version} was not installed.`);\n const reconciled = (await readRuntimeManifest(manifestPath)).manifest;\n reconciled.poCodemodeDependencies = {\n ...recordValue(reconciled.poCodemodeDependencies),\n [name]: { selector: version, resolved },\n };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(reconciled, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,6BAA6B;;AAEnC,MAAM,2BAA2B;;AAE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CACtC,MAAM,UAAU,WAAW,CAAC,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,MAAM,IAAI;CAMtE,MAAM,6BAA6B,WAAW,SAAS,MAAM,MALxC,qBACnB,WACA,yBACA,IAAI,IAAI,CAAC,GAAG,QAAQ,IAAI,WAAW,GAAG,GAAG,OAAO,KAAK,QAAQ,CAAC,CAAC,CACjE,CACmE;CACnE,MAAM,wBAAwBY,mCAAAA,wBAAwB;EAAE,KAAK;EAAW;EAAQ,eAAe;CAAK,GAAG,KAAA,CAAS;CAChH,MAAM,WAAW,MAAM,sBAAsB,WAAW,IAAI;CAC5D,IAAI,aAAa,KAAA,GAAW,MAAM,IAAI,MAAM,kBAAkB,KAAK,GAAG,QAAQ,oBAAoB;CAClG,MAAM,cAAc,MAAM,oBAAoB,YAAY,EAAA,CAAG;CAC7D,WAAW,yBAAyB;EAClC,GAAG,YAAY,WAAW,sBAAsB;GAC/C,OAAO;GAAE,UAAU;GAAS;EAAS;CACxC;CACA,OAAA,GAAMd,4BAAAA,gBAAAA,EAAAA,GACJC,gCAAAA,mBAAAA,CAAmB,CAAC,CAAC,IAAI,SAAS,GAClC,cACA,GAAG,KAAK,UAAU,YAAY,MAAM,CAAC,EAAE,KACvCC,4BAAAA,kBACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isLocalPackageSpecifier","fs","path","writeFileAtomic","createNodePlatform","BACKGROUND_CONTEXT","splitPackageSpecifier","poPackageRoot","consumerPackageEntry","crypto","zlib","os","poHomeDirectory","poRuntimeDirectory","createLayerResolvers","testPackageRoot","resolveNewest","installRuntimePackages"],"sources":["../../../../src/composition/layerPackageInstaller/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { isLocalPackageSpecifier, type MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nimport { consumerPackageEntry, splitPackageSpecifier, testPackageRoot } from '@agimon-ai/po-core/moduleResolution';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { BACKGROUND_CONTEXT, writeFileAtomic } from '@agimon-ai/po-core/platform';\nimport {\n installRuntimePackages,\n type InstallRuntimePackagesOptions,\n resolveNewest,\n} from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { createLayerResolvers, type ExtensionLayerResolvers } from '../../builders/cli/extensionAssembler';\n\nconst NPM_SOURCE_PREFIX = 'npm:';\nconst FILE_SPECIFIER_PREFIX = 'file:';\nconst WORKSPACE_SPECIFIER_PREFIX = 'workspace:';\n/** Root target of a staged catalogue archive: always the staged workspace, never the registry. */\nconst CATALOG_WORKSPACE_TARGET = 'workspace:*';\n/** Where catalogue archives are unpacked inside the runtime, one directory per archive hash. */\nconst CATALOG_STAGING_DIRECTORY = 'catalog';\nconst RUNTIME_PACKAGE_NAME = 'po-runtime';\nconst UNPINNED_PACKAGE_RANGE = '*';\nconst PACKAGE_MANIFEST = 'package.json';\nconst NODE_MODULES = 'node_modules';\nconst PACKAGE_CATALOG_ENV = 'PO_PACKAGE_CATALOG';\n/** The registry catalogue a release writes into the CLI package: `<package root>/dist/catalog/index.json`. */\nconst BUNDLED_CATALOG_SEGMENTS = ['dist', 'catalog', 'index.json'] as const;\n/** upm error codes that mean the registry could not be reached, so the store may still answer. */\nconst NETWORK_FAILURE_CODES = new Set(['ENETWORK', 'ETIMEDOUT', 'EREGISTRY']);\n\nfunction overridePackageName(selector: string): string {\n const separatorIndex = selector.indexOf('@', selector.startsWith('@') ? 1 : 0);\n return separatorIndex === -1 ? selector : selector.slice(0, separatorIndex);\n}\n\n/**\n * Runtime compatibility pins and same-major patches for current foundation packages.\n * Package managers only honor overrides from the install root, so published extensions\n * cannot carry these fixes in their own manifests.\n */\nexport const SAFE_TRANSITIVE_OVERRIDES = {\n // ponytail: Pin for Pi 1.4.0's declaration API; advance with the host's Pi version.\n '@earendil-works/pi-codemode': '1.4.0',\n '@hono/node-server@2.0.0 - 2.0.9': '^2.0.10',\n '@opentelemetry/core@2.0.0 - 2.7.999': '2.8.0',\n 'brace-expansion@1.0.0 - 1.1.20': '^1.1.21',\n 'brace-expansion@5.0.0 - 5.0.11': '^5.0.12',\n 'hono@4.0.0 - 4.13.7': '4.13.8',\n 'js-yaml@4.0.0 - 4.3.1': '^4.3.2',\n 'js-yaml@5.0.0 - 5.2.1': '^5.2.2',\n 'liquidjs@10.0.0 - 10.27.1': '^10.27.2',\n 'protobufjs@8.0.0 - 8.7.1': '^8.7.2',\n 'undici@7.0.0 - 7.29.0': '^7.29.1',\n} as const satisfies Readonly<Record<string, string>>;\n\nconst SAFE_TRANSITIVE_PACKAGE_NAMES = new Set(Object.keys(SAFE_TRANSITIVE_OVERRIDES).map(overridePackageName));\n\nexport interface EnsureLayerPackagesOptions {\n /**\n * The Po root whose layers name the packages. Its own node_modules chain is\n * resolved first; what it cannot provide is installed into the one runtime\n * every root shares, `<po home>/runtime`.\n */\n repoRoot: string;\n config: MajorModesConfig;\n layers: readonly string[];\n environment?: NodeJS.ProcessEnv;\n /**\n * Move every managed package to its newest published version.\n *\n * Launch installs what a selection needs and nothing more, so a session never\n * pays for a registry round trip. Sync is the explicit maintenance command and\n * is the only caller that asks for this.\n */\n refresh?: boolean;\n /**\n * Packages installed into the runtime whatever the root resolves itself, such as the\n * catalogue's `install` list. A `name@version` specifier pins that exact version; a\n * catalogue archive for the name still wins. Refresh never moves a pinned name.\n */\n specifiers?: readonly string[];\n /**\n * Make the runtime manifest declare exactly this run's packages (the specifiers, the\n * selected names and their catalogue dependencies), so pruning can drop anything else.\n * Without it the manifest only grows.\n */\n exactManifest?: boolean;\n /** Receives one human-readable line per package decision. */\n onProgress?: (message: string) => void;\n}\n\nexport interface LayerPackageInstallerDependencies {\n /** Install seam; the default installs `<po home>/runtime` with upm. */\n install?: (options: InstallRuntimePackagesOptions) => Promise<unknown>;\n resolvers?: ExtensionLayerResolvers;\n /** Registry lookup seam; the default resolves the newest allowed version with upm. */\n publishedVersion?: (name: string) => Promise<string>;\n}\n\n/** One managed package moving from the installed version to the newest published one. */\nexport interface LayerPackageUpdate {\n name: string;\n from: string;\n to: string;\n}\n\nexport interface LayerPackageResult {\n /** Sources installed because a configured extension could not be resolved. */\n installed: string[];\n /** Packages this run moved to a newer published version. */\n updated: LayerPackageUpdate[];\n /** Packages left at the installed version because the registry could not be read. */\n unchecked: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction recordValue(value: unknown): Record<string, unknown> {\n return isRecord(value) ? { ...value } : {};\n}\n\nfunction withoutConflictingTransitiveOverrides(value: unknown): Record<string, unknown> {\n const overrides = recordValue(value);\n for (const [selector, replacement] of Object.entries(overrides)) {\n if (SAFE_TRANSITIVE_PACKAGE_NAMES.has(overridePackageName(selector))) {\n delete overrides[selector];\n } else if (isRecord(replacement)) {\n overrides[selector] = withoutConflictingTransitiveOverrides(replacement);\n }\n }\n return overrides;\n}\n\n/** Earlier versions overrode catalog packages with relative `file:` targets; any other override is not Po's. */\nfunction withoutCatalogOverrides(overrides: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(overrides).filter(\n ([, replacement]) => !(typeof replacement === 'string' && replacement.startsWith(FILE_SPECIFIER_PREFIX)),\n ),\n );\n}\n\n/** The published (non-local, required) package specifiers the default and the given layers name. */\nfunction configuredPackageSpecifiers(config: MajorModesConfig, layers: readonly string[]): string[] {\n const specifiers = new Set<string>();\n const selectedDefinitions = [\n ...(config.default ? [config.default] : []),\n ...layers.map((layerName) => {\n const layer = config.layers[layerName];\n if (!layer) throw new Error(`Unknown layer: ${layerName}`);\n return layer;\n }),\n ];\n for (const layer of selectedDefinitions) {\n for (const configured of layer.packages ?? []) {\n const specifier = typeof configured === 'string' ? configured : configured.name;\n const optional = typeof configured !== 'string' && configured.optional === true;\n if (!optional && !isLocalPackageSpecifier(specifier)) specifiers.add(specifier);\n }\n }\n return [...specifiers];\n}\n\nfunction resolvePackageEntries(resolvers: ExtensionLayerResolvers, specifier: string): string[] | undefined {\n const entries = resolvers.optionalPackageEntries?.(specifier);\n if (entries !== undefined) return entries;\n const entry = resolvers.optionalPackageEntry(specifier);\n return entry ? [entry] : undefined;\n}\n\nasync function readRuntimeManifest(\n manifestPath: string,\n): Promise<{ current: string | undefined; manifest: Record<string, unknown> }> {\n const current = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (current === undefined) return { current, manifest: { name: RUNTIME_PACKAGE_NAME, private: true } };\n const parsed: unknown = JSON.parse(current);\n if (!isRecord(parsed)) throw new Error(`Po runtime package manifest at ${manifestPath} must be a JSON object.`);\n return { current, manifest: parsed };\n}\n\n/** Names the runtime manifest already declares: what earlier runs, from any root, installed there. */\nasync function declaredRuntimePackages(runtimeDirectory: string): Promise<Set<string>> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n return new Set(Object.keys(recordValue((await readRuntimeManifest(manifestPath)).manifest.dependencies)));\n}\n\n/**\n * Adds a package set and the patched transitive policy to the shared runtime manifest.\n *\n * `targets` pins names to exact versions or `workspace:*`. `catalogWorkspaces` maps each\n * staged catalogue archive's name to its directory relative to the runtime; the manifest\n * lists exactly those directories as its `workspaces`, so a catalogue package's dependency\n * on another one links the staged copy instead of reaching the registry. Both `overrides` and\n * `pnpm.overrides` are written; upm reads both.\n * With `exact`, declared names outside `sources` are dropped instead of kept.\n */\nexport async function ensureManagedPackageManifest(\n runtimeDirectory: string,\n sources: readonly string[],\n targets: ReadonlyMap<string, string> = new Map(),\n catalogWorkspaces: Readonly<Record<string, string>> = {},\n exact = false,\n): Promise<boolean> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n const { current, manifest } = await readRuntimeManifest(manifestPath);\n\n const declared = recordValue(manifest.dependencies);\n const sourceNames = new Set(sources.map(packageName));\n const dependencies = exact\n ? Object.fromEntries(Object.entries(declared).filter(([name]) => sourceNames.has(name)))\n : declared;\n // Every root shares this manifest, so a catalog archive another process staged (a desktop\n // build, say) may not exist for this one: without a staged copy here it falls back to the\n // registry, which keeps the whole set installable. `file:` targets are what earlier\n // versions wrote for archives.\n for (const [name, declared] of Object.entries(dependencies)) {\n if (Object.hasOwn(catalogWorkspaces, name)) {\n dependencies[name] = CATALOG_WORKSPACE_TARGET;\n } else if (\n typeof declared === 'string' &&\n (declared.startsWith(FILE_SPECIFIER_PREFIX) || declared.startsWith(WORKSPACE_SPECIFIER_PREFIX))\n ) {\n dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n }\n for (const source of sources) {\n const name = packageName(source);\n const target = targets.get(name);\n // An exact target is what makes an update reach the store: a package manager keeps a\n // locked version whenever the recorded range still admits it.\n if (target !== undefined) dependencies[name] = target;\n else if (!Object.hasOwn(dependencies, name)) dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n manifest.dependencies = dependencies;\n // Po owns the runtime's workspaces: exactly the staged archives, which reach only each other.\n const workspaces = Object.values(catalogWorkspaces).sort();\n if (workspaces.length > 0) manifest.workspaces = workspaces;\n else delete manifest.workspaces;\n // Nested and overlapping consumer rules can take precedence in cases that retain\n // vulnerable versions, so Po owns these package-specific selectors recursively.\n manifest.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(manifest.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n const pnpm = recordValue(manifest.pnpm);\n pnpm.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(pnpm.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n manifest.pnpm = pnpm;\n\n const serialized = `${JSON.stringify(manifest, null, 2)}\\n`;\n if (serialized === current) return false;\n await fs.mkdir(runtimeDirectory, { recursive: true });\n await writeFileAtomic(createNodePlatform().env(runtimeDirectory), manifestPath, serialized, BACKGROUND_CONTEXT);\n return true;\n}\n\n/** Finds required npm packages selected by defaults and active layers that Po cannot resolve. */\nexport function missingLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n resolvers: ExtensionLayerResolvers,\n): string[] {\n return configuredPackageSpecifiers(config, layers).filter(\n (specifier) => resolvePackageEntries(resolvers, specifier) === undefined,\n );\n}\n\n/** Whether `root`'s own node_modules chain holds the package, walked the way Node looks it up from `root`. */\nasync function ownsPackage(name: string, root: string): Promise<boolean> {\n for (let directory = path.resolve(root); ; directory = path.dirname(directory)) {\n if (\n await fs.access(path.join(directory, NODE_MODULES, name, PACKAGE_MANIFEST)).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n )\n )\n return true;\n if (path.dirname(directory) === directory) return false;\n }\n}\n\n/**\n * The required npm packages the default and the given layers name that `root` does not get\n * from its own node_modules chain: what the shared runtime provides for it, whether it does so\n * already or not yet. Sync declares exactly these, over every root, in the runtime manifest; a\n * name the runtime already provides still counts, or the next exact manifest would drop it.\n */\nexport async function runtimeLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n root: string,\n): Promise<string[]> {\n const specifiers = configuredPackageSpecifiers(config, layers);\n const owned = await Promise.all(\n specifiers.map((specifier) => ownsPackage(splitPackageSpecifier(specifier).name, root)),\n );\n return specifiers.filter((_specifier, index) => !owned[index]);\n}\n\nfunction packageName(source: string): string {\n const specifier = source.startsWith(NPM_SOURCE_PREFIX) ? source.slice(NPM_SOURCE_PREFIX.length) : source;\n if (specifier.startsWith('@')) {\n const slash = specifier.indexOf('/');\n const version = slash === -1 ? -1 : specifier.indexOf('@', slash);\n return version === -1 ? specifier : specifier.slice(0, version);\n }\n const version = specifier.indexOf('@');\n return version === -1 ? specifier : specifier.slice(0, version);\n}\n\ninterface PackageCatalogEntry {\n /** Absolute path of the bundled archive; it takes precedence over `version`. */\n archive?: string;\n /** Exact registry version, pinned when the entry has no archive. */\n version?: string;\n dependencies: readonly string[];\n}\n\ninterface PackageCatalog {\n packages: ReadonlyMap<string, PackageCatalogEntry>;\n /** Feature packages Po installs out of the box, by name. */\n install: readonly string[];\n}\n\nconst EMPTY_CATALOG: PackageCatalog = { packages: new Map(), install: [] };\n\nfunction stringList(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const strings = value.filter((item): item is string => typeof item === 'string');\n return strings.length === value.length ? strings : undefined;\n}\n\nfunction defaultBundledCatalogPath(): string | undefined {\n try {\n return path.join(poPackageRoot(), ...BUNDLED_CATALOG_SEGMENTS);\n } catch {\n // A bundle with no locatable Po package root has no bundled catalogue to read.\n return undefined;\n }\n}\n\n/**\n * The first catalogue present: `PO_PACKAGE_CATALOG` (desktop's archives), then the one\n * a release bundles into the CLI. With neither, the runtime installs only what roots name.\n */\nasync function packageCatalogPath(environment: NodeJS.ProcessEnv): Promise<string | undefined> {\n const configured = environment[PACKAGE_CATALOG_ENV]?.trim();\n if (configured) return configured;\n const bundledCatalogPath = defaultBundledCatalogPath();\n if (bundledCatalogPath === undefined) return undefined;\n return fs.access(bundledCatalogPath).then(\n () => bundledCatalogPath,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\nasync function readPackageCatalog(manifestPath: string | undefined): Promise<PackageCatalog> {\n if (!manifestPath) return EMPTY_CATALOG;\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n if (!isRecord(parsed) || parsed.version !== 1 || !isRecord(parsed.packages)) {\n throw new Error(`Unsupported Po package catalog: ${manifestPath}`);\n }\n const packages = new Map<string, PackageCatalogEntry>();\n for (const [name, value] of Object.entries(parsed.packages)) {\n if (\n !isRecord(value) ||\n !Array.isArray(value.dependencies) ||\n (value.archive !== undefined && typeof value.archive !== 'string') ||\n (value.version !== undefined && typeof value.version !== 'string') ||\n (value.archive === undefined && value.version === undefined)\n ) {\n throw new Error(`Invalid package entry for ${name} in ${manifestPath}`);\n }\n const dependencies = stringList(value.dependencies);\n if (!dependencies) throw new Error(`Invalid dependencies for ${name} in ${manifestPath}`);\n const version = typeof value.version === 'string' ? value.version : undefined;\n if (typeof value.archive !== 'string') {\n packages.set(name, { version, dependencies });\n continue;\n }\n const archive = path.resolve(path.dirname(manifestPath), value.archive);\n await fs.access(archive).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive is missing: ${archive}`);\n throw error;\n });\n packages.set(name, { archive, version, dependencies });\n }\n const install = parsed.install === undefined ? [] : stringList(parsed.install);\n if (!install) throw new Error(`Invalid install list in ${manifestPath}`);\n const unknown = install.filter((name) => !packages.has(name));\n if (unknown.length > 0) throw new Error(`Po package catalog installs unlisted package(s): ${unknown.join(', ')}`);\n return { packages, install };\n}\n\n/**\n * The catalogue's `install` list as exact `name@version` specifiers for\n * `EnsureLayerPackagesOptions.specifiers`; empty when no catalogue is present.\n */\nexport async function catalogInstallSpecifiers(environment: NodeJS.ProcessEnv = process.env): Promise<string[]> {\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n return catalog.install.map((name) => {\n const version = catalog.packages.get(name)?.version;\n return version ? `${name}@${version}` : name;\n });\n}\n\n/**\n * The installed package roots of the catalogue's `install` list, resolved the way a root\n * resolves a bare name (its own node_modules, then the shared runtime). The global web build\n * covers them, so every first-party plugin has a slot; a name not installed yet is left out.\n */\nexport async function catalogPackageRoots(\n globalRoot: string,\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<string[]> {\n const roots: string[] = [];\n for (const name of (await readPackageCatalog(await packageCatalogPath(environment))).install) {\n const manifest = consumerPackageEntry(`${name}/${PACKAGE_MANIFEST}`, globalRoot, environment);\n if (manifest !== undefined) roots.push(path.dirname(await fs.realpath(manifest)));\n }\n return roots;\n}\n\n/** SHA-256 of the catalogue file in use, or `none` when no catalogue is present. */\nexport async function packageCatalogHash(environment: NodeJS.ProcessEnv = process.env): Promise<string> {\n const catalogPath = await packageCatalogPath(environment);\n if (!catalogPath) return 'none';\n return crypto\n .createHash('sha256')\n .update(await fs.readFile(catalogPath))\n .digest('hex');\n}\n\n/** Exact target per catalogue name: its staged workspace for an archive, else its registry version. */\nfunction catalogTargets(catalog: PackageCatalog): Map<string, string> {\n return new Map(\n [...catalog.packages].flatMap(([name, entry]) => {\n if (entry.archive !== undefined) return [[name, CATALOG_WORKSPACE_TARGET] as const];\n return entry.version !== undefined ? [[name, entry.version] as const] : [];\n }),\n );\n}\n\nconst TAR_BLOCK_SIZE = 512;\nconst TAR_EXECUTABLE_BITS = 0o111;\n\nfunction tarString(block: Buffer, start: number, length: number): string {\n const field = block.subarray(start, start + length);\n const end = field.indexOf(0);\n return field.subarray(0, end === -1 ? field.length : end).toString('utf8');\n}\n\nfunction tarNumber(block: Buffer, start: number, length: number): number {\n const field = block.subarray(start, start + length);\n // GNU base-256: the high bit of the first byte marks a big-endian binary number.\n if ((field[0]! & 0x80) !== 0) return field.subarray(1).reduce((value, byte) => value * 256 + byte, field[0]! & 0x7f);\n const text = tarString(block, start, length).trim();\n return text === '' ? 0 : Number.parseInt(text, 8);\n}\n\n/** The `path` record of a pax extended header, if it has one. */\nfunction paxPath(data: Buffer): string | undefined {\n let found: string | undefined;\n let offset = 0;\n while (offset < data.length) {\n const space = data.indexOf(0x20, offset);\n if (space === -1) break;\n const length = Number.parseInt(data.subarray(offset, space).toString('utf8'), 10);\n if (!Number.isFinite(length) || length <= 0) break;\n const record = data.subarray(space + 1, offset + length - 1).toString('utf8');\n const separator = record.indexOf('=');\n if (record.slice(0, separator) === 'path') found = record.slice(separator + 1);\n offset += length;\n }\n return found;\n}\n\n/**\n * Unpacks a gzipped npm package archive into `destination`, dropping the archive's top\n * directory (`package/`) as npm does. Only files and directories are written: npm package\n * archives carry no links, and an entry that would land outside `destination` is refused.\n */\nasync function extractPackageArchive(archive: string, destination: string): Promise<void> {\n const data = zlib.gunzipSync(await fs.readFile(archive));\n let offset = 0;\n let nextPath: string | undefined;\n while (offset + TAR_BLOCK_SIZE <= data.length) {\n const header = data.subarray(offset, offset + TAR_BLOCK_SIZE);\n if (header.every((byte) => byte === 0)) break;\n const size = tarNumber(header, 124, 12);\n const type = String.fromCharCode(header[156]!);\n const body = data.subarray(offset + TAR_BLOCK_SIZE, offset + TAR_BLOCK_SIZE + size);\n offset += TAR_BLOCK_SIZE + Math.ceil(size / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;\n if (type === 'x' || type === 'L') {\n nextPath = type === 'x' ? (paxPath(body) ?? nextPath) : tarString(body, 0, body.length);\n continue;\n }\n if (type === 'g') continue;\n const prefix = tarString(header, 345, 155);\n const name = nextPath ?? (prefix ? `${prefix}/${tarString(header, 0, 100)}` : tarString(header, 0, 100));\n nextPath = undefined;\n if (type !== '0' && type !== '\\0' && type !== '5') continue;\n const relative = name.split('/').slice(1).join('/');\n if (relative === '') continue;\n const target = path.resolve(destination, relative);\n if (!target.startsWith(`${destination}${path.sep}`)) {\n throw new Error(`Po package catalog archive ${archive} has an entry outside the package: ${name}`);\n }\n if (type === '5') {\n await fs.mkdir(target, { recursive: true });\n continue;\n }\n await fs.mkdir(path.dirname(target), { recursive: true });\n const executable = (tarNumber(header, 100, 8) & TAR_EXECUTABLE_BITS) !== 0;\n await fs.writeFile(target, body, { mode: executable ? 0o755 : 0o644 });\n }\n}\n\n/** Dependency fields of a staged manifest that may name another catalogue package. */\nconst STAGED_DEPENDENCY_FIELDS = ['dependencies', 'optionalDependencies', 'peerDependencies'] as const;\n\n/**\n * Unpacks one catalogue archive into `<runtime>/catalog/<hash>` and returns that directory\n * relative to the runtime, with the catalogue names its manifest depends on.\n *\n * upm only installs a package from a directory as a workspace: a `file:` archive takes its own\n * dependencies from the registry, so one catalogue archive could not depend on another. In the\n * staged manifest every dependency on another catalogue archive becomes `workspace:*`, so the\n * catalogue's copy wins whatever range the package declared, and `devDependencies`, which a\n * workspace would otherwise install, are dropped. The hash covers the archive bytes and the\n * catalogue's archive names, everything that rewrite reads, so a staged directory is reused.\n */\nasync function stageCatalogArchive(\n runtimeDirectory: string,\n archive: string,\n archiveNames: ReadonlySet<string>,\n): Promise<{ relative: string; dependencies: string[] }> {\n const hash = crypto\n .createHash('sha256')\n .update(await fs.readFile(archive))\n .update(`\\0${[...archiveNames].sort().join('\\n')}`)\n .digest('hex');\n const relative = `${CATALOG_STAGING_DIRECTORY}/${hash}`;\n const directory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY, hash);\n const stagedManifest = path.join(directory, PACKAGE_MANIFEST);\n const existing = await fs.readFile(stagedManifest, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === undefined) {\n const temporary = `${directory}.${String(process.pid)}.${crypto.randomUUID()}.tmp`;\n try {\n await extractPackageArchive(archive, temporary);\n const manifestPath = path.join(temporary, PACKAGE_MANIFEST);\n const bytes = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive has no package.json: ${archive}`);\n throw error;\n });\n const manifest: unknown = JSON.parse(bytes);\n if (!isRecord(manifest)) throw new Error(`Po package catalog archive has an invalid package.json: ${archive}`);\n delete manifest.devDependencies;\n for (const field of STAGED_DEPENDENCY_FIELDS) {\n if (!isRecord(manifest[field])) continue;\n const declared = { ...manifest[field] };\n for (const name of Object.keys(declared)) {\n if (archiveNames.has(name)) declared[name] = CATALOG_WORKSPACE_TARGET;\n }\n manifest[field] = declared;\n }\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`);\n try {\n await fs.rename(temporary, directory);\n } catch (error) {\n // Another process staged the same bytes first; its copy is identical.\n await fs.access(stagedManifest).catch(() => {\n throw error;\n });\n }\n } finally {\n await fs.rm(temporary, { recursive: true, force: true });\n }\n }\n const staged = recordValue(JSON.parse(existing ?? (await fs.readFile(stagedManifest, 'utf8'))));\n const dependencies = STAGED_DEPENDENCY_FIELDS.flatMap((field) => Object.keys(recordValue(staged[field])));\n return { relative, dependencies: dependencies.filter((name) => archiveNames.has(name)) };\n}\n\n/**\n * Stages the archive of every named catalogue package and of every catalogue package those\n * name in turn, since a staged manifest's `workspace:*` needs that workspace present. The\n * result, name to staged directory, feeds `ensureManagedPackageManifest`.\n */\nasync function stageCatalogArchives(\n runtimeDirectory: string,\n catalog: PackageCatalog,\n names: Iterable<string>,\n): Promise<Record<string, string>> {\n const archiveNames = new Set(\n [...catalog.packages].flatMap(([name, entry]) => (entry.archive === undefined ? [] : [name])),\n );\n const staged: Record<string, string> = {};\n const pending = [...names].filter((name) => archiveNames.has(name));\n while (pending.length > 0) {\n const name = pending.shift()!;\n if (Object.hasOwn(staged, name)) continue;\n const { relative, dependencies } = await stageCatalogArchive(\n runtimeDirectory,\n catalog.packages.get(name)!.archive!,\n archiveNames,\n );\n staged[name] = relative;\n pending.push(...dependencies);\n }\n return staged;\n}\n\n/**\n * Removes staged archives the runtime manifest no longer lists as workspaces, and returns their\n * folder names. An install never calls this: a running server imports from these folders (its\n * `.po-snapshots` live there), so sync prunes them under the same gate as the runtime store.\n */\nexport async function pruneStagedCatalogArchives(runtimeDirectory: string): Promise<string[]> {\n const stagingDirectory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY);\n const entries = await fs.readdir(stagingDirectory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const { manifest } = await readRuntimeManifest(path.join(runtimeDirectory, PACKAGE_MANIFEST));\n const kept = new Set((stringList(manifest.workspaces) ?? []).map((relative) => path.basename(relative)));\n return Promise.all(\n entries\n .filter((entry) => !kept.has(entry))\n .map(async (entry) => {\n await fs.rm(path.join(stagingDirectory, entry), { recursive: true, force: true });\n return entry;\n }),\n );\n}\n\n/** Splits `name@version` (scoped or not); the version is absent for a bare name or subpath. */\nfunction splitVersionedSpecifier(specifier: string): { name: string; version?: string } {\n const separator = specifier.indexOf('@', specifier.startsWith('@') ? 1 : 0);\n if (separator === -1) return { name: splitPackageSpecifier(specifier).name };\n return { name: specifier.slice(0, separator), version: specifier.slice(separator + 1) };\n}\n\nfunction npmSources(\n specifiers: readonly string[],\n catalog: PackageCatalog,\n targets: ReadonlyMap<string, string>,\n includeCatalogDependencies = false,\n): string[] {\n const names = [...new Set(specifiers.map((specifier) => splitPackageSpecifier(specifier).name))];\n if (includeCatalogDependencies) {\n for (let index = 0; index < names.length; index += 1) {\n for (const dependency of catalog.packages.get(names[index]!)?.dependencies ?? []) {\n if (!names.includes(dependency)) names.push(dependency);\n }\n }\n }\n return names.map((name) => {\n const target = targets.get(name);\n return `${NPM_SOURCE_PREFIX}${name}${target ? `@${target}` : ''}`;\n });\n}\n\nfunction pluralize(count: number, noun: string): string {\n return `${count} ${noun}${count === 1 ? '' : 's'}`;\n}\n\n/** Version of a package inside the shared runtime, absent when Po did not install it there. */\nasync function managedPackageVersion(runtimeDirectory: string, name: string): Promise<string | undefined> {\n const manifestPath = path.join(runtimeDirectory, NODE_MODULES, name, PACKAGE_MANIFEST);\n try {\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n return isRecord(parsed) && typeof parsed.version === 'string' ? parsed.version : undefined;\n } catch {\n // An unreadable manifest carries the same meaning as an absent one: nothing\n // usable is installed, so the caller treats the package as uninstalled.\n return undefined;\n }\n}\n\nfunction errorCode(error: unknown): unknown {\n return typeof error === 'object' && error !== null ? (error as { code?: unknown }).code : undefined;\n}\n\n/**\n * Installs the runtime, and when the registry cannot be reached installs it again offline:\n * an unchanged lockfile whose packages the store already holds needs no network.\n */\nasync function installWithOfflineRetry(\n install: NonNullable<LayerPackageInstallerDependencies['install']>,\n options: InstallRuntimePackagesOptions,\n onProgress: ((message: string) => void) | undefined,\n): Promise<void> {\n try {\n await install(options);\n } catch (error) {\n const code = errorCode(error);\n if (typeof code !== 'string' || !NETWORK_FAILURE_CODES.has(code)) throw error;\n onProgress?.(`the registry is unreachable (${code}); installing offline from the store`);\n try {\n await install({ ...options, preferOffline: false, offline: true });\n } catch {\n // The offline attempt only ever narrows the original failure: the network error\n // explains why the install could not complete, an EOFFLINE miss does not.\n throw error;\n }\n }\n}\n\ninterface CheckedPackage {\n name: string;\n from: string;\n to?: string;\n failure?: string;\n}\n\n/**\n * Compares every package sync installed against the registry.\n *\n * Only the shared runtime is consulted: a package that resolves from the\n * repository's own modules is not sync's to move, and a package that is not\n * installed yet is already covered by the missing-package path.\n */\nasync function resolveUpdates(\n runtimeDirectory: string,\n sources: readonly string[],\n publishedVersion: (name: string) => Promise<string>,\n onProgress: ((message: string) => void) | undefined,\n): Promise<Pick<LayerPackageResult, 'updated' | 'unchecked'>> {\n const managed = (\n await Promise.all(\n sources.map(async (source) => ({\n name: packageName(source),\n from: await managedPackageVersion(runtimeDirectory, packageName(source)),\n })),\n )\n ).filter((entry): entry is { name: string; from: string } => entry.from !== undefined);\n const checked: CheckedPackage[] = await Promise.all(\n managed.map(async (entry) => {\n try {\n return { ...entry, to: await publishedVersion(entry.name) };\n } catch (error) {\n return { ...entry, failure: (error instanceof Error ? error.message : String(error)).split('\\n')[0] };\n }\n }),\n );\n\n const updated: LayerPackageUpdate[] = [];\n const unchecked: string[] = [];\n for (const entry of checked) {\n if (entry.to === undefined) {\n unchecked.push(entry.name);\n onProgress?.(`kept ${entry.name} ${entry.from}: ${entry.failure ?? 'no published version'}`);\n continue;\n }\n if (entry.to === entry.from) continue;\n updated.push({ name: entry.name, from: entry.from, to: entry.to });\n onProgress?.(`${entry.name} ${entry.from} -> ${entry.to}`);\n }\n return { updated, unchecked };\n}\n\n/**\n * Installs the selected layer packages a root cannot resolve into the shared runtime,\n * `<po home>/runtime`, and verifies they now resolve.\n *\n * The runtime manifest is the union of what every root asked for. A root adds the\n * packages it is missing; a package it already resolves from its own node_modules stays\n * out unless an earlier run put it there. One name has one version: an exact target\n * (a sync update, a catalog archive or registry pin) replaces the declared range, last\n * writer wins, and a plain `*` never replaces a range already declared.\n *\n * `specifiers` and `exactManifest` only add behaviour: without them, and without a\n * catalogue, a run behaves as it always has.\n */\nexport async function ensureLayerPackages(\n options: EnsureLayerPackagesOptions,\n dependencies: LayerPackageInstallerDependencies = {},\n): Promise<LayerPackageResult> {\n const environment = options.environment ?? process.env;\n const homeDirectory = environment.HOME ?? os.homedir();\n const poHome = poHomeDirectory(homeDirectory, environment);\n const runtimeDirectory = poRuntimeDirectory(homeDirectory, environment);\n // The root's own .npmrc routes and authenticates the registries its layers name.\n const npmrcFiles = [path.join(options.repoRoot, '.npmrc')];\n const resolvers = dependencies.resolvers ?? createLayerResolvers(options.repoRoot, environment);\n const external = (specifier: string): boolean => testPackageRoot(packageName(specifier), environment) === undefined;\n const configured = configuredPackageSpecifiers(options.config, options.layers).filter(external);\n const missing = configured.filter((specifier) => resolvePackageEntries(resolvers, specifier) === undefined);\n const declared = await declaredRuntimePackages(runtimeDirectory);\n const managed = configured.filter(\n (specifier) => missing.includes(specifier) || declared.has(splitPackageSpecifier(specifier).name),\n );\n const requested = (options.specifiers ?? []).filter(external).map(splitVersionedSpecifier);\n if (managed.length === 0 && requested.length === 0 && options.exactManifest !== true) {\n return { installed: [], updated: [], unchecked: [] };\n }\n\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n const pins = catalogTargets(catalog);\n for (const { name, version } of requested) {\n if (version !== undefined && catalog.packages.get(name)?.archive === undefined) pins.set(name, version);\n }\n // A requested package is missing until the runtime holds it at the version it is pinned to.\n const requestedMissing: string[] = [];\n for (const { name, version } of requested) {\n const installed = await managedPackageVersion(runtimeDirectory, name);\n const entry = catalog.packages.get(name);\n const expected = entry?.archive === undefined ? version : entry.version;\n if (installed === undefined || (expected !== undefined && installed !== expected)) requestedMissing.push(name);\n }\n const missingSources = npmSources([...missing, ...requestedMissing], catalog, pins);\n const sources = npmSources([...managed, ...requested.map(({ name }) => name)], catalog, pins, true).filter(external);\n const missingCount = missing.length + requestedMissing.length;\n\n // Refresh never moves a pinned name: catalogue entries and versioned specifiers stay put.\n const fixedNames = new Set([\n ...catalog.packages.keys(),\n ...requested.filter(({ version }) => version !== undefined).map(({ name }) => name),\n ]);\n const registrySources = sources.filter((source) => !fixedNames.has(packageName(source)));\n const { updated, unchecked } = options.refresh\n ? await resolveUpdates(\n runtimeDirectory,\n registrySources,\n dependencies.publishedVersion ?? ((name) => resolveNewest(name, { dir: runtimeDirectory, poHome, npmrcFiles })),\n options.onProgress,\n )\n : { updated: [], unchecked: [] };\n const targets = new Map(\n sources.flatMap((source) => {\n const target = pins.get(packageName(source));\n return target ? [[packageName(source), target] as const] : [];\n }),\n );\n for (const update of updated) targets.set(update.name, update.to);\n // A kept manifest still declares names earlier runs added; their archives are staged too.\n const stagedNames = new Set([...sources.map(packageName), ...(options.exactManifest === true ? [] : declared)]);\n const staged = await stageCatalogArchives(runtimeDirectory, catalog, stagedNames);\n const manifestChanged = await ensureManagedPackageManifest(\n runtimeDirectory,\n sources,\n targets,\n staged,\n options.exactManifest === true,\n );\n if (missingCount === 0 && !manifestChanged) return { installed: [], updated: [], unchecked };\n\n options.onProgress?.(\n `installing ${\n updated.length > 0\n ? pluralize(updated.length, 'update')\n : missingCount > 0\n ? pluralize(missingCount, 'missing package')\n : 'the package manifest'\n }`,\n );\n try {\n // One install reconciles the complete dependency set written to package.json.\n await installWithOfflineRetry(\n dependencies.install ?? installRuntimePackages,\n {\n dir: runtimeDirectory,\n poHome,\n npmrcFiles,\n // A launch never waits on registry revalidation; sync is the command that refreshes.\n preferOffline: options.refresh !== true,\n log: (message, level) => {\n if (level === 'warn') options.onProgress?.(message);\n },\n },\n options.onProgress,\n );\n } catch (error) {\n const attempted = manifestChanged ? sources : missingSources;\n throw new Error(\n `Failed to reconcile Po layer package(s): ${attempted.join(', ')}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n\n const unresolved = missing.filter((specifier) => !resolvePackageEntries(resolvers, specifier)?.length);\n if (unresolved.length > 0) {\n throw new Error(\n `Installed Po layer package(s) did not expose the configured Pi extension: ${unresolved.join(', ')}`,\n );\n }\n return { installed: missingSources, updated, unchecked };\n}\n\n/** One selector per name in the shared runtime. Caller holds the sync lock throughout. */\nexport async function ensureRuntimeImportPackage(\n name: string,\n version: string,\n options: { homeDirectory: string; environment: Readonly<Record<string, string | undefined>> },\n): Promise<void> {\n const environment = { ...options.environment, HOME: options.homeDirectory };\n const poHome = poHomeDirectory(options.homeDirectory, environment);\n const directory = poRuntimeDirectory(options.homeDirectory, environment);\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n const { manifest } = await readRuntimeManifest(manifestPath);\n const declared = recordValue(manifest.dependencies);\n const imports = recordValue(manifest.poCodemodeDependencies);\n const imported = recordValue(imports[name]);\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n if (catalog.packages.has(name) || (Object.hasOwn(declared, name) && declared[name] !== imported.selector)) {\n throw new Error(\n `Cannot import ${name}: Po manages this runtime dependency (${JSON.stringify(declared[name] ?? 'catalogue')}).`,\n );\n }\n if (Object.hasOwn(imports, name) && imported.selector !== version) {\n throw new Error(`Cannot import ${name}@${version}: the hub already uses ${name}@${String(imported.selector)}.`);\n }\n const installed = await managedPackageVersion(directory, name);\n if (declared[name] === version && installed !== undefined && imported.resolved === installed) return;\n // Only a successful reconciliation is cacheable, not the manifest upm writes ahead of a failed install.\n manifest.poCodemodeDependencies = { ...imports, [name]: { selector: version } };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(manifest, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n const pins = new Map([[name, version]]);\n const sources = npmSources([`${name}@${version}`], catalog, pins, true);\n const staged = await stageCatalogArchives(\n directory,\n catalog,\n new Set([...sources.map(packageName), ...Object.keys(declared)]),\n );\n await ensureManagedPackageManifest(directory, sources, pins, staged);\n await installWithOfflineRetry(installRuntimePackages, { dir: directory, poHome, preferOffline: true }, undefined);\n const resolved = await managedPackageVersion(directory, name);\n if (resolved === undefined) throw new Error(`Runtime import ${name}@${version} was not installed.`);\n const reconciled = (await readRuntimeManifest(manifestPath)).manifest;\n reconciled.poCodemodeDependencies = {\n ...recordValue(reconciled.poCodemodeDependencies),\n [name]: { selector: version, resolved },\n };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(reconciled, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,6BAA6B;;AAEnC,MAAM,2BAA2B;;AAEjC,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,sBAAsB;;AAE5B,MAAM,2BAA2B;CAAC;CAAQ;CAAW;AAAY;;AAEjE,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAY;CAAa;AAAW,CAAC;AAE5E,SAAS,oBAAoB,UAA0B;CACrD,MAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS,WAAW,GAAG,IAAI,IAAI,CAAC;CAC7E,OAAO,mBAAmB,KAAK,WAAW,SAAS,MAAM,GAAG,cAAc;AAC5E;;;;;;AAOA,MAAa,4BAA4B;CAEvC,+BAA+B;CAC/B,mCAAmC;CACnC,uCAAuC;CACvC,kCAAkC;CAClC,kCAAkC;CAClC,uBAAuB;CACvB,yBAAyB;CACzB,yBAAyB;CACzB,6BAA6B;CAC7B,4BAA4B;CAC5B,yBAAyB;AAC3B;AAEA,MAAM,gCAAgC,IAAI,IAAI,OAAO,KAAK,yBAAyB,CAAC,CAAC,IAAI,mBAAmB,CAAC;AA4D7G,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,YAAY,OAAyC;CAC5D,OAAO,SAAS,KAAK,IAAI,EAAE,GAAG,MAAM,I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F;AACF"}
|
|
@@ -594,6 +594,7 @@ async function ensureLayerPackages(options, dependencies = {}) {
|
|
|
594
594
|
const homeDirectory = environment.HOME ?? os.homedir();
|
|
595
595
|
const poHome = poHomeDirectory(homeDirectory, environment);
|
|
596
596
|
const runtimeDirectory = poRuntimeDirectory(homeDirectory, environment);
|
|
597
|
+
const npmrcFiles = [path.join(options.repoRoot, ".npmrc")];
|
|
597
598
|
const resolvers = dependencies.resolvers ?? createLayerResolvers(options.repoRoot, environment);
|
|
598
599
|
const external = (specifier) => testPackageRoot(packageName(specifier), environment) === void 0;
|
|
599
600
|
const configured = configuredPackageSpecifiers(options.config, options.layers).filter(external);
|
|
@@ -623,7 +624,8 @@ async function ensureLayerPackages(options, dependencies = {}) {
|
|
|
623
624
|
const registrySources = sources.filter((source) => !fixedNames.has(packageName(source)));
|
|
624
625
|
const { updated, unchecked } = options.refresh ? await resolveUpdates(runtimeDirectory, registrySources, dependencies.publishedVersion ?? ((name) => resolveNewest(name, {
|
|
625
626
|
dir: runtimeDirectory,
|
|
626
|
-
poHome
|
|
627
|
+
poHome,
|
|
628
|
+
npmrcFiles
|
|
627
629
|
})), options.onProgress) : {
|
|
628
630
|
updated: [],
|
|
629
631
|
unchecked: []
|
|
@@ -644,6 +646,7 @@ async function ensureLayerPackages(options, dependencies = {}) {
|
|
|
644
646
|
await installWithOfflineRetry(dependencies.install ?? installRuntimePackages, {
|
|
645
647
|
dir: runtimeDirectory,
|
|
646
648
|
poHome,
|
|
649
|
+
npmrcFiles,
|
|
647
650
|
preferOffline: options.refresh !== true,
|
|
648
651
|
log: (message, level) => {
|
|
649
652
|
if (level === "warn") options.onProgress?.(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/layerPackageInstaller/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { isLocalPackageSpecifier, type MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nimport { consumerPackageEntry, splitPackageSpecifier, testPackageRoot } from '@agimon-ai/po-core/moduleResolution';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { BACKGROUND_CONTEXT, writeFileAtomic } from '@agimon-ai/po-core/platform';\nimport {\n installRuntimePackages,\n type InstallRuntimePackagesOptions,\n resolveNewest,\n} from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { createLayerResolvers, type ExtensionLayerResolvers } from '../../builders/cli/extensionAssembler';\n\nconst NPM_SOURCE_PREFIX = 'npm:';\nconst FILE_SPECIFIER_PREFIX = 'file:';\nconst WORKSPACE_SPECIFIER_PREFIX = 'workspace:';\n/** Root target of a staged catalogue archive: always the staged workspace, never the registry. */\nconst CATALOG_WORKSPACE_TARGET = 'workspace:*';\n/** Where catalogue archives are unpacked inside the runtime, one directory per archive hash. */\nconst CATALOG_STAGING_DIRECTORY = 'catalog';\nconst RUNTIME_PACKAGE_NAME = 'po-runtime';\nconst UNPINNED_PACKAGE_RANGE = '*';\nconst PACKAGE_MANIFEST = 'package.json';\nconst NODE_MODULES = 'node_modules';\nconst PACKAGE_CATALOG_ENV = 'PO_PACKAGE_CATALOG';\n/** The registry catalogue a release writes into the CLI package: `<package root>/dist/catalog/index.json`. */\nconst BUNDLED_CATALOG_SEGMENTS = ['dist', 'catalog', 'index.json'] as const;\n/** upm error codes that mean the registry could not be reached, so the store may still answer. */\nconst NETWORK_FAILURE_CODES = new Set(['ENETWORK', 'ETIMEDOUT', 'EREGISTRY']);\n\nfunction overridePackageName(selector: string): string {\n const separatorIndex = selector.indexOf('@', selector.startsWith('@') ? 1 : 0);\n return separatorIndex === -1 ? selector : selector.slice(0, separatorIndex);\n}\n\n/**\n * Runtime compatibility pins and same-major patches for current foundation packages.\n * Package managers only honor overrides from the install root, so published extensions\n * cannot carry these fixes in their own manifests.\n */\nexport const SAFE_TRANSITIVE_OVERRIDES = {\n // ponytail: Pin for Pi 1.4.0's declaration API; advance with the host's Pi version.\n '@earendil-works/pi-codemode': '1.4.0',\n '@hono/node-server@2.0.0 - 2.0.9': '^2.0.10',\n '@opentelemetry/core@2.0.0 - 2.7.999': '2.8.0',\n 'brace-expansion@1.0.0 - 1.1.20': '^1.1.21',\n 'brace-expansion@5.0.0 - 5.0.11': '^5.0.12',\n 'hono@4.0.0 - 4.13.7': '4.13.8',\n 'js-yaml@4.0.0 - 4.3.1': '^4.3.2',\n 'js-yaml@5.0.0 - 5.2.1': '^5.2.2',\n 'liquidjs@10.0.0 - 10.27.1': '^10.27.2',\n 'protobufjs@8.0.0 - 8.7.1': '^8.7.2',\n 'undici@7.0.0 - 7.29.0': '^7.29.1',\n} as const satisfies Readonly<Record<string, string>>;\n\nconst SAFE_TRANSITIVE_PACKAGE_NAMES = new Set(Object.keys(SAFE_TRANSITIVE_OVERRIDES).map(overridePackageName));\n\nexport interface EnsureLayerPackagesOptions {\n /**\n * The Po root whose layers name the packages. Its own node_modules chain is\n * resolved first; what it cannot provide is installed into the one runtime\n * every root shares, `<po home>/runtime`.\n */\n repoRoot: string;\n config: MajorModesConfig;\n layers: readonly string[];\n environment?: NodeJS.ProcessEnv;\n /**\n * Move every managed package to its newest published version.\n *\n * Launch installs what a selection needs and nothing more, so a session never\n * pays for a registry round trip. Sync is the explicit maintenance command and\n * is the only caller that asks for this.\n */\n refresh?: boolean;\n /**\n * Packages installed into the runtime whatever the root resolves itself, such as the\n * catalogue's `install` list. A `name@version` specifier pins that exact version; a\n * catalogue archive for the name still wins. Refresh never moves a pinned name.\n */\n specifiers?: readonly string[];\n /**\n * Make the runtime manifest declare exactly this run's packages (the specifiers, the\n * selected names and their catalogue dependencies), so pruning can drop anything else.\n * Without it the manifest only grows.\n */\n exactManifest?: boolean;\n /** Receives one human-readable line per package decision. */\n onProgress?: (message: string) => void;\n}\n\nexport interface LayerPackageInstallerDependencies {\n /** Install seam; the default installs `<po home>/runtime` with upm. */\n install?: (options: InstallRuntimePackagesOptions) => Promise<unknown>;\n resolvers?: ExtensionLayerResolvers;\n /** Registry lookup seam; the default resolves the newest allowed version with upm. */\n publishedVersion?: (name: string) => Promise<string>;\n}\n\n/** One managed package moving from the installed version to the newest published one. */\nexport interface LayerPackageUpdate {\n name: string;\n from: string;\n to: string;\n}\n\nexport interface LayerPackageResult {\n /** Sources installed because a configured extension could not be resolved. */\n installed: string[];\n /** Packages this run moved to a newer published version. */\n updated: LayerPackageUpdate[];\n /** Packages left at the installed version because the registry could not be read. */\n unchecked: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction recordValue(value: unknown): Record<string, unknown> {\n return isRecord(value) ? { ...value } : {};\n}\n\nfunction withoutConflictingTransitiveOverrides(value: unknown): Record<string, unknown> {\n const overrides = recordValue(value);\n for (const [selector, replacement] of Object.entries(overrides)) {\n if (SAFE_TRANSITIVE_PACKAGE_NAMES.has(overridePackageName(selector))) {\n delete overrides[selector];\n } else if (isRecord(replacement)) {\n overrides[selector] = withoutConflictingTransitiveOverrides(replacement);\n }\n }\n return overrides;\n}\n\n/** Earlier versions overrode catalog packages with relative `file:` targets; any other override is not Po's. */\nfunction withoutCatalogOverrides(overrides: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(overrides).filter(\n ([, replacement]) => !(typeof replacement === 'string' && replacement.startsWith(FILE_SPECIFIER_PREFIX)),\n ),\n );\n}\n\n/** The published (non-local, required) package specifiers the default and the given layers name. */\nfunction configuredPackageSpecifiers(config: MajorModesConfig, layers: readonly string[]): string[] {\n const specifiers = new Set<string>();\n const selectedDefinitions = [\n ...(config.default ? [config.default] : []),\n ...layers.map((layerName) => {\n const layer = config.layers[layerName];\n if (!layer) throw new Error(`Unknown layer: ${layerName}`);\n return layer;\n }),\n ];\n for (const layer of selectedDefinitions) {\n for (const configured of layer.packages ?? []) {\n const specifier = typeof configured === 'string' ? configured : configured.name;\n const optional = typeof configured !== 'string' && configured.optional === true;\n if (!optional && !isLocalPackageSpecifier(specifier)) specifiers.add(specifier);\n }\n }\n return [...specifiers];\n}\n\nfunction resolvePackageEntries(resolvers: ExtensionLayerResolvers, specifier: string): string[] | undefined {\n const entries = resolvers.optionalPackageEntries?.(specifier);\n if (entries !== undefined) return entries;\n const entry = resolvers.optionalPackageEntry(specifier);\n return entry ? [entry] : undefined;\n}\n\nasync function readRuntimeManifest(\n manifestPath: string,\n): Promise<{ current: string | undefined; manifest: Record<string, unknown> }> {\n const current = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (current === undefined) return { current, manifest: { name: RUNTIME_PACKAGE_NAME, private: true } };\n const parsed: unknown = JSON.parse(current);\n if (!isRecord(parsed)) throw new Error(`Po runtime package manifest at ${manifestPath} must be a JSON object.`);\n return { current, manifest: parsed };\n}\n\n/** Names the runtime manifest already declares: what earlier runs, from any root, installed there. */\nasync function declaredRuntimePackages(runtimeDirectory: string): Promise<Set<string>> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n return new Set(Object.keys(recordValue((await readRuntimeManifest(manifestPath)).manifest.dependencies)));\n}\n\n/**\n * Adds a package set and the patched transitive policy to the shared runtime manifest.\n *\n * `targets` pins names to exact versions or `workspace:*`. `catalogWorkspaces` maps each\n * staged catalogue archive's name to its directory relative to the runtime; the manifest\n * lists exactly those directories as its `workspaces`, so a catalogue package's dependency\n * on another one links the staged copy instead of reaching the registry. Both `overrides` and\n * `pnpm.overrides` are written; upm reads both.\n * With `exact`, declared names outside `sources` are dropped instead of kept.\n */\nexport async function ensureManagedPackageManifest(\n runtimeDirectory: string,\n sources: readonly string[],\n targets: ReadonlyMap<string, string> = new Map(),\n catalogWorkspaces: Readonly<Record<string, string>> = {},\n exact = false,\n): Promise<boolean> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n const { current, manifest } = await readRuntimeManifest(manifestPath);\n\n const declared = recordValue(manifest.dependencies);\n const sourceNames = new Set(sources.map(packageName));\n const dependencies = exact\n ? Object.fromEntries(Object.entries(declared).filter(([name]) => sourceNames.has(name)))\n : declared;\n // Every root shares this manifest, so a catalog archive another process staged (a desktop\n // build, say) may not exist for this one: without a staged copy here it falls back to the\n // registry, which keeps the whole set installable. `file:` targets are what earlier\n // versions wrote for archives.\n for (const [name, declared] of Object.entries(dependencies)) {\n if (Object.hasOwn(catalogWorkspaces, name)) {\n dependencies[name] = CATALOG_WORKSPACE_TARGET;\n } else if (\n typeof declared === 'string' &&\n (declared.startsWith(FILE_SPECIFIER_PREFIX) || declared.startsWith(WORKSPACE_SPECIFIER_PREFIX))\n ) {\n dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n }\n for (const source of sources) {\n const name = packageName(source);\n const target = targets.get(name);\n // An exact target is what makes an update reach the store: a package manager keeps a\n // locked version whenever the recorded range still admits it.\n if (target !== undefined) dependencies[name] = target;\n else if (!Object.hasOwn(dependencies, name)) dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n manifest.dependencies = dependencies;\n // Po owns the runtime's workspaces: exactly the staged archives, which reach only each other.\n const workspaces = Object.values(catalogWorkspaces).sort();\n if (workspaces.length > 0) manifest.workspaces = workspaces;\n else delete manifest.workspaces;\n // Nested and overlapping consumer rules can take precedence in cases that retain\n // vulnerable versions, so Po owns these package-specific selectors recursively.\n manifest.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(manifest.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n const pnpm = recordValue(manifest.pnpm);\n pnpm.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(pnpm.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n manifest.pnpm = pnpm;\n\n const serialized = `${JSON.stringify(manifest, null, 2)}\\n`;\n if (serialized === current) return false;\n await fs.mkdir(runtimeDirectory, { recursive: true });\n await writeFileAtomic(createNodePlatform().env(runtimeDirectory), manifestPath, serialized, BACKGROUND_CONTEXT);\n return true;\n}\n\n/** Finds required npm packages selected by defaults and active layers that Po cannot resolve. */\nexport function missingLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n resolvers: ExtensionLayerResolvers,\n): string[] {\n return configuredPackageSpecifiers(config, layers).filter(\n (specifier) => resolvePackageEntries(resolvers, specifier) === undefined,\n );\n}\n\n/** Whether `root`'s own node_modules chain holds the package, walked the way Node looks it up from `root`. */\nasync function ownsPackage(name: string, root: string): Promise<boolean> {\n for (let directory = path.resolve(root); ; directory = path.dirname(directory)) {\n if (\n await fs.access(path.join(directory, NODE_MODULES, name, PACKAGE_MANIFEST)).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n )\n )\n return true;\n if (path.dirname(directory) === directory) return false;\n }\n}\n\n/**\n * The required npm packages the default and the given layers name that `root` does not get\n * from its own node_modules chain: what the shared runtime provides for it, whether it does so\n * already or not yet. Sync declares exactly these, over every root, in the runtime manifest; a\n * name the runtime already provides still counts, or the next exact manifest would drop it.\n */\nexport async function runtimeLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n root: string,\n): Promise<string[]> {\n const specifiers = configuredPackageSpecifiers(config, layers);\n const owned = await Promise.all(\n specifiers.map((specifier) => ownsPackage(splitPackageSpecifier(specifier).name, root)),\n );\n return specifiers.filter((_specifier, index) => !owned[index]);\n}\n\nfunction packageName(source: string): string {\n const specifier = source.startsWith(NPM_SOURCE_PREFIX) ? source.slice(NPM_SOURCE_PREFIX.length) : source;\n if (specifier.startsWith('@')) {\n const slash = specifier.indexOf('/');\n const version = slash === -1 ? -1 : specifier.indexOf('@', slash);\n return version === -1 ? specifier : specifier.slice(0, version);\n }\n const version = specifier.indexOf('@');\n return version === -1 ? specifier : specifier.slice(0, version);\n}\n\ninterface PackageCatalogEntry {\n /** Absolute path of the bundled archive; it takes precedence over `version`. */\n archive?: string;\n /** Exact registry version, pinned when the entry has no archive. */\n version?: string;\n dependencies: readonly string[];\n}\n\ninterface PackageCatalog {\n packages: ReadonlyMap<string, PackageCatalogEntry>;\n /** Feature packages Po installs out of the box, by name. */\n install: readonly string[];\n}\n\nconst EMPTY_CATALOG: PackageCatalog = { packages: new Map(), install: [] };\n\nfunction stringList(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const strings = value.filter((item): item is string => typeof item === 'string');\n return strings.length === value.length ? strings : undefined;\n}\n\nfunction defaultBundledCatalogPath(): string | undefined {\n try {\n return path.join(poPackageRoot(), ...BUNDLED_CATALOG_SEGMENTS);\n } catch {\n // A bundle with no locatable Po package root has no bundled catalogue to read.\n return undefined;\n }\n}\n\n/**\n * The first catalogue present: `PO_PACKAGE_CATALOG` (desktop's archives), then the one\n * a release bundles into the CLI. With neither, the runtime installs only what roots name.\n */\nasync function packageCatalogPath(environment: NodeJS.ProcessEnv): Promise<string | undefined> {\n const configured = environment[PACKAGE_CATALOG_ENV]?.trim();\n if (configured) return configured;\n const bundledCatalogPath = defaultBundledCatalogPath();\n if (bundledCatalogPath === undefined) return undefined;\n return fs.access(bundledCatalogPath).then(\n () => bundledCatalogPath,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\nasync function readPackageCatalog(manifestPath: string | undefined): Promise<PackageCatalog> {\n if (!manifestPath) return EMPTY_CATALOG;\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n if (!isRecord(parsed) || parsed.version !== 1 || !isRecord(parsed.packages)) {\n throw new Error(`Unsupported Po package catalog: ${manifestPath}`);\n }\n const packages = new Map<string, PackageCatalogEntry>();\n for (const [name, value] of Object.entries(parsed.packages)) {\n if (\n !isRecord(value) ||\n !Array.isArray(value.dependencies) ||\n (value.archive !== undefined && typeof value.archive !== 'string') ||\n (value.version !== undefined && typeof value.version !== 'string') ||\n (value.archive === undefined && value.version === undefined)\n ) {\n throw new Error(`Invalid package entry for ${name} in ${manifestPath}`);\n }\n const dependencies = stringList(value.dependencies);\n if (!dependencies) throw new Error(`Invalid dependencies for ${name} in ${manifestPath}`);\n const version = typeof value.version === 'string' ? value.version : undefined;\n if (typeof value.archive !== 'string') {\n packages.set(name, { version, dependencies });\n continue;\n }\n const archive = path.resolve(path.dirname(manifestPath), value.archive);\n await fs.access(archive).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive is missing: ${archive}`);\n throw error;\n });\n packages.set(name, { archive, version, dependencies });\n }\n const install = parsed.install === undefined ? [] : stringList(parsed.install);\n if (!install) throw new Error(`Invalid install list in ${manifestPath}`);\n const unknown = install.filter((name) => !packages.has(name));\n if (unknown.length > 0) throw new Error(`Po package catalog installs unlisted package(s): ${unknown.join(', ')}`);\n return { packages, install };\n}\n\n/**\n * The catalogue's `install` list as exact `name@version` specifiers for\n * `EnsureLayerPackagesOptions.specifiers`; empty when no catalogue is present.\n */\nexport async function catalogInstallSpecifiers(environment: NodeJS.ProcessEnv = process.env): Promise<string[]> {\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n return catalog.install.map((name) => {\n const version = catalog.packages.get(name)?.version;\n return version ? `${name}@${version}` : name;\n });\n}\n\n/**\n * The installed package roots of the catalogue's `install` list, resolved the way a root\n * resolves a bare name (its own node_modules, then the shared runtime). The global web build\n * covers them, so every first-party plugin has a slot; a name not installed yet is left out.\n */\nexport async function catalogPackageRoots(\n globalRoot: string,\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<string[]> {\n const roots: string[] = [];\n for (const name of (await readPackageCatalog(await packageCatalogPath(environment))).install) {\n const manifest = consumerPackageEntry(`${name}/${PACKAGE_MANIFEST}`, globalRoot, environment);\n if (manifest !== undefined) roots.push(path.dirname(await fs.realpath(manifest)));\n }\n return roots;\n}\n\n/** SHA-256 of the catalogue file in use, or `none` when no catalogue is present. */\nexport async function packageCatalogHash(environment: NodeJS.ProcessEnv = process.env): Promise<string> {\n const catalogPath = await packageCatalogPath(environment);\n if (!catalogPath) return 'none';\n return crypto\n .createHash('sha256')\n .update(await fs.readFile(catalogPath))\n .digest('hex');\n}\n\n/** Exact target per catalogue name: its staged workspace for an archive, else its registry version. */\nfunction catalogTargets(catalog: PackageCatalog): Map<string, string> {\n return new Map(\n [...catalog.packages].flatMap(([name, entry]) => {\n if (entry.archive !== undefined) return [[name, CATALOG_WORKSPACE_TARGET] as const];\n return entry.version !== undefined ? [[name, entry.version] as const] : [];\n }),\n );\n}\n\nconst TAR_BLOCK_SIZE = 512;\nconst TAR_EXECUTABLE_BITS = 0o111;\n\nfunction tarString(block: Buffer, start: number, length: number): string {\n const field = block.subarray(start, start + length);\n const end = field.indexOf(0);\n return field.subarray(0, end === -1 ? field.length : end).toString('utf8');\n}\n\nfunction tarNumber(block: Buffer, start: number, length: number): number {\n const field = block.subarray(start, start + length);\n // GNU base-256: the high bit of the first byte marks a big-endian binary number.\n if ((field[0]! & 0x80) !== 0) return field.subarray(1).reduce((value, byte) => value * 256 + byte, field[0]! & 0x7f);\n const text = tarString(block, start, length).trim();\n return text === '' ? 0 : Number.parseInt(text, 8);\n}\n\n/** The `path` record of a pax extended header, if it has one. */\nfunction paxPath(data: Buffer): string | undefined {\n let found: string | undefined;\n let offset = 0;\n while (offset < data.length) {\n const space = data.indexOf(0x20, offset);\n if (space === -1) break;\n const length = Number.parseInt(data.subarray(offset, space).toString('utf8'), 10);\n if (!Number.isFinite(length) || length <= 0) break;\n const record = data.subarray(space + 1, offset + length - 1).toString('utf8');\n const separator = record.indexOf('=');\n if (record.slice(0, separator) === 'path') found = record.slice(separator + 1);\n offset += length;\n }\n return found;\n}\n\n/**\n * Unpacks a gzipped npm package archive into `destination`, dropping the archive's top\n * directory (`package/`) as npm does. Only files and directories are written: npm package\n * archives carry no links, and an entry that would land outside `destination` is refused.\n */\nasync function extractPackageArchive(archive: string, destination: string): Promise<void> {\n const data = zlib.gunzipSync(await fs.readFile(archive));\n let offset = 0;\n let nextPath: string | undefined;\n while (offset + TAR_BLOCK_SIZE <= data.length) {\n const header = data.subarray(offset, offset + TAR_BLOCK_SIZE);\n if (header.every((byte) => byte === 0)) break;\n const size = tarNumber(header, 124, 12);\n const type = String.fromCharCode(header[156]!);\n const body = data.subarray(offset + TAR_BLOCK_SIZE, offset + TAR_BLOCK_SIZE + size);\n offset += TAR_BLOCK_SIZE + Math.ceil(size / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;\n if (type === 'x' || type === 'L') {\n nextPath = type === 'x' ? (paxPath(body) ?? nextPath) : tarString(body, 0, body.length);\n continue;\n }\n if (type === 'g') continue;\n const prefix = tarString(header, 345, 155);\n const name = nextPath ?? (prefix ? `${prefix}/${tarString(header, 0, 100)}` : tarString(header, 0, 100));\n nextPath = undefined;\n if (type !== '0' && type !== '\\0' && type !== '5') continue;\n const relative = name.split('/').slice(1).join('/');\n if (relative === '') continue;\n const target = path.resolve(destination, relative);\n if (!target.startsWith(`${destination}${path.sep}`)) {\n throw new Error(`Po package catalog archive ${archive} has an entry outside the package: ${name}`);\n }\n if (type === '5') {\n await fs.mkdir(target, { recursive: true });\n continue;\n }\n await fs.mkdir(path.dirname(target), { recursive: true });\n const executable = (tarNumber(header, 100, 8) & TAR_EXECUTABLE_BITS) !== 0;\n await fs.writeFile(target, body, { mode: executable ? 0o755 : 0o644 });\n }\n}\n\n/** Dependency fields of a staged manifest that may name another catalogue package. */\nconst STAGED_DEPENDENCY_FIELDS = ['dependencies', 'optionalDependencies', 'peerDependencies'] as const;\n\n/**\n * Unpacks one catalogue archive into `<runtime>/catalog/<hash>` and returns that directory\n * relative to the runtime, with the catalogue names its manifest depends on.\n *\n * upm only installs a package from a directory as a workspace: a `file:` archive takes its own\n * dependencies from the registry, so one catalogue archive could not depend on another. In the\n * staged manifest every dependency on another catalogue archive becomes `workspace:*`, so the\n * catalogue's copy wins whatever range the package declared, and `devDependencies`, which a\n * workspace would otherwise install, are dropped. The hash covers the archive bytes and the\n * catalogue's archive names, everything that rewrite reads, so a staged directory is reused.\n */\nasync function stageCatalogArchive(\n runtimeDirectory: string,\n archive: string,\n archiveNames: ReadonlySet<string>,\n): Promise<{ relative: string; dependencies: string[] }> {\n const hash = crypto\n .createHash('sha256')\n .update(await fs.readFile(archive))\n .update(`\\0${[...archiveNames].sort().join('\\n')}`)\n .digest('hex');\n const relative = `${CATALOG_STAGING_DIRECTORY}/${hash}`;\n const directory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY, hash);\n const stagedManifest = path.join(directory, PACKAGE_MANIFEST);\n const existing = await fs.readFile(stagedManifest, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === undefined) {\n const temporary = `${directory}.${String(process.pid)}.${crypto.randomUUID()}.tmp`;\n try {\n await extractPackageArchive(archive, temporary);\n const manifestPath = path.join(temporary, PACKAGE_MANIFEST);\n const bytes = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive has no package.json: ${archive}`);\n throw error;\n });\n const manifest: unknown = JSON.parse(bytes);\n if (!isRecord(manifest)) throw new Error(`Po package catalog archive has an invalid package.json: ${archive}`);\n delete manifest.devDependencies;\n for (const field of STAGED_DEPENDENCY_FIELDS) {\n if (!isRecord(manifest[field])) continue;\n const declared = { ...manifest[field] };\n for (const name of Object.keys(declared)) {\n if (archiveNames.has(name)) declared[name] = CATALOG_WORKSPACE_TARGET;\n }\n manifest[field] = declared;\n }\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`);\n try {\n await fs.rename(temporary, directory);\n } catch (error) {\n // Another process staged the same bytes first; its copy is identical.\n await fs.access(stagedManifest).catch(() => {\n throw error;\n });\n }\n } finally {\n await fs.rm(temporary, { recursive: true, force: true });\n }\n }\n const staged = recordValue(JSON.parse(existing ?? (await fs.readFile(stagedManifest, 'utf8'))));\n const dependencies = STAGED_DEPENDENCY_FIELDS.flatMap((field) => Object.keys(recordValue(staged[field])));\n return { relative, dependencies: dependencies.filter((name) => archiveNames.has(name)) };\n}\n\n/**\n * Stages the archive of every named catalogue package and of every catalogue package those\n * name in turn, since a staged manifest's `workspace:*` needs that workspace present. The\n * result, name to staged directory, feeds `ensureManagedPackageManifest`.\n */\nasync function stageCatalogArchives(\n runtimeDirectory: string,\n catalog: PackageCatalog,\n names: Iterable<string>,\n): Promise<Record<string, string>> {\n const archiveNames = new Set(\n [...catalog.packages].flatMap(([name, entry]) => (entry.archive === undefined ? [] : [name])),\n );\n const staged: Record<string, string> = {};\n const pending = [...names].filter((name) => archiveNames.has(name));\n while (pending.length > 0) {\n const name = pending.shift()!;\n if (Object.hasOwn(staged, name)) continue;\n const { relative, dependencies } = await stageCatalogArchive(\n runtimeDirectory,\n catalog.packages.get(name)!.archive!,\n archiveNames,\n );\n staged[name] = relative;\n pending.push(...dependencies);\n }\n return staged;\n}\n\n/**\n * Removes staged archives the runtime manifest no longer lists as workspaces, and returns their\n * folder names. An install never calls this: a running server imports from these folders (its\n * `.po-snapshots` live there), so sync prunes them under the same gate as the runtime store.\n */\nexport async function pruneStagedCatalogArchives(runtimeDirectory: string): Promise<string[]> {\n const stagingDirectory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY);\n const entries = await fs.readdir(stagingDirectory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const { manifest } = await readRuntimeManifest(path.join(runtimeDirectory, PACKAGE_MANIFEST));\n const kept = new Set((stringList(manifest.workspaces) ?? []).map((relative) => path.basename(relative)));\n return Promise.all(\n entries\n .filter((entry) => !kept.has(entry))\n .map(async (entry) => {\n await fs.rm(path.join(stagingDirectory, entry), { recursive: true, force: true });\n return entry;\n }),\n );\n}\n\n/** Splits `name@version` (scoped or not); the version is absent for a bare name or subpath. */\nfunction splitVersionedSpecifier(specifier: string): { name: string; version?: string } {\n const separator = specifier.indexOf('@', specifier.startsWith('@') ? 1 : 0);\n if (separator === -1) return { name: splitPackageSpecifier(specifier).name };\n return { name: specifier.slice(0, separator), version: specifier.slice(separator + 1) };\n}\n\nfunction npmSources(\n specifiers: readonly string[],\n catalog: PackageCatalog,\n targets: ReadonlyMap<string, string>,\n includeCatalogDependencies = false,\n): string[] {\n const names = [...new Set(specifiers.map((specifier) => splitPackageSpecifier(specifier).name))];\n if (includeCatalogDependencies) {\n for (let index = 0; index < names.length; index += 1) {\n for (const dependency of catalog.packages.get(names[index]!)?.dependencies ?? []) {\n if (!names.includes(dependency)) names.push(dependency);\n }\n }\n }\n return names.map((name) => {\n const target = targets.get(name);\n return `${NPM_SOURCE_PREFIX}${name}${target ? `@${target}` : ''}`;\n });\n}\n\nfunction pluralize(count: number, noun: string): string {\n return `${count} ${noun}${count === 1 ? '' : 's'}`;\n}\n\n/** Version of a package inside the shared runtime, absent when Po did not install it there. */\nasync function managedPackageVersion(runtimeDirectory: string, name: string): Promise<string | undefined> {\n const manifestPath = path.join(runtimeDirectory, NODE_MODULES, name, PACKAGE_MANIFEST);\n try {\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n return isRecord(parsed) && typeof parsed.version === 'string' ? parsed.version : undefined;\n } catch {\n // An unreadable manifest carries the same meaning as an absent one: nothing\n // usable is installed, so the caller treats the package as uninstalled.\n return undefined;\n }\n}\n\nfunction errorCode(error: unknown): unknown {\n return typeof error === 'object' && error !== null ? (error as { code?: unknown }).code : undefined;\n}\n\n/**\n * Installs the runtime, and when the registry cannot be reached installs it again offline:\n * an unchanged lockfile whose packages the store already holds needs no network.\n */\nasync function installWithOfflineRetry(\n install: NonNullable<LayerPackageInstallerDependencies['install']>,\n options: InstallRuntimePackagesOptions,\n onProgress: ((message: string) => void) | undefined,\n): Promise<void> {\n try {\n await install(options);\n } catch (error) {\n const code = errorCode(error);\n if (typeof code !== 'string' || !NETWORK_FAILURE_CODES.has(code)) throw error;\n onProgress?.(`the registry is unreachable (${code}); installing offline from the store`);\n try {\n await install({ ...options, preferOffline: false, offline: true });\n } catch {\n // The offline attempt only ever narrows the original failure: the network error\n // explains why the install could not complete, an EOFFLINE miss does not.\n throw error;\n }\n }\n}\n\ninterface CheckedPackage {\n name: string;\n from: string;\n to?: string;\n failure?: string;\n}\n\n/**\n * Compares every package sync installed against the registry.\n *\n * Only the shared runtime is consulted: a package that resolves from the\n * repository's own modules is not sync's to move, and a package that is not\n * installed yet is already covered by the missing-package path.\n */\nasync function resolveUpdates(\n runtimeDirectory: string,\n sources: readonly string[],\n publishedVersion: (name: string) => Promise<string>,\n onProgress: ((message: string) => void) | undefined,\n): Promise<Pick<LayerPackageResult, 'updated' | 'unchecked'>> {\n const managed = (\n await Promise.all(\n sources.map(async (source) => ({\n name: packageName(source),\n from: await managedPackageVersion(runtimeDirectory, packageName(source)),\n })),\n )\n ).filter((entry): entry is { name: string; from: string } => entry.from !== undefined);\n const checked: CheckedPackage[] = await Promise.all(\n managed.map(async (entry) => {\n try {\n return { ...entry, to: await publishedVersion(entry.name) };\n } catch (error) {\n return { ...entry, failure: (error instanceof Error ? error.message : String(error)).split('\\n')[0] };\n }\n }),\n );\n\n const updated: LayerPackageUpdate[] = [];\n const unchecked: string[] = [];\n for (const entry of checked) {\n if (entry.to === undefined) {\n unchecked.push(entry.name);\n onProgress?.(`kept ${entry.name} ${entry.from}: ${entry.failure ?? 'no published version'}`);\n continue;\n }\n if (entry.to === entry.from) continue;\n updated.push({ name: entry.name, from: entry.from, to: entry.to });\n onProgress?.(`${entry.name} ${entry.from} -> ${entry.to}`);\n }\n return { updated, unchecked };\n}\n\n/**\n * Installs the selected layer packages a root cannot resolve into the shared runtime,\n * `<po home>/runtime`, and verifies they now resolve.\n *\n * The runtime manifest is the union of what every root asked for. A root adds the\n * packages it is missing; a package it already resolves from its own node_modules stays\n * out unless an earlier run put it there. One name has one version: an exact target\n * (a sync update, a catalog archive or registry pin) replaces the declared range, last\n * writer wins, and a plain `*` never replaces a range already declared.\n *\n * `specifiers` and `exactManifest` only add behaviour: without them, and without a\n * catalogue, a run behaves as it always has.\n */\nexport async function ensureLayerPackages(\n options: EnsureLayerPackagesOptions,\n dependencies: LayerPackageInstallerDependencies = {},\n): Promise<LayerPackageResult> {\n const environment = options.environment ?? process.env;\n const homeDirectory = environment.HOME ?? os.homedir();\n const poHome = poHomeDirectory(homeDirectory, environment);\n const runtimeDirectory = poRuntimeDirectory(homeDirectory, environment);\n const resolvers = dependencies.resolvers ?? createLayerResolvers(options.repoRoot, environment);\n const external = (specifier: string): boolean => testPackageRoot(packageName(specifier), environment) === undefined;\n const configured = configuredPackageSpecifiers(options.config, options.layers).filter(external);\n const missing = configured.filter((specifier) => resolvePackageEntries(resolvers, specifier) === undefined);\n const declared = await declaredRuntimePackages(runtimeDirectory);\n const managed = configured.filter(\n (specifier) => missing.includes(specifier) || declared.has(splitPackageSpecifier(specifier).name),\n );\n const requested = (options.specifiers ?? []).filter(external).map(splitVersionedSpecifier);\n if (managed.length === 0 && requested.length === 0 && options.exactManifest !== true) {\n return { installed: [], updated: [], unchecked: [] };\n }\n\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n const pins = catalogTargets(catalog);\n for (const { name, version } of requested) {\n if (version !== undefined && catalog.packages.get(name)?.archive === undefined) pins.set(name, version);\n }\n // A requested package is missing until the runtime holds it at the version it is pinned to.\n const requestedMissing: string[] = [];\n for (const { name, version } of requested) {\n const installed = await managedPackageVersion(runtimeDirectory, name);\n const entry = catalog.packages.get(name);\n const expected = entry?.archive === undefined ? version : entry.version;\n if (installed === undefined || (expected !== undefined && installed !== expected)) requestedMissing.push(name);\n }\n const missingSources = npmSources([...missing, ...requestedMissing], catalog, pins);\n const sources = npmSources([...managed, ...requested.map(({ name }) => name)], catalog, pins, true).filter(external);\n const missingCount = missing.length + requestedMissing.length;\n\n // Refresh never moves a pinned name: catalogue entries and versioned specifiers stay put.\n const fixedNames = new Set([\n ...catalog.packages.keys(),\n ...requested.filter(({ version }) => version !== undefined).map(({ name }) => name),\n ]);\n const registrySources = sources.filter((source) => !fixedNames.has(packageName(source)));\n const { updated, unchecked } = options.refresh\n ? await resolveUpdates(\n runtimeDirectory,\n registrySources,\n dependencies.publishedVersion ?? ((name) => resolveNewest(name, { dir: runtimeDirectory, poHome })),\n options.onProgress,\n )\n : { updated: [], unchecked: [] };\n const targets = new Map(\n sources.flatMap((source) => {\n const target = pins.get(packageName(source));\n return target ? [[packageName(source), target] as const] : [];\n }),\n );\n for (const update of updated) targets.set(update.name, update.to);\n // A kept manifest still declares names earlier runs added; their archives are staged too.\n const stagedNames = new Set([...sources.map(packageName), ...(options.exactManifest === true ? [] : declared)]);\n const staged = await stageCatalogArchives(runtimeDirectory, catalog, stagedNames);\n const manifestChanged = await ensureManagedPackageManifest(\n runtimeDirectory,\n sources,\n targets,\n staged,\n options.exactManifest === true,\n );\n if (missingCount === 0 && !manifestChanged) return { installed: [], updated: [], unchecked };\n\n options.onProgress?.(\n `installing ${\n updated.length > 0\n ? pluralize(updated.length, 'update')\n : missingCount > 0\n ? pluralize(missingCount, 'missing package')\n : 'the package manifest'\n }`,\n );\n try {\n // One install reconciles the complete dependency set written to package.json.\n await installWithOfflineRetry(\n dependencies.install ?? installRuntimePackages,\n {\n dir: runtimeDirectory,\n poHome,\n // A launch never waits on registry revalidation; sync is the command that refreshes.\n preferOffline: options.refresh !== true,\n log: (message, level) => {\n if (level === 'warn') options.onProgress?.(message);\n },\n },\n options.onProgress,\n );\n } catch (error) {\n const attempted = manifestChanged ? sources : missingSources;\n throw new Error(\n `Failed to reconcile Po layer package(s): ${attempted.join(', ')}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n\n const unresolved = missing.filter((specifier) => !resolvePackageEntries(resolvers, specifier)?.length);\n if (unresolved.length > 0) {\n throw new Error(\n `Installed Po layer package(s) did not expose the configured Pi extension: ${unresolved.join(', ')}`,\n );\n }\n return { installed: missingSources, updated, unchecked };\n}\n\n/** One selector per name in the shared runtime. Caller holds the sync lock throughout. */\nexport async function ensureRuntimeImportPackage(\n name: string,\n version: string,\n options: { homeDirectory: string; environment: Readonly<Record<string, string | undefined>> },\n): Promise<void> {\n const environment = { ...options.environment, HOME: options.homeDirectory };\n const poHome = poHomeDirectory(options.homeDirectory, environment);\n const directory = poRuntimeDirectory(options.homeDirectory, environment);\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n const { manifest } = await readRuntimeManifest(manifestPath);\n const declared = recordValue(manifest.dependencies);\n const imports = recordValue(manifest.poCodemodeDependencies);\n const imported = recordValue(imports[name]);\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n if (catalog.packages.has(name) || (Object.hasOwn(declared, name) && declared[name] !== imported.selector)) {\n throw new Error(\n `Cannot import ${name}: Po manages this runtime dependency (${JSON.stringify(declared[name] ?? 'catalogue')}).`,\n );\n }\n if (Object.hasOwn(imports, name) && imported.selector !== version) {\n throw new Error(`Cannot import ${name}@${version}: the hub already uses ${name}@${String(imported.selector)}.`);\n }\n const installed = await managedPackageVersion(directory, name);\n if (declared[name] === version && installed !== undefined && imported.resolved === installed) return;\n // Only a successful reconciliation is cacheable, not the manifest upm writes ahead of a failed install.\n manifest.poCodemodeDependencies = { ...imports, [name]: { selector: version } };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(manifest, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n const pins = new Map([[name, version]]);\n const sources = npmSources([`${name}@${version}`], catalog, pins, true);\n const staged = await stageCatalogArchives(\n directory,\n catalog,\n new Set([...sources.map(packageName), ...Object.keys(declared)]),\n );\n await ensureManagedPackageManifest(directory, sources, pins, staged);\n await installWithOfflineRetry(installRuntimePackages, { dir: directory, poHome, preferOffline: true }, undefined);\n const resolved = await managedPackageVersion(directory, name);\n if (resolved === undefined) throw new Error(`Runtime import ${name}@${version} was not installed.`);\n const reconciled = (await readRuntimeManifest(manifestPath)).manifest;\n reconciled.poCodemodeDependencies = {\n ...recordValue(reconciled.poCodemodeDependencies),\n [name]: { selector: version, resolved },\n };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(reconciled, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,6BAA6B;;AAEnC,MAAM,2BAA2B;;AAEjC,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,sBAAsB;;AAE5B,MAAM,2BAA2B;CAAC;CAAQ;CAAW;AAAY;;AAEjE,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAY;CAAa;AAAW,CAAC;AAE5E,SAAS,oBAAoB,UAA0B;CACrD,MAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS,WAAW,GAAG,IAAI,IAAI,CAAC;CAC7E,OAAO,mBAAmB,KAAK,WAAW,SAAS,MAAM,GAAG,cAAc;AAC5E;;;;;;AAOA,MAAa,4BAA4B;CAEvC,+BAA+B;CAC/B,mCAAmC;CACnC,uCAAuC;CACvC,kCAAkC;CAClC,kCAAkC;CAClC,uBAAuB;CACvB,yBAAyB;CACzB,yBAAyB;CACzB,6BAA6B;CAC7B,4BAA4B;CAC5B,yBAAyB;AAC3B;AAEA,MAAM,gCAAgC,IAAI,IAAI,OAAO,KAAK,yBAAyB,CAAC,CAAC,IAAI,mBAAmB,CAAC;AA4D7G,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,YAAY,OAAyC;CAC5D,OAAO,SAAS,KAAK,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC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AG;CAC7D,WAAW,yBAAyB;EAClC,GAAG,YAAY,WAAW,sBAAsB;GAC/C,OAAO;GAAE,UAAU;GAAS;EAAS;CACxC;CACA,MAAM,gBACJ,mBAAmB,CAAC,CAAC,IAAI,SAAS,GAClC,cACA,GAAG,KAAK,UAAU,YAAY,MAAM,CAAC,EAAE,KACvC,kBACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/layerPackageInstaller/index.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { isLocalPackageSpecifier, type MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nimport { consumerPackageEntry, splitPackageSpecifier, testPackageRoot } from '@agimon-ai/po-core/moduleResolution';\nimport { createNodePlatform } from '@agimon-ai/po-core/nodePlatform';\nimport { BACKGROUND_CONTEXT, writeFileAtomic } from '@agimon-ai/po-core/platform';\nimport {\n installRuntimePackages,\n type InstallRuntimePackagesOptions,\n resolveNewest,\n} from '@agimon-ai/po-core/runtimePackages';\nimport { poHomeDirectory, poRuntimeDirectory } from '@agimon-ai/po-core/runtimePiSettings';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { createLayerResolvers, type ExtensionLayerResolvers } from '../../builders/cli/extensionAssembler';\n\nconst NPM_SOURCE_PREFIX = 'npm:';\nconst FILE_SPECIFIER_PREFIX = 'file:';\nconst WORKSPACE_SPECIFIER_PREFIX = 'workspace:';\n/** Root target of a staged catalogue archive: always the staged workspace, never the registry. */\nconst CATALOG_WORKSPACE_TARGET = 'workspace:*';\n/** Where catalogue archives are unpacked inside the runtime, one directory per archive hash. */\nconst CATALOG_STAGING_DIRECTORY = 'catalog';\nconst RUNTIME_PACKAGE_NAME = 'po-runtime';\nconst UNPINNED_PACKAGE_RANGE = '*';\nconst PACKAGE_MANIFEST = 'package.json';\nconst NODE_MODULES = 'node_modules';\nconst PACKAGE_CATALOG_ENV = 'PO_PACKAGE_CATALOG';\n/** The registry catalogue a release writes into the CLI package: `<package root>/dist/catalog/index.json`. */\nconst BUNDLED_CATALOG_SEGMENTS = ['dist', 'catalog', 'index.json'] as const;\n/** upm error codes that mean the registry could not be reached, so the store may still answer. */\nconst NETWORK_FAILURE_CODES = new Set(['ENETWORK', 'ETIMEDOUT', 'EREGISTRY']);\n\nfunction overridePackageName(selector: string): string {\n const separatorIndex = selector.indexOf('@', selector.startsWith('@') ? 1 : 0);\n return separatorIndex === -1 ? selector : selector.slice(0, separatorIndex);\n}\n\n/**\n * Runtime compatibility pins and same-major patches for current foundation packages.\n * Package managers only honor overrides from the install root, so published extensions\n * cannot carry these fixes in their own manifests.\n */\nexport const SAFE_TRANSITIVE_OVERRIDES = {\n // ponytail: Pin for Pi 1.4.0's declaration API; advance with the host's Pi version.\n '@earendil-works/pi-codemode': '1.4.0',\n '@hono/node-server@2.0.0 - 2.0.9': '^2.0.10',\n '@opentelemetry/core@2.0.0 - 2.7.999': '2.8.0',\n 'brace-expansion@1.0.0 - 1.1.20': '^1.1.21',\n 'brace-expansion@5.0.0 - 5.0.11': '^5.0.12',\n 'hono@4.0.0 - 4.13.7': '4.13.8',\n 'js-yaml@4.0.0 - 4.3.1': '^4.3.2',\n 'js-yaml@5.0.0 - 5.2.1': '^5.2.2',\n 'liquidjs@10.0.0 - 10.27.1': '^10.27.2',\n 'protobufjs@8.0.0 - 8.7.1': '^8.7.2',\n 'undici@7.0.0 - 7.29.0': '^7.29.1',\n} as const satisfies Readonly<Record<string, string>>;\n\nconst SAFE_TRANSITIVE_PACKAGE_NAMES = new Set(Object.keys(SAFE_TRANSITIVE_OVERRIDES).map(overridePackageName));\n\nexport interface EnsureLayerPackagesOptions {\n /**\n * The Po root whose layers name the packages. Its own node_modules chain is\n * resolved first; what it cannot provide is installed into the one runtime\n * every root shares, `<po home>/runtime`.\n */\n repoRoot: string;\n config: MajorModesConfig;\n layers: readonly string[];\n environment?: NodeJS.ProcessEnv;\n /**\n * Move every managed package to its newest published version.\n *\n * Launch installs what a selection needs and nothing more, so a session never\n * pays for a registry round trip. Sync is the explicit maintenance command and\n * is the only caller that asks for this.\n */\n refresh?: boolean;\n /**\n * Packages installed into the runtime whatever the root resolves itself, such as the\n * catalogue's `install` list. A `name@version` specifier pins that exact version; a\n * catalogue archive for the name still wins. Refresh never moves a pinned name.\n */\n specifiers?: readonly string[];\n /**\n * Make the runtime manifest declare exactly this run's packages (the specifiers, the\n * selected names and their catalogue dependencies), so pruning can drop anything else.\n * Without it the manifest only grows.\n */\n exactManifest?: boolean;\n /** Receives one human-readable line per package decision. */\n onProgress?: (message: string) => void;\n}\n\nexport interface LayerPackageInstallerDependencies {\n /** Install seam; the default installs `<po home>/runtime` with upm. */\n install?: (options: InstallRuntimePackagesOptions) => Promise<unknown>;\n resolvers?: ExtensionLayerResolvers;\n /** Registry lookup seam; the default resolves the newest allowed version with upm. */\n publishedVersion?: (name: string) => Promise<string>;\n}\n\n/** One managed package moving from the installed version to the newest published one. */\nexport interface LayerPackageUpdate {\n name: string;\n from: string;\n to: string;\n}\n\nexport interface LayerPackageResult {\n /** Sources installed because a configured extension could not be resolved. */\n installed: string[];\n /** Packages this run moved to a newer published version. */\n updated: LayerPackageUpdate[];\n /** Packages left at the installed version because the registry could not be read. */\n unchecked: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction recordValue(value: unknown): Record<string, unknown> {\n return isRecord(value) ? { ...value } : {};\n}\n\nfunction withoutConflictingTransitiveOverrides(value: unknown): Record<string, unknown> {\n const overrides = recordValue(value);\n for (const [selector, replacement] of Object.entries(overrides)) {\n if (SAFE_TRANSITIVE_PACKAGE_NAMES.has(overridePackageName(selector))) {\n delete overrides[selector];\n } else if (isRecord(replacement)) {\n overrides[selector] = withoutConflictingTransitiveOverrides(replacement);\n }\n }\n return overrides;\n}\n\n/** Earlier versions overrode catalog packages with relative `file:` targets; any other override is not Po's. */\nfunction withoutCatalogOverrides(overrides: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(overrides).filter(\n ([, replacement]) => !(typeof replacement === 'string' && replacement.startsWith(FILE_SPECIFIER_PREFIX)),\n ),\n );\n}\n\n/** The published (non-local, required) package specifiers the default and the given layers name. */\nfunction configuredPackageSpecifiers(config: MajorModesConfig, layers: readonly string[]): string[] {\n const specifiers = new Set<string>();\n const selectedDefinitions = [\n ...(config.default ? [config.default] : []),\n ...layers.map((layerName) => {\n const layer = config.layers[layerName];\n if (!layer) throw new Error(`Unknown layer: ${layerName}`);\n return layer;\n }),\n ];\n for (const layer of selectedDefinitions) {\n for (const configured of layer.packages ?? []) {\n const specifier = typeof configured === 'string' ? configured : configured.name;\n const optional = typeof configured !== 'string' && configured.optional === true;\n if (!optional && !isLocalPackageSpecifier(specifier)) specifiers.add(specifier);\n }\n }\n return [...specifiers];\n}\n\nfunction resolvePackageEntries(resolvers: ExtensionLayerResolvers, specifier: string): string[] | undefined {\n const entries = resolvers.optionalPackageEntries?.(specifier);\n if (entries !== undefined) return entries;\n const entry = resolvers.optionalPackageEntry(specifier);\n return entry ? [entry] : undefined;\n}\n\nasync function readRuntimeManifest(\n manifestPath: string,\n): Promise<{ current: string | undefined; manifest: Record<string, unknown> }> {\n const current = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (current === undefined) return { current, manifest: { name: RUNTIME_PACKAGE_NAME, private: true } };\n const parsed: unknown = JSON.parse(current);\n if (!isRecord(parsed)) throw new Error(`Po runtime package manifest at ${manifestPath} must be a JSON object.`);\n return { current, manifest: parsed };\n}\n\n/** Names the runtime manifest already declares: what earlier runs, from any root, installed there. */\nasync function declaredRuntimePackages(runtimeDirectory: string): Promise<Set<string>> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n return new Set(Object.keys(recordValue((await readRuntimeManifest(manifestPath)).manifest.dependencies)));\n}\n\n/**\n * Adds a package set and the patched transitive policy to the shared runtime manifest.\n *\n * `targets` pins names to exact versions or `workspace:*`. `catalogWorkspaces` maps each\n * staged catalogue archive's name to its directory relative to the runtime; the manifest\n * lists exactly those directories as its `workspaces`, so a catalogue package's dependency\n * on another one links the staged copy instead of reaching the registry. Both `overrides` and\n * `pnpm.overrides` are written; upm reads both.\n * With `exact`, declared names outside `sources` are dropped instead of kept.\n */\nexport async function ensureManagedPackageManifest(\n runtimeDirectory: string,\n sources: readonly string[],\n targets: ReadonlyMap<string, string> = new Map(),\n catalogWorkspaces: Readonly<Record<string, string>> = {},\n exact = false,\n): Promise<boolean> {\n const manifestPath = path.join(runtimeDirectory, PACKAGE_MANIFEST);\n const { current, manifest } = await readRuntimeManifest(manifestPath);\n\n const declared = recordValue(manifest.dependencies);\n const sourceNames = new Set(sources.map(packageName));\n const dependencies = exact\n ? Object.fromEntries(Object.entries(declared).filter(([name]) => sourceNames.has(name)))\n : declared;\n // Every root shares this manifest, so a catalog archive another process staged (a desktop\n // build, say) may not exist for this one: without a staged copy here it falls back to the\n // registry, which keeps the whole set installable. `file:` targets are what earlier\n // versions wrote for archives.\n for (const [name, declared] of Object.entries(dependencies)) {\n if (Object.hasOwn(catalogWorkspaces, name)) {\n dependencies[name] = CATALOG_WORKSPACE_TARGET;\n } else if (\n typeof declared === 'string' &&\n (declared.startsWith(FILE_SPECIFIER_PREFIX) || declared.startsWith(WORKSPACE_SPECIFIER_PREFIX))\n ) {\n dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n }\n for (const source of sources) {\n const name = packageName(source);\n const target = targets.get(name);\n // An exact target is what makes an update reach the store: a package manager keeps a\n // locked version whenever the recorded range still admits it.\n if (target !== undefined) dependencies[name] = target;\n else if (!Object.hasOwn(dependencies, name)) dependencies[name] = UNPINNED_PACKAGE_RANGE;\n }\n manifest.dependencies = dependencies;\n // Po owns the runtime's workspaces: exactly the staged archives, which reach only each other.\n const workspaces = Object.values(catalogWorkspaces).sort();\n if (workspaces.length > 0) manifest.workspaces = workspaces;\n else delete manifest.workspaces;\n // Nested and overlapping consumer rules can take precedence in cases that retain\n // vulnerable versions, so Po owns these package-specific selectors recursively.\n manifest.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(manifest.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n const pnpm = recordValue(manifest.pnpm);\n pnpm.overrides = {\n ...withoutCatalogOverrides(withoutConflictingTransitiveOverrides(pnpm.overrides)),\n ...SAFE_TRANSITIVE_OVERRIDES,\n };\n manifest.pnpm = pnpm;\n\n const serialized = `${JSON.stringify(manifest, null, 2)}\\n`;\n if (serialized === current) return false;\n await fs.mkdir(runtimeDirectory, { recursive: true });\n await writeFileAtomic(createNodePlatform().env(runtimeDirectory), manifestPath, serialized, BACKGROUND_CONTEXT);\n return true;\n}\n\n/** Finds required npm packages selected by defaults and active layers that Po cannot resolve. */\nexport function missingLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n resolvers: ExtensionLayerResolvers,\n): string[] {\n return configuredPackageSpecifiers(config, layers).filter(\n (specifier) => resolvePackageEntries(resolvers, specifier) === undefined,\n );\n}\n\n/** Whether `root`'s own node_modules chain holds the package, walked the way Node looks it up from `root`. */\nasync function ownsPackage(name: string, root: string): Promise<boolean> {\n for (let directory = path.resolve(root); ; directory = path.dirname(directory)) {\n if (\n await fs.access(path.join(directory, NODE_MODULES, name, PACKAGE_MANIFEST)).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n )\n )\n return true;\n if (path.dirname(directory) === directory) return false;\n }\n}\n\n/**\n * The required npm packages the default and the given layers name that `root` does not get\n * from its own node_modules chain: what the shared runtime provides for it, whether it does so\n * already or not yet. Sync declares exactly these, over every root, in the runtime manifest; a\n * name the runtime already provides still counts, or the next exact manifest would drop it.\n */\nexport async function runtimeLayerPackageSpecifiers(\n config: MajorModesConfig,\n layers: readonly string[],\n root: string,\n): Promise<string[]> {\n const specifiers = configuredPackageSpecifiers(config, layers);\n const owned = await Promise.all(\n specifiers.map((specifier) => ownsPackage(splitPackageSpecifier(specifier).name, root)),\n );\n return specifiers.filter((_specifier, index) => !owned[index]);\n}\n\nfunction packageName(source: string): string {\n const specifier = source.startsWith(NPM_SOURCE_PREFIX) ? source.slice(NPM_SOURCE_PREFIX.length) : source;\n if (specifier.startsWith('@')) {\n const slash = specifier.indexOf('/');\n const version = slash === -1 ? -1 : specifier.indexOf('@', slash);\n return version === -1 ? specifier : specifier.slice(0, version);\n }\n const version = specifier.indexOf('@');\n return version === -1 ? specifier : specifier.slice(0, version);\n}\n\ninterface PackageCatalogEntry {\n /** Absolute path of the bundled archive; it takes precedence over `version`. */\n archive?: string;\n /** Exact registry version, pinned when the entry has no archive. */\n version?: string;\n dependencies: readonly string[];\n}\n\ninterface PackageCatalog {\n packages: ReadonlyMap<string, PackageCatalogEntry>;\n /** Feature packages Po installs out of the box, by name. */\n install: readonly string[];\n}\n\nconst EMPTY_CATALOG: PackageCatalog = { packages: new Map(), install: [] };\n\nfunction stringList(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const strings = value.filter((item): item is string => typeof item === 'string');\n return strings.length === value.length ? strings : undefined;\n}\n\nfunction defaultBundledCatalogPath(): string | undefined {\n try {\n return path.join(poPackageRoot(), ...BUNDLED_CATALOG_SEGMENTS);\n } catch {\n // A bundle with no locatable Po package root has no bundled catalogue to read.\n return undefined;\n }\n}\n\n/**\n * The first catalogue present: `PO_PACKAGE_CATALOG` (desktop's archives), then the one\n * a release bundles into the CLI. With neither, the runtime installs only what roots name.\n */\nasync function packageCatalogPath(environment: NodeJS.ProcessEnv): Promise<string | undefined> {\n const configured = environment[PACKAGE_CATALOG_ENV]?.trim();\n if (configured) return configured;\n const bundledCatalogPath = defaultBundledCatalogPath();\n if (bundledCatalogPath === undefined) return undefined;\n return fs.access(bundledCatalogPath).then(\n () => bundledCatalogPath,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\nasync function readPackageCatalog(manifestPath: string | undefined): Promise<PackageCatalog> {\n if (!manifestPath) return EMPTY_CATALOG;\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n if (!isRecord(parsed) || parsed.version !== 1 || !isRecord(parsed.packages)) {\n throw new Error(`Unsupported Po package catalog: ${manifestPath}`);\n }\n const packages = new Map<string, PackageCatalogEntry>();\n for (const [name, value] of Object.entries(parsed.packages)) {\n if (\n !isRecord(value) ||\n !Array.isArray(value.dependencies) ||\n (value.archive !== undefined && typeof value.archive !== 'string') ||\n (value.version !== undefined && typeof value.version !== 'string') ||\n (value.archive === undefined && value.version === undefined)\n ) {\n throw new Error(`Invalid package entry for ${name} in ${manifestPath}`);\n }\n const dependencies = stringList(value.dependencies);\n if (!dependencies) throw new Error(`Invalid dependencies for ${name} in ${manifestPath}`);\n const version = typeof value.version === 'string' ? value.version : undefined;\n if (typeof value.archive !== 'string') {\n packages.set(name, { version, dependencies });\n continue;\n }\n const archive = path.resolve(path.dirname(manifestPath), value.archive);\n await fs.access(archive).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive is missing: ${archive}`);\n throw error;\n });\n packages.set(name, { archive, version, dependencies });\n }\n const install = parsed.install === undefined ? [] : stringList(parsed.install);\n if (!install) throw new Error(`Invalid install list in ${manifestPath}`);\n const unknown = install.filter((name) => !packages.has(name));\n if (unknown.length > 0) throw new Error(`Po package catalog installs unlisted package(s): ${unknown.join(', ')}`);\n return { packages, install };\n}\n\n/**\n * The catalogue's `install` list as exact `name@version` specifiers for\n * `EnsureLayerPackagesOptions.specifiers`; empty when no catalogue is present.\n */\nexport async function catalogInstallSpecifiers(environment: NodeJS.ProcessEnv = process.env): Promise<string[]> {\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n return catalog.install.map((name) => {\n const version = catalog.packages.get(name)?.version;\n return version ? `${name}@${version}` : name;\n });\n}\n\n/**\n * The installed package roots of the catalogue's `install` list, resolved the way a root\n * resolves a bare name (its own node_modules, then the shared runtime). The global web build\n * covers them, so every first-party plugin has a slot; a name not installed yet is left out.\n */\nexport async function catalogPackageRoots(\n globalRoot: string,\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<string[]> {\n const roots: string[] = [];\n for (const name of (await readPackageCatalog(await packageCatalogPath(environment))).install) {\n const manifest = consumerPackageEntry(`${name}/${PACKAGE_MANIFEST}`, globalRoot, environment);\n if (manifest !== undefined) roots.push(path.dirname(await fs.realpath(manifest)));\n }\n return roots;\n}\n\n/** SHA-256 of the catalogue file in use, or `none` when no catalogue is present. */\nexport async function packageCatalogHash(environment: NodeJS.ProcessEnv = process.env): Promise<string> {\n const catalogPath = await packageCatalogPath(environment);\n if (!catalogPath) return 'none';\n return crypto\n .createHash('sha256')\n .update(await fs.readFile(catalogPath))\n .digest('hex');\n}\n\n/** Exact target per catalogue name: its staged workspace for an archive, else its registry version. */\nfunction catalogTargets(catalog: PackageCatalog): Map<string, string> {\n return new Map(\n [...catalog.packages].flatMap(([name, entry]) => {\n if (entry.archive !== undefined) return [[name, CATALOG_WORKSPACE_TARGET] as const];\n return entry.version !== undefined ? [[name, entry.version] as const] : [];\n }),\n );\n}\n\nconst TAR_BLOCK_SIZE = 512;\nconst TAR_EXECUTABLE_BITS = 0o111;\n\nfunction tarString(block: Buffer, start: number, length: number): string {\n const field = block.subarray(start, start + length);\n const end = field.indexOf(0);\n return field.subarray(0, end === -1 ? field.length : end).toString('utf8');\n}\n\nfunction tarNumber(block: Buffer, start: number, length: number): number {\n const field = block.subarray(start, start + length);\n // GNU base-256: the high bit of the first byte marks a big-endian binary number.\n if ((field[0]! & 0x80) !== 0) return field.subarray(1).reduce((value, byte) => value * 256 + byte, field[0]! & 0x7f);\n const text = tarString(block, start, length).trim();\n return text === '' ? 0 : Number.parseInt(text, 8);\n}\n\n/** The `path` record of a pax extended header, if it has one. */\nfunction paxPath(data: Buffer): string | undefined {\n let found: string | undefined;\n let offset = 0;\n while (offset < data.length) {\n const space = data.indexOf(0x20, offset);\n if (space === -1) break;\n const length = Number.parseInt(data.subarray(offset, space).toString('utf8'), 10);\n if (!Number.isFinite(length) || length <= 0) break;\n const record = data.subarray(space + 1, offset + length - 1).toString('utf8');\n const separator = record.indexOf('=');\n if (record.slice(0, separator) === 'path') found = record.slice(separator + 1);\n offset += length;\n }\n return found;\n}\n\n/**\n * Unpacks a gzipped npm package archive into `destination`, dropping the archive's top\n * directory (`package/`) as npm does. Only files and directories are written: npm package\n * archives carry no links, and an entry that would land outside `destination` is refused.\n */\nasync function extractPackageArchive(archive: string, destination: string): Promise<void> {\n const data = zlib.gunzipSync(await fs.readFile(archive));\n let offset = 0;\n let nextPath: string | undefined;\n while (offset + TAR_BLOCK_SIZE <= data.length) {\n const header = data.subarray(offset, offset + TAR_BLOCK_SIZE);\n if (header.every((byte) => byte === 0)) break;\n const size = tarNumber(header, 124, 12);\n const type = String.fromCharCode(header[156]!);\n const body = data.subarray(offset + TAR_BLOCK_SIZE, offset + TAR_BLOCK_SIZE + size);\n offset += TAR_BLOCK_SIZE + Math.ceil(size / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;\n if (type === 'x' || type === 'L') {\n nextPath = type === 'x' ? (paxPath(body) ?? nextPath) : tarString(body, 0, body.length);\n continue;\n }\n if (type === 'g') continue;\n const prefix = tarString(header, 345, 155);\n const name = nextPath ?? (prefix ? `${prefix}/${tarString(header, 0, 100)}` : tarString(header, 0, 100));\n nextPath = undefined;\n if (type !== '0' && type !== '\\0' && type !== '5') continue;\n const relative = name.split('/').slice(1).join('/');\n if (relative === '') continue;\n const target = path.resolve(destination, relative);\n if (!target.startsWith(`${destination}${path.sep}`)) {\n throw new Error(`Po package catalog archive ${archive} has an entry outside the package: ${name}`);\n }\n if (type === '5') {\n await fs.mkdir(target, { recursive: true });\n continue;\n }\n await fs.mkdir(path.dirname(target), { recursive: true });\n const executable = (tarNumber(header, 100, 8) & TAR_EXECUTABLE_BITS) !== 0;\n await fs.writeFile(target, body, { mode: executable ? 0o755 : 0o644 });\n }\n}\n\n/** Dependency fields of a staged manifest that may name another catalogue package. */\nconst STAGED_DEPENDENCY_FIELDS = ['dependencies', 'optionalDependencies', 'peerDependencies'] as const;\n\n/**\n * Unpacks one catalogue archive into `<runtime>/catalog/<hash>` and returns that directory\n * relative to the runtime, with the catalogue names its manifest depends on.\n *\n * upm only installs a package from a directory as a workspace: a `file:` archive takes its own\n * dependencies from the registry, so one catalogue archive could not depend on another. In the\n * staged manifest every dependency on another catalogue archive becomes `workspace:*`, so the\n * catalogue's copy wins whatever range the package declared, and `devDependencies`, which a\n * workspace would otherwise install, are dropped. The hash covers the archive bytes and the\n * catalogue's archive names, everything that rewrite reads, so a staged directory is reused.\n */\nasync function stageCatalogArchive(\n runtimeDirectory: string,\n archive: string,\n archiveNames: ReadonlySet<string>,\n): Promise<{ relative: string; dependencies: string[] }> {\n const hash = crypto\n .createHash('sha256')\n .update(await fs.readFile(archive))\n .update(`\\0${[...archiveNames].sort().join('\\n')}`)\n .digest('hex');\n const relative = `${CATALOG_STAGING_DIRECTORY}/${hash}`;\n const directory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY, hash);\n const stagedManifest = path.join(directory, PACKAGE_MANIFEST);\n const existing = await fs.readFile(stagedManifest, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === undefined) {\n const temporary = `${directory}.${String(process.pid)}.${crypto.randomUUID()}.tmp`;\n try {\n await extractPackageArchive(archive, temporary);\n const manifestPath = path.join(temporary, PACKAGE_MANIFEST);\n const bytes = await fs.readFile(manifestPath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw new Error(`Po package catalog archive has no package.json: ${archive}`);\n throw error;\n });\n const manifest: unknown = JSON.parse(bytes);\n if (!isRecord(manifest)) throw new Error(`Po package catalog archive has an invalid package.json: ${archive}`);\n delete manifest.devDependencies;\n for (const field of STAGED_DEPENDENCY_FIELDS) {\n if (!isRecord(manifest[field])) continue;\n const declared = { ...manifest[field] };\n for (const name of Object.keys(declared)) {\n if (archiveNames.has(name)) declared[name] = CATALOG_WORKSPACE_TARGET;\n }\n manifest[field] = declared;\n }\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`);\n try {\n await fs.rename(temporary, directory);\n } catch (error) {\n // Another process staged the same bytes first; its copy is identical.\n await fs.access(stagedManifest).catch(() => {\n throw error;\n });\n }\n } finally {\n await fs.rm(temporary, { recursive: true, force: true });\n }\n }\n const staged = recordValue(JSON.parse(existing ?? (await fs.readFile(stagedManifest, 'utf8'))));\n const dependencies = STAGED_DEPENDENCY_FIELDS.flatMap((field) => Object.keys(recordValue(staged[field])));\n return { relative, dependencies: dependencies.filter((name) => archiveNames.has(name)) };\n}\n\n/**\n * Stages the archive of every named catalogue package and of every catalogue package those\n * name in turn, since a staged manifest's `workspace:*` needs that workspace present. The\n * result, name to staged directory, feeds `ensureManagedPackageManifest`.\n */\nasync function stageCatalogArchives(\n runtimeDirectory: string,\n catalog: PackageCatalog,\n names: Iterable<string>,\n): Promise<Record<string, string>> {\n const archiveNames = new Set(\n [...catalog.packages].flatMap(([name, entry]) => (entry.archive === undefined ? [] : [name])),\n );\n const staged: Record<string, string> = {};\n const pending = [...names].filter((name) => archiveNames.has(name));\n while (pending.length > 0) {\n const name = pending.shift()!;\n if (Object.hasOwn(staged, name)) continue;\n const { relative, dependencies } = await stageCatalogArchive(\n runtimeDirectory,\n catalog.packages.get(name)!.archive!,\n archiveNames,\n );\n staged[name] = relative;\n pending.push(...dependencies);\n }\n return staged;\n}\n\n/**\n * Removes staged archives the runtime manifest no longer lists as workspaces, and returns their\n * folder names. An install never calls this: a running server imports from these folders (its\n * `.po-snapshots` live there), so sync prunes them under the same gate as the runtime store.\n */\nexport async function pruneStagedCatalogArchives(runtimeDirectory: string): Promise<string[]> {\n const stagingDirectory = path.join(runtimeDirectory, CATALOG_STAGING_DIRECTORY);\n const entries = await fs.readdir(stagingDirectory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const { manifest } = await readRuntimeManifest(path.join(runtimeDirectory, PACKAGE_MANIFEST));\n const kept = new Set((stringList(manifest.workspaces) ?? []).map((relative) => path.basename(relative)));\n return Promise.all(\n entries\n .filter((entry) => !kept.has(entry))\n .map(async (entry) => {\n await fs.rm(path.join(stagingDirectory, entry), { recursive: true, force: true });\n return entry;\n }),\n );\n}\n\n/** Splits `name@version` (scoped or not); the version is absent for a bare name or subpath. */\nfunction splitVersionedSpecifier(specifier: string): { name: string; version?: string } {\n const separator = specifier.indexOf('@', specifier.startsWith('@') ? 1 : 0);\n if (separator === -1) return { name: splitPackageSpecifier(specifier).name };\n return { name: specifier.slice(0, separator), version: specifier.slice(separator + 1) };\n}\n\nfunction npmSources(\n specifiers: readonly string[],\n catalog: PackageCatalog,\n targets: ReadonlyMap<string, string>,\n includeCatalogDependencies = false,\n): string[] {\n const names = [...new Set(specifiers.map((specifier) => splitPackageSpecifier(specifier).name))];\n if (includeCatalogDependencies) {\n for (let index = 0; index < names.length; index += 1) {\n for (const dependency of catalog.packages.get(names[index]!)?.dependencies ?? []) {\n if (!names.includes(dependency)) names.push(dependency);\n }\n }\n }\n return names.map((name) => {\n const target = targets.get(name);\n return `${NPM_SOURCE_PREFIX}${name}${target ? `@${target}` : ''}`;\n });\n}\n\nfunction pluralize(count: number, noun: string): string {\n return `${count} ${noun}${count === 1 ? '' : 's'}`;\n}\n\n/** Version of a package inside the shared runtime, absent when Po did not install it there. */\nasync function managedPackageVersion(runtimeDirectory: string, name: string): Promise<string | undefined> {\n const manifestPath = path.join(runtimeDirectory, NODE_MODULES, name, PACKAGE_MANIFEST);\n try {\n const parsed: unknown = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n return isRecord(parsed) && typeof parsed.version === 'string' ? parsed.version : undefined;\n } catch {\n // An unreadable manifest carries the same meaning as an absent one: nothing\n // usable is installed, so the caller treats the package as uninstalled.\n return undefined;\n }\n}\n\nfunction errorCode(error: unknown): unknown {\n return typeof error === 'object' && error !== null ? (error as { code?: unknown }).code : undefined;\n}\n\n/**\n * Installs the runtime, and when the registry cannot be reached installs it again offline:\n * an unchanged lockfile whose packages the store already holds needs no network.\n */\nasync function installWithOfflineRetry(\n install: NonNullable<LayerPackageInstallerDependencies['install']>,\n options: InstallRuntimePackagesOptions,\n onProgress: ((message: string) => void) | undefined,\n): Promise<void> {\n try {\n await install(options);\n } catch (error) {\n const code = errorCode(error);\n if (typeof code !== 'string' || !NETWORK_FAILURE_CODES.has(code)) throw error;\n onProgress?.(`the registry is unreachable (${code}); installing offline from the store`);\n try {\n await install({ ...options, preferOffline: false, offline: true });\n } catch {\n // The offline attempt only ever narrows the original failure: the network error\n // explains why the install could not complete, an EOFFLINE miss does not.\n throw error;\n }\n }\n}\n\ninterface CheckedPackage {\n name: string;\n from: string;\n to?: string;\n failure?: string;\n}\n\n/**\n * Compares every package sync installed against the registry.\n *\n * Only the shared runtime is consulted: a package that resolves from the\n * repository's own modules is not sync's to move, and a package that is not\n * installed yet is already covered by the missing-package path.\n */\nasync function resolveUpdates(\n runtimeDirectory: string,\n sources: readonly string[],\n publishedVersion: (name: string) => Promise<string>,\n onProgress: ((message: string) => void) | undefined,\n): Promise<Pick<LayerPackageResult, 'updated' | 'unchecked'>> {\n const managed = (\n await Promise.all(\n sources.map(async (source) => ({\n name: packageName(source),\n from: await managedPackageVersion(runtimeDirectory, packageName(source)),\n })),\n )\n ).filter((entry): entry is { name: string; from: string } => entry.from !== undefined);\n const checked: CheckedPackage[] = await Promise.all(\n managed.map(async (entry) => {\n try {\n return { ...entry, to: await publishedVersion(entry.name) };\n } catch (error) {\n return { ...entry, failure: (error instanceof Error ? error.message : String(error)).split('\\n')[0] };\n }\n }),\n );\n\n const updated: LayerPackageUpdate[] = [];\n const unchecked: string[] = [];\n for (const entry of checked) {\n if (entry.to === undefined) {\n unchecked.push(entry.name);\n onProgress?.(`kept ${entry.name} ${entry.from}: ${entry.failure ?? 'no published version'}`);\n continue;\n }\n if (entry.to === entry.from) continue;\n updated.push({ name: entry.name, from: entry.from, to: entry.to });\n onProgress?.(`${entry.name} ${entry.from} -> ${entry.to}`);\n }\n return { updated, unchecked };\n}\n\n/**\n * Installs the selected layer packages a root cannot resolve into the shared runtime,\n * `<po home>/runtime`, and verifies they now resolve.\n *\n * The runtime manifest is the union of what every root asked for. A root adds the\n * packages it is missing; a package it already resolves from its own node_modules stays\n * out unless an earlier run put it there. One name has one version: an exact target\n * (a sync update, a catalog archive or registry pin) replaces the declared range, last\n * writer wins, and a plain `*` never replaces a range already declared.\n *\n * `specifiers` and `exactManifest` only add behaviour: without them, and without a\n * catalogue, a run behaves as it always has.\n */\nexport async function ensureLayerPackages(\n options: EnsureLayerPackagesOptions,\n dependencies: LayerPackageInstallerDependencies = {},\n): Promise<LayerPackageResult> {\n const environment = options.environment ?? process.env;\n const homeDirectory = environment.HOME ?? os.homedir();\n const poHome = poHomeDirectory(homeDirectory, environment);\n const runtimeDirectory = poRuntimeDirectory(homeDirectory, environment);\n // The root's own .npmrc routes and authenticates the registries its layers name.\n const npmrcFiles = [path.join(options.repoRoot, '.npmrc')];\n const resolvers = dependencies.resolvers ?? createLayerResolvers(options.repoRoot, environment);\n const external = (specifier: string): boolean => testPackageRoot(packageName(specifier), environment) === undefined;\n const configured = configuredPackageSpecifiers(options.config, options.layers).filter(external);\n const missing = configured.filter((specifier) => resolvePackageEntries(resolvers, specifier) === undefined);\n const declared = await declaredRuntimePackages(runtimeDirectory);\n const managed = configured.filter(\n (specifier) => missing.includes(specifier) || declared.has(splitPackageSpecifier(specifier).name),\n );\n const requested = (options.specifiers ?? []).filter(external).map(splitVersionedSpecifier);\n if (managed.length === 0 && requested.length === 0 && options.exactManifest !== true) {\n return { installed: [], updated: [], unchecked: [] };\n }\n\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n const pins = catalogTargets(catalog);\n for (const { name, version } of requested) {\n if (version !== undefined && catalog.packages.get(name)?.archive === undefined) pins.set(name, version);\n }\n // A requested package is missing until the runtime holds it at the version it is pinned to.\n const requestedMissing: string[] = [];\n for (const { name, version } of requested) {\n const installed = await managedPackageVersion(runtimeDirectory, name);\n const entry = catalog.packages.get(name);\n const expected = entry?.archive === undefined ? version : entry.version;\n if (installed === undefined || (expected !== undefined && installed !== expected)) requestedMissing.push(name);\n }\n const missingSources = npmSources([...missing, ...requestedMissing], catalog, pins);\n const sources = npmSources([...managed, ...requested.map(({ name }) => name)], catalog, pins, true).filter(external);\n const missingCount = missing.length + requestedMissing.length;\n\n // Refresh never moves a pinned name: catalogue entries and versioned specifiers stay put.\n const fixedNames = new Set([\n ...catalog.packages.keys(),\n ...requested.filter(({ version }) => version !== undefined).map(({ name }) => name),\n ]);\n const registrySources = sources.filter((source) => !fixedNames.has(packageName(source)));\n const { updated, unchecked } = options.refresh\n ? await resolveUpdates(\n runtimeDirectory,\n registrySources,\n dependencies.publishedVersion ?? ((name) => resolveNewest(name, { dir: runtimeDirectory, poHome, npmrcFiles })),\n options.onProgress,\n )\n : { updated: [], unchecked: [] };\n const targets = new Map(\n sources.flatMap((source) => {\n const target = pins.get(packageName(source));\n return target ? [[packageName(source), target] as const] : [];\n }),\n );\n for (const update of updated) targets.set(update.name, update.to);\n // A kept manifest still declares names earlier runs added; their archives are staged too.\n const stagedNames = new Set([...sources.map(packageName), ...(options.exactManifest === true ? [] : declared)]);\n const staged = await stageCatalogArchives(runtimeDirectory, catalog, stagedNames);\n const manifestChanged = await ensureManagedPackageManifest(\n runtimeDirectory,\n sources,\n targets,\n staged,\n options.exactManifest === true,\n );\n if (missingCount === 0 && !manifestChanged) return { installed: [], updated: [], unchecked };\n\n options.onProgress?.(\n `installing ${\n updated.length > 0\n ? pluralize(updated.length, 'update')\n : missingCount > 0\n ? pluralize(missingCount, 'missing package')\n : 'the package manifest'\n }`,\n );\n try {\n // One install reconciles the complete dependency set written to package.json.\n await installWithOfflineRetry(\n dependencies.install ?? installRuntimePackages,\n {\n dir: runtimeDirectory,\n poHome,\n npmrcFiles,\n // A launch never waits on registry revalidation; sync is the command that refreshes.\n preferOffline: options.refresh !== true,\n log: (message, level) => {\n if (level === 'warn') options.onProgress?.(message);\n },\n },\n options.onProgress,\n );\n } catch (error) {\n const attempted = manifestChanged ? sources : missingSources;\n throw new Error(\n `Failed to reconcile Po layer package(s): ${attempted.join(', ')}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n\n const unresolved = missing.filter((specifier) => !resolvePackageEntries(resolvers, specifier)?.length);\n if (unresolved.length > 0) {\n throw new Error(\n `Installed Po layer package(s) did not expose the configured Pi extension: ${unresolved.join(', ')}`,\n );\n }\n return { installed: missingSources, updated, unchecked };\n}\n\n/** One selector per name in the shared runtime. Caller holds the sync lock throughout. */\nexport async function ensureRuntimeImportPackage(\n name: string,\n version: string,\n options: { homeDirectory: string; environment: Readonly<Record<string, string | undefined>> },\n): Promise<void> {\n const environment = { ...options.environment, HOME: options.homeDirectory };\n const poHome = poHomeDirectory(options.homeDirectory, environment);\n const directory = poRuntimeDirectory(options.homeDirectory, environment);\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n const { manifest } = await readRuntimeManifest(manifestPath);\n const declared = recordValue(manifest.dependencies);\n const imports = recordValue(manifest.poCodemodeDependencies);\n const imported = recordValue(imports[name]);\n const catalog = await readPackageCatalog(await packageCatalogPath(environment));\n if (catalog.packages.has(name) || (Object.hasOwn(declared, name) && declared[name] !== imported.selector)) {\n throw new Error(\n `Cannot import ${name}: Po manages this runtime dependency (${JSON.stringify(declared[name] ?? 'catalogue')}).`,\n );\n }\n if (Object.hasOwn(imports, name) && imported.selector !== version) {\n throw new Error(`Cannot import ${name}@${version}: the hub already uses ${name}@${String(imported.selector)}.`);\n }\n const installed = await managedPackageVersion(directory, name);\n if (declared[name] === version && installed !== undefined && imported.resolved === installed) return;\n // Only a successful reconciliation is cacheable, not the manifest upm writes ahead of a failed install.\n manifest.poCodemodeDependencies = { ...imports, [name]: { selector: version } };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(manifest, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n const pins = new Map([[name, version]]);\n const sources = npmSources([`${name}@${version}`], catalog, pins, true);\n const staged = await stageCatalogArchives(\n directory,\n catalog,\n new Set([...sources.map(packageName), ...Object.keys(declared)]),\n );\n await ensureManagedPackageManifest(directory, sources, pins, staged);\n await installWithOfflineRetry(installRuntimePackages, { dir: directory, poHome, preferOffline: true }, undefined);\n const resolved = await managedPackageVersion(directory, name);\n if (resolved === undefined) throw new Error(`Runtime import ${name}@${version} was not installed.`);\n const reconciled = (await readRuntimeManifest(manifestPath)).manifest;\n reconciled.poCodemodeDependencies = {\n ...recordValue(reconciled.poCodemodeDependencies),\n [name]: { selector: version, resolved },\n };\n await writeFileAtomic(\n createNodePlatform().env(directory),\n manifestPath,\n `${JSON.stringify(reconciled, null, 2)}\\n`,\n BACKGROUND_CONTEXT,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,6BAA6B;;AAEnC,MAAM,2BAA2B;;AAEjC,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,sBAAsB;;AAE5B,MAAM,2BAA2B;CAAC;CAAQ;CAAW;AAAY;;AAEjE,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAY;CAAa;AAAW,CAAC;AAE5E,SAAS,oBAAoB,UAA0B;CACrD,MAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS,WAAW,GAAG,IAAI,IAAI,CAAC;CAC7E,OAAO,mBAAmB,KAAK,WAAW,SAAS,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kBACF;CACA,MAAM,uBAAO,IAAI,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC;CACtC,MAAM,UAAU,WAAW,CAAC,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,MAAM,IAAI;CAMtE,MAAM,6BAA6B,WAAW,SAAS,MAAM,MALxC,qBACnB,WACA,yBACA,IAAI,IAAI,CAAC,GAAG,QAAQ,IAAI,WAAW,GAAG,GAAG,OAAO,KAAK,QAAQ,CAAC,CAAC,CACjE,CACmE;CACnE,MAAM,wBAAwB,wBAAwB;EAAE,KAAK;EAAW;EAAQ,eAAe;CAAK,GAAG,KAAA,CAAS;CAChH,MAAM,WAAW,MAAM,sBAAsB,WAAW,IAAI;CAC5D,IAAI,aAAa,KAAA,GAAW,MAAM,IAAI,MAAM,kBAAkB,KAAK,GAAG,QAAQ,oBAAoB;CAClG,MAAM,cAAc,MAAM,oBAAoB,YAAY,EAAA,CAAG;CAC7D,WAAW,yBAAyB;EAClC,GAAG,YAAY,WAAW,sBAAsB;GAC/C,OAAO;GAAE,UAAU;GAAS;EAAS;CACxC;CACA,MAAM,gBACJ,mBAAmB,CAAC,CAAC,IAAI,SAAS,GAClC,cACA,GAAG,KAAK,UAAU,YAAY,MAAM,CAAC,EAAE,KACvC,kBACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.94",
|
|
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.
|
|
181
|
-
"@agimon-ai/po-artifact": "0.0.0-alpha.
|
|
182
|
-
"@agimon-ai/po-autostop": "0.0.0-alpha.
|
|
183
|
-
"@agimon-ai/po-cache": "0.0.0-alpha.
|
|
184
|
-
"@agimon-ai/po-config": "0.0.0-alpha.
|
|
185
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
186
|
-
"@agimon-ai/po-db": "0.0.0-alpha.
|
|
187
|
-
"@agimon-ai/po-domain": "0.0.0-alpha.
|
|
188
|
-
"@agimon-ai/po-logsink": "0.0.1-alpha.
|
|
189
|
-
"@agimon-ai/po-major-mode": "0.0.0-alpha.
|
|
190
|
-
"@agimon-ai/po-mcp-proxy": "0.0.1-alpha.
|
|
191
|
-
"@agimon-ai/po-minor-mode": "0.0.0-alpha.
|
|
192
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
193
|
-
"@agimon-ai/po-network": "0.0.2-alpha.
|
|
194
|
-
"@agimon-ai/po-notification": "0.0.0-alpha.
|
|
195
|
-
"@agimon-ai/po-profile": "0.0.0-alpha.
|
|
196
|
-
"@agimon-ai/po-session": "0.0.0-alpha.
|
|
197
|
-
"@agimon-ai/po-skill": "0.0.0-alpha.
|
|
198
|
-
"@agimon-ai/po-ui": "0.0.0-alpha.
|
|
199
|
-
"@agimon-ai/po-vault": "0.0.0-alpha.
|
|
200
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
201
|
-
"@agimon-ai/po-web-security": "0.0.0-alpha.
|
|
180
|
+
"@agimon-ai/po-approval": "0.0.0-alpha.93",
|
|
181
|
+
"@agimon-ai/po-artifact": "0.0.0-alpha.92",
|
|
182
|
+
"@agimon-ai/po-autostop": "0.0.0-alpha.93",
|
|
183
|
+
"@agimon-ai/po-cache": "0.0.0-alpha.93",
|
|
184
|
+
"@agimon-ai/po-config": "0.0.0-alpha.93",
|
|
185
|
+
"@agimon-ai/po-core": "0.0.0-alpha.93",
|
|
186
|
+
"@agimon-ai/po-db": "0.0.0-alpha.93",
|
|
187
|
+
"@agimon-ai/po-domain": "0.0.0-alpha.93",
|
|
188
|
+
"@agimon-ai/po-logsink": "0.0.1-alpha.75",
|
|
189
|
+
"@agimon-ai/po-major-mode": "0.0.0-alpha.93",
|
|
190
|
+
"@agimon-ai/po-mcp-proxy": "0.0.1-alpha.72",
|
|
191
|
+
"@agimon-ai/po-minor-mode": "0.0.0-alpha.93",
|
|
192
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.93",
|
|
193
|
+
"@agimon-ai/po-network": "0.0.2-alpha.40",
|
|
194
|
+
"@agimon-ai/po-notification": "0.0.0-alpha.93",
|
|
195
|
+
"@agimon-ai/po-profile": "0.0.0-alpha.93",
|
|
196
|
+
"@agimon-ai/po-session": "0.0.0-alpha.93",
|
|
197
|
+
"@agimon-ai/po-skill": "0.0.0-alpha.93",
|
|
198
|
+
"@agimon-ai/po-ui": "0.0.0-alpha.93",
|
|
199
|
+
"@agimon-ai/po-vault": "0.0.0-alpha.93",
|
|
200
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.93",
|
|
201
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.93",
|
|
202
202
|
"@deepseek-ai/cordis": "4.0.5",
|
|
203
203
|
"@earendil-works/pi-agent-core": "1.4.0",
|
|
204
204
|
"@earendil-works/pi-coding-agent": "1.4.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.
|
|
224
|
-
"@agimon-ai/po-identity": "0.0.2-alpha.
|
|
225
|
-
"@agimon-ai/po-runner": "0.0.0-alpha.
|
|
226
|
-
"@agimon-ai/vibe-lint-plugin-po-cli": "0.0.0-alpha.
|
|
223
|
+
"@agimon-ai/po-calendar": "0.0.1-alpha.52",
|
|
224
|
+
"@agimon-ai/po-identity": "0.0.2-alpha.40",
|
|
225
|
+
"@agimon-ai/po-runner": "0.0.0-alpha.93",
|
|
226
|
+
"@agimon-ai/vibe-lint-plugin-po-cli": "0.0.0-alpha.93",
|
|
227
227
|
"@earendil-works/pi-ai": "1.4.0",
|
|
228
228
|
"@modelcontextprotocol/ext-apps": "2.0.3",
|
|
229
229
|
"@modelcontextprotocol/server": "2.3.1",
|