evolcore 0.0.25 → 0.0.27
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 +632 -565
- package/LICENSE +21 -21
- package/README.md +455 -455
- package/bin/codex-managed-acl.ps1 +203 -160
- package/bin/codex-managed-hook.mjs +208 -208
- package/bin/ec-safe-output.js +327 -327
- package/bin/ec.js +40 -29
- package/bin/install-codex-managed-hooks.mjs +582 -555
- package/dist/agents/baseagent-availability.js +68 -0
- package/dist/agents/baseagent.js +96 -46
- package/dist/agents/claude-runner.js +172 -33
- package/dist/agents/codex/app-server-client.js +76 -31
- package/dist/agents/codex/catalog.js +1 -1
- package/dist/agents/codex/diagnostics.js +34 -1
- package/dist/agents/codex-runner.js +434 -446
- package/dist/agents/ecagent-runner.js +174 -34
- package/dist/agents/gemini-runner.js +8 -7
- package/dist/agents/runner-types.js +75 -19
- package/dist/aun/aid/agentmd.js +151 -36
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +180 -1
- package/dist/aun/aid/identity.js +4 -4
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/store.js +17 -13
- package/dist/aun/group/history.js +303 -0
- package/dist/aun/group/identity.js +43 -0
- package/dist/aun/group/index.js +5 -0
- package/dist/aun/{msg/group.js → group/operations.js} +162 -39
- package/dist/aun/{menu-client.js → menu/client.js} +85 -6
- package/dist/aun/menu/index.js +2 -0
- package/dist/aun/menu/transport.js +49 -0
- package/dist/aun/msg/index.js +2 -1
- package/dist/aun/msg/managed-operation.js +85 -19
- package/dist/aun/msg/mention-schema.js +51 -0
- package/dist/aun/msg/p2p.js +19 -9
- package/dist/aun/msg/upload.js +43 -80
- package/dist/aun/outbox.js +29 -7
- package/dist/aun/rpc/client.js +1 -0
- package/dist/aun/storage/client.js +39 -50
- package/dist/channels/aun.js +842 -318
- package/dist/channels/daemon.js +10 -6
- package/dist/cli/agent-command.js +212 -89
- package/dist/cli/agent-create.js +626 -11
- package/dist/cli/agent.js +125 -13
- package/dist/cli/aun-commands.js +487 -337
- package/dist/cli/bench.js +20 -20
- package/dist/cli/config.js +55 -33
- package/dist/cli/contact.js +72 -15
- package/dist/cli/ctl-command.js +24 -24
- package/dist/cli/daemon-commands.js +140 -63
- package/dist/cli/diag.js +31 -0
- package/dist/cli/fs-command.js +70 -70
- package/dist/cli/handoff-command.js +46 -14
- package/dist/cli/index.js +91 -79
- package/dist/cli/init.js +34 -1
- package/dist/cli/link-rules.js +21 -21
- package/dist/cli/managed-command-guard.js +5 -1
- package/dist/cli/menu-client.js +51 -32
- package/dist/cli/model.js +3 -3
- package/dist/cli/net-check.js +22 -22
- package/dist/cli/queue-command.js +31 -31
- package/dist/cli/response.js +32 -32
- package/dist/cli/restart-monitor.js +103 -42
- package/dist/cli/stats.js +51 -51
- package/dist/cli/task-command.js +59 -0
- package/dist/cli/task-context.js +97 -49
- package/dist/cli/trigger-command.js +74 -64
- package/dist/config/builtin-roles.js +11 -0
- package/dist/config/config-field-policy.js +11 -0
- package/dist/config/config-manager.js +32 -4
- package/dist/config/config-operation-service.js +160 -0
- package/dist/config/contact-book-store.js +1 -1
- package/dist/config/contact-book.js +1 -1
- package/dist/config/contact-operation-service.js +97 -8
- package/dist/config/peer-role-resolver.js +1 -1
- package/dist/config/resolved-config-op.js +30 -7
- package/dist/config-store.js +1 -1
- package/dist/core/agent-application-service.js +7 -1
- package/dist/core/audit/event-key.js +17 -2
- package/dist/core/audit/log-integrity.js +34 -8
- package/dist/core/auth/agent-delegation.js +48 -14
- package/dist/core/auth/auth-gateway.js +2 -0
- package/dist/core/auth/authorization-audit.js +53 -49
- package/dist/core/auth/operation-authorizer.js +90 -7
- package/dist/core/auth/operation-catalog.js +145 -4
- package/dist/core/auth/remote-access-store.js +155 -10
- package/dist/core/bootstrap-messages.js +66 -7
- package/dist/core/bootstrap-service.js +111 -20
- package/dist/core/command/agent-control.js +88 -7
- package/dist/core/command/agent-storage-menu.js +443 -0
- package/dist/core/command/cli-intent-parser.js +19 -0
- package/dist/core/command/command-handler.js +159 -65
- package/dist/core/command/data-root-resolver.js +273 -0
- package/dist/core/command/diag-service.js +118 -0
- package/dist/core/command/group-menu.js +7 -2
- package/dist/core/command/menu-catalog.js +46 -7
- package/dist/core/command/menu-handler.js +392 -100
- package/dist/core/command/menu-protocol.js +45 -6
- package/dist/core/command/menu-token-store.js +41 -8
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-gate.js +34 -4
- package/dist/core/command/slash-handler.js +123 -43
- package/dist/core/event-catalog.js +4 -0
- package/dist/core/evolagent-registry.js +28 -2
- package/dist/core/group/invite-service.js +924 -0
- package/dist/core/handoff/runtime.js +205 -27
- package/dist/core/handoff/store.js +193 -4
- package/dist/core/interaction-router.js +22 -8
- package/dist/core/message/im-renderer.js +146 -34
- package/dist/core/message/message-bridge.js +163 -20
- package/dist/core/message/message-log.js +5 -3
- package/dist/core/message/message-queue.js +99 -41
- package/dist/core/message/message-utils.js +1 -0
- package/dist/core/message/response-engine.js +755 -144
- package/dist/core/model/catalog-service.js +79 -49
- package/dist/core/model/context-window-suffix.js +33 -0
- package/dist/core/model/model-catalog.js +1 -1
- package/dist/core/model/model-permission.js +12 -3
- package/dist/core/permission/approval-gateway.js +36 -3
- package/dist/core/permission/ec-command-parser.js +112 -41
- package/dist/core/permission/protected-paths.js +134 -16
- package/dist/core/permission/sandbox-runtime.js +108 -17
- package/dist/core/permission/tool-error-code.js +15 -0
- package/dist/core/permission/tool-policy.js +9 -8
- package/dist/core/relation/peer-identity.js +57 -6
- package/dist/core/relation/shared-data.js +106 -0
- package/dist/core/role/runtime-policy.js +64 -0
- package/dist/core/runtime-lock.js +10 -26
- package/dist/core/session/runner-task-history.js +170 -0
- package/dist/core/session/session-manager.js +34 -6
- package/dist/core/session/session-mapper.js +41 -0
- package/dist/core/session/session-turn-coordinator.js +37 -7
- package/dist/core/session/session-turns.js +48 -7
- package/dist/core/task/task-recovery-service.js +176 -0
- package/dist/core/task/task-resume-operation.js +32 -0
- package/dist/eck/group-rules-sync.js +5 -3
- package/dist/eck/kit-renderer.js +1 -0
- package/dist/index.js +588 -217
- package/dist/ipc.js +193 -15
- package/dist/paths.js +17 -4
- package/dist/product.js +2 -0
- package/dist/response-system/engines/v1/proactive-flow.js +59 -2
- package/dist/stats/billing.js +41 -15
- package/dist/stats/db.js +159 -159
- package/dist/stats/eck-vars.js +9 -9
- package/dist/stats/price-resolver.js +28 -10
- package/dist/stats/query.js +139 -139
- package/dist/stats/role-budget.js +6 -6
- package/dist/stats/writer.js +51 -51
- package/dist/trigger/event-source.js +19 -0
- package/dist/trigger/feedback.js +233 -40
- package/dist/trigger/parser.js +55 -5
- package/dist/trigger/patch.js +9 -0
- package/dist/trigger/scheduler.js +30 -4
- package/dist/trigger/validation.js +20 -3
- package/dist/utils/cross-platform.js +30 -1
- package/dist/utils/ecweb-utils.js +1 -0
- package/dist/utils/error-dict.json +160 -160
- package/dist/utils/error-utils.js +61 -2
- package/dist/utils/evolcore-version.js +129 -0
- package/dist/utils/logger.js +26 -14
- package/dist/utils/macos-autostart.js +22 -22
- package/dist/utils/model-prices.jsonl +23 -23
- package/dist/utils/npm-ops.js +176 -35
- package/dist/utils/tool-summary.js +59 -3
- package/dist/utils/welcome.js +196 -23
- package/ecagent/LICENSE +21 -21
- package/ecagent/NOTICE +11 -11
- package/ecagent/README.md +61 -61
- package/ecagent/dist/harness/agent-harness.js +3 -0
- package/ecagent/dist/harness/compaction/branch-summarization.js +30 -30
- package/ecagent/dist/harness/compaction/compaction.js +83 -83
- package/ecagent/dist/harness/messages.js +7 -7
- package/ecagent/dist/harness/session/jsonl-storage.js +21 -2
- package/kits/docs/GUIDE.md +20 -20
- package/kits/docs/INDEX.md +60 -66
- package/kits/docs/aun/CHEATSHEET.md +19 -19
- package/kits/docs/aun/SYNC_PROTOCOL.md +15 -15
- package/kits/docs/channels/aun.md +69 -56
- package/kits/docs/channels/feishu.md +56 -56
- package/kits/docs/context-assembly.md +379 -367
- package/kits/docs/eck_templates/GUIDE.template.md +22 -22
- package/kits/docs/eck_templates/INDEX.template.md +28 -28
- package/kits/docs/eck_templates/path-registry.template.md +33 -33
- package/kits/docs/eck_templates/runtime.template.md +19 -19
- package/kits/docs/evolcore/INDEX.md +76 -71
- package/kits/docs/evolcore/agent-create.md +202 -165
- package/kits/docs/evolcore/agent.md +99 -67
- package/kits/docs/evolcore/aid.md +68 -60
- package/kits/docs/evolcore/codex-windows-sandbox.md +146 -146
- package/kits/docs/evolcore/config.md +241 -195
- package/kits/docs/evolcore/contact.md +75 -68
- package/kits/docs/evolcore/ctl.md +46 -46
- package/kits/docs/evolcore/event.md +216 -216
- package/kits/docs/evolcore/fs-architecture.md +1215 -1215
- package/kits/docs/evolcore/fs.md +110 -110
- package/kits/docs/evolcore/group-collaboration.md +244 -244
- package/kits/docs/evolcore/group-fs.md +17 -17
- package/kits/docs/evolcore/group-rules.md +251 -251
- package/kits/docs/evolcore/group.md +267 -152
- package/kits/docs/evolcore/menu-client.md +58 -34
- package/kits/docs/evolcore/model.md +50 -50
- package/kits/docs/evolcore/msg.md +169 -165
- package/kits/docs/evolcore/response.md +75 -75
- package/kits/docs/evolcore/rpc.md +37 -37
- package/kits/docs/evolcore/self-summary.md +29 -29
- package/kits/docs/evolcore/stats.md +83 -83
- package/kits/docs/evolcore/storage.md +53 -50
- package/kits/docs/evolcore/task.md +14 -0
- package/kits/docs/evolcore/trigger.md +623 -575
- package/kits/docs/identity/AID_PROFILE_SPEC.md +26 -26
- package/kits/docs/identity/PATH_OPS.md +16 -16
- package/kits/docs/identity/ROLE_DETAIL.md +25 -25
- package/kits/docs/identity/identity-tools.md +26 -26
- package/kits/docs/path-registry.md +62 -62
- package/kits/docs/prompt-loading-architecture.md +269 -269
- package/kits/docs/venues/aun-group.md +45 -45
- package/kits/docs/venues/aun-private.md +10 -10
- package/kits/docs/venues/client-desktop.md +10 -10
- package/kits/docs/venues/client-mobile.md +10 -10
- package/kits/docs/venues/feishu-group.md +13 -13
- package/kits/docs/venues/feishu-private.md +9 -9
- package/kits/docs/venues/group.md +42 -25
- package/kits/docs/venues/private.md +10 -10
- package/kits/eck_manifest.auxiliary.json +43 -43
- package/kits/eck_manifest.json +217 -190
- package/kits/eck_message_manifest.json +74 -74
- package/kits/migrations/README-role-config-v4.md +32 -32
- package/kits/migrations/migrate-contact-book-v2.mjs +748 -748
- package/kits/migrations/migrate-role-config-v4.mjs +614 -614
- package/kits/migrations/migrate-role-config-v5.mjs +365 -365
- package/kits/migrations/rename-config-file.mjs +99 -99
- package/kits/rules/01-overview.md +166 -162
- package/kits/rules/02-navigation.md +96 -96
- package/kits/rules/03-identity.md +36 -36
- package/kits/rules/04-relation.md +76 -75
- package/kits/rules/05-venue.md +60 -60
- package/kits/rules/06-channel.md +65 -63
- package/kits/schemas/_meta.json +53 -53
- package/kits/schemas/agent-config.schema.1.json +177 -177
- package/kits/schemas/agent-config.schema.10.json +395 -395
- package/kits/schemas/agent-config.schema.11.json +421 -421
- package/kits/schemas/agent-config.schema.12.json +451 -427
- package/kits/schemas/agent-config.schema.2.json +239 -239
- package/kits/schemas/agent-config.schema.3.json +119 -119
- package/kits/schemas/agent-config.schema.4.json +208 -208
- package/kits/schemas/agent-config.schema.5.json +326 -326
- package/kits/schemas/agent-config.schema.6.json +322 -322
- package/kits/schemas/agent-config.schema.7.json +303 -303
- package/kits/schemas/agent-config.schema.8.json +304 -304
- package/kits/schemas/agent-config.schema.9.json +364 -364
- package/kits/schemas/contact-book.schema.1.json +36 -36
- package/kits/schemas/contact-book.schema.2.json +43 -43
- package/kits/schemas/contact-book.schema.3.json +67 -67
- package/kits/schemas/daemon.schema.1.json +91 -91
- package/kits/schemas/daemon.schema.2.json +101 -101
- package/kits/schemas/daemon.schema.3.json +123 -123
- package/kits/schemas/daemon.schema.4.json +136 -136
- package/kits/schemas/daemon.schema.5.json +135 -135
- package/kits/schemas/daemon.schema.6.json +131 -131
- package/kits/schemas/defaults.schema.1.json +81 -81
- package/kits/schemas/defaults.schema.2.json +85 -85
- package/kits/schemas/defaults.schema.3.json +73 -73
- package/kits/schemas/defaults.schema.4.json +107 -107
- package/kits/schemas/defaults.schema.5.json +119 -119
- package/kits/schemas/menu-exec-schema-commands.md +208 -208
- package/kits/schemas/migrations/README.md +30 -30
- package/kits/schemas/relation-config.schema.1.json +158 -158
- package/kits/schemas/relation-config.schema.2.json +73 -73
- package/kits/schemas/relation-config.schema.3.json +50 -50
- package/kits/schemas/relation-config.schema.4.json +47 -47
- package/kits/schemas/relation-config.schema.5.json +47 -47
- package/kits/schemas/relation-config.schema.6.json +46 -46
- package/kits/schemas/relation-config.schema.7.json +59 -59
- package/kits/schemas/relation-config.schema.8.json +103 -103
- package/kits/schemas/role-config.schema.1.json +215 -201
- package/kits/schemas/role-registry.schema.1.json +35 -35
- package/kits/schemas/single-session.schema.1.json +31 -31
- package/kits/schemas/single-session.schema.2.json +57 -57
- package/kits/schemas/single-session.schema.3.json +32 -32
- package/kits/templates/bootstrap-welcome.md +17 -17
- package/kits/templates/message-fragments/handoff-context-to-target.md +9 -9
- package/kits/templates/message-fragments/handoff-request-to-target.md +19 -19
- package/kits/templates/message-fragments/handoff-response-to-origin.md +9 -9
- package/kits/templates/message-fragments/inject-default.md +2 -2
- package/kits/templates/message-fragments/item.md +2 -2
- package/kits/templates/roles/admin.json +92 -92
- package/kits/templates/roles/member.json +101 -96
- package/kits/templates/roles/owner.json +9 -9
- package/kits/templates/roles/visitor.json +90 -85
- package/kits/templates/system-fragments/baseagent.md +14 -14
- package/kits/templates/system-fragments/bootstrap.md +53 -34
- package/kits/templates/system-fragments/channel.md +28 -64
- package/kits/templates/system-fragments/commands.md +36 -28
- package/kits/templates/system-fragments/group-unread-history.md +7 -0
- package/kits/templates/system-fragments/identity.md +13 -13
- package/kits/templates/system-fragments/relation.md +19 -19
- package/kits/templates/system-fragments/reply.md +56 -0
- package/kits/templates/system-fragments/session.md +59 -59
- package/kits/templates/system-fragments/venue.md +31 -31
- package/package.json +104 -98
- package/dist/aun/group-identity.js +0 -9
- /package/dist/aun/{group-fs-download.js → group/fs-download.js} +0 -0
- /package/dist/aun/{msg/group-index.js → group/index-rpc.js} +0 -0
|
@@ -4,7 +4,7 @@ import { ipcQuery } from '../ipc.js';
|
|
|
4
4
|
import { HANDOFF_QUERY_DEFAULT_LIMIT, HANDOFF_QUERY_MAX_LIMIT, HANDOFF_STATES } from '../core/handoff/types.js';
|
|
5
5
|
import { HANDOFF_ID_RE } from '../core/handoff/store.js';
|
|
6
6
|
import { isHelpFlag, wantsHelp } from './help.js';
|
|
7
|
-
import {
|
|
7
|
+
import { readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
8
8
|
function parseLimit(value) {
|
|
9
9
|
const limit = Number(value);
|
|
10
10
|
if (!value || !Number.isInteger(limit) || limit < 1 || limit > HANDOFF_QUERY_MAX_LIMIT) {
|
|
@@ -106,13 +106,13 @@ export function parseReturn(args) {
|
|
|
106
106
|
function printReturn(result) {
|
|
107
107
|
if (result.ok) {
|
|
108
108
|
if (result.code === 'HANDOFF_RETURN_ALREADY_APPLIED') {
|
|
109
|
-
console.log(`✓ handoff ${result.handoff_id}
|
|
109
|
+
console.log(`✓ handoff ${result.handoff_id} 已接收过相同结果,未重复处理${result.result_id ? ` result_id=${result.result_id}` : ''}`);
|
|
110
110
|
}
|
|
111
111
|
else if (result.state === 'completed') {
|
|
112
112
|
console.log(`✓ handoff ${result.handoff_id} 已确认完成,不回流来源会话`);
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
console.log(`✓ handoff ${result.handoff_id}
|
|
115
|
+
console.log(`✓ handoff ${result.handoff_id} 回流结果已接收${result.result_id ? ` result_id=${result.result_id}` : ''};后续仍可用同一 ID 追加结果`);
|
|
116
116
|
}
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
@@ -153,13 +153,15 @@ function formatTimestamp(value) {
|
|
|
153
153
|
export async function cmdHandoff(args) {
|
|
154
154
|
const sub = args[0];
|
|
155
155
|
if (!sub || isHelpFlag(sub) || wantsHelp(args)) {
|
|
156
|
-
console.log(`用法: ec handoff <command> [args]
|
|
157
|
-
|
|
158
|
-
Commands:
|
|
159
|
-
return [handoff-id] [content]
|
|
160
|
-
return [handoff-id] --text-from-file <path>
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
console.log(`用法: ec handoff <command> [args]
|
|
157
|
+
|
|
158
|
+
Commands:
|
|
159
|
+
return [handoff-id] [content] 提交一个回流结果;required 可用同一 ID 追加多个结果
|
|
160
|
+
return [handoff-id] --text-from-file <path>
|
|
161
|
+
recover-return <handoff-id> [content] owner-authorized recovery after target session replacement
|
|
162
|
+
recover-return <handoff-id> --text-from-file <path>
|
|
163
|
+
status <handoff-id> 查询 handoff 状态
|
|
164
|
+
list [--state <state>] [--session <id>] [--limit <n>] [--agent <aid>]
|
|
163
165
|
trace <handoff-id> [--limit <n>] [--agent <aid>]`);
|
|
164
166
|
return;
|
|
165
167
|
}
|
|
@@ -184,7 +186,37 @@ Commands:
|
|
|
184
186
|
sessionId: process.env.EVOLCORE_SESSION_ID,
|
|
185
187
|
handoffId: parsed.handoffId,
|
|
186
188
|
content: parsed.content,
|
|
187
|
-
delegationToken:
|
|
189
|
+
delegationToken: readDelegationCredential(),
|
|
190
|
+
}, 5000);
|
|
191
|
+
if (!result) {
|
|
192
|
+
console.error('✗ daemon 暂时不可用');
|
|
193
|
+
process.exitCode = 1;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
printReturn(result);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (sub === 'recover-return') {
|
|
200
|
+
let parsed;
|
|
201
|
+
try {
|
|
202
|
+
parsed = parseReturn(args.slice(1));
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
206
|
+
process.exitCode = 1;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!parsed.handoffId) {
|
|
210
|
+
console.error('✗ recover-return 必须指定 handoff ID');
|
|
211
|
+
process.exitCode = 1;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const result = await ipcQuery(resolvePaths().socket, {
|
|
215
|
+
type: 'handoff-recover-return',
|
|
216
|
+
sessionId: process.env.EVOLCORE_SESSION_ID,
|
|
217
|
+
handoffId: parsed.handoffId,
|
|
218
|
+
content: parsed.content,
|
|
219
|
+
delegationToken: readDelegationCredential(),
|
|
188
220
|
}, 5000);
|
|
189
221
|
if (!result) {
|
|
190
222
|
console.error('✗ daemon 暂时不可用');
|
|
@@ -203,7 +235,7 @@ Commands:
|
|
|
203
235
|
}
|
|
204
236
|
const result = await ipcQuery(resolvePaths().socket, {
|
|
205
237
|
type: 'handoff-status', sessionId: process.env.EVOLCORE_SESSION_ID, handoffId,
|
|
206
|
-
delegationToken:
|
|
238
|
+
delegationToken: readDelegationCredential(),
|
|
207
239
|
}, 5000);
|
|
208
240
|
if (!result) {
|
|
209
241
|
console.error('✗ daemon 暂时不可用');
|
|
@@ -235,7 +267,7 @@ Commands:
|
|
|
235
267
|
state: parsed.state,
|
|
236
268
|
filterSessionId: parsed.sessionId,
|
|
237
269
|
limit: parsed.limit,
|
|
238
|
-
delegationToken:
|
|
270
|
+
delegationToken: readDelegationCredential(),
|
|
239
271
|
}, 5000);
|
|
240
272
|
if (!result) {
|
|
241
273
|
console.error('✗ daemon 暂时不可用');
|
|
@@ -278,7 +310,7 @@ Commands:
|
|
|
278
310
|
agent: parsed.agent,
|
|
279
311
|
handoffId: parsed.handoffId,
|
|
280
312
|
limit: parsed.limit,
|
|
281
|
-
delegationToken:
|
|
313
|
+
delegationToken: readDelegationCredential(),
|
|
282
314
|
}, 5000);
|
|
283
315
|
if (!result) {
|
|
284
316
|
console.error('✗ daemon 暂时不可用');
|
package/dist/cli/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import fs from 'fs';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { getPackageRoot, resolvePaths } from '../paths.js';
|
|
7
7
|
import { ipcQuery } from '../ipc.js';
|
|
8
|
-
import {
|
|
8
|
+
import { readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
9
9
|
import { cmdInit } from './init.js';
|
|
10
10
|
import { cmdInitWechat, cmdInitFeishu, cmdInitDingtalk, cmdInitQQBot, cmdInitWecom, cmdInitAun } from './init-channel.js';
|
|
11
11
|
import { isHelpFlag, wantsHelp, getArgValue } from './help.js';
|
|
@@ -19,57 +19,59 @@ import { cmdStart, cmdStop, cmdRestart, cmdStatus, cmdLogs, cmdWatchCommand, cmd
|
|
|
19
19
|
import { logCliCommand } from './command-log.js';
|
|
20
20
|
import { isInitCancelledError, printInitCancelHint } from './init-cancel.js';
|
|
21
21
|
import { assertManagedTopLevelCommandAllowed, ManagedCommandNotAllowedError } from './managed-command-guard.js';
|
|
22
|
-
const MAIN_HELP = `用法: ec <command> [选项]
|
|
23
|
-
|
|
24
|
-
服务:
|
|
25
|
-
init 初始化默认配置、owner、控制 AID 与 EC Web
|
|
26
|
-
start 启动服务
|
|
27
|
-
stop 停止服务
|
|
28
|
-
restart 重启服务并检查更新
|
|
29
|
-
status 查看运行状态
|
|
30
|
-
logs 持续查看 daemon 日志
|
|
31
|
-
watch 打开日志、AID、消息或 EC Web 监控
|
|
32
|
-
|
|
33
|
-
Agent 与会话:
|
|
34
|
-
agent 管理 EvolAgent
|
|
35
|
-
ctl 当前托管会话的控制命令
|
|
36
|
-
queue 查询或操作 agent 消息队列
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
22
|
+
const MAIN_HELP = `用法: ec <command> [选项]
|
|
23
|
+
|
|
24
|
+
服务:
|
|
25
|
+
init 初始化默认配置、owner、控制 AID 与 EC Web
|
|
26
|
+
start 启动服务
|
|
27
|
+
stop 停止服务
|
|
28
|
+
restart 重启服务并检查更新
|
|
29
|
+
status 查看运行状态
|
|
30
|
+
logs 持续查看 daemon 日志
|
|
31
|
+
watch 打开日志、AID、消息或 EC Web 监控
|
|
32
|
+
|
|
33
|
+
Agent 与会话:
|
|
34
|
+
agent 管理 EvolAgent
|
|
35
|
+
ctl 当前托管会话的控制命令
|
|
36
|
+
queue 查询或操作 agent 消息队列
|
|
37
|
+
task 恢复暂停或异常中断的会话任务
|
|
38
|
+
trigger 管理定时与事件触发器
|
|
39
|
+
handoff 查询和完成跨会话回流
|
|
40
|
+
model 查看或设置模型与推理强度
|
|
41
|
+
response 查看或设置响应模式
|
|
42
|
+
|
|
43
|
+
AUN:
|
|
44
|
+
aid 管理 AID 身份与 agent.md
|
|
45
|
+
msg 私聊消息收发、撤回、在线状态与历史
|
|
46
|
+
group 群消息与群管理
|
|
47
|
+
fs AUN 文件系统
|
|
48
|
+
storage 底层对象存储命令
|
|
49
|
+
rpc 调用底层 AUN RPC
|
|
50
|
+
menu-client 向远程 daemon 发送标准 Menu 请求
|
|
51
|
+
diag 邀请远程诊断 Agent,或 stop 撤销诊断授权
|
|
52
|
+
contact 联系人、待审申请与黑名单管理
|
|
53
|
+
net AUN 网络链路诊断
|
|
54
|
+
|
|
55
|
+
配置与诊断:
|
|
56
|
+
config 读取、修改和检查分层配置
|
|
57
|
+
stats Token 用量与费用统计
|
|
58
|
+
diagnose 检查启动环境
|
|
59
|
+
version 显示组件版本
|
|
60
|
+
mv 迁移项目目录和会话路径
|
|
61
|
+
|
|
62
|
+
维护命令:
|
|
63
|
+
data migrate 迁移 per-Agent 用户数据(显式维护窗口)
|
|
64
|
+
mode 切换开发源码与 npm 包运行模式
|
|
65
|
+
restart-monitor 运行 daemon 重启监控器
|
|
66
|
+
bench AUN 消息性能基准测试
|
|
67
|
+
link-rules 连接 ECK rules 到项目目录
|
|
68
|
+
|
|
69
|
+
运行 ec <command> --help 查看该命令的完整参数。
|
|
70
|
+
|
|
71
|
+
环境变量:
|
|
72
|
+
EVOLCORE_HOME 数据目录(默认: ~/.evolcore)
|
|
73
|
+
LOG_LEVEL 日志级别(默认: INFO)
|
|
74
|
+
MESSAGE_LOG 消息日志(默认: true)
|
|
73
75
|
EVENT_LOG 事件日志(默认: true)`;
|
|
74
76
|
function printLifecycleHelp(command) {
|
|
75
77
|
const help = {
|
|
@@ -115,32 +117,32 @@ export async function main(args) {
|
|
|
115
117
|
case 'init': {
|
|
116
118
|
try {
|
|
117
119
|
if (wantsHelp(args.slice(1))) {
|
|
118
|
-
console.log(`用法: ec init [渠道] [选项]
|
|
119
|
-
|
|
120
|
-
仅初始化 defaults.json:
|
|
121
|
-
ec init 交互式(写完 defaults.json 后嵌套 agent new)
|
|
122
|
-
选择 ecagent 时会继续询问 API Key 和 Base URL
|
|
123
|
-
ec init --non-interactive [选项]
|
|
124
|
-
--baseagent <claude|codex|gemini|ecagent> 默认: PATH 中第一个可用项;ecagent 需显式选择
|
|
125
|
-
--force 已存在 defaults.json 时覆盖
|
|
126
|
-
|
|
127
|
-
云部署非交互式初始化(结构化 JSON 输出):
|
|
128
|
-
ec init --non-interactive --owner <aid> [--format json] [选项]
|
|
129
|
-
--owner <aid> 必填。唯一 daemon owner AID
|
|
130
|
-
--baseagent <claude|codex|gemini|ecagent> 可选。默认从 PATH 检测,ecagent 需显式选择
|
|
131
|
-
--projectpath <abs-path> 可选。默认项目目录(必须绝对路径,自动创建)
|
|
132
|
-
--ecweb 可选。安装 EC Web 并启用自启动
|
|
133
|
-
--auto-start Windows/macOS 上启用 EvolCore 登录自启动
|
|
134
|
-
--no-auto-start Windows/macOS 上禁用 EvolCore 登录自启动
|
|
135
|
-
--format json 可选但推荐。stdout 输出 init.result JSON
|
|
136
|
-
--force 已有不同 owner 时强制覆盖
|
|
137
|
-
|
|
138
|
-
配置渠道(先 ec agent new 创建 agent):
|
|
139
|
-
ec init aun AUN owner 追加绑定(daemon 或指定 agent)
|
|
140
|
-
ec init feishu 飞书扫码登录
|
|
141
|
-
ec init wechat 微信扫码登录
|
|
142
|
-
ec init dingtalk 钉钉扫码登录
|
|
143
|
-
ec init qqbot QQ 机器人扫码绑定
|
|
120
|
+
console.log(`用法: ec init [渠道] [选项]
|
|
121
|
+
|
|
122
|
+
仅初始化 defaults.json:
|
|
123
|
+
ec init 交互式(写完 defaults.json 后嵌套 agent new)
|
|
124
|
+
选择 ecagent 时会继续询问 API Key 和 Base URL
|
|
125
|
+
ec init --non-interactive [选项]
|
|
126
|
+
--baseagent <claude|codex|gemini|ecagent> 默认: PATH 中第一个可用项;ecagent 需显式选择
|
|
127
|
+
--force 已存在 defaults.json 时覆盖
|
|
128
|
+
|
|
129
|
+
云部署非交互式初始化(结构化 JSON 输出):
|
|
130
|
+
ec init --non-interactive --owner <aid> [--format json] [选项]
|
|
131
|
+
--owner <aid> 必填。唯一 daemon owner AID
|
|
132
|
+
--baseagent <claude|codex|gemini|ecagent> 可选。默认从 PATH 检测,ecagent 需显式选择
|
|
133
|
+
--projectpath <abs-path> 可选。默认项目目录(必须绝对路径,自动创建)
|
|
134
|
+
--ecweb 可选。安装 EC Web 并启用自启动
|
|
135
|
+
--auto-start Windows/macOS 上启用 EvolCore 登录自启动
|
|
136
|
+
--no-auto-start Windows/macOS 上禁用 EvolCore 登录自启动
|
|
137
|
+
--format json 可选但推荐。stdout 输出 init.result JSON
|
|
138
|
+
--force 已有不同 owner 时强制覆盖
|
|
139
|
+
|
|
140
|
+
配置渠道(先 ec agent new 创建 agent):
|
|
141
|
+
ec init aun AUN owner 追加绑定(daemon 或指定 agent)
|
|
142
|
+
ec init feishu 飞书扫码登录
|
|
143
|
+
ec init wechat 微信扫码登录
|
|
144
|
+
ec init dingtalk 钉钉扫码登录
|
|
145
|
+
ec init qqbot QQ 机器人扫码绑定
|
|
144
146
|
ec init wecom 企业微信 AI Bot 扫码创建/手工配置`);
|
|
145
147
|
}
|
|
146
148
|
else {
|
|
@@ -246,7 +248,7 @@ export async function main(args) {
|
|
|
246
248
|
}
|
|
247
249
|
if (process.env.EVOLCORE_SESSION_ID) {
|
|
248
250
|
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
249
|
-
const delegationToken =
|
|
251
|
+
const delegationToken = readDelegationCredential();
|
|
250
252
|
const result = await ipcQuery(resolvePaths().socket, {
|
|
251
253
|
type: 'status.auth', sessionId, delegationToken,
|
|
252
254
|
});
|
|
@@ -327,6 +329,11 @@ export async function main(args) {
|
|
|
327
329
|
case 'queue':
|
|
328
330
|
await cmdQueue(args.slice(1));
|
|
329
331
|
break;
|
|
332
|
+
case 'task': {
|
|
333
|
+
const { cmdTask } = await import('./task-command.js');
|
|
334
|
+
await cmdTask(args.slice(1));
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
330
337
|
case 'trigger':
|
|
331
338
|
{
|
|
332
339
|
const { cmdTrigger } = await import('./trigger-command.js');
|
|
@@ -351,6 +358,11 @@ export async function main(args) {
|
|
|
351
358
|
await cmdRpc(args.slice(1));
|
|
352
359
|
break;
|
|
353
360
|
}
|
|
361
|
+
case 'diag': {
|
|
362
|
+
const { cmdDiag } = await import('./diag.js');
|
|
363
|
+
await cmdDiag(args.slice(1));
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
354
366
|
case 'menu-client': {
|
|
355
367
|
const { suppressSdkLogs } = await import('../aun/aid/index.js');
|
|
356
368
|
suppressSdkLogs();
|
package/dist/cli/init.js
CHANGED
|
@@ -7,7 +7,7 @@ import { commandExists } from '../utils/cross-platform.js';
|
|
|
7
7
|
import { scanInstances } from '../utils/instance-registry.js';
|
|
8
8
|
import { saveDefaultsSafe, loadAllAgents, loadDaemonConfig, saveDaemonConfig } from '../config-store.js';
|
|
9
9
|
import { ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
|
|
10
|
-
import { generateControlAid, resolveControlAidDomain } from '../aun/aid/control-aid.js';
|
|
10
|
+
import { ensureControlAgentMd, generateControlAid, resolveControlAidDomain } from '../aun/aid/control-aid.js';
|
|
11
11
|
import { getCodexAppServerAvailability } from '../agents/codex-runner.js';
|
|
12
12
|
import { DEFAULT_ECAGENT_BASE_URL, resolveEcagentConfig } from '../agents/baseagent.js';
|
|
13
13
|
import { defaultProjectsRoot } from '../utils/project-path.js';
|
|
@@ -484,6 +484,12 @@ export async function initTail(options = {}) {
|
|
|
484
484
|
let ownerBindingInterrupted = false;
|
|
485
485
|
if (daemonConfig.aid) {
|
|
486
486
|
console.log(`✓ 控制 AID 已存在: ${daemonConfig.aid}`);
|
|
487
|
+
try {
|
|
488
|
+
await ensureControlAgentMd(daemonConfig.aid);
|
|
489
|
+
}
|
|
490
|
+
catch (e) {
|
|
491
|
+
console.error(`⚠️ 控制 AID agent.md 补全失败(本次继续,后续启动会重试): ${e?.message || e}`);
|
|
492
|
+
}
|
|
487
493
|
}
|
|
488
494
|
else {
|
|
489
495
|
try {
|
|
@@ -861,6 +867,33 @@ export async function cmdInitNonInteractive(opts, dependencies = {}) {
|
|
|
861
867
|
fail('CONTROL_AID_CREATE_FAILED', `control AID creation failed: ${e?.message || e}`, EXIT_RUNTIME, format);
|
|
862
868
|
}
|
|
863
869
|
}
|
|
870
|
+
if (controlAid) {
|
|
871
|
+
const certPath = path.join(resolvePaths().root, 'AIDs', controlAid, 'public', 'cert.pem');
|
|
872
|
+
if (!fs.existsSync(certPath)) {
|
|
873
|
+
// An externally supplied/pre-created AID without a local certificate
|
|
874
|
+
// cannot be signed or uploaded by this process. Avoid entering the SDK
|
|
875
|
+
// network path during non-interactive init; later daemon startup can
|
|
876
|
+
// retry once the identity material is provisioned.
|
|
877
|
+
console.error(`control AID agent.md publish skipped: local certificate not found for ${controlAid}`);
|
|
878
|
+
}
|
|
879
|
+
else {
|
|
880
|
+
try {
|
|
881
|
+
await ensureControlAgentMd(controlAid);
|
|
882
|
+
}
|
|
883
|
+
catch (e) {
|
|
884
|
+
// A registered control AID remains usable when the Name Service is
|
|
885
|
+
// temporarily unavailable; startup and the next init retry publication.
|
|
886
|
+
if (format === 'json') {
|
|
887
|
+
// Keep the successful init result machine-readable; surface the
|
|
888
|
+
// warning through stderr so stdout remains valid JSON.
|
|
889
|
+
console.error(`control AID agent.md publish warning: ${e?.message || e}`);
|
|
890
|
+
}
|
|
891
|
+
else {
|
|
892
|
+
console.error(`⚠️ 控制 AID agent.md 补全失败(本次继续,后续启动会重试): ${e?.message || e}`);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
864
897
|
// ── 9. 写 daemon.json(aid + owners + ecweb)──
|
|
865
898
|
try {
|
|
866
899
|
const next = {
|
package/dist/cli/link-rules.js
CHANGED
|
@@ -79,27 +79,27 @@ function cleanEmptyParents(dir) {
|
|
|
79
79
|
}
|
|
80
80
|
// ── 子命令 ──
|
|
81
81
|
function showHelp() {
|
|
82
|
-
console.log(`Usage: ec link-rules <subcommand> [baseagent] [--dir <path>]
|
|
83
|
-
|
|
84
|
-
Subcommands:
|
|
85
|
-
connect Connect ECK rules to a project directory (default: cwd)
|
|
86
|
-
disconnect Remove ECK rules connection for a baseagent
|
|
87
|
-
status Show connection state for all baseagents
|
|
88
|
-
|
|
89
|
-
Arguments:
|
|
90
|
-
baseagent Target base agent: ${KNOWN_BASEAGENTS.join(', ')} (default: cc)
|
|
91
|
-
--dir <path> Target directory (default: current working directory)
|
|
92
|
-
|
|
93
|
-
Supported baseagents:
|
|
94
|
-
cc Claude Code (.claude/rules/eck/)
|
|
95
|
-
codex Codex (.codex/rules/eck/)
|
|
96
|
-
gemini Gemini CLI (.gemini/rules/eck/)
|
|
97
|
-
|
|
98
|
-
Examples:
|
|
99
|
-
ec link-rules connect # connect cc in cwd
|
|
100
|
-
ec link-rules connect codex # connect codex in cwd
|
|
101
|
-
ec link-rules connect cc --dir /x # connect cc in specific dir
|
|
102
|
-
ec link-rules disconnect cc # disconnect cc
|
|
82
|
+
console.log(`Usage: ec link-rules <subcommand> [baseagent] [--dir <path>]
|
|
83
|
+
|
|
84
|
+
Subcommands:
|
|
85
|
+
connect Connect ECK rules to a project directory (default: cwd)
|
|
86
|
+
disconnect Remove ECK rules connection for a baseagent
|
|
87
|
+
status Show connection state for all baseagents
|
|
88
|
+
|
|
89
|
+
Arguments:
|
|
90
|
+
baseagent Target base agent: ${KNOWN_BASEAGENTS.join(', ')} (default: cc)
|
|
91
|
+
--dir <path> Target directory (default: current working directory)
|
|
92
|
+
|
|
93
|
+
Supported baseagents:
|
|
94
|
+
cc Claude Code (.claude/rules/eck/)
|
|
95
|
+
codex Codex (.codex/rules/eck/)
|
|
96
|
+
gemini Gemini CLI (.gemini/rules/eck/)
|
|
97
|
+
|
|
98
|
+
Examples:
|
|
99
|
+
ec link-rules connect # connect cc in cwd
|
|
100
|
+
ec link-rules connect codex # connect codex in cwd
|
|
101
|
+
ec link-rules connect cc --dir /x # connect cc in specific dir
|
|
102
|
+
ec link-rules disconnect cc # disconnect cc
|
|
103
103
|
ec link-rules status # show all connections`);
|
|
104
104
|
}
|
|
105
105
|
function showStatus() {
|
|
@@ -5,6 +5,9 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
5
5
|
'config',
|
|
6
6
|
'contact',
|
|
7
7
|
'ctl',
|
|
8
|
+
// These commands are authenticated again by their daemon IPC entrypoints.
|
|
9
|
+
'diag',
|
|
10
|
+
'menu-client',
|
|
8
11
|
'fs',
|
|
9
12
|
'group',
|
|
10
13
|
'handoff',
|
|
@@ -17,6 +20,7 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
17
20
|
'stats',
|
|
18
21
|
'status',
|
|
19
22
|
'storage',
|
|
23
|
+
'task',
|
|
20
24
|
'trigger',
|
|
21
25
|
'version',
|
|
22
26
|
'-v',
|
|
@@ -27,7 +31,7 @@ export class ManagedCommandNotAllowedError extends Error {
|
|
|
27
31
|
command;
|
|
28
32
|
code = 'NOT_ALLOWED';
|
|
29
33
|
constructor(command) {
|
|
30
|
-
super(`Command ${command} is not available in a managed Agent task`);
|
|
34
|
+
super(`Command ${command} is not available in a managed Agent task; run it from the host terminal after the task completes`);
|
|
31
35
|
this.command = command;
|
|
32
36
|
this.name = 'ManagedCommandNotAllowedError';
|
|
33
37
|
}
|
package/dist/cli/menu-client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { getArgValue, wantsHelp } from './help.js';
|
|
3
|
-
import { executeMenuClientRequest, MenuClientError } from '../aun/menu
|
|
3
|
+
import { executeMenuClientRequest, MenuClientError } from '../aun/menu/index.js';
|
|
4
|
+
import { readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
4
5
|
function parseDurationMs(value) {
|
|
5
6
|
if (value === undefined)
|
|
6
7
|
return undefined;
|
|
@@ -11,14 +12,14 @@ function parseDurationMs(value) {
|
|
|
11
12
|
const unit = match[2].toLowerCase();
|
|
12
13
|
return amount * (unit === 'ms' ? 1 : unit === 's' ? 1_000 : unit === 'm' ? 60_000 : 3_600_000);
|
|
13
14
|
}
|
|
14
|
-
function readRequest(args) {
|
|
15
|
+
function readRequest(args, readFile = (file) => fs.readFileSync(file, 'utf8')) {
|
|
15
16
|
const file = getArgValue(args, '--request-file');
|
|
16
17
|
const inline = getArgValue(args, '--request-json');
|
|
17
18
|
if (!!file === !!inline)
|
|
18
19
|
throw new MenuClientError('INVALID_ARGUMENT', '--request-file and --request-json are mutually exclusive');
|
|
19
20
|
let raw;
|
|
20
21
|
try {
|
|
21
|
-
raw = file ?
|
|
22
|
+
raw = file ? readFile(file) : inline;
|
|
22
23
|
}
|
|
23
24
|
catch (error) {
|
|
24
25
|
throw new MenuClientError('INVALID_ARGUMENT', `Unable to read request: ${error?.message ?? String(error)}`);
|
|
@@ -36,8 +37,12 @@ function readRequest(args) {
|
|
|
36
37
|
function validateOptions(args) {
|
|
37
38
|
const valueOptions = new Set(['--request-file', '--request-json', '--timeout', '--remote-token', '--ecweb-token', '--app', '--aun-path', '--format']);
|
|
38
39
|
const booleanOptions = new Set(['--encrypt', '--no-encrypt']);
|
|
40
|
+
const seen = new Set();
|
|
39
41
|
for (let index = 0; index < args.length; index += 1) {
|
|
40
42
|
const option = args[index];
|
|
43
|
+
if (seen.has(option))
|
|
44
|
+
throw new MenuClientError('INVALID_ARGUMENT', `Duplicate option: ${option}`);
|
|
45
|
+
seen.add(option);
|
|
41
46
|
if (booleanOptions.has(option))
|
|
42
47
|
continue;
|
|
43
48
|
if (!valueOptions.has(option))
|
|
@@ -54,22 +59,7 @@ function validateOptions(args) {
|
|
|
54
59
|
if (format !== undefined && format !== 'json')
|
|
55
60
|
throw new MenuClientError('INVALID_ARGUMENT', '--format currently supports only json');
|
|
56
61
|
}
|
|
57
|
-
export
|
|
58
|
-
if (wantsHelp(args)) {
|
|
59
|
-
console.log(`用法: ec menu-client request <from-aid> <daemon-aid> [选项]
|
|
60
|
-
|
|
61
|
-
--request-file <path> 从 JSON 文件读取一个 menu.* 请求
|
|
62
|
-
--request-json <json> 直接传入一个 menu.* JSON 请求
|
|
63
|
-
--timeout <时长> 默认 15s,最大 120s
|
|
64
|
-
--encrypt 使用 E2EE(默认)
|
|
65
|
-
--no-encrypt 已拒绝:ec-menu-client 必须使用 E2EE
|
|
66
|
-
--remote-token <token> 使用 daemon 远程访问 token 临时授权
|
|
67
|
-
--ecweb-token <token> --remote-token 的兼容别名
|
|
68
|
-
--app <slot> 覆盖默认 evolcore-menu-client 消费槽位
|
|
69
|
-
--aun-path <path> 覆盖本地 AUN keystore 根目录
|
|
70
|
-
--format json 输出标准 menu.response JSON`);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
62
|
+
export function parseMenuClientArgs(args, readFile) {
|
|
73
63
|
if (args[0] !== 'request')
|
|
74
64
|
throw new MenuClientError('INVALID_ARGUMENT', 'menu-client currently supports only the request subcommand');
|
|
75
65
|
const fromAid = args[1]?.trim();
|
|
@@ -78,18 +68,47 @@ export async function cmdMenuClient(args) {
|
|
|
78
68
|
throw new MenuClientError('INVALID_ARGUMENT', 'request requires <from-aid> and <daemon-aid>');
|
|
79
69
|
const options = args.slice(3);
|
|
80
70
|
validateOptions(options);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
71
|
+
return {
|
|
72
|
+
fromAid, targetAid, request: readRequest(options, readFile),
|
|
73
|
+
timeoutMs: parseDurationMs(getArgValue(options, '--timeout')),
|
|
74
|
+
encrypt: !options.includes('--no-encrypt'),
|
|
75
|
+
remoteAccessToken: getArgValue(options, '--remote-token') ?? getArgValue(options, '--ecweb-token'),
|
|
76
|
+
slotId: getArgValue(options, '--app'), aunPath: getArgValue(options, '--aun-path'),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export async function cmdMenuClient(args) {
|
|
80
|
+
if (wantsHelp(args)) {
|
|
81
|
+
console.log(`用法: ec menu-client request <from-aid> <daemon-aid> [选项]
|
|
82
|
+
|
|
83
|
+
--request-file <path> 从 JSON 文件读取一个 menu.* 请求
|
|
84
|
+
--request-json <json> 直接传入一个 menu.* JSON 请求
|
|
85
|
+
--timeout <时长> 默认 15s,最大 120s
|
|
86
|
+
--encrypt 使用 E2EE(默认)
|
|
87
|
+
--no-encrypt 已拒绝:ec-menu-client 必须使用 E2EE
|
|
88
|
+
--remote-token <token> 使用 daemon 远程访问 token 临时授权
|
|
89
|
+
--ecweb-token <token> --remote-token 的兼容别名
|
|
90
|
+
--app <slot> 覆盖默认 evolcore-menu-client 消费槽位
|
|
91
|
+
--aun-path <path> 覆盖本地 AUN keystore 根目录
|
|
92
|
+
--format json 输出标准 menu.response JSON`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let response;
|
|
96
|
+
if (process.env.EVOLCORE_SESSION_ID) {
|
|
97
|
+
const { ipcQuery, IpcTransportError } = await import('../ipc.js');
|
|
98
|
+
const { resolvePaths } = await import('../paths.js');
|
|
99
|
+
const result = await ipcQuery(resolvePaths().socket, {
|
|
100
|
+
type: 'menu-client.request', argv: args, sessionId: process.env.EVOLCORE_SESSION_ID,
|
|
101
|
+
delegationToken: readDelegationCredential(),
|
|
102
|
+
}, 250_000, { throwOnError: true }).catch(error => {
|
|
103
|
+
if (!(error instanceof IpcTransportError))
|
|
104
|
+
throw error;
|
|
105
|
+
throw new MenuClientError(error.code, error.message);
|
|
106
|
+
});
|
|
107
|
+
if (!result?.ok)
|
|
108
|
+
throw new MenuClientError(result?.code ?? 'DAEMON_UNAVAILABLE', result?.error ?? 'Managed Menu daemon is unavailable');
|
|
109
|
+
response = result.response;
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
|
+
response = await executeMenuClientRequest(parseMenuClientArgs(args));
|
|
94
113
|
console.log(JSON.stringify(response, null, 2));
|
|
95
114
|
}
|
package/dist/cli/model.js
CHANGED
|
@@ -20,7 +20,7 @@ import { ipcQuery } from '../ipc.js';
|
|
|
20
20
|
import { parsePeerKey } from '../core/relation/peer-identity.js';
|
|
21
21
|
import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
|
|
22
22
|
import { getFieldPermission } from '../config/roles.js';
|
|
23
|
-
import { AGENT_DELEGATION_TOKEN_ENV } from '../core/auth/agent-delegation.js';
|
|
23
|
+
import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
24
24
|
import { formatModelCheck, runModelCheck } from '../core/model/model-diagnostics.js';
|
|
25
25
|
import { validateRuntimeStringFieldOverride } from '../core/role/runtime-policy.js';
|
|
26
26
|
const ALL_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'auto'];
|
|
@@ -61,7 +61,7 @@ async function runCtlCommand(cmd, formatJson, timeoutMs = 10_000) {
|
|
|
61
61
|
type: 'ctl',
|
|
62
62
|
cmd,
|
|
63
63
|
sessionId,
|
|
64
|
-
delegationToken:
|
|
64
|
+
delegationToken: readDelegationCredential(),
|
|
65
65
|
}, timeoutMs);
|
|
66
66
|
if (!result)
|
|
67
67
|
fail(formatJson, 'DAEMON_UNAVAILABLE', '无法连接 evolcore 服务');
|
|
@@ -80,7 +80,7 @@ async function runManagedConfigOperation(args, formatJson) {
|
|
|
80
80
|
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
81
81
|
if (!sessionId)
|
|
82
82
|
fail(formatJson, 'NO_SESSION', 'EVOLCORE_SESSION_ID 未设置');
|
|
83
|
-
const delegationToken =
|
|
83
|
+
const delegationToken = readDelegationCredential();
|
|
84
84
|
if (!delegationToken) {
|
|
85
85
|
fail(formatJson, 'DELEGATION_REQUIRED', `${AGENT_DELEGATION_TOKEN_ENV} 未设置`);
|
|
86
86
|
}
|