shennian 0.4.69 → 0.4.72
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/publish-build-manifest.json +150 -90
- package/dist/src/agent-env.js +4 -4
- package/dist/src/agents/adapter.d.ts +7 -3
- package/dist/src/agents/auth-status.d.ts +4 -0
- package/dist/src/agents/auth-status.js +2 -0
- package/dist/src/agents/claude.js +4 -4
- package/dist/src/agents/codex-protocol.d.ts +103 -0
- package/dist/src/agents/codex-protocol.js +3 -0
- package/dist/src/agents/codex-runtime.d.ts +91 -0
- package/dist/src/agents/codex-runtime.js +14 -0
- package/dist/src/agents/codex.d.ts +15 -91
- package/dist/src/agents/codex.js +2 -17
- package/dist/src/agents/command-spec.js +4 -3
- package/dist/src/agents/detect.js +1 -1
- package/dist/src/agents/manager.d.ts +4 -3
- package/dist/src/agents/manager.js +4 -4
- package/dist/src/agents/model-registry/discovery.js +3 -3
- package/dist/src/agents/model-registry/parsers.js +4 -4
- package/dist/src/agents/model-registry/service.d.ts +6 -2
- package/dist/src/agents/model-registry/service.js +1 -1
- package/dist/src/agents/model-registry/types.d.ts +9 -1
- package/dist/src/agents/model-registry/types.js +1 -1
- package/dist/src/agents/opencode.d.ts +4 -0
- package/dist/src/agents/opencode.js +1 -1
- package/dist/src/commands/agent-readiness.d.ts +17 -0
- package/dist/src/commands/agent-readiness.js +2 -0
- package/dist/src/commands/agent.js +2 -2
- package/dist/src/commands/daemon-instance-lock.js +1 -1
- package/dist/src/commands/daemon-process.d.ts +1 -0
- package/dist/src/commands/daemon-process.js +1 -1
- package/dist/src/commands/daemon-service-spec.d.ts +28 -0
- package/dist/src/commands/daemon-service-spec.js +1 -0
- package/dist/src/commands/daemon-start-wait.d.ts +1 -1
- package/dist/src/commands/daemon-start-wait.js +1 -1
- package/dist/src/commands/daemon-state.d.ts +57 -0
- package/dist/src/commands/daemon-state.js +1 -0
- package/dist/src/commands/daemon-windows.d.ts +8 -0
- package/dist/src/commands/daemon-windows.js +10 -10
- package/dist/src/commands/daemon.d.ts +4 -64
- package/dist/src/commands/daemon.js +13 -13
- package/dist/src/commands/manager.js +1 -1
- package/dist/src/commands/upgrade.js +1 -1
- package/dist/src/commands/worker.d.ts +11 -0
- package/dist/src/commands/worker.js +2 -0
- package/dist/src/daemon-ipc/agent-readiness.d.ts +14 -0
- package/dist/src/daemon-ipc/agent-readiness.js +1 -0
- package/dist/src/daemon-ipc/control.d.ts +1 -1
- package/dist/src/daemon-ipc/control.js +1 -1
- package/dist/src/index.js +3 -3
- package/dist/src/manager/prompt.d.ts +1 -1
- package/dist/src/manager/prompt.js +6 -6
- package/dist/src/manager/registry.d.ts +48 -2
- package/dist/src/manager/registry.js +1 -1
- package/dist/src/manager/runtime.d.ts +2 -2
- package/dist/src/manager/runtime.js +6 -6
- package/dist/src/manager/worker-ipc.d.ts +7 -0
- package/dist/src/manager/worker-ipc.js +1 -1
- package/dist/src/native-fusion/local-repository.d.ts +6 -1
- package/dist/src/native-fusion/local-repository.js +2 -2
- package/dist/src/native-fusion/service.d.ts +2 -0
- package/dist/src/native-fusion/service.js +2 -2
- package/dist/src/native-fusion/source-visibility-audit.d.ts +16 -0
- package/dist/src/native-fusion/source-visibility-audit.js +1 -0
- package/dist/src/native-fusion/source-visibility.d.ts +25 -0
- package/dist/src/native-fusion/source-visibility.js +1 -0
- package/dist/src/native-fusion/state.d.ts +1 -0
- package/dist/src/native-fusion/state.js +2 -2
- package/dist/src/native-fusion/types.d.ts +5 -0
- package/dist/src/room/managed-room-binding.d.ts +2 -0
- package/dist/src/room/managed-room-binding.js +1 -1
- package/dist/src/room/room-binding-client.d.ts +1 -0
- package/dist/src/room/room-binding-client.js +1 -1
- package/dist/src/runtime-distribution.d.ts +13 -0
- package/dist/src/runtime-distribution.js +1 -0
- package/dist/src/security/managed-agent-policy.d.ts +7 -0
- package/dist/src/security/managed-agent-policy.js +1 -1
- package/dist/src/session/handlers/agent-workspace-validation.d.ts +1 -0
- package/dist/src/session/handlers/agent-workspace-validation.js +1 -1
- package/dist/src/session/handlers/agents.d.ts +7 -1
- package/dist/src/session/handlers/agents.js +1 -1
- package/dist/src/session/handlers/chat-context.d.ts +31 -0
- package/dist/src/session/handlers/chat-context.js +1 -0
- package/dist/src/session/handlers/chat-events.d.ts +1 -1
- package/dist/src/session/handlers/chat-events.js +2 -2
- package/dist/src/session/handlers/chat-session-lifecycle.d.ts +2 -2
- package/dist/src/session/handlers/chat-session-lifecycle.js +1 -1
- package/dist/src/session/handlers/chat.d.ts +3 -29
- package/dist/src/session/handlers/chat.js +1 -1
- package/dist/src/session/manager.js +2 -2
- package/dist/src/session/queue-helpers.js +2 -2
- package/dist/src/session/queue-message.d.ts +2 -0
- package/dist/src/session/queue.d.ts +7 -1
- package/dist/src/session/queue.js +1 -1
- package/dist/src/session/queued-chat-dispatch.d.ts +4 -1
- package/dist/src/session/queued-chat-dispatch.js +1 -1
- package/dist/src/session/store.d.ts +4 -2
- package/dist/src/session/store.js +2 -2
- package/dist/src/session/types.d.ts +1 -0
- package/dist/src/upgrade/engine.js +2 -2
- package/dist/src/upgrade/scheduler.js +1 -1
- package/dist/src/upgrade/updater-launcher.js +3 -3
- package/node_modules/@shennian/wire/dist/room.d.ts +2 -0
- package/node_modules/@shennian/wire/dist/session-sync.d.ts +2 -1
- package/node_modules/@shennian/wire/dist/session.d.ts +25 -1
- package/node_modules/@shennian/wire/dist/session.js +8 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"jsMinified": true,
|
|
4
4
|
"minifier": "esbuild",
|
|
5
|
-
"fileCount":
|
|
5
|
+
"fileCount": 220,
|
|
6
6
|
"files": [
|
|
7
7
|
{
|
|
8
8
|
"file": "bin/shennian.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"file": "src/agent-env.js",
|
|
14
|
-
"beforeBytes":
|
|
15
|
-
"afterBytes":
|
|
14
|
+
"beforeBytes": 11445,
|
|
15
|
+
"afterBytes": 5115
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"file": "src/agents/acp/adapter.js",
|
|
@@ -91,9 +91,14 @@
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"file": "src/agents/adapter.js",
|
|
94
|
-
"beforeBytes":
|
|
94
|
+
"beforeBytes": 3950,
|
|
95
95
|
"afterBytes": 1948
|
|
96
96
|
},
|
|
97
|
+
{
|
|
98
|
+
"file": "src/agents/auth-status.js",
|
|
99
|
+
"beforeBytes": 2708,
|
|
100
|
+
"afterBytes": 1188
|
|
101
|
+
},
|
|
97
102
|
{
|
|
98
103
|
"file": "src/agents/claude-managed-permissions.js",
|
|
99
104
|
"beforeBytes": 10147,
|
|
@@ -101,8 +106,8 @@
|
|
|
101
106
|
},
|
|
102
107
|
{
|
|
103
108
|
"file": "src/agents/claude.js",
|
|
104
|
-
"beforeBytes":
|
|
105
|
-
"afterBytes":
|
|
109
|
+
"beforeBytes": 18953,
|
|
110
|
+
"afterBytes": 8992
|
|
106
111
|
},
|
|
107
112
|
{
|
|
108
113
|
"file": "src/agents/codex-managed-permissions.js",
|
|
@@ -114,6 +119,16 @@
|
|
|
114
119
|
"beforeBytes": 15680,
|
|
115
120
|
"afterBytes": 9844
|
|
116
121
|
},
|
|
122
|
+
{
|
|
123
|
+
"file": "src/agents/codex-protocol.js",
|
|
124
|
+
"beforeBytes": 5392,
|
|
125
|
+
"afterBytes": 2816
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"file": "src/agents/codex-runtime.js",
|
|
129
|
+
"beforeBytes": 30645,
|
|
130
|
+
"afterBytes": 15637
|
|
131
|
+
},
|
|
117
132
|
{
|
|
118
133
|
"file": "src/agents/codex-utils.js",
|
|
119
134
|
"beforeBytes": 7479,
|
|
@@ -121,13 +136,13 @@
|
|
|
121
136
|
},
|
|
122
137
|
{
|
|
123
138
|
"file": "src/agents/codex.js",
|
|
124
|
-
"beforeBytes":
|
|
125
|
-
"afterBytes":
|
|
139
|
+
"beforeBytes": 34652,
|
|
140
|
+
"afterBytes": 18423
|
|
126
141
|
},
|
|
127
142
|
{
|
|
128
143
|
"file": "src/agents/command-spec.js",
|
|
129
|
-
"beforeBytes":
|
|
130
|
-
"afterBytes":
|
|
144
|
+
"beforeBytes": 19955,
|
|
145
|
+
"afterBytes": 9040
|
|
131
146
|
},
|
|
132
147
|
{
|
|
133
148
|
"file": "src/agents/config-status.js",
|
|
@@ -161,8 +176,8 @@
|
|
|
161
176
|
},
|
|
162
177
|
{
|
|
163
178
|
"file": "src/agents/detect.js",
|
|
164
|
-
"beforeBytes":
|
|
165
|
-
"afterBytes":
|
|
179
|
+
"beforeBytes": 3767,
|
|
180
|
+
"afterBytes": 1707
|
|
166
181
|
},
|
|
167
182
|
{
|
|
168
183
|
"file": "src/agents/external-channel-instructions.js",
|
|
@@ -176,8 +191,8 @@
|
|
|
176
191
|
},
|
|
177
192
|
{
|
|
178
193
|
"file": "src/agents/manager.js",
|
|
179
|
-
"beforeBytes":
|
|
180
|
-
"afterBytes":
|
|
194
|
+
"beforeBytes": 11257,
|
|
195
|
+
"afterBytes": 6122
|
|
181
196
|
},
|
|
182
197
|
{
|
|
183
198
|
"file": "src/agents/model-registry/cache.js",
|
|
@@ -186,8 +201,8 @@
|
|
|
186
201
|
},
|
|
187
202
|
{
|
|
188
203
|
"file": "src/agents/model-registry/discovery.js",
|
|
189
|
-
"beforeBytes":
|
|
190
|
-
"afterBytes":
|
|
204
|
+
"beforeBytes": 11711,
|
|
205
|
+
"afterBytes": 5499
|
|
191
206
|
},
|
|
192
207
|
{
|
|
193
208
|
"file": "src/agents/model-registry/opencode-api.js",
|
|
@@ -196,8 +211,8 @@
|
|
|
196
211
|
},
|
|
197
212
|
{
|
|
198
213
|
"file": "src/agents/model-registry/parsers.js",
|
|
199
|
-
"beforeBytes":
|
|
200
|
-
"afterBytes":
|
|
214
|
+
"beforeBytes": 23995,
|
|
215
|
+
"afterBytes": 12356
|
|
201
216
|
},
|
|
202
217
|
{
|
|
203
218
|
"file": "src/agents/model-registry/runner.js",
|
|
@@ -206,13 +221,13 @@
|
|
|
206
221
|
},
|
|
207
222
|
{
|
|
208
223
|
"file": "src/agents/model-registry/service.js",
|
|
209
|
-
"beforeBytes":
|
|
210
|
-
"afterBytes":
|
|
224
|
+
"beforeBytes": 7401,
|
|
225
|
+
"afterBytes": 2929
|
|
211
226
|
},
|
|
212
227
|
{
|
|
213
228
|
"file": "src/agents/model-registry/types.js",
|
|
214
|
-
"beforeBytes":
|
|
215
|
-
"afterBytes":
|
|
229
|
+
"beforeBytes": 906,
|
|
230
|
+
"afterBytes": 495
|
|
216
231
|
},
|
|
217
232
|
{
|
|
218
233
|
"file": "src/agents/model-registry.js",
|
|
@@ -236,8 +251,8 @@
|
|
|
236
251
|
},
|
|
237
252
|
{
|
|
238
253
|
"file": "src/agents/opencode.js",
|
|
239
|
-
"beforeBytes":
|
|
240
|
-
"afterBytes":
|
|
254
|
+
"beforeBytes": 13211,
|
|
255
|
+
"afterBytes": 6927
|
|
241
256
|
},
|
|
242
257
|
{
|
|
243
258
|
"file": "src/agents/pi-coding-agent-managed-permissions.js",
|
|
@@ -289,35 +304,50 @@
|
|
|
289
304
|
"beforeBytes": 18443,
|
|
290
305
|
"afterBytes": 9602
|
|
291
306
|
},
|
|
307
|
+
{
|
|
308
|
+
"file": "src/commands/agent-readiness.js",
|
|
309
|
+
"beforeBytes": 3718,
|
|
310
|
+
"afterBytes": 3018
|
|
311
|
+
},
|
|
292
312
|
{
|
|
293
313
|
"file": "src/commands/agent.js",
|
|
294
|
-
"beforeBytes":
|
|
295
|
-
"afterBytes":
|
|
314
|
+
"beforeBytes": 5283,
|
|
315
|
+
"afterBytes": 2934
|
|
296
316
|
},
|
|
297
317
|
{
|
|
298
318
|
"file": "src/commands/daemon-instance-lock.js",
|
|
299
|
-
"beforeBytes":
|
|
300
|
-
"afterBytes":
|
|
319
|
+
"beforeBytes": 4507,
|
|
320
|
+
"afterBytes": 1811
|
|
301
321
|
},
|
|
302
322
|
{
|
|
303
323
|
"file": "src/commands/daemon-process.js",
|
|
304
|
-
"beforeBytes":
|
|
305
|
-
"afterBytes":
|
|
324
|
+
"beforeBytes": 7019,
|
|
325
|
+
"afterBytes": 3895
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"file": "src/commands/daemon-service-spec.js",
|
|
329
|
+
"beforeBytes": 4365,
|
|
330
|
+
"afterBytes": 2648
|
|
306
331
|
},
|
|
307
332
|
{
|
|
308
333
|
"file": "src/commands/daemon-start-wait.js",
|
|
309
|
-
"beforeBytes":
|
|
310
|
-
"afterBytes":
|
|
334
|
+
"beforeBytes": 1208,
|
|
335
|
+
"afterBytes": 438
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"file": "src/commands/daemon-state.js",
|
|
339
|
+
"beforeBytes": 10369,
|
|
340
|
+
"afterBytes": 5116
|
|
311
341
|
},
|
|
312
342
|
{
|
|
313
343
|
"file": "src/commands/daemon-windows.js",
|
|
314
|
-
"beforeBytes":
|
|
315
|
-
"afterBytes":
|
|
344
|
+
"beforeBytes": 5732,
|
|
345
|
+
"afterBytes": 4027
|
|
316
346
|
},
|
|
317
347
|
{
|
|
318
348
|
"file": "src/commands/daemon.js",
|
|
319
|
-
"beforeBytes":
|
|
320
|
-
"afterBytes":
|
|
349
|
+
"beforeBytes": 34161,
|
|
350
|
+
"afterBytes": 17352
|
|
321
351
|
},
|
|
322
352
|
{
|
|
323
353
|
"file": "src/commands/integration.js",
|
|
@@ -331,8 +361,8 @@
|
|
|
331
361
|
},
|
|
332
362
|
{
|
|
333
363
|
"file": "src/commands/manager.js",
|
|
334
|
-
"beforeBytes":
|
|
335
|
-
"afterBytes":
|
|
364
|
+
"beforeBytes": 9692,
|
|
365
|
+
"afterBytes": 6336
|
|
336
366
|
},
|
|
337
367
|
{
|
|
338
368
|
"file": "src/commands/pair-authorization.js",
|
|
@@ -376,14 +406,24 @@
|
|
|
376
406
|
},
|
|
377
407
|
{
|
|
378
408
|
"file": "src/commands/upgrade.js",
|
|
379
|
-
"beforeBytes":
|
|
380
|
-
"afterBytes":
|
|
409
|
+
"beforeBytes": 13446,
|
|
410
|
+
"afterBytes": 6795
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"file": "src/commands/worker.js",
|
|
414
|
+
"beforeBytes": 6654,
|
|
415
|
+
"afterBytes": 4212
|
|
381
416
|
},
|
|
382
417
|
{
|
|
383
418
|
"file": "src/config/index.js",
|
|
384
419
|
"beforeBytes": 2801,
|
|
385
420
|
"afterBytes": 1662
|
|
386
421
|
},
|
|
422
|
+
{
|
|
423
|
+
"file": "src/daemon-ipc/agent-readiness.js",
|
|
424
|
+
"beforeBytes": 4154,
|
|
425
|
+
"afterBytes": 2206
|
|
426
|
+
},
|
|
387
427
|
{
|
|
388
428
|
"file": "src/daemon-ipc/client.js",
|
|
389
429
|
"beforeBytes": 2786,
|
|
@@ -391,8 +431,8 @@
|
|
|
391
431
|
},
|
|
392
432
|
{
|
|
393
433
|
"file": "src/daemon-ipc/control.js",
|
|
394
|
-
"beforeBytes":
|
|
395
|
-
"afterBytes":
|
|
434
|
+
"beforeBytes": 4016,
|
|
435
|
+
"afterBytes": 2227
|
|
396
436
|
},
|
|
397
437
|
{
|
|
398
438
|
"file": "src/daemon-ipc/json.js",
|
|
@@ -451,8 +491,8 @@
|
|
|
451
491
|
},
|
|
452
492
|
{
|
|
453
493
|
"file": "src/index.js",
|
|
454
|
-
"beforeBytes":
|
|
455
|
-
"afterBytes":
|
|
494
|
+
"beforeBytes": 41017,
|
|
495
|
+
"afterBytes": 20498
|
|
456
496
|
},
|
|
457
497
|
{
|
|
458
498
|
"file": "src/log-redaction.js",
|
|
@@ -466,13 +506,13 @@
|
|
|
466
506
|
},
|
|
467
507
|
{
|
|
468
508
|
"file": "src/manager/prompt.js",
|
|
469
|
-
"beforeBytes":
|
|
470
|
-
"afterBytes":
|
|
509
|
+
"beforeBytes": 5067,
|
|
510
|
+
"afterBytes": 8427
|
|
471
511
|
},
|
|
472
512
|
{
|
|
473
513
|
"file": "src/manager/registry.js",
|
|
474
|
-
"beforeBytes":
|
|
475
|
-
"afterBytes":
|
|
514
|
+
"beforeBytes": 16879,
|
|
515
|
+
"afterBytes": 8079
|
|
476
516
|
},
|
|
477
517
|
{
|
|
478
518
|
"file": "src/manager/retired-external-channel-compat.js",
|
|
@@ -481,13 +521,13 @@
|
|
|
481
521
|
},
|
|
482
522
|
{
|
|
483
523
|
"file": "src/manager/runtime.js",
|
|
484
|
-
"beforeBytes":
|
|
485
|
-
"afterBytes":
|
|
524
|
+
"beforeBytes": 34449,
|
|
525
|
+
"afterBytes": 16700
|
|
486
526
|
},
|
|
487
527
|
{
|
|
488
528
|
"file": "src/manager/worker-ipc.js",
|
|
489
|
-
"beforeBytes":
|
|
490
|
-
"afterBytes":
|
|
529
|
+
"beforeBytes": 19731,
|
|
530
|
+
"afterBytes": 11321
|
|
491
531
|
},
|
|
492
532
|
{
|
|
493
533
|
"file": "src/manager/worker-markdown.js",
|
|
@@ -526,8 +566,8 @@
|
|
|
526
566
|
},
|
|
527
567
|
{
|
|
528
568
|
"file": "src/native-fusion/local-repository.js",
|
|
529
|
-
"beforeBytes":
|
|
530
|
-
"afterBytes":
|
|
569
|
+
"beforeBytes": 27323,
|
|
570
|
+
"afterBytes": 13527
|
|
531
571
|
},
|
|
532
572
|
{
|
|
533
573
|
"file": "src/native-fusion/native-source-deletions.js",
|
|
@@ -551,18 +591,28 @@
|
|
|
551
591
|
},
|
|
552
592
|
{
|
|
553
593
|
"file": "src/native-fusion/service.js",
|
|
554
|
-
"beforeBytes":
|
|
555
|
-
"afterBytes":
|
|
594
|
+
"beforeBytes": 39178,
|
|
595
|
+
"afterBytes": 17772
|
|
556
596
|
},
|
|
557
597
|
{
|
|
558
598
|
"file": "src/native-fusion/session-header.js",
|
|
559
599
|
"beforeBytes": 4294,
|
|
560
600
|
"afterBytes": 1996
|
|
561
601
|
},
|
|
602
|
+
{
|
|
603
|
+
"file": "src/native-fusion/source-visibility-audit.js",
|
|
604
|
+
"beforeBytes": 2911,
|
|
605
|
+
"afterBytes": 1532
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"file": "src/native-fusion/source-visibility.js",
|
|
609
|
+
"beforeBytes": 4772,
|
|
610
|
+
"afterBytes": 2342
|
|
611
|
+
},
|
|
562
612
|
{
|
|
563
613
|
"file": "src/native-fusion/state.js",
|
|
564
|
-
"beforeBytes":
|
|
565
|
-
"afterBytes":
|
|
614
|
+
"beforeBytes": 5715,
|
|
615
|
+
"afterBytes": 3080
|
|
566
616
|
},
|
|
567
617
|
{
|
|
568
618
|
"file": "src/native-fusion/types.js",
|
|
@@ -661,8 +711,8 @@
|
|
|
661
711
|
},
|
|
662
712
|
{
|
|
663
713
|
"file": "src/room/managed-room-binding.js",
|
|
664
|
-
"beforeBytes":
|
|
665
|
-
"afterBytes":
|
|
714
|
+
"beforeBytes": 6625,
|
|
715
|
+
"afterBytes": 3516
|
|
666
716
|
},
|
|
667
717
|
{
|
|
668
718
|
"file": "src/room/managed-room-ipc.js",
|
|
@@ -701,14 +751,19 @@
|
|
|
701
751
|
},
|
|
702
752
|
{
|
|
703
753
|
"file": "src/room/room-binding-client.js",
|
|
704
|
-
"beforeBytes":
|
|
705
|
-
"afterBytes":
|
|
754
|
+
"beforeBytes": 7086,
|
|
755
|
+
"afterBytes": 4075
|
|
706
756
|
},
|
|
707
757
|
{
|
|
708
758
|
"file": "src/room/session-registry.js",
|
|
709
759
|
"beforeBytes": 30575,
|
|
710
760
|
"afterBytes": 17164
|
|
711
761
|
},
|
|
762
|
+
{
|
|
763
|
+
"file": "src/runtime-distribution.js",
|
|
764
|
+
"beforeBytes": 2844,
|
|
765
|
+
"afterBytes": 1540
|
|
766
|
+
},
|
|
712
767
|
{
|
|
713
768
|
"file": "src/schedules/personal-context.js",
|
|
714
769
|
"beforeBytes": 901,
|
|
@@ -731,8 +786,8 @@
|
|
|
731
786
|
},
|
|
732
787
|
{
|
|
733
788
|
"file": "src/security/managed-agent-policy.js",
|
|
734
|
-
"beforeBytes":
|
|
735
|
-
"afterBytes":
|
|
789
|
+
"beforeBytes": 7465,
|
|
790
|
+
"afterBytes": 3578
|
|
736
791
|
},
|
|
737
792
|
{
|
|
738
793
|
"file": "src/security/managed-agent-runtime.js",
|
|
@@ -786,23 +841,28 @@
|
|
|
786
841
|
},
|
|
787
842
|
{
|
|
788
843
|
"file": "src/session/handlers/agent-workspace-validation.js",
|
|
789
|
-
"beforeBytes":
|
|
790
|
-
"afterBytes":
|
|
844
|
+
"beforeBytes": 9750,
|
|
845
|
+
"afterBytes": 5155
|
|
791
846
|
},
|
|
792
847
|
{
|
|
793
848
|
"file": "src/session/handlers/agents.js",
|
|
794
|
-
"beforeBytes":
|
|
795
|
-
"afterBytes":
|
|
849
|
+
"beforeBytes": 2481,
|
|
850
|
+
"afterBytes": 1211
|
|
796
851
|
},
|
|
797
852
|
{
|
|
798
853
|
"file": "src/session/handlers/chat-adapter-config.js",
|
|
799
854
|
"beforeBytes": 2814,
|
|
800
855
|
"afterBytes": 1159
|
|
801
856
|
},
|
|
857
|
+
{
|
|
858
|
+
"file": "src/session/handlers/chat-context.js",
|
|
859
|
+
"beforeBytes": 3243,
|
|
860
|
+
"afterBytes": 1986
|
|
861
|
+
},
|
|
802
862
|
{
|
|
803
863
|
"file": "src/session/handlers/chat-events.js",
|
|
804
|
-
"beforeBytes":
|
|
805
|
-
"afterBytes":
|
|
864
|
+
"beforeBytes": 15787,
|
|
865
|
+
"afterBytes": 6851
|
|
806
866
|
},
|
|
807
867
|
{
|
|
808
868
|
"file": "src/session/handlers/chat-recovery.js",
|
|
@@ -811,13 +871,13 @@
|
|
|
811
871
|
},
|
|
812
872
|
{
|
|
813
873
|
"file": "src/session/handlers/chat-session-lifecycle.js",
|
|
814
|
-
"beforeBytes":
|
|
815
|
-
"afterBytes":
|
|
874
|
+
"beforeBytes": 4467,
|
|
875
|
+
"afterBytes": 2119
|
|
816
876
|
},
|
|
817
877
|
{
|
|
818
878
|
"file": "src/session/handlers/chat.js",
|
|
819
|
-
"beforeBytes":
|
|
820
|
-
"afterBytes":
|
|
879
|
+
"beforeBytes": 33039,
|
|
880
|
+
"afterBytes": 13936
|
|
821
881
|
},
|
|
822
882
|
{
|
|
823
883
|
"file": "src/session/handlers/control.js",
|
|
@@ -891,8 +951,8 @@
|
|
|
891
951
|
},
|
|
892
952
|
{
|
|
893
953
|
"file": "src/session/manager.js",
|
|
894
|
-
"beforeBytes":
|
|
895
|
-
"afterBytes":
|
|
954
|
+
"beforeBytes": 42836,
|
|
955
|
+
"afterBytes": 22584
|
|
896
956
|
},
|
|
897
957
|
{
|
|
898
958
|
"file": "src/session/native-cleanup-outbox.js",
|
|
@@ -916,8 +976,8 @@
|
|
|
916
976
|
},
|
|
917
977
|
{
|
|
918
978
|
"file": "src/session/queue-helpers.js",
|
|
919
|
-
"beforeBytes":
|
|
920
|
-
"afterBytes":
|
|
979
|
+
"beforeBytes": 8579,
|
|
980
|
+
"afterBytes": 4271
|
|
921
981
|
},
|
|
922
982
|
{
|
|
923
983
|
"file": "src/session/queue-message.js",
|
|
@@ -941,13 +1001,13 @@
|
|
|
941
1001
|
},
|
|
942
1002
|
{
|
|
943
1003
|
"file": "src/session/queue.js",
|
|
944
|
-
"beforeBytes":
|
|
945
|
-
"afterBytes":
|
|
1004
|
+
"beforeBytes": 49538,
|
|
1005
|
+
"afterBytes": 21745
|
|
946
1006
|
},
|
|
947
1007
|
{
|
|
948
1008
|
"file": "src/session/queued-chat-dispatch.js",
|
|
949
|
-
"beforeBytes":
|
|
950
|
-
"afterBytes":
|
|
1009
|
+
"beforeBytes": 3176,
|
|
1010
|
+
"afterBytes": 1809
|
|
951
1011
|
},
|
|
952
1012
|
{
|
|
953
1013
|
"file": "src/session/run-recovery/barrier.js",
|
|
@@ -971,8 +1031,8 @@
|
|
|
971
1031
|
},
|
|
972
1032
|
{
|
|
973
1033
|
"file": "src/session/store.js",
|
|
974
|
-
"beforeBytes":
|
|
975
|
-
"afterBytes":
|
|
1034
|
+
"beforeBytes": 32798,
|
|
1035
|
+
"afterBytes": 16719
|
|
976
1036
|
},
|
|
977
1037
|
{
|
|
978
1038
|
"file": "src/session/tool-detail-store.js",
|
|
@@ -1006,13 +1066,13 @@
|
|
|
1006
1066
|
},
|
|
1007
1067
|
{
|
|
1008
1068
|
"file": "src/upgrade/engine.js",
|
|
1009
|
-
"beforeBytes":
|
|
1010
|
-
"afterBytes":
|
|
1069
|
+
"beforeBytes": 16931,
|
|
1070
|
+
"afterBytes": 7217
|
|
1011
1071
|
},
|
|
1012
1072
|
{
|
|
1013
1073
|
"file": "src/upgrade/scheduler.js",
|
|
1014
|
-
"beforeBytes":
|
|
1015
|
-
"afterBytes":
|
|
1074
|
+
"beforeBytes": 7508,
|
|
1075
|
+
"afterBytes": 4246
|
|
1016
1076
|
},
|
|
1017
1077
|
{
|
|
1018
1078
|
"file": "src/upgrade/updater-bootstrap.js",
|
|
@@ -1021,8 +1081,8 @@
|
|
|
1021
1081
|
},
|
|
1022
1082
|
{
|
|
1023
1083
|
"file": "src/upgrade/updater-launcher.js",
|
|
1024
|
-
"beforeBytes":
|
|
1025
|
-
"afterBytes":
|
|
1084
|
+
"beforeBytes": 10418,
|
|
1085
|
+
"afterBytes": 5326
|
|
1026
1086
|
},
|
|
1027
1087
|
{
|
|
1028
1088
|
"file": "src/upgrade/updater-protocol.js",
|
package/dist/src/agent-env.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import T from"node:os";import{desktopCommandDirectory as R}from"./runtime-distribution.js";import c from"node:path";import{spawnSync as p}from"node:child_process";import{buildAugmentedPath as g}from"./env-path.js";import{buildWindowsSystemEnv as a,resolveWindowsPowerShellPath as D}from"./windows-shell.js";const _="__SHENNIAN_AGENT_ENV_START__",u="__SHENNIAN_AGENT_ENV_END__",S=["HOME","USER","LOGNAME","LANG","LANGUAGE","LC_ALL","LC_CTYPE","TMPDIR","TMP","TEMP","TZ"],m=["SystemRoot","WINDIR","ComSpec","PATHEXT","USERPROFILE","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","TEMP","TMP","TZ"],P=["NO_COLOR","PI_CODING_AGENT_DIR"],f=["SHENNIAN_MANAGED_ROOM_CONTEXT","SHENNIAN_MANAGED_ROOM_IPC_ROOT"],I=["SHENNIAN_MANAGER_SESSION_ID","SHENNIAN_MANAGER_AGENT_SESSION_ID","SHENNIAN_MANAGER_WORKDIR","SHENNIAN_MANAGER_MODEL","SHENNIAN_MANAGER_IPC_URL","SHENNIAN_MANAGER_IPC_TOKEN"],h={codex:["OPENAI_BASE_URL","OPENAI_API_KEY"],claude:["ANTHROPIC_BASE_URL","ANTHROPIC_API_KEY"],pi:["DASHSCOPE_BASE_URL","DASHSCOPE_API_KEY"]};function G(e){return h[e]??[]}function w(e){return e==="codex"||e==="claude"||e==="pi-coding-agent"?[...f,...I]:f}function Y(e=process.platform){return["PATH",...e==="win32"?m:S,...P]}function A(e){return`'${e.replace(/'/g,"'\\''")}'`}function O(e){const n=e.indexOf(_),o=e.indexOf(u,n+_.length);if(n===-1||o===-1)return null;const t=e.slice(n+_.length,o);try{const s=JSON.parse(t),i={};for(const[E,r]of Object.entries(s))typeof r=="string"&&(i[E]=r);return i}catch{return null}}function M(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${A(_)}`,`${A(process.execPath)} -e ${A("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${A(u)}`].join("; ");for(const o of[["-ilc",n],["-lc",n]]){const t=p(e,o,{env:process.env,encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0}),s=typeof t.stdout=="string"?O(t.stdout):null;if(s)return s}return null}function H(){const e=`
|
|
2
2
|
$envs = @{}
|
|
3
3
|
[Environment]::GetEnvironmentVariables('Machine').GetEnumerator() | ForEach-Object { $envs[$_.Key] = [string]$_.Value }
|
|
4
4
|
[Environment]::GetEnvironmentVariables('User').GetEnumerator() | ForEach-Object { $envs[$_.Key] = [string]$_.Value }
|
|
5
|
-
Write-Output '${
|
|
5
|
+
Write-Output '${_}'
|
|
6
6
|
$envs | ConvertTo-Json -Compress
|
|
7
|
-
Write-Output '${
|
|
8
|
-
`,n=p(
|
|
7
|
+
Write-Output '${u}'
|
|
8
|
+
`,n=p(D(),["-NoProfile","-Command",e],{env:{...process.env,...a(process.env)},encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0});return typeof n.stdout=="string"?O(n.stdout):null}function C(){return(T.platform()==="win32"?H():M())??{}}function y(e){const n={...e.daemonEnv,...e.userEnv,...e.extra};return process.platform==="win32"&&Object.assign(n,a(n)),n.PATH=x(e.daemonEnv,e.userEnv,e.extra,n),delete n.Path,delete n.path,n}function L(e={}){const n=y({daemonEnv:process.env,userEnv:C(),extra:e});return delete n.SHENNIAN_SCHEDULE_CONTEXT,v(n),n}function F(e={}){const n=L(e),o=new Set([...f,...I]);for(const t of Object.keys(n))t.startsWith("SHENNIAN_")&&!o.has(t)&&delete n[t];return n}function k(e){const n=e.daemonEnv??process.env,o=e.platform??process.platform,t={};return l(t,n,o==="win32"?m:S,o),l(t,e.providerEnv,G(e.agentType),o),l(t,e.sessionEnv,w(e.agentType),o),l(t,e.runtimeEnv,P,o),o==="win32"&&Object.assign(t,a({...n,...t})),t.PATH=b(n,t,o),v(t),delete t.Path,delete t.path,t}function v(e){delete e.ELECTRON_RUN_AS_NODE,delete e.ELECTRON_NO_ASAR,delete e.SHENNIAN_DESKTOP_CLI_SCRIPT,delete e.SHENNIAN_DESKTOP_CLI_BRIDGE,delete e.SHENNIAN_DESKTOP_CLI_COMMAND;const n=R();n&&(e.PATH=[n,...(e.PATH??"").split(c.delimiter).filter(o=>o&&o!==n)].join(c.delimiter))}function l(e,n,o,t){if(!n)return;const s=Object.entries(n);for(const i of o){const r=(t==="win32"?s.find(([N])=>N.toUpperCase()===i.toUpperCase()):s.find(([N])=>N===i))?.[1];typeof r=="string"&&r.length>0&&(e[i]=r)}}function b(e,n,o){const t=o==="win32"?c.win32.delimiter:c.posix.delimiter,s=[],i=(E,r=!1)=>{if(E)for(const N of E.split(t))!N||s.includes(N)||(r?s.unshift(N):s.push(N))};if(i(d(e)),i(c.dirname(process.execPath),!0),o==="win32"){const E=a({...e,...n}),r=E.SystemRoot??E.WINDIR??"C:\\Windows";i(c.win32.join(r,"System32")),i(c.win32.join(r,"System32","WindowsPowerShell","v1.0")),i(r)}else i("/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");return s.join(t)}function d(e){return e?.PATH??e?.Path??e?.path}function x(e,n,o,t){const s=[];for(const E of[d(e),d(n),d(o)])for(const r of(E??"").split(c.delimiter))r&&!s.includes(r)&&s.push(r);if(process.platform==="win32"){const E=t.SystemRoot||t.WINDIR||process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";for(const r of[c.win32.join(E,"System32"),c.win32.join(E,"System32","WindowsPowerShell","v1.0"),c.win32.join(E)])r&&!s.includes(r)&&s.push(r)}const i=c.dirname(process.execPath);return i&&!s.includes(i)&&s.unshift(i),g({pathValue:s.join(c.delimiter),env:t})}export{f as MANAGED_AGENT_SESSION_ENV_KEYS,L as buildAgentProcessEnv,k as buildManagedAgentProcessEnv,F as buildManagedNativeFullProcessEnv,Y as getManagedAgentBaseEnvKeys,G as getManagedAgentProviderEnvKeys,w as getManagedAgentSessionEnvKeys,y as mergeAgentProcessEnv,C as readLatestUserEnv};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { AgentType, ChatAttachmentMeta, ExternalChannelSessionStatus, ModelInfo, SessionRunPhase } from '@shennian/wire';
|
|
1
2
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import type { AgentType, ChatAttachmentMeta, ExternalChannelSessionStatus, SessionRunPhase, ModelInfo } from '@shennian/wire';
|
|
3
|
-
import type { CompiledManagedAgentPolicy } from '../security/managed-agent-policy.js';
|
|
4
3
|
import type { ManagedRoomExecutor } from '../room/managed-room-ipc.js';
|
|
4
|
+
import type { CompiledManagedAgentPolicy } from '../security/managed-agent-policy.js';
|
|
5
5
|
export type AgentEvent = {
|
|
6
6
|
state: string;
|
|
7
7
|
runId: string;
|
|
@@ -74,7 +74,7 @@ export type AgentSessionOptions = {
|
|
|
74
74
|
export type AgentStartOptions = {
|
|
75
75
|
/** Test-only callers can disable provider-native history persistence. */
|
|
76
76
|
persistNativeSession?: boolean;
|
|
77
|
-
/**
|
|
77
|
+
/** Internal ownership hint, not a guarantee about a third-party client's sidebar. */
|
|
78
78
|
nativeSessionVisibility?: 'user' | 'internal';
|
|
79
79
|
};
|
|
80
80
|
export type AgentRecoveryCapabilities = {
|
|
@@ -121,8 +121,12 @@ export type AgentRecoveryResult = {
|
|
|
121
121
|
};
|
|
122
122
|
export interface AgentAdapterEvents {
|
|
123
123
|
agentEvent: [event: AgentEvent];
|
|
124
|
+
nativeSession: [provider: AgentType, agentSessionId: string];
|
|
124
125
|
error: [error: Error];
|
|
125
126
|
}
|
|
127
|
+
/** Adapters emit nativeSession(provider, id) synchronously before sending a turn.
|
|
128
|
+
* The session lifecycle listener durably registers ownership; a listener error
|
|
129
|
+
* must abort the turn, not be swallowed as a best-effort telemetry failure. */
|
|
126
130
|
export declare abstract class AgentAdapter extends EventEmitter<AgentAdapterEvents> {
|
|
127
131
|
abstract readonly type: AgentType;
|
|
128
132
|
/** Explicit fail-closed default; resumable adapters must opt in. */
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AgentAuthState, BuiltinAgentType } from '@shennian/wire';
|
|
2
|
+
import { type ResolvedCommandSpec } from './command-spec.js';
|
|
3
|
+
export declare function parseBuiltinAuthStatus(agent: 'codex' | 'claude', code: number | null, stdout: string, stderr: string): AgentAuthState;
|
|
4
|
+
export declare function probeBuiltinAuthStatus(agent: BuiltinAgentType, spec: ResolvedCommandSpec, version?: string): Promise<AgentAuthState>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{buildAgentProcessEnv as p}from"../agent-env.js";import{buildManagedAgentEnv as g}from"./config-status.js";import{spawnResolvedCommand as m}from"./command-spec.js";function h(n,o,i,l){if(n==="claude"){try{const r=JSON.parse(i);if(r?.loggedIn===!0&&o===0)return"ready";if(r?.loggedIn===!1&&o===1)return"required"}catch{}return"unknown"}const e=`${i}
|
|
2
|
+
${l}`.replace(/\u001b\[[0-9;]*m/g,"");return o===0&&/\bLogged in (?:using|with)\b/i.test(e)?"ready":o===1&&/\bNot logged in\b/i.test(e)?"required":"unknown"}async function S(n,o,i){return n!=="codex"&&n!=="claude"||!i?"unknown":new Promise(l=>{let e="",r="",c=!1;const s=t=>{c||(c=!0,clearTimeout(f),e="",r="",l(t))},u=m(o,n==="codex"?["login","status"]:["auth","status"],{env:p(g(n)),stdio:["ignore","pipe","pipe"]}),f=setTimeout(()=>{u.kill("SIGKILL"),s("unknown")},5e3),d=(t,a)=>{if(!c){if(e.length+r.length+a.length>32768){u.kill("SIGKILL"),s("unknown");return}t==="out"?e+=a.toString():r+=a.toString()}};u.stdout?.on("data",t=>d("out",t)),u.stderr?.on("data",t=>d("err",t)),u.once("error",()=>s("unknown")),u.once("close",t=>s(h(n,t,e,r)))}).catch(()=>"unknown")}export{h as parseBuiltinAuthStatus,S as probeBuiltinAuthStatus};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import p from"node:fs";import o from"node:path";import{createInterface as y}from"node:readline";import{randomUUID as f}from"node:crypto";import{AgentAdapter as S,registerAgent as E}from"./adapter.js";import{resolveBuiltinCommand as m,spawnAgentCommand as x,spawnResolvedCommandSync as v}from"./command-spec.js";import{buildAgentProcessEnv as P,buildManagedAgentProcessEnv as I,buildManagedNativeFullProcessEnv as C}from"../agent-env.js";import{buildPlatformInstructions as g}from"./platform-instructions.js";import{resolveManagedAgentAdapterEnforcement as k,isManagedAgentNativeFull as
|
|
2
|
-
${t.stderr??""}`,a=/(?:^|\s)--effort(?:\s|,|<)/.test(s);return
|
|
1
|
+
import p from"node:fs";import o from"node:path";import{createInterface as y}from"node:readline";import{randomUUID as f}from"node:crypto";import{AgentAdapter as S,registerAgent as E}from"./adapter.js";import{resolveBuiltinCommand as m,spawnAgentCommand as x,spawnResolvedCommandSync as v}from"./command-spec.js";import{buildAgentProcessEnv as P,buildManagedAgentProcessEnv as I,buildManagedNativeFullProcessEnv as C}from"../agent-env.js";import{buildPlatformInstructions as g}from"./platform-instructions.js";import{resolveManagedAgentAdapterEnforcement as k,isManagedAgentNativeFull as h}from"../security/managed-agent-policy.js";import{registerManagedAgentRuntimeSecurity as w}from"../security/managed-agent-runtime.js";import{resolveManagedRoomIpcPaths as A}from"../daemon-ipc/paths.js";import{CLAUDE_MANAGED_RUNTIME_SECURITY as _,compileClaudeManagedPermissions as T}from"./claude-managed-permissions.js";w("claude",_);function R(n){return n?.trim()||"default"}const M=new Set(["low","medium","high","xhigh","max"]),c=new Map;function O(n){const e=n?.trim();if(e){if(M.has(e))return e;throw new Error(`Unsupported Claude reasoning effort "${e}". Supported values: low, medium, high, xhigh, max.`)}}function X(){c.clear()}function N(n){const e=n.trim();return e?!e.includes("claude.ai connectors are disabled because"):!1}function D(){const n=m("claude");if(!n)return!1;const e=`${n.kind}:${n.path}:${n.command}:${n.args.join("\0")}`;if(c.has(e))return c.get(e)??!1;try{const t=v(n,["--help"],{encoding:"utf-8",stdio:["ignore","pipe","pipe"],timeout:3e3,env:process.env}),s=`${t.stdout??""}
|
|
2
|
+
${t.stderr??""}`,a=/(?:^|\s)--effort(?:\s|,|<)/.test(s);return c.set(e,a),a}catch{return c.set(e,!1),!1}}class F extends S{options;type="claude";get recoveryCapabilities(){return{inspectTerminal:!1,reattachRun:!1,resumeRun:!1,resumeSession:!0}}process=null;agentSessionId=null;sessionId=null;workDir=null;seq=0;runId="";hasEmittedText=!1;terminalState="open";pendingSuccess=null;persistNativeSession=!0;managedAgentPolicy=null;constructor(e={}){super(),this.options=e}externalChannel=null;shennianSessionId=null;extraEnv={};configure(e){this.shennianSessionId=e.sessionId??null,this.externalChannel=e.externalChannel??null,this.extraEnv=e.env??{},"managedAgentPolicy"in e&&(this.managedAgentPolicy=e.managedAgentPolicy??null),this.managedAgentPolicy&&(this.workDir=this.managedAgentPolicy.adapterPolicy.workDir)}async start(e,t,s,a){this.sessionId=e,this.workDir=this.managedAgentPolicy?.adapterPolicy.workDir??t,this.seq=0,this.persistNativeSession=a?.persistNativeSession!==!1,s&&(this.agentSessionId=s)}async send(e,t,s,a,l,r){if(r?.source==="room_activation"&&!this.managedAgentPolicy)throw new Error("managed_agent_policy_missing");await this.killProcess(),this.runId=f(),this.resetRunState();const i=["-p",e,"--output-format","stream-json","--verbose",...this.buildManagedPermissionConfig()?.args??[]];this.persistNativeSession||i.push("--no-session-persistence");const u=this.options.systemPrompt??g(this.workDir??process.cwd(),this.externalChannel,this.shennianSessionId??void 0,l);u&&i.push("--append-system-prompt",u),this.options.hidden&&i.push("--name","Shennian Manager Substrate"),(!this.managedAgentPolicy||h(this.managedAgentPolicy))&&process.getuid?.()!==0&&i.push("--dangerously-skip-permissions"),i.push("--model",R(t));const d=O(s);d&&D()&&i.push("--effort",d),this.agentSessionId&&i.push("--resume",this.agentSessionId),this.spawnAndParse(i)}async resume(e){await this.killProcess(),this.agentSessionId=e,this.runId=f(),this.resetRunState();const t=["--resume",e,"--output-format","stream-json","--verbose",...this.buildManagedPermissionConfig()?.args??[]],s=this.options.systemPrompt??g(this.workDir??process.cwd(),this.externalChannel,this.shennianSessionId??void 0);s&&t.push("--append-system-prompt",s),this.options.hidden&&t.push("--name","Shennian Manager Substrate"),(!this.managedAgentPolicy||h(this.managedAgentPolicy))&&process.getuid?.()!==0&&t.push("--dangerously-skip-permissions"),this.spawnAndParse(t)}async stop(){await this.killProcess()}spawnAndParse(e){const t=m("claude");if(!t){this.emit("error",new Error('Command "claude" not found. Is Claude Code CLI installed?'));return}const s=x(t,e,{cwd:this.workDir??void 0,stdio:["ignore","pipe","pipe"],env:this.buildProcessEnv()});this.process=s,y({input:s.stdout}).on("line",r=>{if(r.trim())try{const i=JSON.parse(r);this.handleStreamEvent(i)}catch{}});let l="";s.stderr?.on("data",r=>{const i=r.toString();if(l+=i,this.terminalState==="open")for(const u of i.split(`
|
|
3
3
|
`)){const d=u.trim();N(d)&&this.emitEvent({state:"delta",text:d+`
|
|
4
|
-
`})}}),s.on("close",r=>{this.process===s&&(this.process=null,this.handleProcessClose(r,l))}),s.on("error",r=>{this.process===s&&(this.process=null,r.code==="ENOENT"?this.emit("error",new Error('Command "claude" not found. Is Claude Code CLI installed?')):this.emit("error",r))})}buildManagedPermissionConfig(){const e=this.managedAgentPolicy;if(!e||
|
|
4
|
+
`})}}),s.on("close",r=>{this.process===s&&(this.process=null,this.handleProcessClose(r,l))}),s.on("error",r=>{this.process===s&&(this.process=null,r.code==="ENOENT"?this.emit("error",new Error('Command "claude" not found. Is Claude Code CLI installed?')):this.emit("error",r))})}buildManagedPermissionConfig(){const e=this.managedAgentPolicy;if(!e||h(e))return null;const t=L();return T(k(e),e.adapterPolicy.workDir,{internalReadPaths:t.readPaths,internalUnixSockets:t.unixSockets,shellSubprocessPolicy:e.environmentPolicy.shellSubprocess})}buildProcessEnv(){return this.managedAgentPolicy?h(this.managedAgentPolicy)?C({NO_COLOR:"1",...this.extraEnv}):I({agentType:"claude",providerEnv:this.extraEnv,sessionEnv:this.extraEnv,runtimeEnv:{NO_COLOR:"1"}}):P(this.extraEnv)}handleStreamEvent(e){if(e.type==="system"&&e.subtype==="init"&&e.session_id){this.agentSessionId=e.session_id,this.emitEvent({state:"start",agentSessionId:this.agentSessionId});return}if(!(e.type==="system"&&e.subtype==="api_retry"&&e.error==="authentication_failed")){if(e.type==="assistant"){if(e.message?.content){for(const t of e.message.content)if(t.type==="text"&&t.text){const s=this.hasEmittedText?`
|
|
5
5
|
|
|
6
6
|
`:"";this.emitEvent({state:"delta",text:s+t.text}),this.hasEmittedText=!0}else t.type==="thinking"&&t.thinking?this.emitEvent({state:"delta",text:t.thinking,thinking:!0}):t.type==="tool_use"&&this.emitEvent({state:"tool-call",name:t.name,args:t.input});return}if(e.subtype==="text"&&e.text){const t=this.hasEmittedText?`
|
|
7
7
|
|
|
8
|
-
`:"";this.emitEvent({state:"delta",text:t+e.text}),this.hasEmittedText=!0}else e.subtype==="thinking"&&e.thinking?this.emitEvent({state:"delta",text:e.thinking,thinking:!0}):e.subtype==="tool_use"&&this.emitEvent({state:"tool-call",name:e.name,args:e.input});return}if(e.type==="result")if(e.subtype==="tool_result"){const t=typeof e.content=="string"?e.content:JSON.stringify(e.content);this.emitEvent({state:"tool-result",name:e.name,result:t})}else if(e.subtype==="success"){e.session_id&&(this.agentSessionId=e.session_id);const t=typeof e.result=="string"?e.result:"";!this.hasEmittedText&&t.trim()&&(this.emitEvent({state:"delta",text:t}),this.hasEmittedText=!0);const s=e.usage??e.message?.usage;this.pendingSuccess={agentSessionId:this.agentSessionId??void 0,usage:s?{inputTokens:s.input_tokens,outputTokens:s.output_tokens}:void 0}}else e.subtype==="error"&&this.emitErrorIfOpen({state:"error",message:e.error??e.result??"unknown error"})}handleProcessClose(e,t){if(e!==0&&e!==null){const s=t.trim()||`claude exited with code ${e}`;this.emitErrorIfOpen({state:"error",message:s});return}if(!this.hasEmittedText){this.emitErrorIfOpen({state:"error",message:"Claude completed without response text"});return}this.emitFinalIfOpen({state:"final",agentSessionId:this.pendingSuccess?.agentSessionId??this.agentSessionId??void 0,usage:this.pendingSuccess?.usage})}emitFinalIfOpen(e){this.terminalState==="open"&&(this.terminalState="final",this.emitEvent(e))}emitErrorIfOpen(e){this.terminalState==="open"&&(this.terminalState="error",this.emitEvent(e))}resetRunState(){this.seq=0,this.hasEmittedText=!1,this.terminalState="open",this.pendingSuccess=null}emitEvent(e){const t={...e,runId:this.runId,seq:this.seq++};this.emit("agentEvent",t)}async killProcess(){const e=this.process;e&&(this.process=null,e.kill("SIGTERM"),await new Promise(t=>{e.on("close",t),setTimeout(()=>{e.kill("SIGKILL"),t()},3e3)}))}}function L(){const n=A(),e=[n.secretFile],t=n.transport==="unix_socket"?[n.endpoint]:[];n.transport==="unix_socket"&&e.push(n.endpoint);const s=m("pi");return s?.path&&e.push(...U(s.path)),{readPaths:[...new Set(e)].sort(),unixSockets:[...new Set(t)].sort()}}function U(n){const e=o.normalize(n.trim());if(!e||!o.isAbsolute(e))return[];const t=[e];try{const s=p.realpathSync(e);t.push(s,o.dirname(s),o.dirname(o.dirname(s)));let a=o.dirname(s);for(let l=0;l<8;l+=1){const r=o.join(a,"package.json");try{if(JSON.parse(p.readFileSync(r,"utf8")).name==="shennian"){t.push(a);break}}catch{}const i=o.dirname(a);if(i===a)break;a=i}}catch{}return[...new Set(t)].sort()}E("claude",()=>new F);export{F as ClaudeAdapter,R as normalizeClaudeModelId,
|
|
8
|
+
`:"";this.emitEvent({state:"delta",text:t+e.text}),this.hasEmittedText=!0}else e.subtype==="thinking"&&e.thinking?this.emitEvent({state:"delta",text:e.thinking,thinking:!0}):e.subtype==="tool_use"&&this.emitEvent({state:"tool-call",name:e.name,args:e.input});return}if(e.type==="result")if(e.subtype==="tool_result"){const t=typeof e.content=="string"?e.content:JSON.stringify(e.content);this.emitEvent({state:"tool-result",name:e.name,result:t})}else if(e.subtype==="success"){e.session_id&&(this.agentSessionId=e.session_id);const t=typeof e.result=="string"?e.result:"";!this.hasEmittedText&&t.trim()&&(this.emitEvent({state:"delta",text:t}),this.hasEmittedText=!0);const s=e.usage??e.message?.usage;this.pendingSuccess={agentSessionId:this.agentSessionId??void 0,usage:s?{inputTokens:s.input_tokens,outputTokens:s.output_tokens}:void 0}}else e.subtype==="error"&&this.emitErrorIfOpen({state:"error",message:e.error??e.result??"unknown error"})}}handleProcessClose(e,t){if(e!==0&&e!==null){const s=t.trim()||`claude exited with code ${e}`;this.emitErrorIfOpen({state:"error",message:s});return}if(!this.hasEmittedText){this.emitErrorIfOpen({state:"error",message:"Claude completed without response text"});return}this.emitFinalIfOpen({state:"final",agentSessionId:this.pendingSuccess?.agentSessionId??this.agentSessionId??void 0,usage:this.pendingSuccess?.usage})}emitFinalIfOpen(e){this.terminalState==="open"&&(this.terminalState="final",this.emitEvent(e))}emitErrorIfOpen(e){this.terminalState==="open"&&(this.terminalState="error",this.emitEvent(e))}resetRunState(){this.seq=0,this.hasEmittedText=!1,this.terminalState="open",this.pendingSuccess=null}emitEvent(e){const t={...e,runId:this.runId,seq:this.seq++};this.emit("agentEvent",t)}async killProcess(){const e=this.process;e&&(this.process=null,e.kill("SIGTERM"),await new Promise(t=>{e.on("close",t),setTimeout(()=>{e.kill("SIGKILL"),t()},3e3)}))}}function L(){const n=A(),e=[n.secretFile],t=n.transport==="unix_socket"?[n.endpoint]:[];n.transport==="unix_socket"&&e.push(n.endpoint);const s=m("pi");return s?.path&&e.push(...U(s.path)),{readPaths:[...new Set(e)].sort(),unixSockets:[...new Set(t)].sort()}}function U(n){const e=o.normalize(n.trim());if(!e||!o.isAbsolute(e))return[];const t=[e];try{const s=p.realpathSync(e);t.push(s,o.dirname(s),o.dirname(o.dirname(s)));let a=o.dirname(s);for(let l=0;l<8;l+=1){const r=o.join(a,"package.json");try{if(JSON.parse(p.readFileSync(r,"utf8")).name==="shennian"){t.push(a);break}}catch{}const i=o.dirname(a);if(i===a)break;a=i}}catch{}return[...new Set(t)].sort()}E("claude",()=>new F);export{F as ClaudeAdapter,R as normalizeClaudeModelId,O as normalizeClaudeReasoningEffort,X as resetClaudeCapabilityCacheForTests,L as resolveClaudeManagedInternalAccess,U as resolveClaudeShennianCliReadPaths,N as shouldForwardClaudeStderrLine,D as supportsClaudeReasoningEffort};
|