evolcore 0.0.11 → 0.0.13

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 (164) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/bin/codex-managed-hook.mjs +80 -0
  3. package/bin/ec-safe-output.js +26 -7
  4. package/dist/agents/claude-runner.js +86 -7
  5. package/dist/agents/codex-app-server-client.js +174 -20
  6. package/dist/agents/codex-runner.js +375 -92
  7. package/dist/agents/ecagent-runner.js +39 -4
  8. package/dist/agents/gemini-runner.js +1 -0
  9. package/dist/aun/aid/client.js +11 -21
  10. package/dist/aun/aid/control-aid.js +36 -13
  11. package/dist/aun/aid/managed-operation.js +107 -0
  12. package/dist/aun/aid/store.js +13 -7
  13. package/dist/aun/group-fs-download.js +56 -0
  14. package/dist/aun/group-identity.js +1 -2
  15. package/dist/aun/msg/group.js +91 -44
  16. package/dist/aun/msg/index.js +1 -2
  17. package/dist/aun/msg/managed-operation.js +865 -0
  18. package/dist/aun/msg/mention-schema.js +20 -0
  19. package/dist/aun/msg/p2p.js +7 -0
  20. package/dist/aun/msg/upload.js +16 -1
  21. package/dist/aun/outbox.js +31 -2
  22. package/dist/aun/rpc/client.js +66 -0
  23. package/dist/aun/rpc/index.js +1 -2
  24. package/dist/aun/storage/{upload.js → client.js} +11 -2
  25. package/dist/aun/storage/index.js +1 -2
  26. package/dist/channels/aun.js +655 -240
  27. package/dist/channels/daemon.js +13 -0
  28. package/dist/cli/agent-command.js +56 -8
  29. package/dist/cli/agent.js +108 -31
  30. package/dist/cli/aun-commands.js +270 -69
  31. package/dist/cli/bench.js +12 -3
  32. package/dist/cli/cli-argv.js +10 -0
  33. package/dist/cli/config.js +9 -17
  34. package/dist/cli/ctl-command.js +1 -1
  35. package/dist/cli/daemon-commands.js +70 -55
  36. package/dist/cli/fs-command.js +79 -10
  37. package/dist/cli/handoff-command.js +3 -0
  38. package/dist/cli/index.js +30 -2
  39. package/dist/cli/init.js +77 -8
  40. package/dist/cli/managed-command-guard.js +41 -0
  41. package/dist/cli/model.js +11 -4
  42. package/dist/cli/queue-command.js +53 -1
  43. package/dist/cli/response.js +71 -0
  44. package/dist/cli/restart-monitor.js +7 -32
  45. package/dist/cli/trigger-command.js +11 -0
  46. package/dist/config/access-policy.js +1 -2
  47. package/dist/config/builtin-roles.js +9 -0
  48. package/dist/config/config-manager.js +21 -1
  49. package/dist/config/contact-book-store.js +11 -3
  50. package/dist/config/contact-request-service.js +161 -15
  51. package/dist/config/mention-mode.js +8 -24
  52. package/dist/config/peer-role-resolver.js +6 -2
  53. package/dist/config/role-migration-startup.js +53 -0
  54. package/dist/config/role-store.js +1 -1
  55. package/dist/core/auth/agent-delegation.js +1 -2
  56. package/dist/core/auth/auth-gateway.js +29 -1
  57. package/dist/core/auth/authorization-audit.js +15 -0
  58. package/dist/core/auth/operation-authorizer.js +31 -7
  59. package/dist/core/auth/operation-catalog.js +196 -25
  60. package/dist/core/bootstrap-messages.js +25 -0
  61. package/dist/core/bootstrap-service.js +64 -4
  62. package/dist/core/capability/providers/claude-capability-provider.js +9 -31
  63. package/dist/core/capability/providers/codex-capability-provider.js +4 -15
  64. package/dist/core/capability/skill-discovery.js +55 -0
  65. package/dist/core/channel-loader.js +1 -1
  66. package/dist/core/command/cli-intent-parser.js +9 -0
  67. package/dist/core/command/command-handler.js +650 -42
  68. package/dist/core/command/connect-menu.js +15 -0
  69. package/dist/core/command/group-menu.js +4 -4
  70. package/dist/core/command/menu-catalog.js +370 -0
  71. package/dist/core/command/menu-handler.js +230 -51
  72. package/dist/core/command/menu-protocol.js +94 -2
  73. package/dist/core/command/slash-gate.js +5 -2
  74. package/dist/core/command/slash-handler.js +99 -31
  75. package/dist/core/daemon-file-cache.js +2 -1
  76. package/dist/core/data-migration.js +9 -2
  77. package/dist/core/event-catalog.js +6 -0
  78. package/dist/core/evolagent.js +4 -2
  79. package/dist/core/handoff/dispatcher.js +5 -2
  80. package/dist/core/handoff/runtime.js +157 -22
  81. package/dist/core/handoff/store.js +29 -1
  82. package/dist/core/handoff/types.js +1 -0
  83. package/dist/core/interaction-router.js +10 -0
  84. package/dist/core/message/im-renderer.js +19 -0
  85. package/dist/core/message/logical-queue-bridge.js +1 -0
  86. package/dist/core/message/mention-schema.js +126 -0
  87. package/dist/core/message/message-bridge.js +298 -88
  88. package/dist/core/message/message-log.js +3 -0
  89. package/dist/core/message/message-queue.js +268 -39
  90. package/dist/core/message/message-utils.js +81 -4
  91. package/dist/core/message/response-engine.js +161 -77
  92. package/dist/core/message/stream-debouncer.js +10 -2
  93. package/dist/core/permission/approval-gateway.js +1 -0
  94. package/dist/core/permission/ec-command-parser.js +243 -18
  95. package/dist/core/permission/index.js +1 -1
  96. package/dist/core/permission/mode.js +15 -0
  97. package/dist/core/permission/readonly-shell-query.js +148 -8
  98. package/dist/core/permission/sandbox-runtime.js +43 -1
  99. package/dist/core/permission/tool-policy.js +322 -57
  100. package/dist/core/protected-paths.js +114 -4
  101. package/dist/core/session/session-manager.js +42 -4
  102. package/dist/core/session/session-mapper.js +20 -1
  103. package/dist/eck/detect.js +18 -1
  104. package/dist/eck/group-rules-sync.js +15 -44
  105. package/dist/eck/manifest-engine.js +39 -13
  106. package/dist/index.js +541 -180
  107. package/dist/ipc.js +232 -10
  108. package/dist/paths.js +3 -0
  109. package/dist/response-system/coordinator.js +6 -4
  110. package/dist/response-system/engines/v1/proactive-flow.js +26 -8
  111. package/dist/response-system/modes/single-session/index.js +14 -1
  112. package/dist/response-system/selector.js +6 -5
  113. package/dist/trigger/anomaly-store.js +4 -0
  114. package/dist/trigger/feedback.js +64 -11
  115. package/dist/trigger/manager.js +21 -1
  116. package/dist/trigger/parser.js +14 -2
  117. package/dist/trigger/scheduler.js +1 -0
  118. package/dist/trigger/script-executor.js +1 -0
  119. package/dist/trigger/validation.js +67 -6
  120. package/dist/utils/codex-app-server-registry.js +90 -0
  121. package/dist/utils/codex-cli.js +5 -1
  122. package/dist/utils/cross-platform.js +15 -0
  123. package/dist/utils/ecweb-supervisor.js +332 -0
  124. package/dist/utils/error-utils.js +10 -0
  125. package/dist/utils/npm-ops.js +5 -12
  126. package/dist/utils/tool-summary.js +11 -0
  127. package/kits/docs/channels/aun.md +1 -1
  128. package/kits/docs/context-assembly.md +2 -2
  129. package/kits/docs/evolcore/agent.md +11 -6
  130. package/kits/docs/evolcore/aid.md +14 -0
  131. package/kits/docs/evolcore/trigger.md +17 -1
  132. package/kits/docs/prompt-loading-architecture.md +1 -2
  133. package/kits/docs/venues/group.md +1 -1
  134. package/kits/eck_manifest.json +0 -12
  135. package/kits/migrations/migrate-contact-book-v2.mjs +1 -2
  136. package/kits/rules/04-relation.md +1 -1
  137. package/kits/rules/05-venue.md +2 -2
  138. package/kits/schemas/role-config.schema.1.json +1 -0
  139. package/kits/schemas/single-session.schema.1.json +3 -3
  140. package/kits/schemas/single-session.schema.2.json +3 -3
  141. package/kits/templates/roles/admin.json +27 -0
  142. package/kits/templates/roles/member.json +34 -1
  143. package/kits/templates/roles/visitor.json +35 -3
  144. package/kits/templates/system-fragments/bootstrap.md +1 -1
  145. package/kits/templates/system-fragments/channel.md +1 -1
  146. package/kits/templates/system-fragments/session.md +1 -1
  147. package/package.json +2 -2
  148. package/dist/aun/msg/payload-type.js +0 -27
  149. package/dist/aun/rpc/caller.js +0 -42
  150. package/dist/aun/rpc/connection.js +0 -25
  151. package/dist/aun/storage/manage.js +0 -10
  152. package/dist/config/access-policy-domain.js +0 -18
  153. package/dist/config/config-batch-get.js +0 -11
  154. package/dist/config/owner-policy.js +0 -4
  155. package/dist/config/role-config-v4-startup.js +0 -32
  156. package/dist/config/role-config-v5-startup.js +0 -27
  157. package/dist/core/auth/trigger-authorization.js +0 -15
  158. package/dist/core/command/evol-menu-version-gate.js +0 -39
  159. package/dist/core/interaction-registration.js +0 -10
  160. package/dist/core/permission/execution-sandbox.js +0 -16
  161. package/dist/core/relation/peer-key.js +0 -1
  162. package/dist/core/session/session-key.js +0 -24
  163. package/dist/eck/baseagent-caps.js +0 -18
  164. package/dist/eck/rules-loader.js +0 -28
@@ -3,6 +3,8 @@ import path from 'path';
3
3
  import { agentMdPath, resolvePaths, resolveRoot } from '../paths.js';
4
4
  import { isExplicitGroupId } from '../aun/group-identity.js';
5
5
  import { getArgValue, isHelpFlag, wantsHelp } from './help.js';
6
+ import { ipcQuery } from '../ipc.js';
7
+ import { AGENT_DELEGATION_TOKEN_ENV } from '../core/auth/agent-delegation.js';
6
8
  // ==================== AID ====================
7
9
  function resolveAunPath(args) {
8
10
  const idx = args.indexOf('--aun-path');
@@ -10,6 +12,238 @@ function resolveAunPath(args) {
10
12
  return args[idx + 1];
11
13
  return process.env.AUN_HOME || undefined;
12
14
  }
15
+ function renderAidShow(info, formatJson) {
16
+ if (formatJson) {
17
+ console.log(JSON.stringify(info, null, 2));
18
+ return;
19
+ }
20
+ console.log(`AID: ${info.aid}`);
21
+ console.log(` 私钥: ${info.hasPrivateKey ? '有' : '无'}`);
22
+ console.log(` agent.md: ${info.hasAgentMd ? '有' : '无'}`);
23
+ if (info.hasAgentMd) {
24
+ const sigLabel = info.agentMdSignature === 'verified' ? '✓ 已验签'
25
+ : info.agentMdSignature === 'unsigned' ? '⚠ 未签名'
26
+ : info.agentMdSignature === 'invalid' ? `✗ 签名无效${info.agentMdSignatureReason ? ': ' + info.agentMdSignatureReason : ''}`
27
+ : '? 未知';
28
+ console.log(` 签名状态: ${sigLabel}`);
29
+ }
30
+ console.log(` 证书到期: ${info.certExpiresAt ?? '无证书'}${info.certExpired ? ' (已过期!)' : ''}`);
31
+ if (info.certSubject)
32
+ console.log(` 证书主体: ${info.certSubject}`);
33
+ if (info.keyMatchesCert === false)
34
+ console.log(' 密钥/证书: ✗ 公钥不匹配(cert.pem 与 key.json 公钥不一致)');
35
+ else if (info.keyMatchesCert === true)
36
+ console.log(' 密钥/证书: ✓ 公钥一致');
37
+ if (info.signVerified === true)
38
+ console.log(' 可签名/验签: ✓ 实测通过');
39
+ else if (info.signVerified === false)
40
+ console.log(` 可签名/验签: ✗ 失败${info.signError ? `(${info.signError})` : ''}`);
41
+ else
42
+ console.log(' 可签名/验签: ? 未知');
43
+ }
44
+ function renderAidLookup(result, formatJson) {
45
+ if (formatJson) {
46
+ console.log(JSON.stringify(result, null, 2));
47
+ return;
48
+ }
49
+ if (result.exists) {
50
+ console.log(`✓ ${result.aid} 已注册`);
51
+ if (result.gateway)
52
+ console.log(` 网关: ${result.gateway}`);
53
+ if (result.content) {
54
+ const hasSig = result.content.includes('AUN-SIGNATURE');
55
+ console.log(` 签名: ${hasSig ? '有(未验证,如需验证请用 ec aid agentmd get ' + result.aid + ')' : '无'}`);
56
+ console.log('');
57
+ console.log(result.content);
58
+ }
59
+ }
60
+ else {
61
+ console.log(`✗ ${result.aid} 未注册`);
62
+ if (result.gateway)
63
+ console.log(` 网关: ${result.gateway}`);
64
+ if (result.error)
65
+ console.log(` 原因: ${result.error}`);
66
+ }
67
+ }
68
+ function renderAgentmdGet(aid, result, formatJson) {
69
+ if (!result.content || !result.content.trim()) {
70
+ console.log(`ℹ️ ${aid} 尚未设置 agent.md`);
71
+ return;
72
+ }
73
+ if (formatJson) {
74
+ console.log(JSON.stringify(result, null, 2));
75
+ return;
76
+ }
77
+ console.log(result.content);
78
+ const verification = result.verification;
79
+ if (verification.status === 'verified')
80
+ console.error('✓ 签名验证通过');
81
+ else if (verification.status === 'invalid')
82
+ console.error(`⚠ 签名验证失败: ${verification.reason ?? '未知原因'}`);
83
+ else
84
+ console.error('ℹ️ 未签名');
85
+ }
86
+ function failManagedAid(formatJson, code, error) {
87
+ if (formatJson)
88
+ console.log(JSON.stringify({ ok: false, code, error }, null, 2));
89
+ else
90
+ console.error(`❌ ${error}`);
91
+ process.exit(1);
92
+ }
93
+ async function runManagedAid(args, formatJson) {
94
+ const sessionId = process.env.EVOLCORE_SESSION_ID;
95
+ if (!sessionId)
96
+ failManagedAid(formatJson, 'NO_SESSION', 'EVOLCORE_SESSION_ID is not set');
97
+ const delegationToken = process.env[AGENT_DELEGATION_TOKEN_ENV];
98
+ if (!delegationToken) {
99
+ failManagedAid(formatJson, 'DELEGATION_REQUIRED', `${AGENT_DELEGATION_TOKEN_ENV} is not set for the active task`);
100
+ }
101
+ const response = await ipcQuery(resolvePaths().socket, {
102
+ type: 'aid.op',
103
+ argv: ['aid', ...args],
104
+ sessionId,
105
+ delegationToken,
106
+ }, 30_000);
107
+ if (!response)
108
+ failManagedAid(formatJson, 'DAEMON_UNAVAILABLE', 'Unable to connect to the evolcore daemon');
109
+ if (!response.ok || !response.result) {
110
+ const error = response.error || 'AID operation failed';
111
+ const aid = args[0] === 'agentmd' ? args[2] : args[1];
112
+ if (args[0] === 'agentmd' && args[1] === 'get' && (error.includes('not found') || error.includes('404'))) {
113
+ console.log(`ℹ️ ${aid} 尚未设置 agent.md`);
114
+ return;
115
+ }
116
+ if (response.code === 'LOCAL_AGENTMD_MISSING') {
117
+ failManagedAid(formatJson, response.code, `本地无 agent.md: ${aid}`);
118
+ }
119
+ failManagedAid(formatJson, response.code || 'AID_OPERATION_FAILED', error);
120
+ }
121
+ switch (response.result.kind) {
122
+ case 'show':
123
+ renderAidShow(response.result.value, formatJson);
124
+ return;
125
+ case 'lookup':
126
+ renderAidLookup(response.result.value, formatJson);
127
+ return;
128
+ case 'agentmd.get':
129
+ renderAgentmdGet(response.result.aid, response.result.value, formatJson);
130
+ return;
131
+ case 'agentmd.put':
132
+ if (formatJson)
133
+ console.log(JSON.stringify({ ok: true, aid: response.result.aid, path: response.result.path }, null, 2));
134
+ else
135
+ console.log('✓ agent.md 已发布');
136
+ }
137
+ }
138
+ function failManagedGroup(formatJson, code, error) {
139
+ if (formatJson)
140
+ console.log(JSON.stringify({ ok: false, code, error }));
141
+ else
142
+ console.error(`❌ ${error}`);
143
+ process.exit(1);
144
+ }
145
+ async function runManagedGroup(args, formatJson) {
146
+ const sessionId = process.env.EVOLCORE_SESSION_ID;
147
+ if (!sessionId)
148
+ failManagedGroup(formatJson, 'NO_SESSION', 'EVOLCORE_SESSION_ID is not set');
149
+ const delegationToken = process.env[AGENT_DELEGATION_TOKEN_ENV];
150
+ if (!delegationToken) {
151
+ failManagedGroup(formatJson, 'DELEGATION_REQUIRED', `${AGENT_DELEGATION_TOKEN_ENV} is not set for the active task`);
152
+ }
153
+ if (args.includes('--aun-path') || args.includes('--app')) {
154
+ failManagedGroup(formatJson, 'NOT_ALLOWED', '--aun-path and --app are not allowed in a managed task');
155
+ }
156
+ const response = await ipcQuery(resolvePaths().socket, {
157
+ type: 'group.op',
158
+ argv: ['group', ...args],
159
+ sessionId,
160
+ delegationToken,
161
+ }, 60_000);
162
+ if (!response)
163
+ failManagedGroup(formatJson, 'DAEMON_UNAVAILABLE', 'Unable to connect to the evolcore daemon');
164
+ if (!response.ok || !response.result) {
165
+ failManagedGroup(formatJson, response.code || 'GROUP_OPERATION_FAILED', response.error || 'Group operation failed');
166
+ }
167
+ return response.result;
168
+ }
169
+ async function runManagedMsg(args, formatJson) {
170
+ const sessionId = process.env.EVOLCORE_SESSION_ID;
171
+ if (!sessionId)
172
+ failManagedGroup(formatJson, 'NO_SESSION', 'EVOLCORE_SESSION_ID is not set');
173
+ const delegationToken = process.env[AGENT_DELEGATION_TOKEN_ENV];
174
+ if (!delegationToken) {
175
+ failManagedGroup(formatJson, 'DELEGATION_REQUIRED', `${AGENT_DELEGATION_TOKEN_ENV} is not set for the active task`);
176
+ }
177
+ const response = await ipcQuery(resolvePaths().socket, {
178
+ type: 'msg.op',
179
+ argv: ['msg', ...args],
180
+ sessionId,
181
+ delegationToken,
182
+ }, 30_000);
183
+ if (!response)
184
+ failManagedGroup(formatJson, 'DAEMON_UNAVAILABLE', 'Unable to connect to the evolcore daemon');
185
+ if (!response.ok || !response.result) {
186
+ failManagedGroup(formatJson, response.code || 'MSG_OPERATION_FAILED', response.error || 'Msg operation failed');
187
+ }
188
+ return response.result;
189
+ }
190
+ function renderManagedMsgResult(sub, result, formatJson) {
191
+ if (formatJson) {
192
+ console.log(JSON.stringify(result));
193
+ return;
194
+ }
195
+ if (sub === 'online') {
196
+ for (const [aid, online] of Object.entries(result.online ?? {})) {
197
+ console.log(` ${online ? '🟢' : '⚫'} ${aid}`);
198
+ }
199
+ return;
200
+ }
201
+ if (result.count === 0) {
202
+ console.log('暂无消息历史');
203
+ return;
204
+ }
205
+ console.log(`✓ ${result.count} 条消息${result.session_id ? `,session=${result.session_id}` : ''}`);
206
+ for (const message of result.messages ?? []) {
207
+ const arrow = message.dir === 'in' ? '←' : '→';
208
+ const peer = message.dir === 'in' ? message.from : message.to;
209
+ const content = String(message.content ?? '').replace(/\r?\n/g, '\n ');
210
+ console.log(` [${message.time}] ${arrow} ${peer} [${message.msgType}] ${content}`);
211
+ }
212
+ }
213
+ function renderManagedGroupResult(args, result, formatJson) {
214
+ if (formatJson) {
215
+ console.log(JSON.stringify(result));
216
+ return;
217
+ }
218
+ const sub = args[0];
219
+ if (sub === 'list') {
220
+ if (!result.items?.length)
221
+ console.log('(没有加入任何群)');
222
+ else {
223
+ console.log(`共 ${result.total ?? result.items.length} 个群:`);
224
+ for (const group of result.items)
225
+ console.log(` ${group.group_id} ${group.name} (${group.member_count ?? '?'} 人)`);
226
+ }
227
+ return;
228
+ }
229
+ if (sub === 'create') {
230
+ console.log(`✓ 已创建群 ${result.group?.group_id ?? '-'}`);
231
+ return;
232
+ }
233
+ if (sub === 'rules' && args[3] === 'get' && result.status === 'ok') {
234
+ process.stdout.write(String(result.content ?? ''));
235
+ return;
236
+ }
237
+ if (sub === 'rules' && (args[3] === 'set' || args[3] === 'publish') && result.status !== 'ok') {
238
+ console.error(`❌ ${result.error ?? `群规则操作状态: ${result.status ?? 'unknown'}`}`);
239
+ process.exit(1);
240
+ }
241
+ if (sub === 'invite') {
242
+ console.log(`✓ 成功 ${result.added?.length ?? 0},失败 ${result.failed?.length ?? 0}`);
243
+ return;
244
+ }
245
+ console.log(`✓ group ${sub} 完成`);
246
+ }
13
247
  export async function cmdAid(args) {
14
248
  const sub = args[0];
15
249
  const formatJson = getArgValue(args, '--format') === 'json';
@@ -48,6 +282,10 @@ Options:
48
282
  ec aid agentmd get someone.agentid.pub`);
49
283
  return;
50
284
  }
285
+ if (process.env.EVOLCORE_SESSION_ID && !wantsHelp(args)) {
286
+ await runManagedAid(args, formatJson);
287
+ return;
288
+ }
51
289
  const { aidList, aidListVerified, aidCreate, aidShow, aidDelete, aidLookup, agentmdPut, agentmdGet, buildInitialAgentMd, isValidAid } = await import('../aun/aid/index.js');
52
290
  if (sub === 'list') {
53
291
  if (wantsHelp(args)) {
@@ -140,33 +378,7 @@ Options:
140
378
  process.exit(1);
141
379
  }
142
380
  const info = await aidShow(aid, { aunPath });
143
- if (formatJson) {
144
- console.log(JSON.stringify(info, null, 2));
145
- return;
146
- }
147
- console.log(`AID: ${info.aid}`);
148
- console.log(` 私钥: ${info.hasPrivateKey ? '有' : '无'}`);
149
- console.log(` agent.md: ${info.hasAgentMd ? '有' : '无'}`);
150
- if (info.hasAgentMd) {
151
- const sigLabel = info.agentMdSignature === 'verified' ? '✓ 已验签'
152
- : info.agentMdSignature === 'unsigned' ? '⚠ 未签名'
153
- : info.agentMdSignature === 'invalid' ? `✗ 签名无效${info.agentMdSignatureReason ? ': ' + info.agentMdSignatureReason : ''}`
154
- : '? 未知';
155
- console.log(` 签名状态: ${sigLabel}`);
156
- }
157
- console.log(` 证书到期: ${info.certExpiresAt ?? '无证书'}${info.certExpired ? ' (已过期!)' : ''}`);
158
- if (info.certSubject)
159
- console.log(` 证书主体: ${info.certSubject}`);
160
- if (info.keyMatchesCert === false)
161
- console.log(` 密钥/证书: ✗ 公钥不匹配(cert.pem 与 key.json 公钥不一致)`);
162
- else if (info.keyMatchesCert === true)
163
- console.log(` 密钥/证书: ✓ 公钥一致`);
164
- if (info.signVerified === true)
165
- console.log(` 可签名/验签: ✓ 实测通过`);
166
- else if (info.signVerified === false)
167
- console.log(` 可签名/验签: ✗ 失败${info.signError ? `(${info.signError})` : ''}`);
168
- else
169
- console.log(` 可签名/验签: ? 未知`);
381
+ renderAidShow(info, formatJson);
170
382
  return;
171
383
  }
172
384
  if (sub === 'new') {
@@ -435,28 +647,7 @@ Options:
435
647
  process.exit(1);
436
648
  }
437
649
  const result = await aidLookup(aid);
438
- if (formatJson) {
439
- console.log(JSON.stringify(result, null, 2));
440
- return;
441
- }
442
- if (result.exists) {
443
- console.log(`✓ ${aid} 已注册`);
444
- if (result.gateway)
445
- console.log(` 网关: ${result.gateway}`);
446
- if (result.content) {
447
- const hasSig = result.content.includes('AUN-SIGNATURE');
448
- console.log(` 签名: ${hasSig ? '有(未验证,如需验证请用 ec aid agentmd get ' + aid + ')' : '无'}`);
449
- console.log('');
450
- console.log(result.content);
451
- }
452
- }
453
- else {
454
- console.log(`✗ ${aid} 未注册`);
455
- if (result.gateway)
456
- console.log(` 网关: ${result.gateway}`);
457
- if (result.error)
458
- console.log(` 原因: ${result.error}`);
459
- }
650
+ renderAidLookup(result, formatJson);
460
651
  return;
461
652
  }
462
653
  if (sub === 'agentmd') {
@@ -504,26 +695,7 @@ Options:
504
695
  }
505
696
  try {
506
697
  const result = await agentmdGet(aid, { withVerification: true, aunPath });
507
- if (!result.content || !result.content.trim()) {
508
- console.log(`ℹ️ ${aid} 尚未设置 agent.md`);
509
- return;
510
- }
511
- if (formatJson) {
512
- console.log(JSON.stringify(result, null, 2));
513
- }
514
- else {
515
- console.log(result.content);
516
- const v = result.verification;
517
- if (v.status === 'verified') {
518
- console.error(`✓ 签名验证通过`);
519
- }
520
- else if (v.status === 'invalid') {
521
- console.error(`⚠ 签名验证失败: ${v.reason ?? '未知原因'}`);
522
- }
523
- else {
524
- console.error(`ℹ️ 未签名`);
525
- }
526
- }
698
+ renderAgentmdGet(aid, result, formatJson);
527
699
  }
528
700
  catch (e) {
529
701
  const msg = String(e.message || e);
@@ -667,6 +839,25 @@ Options:
667
839
  console.error(`❌ 无效 AID 格式: ${aid}`);
668
840
  process.exit(1);
669
841
  }
842
+ if (process.env.EVOLCORE_SESSION_ID) {
843
+ const operation = { ls: 'storage.list', quota: 'storage.quota', upload: 'storage.upload', download: 'storage.download', rm: 'storage.delete' }[sub];
844
+ if (!operation)
845
+ failManagedGroup(formatJson, 'NOT_ALLOWED', `unsupported managed storage command: ${sub}`);
846
+ const delegationToken = process.env[AGENT_DELEGATION_TOKEN_ENV];
847
+ if (!delegationToken)
848
+ failManagedGroup(formatJson, 'DELEGATION_REQUIRED', `${AGENT_DELEGATION_TOKEN_ENV} is not set for the active task`);
849
+ const authorization = await ipcQuery(resolvePaths().socket, {
850
+ type: 'storage.auth',
851
+ operation,
852
+ aid,
853
+ sessionId: process.env.EVOLCORE_SESSION_ID,
854
+ delegationToken,
855
+ }, 10_000);
856
+ if (!authorization)
857
+ failManagedGroup(formatJson, 'DAEMON_UNAVAILABLE', 'Unable to connect to the evolcore daemon');
858
+ if (!authorization.ok)
859
+ failManagedGroup(formatJson, authorization.code || 'STORAGE_AUTH_FAILED', authorization.error || 'Storage operation denied');
860
+ }
670
861
  const { storageUpload, storageDownload, storageLs, storageRm, storageQuota } = await import('../aun/storage/index.js');
671
862
  if (sub === 'upload') {
672
863
  const localFile = args[2];
@@ -874,6 +1065,11 @@ Options:
874
1065
  console.error(`❌ 无效 AID 格式: ${from}`);
875
1066
  process.exit(1);
876
1067
  }
1068
+ if (process.env.EVOLCORE_SESSION_ID && sub !== 'send') {
1069
+ const result = await runManagedMsg(args, formatJson);
1070
+ renderManagedMsgResult(sub, result, formatJson);
1071
+ return;
1072
+ }
877
1073
  const { msgSend, msgPull, msgAck, msgRecall, msgOnline, msgHistory } = await import('../aun/msg/index.js');
878
1074
  const commonOpts = { aunPath, slotId: appSlot };
879
1075
  if (sub === 'history') {
@@ -1334,6 +1530,11 @@ Options:
1334
1530
  printGroupSendAidHint();
1335
1531
  process.exit(1);
1336
1532
  }
1533
+ if (process.env.EVOLCORE_SESSION_ID && sub !== 'send') {
1534
+ const result = await runManagedGroup(args, formatJson);
1535
+ renderManagedGroupResult(args, result, formatJson);
1536
+ return;
1537
+ }
1337
1538
  const { groupSend, groupPull, groupAck, groupCreate, groupInfo, groupList, groupUpdate, groupDissolve, groupSuspend, groupResume, groupJoin, groupLeave, groupInvite, groupKick, groupMembers, groupOnline, groupSetRole, groupTransferOwner, groupBan, groupUnban, groupBanlist, groupRules, groupUpdateRules, groupRulesFileGet, groupRulesFileSet, groupRulesFilePublish, } = await import('../aun/msg/index.js');
1338
1539
  const commonOpts = { aunPath, slotId: appSlot };
1339
1540
  // 通用 group_id 提取(第三参数)
package/dist/cli/bench.js CHANGED
@@ -333,7 +333,10 @@ async function cliSend(from, to, text, slotId, encrypt) {
333
333
  if (encrypt)
334
334
  sendArgs.push('--encrypt');
335
335
  try {
336
- const { stdout } = await execFileAsync('node', sendArgs, { timeout: 30000 });
336
+ const { stdout } = await execFileAsync('node', sendArgs, {
337
+ timeout: 30000,
338
+ windowsHide: process.platform === 'win32',
339
+ });
337
340
  const res = JSON.parse(stdout.trim());
338
341
  return { ok: true, timestamp: res.timestamp };
339
342
  }
@@ -349,7 +352,10 @@ async function cliPull(from, slotId, afterSeq) {
349
352
  if (afterSeq !== undefined)
350
353
  pullArgs.push('--after-seq', String(afterSeq));
351
354
  try {
352
- const { stdout } = await execFileAsync('node', pullArgs, { timeout: 30000 });
355
+ const { stdout } = await execFileAsync('node', pullArgs, {
356
+ timeout: 30000,
357
+ windowsHide: process.platform === 'win32',
358
+ });
353
359
  const res = JSON.parse(stdout.trim());
354
360
  return { ok: true, messages: res.messages ?? [] };
355
361
  }
@@ -362,7 +368,10 @@ async function cliAuth(aid, slotId) {
362
368
  const bin = path.join(getPackageRoot(), 'dist', 'cli', 'index.js');
363
369
  const start = Date.now();
364
370
  try {
365
- await execFileAsync('node', [bin, 'msg', 'online', aid, aid, '--app', slotId, '--format', 'json'], { timeout: 15000 });
371
+ await execFileAsync('node', [bin, 'msg', 'online', aid, aid, '--app', slotId, '--format', 'json'], {
372
+ timeout: 15000,
373
+ windowsHide: process.platform === 'win32',
374
+ });
366
375
  return { ok: true, authMs: Date.now() - start };
367
376
  }
368
377
  catch {
@@ -3,6 +3,16 @@ export function normalizeCliArgv(argv) {
3
3
  return argv.slice(1);
4
4
  return argv;
5
5
  }
6
+ export function splitConfigBatchGetArgv(inputArgv) {
7
+ const argv = normalizeCliArgv(inputArgv);
8
+ if (argv[0] !== 'config' || argv[1] !== 'get')
9
+ return null;
10
+ const fields = [];
11
+ let i = 2;
12
+ for (; i < argv.length && !argv[i].startsWith('-'); i++)
13
+ fields.push(argv[i]);
14
+ return { fields, rest: argv.slice(i) };
15
+ }
6
16
  export function validateCliArgv(value) {
7
17
  if (!Array.isArray(value) || value.length === 0)
8
18
  return { ok: false, reason: 'args.argv must be a non-empty string array' };
@@ -5,7 +5,7 @@ import { AUTHENTICATED_CONFIG_ROLE_ENV, executeResolvedConfigCommand, } from '..
5
5
  import { ipcQuery } from '../ipc.js';
6
6
  import { resolvePaths } from '../paths.js';
7
7
  import { AGENT_DELEGATION_TOKEN_ENV } from '../core/auth/agent-delegation.js';
8
- import { splitConfigBatchGetArgv } from '../config/config-batch-get.js';
8
+ import { splitConfigBatchGetArgv } from './cli-argv.js';
9
9
  function emit(formatJson, payload, text) {
10
10
  if (formatJson)
11
11
  console.log(JSON.stringify(payload, null, 2));
@@ -47,6 +47,8 @@ function renderConfigExecution(result, formatJson) {
47
47
  switch (result.subcommand) {
48
48
  case 'get':
49
49
  return emit(formatJson, getResultPayload(result), () => getResultLine(result));
50
+ case 'batch-get':
51
+ return renderBatchGet(result.results, formatJson);
50
52
  case 'set':
51
53
  return emit(formatJson, {
52
54
  ok: true,
@@ -186,23 +188,13 @@ function runDirectBatchGet(fields, rest, formatJson) {
186
188
  }
187
189
  async function runManagedBatchGet(fields, rest, formatJson) {
188
190
  const { sessionId, delegationToken } = managedSession(formatJson);
189
- const results = [];
190
- for (const field of fields) {
191
- const response = await managedConfigQuery(['get', field, ...rest], sessionId, delegationToken);
192
- if (!response) {
193
- results.push({ ok: false, field, code: 'DAEMON_UNAVAILABLE', error: 'Unable to connect to the evolcore daemon' });
194
- }
195
- else if (!response.ok || !response.result || !response.result.ok) {
196
- results.push({ ok: false, field, code: response.code || 'CONFIG_AUTH_FAILED', error: response.error || 'config operation failed' });
197
- }
198
- else if (response.result.subcommand === 'get') {
199
- results.push(response.result);
200
- }
201
- else {
202
- results.push({ ok: false, field, code: 'UNEXPECTED_RESULT', error: `config get ${field} produced a non-get result` });
203
- }
191
+ const response = await managedConfigQuery(['get', ...fields, ...rest], sessionId, delegationToken);
192
+ if (!response)
193
+ fail(formatJson, 'DAEMON_UNAVAILABLE', 'Unable to connect to the evolcore daemon');
194
+ if (!response.ok || !response.result) {
195
+ fail(formatJson, response.code || 'CONFIG_AUTH_FAILED', response.error || 'config operation failed', response.data);
204
196
  }
205
- renderBatchGet(results, formatJson);
197
+ renderConfigExecution(response.result, formatJson);
206
198
  }
207
199
  const HELP = `Usage: ec config <command> [options]
208
200
 
@@ -16,7 +16,7 @@ const CTL_HELP = `用法: ec ctl <command> [args...]
16
16
  消息:
17
17
  send <消息内容> 主动发送文本消息(proactive 模式)
18
18
  file [channel] <path> 发送项目内文件
19
- queue 查看/管理会话消息队列
19
+ queue [--after <time>] [--before <time>] 查看/管理会话消息队列
20
20
 
21
21
  示例:
22
22
  ec ctl status