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.
- package/README.md +1 -0
- package/dist/publish-build-manifest.json +73 -168
- package/dist/src/agents/detect.js +1 -1
- package/dist/src/agents/manager.d.ts +36 -0
- package/dist/src/agents/manager.js +11 -6
- package/dist/src/agents/model-registry/service.js +1 -1
- package/dist/src/agents/workbuddy.js +2 -2
- package/dist/src/commands/agent.d.ts +6 -1
- package/dist/src/commands/agent.js +3 -6
- package/dist/src/commands/integration.d.ts +1 -0
- package/dist/src/commands/integration.js +2 -1
- package/dist/src/commands/manager.js +1 -1
- package/dist/src/commands/pair-authorization.d.ts +3 -0
- package/dist/src/commands/pair-authorization.js +1 -0
- package/dist/src/commands/pair-browser.js +1 -1
- package/dist/src/commands/room.d.ts +9 -17
- package/dist/src/commands/room.js +3 -8
- package/dist/src/commands/runtime.d.ts +2 -0
- package/dist/src/commands/runtime.js +6 -0
- package/dist/src/daemon-ipc/client.d.ts +1 -1
- package/dist/src/daemon-ipc/json.d.ts +3 -0
- package/dist/src/daemon-ipc/json.js +1 -0
- package/dist/src/daemon-ipc/protocol.d.ts +1 -1
- package/dist/src/daemon-ipc/server.d.ts +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/manager/registry.d.ts +21 -0
- package/dist/src/manager/registry.js +2 -2
- package/dist/src/manager/runtime.d.ts +5 -1
- package/dist/src/manager/runtime.js +14 -13
- package/dist/src/room/activation-service.d.ts +6 -0
- package/dist/src/room/activation-service.js +5 -8
- package/dist/src/room/attachment-cache.d.ts +2 -1
- package/dist/src/room/attachment-cache.js +2 -2
- package/dist/src/room/device-authorization-client.d.ts +39 -1
- package/dist/src/room/managed-context.d.ts +45 -0
- package/dist/src/room/managed-context.js +1 -0
- package/dist/src/room/managed-prompt-composer.d.ts +32 -0
- package/dist/src/room/managed-prompt-composer.js +24 -0
- package/dist/src/room/managed-room-ipc.d.ts +16 -0
- package/dist/src/room/managed-room-ipc.js +1 -0
- package/dist/src/room/mirror-sync-service.d.ts +2 -5
- package/dist/src/room/mirror-sync-service.js +1 -1
- package/dist/src/room/public-attachment-cache.d.ts +34 -0
- package/dist/src/room/public-attachment-cache.js +2 -0
- package/dist/src/room/public-room-client.d.ts +36 -0
- package/dist/src/room/public-room-client.js +1 -0
- package/dist/src/room/room-action-client.d.ts +3 -1
- package/dist/src/room/room-action-client.js +1 -1
- package/dist/src/room/session-registry.d.ts +7 -0
- package/dist/src/room/session-registry.js +2 -2
- package/dist/src/session/handlers/chat.d.ts +5 -1
- package/dist/src/session/handlers/chat.js +2 -2
- package/dist/src/session/manager.d.ts +1 -20
- package/dist/src/session/manager.js +1 -1
- package/dist/src/session/queue.js +3 -3
- package/dist/src/session/store.d.ts +9 -1
- package/dist/src/session/store.js +3 -3
- package/dist/src/session/types.d.ts +2 -1
- package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/agent-capabilities.js +0 -1
- package/node_modules/@shennian/wire/dist/agent-workspace.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/agent-workspace.js +0 -1
- package/node_modules/@shennian/wire/dist/envelope.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/envelope.js +0 -1
- package/node_modules/@shennian/wire/dist/events.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/events.js +0 -1
- package/node_modules/@shennian/wire/dist/external-message-format.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/external-message-format.js +0 -1
- package/node_modules/@shennian/wire/dist/frames.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/frames.js +0 -1
- package/node_modules/@shennian/wire/dist/fs.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/fs.js +0 -1
- package/node_modules/@shennian/wire/dist/index.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/index.js +0 -1
- package/node_modules/@shennian/wire/dist/machine.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/machine.js +0 -1
- package/node_modules/@shennian/wire/dist/message-payload.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/message-payload.js +0 -1
- package/node_modules/@shennian/wire/dist/methods.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/methods.js +0 -1
- package/node_modules/@shennian/wire/dist/native-session.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/native-session.js +0 -1
- package/node_modules/@shennian/wire/dist/project.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/project.js +0 -1
- package/node_modules/@shennian/wire/dist/room.d.ts +44 -1
- package/node_modules/@shennian/wire/dist/room.js +0 -1
- package/node_modules/@shennian/wire/dist/session.d.ts +18 -3
- package/node_modules/@shennian/wire/dist/session.js +0 -2
- package/node_modules/@shennian/wire/dist/tool-detail.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/tool-detail.js +0 -1
- package/node_modules/@shennian/wire/dist/voice-chief.d.ts +0 -1
- package/node_modules/@shennian/wire/dist/voice-chief.js +0 -1
- package/node_modules/@shennian/wire/package.json +1 -0
- package/package.json +2 -2
- package/dist/src/integrations/claude-room-plugin-lifecycle.d.ts +0 -47
- package/dist/src/integrations/claude-room-plugin-lifecycle.js +0 -1
- package/dist/src/integrations/codex-room-plugin-lifecycle.d.ts +0 -49
- package/dist/src/integrations/codex-room-plugin-lifecycle.js +0 -1
- package/dist/src/integrations/room-plugin-bundles.d.ts +0 -23
- package/dist/src/integrations/room-plugin-bundles.js +0 -1
- package/dist/src/integrations/room-plugin-lifecycle-common.d.ts +0 -17
- package/dist/src/integrations/room-plugin-lifecycle-common.js +0 -1
- package/dist/src/integrations/room-plugin-shared.d.ts +0 -24
- package/dist/src/integrations/room-plugin-shared.js +0 -38
- package/dist/src/integrations/room-session-hook.d.ts +0 -30
- package/dist/src/integrations/room-session-hook.js +0 -2
- package/dist/src/integrations/workbuddy-plugin-bundle.d.ts +0 -16
- package/dist/src/integrations/workbuddy-plugin-bundle.js +0 -1
- package/dist/src/integrations/workbuddy-plugin-lifecycle.d.ts +0 -62
- package/dist/src/integrations/workbuddy-plugin-lifecycle.js +0 -2
- package/dist/src/integrations/workbuddy-session-hook.d.ts +0 -22
- package/dist/src/integrations/workbuddy-session-hook.js +0 -1
- package/dist/src/room/agent-tool.d.ts +0 -63
- package/dist/src/room/agent-tool.js +0 -1
- package/dist/src/room/authorized-action-coordinator.d.ts +0 -40
- package/dist/src/room/authorized-action-coordinator.js +0 -1
- package/dist/src/room/authorized-action-ipc.d.ts +0 -11
- package/dist/src/room/authorized-action-ipc.js +0 -1
- package/dist/src/room/host-session-observation-ipc.d.ts +0 -9
- package/dist/src/room/host-session-observation-ipc.js +0 -1
- package/dist/src/room/invocation-token-ipc.d.ts +0 -9
- package/dist/src/room/invocation-token-ipc.js +0 -1
- package/dist/src/room/invocation-token.d.ts +0 -53
- package/dist/src/room/invocation-token.js +0 -1
- package/dist/src/room/jsonl-mirror.d.ts +0 -73
- package/dist/src/room/jsonl-mirror.js +0 -6
- package/dist/src/room/managed-room-session-runtime.d.ts +0 -18
- package/dist/src/room/managed-room-session-runtime.js +0 -1
- package/dist/src/room/managed-room-session.d.ts +0 -144
- package/dist/src/room/managed-room-session.js +0 -2
- package/dist/src/room/operator-ipc.d.ts +0 -13
- package/dist/src/room/operator-ipc.js +0 -1
- package/dist/src/room/pending-authorized-actions.d.ts +0 -69
- package/dist/src/room/pending-authorized-actions.js +0 -3
- package/dist/src/room/room-action-ipc.d.ts +0 -34
- package/dist/src/room/room-action-ipc.js +0 -1
- package/dist/src/room/room-action-schema.d.ts +0 -3
- package/dist/src/room/room-action-schema.js +0 -1
- package/dist/src/room/room-authorized-action-executor.d.ts +0 -23
- package/dist/src/room/room-authorized-action-executor.js +0 -1
- package/dist/src/room/room-binding-ipc.d.ts +0 -31
- package/dist/src/room/room-binding-ipc.js +0 -1
- package/dist/src/room/session-registry-ipc.d.ts +0 -14
- package/dist/src/room/session-registry-ipc.js +0 -1
- package/dist/src/room/tool-schema.d.ts +0 -120
- package/dist/src/room/tool-schema.js +0 -1
- package/dist/src/room/tool-server.d.ts +0 -11
- package/dist/src/room/tool-server.js +0 -3
- package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.d.ts +0 -2
- package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.js +0 -23
- package/node_modules/@shennian/wire/dist/__tests__/message-payload.test.js.map +0 -1
- package/node_modules/@shennian/wire/dist/__tests__/mock.test.d.ts +0 -2
- package/node_modules/@shennian/wire/dist/__tests__/mock.test.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/__tests__/mock.test.js +0 -66
- package/node_modules/@shennian/wire/dist/__tests__/mock.test.js.map +0 -1
- package/node_modules/@shennian/wire/dist/__tests__/types.test.d.ts +0 -2
- package/node_modules/@shennian/wire/dist/__tests__/types.test.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/__tests__/types.test.js +0 -159
- package/node_modules/@shennian/wire/dist/__tests__/types.test.js.map +0 -1
- package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/agent-capabilities.js.map +0 -1
- package/node_modules/@shennian/wire/dist/agent-workspace.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/agent-workspace.js.map +0 -1
- package/node_modules/@shennian/wire/dist/envelope.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/envelope.js.map +0 -1
- package/node_modules/@shennian/wire/dist/events.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/events.js.map +0 -1
- package/node_modules/@shennian/wire/dist/external-message-format.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/external-message-format.js.map +0 -1
- package/node_modules/@shennian/wire/dist/frames.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/frames.js.map +0 -1
- package/node_modules/@shennian/wire/dist/fs.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/fs.js.map +0 -1
- package/node_modules/@shennian/wire/dist/index.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/index.js.map +0 -1
- package/node_modules/@shennian/wire/dist/machine.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/machine.js.map +0 -1
- package/node_modules/@shennian/wire/dist/message-payload.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/message-payload.js.map +0 -1
- package/node_modules/@shennian/wire/dist/methods.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/methods.js.map +0 -1
- package/node_modules/@shennian/wire/dist/mock/fixtures.d.ts +0 -39
- package/node_modules/@shennian/wire/dist/mock/fixtures.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/mock/fixtures.js +0 -99
- package/node_modules/@shennian/wire/dist/mock/fixtures.js.map +0 -1
- package/node_modules/@shennian/wire/dist/mock/index.d.ts +0 -3
- package/node_modules/@shennian/wire/dist/mock/index.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/mock/index.js +0 -4
- package/node_modules/@shennian/wire/dist/mock/index.js.map +0 -1
- package/node_modules/@shennian/wire/dist/mock/routes.d.ts +0 -96
- package/node_modules/@shennian/wire/dist/mock/routes.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/mock/routes.js +0 -40
- package/node_modules/@shennian/wire/dist/mock/routes.js.map +0 -1
- package/node_modules/@shennian/wire/dist/native-session.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/native-session.js.map +0 -1
- package/node_modules/@shennian/wire/dist/project.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/project.js.map +0 -1
- package/node_modules/@shennian/wire/dist/queue.d.ts +0 -15
- package/node_modules/@shennian/wire/dist/queue.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/queue.js +0 -2
- package/node_modules/@shennian/wire/dist/queue.js.map +0 -1
- package/node_modules/@shennian/wire/dist/room.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/room.js.map +0 -1
- package/node_modules/@shennian/wire/dist/session.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/session.js.map +0 -1
- package/node_modules/@shennian/wire/dist/skills.d.ts +0 -61
- package/node_modules/@shennian/wire/dist/skills.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/skills.js +0 -2
- package/node_modules/@shennian/wire/dist/skills.js.map +0 -1
- package/node_modules/@shennian/wire/dist/tool-detail.d.ts.map +0 -1
- package/node_modules/@shennian/wire/dist/tool-detail.js.map +0 -1
- package/node_modules/@shennian/wire/dist/voice-chief.d.ts.map +0 -1
- 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":
|
|
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":
|
|
60
|
-
"afterBytes":
|
|
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":
|
|
75
|
-
"afterBytes":
|
|
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":
|
|
100
|
-
"afterBytes":
|
|
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":
|
|
140
|
-
"afterBytes":
|
|
139
|
+
"beforeBytes": 14265,
|
|
140
|
+
"afterBytes": 7150
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
"file": "src/commands/agent.js",
|
|
144
|
-
"beforeBytes":
|
|
145
|
-
"afterBytes":
|
|
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":
|
|
170
|
-
"afterBytes":
|
|
169
|
+
"beforeBytes": 815,
|
|
170
|
+
"afterBytes": 468
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
"file": "src/commands/manager.js",
|
|
174
|
-
"beforeBytes":
|
|
175
|
-
"afterBytes":
|
|
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":
|
|
180
|
-
"afterBytes":
|
|
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":
|
|
195
|
-
"afterBytes":
|
|
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":
|
|
270
|
-
"afterBytes":
|
|
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":
|
|
330
|
-
"afterBytes":
|
|
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":
|
|
340
|
-
"afterBytes":
|
|
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":
|
|
405
|
-
"afterBytes":
|
|
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":
|
|
415
|
-
"afterBytes":
|
|
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/
|
|
454
|
-
"beforeBytes":
|
|
455
|
-
"afterBytes":
|
|
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/
|
|
464
|
-
"beforeBytes":
|
|
465
|
-
"afterBytes":
|
|
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-
|
|
474
|
-
"beforeBytes":
|
|
475
|
-
"afterBytes":
|
|
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":
|
|
485
|
-
"afterBytes":
|
|
424
|
+
"beforeBytes": 7714,
|
|
425
|
+
"afterBytes": 3498
|
|
486
426
|
},
|
|
487
427
|
{
|
|
488
|
-
"file": "src/room/
|
|
489
|
-
"beforeBytes":
|
|
490
|
-
"afterBytes":
|
|
428
|
+
"file": "src/room/public-attachment-cache.js",
|
|
429
|
+
"beforeBytes": 10361,
|
|
430
|
+
"afterBytes": 5048
|
|
491
431
|
},
|
|
492
432
|
{
|
|
493
|
-
"file": "src/room/
|
|
494
|
-
"beforeBytes":
|
|
495
|
-
"afterBytes":
|
|
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":
|
|
500
|
-
"afterBytes":
|
|
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":
|
|
535
|
-
"afterBytes":
|
|
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":
|
|
570
|
-
"afterBytes":
|
|
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":
|
|
605
|
-
"afterBytes":
|
|
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":
|
|
615
|
-
"afterBytes":
|
|
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":
|
|
625
|
-
"afterBytes":
|
|
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
|
|
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
|
|
2
|
-
\u9ED8\u8BA4 worker \u6A21\u578B\uFF1A${
|
|
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
|
-
${
|
|
6
|
+
${y}`,a?`## Worker Defaults
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${a}`:"",r?`## External Message Channel Instructions
|
|
9
9
|
|
|
10
|
-
${r}`:"",
|
|
10
|
+
${r}`:"",S].filter(Boolean).join(`
|
|
11
11
|
|
|
12
12
|
`)}
|
|
13
|
-
`}function
|
|
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
|
|
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
|
|
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,
|
|
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
|
-
|
|
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
|
|
2
|
-
`).
|
|
3
|
-
|
|
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 +1,2 @@
|
|
|
1
|
-
|
|
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};
|