shennian 0.4.0 → 0.4.2

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 (61) hide show
  1. package/dist/native/macos-background-client/Shennian.app/Contents/CodeResources +0 -0
  2. package/dist/native/macos-background-client/Shennian.app/Contents/Info.plist +17 -0
  3. package/dist/native/macos-background-client/Shennian.app/Contents/MacOS/ShennianClientLauncher +0 -0
  4. package/dist/native/macos-background-client/Shennian.app/Contents/Resources/en.lproj/InfoPlist.strings +2 -0
  5. package/dist/native/macos-background-client/Shennian.app/Contents/Resources/zh-Hans.lproj/InfoPlist.strings +2 -0
  6. package/dist/native/macos-background-client/Shennian.app/Contents/_CodeSignature/CodeResources +153 -0
  7. package/dist/publish-build-manifest.json +78 -43
  8. package/dist/src/agent-env.d.ts +1 -0
  9. package/dist/src/agent-env.js +4 -4
  10. package/dist/src/agents/codex.d.ts +3 -2
  11. package/dist/src/agents/codex.js +8 -8
  12. package/dist/src/agents/command-spec.js +1 -1
  13. package/dist/src/agents/config-status.js +1 -1
  14. package/dist/src/agents/detect.d.ts +1 -0
  15. package/dist/src/agents/detect.js +1 -1
  16. package/dist/src/agents/manager.d.ts +3 -3
  17. package/dist/src/agents/manager.js +9 -9
  18. package/dist/src/agents/model-registry/cache.d.ts +1 -1
  19. package/dist/src/agents/model-registry/cache.js +1 -1
  20. package/dist/src/agents/model-registry/discovery.js +3 -2
  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/model-registry/types.d.ts +1 -0
  24. package/dist/src/agents/pi-coding-agent-managed-permissions.d.ts +7 -0
  25. package/dist/src/agents/pi-coding-agent-managed-permissions.js +1 -0
  26. package/dist/src/agents/pi-coding-agent.d.ts +55 -0
  27. package/dist/src/agents/pi-coding-agent.js +4 -0
  28. package/dist/src/agents/pi-managed-extension.d.ts +12 -0
  29. package/dist/src/agents/pi-managed-extension.js +89 -0
  30. package/dist/src/agents/pi-managed-model-broker.d.ts +27 -0
  31. package/dist/src/agents/pi-managed-model-broker.js +1 -0
  32. package/dist/src/agents/pi-rpc-client.d.ts +31 -0
  33. package/dist/src/agents/pi-rpc-client.js +3 -0
  34. package/dist/src/agents/pi-session-ownership.d.ts +2 -0
  35. package/dist/src/agents/pi-session-ownership.js +2 -0
  36. package/dist/src/commands/daemon.d.ts +4 -0
  37. package/dist/src/commands/daemon.js +21 -17
  38. package/dist/src/commands/pair-browser.js +1 -1
  39. package/dist/src/manager/prompt.d.ts +1 -1
  40. package/dist/src/manager/prompt.js +2 -2
  41. package/dist/src/manager/registry.d.ts +4 -4
  42. package/dist/src/manager/runtime.d.ts +3 -3
  43. package/dist/src/room/activation-service.js +4 -4
  44. package/dist/src/room/device-authorization-client.d.ts +2 -0
  45. package/dist/src/room/managed-prompt-composer.d.ts +1 -1
  46. package/dist/src/room/managed-prompt-composer.js +2 -1
  47. package/dist/src/security/managed-agent-policy.js +1 -1
  48. package/dist/src/session/handlers/agent-workspace-validation.d.ts +24 -0
  49. package/dist/src/session/handlers/agent-workspace-validation.js +1 -0
  50. package/dist/src/session/handlers/chat.js +1 -1
  51. package/dist/src/session/manager.d.ts +1 -0
  52. package/dist/src/session/manager.js +1 -1
  53. package/dist/src/session/native-session-lifecycle.js +6 -6
  54. package/dist/src/session/queue.d.ts +5 -1
  55. package/dist/src/session/queue.js +2 -2
  56. package/dist/src/upgrade/engine.d.ts +1 -0
  57. package/dist/src/upgrade/engine.js +2 -2
  58. package/node_modules/@shennian/wire/dist/methods.d.ts +1 -1
  59. package/node_modules/@shennian/wire/dist/session.d.ts +2 -2
  60. package/node_modules/@shennian/wire/dist/session.js +1 -0
  61. package/package.json +3 -3
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key><string>en</string>
6
+ <key>CFBundleDisplayName</key><string>Shennian</string>
7
+ <key>CFBundleExecutable</key><string>ShennianClientLauncher</string>
8
+ <key>CFBundleIdentifier</key><string>net.shennian.client.background-service</string>
9
+ <key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
10
+ <key>CFBundleName</key><string>Shennian</string>
11
+ <key>CFBundlePackageType</key><string>APPL</string>
12
+ <key>CFBundleShortVersionString</key><string>1.0.0</string>
13
+ <key>CFBundleVersion</key><string>1.0.0</string>
14
+ <key>LSBackgroundOnly</key><true/>
15
+ <key>LSMinimumSystemVersion</key><string>13.0</string>
16
+ </dict>
17
+ </plist>
@@ -0,0 +1,2 @@
1
+ "CFBundleDisplayName" = "Shennian";
2
+ "CFBundleName" = "Shennian";
@@ -0,0 +1,2 @@
1
+ "CFBundleDisplayName" = "神念";
2
+ "CFBundleName" = "神念";
@@ -0,0 +1,153 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict>
7
+ <key>Resources/en.lproj/InfoPlist.strings</key>
8
+ <dict>
9
+ <key>hash</key>
10
+ <data>
11
+ 7cZ/3Y+z3FLOqySef5/rGgdk+hU=
12
+ </data>
13
+ <key>optional</key>
14
+ <true/>
15
+ </dict>
16
+ <key>Resources/zh-Hans.lproj/InfoPlist.strings</key>
17
+ <dict>
18
+ <key>hash</key>
19
+ <data>
20
+ 6MKN0tNN2Z8t8wIkKiANNKgscLY=
21
+ </data>
22
+ <key>optional</key>
23
+ <true/>
24
+ </dict>
25
+ </dict>
26
+ <key>files2</key>
27
+ <dict>
28
+ <key>Resources/en.lproj/InfoPlist.strings</key>
29
+ <dict>
30
+ <key>hash2</key>
31
+ <data>
32
+ FJaLoD8f3R/s4Tvbgbvcrb9uzFLfPBACRdeL+bpiUtw=
33
+ </data>
34
+ <key>optional</key>
35
+ <true/>
36
+ </dict>
37
+ <key>Resources/zh-Hans.lproj/InfoPlist.strings</key>
38
+ <dict>
39
+ <key>hash2</key>
40
+ <data>
41
+ B/tCw00PlOTxARULQMz6SavBh8IU6/M0b8GXT253tC0=
42
+ </data>
43
+ <key>optional</key>
44
+ <true/>
45
+ </dict>
46
+ </dict>
47
+ <key>rules</key>
48
+ <dict>
49
+ <key>^Resources/</key>
50
+ <true/>
51
+ <key>^Resources/.*\.lproj/</key>
52
+ <dict>
53
+ <key>optional</key>
54
+ <true/>
55
+ <key>weight</key>
56
+ <real>1000</real>
57
+ </dict>
58
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
59
+ <dict>
60
+ <key>omit</key>
61
+ <true/>
62
+ <key>weight</key>
63
+ <real>1100</real>
64
+ </dict>
65
+ <key>^Resources/Base\.lproj/</key>
66
+ <dict>
67
+ <key>weight</key>
68
+ <real>1010</real>
69
+ </dict>
70
+ <key>^version.plist$</key>
71
+ <true/>
72
+ </dict>
73
+ <key>rules2</key>
74
+ <dict>
75
+ <key>.*\.dSYM($|/)</key>
76
+ <dict>
77
+ <key>weight</key>
78
+ <real>11</real>
79
+ </dict>
80
+ <key>^(.*/)?\.DS_Store$</key>
81
+ <dict>
82
+ <key>omit</key>
83
+ <true/>
84
+ <key>weight</key>
85
+ <real>2000</real>
86
+ </dict>
87
+ <key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
88
+ <dict>
89
+ <key>nested</key>
90
+ <true/>
91
+ <key>weight</key>
92
+ <real>10</real>
93
+ </dict>
94
+ <key>^.*</key>
95
+ <true/>
96
+ <key>^Info\.plist$</key>
97
+ <dict>
98
+ <key>omit</key>
99
+ <true/>
100
+ <key>weight</key>
101
+ <real>20</real>
102
+ </dict>
103
+ <key>^PkgInfo$</key>
104
+ <dict>
105
+ <key>omit</key>
106
+ <true/>
107
+ <key>weight</key>
108
+ <real>20</real>
109
+ </dict>
110
+ <key>^Resources/</key>
111
+ <dict>
112
+ <key>weight</key>
113
+ <real>20</real>
114
+ </dict>
115
+ <key>^Resources/.*\.lproj/</key>
116
+ <dict>
117
+ <key>optional</key>
118
+ <true/>
119
+ <key>weight</key>
120
+ <real>1000</real>
121
+ </dict>
122
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
123
+ <dict>
124
+ <key>omit</key>
125
+ <true/>
126
+ <key>weight</key>
127
+ <real>1100</real>
128
+ </dict>
129
+ <key>^Resources/Base\.lproj/</key>
130
+ <dict>
131
+ <key>weight</key>
132
+ <real>1010</real>
133
+ </dict>
134
+ <key>^[^/]+$</key>
135
+ <dict>
136
+ <key>nested</key>
137
+ <true/>
138
+ <key>weight</key>
139
+ <real>10</real>
140
+ </dict>
141
+ <key>^embedded\.provisionprofile$</key>
142
+ <dict>
143
+ <key>weight</key>
144
+ <real>20</real>
145
+ </dict>
146
+ <key>^version\.plist$</key>
147
+ <dict>
148
+ <key>weight</key>
149
+ <real>20</real>
150
+ </dict>
151
+ </dict>
152
+ </dict>
153
+ </plist>
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "jsMinified": true,
4
4
  "minifier": "esbuild",
5
- "fileCount": 145,
5
+ "fileCount": 152,
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": 9273,
15
- "afterBytes": 4197
14
+ "beforeBytes": 9854,
15
+ "afterBytes": 4529
16
16
  },
17
17
  {
18
18
  "file": "src/agents/adapter.js",
@@ -46,18 +46,18 @@
46
46
  },
47
47
  {
48
48
  "file": "src/agents/codex.js",
49
- "beforeBytes": 64672,
50
- "afterBytes": 33374
49
+ "beforeBytes": 64856,
50
+ "afterBytes": 33479
51
51
  },
52
52
  {
53
53
  "file": "src/agents/command-spec.js",
54
- "beforeBytes": 17437,
55
- "afterBytes": 7807
54
+ "beforeBytes": 17521,
55
+ "afterBytes": 7863
56
56
  },
57
57
  {
58
58
  "file": "src/agents/config-status.js",
59
- "beforeBytes": 7583,
60
- "afterBytes": 3900
59
+ "beforeBytes": 7976,
60
+ "afterBytes": 4126
61
61
  },
62
62
  {
63
63
  "file": "src/agents/cursor-managed-permissions.js",
@@ -81,8 +81,8 @@
81
81
  },
82
82
  {
83
83
  "file": "src/agents/detect.js",
84
- "beforeBytes": 2358,
85
- "afterBytes": 1204
84
+ "beforeBytes": 3055,
85
+ "afterBytes": 1544
86
86
  },
87
87
  {
88
88
  "file": "src/agents/external-channel-instructions.js",
@@ -96,23 +96,23 @@
96
96
  },
97
97
  {
98
98
  "file": "src/agents/manager.js",
99
- "beforeBytes": 10725,
100
- "afterBytes": 5801
99
+ "beforeBytes": 10675,
100
+ "afterBytes": 5749
101
101
  },
102
102
  {
103
103
  "file": "src/agents/model-registry/cache.js",
104
- "beforeBytes": 1216,
105
- "afterBytes": 548
104
+ "beforeBytes": 1321,
105
+ "afterBytes": 575
106
106
  },
107
107
  {
108
108
  "file": "src/agents/model-registry/discovery.js",
109
- "beforeBytes": 7085,
110
- "afterBytes": 3340
109
+ "beforeBytes": 10881,
110
+ "afterBytes": 5056
111
111
  },
112
112
  {
113
113
  "file": "src/agents/model-registry/parsers.js",
114
- "beforeBytes": 19646,
115
- "afterBytes": 10067
114
+ "beforeBytes": 19925,
115
+ "afterBytes": 10288
116
116
  },
117
117
  {
118
118
  "file": "src/agents/model-registry/runner.js",
@@ -121,8 +121,8 @@
121
121
  },
122
122
  {
123
123
  "file": "src/agents/model-registry/service.js",
124
- "beforeBytes": 4344,
125
- "afterBytes": 1743
124
+ "beforeBytes": 4571,
125
+ "afterBytes": 1869
126
126
  },
127
127
  {
128
128
  "file": "src/agents/model-registry/types.js",
@@ -154,6 +154,36 @@
154
154
  "beforeBytes": 11310,
155
155
  "afterBytes": 6249
156
156
  },
157
+ {
158
+ "file": "src/agents/pi-coding-agent-managed-permissions.js",
159
+ "beforeBytes": 1534,
160
+ "afterBytes": 592
161
+ },
162
+ {
163
+ "file": "src/agents/pi-coding-agent.js",
164
+ "beforeBytes": 24240,
165
+ "afterBytes": 13052
166
+ },
167
+ {
168
+ "file": "src/agents/pi-managed-extension.js",
169
+ "beforeBytes": 8913,
170
+ "afterBytes": 8208
171
+ },
172
+ {
173
+ "file": "src/agents/pi-managed-model-broker.js",
174
+ "beforeBytes": 8338,
175
+ "afterBytes": 4484
176
+ },
177
+ {
178
+ "file": "src/agents/pi-rpc-client.js",
179
+ "beforeBytes": 5326,
180
+ "afterBytes": 2807
181
+ },
182
+ {
183
+ "file": "src/agents/pi-session-ownership.js",
184
+ "beforeBytes": 2329,
185
+ "afterBytes": 1278
186
+ },
157
187
  {
158
188
  "file": "src/agents/platform-instructions.js",
159
189
  "beforeBytes": 2829,
@@ -191,8 +221,8 @@
191
221
  },
192
222
  {
193
223
  "file": "src/commands/daemon.js",
194
- "beforeBytes": 43216,
195
- "afterBytes": 20705
224
+ "beforeBytes": 46411,
225
+ "afterBytes": 22150
196
226
  },
197
227
  {
198
228
  "file": "src/commands/integration.js",
@@ -216,8 +246,8 @@
216
246
  },
217
247
  {
218
248
  "file": "src/commands/pair-browser.js",
219
- "beforeBytes": 6655,
220
- "afterBytes": 3699
249
+ "beforeBytes": 6847,
250
+ "afterBytes": 3822
221
251
  },
222
252
  {
223
253
  "file": "src/commands/pair-qr.js",
@@ -331,8 +361,8 @@
331
361
  },
332
362
  {
333
363
  "file": "src/manager/prompt.js",
334
- "beforeBytes": 4350,
335
- "afterBytes": 7113
364
+ "beforeBytes": 4370,
365
+ "afterBytes": 7133
336
366
  },
337
367
  {
338
368
  "file": "src/manager/registry.js",
@@ -466,8 +496,8 @@
466
496
  },
467
497
  {
468
498
  "file": "src/room/activation-service.js",
469
- "beforeBytes": 21713,
470
- "afterBytes": 10792
499
+ "beforeBytes": 22403,
500
+ "afterBytes": 11182
471
501
  },
472
502
  {
473
503
  "file": "src/room/attachment-cache.js",
@@ -506,8 +536,8 @@
506
536
  },
507
537
  {
508
538
  "file": "src/room/managed-prompt-composer.js",
509
- "beforeBytes": 9264,
510
- "afterBytes": 9441
539
+ "beforeBytes": 9461,
540
+ "afterBytes": 9832
511
541
  },
512
542
  {
513
543
  "file": "src/room/managed-room-binding.js",
@@ -561,8 +591,8 @@
561
591
  },
562
592
  {
563
593
  "file": "src/security/managed-agent-policy.js",
564
- "beforeBytes": 6728,
565
- "afterBytes": 3141
594
+ "beforeBytes": 6759,
595
+ "afterBytes": 3166
566
596
  },
567
597
  {
568
598
  "file": "src/security/managed-agent-runtime.js",
@@ -604,6 +634,11 @@
604
634
  "beforeBytes": 5590,
605
635
  "afterBytes": 2803
606
636
  },
637
+ {
638
+ "file": "src/session/handlers/agent-workspace-validation.js",
639
+ "beforeBytes": 7952,
640
+ "afterBytes": 4110
641
+ },
607
642
  {
608
643
  "file": "src/session/handlers/agents.js",
609
644
  "beforeBytes": 1853,
@@ -611,8 +646,8 @@
611
646
  },
612
647
  {
613
648
  "file": "src/session/handlers/chat.js",
614
- "beforeBytes": 43645,
615
- "afterBytes": 18275
649
+ "beforeBytes": 43663,
650
+ "afterBytes": 18270
616
651
  },
617
652
  {
618
653
  "file": "src/session/handlers/control.js",
@@ -671,8 +706,8 @@
671
706
  },
672
707
  {
673
708
  "file": "src/session/manager.js",
674
- "beforeBytes": 31103,
675
- "afterBytes": 16179
709
+ "beforeBytes": 31381,
710
+ "afterBytes": 16358
676
711
  },
677
712
  {
678
713
  "file": "src/session/native-cleanup-outbox.js",
@@ -681,8 +716,8 @@
681
716
  },
682
717
  {
683
718
  "file": "src/session/native-session-lifecycle.js",
684
- "beforeBytes": 14160,
685
- "afterBytes": 6446
719
+ "beforeBytes": 14829,
720
+ "afterBytes": 6738
686
721
  },
687
722
  {
688
723
  "file": "src/session/projection.js",
@@ -691,8 +726,8 @@
691
726
  },
692
727
  {
693
728
  "file": "src/session/queue.js",
694
- "beforeBytes": 33159,
695
- "afterBytes": 14816
729
+ "beforeBytes": 33537,
730
+ "afterBytes": 14902
696
731
  },
697
732
  {
698
733
  "file": "src/session/store.js",
@@ -716,8 +751,8 @@
716
751
  },
717
752
  {
718
753
  "file": "src/upgrade/engine.js",
719
- "beforeBytes": 15579,
720
- "afterBytes": 6624
754
+ "beforeBytes": 16698,
755
+ "afterBytes": 7021
721
756
  },
722
757
  {
723
758
  "file": "src/upgrade/scheduler.js",
@@ -6,6 +6,7 @@ import type { AgentType } from '@shennian/wire';
6
6
  */
7
7
  export declare const MANAGED_AGENT_SESSION_ENV_KEYS: readonly ["SHENNIAN_MANAGED_ROOM_CONTEXT", "SHENNIAN_MANAGED_ROOM_IPC_ROOT"];
8
8
  export declare function getManagedAgentProviderEnvKeys(agentType: AgentType): readonly string[];
9
+ export declare function getManagedAgentSessionEnvKeys(agentType: AgentType): readonly string[];
9
10
  export declare function getManagedAgentBaseEnvKeys(platform?: NodeJS.Platform): readonly string[];
10
11
  export type ManagedAgentProcessEnvInput = {
11
12
  agentType: AgentType;
@@ -1,8 +1,8 @@
1
- import S from"node:os";import a from"node:path";import{spawnSync as _}from"node:child_process";import{buildAugmentedPath as g}from"./env-path.js";import{buildWindowsSystemEnv as u,resolveWindowsPowerShellPath as h}from"./windows-shell.js";const l="__SHENNIAN_AGENT_ENV_START__",A="__SHENNIAN_AGENT_ENV_END__",m=["HOME","USER","LOGNAME","LANG","LANGUAGE","LC_ALL","LC_CTYPE","TMPDIR","TMP","TEMP","TZ"],N=["SystemRoot","WINDIR","ComSpec","PATHEXT","USERPROFILE","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","TEMP","TMP","TZ"],P=["NO_COLOR"],O=["SHENNIAN_MANAGED_ROOM_CONTEXT","SHENNIAN_MANAGED_ROOM_IPC_ROOT"],T={codex:["OPENAI_BASE_URL","OPENAI_API_KEY"],claude:["ANTHROPIC_BASE_URL","ANTHROPIC_API_KEY"],pi:["DASHSCOPE_BASE_URL","DASHSCOPE_API_KEY"]};function w(e){return T[e]??[]}function V(e=process.platform){return["PATH",...e==="win32"?N:m,...P]}function p(e){return`'${e.replace(/'/g,"'\\''")}'`}function v(e){const n=e.indexOf(l),r=e.indexOf(A,n+l.length);if(n===-1||r===-1)return null;const t=e.slice(n+l.length,r);try{const o=JSON.parse(t),i={};for(const[c,s]of Object.entries(o))typeof s=="string"&&(i[c]=s);return i}catch{return null}}function R(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${p(l)}`,`${p(process.execPath)} -e ${p("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${p(A)}`].join("; ");for(const r of[["-ilc",n],["-lc",n]]){const t=_(e,r,{env:process.env,encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0}),o=typeof t.stdout=="string"?v(t.stdout):null;if(o)return o}return null}function y(){const e=`
1
+ import I from"node:os";import E from"node:path";import{spawnSync as p}from"node:child_process";import{buildAugmentedPath as O}from"./env-path.js";import{buildWindowsSystemEnv as A,resolveWindowsPowerShellPath as g}from"./windows-shell.js";const N="__SHENNIAN_AGENT_ENV_START__",f="__SHENNIAN_AGENT_ENV_END__",d=["HOME","USER","LOGNAME","LANG","LANGUAGE","LC_ALL","LC_CTYPE","TMPDIR","TMP","TEMP","TZ"],S=["SystemRoot","WINDIR","ComSpec","PATHEXT","USERPROFILE","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","TEMP","TMP","TZ"],m=["NO_COLOR","PI_CODING_AGENT_DIR"],P=["SHENNIAN_MANAGED_ROOM_CONTEXT","SHENNIAN_MANAGED_ROOM_IPC_ROOT"],R=["SHENNIAN_MANAGER_SESSION_ID","SHENNIAN_MANAGER_AGENT_SESSION_ID","SHENNIAN_MANAGER_WORKDIR","SHENNIAN_MANAGER_MODEL","SHENNIAN_MANAGER_IPC_URL","SHENNIAN_MANAGER_IPC_TOKEN"],T={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 T[e]??[]}function G(e){return e==="codex"||e==="claude"||e==="pi-coding-agent"?[...P,...R]:P}function W(e=process.platform){return["PATH",...e==="win32"?S:d,...m]}function _(e){return`'${e.replace(/'/g,"'\\''")}'`}function v(e){const n=e.indexOf(N),r=e.indexOf(f,n+N.length);if(n===-1||r===-1)return null;const t=e.slice(n+N.length,r);try{const o=JSON.parse(t),i={};for(const[c,s]of Object.entries(o))typeof s=="string"&&(i[c]=s);return i}catch{return null}}function w(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${_(N)}`,`${_(process.execPath)} -e ${_("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${_(f)}`].join("; ");for(const r of[["-ilc",n],["-lc",n]]){const t=p(e,r,{env:process.env,encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0}),o=typeof t.stdout=="string"?v(t.stdout):null;if(o)return o}return null}function M(){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 '${l}'
5
+ Write-Output '${N}'
6
6
  $envs | ConvertTo-Json -Compress
7
- Write-Output '${A}'
8
- `,n=_(h(),["-NoProfile","-Command",e],{env:{...process.env,...u(process.env)},encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0});return typeof n.stdout=="string"?v(n.stdout):null}function I(){return(S.platform()==="win32"?y():R())??{}}function G(e){const n={...e.daemonEnv,...e.userEnv,...e.extra};return process.platform==="win32"&&Object.assign(n,u(n)),n.PATH=M(e.daemonEnv,e.userEnv,e.extra,n),delete n.Path,delete n.path,n}function j(e={}){return G({daemonEnv:process.env,userEnv:I(),extra:e})}function W(e){const n=e.daemonEnv??process.env,r=e.platform??process.platform,t={};return f(t,n,r==="win32"?N:m,r),f(t,e.providerEnv,w(e.agentType),r),f(t,e.sessionEnv,O,r),f(t,e.runtimeEnv,P,r),r==="win32"&&Object.assign(t,u({...n,...t})),t.PATH=D(n,t,r),delete t.Path,delete t.path,t}function f(e,n,r,t){if(!n)return;const o=Object.entries(n);for(const i of r){const s=(t==="win32"?o.find(([E])=>E.toUpperCase()===i.toUpperCase()):o.find(([E])=>E===i))?.[1];typeof s=="string"&&s.length>0&&(e[i]=s)}}function D(e,n,r){const t=r==="win32"?a.win32.delimiter:a.posix.delimiter,o=[],i=(c,s=!1)=>{if(c)for(const E of c.split(t))!E||o.includes(E)||(s?o.unshift(E):o.push(E))};if(i(d(e)),i(a.dirname(process.execPath),!0),r==="win32"){const c=u({...e,...n}),s=c.SystemRoot??c.WINDIR??"C:\\Windows";i(a.win32.join(s,"System32")),i(a.win32.join(s,"System32","WindowsPowerShell","v1.0")),i(s)}else i("/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");return o.join(t)}function d(e){return e?.PATH??e?.Path??e?.path}function M(e,n,r,t){const o=[];for(const c of[d(e),d(n),d(r)])for(const s of(c??"").split(a.delimiter))s&&!o.includes(s)&&o.push(s);if(process.platform==="win32"){const c=t.SystemRoot||t.WINDIR||process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";for(const s of[a.win32.join(c,"System32"),a.win32.join(c,"System32","WindowsPowerShell","v1.0"),a.win32.join(c)])s&&!o.includes(s)&&o.push(s)}const i=a.dirname(process.execPath);return i&&!o.includes(i)&&o.unshift(i),g({pathValue:o.join(a.delimiter),env:t})}export{O as MANAGED_AGENT_SESSION_ENV_KEYS,j as buildAgentProcessEnv,W as buildManagedAgentProcessEnv,V as getManagedAgentBaseEnvKeys,w as getManagedAgentProviderEnvKeys,G as mergeAgentProcessEnv,I as readLatestUserEnv};
7
+ Write-Output '${f}'
8
+ `,n=p(g(),["-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"?v(n.stdout):null}function D(){return(I.platform()==="win32"?M():w())??{}}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 j(e={}){return y({daemonEnv:process.env,userEnv:D(),extra:e})}function $(e){const n=e.daemonEnv??process.env,r=e.platform??process.platform,t={};return l(t,n,r==="win32"?S:d,r),l(t,e.providerEnv,h(e.agentType),r),l(t,e.sessionEnv,G(e.agentType),r),l(t,e.runtimeEnv,m,r),r==="win32"&&Object.assign(t,A({...n,...t})),t.PATH=H(n,t,r),delete t.Path,delete t.path,t}function l(e,n,r,t){if(!n)return;const o=Object.entries(n);for(const i of r){const s=(t==="win32"?o.find(([a])=>a.toUpperCase()===i.toUpperCase()):o.find(([a])=>a===i))?.[1];typeof s=="string"&&s.length>0&&(e[i]=s)}}function H(e,n,r){const t=r==="win32"?E.win32.delimiter:E.posix.delimiter,o=[],i=(c,s=!1)=>{if(c)for(const a of c.split(t))!a||o.includes(a)||(s?o.unshift(a):o.push(a))};if(i(u(e)),i(E.dirname(process.execPath),!0),r==="win32"){const c=A({...e,...n}),s=c.SystemRoot??c.WINDIR??"C:\\Windows";i(E.win32.join(s,"System32")),i(E.win32.join(s,"System32","WindowsPowerShell","v1.0")),i(s)}else i("/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");return o.join(t)}function u(e){return e?.PATH??e?.Path??e?.path}function L(e,n,r,t){const o=[];for(const c of[u(e),u(n),u(r)])for(const s of(c??"").split(E.delimiter))s&&!o.includes(s)&&o.push(s);if(process.platform==="win32"){const c=t.SystemRoot||t.WINDIR||process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";for(const s of[E.win32.join(c,"System32"),E.win32.join(c,"System32","WindowsPowerShell","v1.0"),E.win32.join(c)])s&&!o.includes(s)&&o.push(s)}const i=E.dirname(process.execPath);return i&&!o.includes(i)&&o.unshift(i),O({pathValue:o.join(E.delimiter),env:t})}export{P as MANAGED_AGENT_SESSION_ENV_KEYS,j as buildAgentProcessEnv,$ as buildManagedAgentProcessEnv,W as getManagedAgentBaseEnvKeys,h as getManagedAgentProviderEnvKeys,G as getManagedAgentSessionEnvKeys,y as mergeAgentProcessEnv,D as readLatestUserEnv};
@@ -1,4 +1,4 @@
1
- import { AgentAdapter, type AgentSendContext, type AgentSendResult } from './adapter.js';
1
+ import { AgentAdapter, type AgentSendContext, type AgentSendResult, type AgentStartOptions } from './adapter.js';
2
2
  import { type ChatAttachmentMeta, type ExternalChannelSessionStatus } from '@shennian/wire';
3
3
  import type { SessionRunPhase } from '@shennian/wire';
4
4
  import { type CompiledManagedAgentPolicy } from '../security/managed-agent-policy.js';
@@ -49,6 +49,7 @@ export declare class CodexAdapter extends AgentAdapter {
49
49
  private preparedExternalOwnerThreadId;
50
50
  private managedTurnReplay;
51
51
  private managedAsyncRecovery;
52
+ private persistNativeSession;
52
53
  constructor(options?: {
53
54
  modelInstructionsFile?: string;
54
55
  hidden?: boolean;
@@ -67,7 +68,7 @@ export declare class CodexAdapter extends AgentAdapter {
67
68
  }): void;
68
69
  private configurationFingerprint;
69
70
  private buildProcessEnv;
70
- start(_sessionId: string, workDir: string, agentSessionId?: string | null): Promise<void>;
71
+ start(_sessionId: string, workDir: string, agentSessionId?: string | null, options?: AgentStartOptions): Promise<void>;
71
72
  prepareSend(_text: string, modelId?: string, _reasoningEffort?: string, _attachments?: ChatAttachmentMeta[], agentSystemPrompt?: string | null, context?: AgentSendContext): Promise<void>;
72
73
  send(text: string, modelId?: string, reasoningEffort?: string, attachments?: ChatAttachmentMeta[], agentSystemPrompt?: string | null, context?: AgentSendContext): Promise<void | AgentSendResult>;
73
74
  private isThreadTailInterrupted;