shennian 0.4.68 → 0.4.71

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.
Files changed (95) hide show
  1. package/dist/publish-build-manifest.json +138 -78
  2. package/dist/src/agent-env.js +4 -4
  3. package/dist/src/agents/adapter.d.ts +7 -3
  4. package/dist/src/agents/auth-status.d.ts +4 -0
  5. package/dist/src/agents/auth-status.js +2 -0
  6. package/dist/src/agents/codex-protocol.d.ts +103 -0
  7. package/dist/src/agents/codex-protocol.js +3 -0
  8. package/dist/src/agents/codex-runtime.d.ts +91 -0
  9. package/dist/src/agents/codex-runtime.js +14 -0
  10. package/dist/src/agents/codex.d.ts +15 -91
  11. package/dist/src/agents/codex.js +2 -17
  12. package/dist/src/agents/command-spec.js +4 -3
  13. package/dist/src/agents/detect.js +1 -1
  14. package/dist/src/agents/manager.d.ts +4 -3
  15. package/dist/src/agents/manager.js +4 -4
  16. package/dist/src/agents/model-registry/cache.js +1 -1
  17. package/dist/src/agents/model-registry/discovery.js +3 -3
  18. package/dist/src/agents/model-registry/opencode-api.d.ts +2 -0
  19. package/dist/src/agents/model-registry/opencode-api.js +1 -0
  20. package/dist/src/agents/model-registry/parsers.d.ts +1 -0
  21. package/dist/src/agents/model-registry/parsers.js +4 -4
  22. package/dist/src/agents/model-registry/service.js +1 -1
  23. package/dist/src/agents/opencode.d.ts +4 -0
  24. package/dist/src/agents/opencode.js +1 -1
  25. package/dist/src/commands/agent-readiness.d.ts +17 -0
  26. package/dist/src/commands/agent-readiness.js +2 -0
  27. package/dist/src/commands/agent.js +2 -2
  28. package/dist/src/commands/daemon-instance-lock.js +1 -1
  29. package/dist/src/commands/daemon-process.d.ts +1 -0
  30. package/dist/src/commands/daemon-process.js +1 -1
  31. package/dist/src/commands/daemon-service-spec.d.ts +28 -0
  32. package/dist/src/commands/daemon-service-spec.js +1 -0
  33. package/dist/src/commands/daemon-start-wait.d.ts +1 -1
  34. package/dist/src/commands/daemon-start-wait.js +1 -1
  35. package/dist/src/commands/daemon-state.d.ts +57 -0
  36. package/dist/src/commands/daemon-state.js +1 -0
  37. package/dist/src/commands/daemon-windows.d.ts +8 -0
  38. package/dist/src/commands/daemon-windows.js +10 -10
  39. package/dist/src/commands/daemon.d.ts +4 -64
  40. package/dist/src/commands/daemon.js +13 -13
  41. package/dist/src/commands/upgrade.js +1 -1
  42. package/dist/src/daemon-ipc/agent-readiness.d.ts +14 -0
  43. package/dist/src/daemon-ipc/agent-readiness.js +1 -0
  44. package/dist/src/daemon-ipc/control.d.ts +1 -1
  45. package/dist/src/daemon-ipc/control.js +1 -1
  46. package/dist/src/index.js +3 -3
  47. package/dist/src/native-fusion/local-repository.d.ts +6 -1
  48. package/dist/src/native-fusion/local-repository.js +2 -2
  49. package/dist/src/native-fusion/service.d.ts +2 -0
  50. package/dist/src/native-fusion/service.js +2 -2
  51. package/dist/src/native-fusion/source-visibility-audit.d.ts +16 -0
  52. package/dist/src/native-fusion/source-visibility-audit.js +1 -0
  53. package/dist/src/native-fusion/source-visibility.d.ts +25 -0
  54. package/dist/src/native-fusion/source-visibility.js +1 -0
  55. package/dist/src/native-fusion/state.d.ts +1 -0
  56. package/dist/src/native-fusion/state.js +2 -2
  57. package/dist/src/native-fusion/types.d.ts +5 -0
  58. package/dist/src/room/managed-room-binding.d.ts +2 -0
  59. package/dist/src/room/managed-room-binding.js +1 -1
  60. package/dist/src/room/room-binding-client.d.ts +1 -0
  61. package/dist/src/room/room-binding-client.js +1 -1
  62. package/dist/src/runtime-distribution.d.ts +13 -0
  63. package/dist/src/runtime-distribution.js +1 -0
  64. package/dist/src/security/managed-agent-policy.d.ts +7 -0
  65. package/dist/src/security/managed-agent-policy.js +1 -1
  66. package/dist/src/session/handlers/agent-workspace-validation.d.ts +1 -0
  67. package/dist/src/session/handlers/agent-workspace-validation.js +1 -1
  68. package/dist/src/session/handlers/agents.d.ts +7 -1
  69. package/dist/src/session/handlers/agents.js +1 -1
  70. package/dist/src/session/handlers/chat-context.d.ts +31 -0
  71. package/dist/src/session/handlers/chat-context.js +1 -0
  72. package/dist/src/session/handlers/chat-events.d.ts +1 -1
  73. package/dist/src/session/handlers/chat-events.js +2 -2
  74. package/dist/src/session/handlers/chat-session-lifecycle.d.ts +2 -2
  75. package/dist/src/session/handlers/chat-session-lifecycle.js +1 -1
  76. package/dist/src/session/handlers/chat.d.ts +3 -29
  77. package/dist/src/session/handlers/chat.js +1 -1
  78. package/dist/src/session/manager.js +2 -2
  79. package/dist/src/session/queue-helpers.js +2 -2
  80. package/dist/src/session/queue-message.d.ts +2 -0
  81. package/dist/src/session/queue.d.ts +7 -1
  82. package/dist/src/session/queue.js +1 -1
  83. package/dist/src/session/queued-chat-dispatch.d.ts +4 -1
  84. package/dist/src/session/queued-chat-dispatch.js +1 -1
  85. package/dist/src/session/store.d.ts +4 -2
  86. package/dist/src/session/store.js +2 -2
  87. package/dist/src/session/types.d.ts +1 -0
  88. package/dist/src/upgrade/engine.js +2 -2
  89. package/dist/src/upgrade/scheduler.js +1 -1
  90. package/dist/src/upgrade/updater-launcher.js +3 -3
  91. package/node_modules/@shennian/wire/dist/room.d.ts +2 -0
  92. package/node_modules/@shennian/wire/dist/session-sync.d.ts +2 -1
  93. package/node_modules/@shennian/wire/dist/session.d.ts +19 -1
  94. package/node_modules/@shennian/wire/dist/session.js +8 -0
  95. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "jsMinified": true,
4
4
  "minifier": "esbuild",
5
- "fileCount": 207,
5
+ "fileCount": 219,
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": 10709,
15
- "afterBytes": 4754
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": 3707,
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,
@@ -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": 69014,
125
- "afterBytes": 35438
139
+ "beforeBytes": 34652,
140
+ "afterBytes": 18423
126
141
  },
127
142
  {
128
143
  "file": "src/agents/command-spec.js",
129
- "beforeBytes": 19263,
130
- "afterBytes": 8681
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": 3496,
165
- "afterBytes": 1591
179
+ "beforeBytes": 3767,
180
+ "afterBytes": 1707
166
181
  },
167
182
  {
168
183
  "file": "src/agents/external-channel-instructions.js",
@@ -176,23 +191,28 @@
176
191
  },
177
192
  {
178
193
  "file": "src/agents/manager.js",
179
- "beforeBytes": 10984,
180
- "afterBytes": 5949
194
+ "beforeBytes": 11257,
195
+ "afterBytes": 6122
181
196
  },
182
197
  {
183
198
  "file": "src/agents/model-registry/cache.js",
184
- "beforeBytes": 1321,
185
- "afterBytes": 575
199
+ "beforeBytes": 1491,
200
+ "afterBytes": 640
186
201
  },
187
202
  {
188
203
  "file": "src/agents/model-registry/discovery.js",
189
- "beforeBytes": 10881,
190
- "afterBytes": 5056
204
+ "beforeBytes": 11070,
205
+ "afterBytes": 5176
206
+ },
207
+ {
208
+ "file": "src/agents/model-registry/opencode-api.js",
209
+ "beforeBytes": 3026,
210
+ "afterBytes": 1539
191
211
  },
192
212
  {
193
213
  "file": "src/agents/model-registry/parsers.js",
194
- "beforeBytes": 19925,
195
- "afterBytes": 10288
214
+ "beforeBytes": 22727,
215
+ "afterBytes": 11534
196
216
  },
197
217
  {
198
218
  "file": "src/agents/model-registry/runner.js",
@@ -201,8 +221,8 @@
201
221
  },
202
222
  {
203
223
  "file": "src/agents/model-registry/service.js",
204
- "beforeBytes": 5997,
205
- "afterBytes": 2572
224
+ "beforeBytes": 6036,
225
+ "afterBytes": 2605
206
226
  },
207
227
  {
208
228
  "file": "src/agents/model-registry/types.js",
@@ -231,8 +251,8 @@
231
251
  },
232
252
  {
233
253
  "file": "src/agents/opencode.js",
234
- "beforeBytes": 12131,
235
- "afterBytes": 6608
254
+ "beforeBytes": 13211,
255
+ "afterBytes": 6927
236
256
  },
237
257
  {
238
258
  "file": "src/agents/pi-coding-agent-managed-permissions.js",
@@ -284,35 +304,50 @@
284
304
  "beforeBytes": 18443,
285
305
  "afterBytes": 9602
286
306
  },
307
+ {
308
+ "file": "src/commands/agent-readiness.js",
309
+ "beforeBytes": 3425,
310
+ "afterBytes": 2819
311
+ },
287
312
  {
288
313
  "file": "src/commands/agent.js",
289
- "beforeBytes": 5136,
290
- "afterBytes": 2826
314
+ "beforeBytes": 5283,
315
+ "afterBytes": 2934
291
316
  },
292
317
  {
293
318
  "file": "src/commands/daemon-instance-lock.js",
294
- "beforeBytes": 3665,
295
- "afterBytes": 1250
319
+ "beforeBytes": 4507,
320
+ "afterBytes": 1811
296
321
  },
297
322
  {
298
323
  "file": "src/commands/daemon-process.js",
299
- "beforeBytes": 5335,
300
- "afterBytes": 2995
324
+ "beforeBytes": 7019,
325
+ "afterBytes": 3895
326
+ },
327
+ {
328
+ "file": "src/commands/daemon-service-spec.js",
329
+ "beforeBytes": 4365,
330
+ "afterBytes": 2648
301
331
  },
302
332
  {
303
333
  "file": "src/commands/daemon-start-wait.js",
304
- "beforeBytes": 1013,
305
- "afterBytes": 422
334
+ "beforeBytes": 1208,
335
+ "afterBytes": 438
336
+ },
337
+ {
338
+ "file": "src/commands/daemon-state.js",
339
+ "beforeBytes": 10369,
340
+ "afterBytes": 5116
306
341
  },
307
342
  {
308
343
  "file": "src/commands/daemon-windows.js",
309
- "beforeBytes": 4512,
310
- "afterBytes": 3389
344
+ "beforeBytes": 5732,
345
+ "afterBytes": 4027
311
346
  },
312
347
  {
313
348
  "file": "src/commands/daemon.js",
314
- "beforeBytes": 45807,
315
- "afterBytes": 21994
349
+ "beforeBytes": 34161,
350
+ "afterBytes": 17352
316
351
  },
317
352
  {
318
353
  "file": "src/commands/integration.js",
@@ -371,14 +406,19 @@
371
406
  },
372
407
  {
373
408
  "file": "src/commands/upgrade.js",
374
- "beforeBytes": 13052,
375
- "afterBytes": 6572
409
+ "beforeBytes": 13446,
410
+ "afterBytes": 6795
376
411
  },
377
412
  {
378
413
  "file": "src/config/index.js",
379
414
  "beforeBytes": 2801,
380
415
  "afterBytes": 1662
381
416
  },
417
+ {
418
+ "file": "src/daemon-ipc/agent-readiness.js",
419
+ "beforeBytes": 2884,
420
+ "afterBytes": 1555
421
+ },
382
422
  {
383
423
  "file": "src/daemon-ipc/client.js",
384
424
  "beforeBytes": 2786,
@@ -386,8 +426,8 @@
386
426
  },
387
427
  {
388
428
  "file": "src/daemon-ipc/control.js",
389
- "beforeBytes": 3975,
390
- "afterBytes": 2196
429
+ "beforeBytes": 4016,
430
+ "afterBytes": 2227
391
431
  },
392
432
  {
393
433
  "file": "src/daemon-ipc/json.js",
@@ -446,8 +486,8 @@
446
486
  },
447
487
  {
448
488
  "file": "src/index.js",
449
- "beforeBytes": 39165,
450
- "afterBytes": 19567
489
+ "beforeBytes": 40923,
490
+ "afterBytes": 20430
451
491
  },
452
492
  {
453
493
  "file": "src/log-redaction.js",
@@ -521,8 +561,8 @@
521
561
  },
522
562
  {
523
563
  "file": "src/native-fusion/local-repository.js",
524
- "beforeBytes": 26330,
525
- "afterBytes": 12881
564
+ "beforeBytes": 27323,
565
+ "afterBytes": 13527
526
566
  },
527
567
  {
528
568
  "file": "src/native-fusion/native-source-deletions.js",
@@ -546,18 +586,28 @@
546
586
  },
547
587
  {
548
588
  "file": "src/native-fusion/service.js",
549
- "beforeBytes": 37567,
550
- "afterBytes": 16892
589
+ "beforeBytes": 39178,
590
+ "afterBytes": 17772
551
591
  },
552
592
  {
553
593
  "file": "src/native-fusion/session-header.js",
554
594
  "beforeBytes": 4294,
555
595
  "afterBytes": 1996
556
596
  },
597
+ {
598
+ "file": "src/native-fusion/source-visibility-audit.js",
599
+ "beforeBytes": 2911,
600
+ "afterBytes": 1532
601
+ },
602
+ {
603
+ "file": "src/native-fusion/source-visibility.js",
604
+ "beforeBytes": 4772,
605
+ "afterBytes": 2342
606
+ },
557
607
  {
558
608
  "file": "src/native-fusion/state.js",
559
- "beforeBytes": 4401,
560
- "afterBytes": 2293
609
+ "beforeBytes": 5715,
610
+ "afterBytes": 3080
561
611
  },
562
612
  {
563
613
  "file": "src/native-fusion/types.js",
@@ -656,8 +706,8 @@
656
706
  },
657
707
  {
658
708
  "file": "src/room/managed-room-binding.js",
659
- "beforeBytes": 6573,
660
- "afterBytes": 3483
709
+ "beforeBytes": 6625,
710
+ "afterBytes": 3516
661
711
  },
662
712
  {
663
713
  "file": "src/room/managed-room-ipc.js",
@@ -696,14 +746,19 @@
696
746
  },
697
747
  {
698
748
  "file": "src/room/room-binding-client.js",
699
- "beforeBytes": 6903,
700
- "afterBytes": 3961
749
+ "beforeBytes": 7086,
750
+ "afterBytes": 4075
701
751
  },
702
752
  {
703
753
  "file": "src/room/session-registry.js",
704
754
  "beforeBytes": 30575,
705
755
  "afterBytes": 17164
706
756
  },
757
+ {
758
+ "file": "src/runtime-distribution.js",
759
+ "beforeBytes": 2844,
760
+ "afterBytes": 1540
761
+ },
707
762
  {
708
763
  "file": "src/schedules/personal-context.js",
709
764
  "beforeBytes": 901,
@@ -726,8 +781,8 @@
726
781
  },
727
782
  {
728
783
  "file": "src/security/managed-agent-policy.js",
729
- "beforeBytes": 7408,
730
- "afterBytes": 3542
784
+ "beforeBytes": 7465,
785
+ "afterBytes": 3578
731
786
  },
732
787
  {
733
788
  "file": "src/security/managed-agent-runtime.js",
@@ -781,23 +836,28 @@
781
836
  },
782
837
  {
783
838
  "file": "src/session/handlers/agent-workspace-validation.js",
784
- "beforeBytes": 9051,
785
- "afterBytes": 4712
839
+ "beforeBytes": 9962,
840
+ "afterBytes": 5313
786
841
  },
787
842
  {
788
843
  "file": "src/session/handlers/agents.js",
789
- "beforeBytes": 2274,
790
- "afterBytes": 1134
844
+ "beforeBytes": 2481,
845
+ "afterBytes": 1211
791
846
  },
792
847
  {
793
848
  "file": "src/session/handlers/chat-adapter-config.js",
794
849
  "beforeBytes": 2814,
795
850
  "afterBytes": 1159
796
851
  },
852
+ {
853
+ "file": "src/session/handlers/chat-context.js",
854
+ "beforeBytes": 3243,
855
+ "afterBytes": 1986
856
+ },
797
857
  {
798
858
  "file": "src/session/handlers/chat-events.js",
799
- "beforeBytes": 15468,
800
- "afterBytes": 6683
859
+ "beforeBytes": 15787,
860
+ "afterBytes": 6851
801
861
  },
802
862
  {
803
863
  "file": "src/session/handlers/chat-recovery.js",
@@ -806,13 +866,13 @@
806
866
  },
807
867
  {
808
868
  "file": "src/session/handlers/chat-session-lifecycle.js",
809
- "beforeBytes": 3728,
810
- "afterBytes": 1723
869
+ "beforeBytes": 4467,
870
+ "afterBytes": 2119
811
871
  },
812
872
  {
813
873
  "file": "src/session/handlers/chat.js",
814
- "beforeBytes": 35331,
815
- "afterBytes": 15258
874
+ "beforeBytes": 33039,
875
+ "afterBytes": 13936
816
876
  },
817
877
  {
818
878
  "file": "src/session/handlers/control.js",
@@ -886,8 +946,8 @@
886
946
  },
887
947
  {
888
948
  "file": "src/session/manager.js",
889
- "beforeBytes": 42657,
890
- "afterBytes": 22491
949
+ "beforeBytes": 42836,
950
+ "afterBytes": 22584
891
951
  },
892
952
  {
893
953
  "file": "src/session/native-cleanup-outbox.js",
@@ -911,8 +971,8 @@
911
971
  },
912
972
  {
913
973
  "file": "src/session/queue-helpers.js",
914
- "beforeBytes": 8522,
915
- "afterBytes": 4242
974
+ "beforeBytes": 8579,
975
+ "afterBytes": 4271
916
976
  },
917
977
  {
918
978
  "file": "src/session/queue-message.js",
@@ -936,13 +996,13 @@
936
996
  },
937
997
  {
938
998
  "file": "src/session/queue.js",
939
- "beforeBytes": 44695,
940
- "afterBytes": 19911
999
+ "beforeBytes": 49532,
1000
+ "afterBytes": 21739
941
1001
  },
942
1002
  {
943
1003
  "file": "src/session/queued-chat-dispatch.js",
944
- "beforeBytes": 3024,
945
- "afterBytes": 1703
1004
+ "beforeBytes": 3176,
1005
+ "afterBytes": 1809
946
1006
  },
947
1007
  {
948
1008
  "file": "src/session/run-recovery/barrier.js",
@@ -966,8 +1026,8 @@
966
1026
  },
967
1027
  {
968
1028
  "file": "src/session/store.js",
969
- "beforeBytes": 32176,
970
- "afterBytes": 16319
1029
+ "beforeBytes": 32798,
1030
+ "afterBytes": 16719
971
1031
  },
972
1032
  {
973
1033
  "file": "src/session/tool-detail-store.js",
@@ -1001,13 +1061,13 @@
1001
1061
  },
1002
1062
  {
1003
1063
  "file": "src/upgrade/engine.js",
1004
- "beforeBytes": 16718,
1005
- "afterBytes": 7089
1064
+ "beforeBytes": 16931,
1065
+ "afterBytes": 7217
1006
1066
  },
1007
1067
  {
1008
1068
  "file": "src/upgrade/scheduler.js",
1009
- "beforeBytes": 7326,
1010
- "afterBytes": 4169
1069
+ "beforeBytes": 7508,
1070
+ "afterBytes": 4246
1011
1071
  },
1012
1072
  {
1013
1073
  "file": "src/upgrade/updater-bootstrap.js",
@@ -1016,8 +1076,8 @@
1016
1076
  },
1017
1077
  {
1018
1078
  "file": "src/upgrade/updater-launcher.js",
1019
- "beforeBytes": 10317,
1020
- "afterBytes": 5253
1079
+ "beforeBytes": 10418,
1080
+ "afterBytes": 5326
1021
1081
  },
1022
1082
  {
1023
1083
  "file": "src/upgrade/updater-protocol.js",
@@ -1,8 +1,8 @@
1
- import O from"node:os";import E 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 T}from"./windows-shell.js";const N="__SHENNIAN_AGENT_ENV_START__",d="__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"],v=["NO_COLOR","PI_CODING_AGENT_DIR"],f=["SHENNIAN_MANAGED_ROOM_CONTEXT","SHENNIAN_MANAGED_ROOM_IPC_ROOT"],P=["SHENNIAN_MANAGER_SESSION_ID","SHENNIAN_MANAGER_AGENT_SESSION_ID","SHENNIAN_MANAGER_WORKDIR","SHENNIAN_MANAGER_MODEL","SHENNIAN_MANAGER_IPC_URL","SHENNIAN_MANAGER_IPC_TOKEN"],R={codex:["OPENAI_BASE_URL","OPENAI_API_KEY"],claude:["ANTHROPIC_BASE_URL","ANTHROPIC_API_KEY"],pi:["DASHSCOPE_BASE_URL","DASHSCOPE_API_KEY"]};function h(e){return R[e]??[]}function w(e){return e==="codex"||e==="claude"||e==="pi-coding-agent"?[...f,...P]:f}function j(e=process.platform){return["PATH",...e==="win32"?m:S,...v]}function _(e){return`'${e.replace(/'/g,"'\\''")}'`}function I(e){const n=e.indexOf(N),o=e.indexOf(d,n+N.length);if(n===-1||o===-1)return null;const t=e.slice(n+N.length,o);try{const s=JSON.parse(t),i={};for(const[c,r]of Object.entries(s))typeof r=="string"&&(i[c]=r);return i}catch{return null}}function G(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${_(N)}`,`${_(process.execPath)} -e ${_("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${_(d)}`].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"?I(t.stdout):null;if(s)return s}return null}function M(){const e=`
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 '${N}'
5
+ Write-Output '${_}'
6
6
  $envs | ConvertTo-Json -Compress
7
- Write-Output '${d}'
8
- `,n=p(T(),["-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"?I(n.stdout):null}function D(){return(O.platform()==="win32"?M():G())??{}}function y(e){const n={...e.daemonEnv,...e.userEnv,...e.extra};return process.platform==="win32"&&Object.assign(n,A(n)),n.PATH=L(e.daemonEnv,e.userEnv,e.extra,n),delete n.Path,delete n.path,n}function H(e={}){const n=y({daemonEnv:process.env,userEnv:D(),extra:e});return delete n.SHENNIAN_SCHEDULE_CONTEXT,n}function $(e={}){const n=H(e),o=new Set([...f,...P]);for(const t of Object.keys(n))t.startsWith("SHENNIAN_")&&!o.has(t)&&delete n[t];return n}function U(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,h(e.agentType),o),l(t,e.sessionEnv,w(e.agentType),o),l(t,e.runtimeEnv,v,o),o==="win32"&&Object.assign(t,A({...n,...t})),t.PATH=C(n,t,o),delete t.Path,delete t.path,t}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(([a])=>a.toUpperCase()===i.toUpperCase()):s.find(([a])=>a===i))?.[1];typeof r=="string"&&r.length>0&&(e[i]=r)}}function C(e,n,o){const t=o==="win32"?E.win32.delimiter:E.posix.delimiter,s=[],i=(c,r=!1)=>{if(c)for(const a of c.split(t))!a||s.includes(a)||(r?s.unshift(a):s.push(a))};if(i(u(e)),i(E.dirname(process.execPath),!0),o==="win32"){const c=A({...e,...n}),r=c.SystemRoot??c.WINDIR??"C:\\Windows";i(E.win32.join(r,"System32")),i(E.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 u(e){return e?.PATH??e?.Path??e?.path}function L(e,n,o,t){const s=[];for(const c of[u(e),u(n),u(o)])for(const r of(c??"").split(E.delimiter))r&&!s.includes(r)&&s.push(r);if(process.platform==="win32"){const c=t.SystemRoot||t.WINDIR||process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";for(const r of[E.win32.join(c,"System32"),E.win32.join(c,"System32","WindowsPowerShell","v1.0"),E.win32.join(c)])r&&!s.includes(r)&&s.push(r)}const i=E.dirname(process.execPath);return i&&!s.includes(i)&&s.unshift(i),g({pathValue:s.join(E.delimiter),env:t})}export{f as MANAGED_AGENT_SESSION_ENV_KEYS,H as buildAgentProcessEnv,U as buildManagedAgentProcessEnv,$ as buildManagedNativeFullProcessEnv,j as getManagedAgentBaseEnvKeys,h as getManagedAgentProviderEnvKeys,w as getManagedAgentSessionEnvKeys,y as mergeAgentProcessEnv,D as readLatestUserEnv};
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
- /** Keep an internal orchestration session out of the provider's user-facing task list. */
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};
@@ -0,0 +1,103 @@
1
+ import type { ChatAttachmentMeta } from '@shennian/wire';
2
+ export declare function isCodexActiveWriterError(error: unknown): boolean;
3
+ export declare function isCodexPaginatedHistoryUnsupportedError(error: unknown): boolean;
4
+ export declare function isCodexExcludeTurnsUnsupportedError(error: unknown): boolean;
5
+ export declare function isCodexProjectApiUnsupportedError(error: unknown): boolean;
6
+ export type CodexUsage = {
7
+ input_tokens?: number;
8
+ cached_input_tokens?: number;
9
+ output_tokens?: number;
10
+ prompt_tokens?: number;
11
+ completion_tokens?: number;
12
+ };
13
+ export type CodexItem = {
14
+ id?: string;
15
+ type?: string;
16
+ text?: string;
17
+ command?: string;
18
+ aggregated_output?: string;
19
+ exit_code?: number | null;
20
+ status?: string;
21
+ server?: string;
22
+ tool?: string;
23
+ arguments?: Record<string, unknown> | null;
24
+ result?: unknown;
25
+ error?: {
26
+ message?: string;
27
+ } | null;
28
+ message?: string;
29
+ query?: string;
30
+ changes?: Array<{
31
+ path: string;
32
+ kind: string;
33
+ }>;
34
+ items?: Array<{
35
+ text: string;
36
+ completed: boolean;
37
+ }>;
38
+ approval_id?: string;
39
+ approvalId?: string;
40
+ reason?: string;
41
+ title?: string;
42
+ prompt?: string;
43
+ };
44
+ export type ManagedTurnReplay = {
45
+ text: string;
46
+ modelId?: string;
47
+ reasoningEffort?: string;
48
+ attachments?: ChatAttachmentMeta[];
49
+ recoveryCount: number;
50
+ };
51
+ export type CodexStreamEvent = {
52
+ type?: string;
53
+ event?: string;
54
+ item?: CodexItem;
55
+ content?: string;
56
+ text?: string;
57
+ name?: string;
58
+ arguments?: Record<string, unknown>;
59
+ input?: Record<string, unknown>;
60
+ output?: string;
61
+ result?: string;
62
+ error?: string | {
63
+ message?: string;
64
+ };
65
+ message?: string;
66
+ reason?: string;
67
+ title?: string;
68
+ prompt?: string;
69
+ usage?: CodexUsage;
70
+ };
71
+ export type JsonRpcMessage = {
72
+ id?: number | string;
73
+ method?: string;
74
+ params?: Record<string, unknown>;
75
+ result?: unknown;
76
+ error?: {
77
+ message?: string;
78
+ code?: number;
79
+ };
80
+ };
81
+ export type CodexThreadStatus = {
82
+ type?: string;
83
+ activeFlags?: string[];
84
+ };
85
+ export type PendingRequest = {
86
+ resolve: (value: unknown) => void;
87
+ reject: (error: Error) => void;
88
+ timer: NodeJS.Timeout;
89
+ };
90
+ export type CodexProject = {
91
+ id?: string;
92
+ roots?: Array<{
93
+ path?: string;
94
+ }>;
95
+ };
96
+ export type CodexProjectListResponse = {
97
+ data?: CodexProject[];
98
+ nextCursor?: string | null;
99
+ };
100
+ export declare function selectCodexProjectIdForWorkDir(projects: CodexProject[], workDir: string): string | undefined;
101
+ export declare function buildCodexTextInput(text: string, attachments?: ChatAttachmentMeta[]): Record<string, unknown>;
102
+ export declare function buildCodexQueuedText(text: string, attachments?: ChatAttachmentMeta[]): string;
103
+ export declare function buildCodexQueueArgs(threadId: string, text: string, attachments?: ChatAttachmentMeta[]): string[];
@@ -0,0 +1,3 @@
1
+ import{spawnSync as c}from"node:child_process";import u from"node:path";function v(e){const t=e instanceof Error?e.message:String(e);return/already has an active writer|thread-store conflict/i.test(t)}function y(e){const t=e instanceof Error?e.message:String(e);return/paginated(?:_threads|\s+(?:thread\s+)?history)?.*(?:not supported|unsupported|unavailable)/i.test(t)||/(?:not supported|unsupported|unavailable).*paginated(?:_threads|\s+(?:thread\s+)?history)?/i.test(t)}function b(e){const t=e instanceof Error?e.message:String(e);return/unknown field [`'"]?excludeTurns/i.test(t)||/excludeTurns.*(?:not supported|unsupported|unavailable)/i.test(t)}function $(e){const t=e instanceof Error?e.message:String(e);return/(?:method not found|unknown method).*(?:project\/list|project\/create)/i.test(t)||/(?:project\/list|project\/create).*(?:not supported|unsupported|unavailable)/i.test(t)}function k(e,t){const i=u.resolve(t);let s;for(const n of e)if(n.id)for(const r of n.roots??[]){if(!r.path)continue;const o=u.resolve(r.path),p=u.relative(o,i);!(p===""||!p.startsWith("..")&&!u.isAbsolute(p))||o.length<=(s?.rootLength??-1)||(s={id:n.id,rootLength:o.length})}return s?.id}function w(e,t){const i=t?.flatMap(n=>d(n)).filter(n=>!/^https?:\/\//i.test(n.path)).filter(n=>n.path);return{type:"text",text:g(e,t),text_elements:[],...i?.length?{local_images:i}:{}}}function d(e){if(e.kind==="image")return e.previewData?[{path:e.path,data:e.previewData,mimeType:e.mimeType}]:[{path:e.path}];if(e.mimeType.startsWith("video/")){const t=f(e.path);return t?[{path:t}]:[]}return[]}function f(e){if(!e||/^https?:\/\//i.test(e))return null;const t=u.extname(e),s=`${t?e.slice(0,-t.length):e}.preview.png`;return c("ffmpeg",["-y","-ss","0","-i",e,"-frames:v","1","-vf","scale=320:-1",s],{stdio:"ignore",timeout:15e3}).status===0?s:null}function g(e,t){const i=t?.filter(r=>r.kind!=="image").filter(r=>r.path&&!/^https?:\/\//i.test(r.path));if(!i?.length||i.every(r=>e.includes(r.path)))return e;const n=i.map((r,o)=>{const p=r.name||`attachment-${o+1}`,a=r.mimeType?` (${r.mimeType})`:"";return`[${l(p)}${a}](<${r.path}>)`});return[e,"",...n].join(`
2
+ `)}function m(e,t){const i=t?.filter(n=>n.path&&!/^https?:\/\//i.test(n.path)&&!e.includes(n.path));if(!i?.length)return e;const s=i.map((n,r)=>{const o=l(n.name||`attachment-${r+1}`);return n.kind==="image"?`![${o}](<${n.path}>)`:`[${o}](<${n.path}>)`});return[e,"",...s].join(`
3
+ `)}function T(e,t,i){return["queue","--thread",e,"--message",m(t,i)]}function l(e){return e.replace(/[[\]\\]/g,"\\$&")}export{T as buildCodexQueueArgs,m as buildCodexQueuedText,w as buildCodexTextInput,v as isCodexActiveWriterError,b as isCodexExcludeTurnsUnsupportedError,y as isCodexPaginatedHistoryUnsupportedError,$ as isCodexProjectApiUnsupportedError,k as selectCodexProjectIdForWorkDir};