shennian 0.3.37 → 0.3.38

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 (214) hide show
  1. package/README.md +1 -0
  2. package/dist/publish-build-manifest.json +73 -168
  3. package/dist/src/agents/detect.js +1 -1
  4. package/dist/src/agents/manager.d.ts +36 -0
  5. package/dist/src/agents/manager.js +11 -6
  6. package/dist/src/agents/model-registry/service.js +1 -1
  7. package/dist/src/agents/workbuddy.js +2 -2
  8. package/dist/src/commands/agent.d.ts +6 -1
  9. package/dist/src/commands/agent.js +3 -6
  10. package/dist/src/commands/integration.d.ts +1 -0
  11. package/dist/src/commands/integration.js +2 -1
  12. package/dist/src/commands/manager.js +1 -1
  13. package/dist/src/commands/pair-authorization.d.ts +3 -0
  14. package/dist/src/commands/pair-authorization.js +1 -0
  15. package/dist/src/commands/pair-browser.js +1 -1
  16. package/dist/src/commands/room.d.ts +9 -17
  17. package/dist/src/commands/room.js +3 -8
  18. package/dist/src/commands/runtime.d.ts +2 -0
  19. package/dist/src/commands/runtime.js +6 -0
  20. package/dist/src/daemon-ipc/client.d.ts +1 -1
  21. package/dist/src/daemon-ipc/json.d.ts +3 -0
  22. package/dist/src/daemon-ipc/json.js +1 -0
  23. package/dist/src/daemon-ipc/protocol.d.ts +1 -1
  24. package/dist/src/daemon-ipc/server.d.ts +1 -1
  25. package/dist/src/index.js +3 -2
  26. package/dist/src/manager/registry.d.ts +21 -0
  27. package/dist/src/manager/registry.js +2 -2
  28. package/dist/src/manager/runtime.d.ts +5 -1
  29. package/dist/src/manager/runtime.js +14 -13
  30. package/dist/src/room/activation-service.d.ts +6 -0
  31. package/dist/src/room/activation-service.js +5 -8
  32. package/dist/src/room/attachment-cache.d.ts +2 -1
  33. package/dist/src/room/attachment-cache.js +2 -2
  34. package/dist/src/room/device-authorization-client.d.ts +39 -1
  35. package/dist/src/room/managed-context.d.ts +45 -0
  36. package/dist/src/room/managed-context.js +1 -0
  37. package/dist/src/room/managed-prompt-composer.d.ts +32 -0
  38. package/dist/src/room/managed-prompt-composer.js +24 -0
  39. package/dist/src/room/managed-room-ipc.d.ts +16 -0
  40. package/dist/src/room/managed-room-ipc.js +1 -0
  41. package/dist/src/room/mirror-sync-service.d.ts +2 -5
  42. package/dist/src/room/mirror-sync-service.js +1 -1
  43. package/dist/src/room/public-attachment-cache.d.ts +34 -0
  44. package/dist/src/room/public-attachment-cache.js +2 -0
  45. package/dist/src/room/public-room-client.d.ts +36 -0
  46. package/dist/src/room/public-room-client.js +1 -0
  47. package/dist/src/room/room-action-client.d.ts +3 -1
  48. package/dist/src/room/room-action-client.js +1 -1
  49. package/dist/src/room/session-registry.d.ts +7 -0
  50. package/dist/src/room/session-registry.js +2 -2
  51. package/dist/src/session/handlers/chat.d.ts +5 -1
  52. package/dist/src/session/handlers/chat.js +2 -2
  53. package/dist/src/session/manager.d.ts +1 -20
  54. package/dist/src/session/manager.js +1 -1
  55. package/dist/src/session/queue.js +3 -3
  56. package/dist/src/session/store.d.ts +9 -1
  57. package/dist/src/session/store.js +3 -3
  58. package/dist/src/session/types.d.ts +2 -1
  59. package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts +0 -1
  60. package/node_modules/@shennian/wire/dist/agent-capabilities.js +0 -1
  61. package/node_modules/@shennian/wire/dist/agent-workspace.d.ts +0 -1
  62. package/node_modules/@shennian/wire/dist/agent-workspace.js +0 -1
  63. package/node_modules/@shennian/wire/dist/envelope.d.ts +0 -1
  64. package/node_modules/@shennian/wire/dist/envelope.js +0 -1
  65. package/node_modules/@shennian/wire/dist/events.d.ts +0 -1
  66. package/node_modules/@shennian/wire/dist/events.js +0 -1
  67. package/node_modules/@shennian/wire/dist/external-message-format.d.ts +0 -1
  68. package/node_modules/@shennian/wire/dist/external-message-format.js +0 -1
  69. package/node_modules/@shennian/wire/dist/frames.d.ts +0 -1
  70. package/node_modules/@shennian/wire/dist/frames.js +0 -1
  71. package/node_modules/@shennian/wire/dist/fs.d.ts +0 -1
  72. package/node_modules/@shennian/wire/dist/fs.js +0 -1
  73. package/node_modules/@shennian/wire/dist/index.d.ts +0 -1
  74. package/node_modules/@shennian/wire/dist/index.js +0 -1
  75. package/node_modules/@shennian/wire/dist/machine.d.ts +0 -1
  76. package/node_modules/@shennian/wire/dist/machine.js +0 -1
  77. package/node_modules/@shennian/wire/dist/message-payload.d.ts +0 -1
  78. package/node_modules/@shennian/wire/dist/message-payload.js +0 -1
  79. package/node_modules/@shennian/wire/dist/methods.d.ts +0 -1
  80. package/node_modules/@shennian/wire/dist/methods.js +0 -1
  81. package/node_modules/@shennian/wire/dist/native-session.d.ts +0 -1
  82. package/node_modules/@shennian/wire/dist/native-session.js +0 -1
  83. package/node_modules/@shennian/wire/dist/project.d.ts +0 -1
  84. package/node_modules/@shennian/wire/dist/project.js +0 -1
  85. package/node_modules/@shennian/wire/dist/room.d.ts +44 -1
  86. package/node_modules/@shennian/wire/dist/room.js +0 -1
  87. package/node_modules/@shennian/wire/dist/session.d.ts +18 -3
  88. package/node_modules/@shennian/wire/dist/session.js +0 -2
  89. package/node_modules/@shennian/wire/dist/tool-detail.d.ts +0 -1
  90. package/node_modules/@shennian/wire/dist/tool-detail.js +0 -1
  91. package/node_modules/@shennian/wire/dist/voice-chief.d.ts +0 -1
  92. package/node_modules/@shennian/wire/dist/voice-chief.js +0 -1
  93. package/node_modules/@shennian/wire/package.json +1 -0
  94. package/package.json +2 -2
  95. package/dist/src/integrations/claude-room-plugin-lifecycle.d.ts +0 -47
  96. package/dist/src/integrations/claude-room-plugin-lifecycle.js +0 -1
  97. package/dist/src/integrations/codex-room-plugin-lifecycle.d.ts +0 -49
  98. package/dist/src/integrations/codex-room-plugin-lifecycle.js +0 -1
  99. package/dist/src/integrations/room-plugin-bundles.d.ts +0 -23
  100. package/dist/src/integrations/room-plugin-bundles.js +0 -1
  101. package/dist/src/integrations/room-plugin-lifecycle-common.d.ts +0 -17
  102. package/dist/src/integrations/room-plugin-lifecycle-common.js +0 -1
  103. package/dist/src/integrations/room-plugin-shared.d.ts +0 -24
  104. package/dist/src/integrations/room-plugin-shared.js +0 -38
  105. package/dist/src/integrations/room-session-hook.d.ts +0 -30
  106. package/dist/src/integrations/room-session-hook.js +0 -2
  107. package/dist/src/integrations/workbuddy-plugin-bundle.d.ts +0 -16
  108. package/dist/src/integrations/workbuddy-plugin-bundle.js +0 -1
  109. package/dist/src/integrations/workbuddy-plugin-lifecycle.d.ts +0 -62
  110. package/dist/src/integrations/workbuddy-plugin-lifecycle.js +0 -2
  111. package/dist/src/integrations/workbuddy-session-hook.d.ts +0 -22
  112. package/dist/src/integrations/workbuddy-session-hook.js +0 -1
  113. package/dist/src/room/agent-tool.d.ts +0 -63
  114. package/dist/src/room/agent-tool.js +0 -1
  115. package/dist/src/room/authorized-action-coordinator.d.ts +0 -40
  116. package/dist/src/room/authorized-action-coordinator.js +0 -1
  117. package/dist/src/room/authorized-action-ipc.d.ts +0 -11
  118. package/dist/src/room/authorized-action-ipc.js +0 -1
  119. package/dist/src/room/host-session-observation-ipc.d.ts +0 -9
  120. package/dist/src/room/host-session-observation-ipc.js +0 -1
  121. package/dist/src/room/invocation-token-ipc.d.ts +0 -9
  122. package/dist/src/room/invocation-token-ipc.js +0 -1
  123. package/dist/src/room/invocation-token.d.ts +0 -53
  124. package/dist/src/room/invocation-token.js +0 -1
  125. package/dist/src/room/jsonl-mirror.d.ts +0 -73
  126. package/dist/src/room/jsonl-mirror.js +0 -6
  127. package/dist/src/room/managed-room-session-runtime.d.ts +0 -18
  128. package/dist/src/room/managed-room-session-runtime.js +0 -1
  129. package/dist/src/room/managed-room-session.d.ts +0 -144
  130. package/dist/src/room/managed-room-session.js +0 -2
  131. package/dist/src/room/operator-ipc.d.ts +0 -13
  132. package/dist/src/room/operator-ipc.js +0 -1
  133. package/dist/src/room/pending-authorized-actions.d.ts +0 -69
  134. package/dist/src/room/pending-authorized-actions.js +0 -3
  135. package/dist/src/room/room-action-ipc.d.ts +0 -34
  136. package/dist/src/room/room-action-ipc.js +0 -1
  137. package/dist/src/room/room-action-schema.d.ts +0 -3
  138. package/dist/src/room/room-action-schema.js +0 -1
  139. package/dist/src/room/room-authorized-action-executor.d.ts +0 -23
  140. package/dist/src/room/room-authorized-action-executor.js +0 -1
  141. package/dist/src/room/room-binding-ipc.d.ts +0 -31
  142. package/dist/src/room/room-binding-ipc.js +0 -1
  143. package/dist/src/room/session-registry-ipc.d.ts +0 -14
  144. package/dist/src/room/session-registry-ipc.js +0 -1
  145. package/dist/src/room/tool-schema.d.ts +0 -120
  146. package/dist/src/room/tool-schema.js +0 -1
  147. package/dist/src/room/tool-server.d.ts +0 -11
  148. package/dist/src/room/tool-server.js +0 -3
  149. package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.d.ts +0 -2
  150. package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.d.ts.map +0 -1
  151. package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.js +0 -23
  152. package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.js.map +0 -1
  153. package/node_modules/@shennian/wire/dist/__tests__/mock.test.d.ts +0 -2
  154. package/node_modules/@shennian/wire/dist/__tests__/mock.test.d.ts.map +0 -1
  155. package/node_modules/@shennian/wire/dist/__tests__/mock.test.js +0 -66
  156. package/node_modules/@shennian/wire/dist/__tests__/mock.test.js.map +0 -1
  157. package/node_modules/@shennian/wire/dist/__tests__/types.test.d.ts +0 -2
  158. package/node_modules/@shennian/wire/dist/__tests__/types.test.d.ts.map +0 -1
  159. package/node_modules/@shennian/wire/dist/__tests__/types.test.js +0 -159
  160. package/node_modules/@shennian/wire/dist/__tests__/types.test.js.map +0 -1
  161. package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts.map +0 -1
  162. package/node_modules/@shennian/wire/dist/agent-capabilities.js.map +0 -1
  163. package/node_modules/@shennian/wire/dist/agent-workspace.d.ts.map +0 -1
  164. package/node_modules/@shennian/wire/dist/agent-workspace.js.map +0 -1
  165. package/node_modules/@shennian/wire/dist/envelope.d.ts.map +0 -1
  166. package/node_modules/@shennian/wire/dist/envelope.js.map +0 -1
  167. package/node_modules/@shennian/wire/dist/events.d.ts.map +0 -1
  168. package/node_modules/@shennian/wire/dist/events.js.map +0 -1
  169. package/node_modules/@shennian/wire/dist/external-message-format.d.ts.map +0 -1
  170. package/node_modules/@shennian/wire/dist/external-message-format.js.map +0 -1
  171. package/node_modules/@shennian/wire/dist/frames.d.ts.map +0 -1
  172. package/node_modules/@shennian/wire/dist/frames.js.map +0 -1
  173. package/node_modules/@shennian/wire/dist/fs.d.ts.map +0 -1
  174. package/node_modules/@shennian/wire/dist/fs.js.map +0 -1
  175. package/node_modules/@shennian/wire/dist/index.d.ts.map +0 -1
  176. package/node_modules/@shennian/wire/dist/index.js.map +0 -1
  177. package/node_modules/@shennian/wire/dist/machine.d.ts.map +0 -1
  178. package/node_modules/@shennian/wire/dist/machine.js.map +0 -1
  179. package/node_modules/@shennian/wire/dist/message-payload.d.ts.map +0 -1
  180. package/node_modules/@shennian/wire/dist/message-payload.js.map +0 -1
  181. package/node_modules/@shennian/wire/dist/methods.d.ts.map +0 -1
  182. package/node_modules/@shennian/wire/dist/methods.js.map +0 -1
  183. package/node_modules/@shennian/wire/dist/mock/fixtures.d.ts +0 -39
  184. package/node_modules/@shennian/wire/dist/mock/fixtures.d.ts.map +0 -1
  185. package/node_modules/@shennian/wire/dist/mock/fixtures.js +0 -99
  186. package/node_modules/@shennian/wire/dist/mock/fixtures.js.map +0 -1
  187. package/node_modules/@shennian/wire/dist/mock/index.d.ts +0 -3
  188. package/node_modules/@shennian/wire/dist/mock/index.d.ts.map +0 -1
  189. package/node_modules/@shennian/wire/dist/mock/index.js +0 -4
  190. package/node_modules/@shennian/wire/dist/mock/index.js.map +0 -1
  191. package/node_modules/@shennian/wire/dist/mock/routes.d.ts +0 -96
  192. package/node_modules/@shennian/wire/dist/mock/routes.d.ts.map +0 -1
  193. package/node_modules/@shennian/wire/dist/mock/routes.js +0 -40
  194. package/node_modules/@shennian/wire/dist/mock/routes.js.map +0 -1
  195. package/node_modules/@shennian/wire/dist/native-session.d.ts.map +0 -1
  196. package/node_modules/@shennian/wire/dist/native-session.js.map +0 -1
  197. package/node_modules/@shennian/wire/dist/project.d.ts.map +0 -1
  198. package/node_modules/@shennian/wire/dist/project.js.map +0 -1
  199. package/node_modules/@shennian/wire/dist/queue.d.ts +0 -15
  200. package/node_modules/@shennian/wire/dist/queue.d.ts.map +0 -1
  201. package/node_modules/@shennian/wire/dist/queue.js +0 -2
  202. package/node_modules/@shennian/wire/dist/queue.js.map +0 -1
  203. package/node_modules/@shennian/wire/dist/room.d.ts.map +0 -1
  204. package/node_modules/@shennian/wire/dist/room.js.map +0 -1
  205. package/node_modules/@shennian/wire/dist/session.d.ts.map +0 -1
  206. package/node_modules/@shennian/wire/dist/session.js.map +0 -1
  207. package/node_modules/@shennian/wire/dist/skills.d.ts +0 -61
  208. package/node_modules/@shennian/wire/dist/skills.d.ts.map +0 -1
  209. package/node_modules/@shennian/wire/dist/skills.js +0 -2
  210. package/node_modules/@shennian/wire/dist/skills.js.map +0 -1
  211. package/node_modules/@shennian/wire/dist/tool-detail.d.ts.map +0 -1
  212. package/node_modules/@shennian/wire/dist/tool-detail.js.map +0 -1
  213. package/node_modules/@shennian/wire/dist/voice-chief.d.ts.map +0 -1
  214. package/node_modules/@shennian/wire/dist/voice-chief.js.map +0 -1
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  > Shennian AI Agent 控制面的本机后台服务 / CLI
4
4
  >
5
5
  > **架构设计** → [docs/architecture/cli/](../../docs/architecture/cli/)
6
+ > - [CLI 设计哲学](../../docs/architecture/cli/design-philosophy.md) — CLI、Skill、daemon、身份与宿主适配边界
6
7
  > - [Daemon 架构](../../docs/architecture/cli/daemon.md) — 模块拓扑、数据流、守护进程
7
8
  > - [Agent Adapters](../../docs/architecture/cli/agent-adapters.md) — 5 种 agent 的适配与归一化
8
9
  > - [开源 Agent Protocol](../../docs/architecture/cli/agent-protocol.md) — 第三方 agent 接入协议
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "jsMinified": true,
4
4
  "minifier": "esbuild",
5
- "fileCount": 130,
5
+ "fileCount": 111,
6
6
  "files": [
7
7
  {
8
8
  "file": "bin/shennian.js",
@@ -56,8 +56,8 @@
56
56
  },
57
57
  {
58
58
  "file": "src/agents/detect.js",
59
- "beforeBytes": 1817,
60
- "afterBytes": 904
59
+ "beforeBytes": 1506,
60
+ "afterBytes": 701
61
61
  },
62
62
  {
63
63
  "file": "src/agents/external-channel-instructions.js",
@@ -71,8 +71,8 @@
71
71
  },
72
72
  {
73
73
  "file": "src/agents/manager.js",
74
- "beforeBytes": 6489,
75
- "afterBytes": 3499
74
+ "beforeBytes": 10395,
75
+ "afterBytes": 5613
76
76
  },
77
77
  {
78
78
  "file": "src/agents/model-registry/cache.js",
@@ -96,8 +96,8 @@
96
96
  },
97
97
  {
98
98
  "file": "src/agents/model-registry/service.js",
99
- "beforeBytes": 2880,
100
- "afterBytes": 1209
99
+ "beforeBytes": 3048,
100
+ "afterBytes": 1321
101
101
  },
102
102
  {
103
103
  "file": "src/agents/model-registry/types.js",
@@ -136,13 +136,13 @@
136
136
  },
137
137
  {
138
138
  "file": "src/agents/workbuddy.js",
139
- "beforeBytes": 14877,
140
- "afterBytes": 7544
139
+ "beforeBytes": 14265,
140
+ "afterBytes": 7150
141
141
  },
142
142
  {
143
143
  "file": "src/commands/agent.js",
144
- "beforeBytes": 6216,
145
- "afterBytes": 3443
144
+ "beforeBytes": 7536,
145
+ "afterBytes": 4438
146
146
  },
147
147
  {
148
148
  "file": "src/commands/daemon-process.js",
@@ -166,18 +166,23 @@
166
166
  },
167
167
  {
168
168
  "file": "src/commands/integration.js",
169
- "beforeBytes": 4173,
170
- "afterBytes": 2491
169
+ "beforeBytes": 815,
170
+ "afterBytes": 468
171
171
  },
172
172
  {
173
173
  "file": "src/commands/manager.js",
174
- "beforeBytes": 6882,
175
- "afterBytes": 4465
174
+ "beforeBytes": 6902,
175
+ "afterBytes": 4479
176
+ },
177
+ {
178
+ "file": "src/commands/pair-authorization.js",
179
+ "beforeBytes": 1255,
180
+ "afterBytes": 746
176
181
  },
177
182
  {
178
183
  "file": "src/commands/pair-browser.js",
179
- "beforeBytes": 6558,
180
- "afterBytes": 3650
184
+ "beforeBytes": 6544,
185
+ "afterBytes": 3636
181
186
  },
182
187
  {
183
188
  "file": "src/commands/pair-qr.js",
@@ -191,8 +196,13 @@
191
196
  },
192
197
  {
193
198
  "file": "src/commands/room.js",
194
- "beforeBytes": 11089,
195
- "afterBytes": 5750
199
+ "beforeBytes": 14862,
200
+ "afterBytes": 8665
201
+ },
202
+ {
203
+ "file": "src/commands/runtime.js",
204
+ "beforeBytes": 4986,
205
+ "afterBytes": 2765
196
206
  },
197
207
  {
198
208
  "file": "src/commands/tools.js",
@@ -214,6 +224,11 @@
214
224
  "beforeBytes": 2754,
215
225
  "afterBytes": 1393
216
226
  },
227
+ {
228
+ "file": "src/daemon-ipc/json.js",
229
+ "beforeBytes": 11,
230
+ "afterBytes": 1
231
+ },
217
232
  {
218
233
  "file": "src/daemon-ipc/paths.js",
219
234
  "beforeBytes": 1010,
@@ -266,53 +281,8 @@
266
281
  },
267
282
  {
268
283
  "file": "src/index.js",
269
- "beforeBytes": 26427,
270
- "afterBytes": 13597
271
- },
272
- {
273
- "file": "src/integrations/claude-room-plugin-lifecycle.js",
274
- "beforeBytes": 11692,
275
- "afterBytes": 6435
276
- },
277
- {
278
- "file": "src/integrations/codex-room-plugin-lifecycle.js",
279
- "beforeBytes": 13989,
280
- "afterBytes": 7423
281
- },
282
- {
283
- "file": "src/integrations/room-plugin-bundles.js",
284
- "beforeBytes": 5035,
285
- "afterBytes": 2787
286
- },
287
- {
288
- "file": "src/integrations/room-plugin-lifecycle-common.js",
289
- "beforeBytes": 4324,
290
- "afterBytes": 2202
291
- },
292
- {
293
- "file": "src/integrations/room-plugin-shared.js",
294
- "beforeBytes": 10882,
295
- "afterBytes": 9031
296
- },
297
- {
298
- "file": "src/integrations/room-session-hook.js",
299
- "beforeBytes": 12856,
300
- "afterBytes": 6456
301
- },
302
- {
303
- "file": "src/integrations/workbuddy-plugin-bundle.js",
304
- "beforeBytes": 2256,
305
- "afterBytes": 1258
306
- },
307
- {
308
- "file": "src/integrations/workbuddy-plugin-lifecycle.js",
309
- "beforeBytes": 15998,
310
- "afterBytes": 8237
311
- },
312
- {
313
- "file": "src/integrations/workbuddy-session-hook.js",
314
- "beforeBytes": 2622,
315
- "afterBytes": 1252
284
+ "beforeBytes": 21131,
285
+ "afterBytes": 11117
316
286
  },
317
287
  {
318
288
  "file": "src/log-reporter.js",
@@ -326,8 +296,8 @@
326
296
  },
327
297
  {
328
298
  "file": "src/manager/registry.js",
329
- "beforeBytes": 11834,
330
- "afterBytes": 5843
299
+ "beforeBytes": 13897,
300
+ "afterBytes": 6747
331
301
  },
332
302
  {
333
303
  "file": "src/manager/retired-external-channel-compat.js",
@@ -336,8 +306,8 @@
336
306
  },
337
307
  {
338
308
  "file": "src/manager/runtime.js",
339
- "beforeBytes": 68697,
340
- "afterBytes": 34863
309
+ "beforeBytes": 71951,
310
+ "afterBytes": 36578
341
311
  },
342
312
  {
343
313
  "file": "src/native-fusion/codex-parser.js",
@@ -401,44 +371,24 @@
401
371
  },
402
372
  {
403
373
  "file": "src/room/activation-service.js",
404
- "beforeBytes": 16619,
405
- "afterBytes": 9832
406
- },
407
- {
408
- "file": "src/room/agent-tool.js",
409
- "beforeBytes": 5020,
410
- "afterBytes": 3009
374
+ "beforeBytes": 15508,
375
+ "afterBytes": 7310
411
376
  },
412
377
  {
413
378
  "file": "src/room/attachment-cache.js",
414
- "beforeBytes": 12422,
415
- "afterBytes": 5892
379
+ "beforeBytes": 12558,
380
+ "afterBytes": 6015
416
381
  },
417
382
  {
418
383
  "file": "src/room/attachment-upload.js",
419
384
  "beforeBytes": 4871,
420
385
  "afterBytes": 2617
421
386
  },
422
- {
423
- "file": "src/room/authorized-action-coordinator.js",
424
- "beforeBytes": 3558,
425
- "afterBytes": 1690
426
- },
427
- {
428
- "file": "src/room/authorized-action-ipc.js",
429
- "beforeBytes": 7421,
430
- "afterBytes": 3693
431
- },
432
387
  {
433
388
  "file": "src/room/device-authorization-client.js",
434
389
  "beforeBytes": 3803,
435
390
  "afterBytes": 2160
436
391
  },
437
- {
438
- "file": "src/room/host-session-observation-ipc.js",
439
- "beforeBytes": 4071,
440
- "afterBytes": 2166
441
- },
442
392
  {
443
393
  "file": "src/room/host-session-observations.js",
444
394
  "beforeBytes": 9376,
@@ -450,19 +400,14 @@
450
400
  "afterBytes": 3363
451
401
  },
452
402
  {
453
- "file": "src/room/invocation-token-ipc.js",
454
- "beforeBytes": 3247,
455
- "afterBytes": 1723
456
- },
457
- {
458
- "file": "src/room/invocation-token.js",
459
- "beforeBytes": 7288,
460
- "afterBytes": 3803
403
+ "file": "src/room/managed-context.js",
404
+ "beforeBytes": 4442,
405
+ "afterBytes": 2478
461
406
  },
462
407
  {
463
- "file": "src/room/jsonl-mirror.js",
464
- "beforeBytes": 17632,
465
- "afterBytes": 9201
408
+ "file": "src/room/managed-prompt-composer.js",
409
+ "beforeBytes": 4423,
410
+ "afterBytes": 4204
466
411
  },
467
412
  {
468
413
  "file": "src/room/managed-room-binding.js",
@@ -470,79 +415,39 @@
470
415
  "afterBytes": 3316
471
416
  },
472
417
  {
473
- "file": "src/room/managed-room-session-runtime.js",
474
- "beforeBytes": 6393,
475
- "afterBytes": 3293
476
- },
477
- {
478
- "file": "src/room/managed-room-session.js",
479
- "beforeBytes": 17354,
480
- "afterBytes": 8762
418
+ "file": "src/room/managed-room-ipc.js",
419
+ "beforeBytes": 7797,
420
+ "afterBytes": 3832
481
421
  },
482
422
  {
483
423
  "file": "src/room/mirror-sync-service.js",
484
- "beforeBytes": 7686,
485
- "afterBytes": 3515
424
+ "beforeBytes": 7714,
425
+ "afterBytes": 3498
486
426
  },
487
427
  {
488
- "file": "src/room/operator-ipc.js",
489
- "beforeBytes": 8566,
490
- "afterBytes": 4401
428
+ "file": "src/room/public-attachment-cache.js",
429
+ "beforeBytes": 10361,
430
+ "afterBytes": 5048
491
431
  },
492
432
  {
493
- "file": "src/room/pending-authorized-actions.js",
494
- "beforeBytes": 15111,
495
- "afterBytes": 8340
433
+ "file": "src/room/public-room-client.js",
434
+ "beforeBytes": 5637,
435
+ "afterBytes": 3101
496
436
  },
497
437
  {
498
438
  "file": "src/room/room-action-client.js",
499
- "beforeBytes": 23011,
500
- "afterBytes": 11555
501
- },
502
- {
503
- "file": "src/room/room-action-ipc.js",
504
- "beforeBytes": 16387,
505
- "afterBytes": 7413
506
- },
507
- {
508
- "file": "src/room/room-action-schema.js",
509
- "beforeBytes": 6434,
510
- "afterBytes": 3065
511
- },
512
- {
513
- "file": "src/room/room-authorized-action-executor.js",
514
- "beforeBytes": 6641,
515
- "afterBytes": 3594
439
+ "beforeBytes": 23331,
440
+ "afterBytes": 11775
516
441
  },
517
442
  {
518
443
  "file": "src/room/room-binding-client.js",
519
444
  "beforeBytes": 7028,
520
445
  "afterBytes": 4032
521
446
  },
522
- {
523
- "file": "src/room/room-binding-ipc.js",
524
- "beforeBytes": 5545,
525
- "afterBytes": 2843
526
- },
527
- {
528
- "file": "src/room/session-registry-ipc.js",
529
- "beforeBytes": 7514,
530
- "afterBytes": 3827
531
- },
532
447
  {
533
448
  "file": "src/room/session-registry.js",
534
- "beforeBytes": 26358,
535
- "afterBytes": 14831
536
- },
537
- {
538
- "file": "src/room/tool-schema.js",
539
- "beforeBytes": 5223,
540
- "afterBytes": 3212
541
- },
542
- {
543
- "file": "src/room/tool-server.js",
544
- "beforeBytes": 8507,
545
- "afterBytes": 4475
449
+ "beforeBytes": 27208,
450
+ "afterBytes": 15357
546
451
  },
547
452
  {
548
453
  "file": "src/session/archive-zip.js",
@@ -566,8 +471,8 @@
566
471
  },
567
472
  {
568
473
  "file": "src/session/handlers/chat.js",
569
- "beforeBytes": 29613,
570
- "afterBytes": 12377
474
+ "beforeBytes": 31135,
475
+ "afterBytes": 13184
571
476
  },
572
477
  {
573
478
  "file": "src/session/handlers/control.js",
@@ -601,8 +506,8 @@
601
506
  },
602
507
  {
603
508
  "file": "src/session/manager.js",
604
- "beforeBytes": 21721,
605
- "afterBytes": 11139
509
+ "beforeBytes": 18103,
510
+ "afterBytes": 9204
606
511
  },
607
512
  {
608
513
  "file": "src/session/projection.js",
@@ -611,8 +516,8 @@
611
516
  },
612
517
  {
613
518
  "file": "src/session/queue.js",
614
- "beforeBytes": 14491,
615
- "afterBytes": 6801
519
+ "beforeBytes": 15015,
520
+ "afterBytes": 7165
616
521
  },
617
522
  {
618
523
  "file": "src/session/remote-attachments.js",
@@ -621,8 +526,8 @@
621
526
  },
622
527
  {
623
528
  "file": "src/session/store.js",
624
- "beforeBytes": 3925,
625
- "afterBytes": 1918
529
+ "beforeBytes": 4333,
530
+ "afterBytes": 2212
626
531
  },
627
532
  {
628
533
  "file": "src/session/tool-summary.js",
@@ -1 +1 @@
1
- import{AVAILABLE_BUILTIN_AGENT_TYPES as s}from"@shennian/wire";import{loadConfig as r}from"../config/index.js";import{getCommandVersion as d,resolveBuiltinCommand as a}from"./command-spec.js";const i=s.filter(e=>e!=="pi"&&e!=="manager");function c(e){const t=e.models?.length?e.models:e.model?[e.model]:[],n=e.defaultModel??e.model;return t.map(o=>({id:o,name:o,isDefault:o===n}))}function g(){const e=[{type:"manager",command:"shennian",args:["manager"],version:void 0,models:[{id:"codex",name:"Codex",provider:"shennian",isDefault:!0},{id:"claude",name:"Claude Code",provider:"shennian"}]}];for(const n of i){const o=a(n);if(!o)continue;const m=d(o);e.push({type:n,command:o.command,args:o.args,version:m})}const t=r();for(const[n,o]of Object.entries(t.customAgents??{}))e.push({type:`custom:${n}`,command:o.command,args:[],version:o.caps.version,models:c(o.caps)});return e}export{g as detectAgents};
1
+ import{AVAILABLE_BUILTIN_AGENT_TYPES as s}from"@shennian/wire";import{loadConfig as r}from"../config/index.js";import{getCommandVersion as c,resolveBuiltinCommand as d}from"./command-spec.js";const i=s.filter(o=>o!=="pi");function l(o){const n=o.models?.length?o.models:o.model?[o.model]:[],t=o.defaultModel??o.model;return n.map(e=>({id:e,name:e,isDefault:e===t}))}function g(){const o=[];for(const t of i){const e=d(t);if(!e)continue;const m=c(e);o.push({type:t,command:e.command,args:e.args,version:m})}const n=r();for(const[t,e]of Object.entries(n.customAgents??{}))o.push({type:`custom:${t}`,command:e.command,args:[],version:e.caps.version,models:l(e.caps)});return o}export{g as detectAgents};
@@ -1,4 +1,39 @@
1
+ import type { AgentSendContext, AgentSendResult } from './adapter.js';
1
2
  import { AgentAdapter } from './adapter.js';
3
+ import type { ChatAttachmentMeta, ExternalChannelSessionStatus } from '@shennian/wire';
4
+ type ManagerModelId = 'codex' | 'claude';
5
+ /** Decorates a real provider Adapter with Manager session capabilities. New
6
+ * sessions use this class and keep their real agentType/modelId. */
7
+ export declare class ManagerModeAdapter extends AgentAdapter {
8
+ private readonly inner;
9
+ private readonly substrate;
10
+ readonly type: import("@shennian/wire").AgentType;
11
+ private sessionId;
12
+ private workDir;
13
+ private agentSessionId;
14
+ private configured;
15
+ constructor(inner: AgentAdapter, substrate: ManagerModelId);
16
+ configure(options: {
17
+ sessionId?: string;
18
+ externalChannel?: ExternalChannelSessionStatus | null;
19
+ env?: NodeJS.ProcessEnv;
20
+ }): void;
21
+ start(sessionId: string, workDir: string, agentSessionId?: string | null): Promise<void>;
22
+ send(text: string, modelId?: string, reasoningEffort?: string, attachments?: ChatAttachmentMeta[], agentSystemPrompt?: string | null, context?: AgentSendContext): Promise<void | AgentSendResult>;
23
+ resume(agentSessionId: string): Promise<void>;
24
+ stop(): Promise<void>;
25
+ getStatus(): Promise<{
26
+ active: boolean;
27
+ runId?: string | null;
28
+ runPhase?: import("@shennian/wire").SessionRunPhase | null;
29
+ canStop?: boolean;
30
+ }> | Promise<{
31
+ active: false;
32
+ }>;
33
+ setTitle(agentSessionId: string, title: string, workDir?: string): Promise<void>;
34
+ private applyEnvironment;
35
+ }
36
+ export declare function combineManagerInstructions(managerInstructions: string, systemPrompt?: string | null): string;
2
37
  export declare class ManagerAdapter extends AgentAdapter {
3
38
  readonly type: "manager";
4
39
  private inner;
@@ -14,3 +49,4 @@ export declare class ManagerAdapter extends AgentAdapter {
14
49
  private wrapEvent;
15
50
  private withManagerEnv;
16
51
  }
52
+ export {};
@@ -1,13 +1,18 @@
1
- import{AgentAdapter as h,registerAgent as l}from"./adapter.js";import{CodexAdapter as g}from"./codex.js";import{ClaudeAdapter as m}from"./claude.js";import{MANAGER_SYSTEM_PROMPT as I,buildManagerPrompt as f}from"../manager/prompt.js";import{getManagerRuntimeService as o}from"../manager/runtime.js";import a from"node:fs";import d from"node:path";import{PLATFORM_OUTPUT_INSTRUCTIONS as p}from"./platform-instructions.js";function S(s){return s==="claude"?"claude":"codex"}function w(s){return s.replace(/[^a-zA-Z0-9_.-]/g,"_")}function M(s){const e=d.join(s,"AGENTS.md");try{return a.readFileSync(e,"utf8").trim()}catch{return""}}function y(s,e){return d.join(s,".shennian","runtime","manager",w(e),"instructions.md")}function u(s,e){const n=M(s),t=o(),r=t?.getManagerExternalChannelSystemPrompt(e)??"",i=typeof t?.getManagerWorkerDefaults=="function"?t.getManagerWorkerDefaults(e):void 0,c=i?.agentType?`\u9ED8\u8BA4 worker Agent\uFF1A${i.agentType}${i.modelId?`
2
- \u9ED8\u8BA4 worker \u6A21\u578B\uFF1A${i.modelId}`:""}\u3002\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\u6216\u4EFB\u52A1\u660E\u663E\u9700\u8981\u5176\u4ED6 Agent/\u6A21\u578B\uFF0C\u521B\u5EFA worker \u65F6\u4F18\u5148\u4F7F\u7528\u8FD9\u4E2A\u9ED8\u8BA4\u7EC4\u5408\u3002`:"";return`${["# Shennian Manager Instructions","This file is generated by Shennian for a Manager Agent substrate session. Do not edit it by hand.",n?`## Project Instructions
1
+ import{AgentAdapter as g,registerAgent as I}from"./adapter.js";import{CodexAdapter as p}from"./codex.js";import{ClaudeAdapter as f}from"./claude.js";import{MANAGER_SYSTEM_PROMPT as y,buildManagerPrompt as l}from"../manager/prompt.js";import{getManagerRuntimeService as o}from"../manager/runtime.js";import d from"node:fs";import c from"node:path";import{PLATFORM_OUTPUT_INSTRUCTIONS as S}from"./platform-instructions.js";function w(i){return i==="claude"?"claude":"codex"}function M(i){return i.replace(/[^a-zA-Z0-9_.-]/g,"_")}function v(i){const e=c.join(i,"AGENTS.md");try{return d.readFileSync(e,"utf8").trim()}catch{return""}}function k(i,e){return c.join(i,".shennian","runtime","manager",M(e),"instructions.md")}function h(i,e){const n=v(i),t=o(),r=t?.getManagerExternalChannelSystemPrompt(e)??"",s=typeof t?.getManagerWorkerDefaults=="function"?t.getManagerWorkerDefaults(e):void 0,a=s?.agentType?`\u9ED8\u8BA4 worker Agent\uFF1A${s.agentType}${s.modelId?`
2
+ \u9ED8\u8BA4 worker \u6A21\u578B\uFF1A${s.modelId}`:""}\u3002\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\u6216\u4EFB\u52A1\u660E\u663E\u9700\u8981\u5176\u4ED6 Agent/\u6A21\u578B\uFF0C\u521B\u5EFA worker \u65F6\u4F18\u5148\u4F7F\u7528\u8FD9\u4E2A\u9ED8\u8BA4\u7EC4\u5408\u3002`:"";return`${["# Shennian Manager Instructions","This file is generated by Shennian for a Manager Agent substrate session. Do not edit it by hand.",n?`## Project Instructions
3
3
 
4
4
  ${n}`:"",`## Manager Instructions
5
5
 
6
- ${I}`,c?`## Worker Defaults
6
+ ${y}`,a?`## Worker Defaults
7
7
 
8
- ${c}`:"",r?`## External Message Channel Instructions
8
+ ${a}`:"",r?`## External Message Channel Instructions
9
9
 
10
- ${r}`:"",p].filter(Boolean).join(`
10
+ ${r}`:"",S].filter(Boolean).join(`
11
11
 
12
12
  `)}
13
- `}function k(s,e){const n=y(s,e),t=u(s,e);a.mkdirSync(d.dirname(n),{recursive:!0});try{if(a.readFileSync(n,"utf8")===t)return n}catch{}return a.writeFileSync(n,t),n}class A extends h{type="manager";inner=null;sessionId="";workDir="";agentSessionId=null;modelId="codex";async start(e,n,t){this.sessionId=e,this.workDir=n,this.agentSessionId=t??null,o()?.registerManager({sessionId:e,agentSessionId:this.agentSessionId,workDir:n,modelId:this.modelId,status:"idle"})}async send(e,n){const t=S(n);if(!this.inner||t!==this.modelId){await this.inner?.stop().catch(()=>{}),this.inner?.removeAllListeners(),this.modelId=t;const r=k(this.workDir,this.sessionId),i=u(this.workDir,this.sessionId);this.inner=t==="claude"?new m({systemPrompt:i,hidden:!0}):new g({modelInstructionsFile:r,hidden:!0}),this.bindInner(this.inner),await this.inner.start(this.sessionId,this.workDir,this.agentSessionId),o()?.bindManagerAdapterEvents(this.sessionId,this.inner)}o()?.registerManager({sessionId:this.sessionId,agentSessionId:this.agentSessionId,workDir:this.workDir,modelId:this.modelId,status:"running"}),await o()?.ready(),await this.withManagerEnv(()=>this.inner.send(f(e)))}async resume(e){this.agentSessionId=e,this.inner&&await this.inner.resume(e)}async stop(){await this.inner?.stop()}bindInner(e){e.on("agentEvent",n=>{n.agentSessionId&&(this.agentSessionId=n.agentSessionId),this.emit("agentEvent",this.wrapEvent(n))}),e.on("error",n=>this.emit("error",n))}wrapEvent(e){return{...e,source:e.source??this.modelId,agentSessionId:e.agentSessionId??this.agentSessionId??void 0}}async withManagerEnv(e){const n=o()?.getInjectedEnv(this.sessionId,this.agentSessionId,this.workDir,this.modelId)??{},t=new Map;for(const[r,i]of Object.entries(n))t.set(r,process.env[r]),process.env[r]=i;try{return await e()}finally{for(const[r,i]of t)i===void 0?delete process.env[r]:process.env[r]=i}}}l("manager",()=>new A);export{A as ManagerAdapter};
13
+ `}function E(i,e){const n=k(i,e),t=h(i,e);d.mkdirSync(c.dirname(n),{recursive:!0});try{if(d.readFileSync(n,"utf8")===t)return n}catch{}return d.writeFileSync(n,t),n}class R extends g{inner;substrate;type;sessionId="";workDir="";agentSessionId=null;configured={};constructor(e,n){super(),this.inner=e,this.substrate=n,this.type=e.type,e.on("agentEvent",t=>{t.agentSessionId&&(this.agentSessionId=t.agentSessionId),this.emit("agentEvent",{...t,source:t.source??n})}),e.on("error",t=>this.emit("error",t))}configure(e){this.configured=e,this.applyEnvironment()}async start(e,n,t){this.sessionId=e,this.workDir=n,this.agentSessionId=t??null,this.applyEnvironment(),await this.inner.start(e,n,t),o()?.registerManager({sessionId:e,agentSessionId:this.agentSessionId,workDir:n,modelId:this.substrate,agentType:this.type==="claude"?"claude":"codex",status:"idle"}),o()?.bindManagerAdapterEvents(e,this.inner)}async send(e,n,t,r,s,a){o()?.registerManager({sessionId:this.sessionId,agentSessionId:this.agentSessionId,workDir:this.workDir,modelId:this.substrate,agentType:this.type==="claude"?"claude":"codex",providerModelId:n??null,status:"running"}),await o()?.ready(),this.applyEnvironment();const u=h(this.workDir,this.sessionId),m=A(u,s);return this.inner.send(l(e),n,t,r,m,a)}async resume(e){this.agentSessionId=e,await this.inner.resume(e)}async stop(){await this.inner.stop()}getStatus(){return this.inner.getStatus?.()??Promise.resolve({active:!1})}setTitle(e,n,t){return this.inner.setTitle?.(e,n,t)??Promise.resolve()}applyEnvironment(){const e=this.sessionId?o()?.getInjectedEnv(this.sessionId,this.agentSessionId,this.workDir,this.substrate)??{}:{};this.inner.configure?.({...this.configured,sessionId:this.configured.sessionId??this.sessionId,env:{...this.configured.env??{},...e}})}}function A(i,e){const n=e?.trim()??"";if(!n)return i;const r=["[\u667A\u80FD\u4F53\u79C1\u6709\u7CFB\u7EDF\u63D0\u793A\u8BCD]","[\u667A\u80FD\u4F53\u8EAB\u4EFD]"].map(s=>n.indexOf(s)).filter(s=>s>=0).sort((s,a)=>s-a)[0]??-1;return n.startsWith("[\u795E\u5FF5\u53D7\u7BA1\u4F1A\u8BDD\u89C4\u5219]")&&r>=0?`${n.slice(0,r)}[\u4F1A\u8BDD\u6A21\u5F0F]
14
+ ${i.trim()}
15
+
16
+ ${n.slice(r)}`:`${i.trim()}
17
+
18
+ ${n}`}class b extends g{type="manager";inner=null;sessionId="";workDir="";agentSessionId=null;modelId="codex";async start(e,n,t){this.sessionId=e,this.workDir=n,this.agentSessionId=t??null,o()?.registerManager({sessionId:e,agentSessionId:this.agentSessionId,workDir:n,modelId:this.modelId,agentType:"manager",status:"idle"})}async send(e,n){const t=w(n);if(!this.inner||t!==this.modelId){await this.inner?.stop().catch(()=>{}),this.inner?.removeAllListeners(),this.modelId=t;const r=E(this.workDir,this.sessionId),s=h(this.workDir,this.sessionId);this.inner=t==="claude"?new f({systemPrompt:s,hidden:!0}):new p({modelInstructionsFile:r,hidden:!0}),this.bindInner(this.inner),await this.inner.start(this.sessionId,this.workDir,this.agentSessionId),o()?.bindManagerAdapterEvents(this.sessionId,this.inner)}o()?.registerManager({sessionId:this.sessionId,agentSessionId:this.agentSessionId,workDir:this.workDir,modelId:this.modelId,agentType:"manager",status:"running"}),await o()?.ready(),await this.withManagerEnv(()=>this.inner.send(l(e)))}async resume(e){this.agentSessionId=e,this.inner&&await this.inner.resume(e)}async stop(){await this.inner?.stop()}bindInner(e){e.on("agentEvent",n=>{n.agentSessionId&&(this.agentSessionId=n.agentSessionId),this.emit("agentEvent",this.wrapEvent(n))}),e.on("error",n=>this.emit("error",n))}wrapEvent(e){return{...e,source:e.source??this.modelId,agentSessionId:e.agentSessionId??this.agentSessionId??void 0}}async withManagerEnv(e){const n=o()?.getInjectedEnv(this.sessionId,this.agentSessionId,this.workDir,this.modelId)??{},t=new Map;for(const[r,s]of Object.entries(n))t.set(r,process.env[r]),process.env[r]=s;try{return await e()}finally{for(const[r,s]of t)s===void 0?delete process.env[r]:process.env[r]=s}}}I("manager",()=>new b);export{b as ManagerAdapter,R as ManagerModeAdapter,A as combineManagerInstructions};
@@ -1 +1 @@
1
- import{getAgentConfigSummary as u}from"../config-status.js";import{isCacheFresh as h,readCache as m,writeCache as p}from"./cache.js";import{discoverModelsForAgent as y}from"./discovery.js";import{getAgentRuntimeSummary as g}from"../runtime-compatibility.js";function v(o){const s=new Set,e=[];for(const t of o)!t.id||s.has(t.id)||(s.add(t.id),e.push(t));return e}function I(o){const s=m();return o.map(e=>{const t=u(e.type),r=g(e);return{type:e.type,models:s.agents[e.type]?.models??e.models??[],...t?{config:t}:{},...r?{runtime:r}:{}}})}async function q(o,s){const e=m();for(const t of o)delete e.agents[t.type];return p(e),A(o,s)}async function A(o,s){const e=m();let t=!1;const r=[];for(const n of o){const c=e.agents[n.type];let i;if(h(c,n.version))i=c.models;else{let f=null;try{f=v(await y(n,s)),i=f.length>0?f:c?.models??n.models??[]}catch{i=c?.models??n.models??[]}if(f&&f.length>0){const l={version:n.version,refreshedAt:Date.now(),models:i};JSON.stringify(c)!==JSON.stringify(l)&&(e.agents[n.type]=l,t=!0)}}const a=u(n.type),d=g(n);r.push({type:n.type,models:i,...a?{config:a}:{},...d?{runtime:d}:{}})}return t&&p(e),r}export{I as getCachedAgentInfos,q as refreshAgentInfos,A as resolveAgentInfos};
1
+ import{getAgentConfigSummary as m}from"../config-status.js";import{isCacheFresh as g,readCache as d,writeCache as l}from"./cache.js";import{discoverModelsForAgent as h}from"./discovery.js";import{getAgentRuntimeSummary as y}from"../runtime-compatibility.js";function v(n){const s=new Set,e=[];for(const t of n)!t.id||s.has(t.id)||(s.add(t.id),e.push(t));return e}function w(n){const s=d();return n.map(e=>{const t=m(e.type),r=y(e);return{type:e.type,models:s.agents[e.type]?.models??e.models??[],supportsManagerMode:e.type==="codex"||e.type==="claude",...t?{config:t}:{},...r?{runtime:r}:{}}})}async function I(n,s){const e=d();for(const t of n)delete e.agents[t.type];return l(e),x(n,s)}async function x(n,s){const e=d();let t=!1;const r=[];for(const o of n){const c=e.agents[o.type];let i;if(g(c,o.version))i=c.models;else{let f=null;try{f=v(await h(o,s)),i=f.length>0?f:c?.models??o.models??[]}catch{i=c?.models??o.models??[]}if(f&&f.length>0){const u={version:o.version,refreshedAt:Date.now(),models:i};JSON.stringify(c)!==JSON.stringify(u)&&(e.agents[o.type]=u,t=!0)}}const a=m(o.type),p=y(o);r.push({type:o.type,models:i,supportsManagerMode:o.type==="codex"||o.type==="claude",...a?{config:a}:{},...p?{runtime:p}:{}})}return t&&l(e),r}export{w as getCachedAgentInfos,I as refreshAgentInfos,x as resolveAgentInfos};
@@ -1,3 +1,3 @@
1
- import{spawnSync as w}from"node:child_process";import{createInterface as k}from"node:readline";import{randomUUID as I}from"node:crypto";import S from"node:path";import{AgentAdapter as x,registerAgent as _}from"./adapter.js";import{resolveBuiltinCommand as E,spawnAgentCommand as B}from"./command-spec.js";import{buildAgentProcessEnv as P}from"../agent-env.js";import{buildPlatformInstructions as T,ensurePlatformInstructionsFile as W}from"./platform-instructions.js";import{ensureWorkBuddyRoomPluginBundle as C}from"../integrations/workbuddy-plugin-bundle.js";import{roomMcpHostToolName as A}from"../integrations/room-plugin-shared.js";import{resolveWindowsSystemRoot as R}from"../windows-shell.js";const O=new Set(["minimal","low","medium","high","xhigh","max"]);function q(s){const t=s?.trim();return t&&t!=="auto"?t:void 0}function D(s){const t=s?.trim();if(t){if(O.has(t))return t;throw new Error(`Unsupported WorkBuddy reasoning effort "${t}". Supported values: minimal, low, medium, high, xhigh, max.`)}}function $(s,t,e){if(!s)return[];if(t==="win32"){if(!e)throw new Error("WorkBuddy system prompt file is required on Windows.");return["--system-prompt-file",e]}return["--append-system-prompt",s]}function F(s){const t=s.split(/\n\n(?=<[^>\n]+>\n)/);return(t[t.length-1]??s).replace(/^\[群消息\][ \t]+<[^>\n]+>\n/,"").replace(/^\[群消息\]\n?/,"").replace(/^<[^>\n]+>\n/,"").trim()}function f(s,t=process.platform,e=b){t==="win32"&&s.pid&&e(s.pid)||s.kill("SIGTERM")}function b(s){const t=S.win32.join(R(),"System32","taskkill.exe");return w(t,["/pid",String(s),"/T","/F"],{stdio:"ignore",windowsHide:!0,timeout:5e3}).status===0}class z extends x{type="workbuddy";process=null;agentSessionId=null;workDir=null;seq=0;runId="";terminalState="open";hasEmittedText=!1;runPhase=null;externalChannel=null;shennianSessionId=null;extraEnv={};configure(t){this.shennianSessionId=t.sessionId??null,this.externalChannel=t.externalChannel??null,this.extraEnv=t.env??{}}async start(t,e,n){this.workDir=e,this.seq=0,n&&(this.agentSessionId=n)}async send(t,e,n,o,a,r){await this.killProcess(),this.runId=I(),this.resetRunState();const u=r?.source==="room_activation",i=["-p",u?F(t):t,"--output-format","stream-json","--verbose","--permission-mode",u?"dontAsk":"bypassPermissions","--setting-sources","user,project,local"],d=q(e);d&&i.push("--model",d);const h=C(),m=A("workbuddy");u?i.push("--allowedTools",m,"--tools",`NoDefer(${m})`,"--mcp-config",h.mcpFile,"--strict-mcp-config","--disallowedTools","mcp__shennian_room__shennian_agent","--max-turns","2"):i.push("--tools","default"),i.push("--plugin-dir",h.pluginRoot);const p=this.shennianSessionId?.startsWith("room-managed-")&&!this.agentSessionId&&!u?null:T(this.workDir??process.cwd(),this.externalChannel,this.shennianSessionId??void 0,a);if(p){const y=process.platform==="win32"?W(this.workDir??process.cwd(),this.externalChannel,this.shennianSessionId??void 0,a):void 0;i.push(...$(p,process.platform,y))}const c=D(n);c&&i.push("--effort",c),this.agentSessionId&&i.push("--resume",this.agentSessionId),this.spawnAndParse(i)}async resume(t){await this.killProcess(),this.agentSessionId=t,this.resetRunState()}async stop(){await this.killProcess()}async getStatus(){return{active:this.process!=null&&this.terminalState==="open",runId:this.runId||null,runPhase:this.runPhase,canStop:this.process!=null&&this.terminalState==="open"}}spawnAndParse(t){const e=E("workbuddy");if(!e){this.emit("error",new Error("WorkBuddy was not found. Install WorkBuddy Desktop or the CodeBuddy CLI, then retry."));return}const n=B(e,t,{cwd:this.workDir??void 0,stdio:["ignore","pipe","pipe"],env:P(this.extraEnv)});this.process=n,k({input:n.stdout}).on("line",r=>{if(r.trim())try{this.handleStreamEvent(JSON.parse(r))}catch{}});let a="";n.stderr?.on("data",r=>{a=`${a}${r.toString()}`.slice(-8e3)}),n.on("close",r=>{this.process===n&&(this.process=null,this.runPhase=null,this.handleProcessClose(r,a))}),n.on("error",r=>{if(this.process!==n)return;this.process=null,this.runPhase=null;const u=r.code==="ENOENT";this.emitErrorIfOpen({state:"error",message:u?"WorkBuddy was not found. Install WorkBuddy Desktop or the CodeBuddy CLI, then retry.":l(r.message)})})}handleStreamEvent(t){if(t.type==="system"&&t.subtype==="init"&&t.session_id){this.agentSessionId=t.session_id,this.runPhase="thinking",this.emitEvent({state:"start",agentSessionId:t.session_id});return}if(t.type==="control_request"&&t.request?.subtype==="can_use_tool"){this.runPhase="waiting_approval",this.emitEvent({state:"approval-pending",name:t.request.tool_name,args:t.request.input,approval:{title:`WorkBuddy \u8BF7\u6C42\u4F7F\u7528 ${t.request.tool_name||"\u5DE5\u5177"}`,source:"workbuddy",actionHint:"\u8BF7\u5728 WorkBuddy \u6216\u795E\u5FF5\u4E2D\u786E\u8BA4\u540E\u7EE7\u7EED\u3002"}});return}if(t.type==="assistant"){const n=t.message?.content;if(n?.length)for(const o of n)this.handleContentBlock(o);else t.text&&this.emitText(t.text,!!t.thinking);return}if(t.type!=="result")return;if(t.subtype==="tool_result"){this.runPhase="tool_running",this.emitEvent({state:"tool-result",name:t.name,result:g(t.content)});return}if(t.subtype==="error"||t.error){this.emitErrorIfOpen({state:"error",message:l(t.error||t.result||"WorkBuddy failed.")});return}!this.hasEmittedText&&t.result&&this.emitText(t.result,!1),t.session_id&&(this.agentSessionId=t.session_id);const e=t.usage??t.message?.usage;this.emitFinalIfOpen({state:"final",agentSessionId:this.agentSessionId??void 0,usage:e?{inputTokens:e.input_tokens??0,outputTokens:e.output_tokens??0}:void 0})}handleContentBlock(t){t.type==="text"&&t.text?this.emitText(t.text,!1):t.type==="thinking"&&t.thinking?this.emitText(t.thinking,!0):t.type==="tool_use"?(this.runPhase="tool_running",this.emitEvent({state:"tool-call",name:t.name,args:t.input})):t.type==="tool_result"&&this.emitEvent({state:"tool-result",name:t.name,result:g(t.content)})}emitText(t,e){this.runPhase=e?"thinking":"streaming_text";const n=!e&&this.hasEmittedText?`
1
+ import{spawnSync as g}from"node:child_process";import{createInterface as y}from"node:readline";import{randomUUID as w}from"node:crypto";import k from"node:path";import{AgentAdapter as I,registerAgent as S}from"./adapter.js";import{resolveBuiltinCommand as x,spawnAgentCommand as E}from"./command-spec.js";import{buildAgentProcessEnv as _}from"../agent-env.js";import{buildPlatformInstructions as B,ensurePlatformInstructionsFile as P}from"./platform-instructions.js";import{resolveWindowsSystemRoot as T}from"../windows-shell.js";const W=new Set(["minimal","low","medium","high","xhigh","max"]);function C(s){const t=s?.trim();return t&&t!=="auto"?t:void 0}function A(s){const t=s?.trim();if(t){if(W.has(t))return t;throw new Error(`Unsupported WorkBuddy reasoning effort "${t}". Supported values: minimal, low, medium, high, xhigh, max.`)}}function O(s,t,e){if(!s)return[];if(t==="win32"){if(!e)throw new Error("WorkBuddy system prompt file is required on Windows.");return["--system-prompt-file",e]}return["--append-system-prompt",s]}function q(s){const t=s.split(/\n\n(?=<[^>\n]+>\n)/);return(t[t.length-1]??s).replace(/^\[群消息\][ \t]+<[^>\n]+>\n/,"").replace(/^\[群消息\]\n?/,"").replace(/^<[^>\n]+>\n/,"").trim()}function p(s,t=process.platform,e=R){t==="win32"&&s.pid&&e(s.pid)||s.kill("SIGTERM")}function R(s){const t=k.win32.join(T(),"System32","taskkill.exe");return g(t,["/pid",String(s),"/T","/F"],{stdio:"ignore",windowsHide:!0,timeout:5e3}).status===0}class D extends I{type="workbuddy";process=null;agentSessionId=null;workDir=null;seq=0;runId="";terminalState="open";hasEmittedText=!1;runPhase=null;externalChannel=null;shennianSessionId=null;extraEnv={};configure(t){this.shennianSessionId=t.sessionId??null,this.externalChannel=t.externalChannel??null,this.extraEnv=t.env??{}}async start(t,e,n){this.workDir=e,this.seq=0,n&&(this.agentSessionId=n)}async send(t,e,n,o,a,r){await this.killProcess(),this.runId=w(),this.resetRunState();const u=r?.source==="room_activation",i=["-p",u?q(t):t,"--output-format","stream-json","--verbose","--permission-mode","bypassPermissions","--setting-sources","user,project,local"],d=C(e);d&&i.push("--model",d),i.push("--tools","default"),u&&i.push("--max-turns","8");const h=this.shennianSessionId?.startsWith("room-managed-")&&!this.agentSessionId&&!u?null:B(this.workDir??process.cwd(),this.externalChannel,this.shennianSessionId??void 0,a);if(h){const c=process.platform==="win32"?P(this.workDir??process.cwd(),this.externalChannel,this.shennianSessionId??void 0,a):void 0;i.push(...O(h,process.platform,c))}const m=A(n);m&&i.push("--effort",m),this.agentSessionId&&i.push("--resume",this.agentSessionId),this.spawnAndParse(i)}async resume(t){await this.killProcess(),this.agentSessionId=t,this.resetRunState()}async stop(){await this.killProcess()}async getStatus(){return{active:this.process!=null&&this.terminalState==="open",runId:this.runId||null,runPhase:this.runPhase,canStop:this.process!=null&&this.terminalState==="open"}}spawnAndParse(t){const e=x("workbuddy");if(!e){this.emit("error",new Error("WorkBuddy was not found. Install WorkBuddy Desktop or the CodeBuddy CLI, then retry."));return}const n=E(e,t,{cwd:this.workDir??void 0,stdio:["ignore","pipe","pipe"],env:_(this.extraEnv)});this.process=n,y({input:n.stdout}).on("line",r=>{if(r.trim())try{this.handleStreamEvent(JSON.parse(r))}catch{}});let a="";n.stderr?.on("data",r=>{a=`${a}${r.toString()}`.slice(-8e3)}),n.on("close",r=>{this.process===n&&(this.process=null,this.runPhase=null,this.handleProcessClose(r,a))}),n.on("error",r=>{if(this.process!==n)return;this.process=null,this.runPhase=null;const u=r.code==="ENOENT";this.emitErrorIfOpen({state:"error",message:u?"WorkBuddy was not found. Install WorkBuddy Desktop or the CodeBuddy CLI, then retry.":l(r.message)})})}handleStreamEvent(t){if(t.type==="system"&&t.subtype==="init"&&t.session_id){this.agentSessionId=t.session_id,this.runPhase="thinking",this.emitEvent({state:"start",agentSessionId:t.session_id});return}if(t.type==="control_request"&&t.request?.subtype==="can_use_tool"){this.runPhase="waiting_approval",this.emitEvent({state:"approval-pending",name:t.request.tool_name,args:t.request.input,approval:{title:`WorkBuddy \u8BF7\u6C42\u4F7F\u7528 ${t.request.tool_name||"\u5DE5\u5177"}`,source:"workbuddy",actionHint:"\u8BF7\u5728 WorkBuddy \u6216\u795E\u5FF5\u4E2D\u786E\u8BA4\u540E\u7EE7\u7EED\u3002"}});return}if(t.type==="assistant"){const n=t.message?.content;if(n?.length)for(const o of n)this.handleContentBlock(o);else t.text&&this.emitText(t.text,!!t.thinking);return}if(t.type!=="result")return;if(t.subtype==="tool_result"){this.runPhase="tool_running",this.emitEvent({state:"tool-result",name:t.name,result:f(t.content)});return}if(t.subtype==="error"||t.error){this.emitErrorIfOpen({state:"error",message:l(t.error||t.result||"WorkBuddy failed.")});return}!this.hasEmittedText&&t.result&&this.emitText(t.result,!1),t.session_id&&(this.agentSessionId=t.session_id);const e=t.usage??t.message?.usage;this.emitFinalIfOpen({state:"final",agentSessionId:this.agentSessionId??void 0,usage:e?{inputTokens:e.input_tokens??0,outputTokens:e.output_tokens??0}:void 0})}handleContentBlock(t){t.type==="text"&&t.text?this.emitText(t.text,!1):t.type==="thinking"&&t.thinking?this.emitText(t.thinking,!0):t.type==="tool_use"?(this.runPhase="tool_running",this.emitEvent({state:"tool-call",name:t.name,args:t.input})):t.type==="tool_result"&&this.emitEvent({state:"tool-result",name:t.name,result:f(t.content)})}emitText(t,e){this.runPhase=e?"thinking":"streaming_text";const n=!e&&this.hasEmittedText?`
2
2
 
3
- `:"";this.emitEvent({state:"delta",text:n+t,thinking:e||void 0}),e||(this.hasEmittedText=!0)}handleProcessClose(t,e){if(t!==0&&t!==null){this.emitErrorIfOpen({state:"error",message:l(e)||`WorkBuddy exited with code ${t}.`});return}this.emitFinalIfOpen({state:"final",agentSessionId:this.agentSessionId??void 0})}emitFinalIfOpen(t){this.terminalState==="open"&&(this.terminalState="final",this.runPhase=null,this.emitEvent(t))}emitErrorIfOpen(t){this.terminalState==="open"&&(this.terminalState="error",this.runPhase=null,this.emitEvent(t))}emitEvent(t){this.emit("agentEvent",{...t,runId:this.runId,seq:this.seq++})}resetRunState(){this.seq=0,this.terminalState="open",this.hasEmittedText=!1,this.runPhase=null}async killProcess(){const t=this.process;t&&(this.process=null,this.runPhase=null,f(t),await new Promise(e=>{let n=!1;const o=()=>{n||(n=!0,e())};t.once("close",o),setTimeout(()=>{f(t),o()},3e3).unref?.()}))}}function g(s){if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return"[unserializable WorkBuddy tool result]"}}function l(s){return s.replace(/(Authorization\s*:\s*)Bearer\s+[A-Za-z0-9._~+/-]+/gi,"$1Bearer [redacted]").replace(/(api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|connector[-_ ]?token)(\s*[:=]\s*)[^\s,;]+/gi,"$1$2[redacted]").trim().slice(0,2e3)}_("workbuddy",()=>new z);export{z as WorkBuddyAdapter,q as normalizeWorkBuddyModelId,D as normalizeWorkBuddyReasoningEffort,l as sanitizeWorkBuddyError,f as terminateWorkBuddyProcess,F as workBuddyRoomActivationText,$ as workBuddySystemPromptArgs};
3
+ `:"";this.emitEvent({state:"delta",text:n+t,thinking:e||void 0}),e||(this.hasEmittedText=!0)}handleProcessClose(t,e){if(t!==0&&t!==null){this.emitErrorIfOpen({state:"error",message:l(e)||`WorkBuddy exited with code ${t}.`});return}this.emitFinalIfOpen({state:"final",agentSessionId:this.agentSessionId??void 0})}emitFinalIfOpen(t){this.terminalState==="open"&&(this.terminalState="final",this.runPhase=null,this.emitEvent(t))}emitErrorIfOpen(t){this.terminalState==="open"&&(this.terminalState="error",this.runPhase=null,this.emitEvent(t))}emitEvent(t){this.emit("agentEvent",{...t,runId:this.runId,seq:this.seq++})}resetRunState(){this.seq=0,this.terminalState="open",this.hasEmittedText=!1,this.runPhase=null}async killProcess(){const t=this.process;t&&(this.process=null,this.runPhase=null,p(t),await new Promise(e=>{let n=!1;const o=()=>{n||(n=!0,e())};t.once("close",o),setTimeout(()=>{p(t),o()},3e3).unref?.()}))}}function f(s){if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return"[unserializable WorkBuddy tool result]"}}function l(s){return s.replace(/(Authorization\s*:\s*)Bearer\s+[A-Za-z0-9._~+/-]+/gi,"$1Bearer [redacted]").replace(/(api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|connector[-_ ]?token)(\s*[:=]\s*)[^\s,;]+/gi,"$1$2[redacted]").trim().slice(0,2e3)}S("workbuddy",()=>new D);export{D as WorkBuddyAdapter,C as normalizeWorkBuddyModelId,A as normalizeWorkBuddyReasoningEffort,l as sanitizeWorkBuddyError,p as terminateWorkBuddyProcess,q as workBuddyRoomActivationText,O as workBuddySystemPromptArgs};
@@ -1,2 +1,7 @@
1
1
  import type { Command } from 'commander';
2
- export declare function registerAgentCommand(program: Command): void;
2
+ type FetchLike = typeof fetch;
3
+ type AgentCommandOptions = {
4
+ fetchImpl?: FetchLike;
5
+ };
6
+ export declare function registerAgentCommand(program: Command, options?: AgentCommandOptions): void;
7
+ export {};
@@ -1,6 +1,3 @@
1
- import o from"chalk";import{loadConfig as d,saveConfig as l}from"../config/index.js";import{spawnCommandString as p}from"../agents/command-spec.js";function g(m){return m.models?.length?m.models:m.model?[m.model]:[]}async function u(m){return new Promise((c,e)=>{const n=p(m,["/caps"],{stdio:["ignore","pipe","pipe"]});let s="",t="";n.stdout?.on("data",r=>{s+=r.toString()}),n.stderr?.on("data",r=>{t+=r.toString()}),n.on("error",r=>e(new Error(`Failed to run command: ${r.message}`))),n.on("close",r=>{const i=s.trim().split(`
2
- `).find(a=>a.trim().startsWith("{"));if(!i){e(new Error(`Command did not output valid caps JSON.
3
- stdout: ${s.trim()}
4
- stderr: ${t.trim()}`));return}try{const a=JSON.parse(i);if(!a.name||!a.mode){e(new Error('Caps JSON must contain "name" and "mode" fields'));return}if(g(a).length===0){e(new Error('Caps JSON must contain either "model" or a non-empty "models" array'));return}if(a.mode!=="spawn"&&a.mode!=="stdio"){e(new Error(`Caps "mode" must be "spawn" or "stdio", got: ${a.mode}`));return}c(a)}catch{e(new Error(`Failed to parse caps JSON: ${i}`))}}),setTimeout(()=>{n.kill("SIGTERM"),e(new Error("Timed out waiting for caps response (5s)"))},5e3)})}function $(m){const c=m.command("agent").description("Manage custom agents");c.command("add <name>").description("Register a custom agent").requiredOption("--command <cmd>",'Command to run the agent (e.g. "python /path/agent.py")').action(async(e,n)=>{/^[a-zA-Z0-9_-]+$/.test(e)||(console.error(o.red("\u2717 Agent name must contain only letters, numbers, hyphens, and underscores")),process.exit(1)),console.log(o.gray(`Probing caps: ${n.command} /caps ...`));let s;try{s=await u(n.command)}catch(r){console.error(o.red(`\u2717 ${r instanceof Error?r.message:String(r)}`)),process.exit(1)}const t=d();t.customAgents=t.customAgents??{},t.customAgents[e]={command:n.command,caps:s},l(t),console.log(o.green(`\u2713 Agent "${e}" registered`)),console.log(o.gray(` Name: ${s.name}`)),console.log(o.gray(` Models: ${g(s).join(", ")}`)),console.log(o.gray(` Mode: ${s.mode}`)),s.version&&console.log(o.gray(` Version: ${s.version}`)),console.log(),console.log(o.yellow(` The agent will appear as "custom:${e}" in the Shennian app.`)),console.log(o.yellow(" Refresh Agents in the app to hot-reload this daemon, or restart the daemon as a fallback."))}),c.command("list").description("List registered custom agents").action(()=>{const e=d(),n=Object.entries(e.customAgents??{});if(n.length===0){console.log(o.gray("No custom agents registered.")),console.log(o.gray('Add one with: shennian agent add <name> --command "<cmd>"'));return}console.log(o.bold(`
5
- Custom agents:
6
- `));for(const[s,t]of n){const r=t.caps.models?.length?t.caps.models.join(", "):t.caps.model??"(none)";console.log(` ${o.cyan(s)}`),console.log(` ${o.gray("display:")} ${t.caps.name}`),console.log(` ${o.gray("models:")} ${r}`),console.log(` ${o.gray("mode:")} ${t.caps.mode}`),console.log(` ${o.gray("command:")} ${t.command}`),console.log()}}),c.command("remove <name>").description("Unregister a custom agent").action(e=>{const n=d();n.customAgents?.[e]||(console.error(o.red(`\u2717 No agent named "${e}"`)),process.exit(1)),delete n.customAgents[e],l(n),console.log(o.green(`\u2713 Agent "${e}" removed`)),console.log(o.yellow(" Refresh Agents in the app to hot-reload this daemon, or restart the daemon as a fallback."))})}export{$ as registerAgentCommand};
1
+ import{loadConfig as f}from"../config/index.js";import{SERVERS as A}from"../region.js";function k(t,n={}){const e=w(n.fetchImpl??fetch),a=t.command("agent").description("Create and manage stable Shennian Agents");a.command("create").description("Create a stable Agent owned by the paired user").requiredOption("--name <name>","Agent display name").requiredOption("--description <description>","Public Agent responsibility").requiredOption("--runtime <runtime>","Agent runtime, for example codex or claude").requiredOption("--workdir <absolute-path>","Absolute working directory").option("--model <model>","Default model").option("--system-prompt <prompt>","Private system prompt").action(async o=>{await u("agent.create",()=>e("POST","/api/agents",{displayName:o.name,description:o.description,runtimeAdapter:o.runtime,workDir:o.workdir,...o.model!=null?{modelId:o.model}:{},...o.systemPrompt!=null?{systemPrompt:o.systemPrompt}:{}}))}),a.command("get <agent-ref>").description("Get one explicitly referenced stable Agent").action(async o=>{const r=g(o);if(!r)return d("invalid_agent_ref","agent-ref is invalid.",null);await u("agent.get",()=>e("GET",`/api/agents/${encodeURIComponent(r)}`))}),a.command("update <agent-ref>").description("Update fields on one explicitly referenced stable Agent").option("--name <name>","Agent display name").option("--description <description>","Public Agent responsibility").option("--runtime <runtime>","Agent runtime").option("--workdir <absolute-path>","Absolute working directory").option("--model <model>","Default model; use an empty value to clear").option("--system-prompt <prompt>","Private system prompt; use an empty value to clear").action(async(o,r)=>{const s=g(o);if(!s)return d("invalid_agent_ref","agent-ref is invalid.",null);const i={};if(r.name!=null&&(i.displayName=r.name),r.description!=null&&(i.description=r.description),r.runtime!=null&&(i.runtimeAdapter=r.runtime),r.workdir!=null&&(i.workDir=r.workdir),r.model!=null&&(i.modelId=r.model),r.systemPrompt!=null&&(i.systemPrompt=r.systemPrompt),Object.keys(i).length===0)return d("no_changes","Provide at least one field to update.",null);await u("agent.update",()=>e("PATCH",`/api/agents/${encodeURIComponent(s)}`,i))}),l(a,"add"),l(a,"list"),l(a,"remove")}function l(t,n){const e=n==="list"?n:`${n} [name]`;t.command(e,{hidden:!0}).allowUnknownOption(!0).description(`Moved to shennian runtime ${n}`).action(()=>d("command_moved",`Custom runtime management moved to "shennian runtime ${n}".`,{type:"run_command",command:`shennian runtime ${n}`}))}function w(t){return async(n,e,a)=>{const o=f();if(!o.machineToken)throw new m("not_paired","Shennian CLI is not paired.",{type:"run_command",command:"shennian pair --browser"});const r=(o.serverUrl??A.cn.url).replace(/\/+$/,"");let s;try{s=await t(`${r}${e}`,{method:n,headers:{authorization:`Bearer ${o.machineToken}`,...a==null?{}:{"content-type":"application/json"}},...a==null?{}:{body:JSON.stringify(a)},signal:AbortSignal.timeout(15e3)})}catch{throw new m("server_unavailable","Shennian service is unavailable.",null)}const i=await h(s);if(!s.ok){const p=y(i)?i:{};throw new m(typeof p.code=="string"?`agent_${p.code}`:`http_${s.status}`,typeof p.error=="string"?p.error:"Agent request failed.",null)}const c=y(i)&&y(i.agent)?i.agent:null;if(!c||typeof c.id!="string"||typeof c.displayName!="string")throw new m("invalid_server_response","Shennian returned an invalid Agent response.",null);return c}}async function u(t,n){try{const e=await n();process.stdout.write(`${JSON.stringify({ok:!0,command:t,result:{agentRef:e.id,name:e.displayName,description:e.description,runtime:e.runtimeAdapter,workdir:e.workDir,model:e.modelId,systemPromptConfigured:!!e.systemPrompt,avatar:e.avatar??null,status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt}})}
2
+ `)}catch(e){if(e instanceof m){d(e.code,e.message,e.nextAction);return}d("agent_command_failed","Shennian Agent command failed.",null)}}class m extends Error{code;nextAction;constructor(n,e,a){super(e),this.code=n,this.nextAction=a}}function g(t){const n=t.startsWith("agent:")?t.slice(6):t;return/^[A-Za-z0-9_-]{1,191}$/.test(n)?n:null}async function h(t){try{return await t.json()}catch{return null}}function y(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function d(t,n,e){process.stdout.write(`${JSON.stringify({ok:!1,error:t,message:n,nextAction:e})}
3
+ `),process.exitCode=1}export{k as registerAgentCommand};
@@ -1,2 +1,3 @@
1
1
  import type { Command } from 'commander';
2
+ /** Compatibility tombstone. Shennian no longer writes third-party host config. */
2
3
  export declare function registerIntegrationCommand(program: Command): void;
@@ -1 +1,2 @@
1
- import{WorkBuddyPluginLifecycle as l,WorkBuddyPluginLifecycleError as f}from"../integrations/workbuddy-plugin-lifecycle.js";import{CodexRoomPluginLifecycle as m}from"../integrations/codex-room-plugin-lifecycle.js";import{ClaudeRoomPluginLifecycle as y}from"../integrations/claude-room-plugin-lifecycle.js";import{RoomPluginLifecycleError as p}from"../integrations/room-plugin-lifecycle-common.js";const d=["The official Shennian Agent connection installs a local Skill, MCP tool, and lifecycle Hooks with your user permissions.","It reports only the current native Session identifier and lifecycle metadata to the local authenticated Shennian daemon.","It does not send prompts, transcript contents, credentials, or native Session identifiers to a Room or remote URL.","You can disable or remove it at any time."].join(" ");function k(t){const o=t.command("integration").description("Manage local Agent integrations");u(o,"codex","Codex",()=>new m),u(o,"claude-code","Claude Code",()=>new y);const e=o.command("workbuddy").description("Manage the official WorkBuddy connection");e.command("status",{isDefault:!0}).option("--json","Print JSON",!1).action(async n=>{await r(()=>new l().status(),!!n.json)});for(const n of["install","enable","disable","update","uninstall"])e.command(n).option("--confirm-user-action","Confirm this action was explicitly requested by the user",!1).option("--json","Print JSON",!1).action(async i=>{if(!i.confirmUserAction){s({ok:!1,errorCode:"user_confirmation_required",disclosure:d},!!i.json),process.exitCode=2;return}await r(()=>new l().apply(n),!!i.json)})}function u(t,o,e,n){const i=t.command(o).description(`Manage the official ${e} connection`);i.command("status",{isDefault:!0}).option("--json","Print JSON",!1).action(async a=>{await r(()=>n().status(),!!a.json)});for(const a of["install","enable","disable","update","uninstall"])i.command(a).option("--confirm-user-action","Confirm this action was explicitly requested by the user",!1).option("--json","Print JSON",!1).action(async c=>{if(!c.confirmUserAction){s({ok:!1,errorCode:"user_confirmation_required",disclosure:d},!!c.json),process.exitCode=2;return}await r(()=>n().apply(a),!!c.json)})}async function r(t,o){try{const e=await t();s({ok:!0,result:e},o)}catch(e){const n=e instanceof f||e instanceof p?e.code:"integration_failed";s({ok:!1,errorCode:n},o),process.exitCode=1}}function s(t,o){console.log(o?JSON.stringify(t):JSON.stringify(t,null,2))}export{k as registerIntegrationCommand};
1
+ function t(n){n.command("integration",{hidden:!0}).allowUnknownOption(!0).allowExcessArguments(!0).action(()=>{process.stdout.write(`${JSON.stringify({ok:!1,error:"integration_command_retired",message:"Shennian no longer installs MCP, Hooks, or host integrations. Install the official Shennian Skill with your Agent host.",nextAction:{type:"open_install_guide",url:"https://shennian.net/install.md"}})}
2
+ `),process.exitCode=1})}export{t as registerIntegrationCommand};