shennian 0.4.69 → 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 (88) hide show
  1. package/dist/publish-build-manifest.json +125 -70
  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/opencode.d.ts +4 -0
  17. package/dist/src/agents/opencode.js +1 -1
  18. package/dist/src/commands/agent-readiness.d.ts +17 -0
  19. package/dist/src/commands/agent-readiness.js +2 -0
  20. package/dist/src/commands/agent.js +2 -2
  21. package/dist/src/commands/daemon-instance-lock.js +1 -1
  22. package/dist/src/commands/daemon-process.d.ts +1 -0
  23. package/dist/src/commands/daemon-process.js +1 -1
  24. package/dist/src/commands/daemon-service-spec.d.ts +28 -0
  25. package/dist/src/commands/daemon-service-spec.js +1 -0
  26. package/dist/src/commands/daemon-start-wait.d.ts +1 -1
  27. package/dist/src/commands/daemon-start-wait.js +1 -1
  28. package/dist/src/commands/daemon-state.d.ts +57 -0
  29. package/dist/src/commands/daemon-state.js +1 -0
  30. package/dist/src/commands/daemon-windows.d.ts +8 -0
  31. package/dist/src/commands/daemon-windows.js +10 -10
  32. package/dist/src/commands/daemon.d.ts +4 -64
  33. package/dist/src/commands/daemon.js +13 -13
  34. package/dist/src/commands/upgrade.js +1 -1
  35. package/dist/src/daemon-ipc/agent-readiness.d.ts +14 -0
  36. package/dist/src/daemon-ipc/agent-readiness.js +1 -0
  37. package/dist/src/daemon-ipc/control.d.ts +1 -1
  38. package/dist/src/daemon-ipc/control.js +1 -1
  39. package/dist/src/index.js +3 -3
  40. package/dist/src/native-fusion/local-repository.d.ts +6 -1
  41. package/dist/src/native-fusion/local-repository.js +2 -2
  42. package/dist/src/native-fusion/service.d.ts +2 -0
  43. package/dist/src/native-fusion/service.js +2 -2
  44. package/dist/src/native-fusion/source-visibility-audit.d.ts +16 -0
  45. package/dist/src/native-fusion/source-visibility-audit.js +1 -0
  46. package/dist/src/native-fusion/source-visibility.d.ts +25 -0
  47. package/dist/src/native-fusion/source-visibility.js +1 -0
  48. package/dist/src/native-fusion/state.d.ts +1 -0
  49. package/dist/src/native-fusion/state.js +2 -2
  50. package/dist/src/native-fusion/types.d.ts +5 -0
  51. package/dist/src/room/managed-room-binding.d.ts +2 -0
  52. package/dist/src/room/managed-room-binding.js +1 -1
  53. package/dist/src/room/room-binding-client.d.ts +1 -0
  54. package/dist/src/room/room-binding-client.js +1 -1
  55. package/dist/src/runtime-distribution.d.ts +13 -0
  56. package/dist/src/runtime-distribution.js +1 -0
  57. package/dist/src/security/managed-agent-policy.d.ts +7 -0
  58. package/dist/src/security/managed-agent-policy.js +1 -1
  59. package/dist/src/session/handlers/agent-workspace-validation.d.ts +1 -0
  60. package/dist/src/session/handlers/agent-workspace-validation.js +1 -1
  61. package/dist/src/session/handlers/agents.d.ts +7 -1
  62. package/dist/src/session/handlers/agents.js +1 -1
  63. package/dist/src/session/handlers/chat-context.d.ts +31 -0
  64. package/dist/src/session/handlers/chat-context.js +1 -0
  65. package/dist/src/session/handlers/chat-events.d.ts +1 -1
  66. package/dist/src/session/handlers/chat-events.js +2 -2
  67. package/dist/src/session/handlers/chat-session-lifecycle.d.ts +2 -2
  68. package/dist/src/session/handlers/chat-session-lifecycle.js +1 -1
  69. package/dist/src/session/handlers/chat.d.ts +3 -29
  70. package/dist/src/session/handlers/chat.js +1 -1
  71. package/dist/src/session/manager.js +2 -2
  72. package/dist/src/session/queue-helpers.js +2 -2
  73. package/dist/src/session/queue-message.d.ts +2 -0
  74. package/dist/src/session/queue.d.ts +7 -1
  75. package/dist/src/session/queue.js +1 -1
  76. package/dist/src/session/queued-chat-dispatch.d.ts +4 -1
  77. package/dist/src/session/queued-chat-dispatch.js +1 -1
  78. package/dist/src/session/store.d.ts +4 -2
  79. package/dist/src/session/store.js +2 -2
  80. package/dist/src/session/types.d.ts +1 -0
  81. package/dist/src/upgrade/engine.js +2 -2
  82. package/dist/src/upgrade/scheduler.js +1 -1
  83. package/dist/src/upgrade/updater-launcher.js +3 -3
  84. package/node_modules/@shennian/wire/dist/room.d.ts +2 -0
  85. package/node_modules/@shennian/wire/dist/session-sync.d.ts +2 -1
  86. package/node_modules/@shennian/wire/dist/session.d.ts +19 -1
  87. package/node_modules/@shennian/wire/dist/session.js +8 -0
  88. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "jsMinified": true,
4
4
  "minifier": "esbuild",
5
- "fileCount": 208,
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,8 +191,8 @@
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",
@@ -236,8 +251,8 @@
236
251
  },
237
252
  {
238
253
  "file": "src/agents/opencode.js",
239
- "beforeBytes": 12131,
240
- "afterBytes": 6608
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": 3425,
310
+ "afterBytes": 2819
311
+ },
292
312
  {
293
313
  "file": "src/commands/agent.js",
294
- "beforeBytes": 5136,
295
- "afterBytes": 2826
314
+ "beforeBytes": 5283,
315
+ "afterBytes": 2934
296
316
  },
297
317
  {
298
318
  "file": "src/commands/daemon-instance-lock.js",
299
- "beforeBytes": 3665,
300
- "afterBytes": 1250
319
+ "beforeBytes": 4507,
320
+ "afterBytes": 1811
301
321
  },
302
322
  {
303
323
  "file": "src/commands/daemon-process.js",
304
- "beforeBytes": 5335,
305
- "afterBytes": 2995
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": 1013,
310
- "afterBytes": 422
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": 4512,
315
- "afterBytes": 3389
344
+ "beforeBytes": 5732,
345
+ "afterBytes": 4027
316
346
  },
317
347
  {
318
348
  "file": "src/commands/daemon.js",
319
- "beforeBytes": 45807,
320
- "afterBytes": 21994
349
+ "beforeBytes": 34161,
350
+ "afterBytes": 17352
321
351
  },
322
352
  {
323
353
  "file": "src/commands/integration.js",
@@ -376,14 +406,19 @@
376
406
  },
377
407
  {
378
408
  "file": "src/commands/upgrade.js",
379
- "beforeBytes": 13052,
380
- "afterBytes": 6572
409
+ "beforeBytes": 13446,
410
+ "afterBytes": 6795
381
411
  },
382
412
  {
383
413
  "file": "src/config/index.js",
384
414
  "beforeBytes": 2801,
385
415
  "afterBytes": 1662
386
416
  },
417
+ {
418
+ "file": "src/daemon-ipc/agent-readiness.js",
419
+ "beforeBytes": 2884,
420
+ "afterBytes": 1555
421
+ },
387
422
  {
388
423
  "file": "src/daemon-ipc/client.js",
389
424
  "beforeBytes": 2786,
@@ -391,8 +426,8 @@
391
426
  },
392
427
  {
393
428
  "file": "src/daemon-ipc/control.js",
394
- "beforeBytes": 3975,
395
- "afterBytes": 2196
429
+ "beforeBytes": 4016,
430
+ "afterBytes": 2227
396
431
  },
397
432
  {
398
433
  "file": "src/daemon-ipc/json.js",
@@ -451,8 +486,8 @@
451
486
  },
452
487
  {
453
488
  "file": "src/index.js",
454
- "beforeBytes": 39165,
455
- "afterBytes": 19567
489
+ "beforeBytes": 40923,
490
+ "afterBytes": 20430
456
491
  },
457
492
  {
458
493
  "file": "src/log-redaction.js",
@@ -526,8 +561,8 @@
526
561
  },
527
562
  {
528
563
  "file": "src/native-fusion/local-repository.js",
529
- "beforeBytes": 26330,
530
- "afterBytes": 12881
564
+ "beforeBytes": 27323,
565
+ "afterBytes": 13527
531
566
  },
532
567
  {
533
568
  "file": "src/native-fusion/native-source-deletions.js",
@@ -551,18 +586,28 @@
551
586
  },
552
587
  {
553
588
  "file": "src/native-fusion/service.js",
554
- "beforeBytes": 37567,
555
- "afterBytes": 16892
589
+ "beforeBytes": 39178,
590
+ "afterBytes": 17772
556
591
  },
557
592
  {
558
593
  "file": "src/native-fusion/session-header.js",
559
594
  "beforeBytes": 4294,
560
595
  "afterBytes": 1996
561
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
+ },
562
607
  {
563
608
  "file": "src/native-fusion/state.js",
564
- "beforeBytes": 4401,
565
- "afterBytes": 2293
609
+ "beforeBytes": 5715,
610
+ "afterBytes": 3080
566
611
  },
567
612
  {
568
613
  "file": "src/native-fusion/types.js",
@@ -661,8 +706,8 @@
661
706
  },
662
707
  {
663
708
  "file": "src/room/managed-room-binding.js",
664
- "beforeBytes": 6573,
665
- "afterBytes": 3483
709
+ "beforeBytes": 6625,
710
+ "afterBytes": 3516
666
711
  },
667
712
  {
668
713
  "file": "src/room/managed-room-ipc.js",
@@ -701,14 +746,19 @@
701
746
  },
702
747
  {
703
748
  "file": "src/room/room-binding-client.js",
704
- "beforeBytes": 6903,
705
- "afterBytes": 3961
749
+ "beforeBytes": 7086,
750
+ "afterBytes": 4075
706
751
  },
707
752
  {
708
753
  "file": "src/room/session-registry.js",
709
754
  "beforeBytes": 30575,
710
755
  "afterBytes": 17164
711
756
  },
757
+ {
758
+ "file": "src/runtime-distribution.js",
759
+ "beforeBytes": 2844,
760
+ "afterBytes": 1540
761
+ },
712
762
  {
713
763
  "file": "src/schedules/personal-context.js",
714
764
  "beforeBytes": 901,
@@ -731,8 +781,8 @@
731
781
  },
732
782
  {
733
783
  "file": "src/security/managed-agent-policy.js",
734
- "beforeBytes": 7408,
735
- "afterBytes": 3542
784
+ "beforeBytes": 7465,
785
+ "afterBytes": 3578
736
786
  },
737
787
  {
738
788
  "file": "src/security/managed-agent-runtime.js",
@@ -786,23 +836,28 @@
786
836
  },
787
837
  {
788
838
  "file": "src/session/handlers/agent-workspace-validation.js",
789
- "beforeBytes": 9051,
790
- "afterBytes": 4712
839
+ "beforeBytes": 9962,
840
+ "afterBytes": 5313
791
841
  },
792
842
  {
793
843
  "file": "src/session/handlers/agents.js",
794
- "beforeBytes": 2274,
795
- "afterBytes": 1134
844
+ "beforeBytes": 2481,
845
+ "afterBytes": 1211
796
846
  },
797
847
  {
798
848
  "file": "src/session/handlers/chat-adapter-config.js",
799
849
  "beforeBytes": 2814,
800
850
  "afterBytes": 1159
801
851
  },
852
+ {
853
+ "file": "src/session/handlers/chat-context.js",
854
+ "beforeBytes": 3243,
855
+ "afterBytes": 1986
856
+ },
802
857
  {
803
858
  "file": "src/session/handlers/chat-events.js",
804
- "beforeBytes": 15468,
805
- "afterBytes": 6683
859
+ "beforeBytes": 15787,
860
+ "afterBytes": 6851
806
861
  },
807
862
  {
808
863
  "file": "src/session/handlers/chat-recovery.js",
@@ -811,13 +866,13 @@
811
866
  },
812
867
  {
813
868
  "file": "src/session/handlers/chat-session-lifecycle.js",
814
- "beforeBytes": 3728,
815
- "afterBytes": 1723
869
+ "beforeBytes": 4467,
870
+ "afterBytes": 2119
816
871
  },
817
872
  {
818
873
  "file": "src/session/handlers/chat.js",
819
- "beforeBytes": 35331,
820
- "afterBytes": 15258
874
+ "beforeBytes": 33039,
875
+ "afterBytes": 13936
821
876
  },
822
877
  {
823
878
  "file": "src/session/handlers/control.js",
@@ -891,8 +946,8 @@
891
946
  },
892
947
  {
893
948
  "file": "src/session/manager.js",
894
- "beforeBytes": 42657,
895
- "afterBytes": 22491
949
+ "beforeBytes": 42836,
950
+ "afterBytes": 22584
896
951
  },
897
952
  {
898
953
  "file": "src/session/native-cleanup-outbox.js",
@@ -916,8 +971,8 @@
916
971
  },
917
972
  {
918
973
  "file": "src/session/queue-helpers.js",
919
- "beforeBytes": 8522,
920
- "afterBytes": 4242
974
+ "beforeBytes": 8579,
975
+ "afterBytes": 4271
921
976
  },
922
977
  {
923
978
  "file": "src/session/queue-message.js",
@@ -941,13 +996,13 @@
941
996
  },
942
997
  {
943
998
  "file": "src/session/queue.js",
944
- "beforeBytes": 44695,
945
- "afterBytes": 19911
999
+ "beforeBytes": 49532,
1000
+ "afterBytes": 21739
946
1001
  },
947
1002
  {
948
1003
  "file": "src/session/queued-chat-dispatch.js",
949
- "beforeBytes": 3024,
950
- "afterBytes": 1703
1004
+ "beforeBytes": 3176,
1005
+ "afterBytes": 1809
951
1006
  },
952
1007
  {
953
1008
  "file": "src/session/run-recovery/barrier.js",
@@ -971,8 +1026,8 @@
971
1026
  },
972
1027
  {
973
1028
  "file": "src/session/store.js",
974
- "beforeBytes": 32176,
975
- "afterBytes": 16319
1029
+ "beforeBytes": 32798,
1030
+ "afterBytes": 16719
976
1031
  },
977
1032
  {
978
1033
  "file": "src/session/tool-detail-store.js",
@@ -1006,13 +1061,13 @@
1006
1061
  },
1007
1062
  {
1008
1063
  "file": "src/upgrade/engine.js",
1009
- "beforeBytes": 16718,
1010
- "afterBytes": 7089
1064
+ "beforeBytes": 16931,
1065
+ "afterBytes": 7217
1011
1066
  },
1012
1067
  {
1013
1068
  "file": "src/upgrade/scheduler.js",
1014
- "beforeBytes": 7326,
1015
- "afterBytes": 4169
1069
+ "beforeBytes": 7508,
1070
+ "afterBytes": 4246
1016
1071
  },
1017
1072
  {
1018
1073
  "file": "src/upgrade/updater-bootstrap.js",
@@ -1021,8 +1076,8 @@
1021
1076
  },
1022
1077
  {
1023
1078
  "file": "src/upgrade/updater-launcher.js",
1024
- "beforeBytes": 10317,
1025
- "afterBytes": 5253
1079
+ "beforeBytes": 10418,
1080
+ "afterBytes": 5326
1026
1081
  },
1027
1082
  {
1028
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};