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.
- package/CHANGELOG.md +44 -0
- package/bin/codex-managed-hook.mjs +80 -0
- package/bin/ec-safe-output.js +26 -7
- package/dist/agents/claude-runner.js +86 -7
- package/dist/agents/codex-app-server-client.js +174 -20
- package/dist/agents/codex-runner.js +375 -92
- package/dist/agents/ecagent-runner.js +39 -4
- package/dist/agents/gemini-runner.js +1 -0
- package/dist/aun/aid/client.js +11 -21
- package/dist/aun/aid/control-aid.js +36 -13
- package/dist/aun/aid/managed-operation.js +107 -0
- package/dist/aun/aid/store.js +13 -7
- package/dist/aun/group-fs-download.js +56 -0
- package/dist/aun/group-identity.js +1 -2
- package/dist/aun/msg/group.js +91 -44
- package/dist/aun/msg/index.js +1 -2
- package/dist/aun/msg/managed-operation.js +865 -0
- package/dist/aun/msg/mention-schema.js +20 -0
- package/dist/aun/msg/p2p.js +7 -0
- package/dist/aun/msg/upload.js +16 -1
- package/dist/aun/outbox.js +31 -2
- package/dist/aun/rpc/client.js +66 -0
- package/dist/aun/rpc/index.js +1 -2
- package/dist/aun/storage/{upload.js → client.js} +11 -2
- package/dist/aun/storage/index.js +1 -2
- package/dist/channels/aun.js +655 -240
- package/dist/channels/daemon.js +13 -0
- package/dist/cli/agent-command.js +56 -8
- package/dist/cli/agent.js +108 -31
- package/dist/cli/aun-commands.js +270 -69
- package/dist/cli/bench.js +12 -3
- package/dist/cli/cli-argv.js +10 -0
- package/dist/cli/config.js +9 -17
- package/dist/cli/ctl-command.js +1 -1
- package/dist/cli/daemon-commands.js +70 -55
- package/dist/cli/fs-command.js +79 -10
- package/dist/cli/handoff-command.js +3 -0
- package/dist/cli/index.js +30 -2
- package/dist/cli/init.js +77 -8
- package/dist/cli/managed-command-guard.js +41 -0
- package/dist/cli/model.js +11 -4
- package/dist/cli/queue-command.js +53 -1
- package/dist/cli/response.js +71 -0
- package/dist/cli/restart-monitor.js +7 -32
- package/dist/cli/trigger-command.js +11 -0
- package/dist/config/access-policy.js +1 -2
- package/dist/config/builtin-roles.js +9 -0
- package/dist/config/config-manager.js +21 -1
- package/dist/config/contact-book-store.js +11 -3
- package/dist/config/contact-request-service.js +161 -15
- package/dist/config/mention-mode.js +8 -24
- package/dist/config/peer-role-resolver.js +6 -2
- package/dist/config/role-migration-startup.js +53 -0
- package/dist/config/role-store.js +1 -1
- package/dist/core/auth/agent-delegation.js +1 -2
- package/dist/core/auth/auth-gateway.js +29 -1
- package/dist/core/auth/authorization-audit.js +15 -0
- package/dist/core/auth/operation-authorizer.js +31 -7
- package/dist/core/auth/operation-catalog.js +196 -25
- package/dist/core/bootstrap-messages.js +25 -0
- package/dist/core/bootstrap-service.js +64 -4
- package/dist/core/capability/providers/claude-capability-provider.js +9 -31
- package/dist/core/capability/providers/codex-capability-provider.js +4 -15
- package/dist/core/capability/skill-discovery.js +55 -0
- package/dist/core/channel-loader.js +1 -1
- package/dist/core/command/cli-intent-parser.js +9 -0
- package/dist/core/command/command-handler.js +650 -42
- package/dist/core/command/connect-menu.js +15 -0
- package/dist/core/command/group-menu.js +4 -4
- package/dist/core/command/menu-catalog.js +370 -0
- package/dist/core/command/menu-handler.js +230 -51
- package/dist/core/command/menu-protocol.js +94 -2
- package/dist/core/command/slash-gate.js +5 -2
- package/dist/core/command/slash-handler.js +99 -31
- package/dist/core/daemon-file-cache.js +2 -1
- package/dist/core/data-migration.js +9 -2
- package/dist/core/event-catalog.js +6 -0
- package/dist/core/evolagent.js +4 -2
- package/dist/core/handoff/dispatcher.js +5 -2
- package/dist/core/handoff/runtime.js +157 -22
- package/dist/core/handoff/store.js +29 -1
- package/dist/core/handoff/types.js +1 -0
- package/dist/core/interaction-router.js +10 -0
- package/dist/core/message/im-renderer.js +19 -0
- package/dist/core/message/logical-queue-bridge.js +1 -0
- package/dist/core/message/mention-schema.js +126 -0
- package/dist/core/message/message-bridge.js +298 -88
- package/dist/core/message/message-log.js +3 -0
- package/dist/core/message/message-queue.js +268 -39
- package/dist/core/message/message-utils.js +81 -4
- package/dist/core/message/response-engine.js +161 -77
- package/dist/core/message/stream-debouncer.js +10 -2
- package/dist/core/permission/approval-gateway.js +1 -0
- package/dist/core/permission/ec-command-parser.js +243 -18
- package/dist/core/permission/index.js +1 -1
- package/dist/core/permission/mode.js +15 -0
- package/dist/core/permission/readonly-shell-query.js +148 -8
- package/dist/core/permission/sandbox-runtime.js +43 -1
- package/dist/core/permission/tool-policy.js +322 -57
- package/dist/core/protected-paths.js +114 -4
- package/dist/core/session/session-manager.js +42 -4
- package/dist/core/session/session-mapper.js +20 -1
- package/dist/eck/detect.js +18 -1
- package/dist/eck/group-rules-sync.js +15 -44
- package/dist/eck/manifest-engine.js +39 -13
- package/dist/index.js +541 -180
- package/dist/ipc.js +232 -10
- package/dist/paths.js +3 -0
- package/dist/response-system/coordinator.js +6 -4
- package/dist/response-system/engines/v1/proactive-flow.js +26 -8
- package/dist/response-system/modes/single-session/index.js +14 -1
- package/dist/response-system/selector.js +6 -5
- package/dist/trigger/anomaly-store.js +4 -0
- package/dist/trigger/feedback.js +64 -11
- package/dist/trigger/manager.js +21 -1
- package/dist/trigger/parser.js +14 -2
- package/dist/trigger/scheduler.js +1 -0
- package/dist/trigger/script-executor.js +1 -0
- package/dist/trigger/validation.js +67 -6
- package/dist/utils/codex-app-server-registry.js +90 -0
- package/dist/utils/codex-cli.js +5 -1
- package/dist/utils/cross-platform.js +15 -0
- package/dist/utils/ecweb-supervisor.js +332 -0
- package/dist/utils/error-utils.js +10 -0
- package/dist/utils/npm-ops.js +5 -12
- package/dist/utils/tool-summary.js +11 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +2 -2
- package/kits/docs/evolcore/agent.md +11 -6
- package/kits/docs/evolcore/aid.md +14 -0
- package/kits/docs/evolcore/trigger.md +17 -1
- package/kits/docs/prompt-loading-architecture.md +1 -2
- package/kits/docs/venues/group.md +1 -1
- package/kits/eck_manifest.json +0 -12
- package/kits/migrations/migrate-contact-book-v2.mjs +1 -2
- package/kits/rules/04-relation.md +1 -1
- package/kits/rules/05-venue.md +2 -2
- package/kits/schemas/role-config.schema.1.json +1 -0
- package/kits/schemas/single-session.schema.1.json +3 -3
- package/kits/schemas/single-session.schema.2.json +3 -3
- package/kits/templates/roles/admin.json +27 -0
- package/kits/templates/roles/member.json +34 -1
- package/kits/templates/roles/visitor.json +35 -3
- package/kits/templates/system-fragments/bootstrap.md +1 -1
- package/kits/templates/system-fragments/channel.md +1 -1
- package/kits/templates/system-fragments/session.md +1 -1
- package/package.json +2 -2
- package/dist/aun/msg/payload-type.js +0 -27
- package/dist/aun/rpc/caller.js +0 -42
- package/dist/aun/rpc/connection.js +0 -25
- package/dist/aun/storage/manage.js +0 -10
- package/dist/config/access-policy-domain.js +0 -18
- package/dist/config/config-batch-get.js +0 -11
- package/dist/config/owner-policy.js +0 -4
- package/dist/config/role-config-v4-startup.js +0 -32
- package/dist/config/role-config-v5-startup.js +0 -27
- package/dist/core/auth/trigger-authorization.js +0 -15
- package/dist/core/command/evol-menu-version-gate.js +0 -39
- package/dist/core/interaction-registration.js +0 -10
- package/dist/core/permission/execution-sandbox.js +0 -16
- package/dist/core/relation/peer-key.js +0 -1
- package/dist/core/session/session-key.js +0 -24
- package/dist/eck/baseagent-caps.js +0 -18
- package/dist/eck/rules-loader.js +0 -28
package/dist/cli/aun-commands.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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, {
|
|
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, {
|
|
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'], {
|
|
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 {
|
package/dist/cli/cli-argv.js
CHANGED
|
@@ -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' };
|
package/dist/cli/config.js
CHANGED
|
@@ -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 '
|
|
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
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
197
|
+
renderConfigExecution(response.result, formatJson);
|
|
206
198
|
}
|
|
207
199
|
const HELP = `Usage: ec config <command> [options]
|
|
208
200
|
|
package/dist/cli/ctl-command.js
CHANGED