evolcore 0.0.35 → 0.0.36
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 +31 -0
- package/README.md +6 -0
- package/bin/install-codex-managed-hooks.mjs +20 -3
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +88 -0
- package/dist/agents/claude-runner.js +59 -12
- package/dist/agents/codex/app-server-client.js +18 -1
- package/dist/agents/codex-runner.js +262 -21
- package/dist/agents/ecagent-runner.js +47 -11
- package/dist/agents/gemini-runner.js +36 -12
- package/dist/aun/aid/client.js +4 -3
- package/dist/aun/aid/control-aid.js +270 -8
- package/dist/aun/aid/identity.js +6 -3
- package/dist/aun/aid/ownership-operation.js +58 -0
- package/dist/aun/aid/store.js +1 -0
- package/dist/aun/group/fs-download.js +67 -2
- package/dist/aun/group/history.js +20 -5
- package/dist/aun/group/operations.js +8 -2
- package/dist/aun/menu/client.js +39 -2
- package/dist/aun/menu/transport.js +1 -1
- package/dist/aun/msg/history.js +43 -4
- package/dist/aun/msg/managed-operation.js +30 -53
- package/dist/aun/msg/p2p.js +51 -15
- package/dist/aun/outbox.js +4 -0
- package/dist/channels/aun.js +260 -73
- package/dist/channels/daemon.js +6 -4
- package/dist/channels/feishu.js +3 -0
- package/dist/cli/agent-command.js +161 -223
- package/dist/cli/agent-create.js +190 -223
- package/dist/cli/agent.js +3 -1
- package/dist/cli/aid-bind-command.js +53 -0
- package/dist/cli/aun-commands.js +384 -91
- package/dist/cli/bench.js +1 -1
- package/dist/cli/cli-argv.js +74 -0
- package/dist/cli/daemon-commands.js +105 -74
- package/dist/cli/diag.js +1 -1
- package/dist/cli/fs-command.js +18 -19
- package/dist/cli/getmeta-command.js +159 -6
- package/dist/cli/index.js +6 -12
- package/dist/cli/init-channel.js +8 -55
- package/dist/cli/init.js +125 -218
- package/dist/cli/queue-command.js +11 -8
- package/dist/cli/restart-monitor.js +134 -48
- package/dist/cli/session-command.js +1 -1
- package/dist/cli/stats.js +7 -5
- package/dist/cli/thread-command.js +103 -30
- package/dist/cli/trigger-command.js +1 -1
- package/dist/cli/watch-msg-diag.js +1 -0
- package/dist/config/access-policy.js +2 -2
- package/dist/config/boot-log.js +14 -11
- package/dist/config/config-field-policy.js +9 -1
- package/dist/config/config-manager.js +176 -90
- package/dist/config/config-operation-service.js +7 -14
- package/dist/config/contact-book-store.js +142 -26
- package/dist/config/contact-book.js +4 -2
- package/dist/config/lifecycle.js +1 -1
- package/dist/config/owner-config.js +96 -0
- package/dist/config/peer-role-resolver.js +12 -18
- package/dist/config/providers-config.js +382 -0
- package/dist/config/providers-import.js +74 -0
- package/dist/config/providers-management.js +328 -0
- package/dist/config/providers.js +22 -0
- package/dist/config/resolved-config-op.js +17 -14
- package/dist/config/snapshot.js +28 -16
- package/dist/config-store.js +18 -14
- package/dist/core/agent-ipc-registration.js +21 -63
- package/dist/core/agent-runtime.js +16 -5
- package/dist/core/auth/agent-delegation.js +199 -25
- package/dist/core/auth/auth-gateway.js +44 -2
- package/dist/core/auth/authorization-denial.js +1 -1
- package/dist/core/auth/debug-context.js +2 -1
- package/dist/core/auth/delegation-authorization.js +2 -2
- package/dist/core/auth/delegation-diagnostics.js +4 -1
- package/dist/core/auth/operation-authorizer.js +10 -1
- package/dist/core/auth/operation-catalog.js +19 -1
- package/dist/core/bootstrap-service.js +43 -20
- package/dist/core/channel-loader.js +0 -1
- package/dist/core/channel-runtime.js +30 -4
- package/dist/core/command/agent-control.js +196 -37
- package/dist/core/command/cli-intent-parser.js +60 -4
- package/dist/core/command/command-handler.js +212 -60
- package/dist/core/command/connect-menu.js +1 -0
- package/dist/core/command/diag-service.js +5 -4
- package/dist/core/command/file-search.js +368 -0
- package/dist/core/command/menu-catalog.js +2 -1
- package/dist/core/command/menu-handler.js +292 -107
- package/dist/core/command/menu-protocol.js +23 -0
- package/dist/core/command/role-menu.js +7 -19
- package/dist/core/command/skill-slash.js +130 -25
- package/dist/core/command/slash-handler.js +101 -53
- package/dist/core/command/topic-slash.js +16 -5
- package/dist/core/daemon-bootstrap.js +7 -1
- package/dist/core/daemon-control.js +19 -1
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-catalog.js +2 -0
- package/dist/core/evolagent-registry.js +13 -2
- package/dist/core/evolagent.js +3 -6
- package/dist/core/handoff/ipc-registration.js +2 -2
- package/dist/core/handoff/runtime.js +40 -6
- package/dist/core/handoff/store.js +1 -0
- package/dist/core/inference/text-inference.js +95 -6
- package/dist/core/ipc-registration.js +43 -24
- package/dist/core/memory/consolidation-context.js +4 -1
- package/dist/core/memory/consolidation.js +25 -14
- package/dist/core/message/aun-ipc-sender.js +296 -88
- package/dist/core/message/aun-request-registry.js +226 -0
- package/dist/core/message/create-status.js +33 -4
- package/dist/core/message/message-bridge.js +62 -13
- package/dist/core/message/message-log.js +0 -1
- package/dist/core/message/message-queue.js +4 -1
- package/dist/core/message/message-utils.js +8 -1
- package/dist/core/message/peer-mode.js +17 -9
- package/dist/core/message/response-engine.js +266 -124
- package/dist/core/message/retry-scheduler.js +11 -8
- package/dist/core/model/catalog-service.js +60 -18
- package/dist/core/model/model-catalog.js +112 -9
- package/dist/core/model/model-fallback.js +94 -26
- package/dist/core/ownership/owner-resolver.js +687 -0
- package/dist/core/permission/approval-gateway.js +196 -62
- package/dist/core/permission/ec-command-parser.js +138 -25
- package/dist/core/permission/filesystem-approval-scope.js +141 -0
- package/dist/core/permission/protected-paths.js +14 -1
- package/dist/core/permission/sandbox-runtime.js +171 -18
- package/dist/core/permission/tool-policy.js +13 -2
- package/dist/core/role/runtime-policy.js +3 -4
- package/dist/core/session/session-idle-monitor.js +10 -8
- package/dist/core/session/session-manager.js +72 -45
- package/dist/core/session/session-mapper.js +18 -7
- package/dist/core/session/session-renew.js +5 -4
- package/dist/core/session/session-title.js +2 -1
- package/dist/core/session/session-turn-coordinator.js +4 -2
- package/dist/core/skill/index-generator.js +2 -16
- package/dist/core/task/task-recovery-service.js +15 -2
- package/dist/core/thread/command-parser.js +28 -13
- package/dist/core/thread/index.js +1 -0
- package/dist/core/thread/ipc-operation.js +11 -8
- package/dist/core/thread/thread-operation.js +79 -44
- package/dist/core/thread/thread-route.js +54 -6
- package/dist/core/thread/thread-service.js +236 -45
- package/dist/core/thread/topic-id.js +248 -0
- package/dist/eck/kit-renderer.js +1 -1
- package/dist/eck/message-renderer.js +12 -2
- package/dist/index.js +50 -27
- package/dist/ipc.js +59 -6
- package/dist/paths.js +1 -0
- package/dist/product.js +1 -0
- package/dist/response-system/engines/v1/proactive-flow.js +10 -3
- package/dist/stats/db.js +8 -0
- package/dist/stats/writer.js +26 -4
- package/dist/trigger/authorization.js +48 -3
- package/dist/trigger/feedback.js +28 -10
- package/dist/trigger/ipc-service.js +86 -10
- package/dist/trigger/local-files.js +55 -23
- package/dist/trigger/scheduler.js +57 -11
- package/dist/trigger/system-definitions.js +1 -0
- package/dist/trigger/validation.js +44 -15
- package/dist/utils/aid-bind.js +17 -297
- package/dist/utils/avatar-upload.js +16 -4
- package/dist/utils/cross-platform.js +109 -34
- package/dist/utils/ecweb-supervisor.js +1 -1
- package/dist/utils/ecweb-utils.js +8 -1
- package/dist/utils/error-utils.js +44 -6
- package/dist/utils/instance-registry.js +12 -2
- package/dist/utils/npm-ops.js +102 -27
- package/dist/utils/package-version-info.js +72 -27
- package/dist/utils/restart-safety.js +50 -0
- package/dist/utils/upgrade-jobs.js +304 -0
- package/dist/utils/windows-autostart.js +17 -10
- package/kits/docs/INDEX.md +5 -0
- package/kits/docs/aun/ABILITY_CALLING.md +239 -0
- package/kits/docs/evolcore/INDEX.md +14 -3
- package/kits/docs/evolcore/agent-create.md +55 -141
- package/kits/docs/evolcore/agent.md +38 -16
- package/kits/docs/evolcore/aid.md +34 -0
- package/kits/docs/evolcore/config.md +20 -1
- package/kits/docs/evolcore/event.md +2 -2
- package/kits/docs/evolcore/fs.md +18 -2
- package/kits/docs/evolcore/group-collaboration.md +13 -246
- package/kits/docs/evolcore/group.md +2 -1
- package/kits/docs/evolcore/memory-consolidation-batches.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +65 -1
- package/kits/docs/evolcore/msg.md +64 -2
- package/kits/docs/evolcore/skill.md +86 -0
- package/kits/docs/evolcore/stats.md +6 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +145 -51
- package/kits/docs/evolcore/trigger.md +48 -3
- package/kits/eck_manifest.json +21 -0
- package/kits/eck_message_manifest.json +4 -4
- package/kits/migrations/migrate-role-config-v5.mjs +20 -7
- package/kits/rules/01-overview.md +2 -1
- package/kits/rules/03-identity.md +3 -1
- package/kits/rules/04-relation.md +1 -1
- package/kits/rules/07-memory-and-thread.md +1 -1
- package/kits/schemas/_meta.json +16 -1
- package/kits/schemas/agent-config.schema.13.json +44 -2
- package/kits/schemas/contact-book.schema.3.json +5 -0
- package/kits/schemas/daemon.schema.6.json +3 -1
- package/kits/schemas/daemon.schema.8.json +329 -0
- package/kits/schemas/defaults.schema.5.json +39 -3
- package/kits/schemas/providers.schema.1.json +76 -0
- package/kits/schemas/relation-config.schema.9.json +5 -1
- package/kits/skills/.switches.json +28 -0
- package/kits/skills/aid-ability/SKILL.md +214 -0
- package/kits/skills/ec-agent-create/SKILL.md +162 -0
- package/kits/skills/ec-group/SKILL.md +2 -1
- package/kits/skills/ec-group-collaboration/SKILL.md +228 -0
- package/kits/skills/ec-identity/SKILL.md +143 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +36 -3
- package/kits/skills/ec-skill/scripts/skill.mjs +202 -15
- package/kits/skills/ec-trigger/SKILL.md +167 -0
- package/kits/skills/ec-trigger/references/examples.md +153 -0
- package/kits/skills/thread-ops/SKILL.md +108 -420
- package/kits/templates/message-fragments/thread-context.md +1 -2
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/member.json +1 -1
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/bootstrap.md +1 -0
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +5 -4
- package/kits/templates/system-fragments/identity.md +2 -0
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +4 -3
package/dist/channels/daemon.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ExecutionTimeoutError } from '../utils/error-utils.js';
|
|
|
3
3
|
import { normalizeExecutionMode } from '../trigger/validation.js';
|
|
4
4
|
import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
|
|
5
5
|
import { assertSystemSessionLaunchable } from '../core/system-session/registry.js';
|
|
6
|
+
import { sessionTopicThreadId } from '../core/thread/topic-id.js';
|
|
6
7
|
const DEFAULT_WATCHDOG_MS = 11 * 60 * 1000;
|
|
7
8
|
export class DaemonChannel {
|
|
8
9
|
sessionManager;
|
|
@@ -75,7 +76,7 @@ export class DaemonChannel {
|
|
|
75
76
|
channelId: ctx.session.channelId,
|
|
76
77
|
selfAID: ctx.trigger.agentAid,
|
|
77
78
|
baseagent: ctx.baseagent,
|
|
78
|
-
threadId: ctx.session
|
|
79
|
+
threadId: sessionTopicThreadId(ctx.session) ?? '',
|
|
79
80
|
chatType: 'private',
|
|
80
81
|
peerId: `trigger:${ctx.trigger.id}`,
|
|
81
82
|
peerName: ctx.trigger.name,
|
|
@@ -186,11 +187,11 @@ export class DaemonChannel {
|
|
|
186
187
|
slot.acc.files.push({ path: payload.filePath, name: payload.fileName });
|
|
187
188
|
break;
|
|
188
189
|
case 'result.error':
|
|
189
|
-
slot.acc.error = { reason: payload.reason, text: payload.text };
|
|
190
|
+
slot.acc.error = { reason: payload.reason, text: payload.text, recoverable: payload.recoverable };
|
|
190
191
|
this.finish(runId, 'error', { errorType: payload.reason ?? 'result_error' });
|
|
191
192
|
break;
|
|
192
193
|
case 'system.error':
|
|
193
|
-
slot.acc.error = { reason: payload.subtype, text: payload.text };
|
|
194
|
+
slot.acc.error = { reason: payload.subtype, text: payload.text, recoverable: payload.recoverable };
|
|
194
195
|
this.finish(runId, 'error', { errorType: payload.subtype });
|
|
195
196
|
break;
|
|
196
197
|
case 'status.progress':
|
|
@@ -222,6 +223,7 @@ export class DaemonChannel {
|
|
|
222
223
|
slot.acc.error = {
|
|
223
224
|
reason: payload.metadata.errorType ?? 'status_error',
|
|
224
225
|
text: payload.metadata.message,
|
|
226
|
+
recoverable: payload.metadata.recoverable,
|
|
225
227
|
};
|
|
226
228
|
}
|
|
227
229
|
this.finish(runId, 'error', payload.metadata);
|
|
@@ -611,7 +613,7 @@ export class DaemonChannel {
|
|
|
611
613
|
channelId: session.channelId,
|
|
612
614
|
selfAID: spec.agentAid,
|
|
613
615
|
baseagent: spec.baseagent,
|
|
614
|
-
threadId: session
|
|
616
|
+
threadId: sessionTopicThreadId(session) ?? '',
|
|
615
617
|
chatType: 'private',
|
|
616
618
|
peerId: `bg:${spec.kind}`,
|
|
617
619
|
peerName: spec.kind,
|
package/dist/channels/feishu.js
CHANGED
|
@@ -1480,6 +1480,9 @@ export function buildResolvedV2(interaction, response) {
|
|
|
1480
1480
|
'allow': '✅ 已允许',
|
|
1481
1481
|
'always': temporaryGrantIsFileScoped ? '⏱ 已授权同文件 30 分钟' : '⏱ 已授权同操作 30 分钟',
|
|
1482
1482
|
'approve_session_30m': temporaryGrantIsFileScoped ? '⏱ 已授权同文件 30 分钟' : '⏱ 已授权本会话 30 分钟',
|
|
1483
|
+
'approve_file_60m': '⏱ 已授权同文件 60 分钟',
|
|
1484
|
+
'approve_directory_60m': '⏱ 已授权当前目录及子目录 60 分钟',
|
|
1485
|
+
'approve_all_directories_60m': '⏱ 已授权当前会话所有普通目录 60 分钟',
|
|
1483
1486
|
'deny': '❌ 已拒绝',
|
|
1484
1487
|
'cancel': '取消',
|
|
1485
1488
|
};
|
|
@@ -3,10 +3,15 @@ import { MAIN_CLI_BIN, SELF_AID_ENV, SESSION_ID_ENV } from '../product.js';
|
|
|
3
3
|
import { getArgValue, isHelpFlag, wantsHelp } from './help.js';
|
|
4
4
|
import { isHostChinese } from '../utils/locale.js';
|
|
5
5
|
import { readTaskRuntimeContextFromEnv } from './task-context.js';
|
|
6
|
-
import { parseAgentWelcomeArgs } from './agent-create.js';
|
|
6
|
+
import { parseAgentAvatarArgs, parseAgentWelcomeArgs, resolveAgentCreateMode } from './agent-create.js';
|
|
7
7
|
import { assertEcSingleLine } from './cli-argv.js';
|
|
8
8
|
import { canonicalizeEvolcoreCommandArgv } from '../core/permission/ec-command-parser.js';
|
|
9
|
-
|
|
9
|
+
function printCreatedAgentOwner(result) {
|
|
10
|
+
if (!result.ownerAid)
|
|
11
|
+
return;
|
|
12
|
+
console.log(` Owner 绑定目标: ${result.ownerAid}(以 Ownership 协议共识为准)`);
|
|
13
|
+
console.log(` 查看绑定状态: ${MAIN_CLI_BIN} aid bind status --subject ${result.aid}`);
|
|
14
|
+
}
|
|
10
15
|
function printBootstrapDeliveries(result) {
|
|
11
16
|
for (const delivery of result?.deliveries ?? []) {
|
|
12
17
|
if (delivery.status === 'sent')
|
|
@@ -65,6 +70,36 @@ function displayWidth(s) {
|
|
|
65
70
|
function padEndDisplay(s, targetWidth) {
|
|
66
71
|
return s + ' '.repeat(Math.max(0, targetWidth - displayWidth(s)));
|
|
67
72
|
}
|
|
73
|
+
function printAgentNewHelp() {
|
|
74
|
+
console.log(`用法: ${MAIN_CLI_BIN} agent new <aid> [--initialize | --bootstrap] [选项]
|
|
75
|
+
|
|
76
|
+
创建模式:
|
|
77
|
+
--initialize 默认;使用显式名片直接初始化并激活
|
|
78
|
+
--bootstrap 创建后进入 Bootstrap,与 --initialize 互斥
|
|
79
|
+
--non-interactive 保留支持;两种创建模式均隐含非交互
|
|
80
|
+
|
|
81
|
+
选项:
|
|
82
|
+
--project <path> 默认: 当前目录
|
|
83
|
+
--baseagent <claude|codex|gemini|ecagent>
|
|
84
|
+
默认: defaults 配置,否则检测本机可用基座
|
|
85
|
+
--owner <aid> 必填;初始协议 Owner 绑定意图
|
|
86
|
+
--name <display-name> 初始化必填;Bootstrap 默认取项目名称
|
|
87
|
+
--description <text> 初始化必填;Bootstrap 默认取项目描述
|
|
88
|
+
--tags <json-array> 初始化必填;3 到 6 个标签
|
|
89
|
+
--type <type> 主体类型,默认 agent
|
|
90
|
+
--avatar-file <path> 头像图片文件(或 attachment:<id>)
|
|
91
|
+
--avatar-url <https-url> 头像 HTTPS 地址;与 --avatar-file 互斥
|
|
92
|
+
--persona-file <path> 初始化人格 .md/.txt(或 --persona-text <text>)
|
|
93
|
+
--wait <seconds> 初始化等待 0–300 秒,默认 60
|
|
94
|
+
--dry-run 只预览最终参数,不注册 AID、不写文件
|
|
95
|
+
--force 仅 --bootstrap 支持,覆盖已有 config.json
|
|
96
|
+
--format json 输出 JSON
|
|
97
|
+
|
|
98
|
+
示例:
|
|
99
|
+
${MAIN_CLI_BIN} agent new mybot.agentid.pub --owner owner.agentid.pub --name 'My Bot' --description '项目助手' --tags '["coding","diagnostics","logs"]'
|
|
100
|
+
${MAIN_CLI_BIN} agent new mybot.agentid.pub --bootstrap --owner owner.agentid.pub
|
|
101
|
+
${MAIN_CLI_BIN} agent new mybot.agentid.pub --bootstrap --non-interactive --owner owner.agentid.pub --dry-run --format json`);
|
|
102
|
+
}
|
|
68
103
|
// ==================== Agent ====================
|
|
69
104
|
export async function cmdAgent(args) {
|
|
70
105
|
args = canonicalizeEvolcoreCommandArgv(['ec', 'agent', ...args]).slice(2);
|
|
@@ -91,9 +126,8 @@ export async function cmdAgent(args) {
|
|
|
91
126
|
Commands:
|
|
92
127
|
list 列出所有 agent
|
|
93
128
|
show <aid> 查看 agent 详情(身份 + 配置 + 连接 + 会话 + 路径)
|
|
94
|
-
new
|
|
95
|
-
new <aid> --
|
|
96
|
-
new <aid> --initialize ... 创建并激活(隐含非交互)
|
|
129
|
+
new <aid> ... 创建并激活(默认 --initialize,隐含非交互)
|
|
130
|
+
new <aid> --bootstrap ... 创建后进入 Bootstrap(隐含非交互)
|
|
97
131
|
initialize <aid> --resume 恢复一次性初始化
|
|
98
132
|
enable <aid> 启用 agent
|
|
99
133
|
disable <aid> 停用 agent
|
|
@@ -116,7 +150,7 @@ Options:
|
|
|
116
150
|
示例:
|
|
117
151
|
ec agent list
|
|
118
152
|
ec agent show mybot.agentid.pub
|
|
119
|
-
ec agent new mybot.agentid.pub
|
|
153
|
+
ec agent new mybot.agentid.pub --help
|
|
120
154
|
ec agent enable mybot.agentid.pub
|
|
121
155
|
ec agent get mybot.agentid.pub active_baseagent
|
|
122
156
|
ec agent set mybot.agentid.pub active_baseagent codex
|
|
@@ -126,9 +160,28 @@ Options:
|
|
|
126
160
|
ec agent delete mybot.agentid.pub --purge`);
|
|
127
161
|
return;
|
|
128
162
|
}
|
|
129
|
-
if (
|
|
163
|
+
if (sub === 'new' && wantsHelp(args)) {
|
|
164
|
+
printAgentNewHelp();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
let createMode;
|
|
168
|
+
if (sub === 'new') {
|
|
169
|
+
try {
|
|
170
|
+
createMode = resolveAgentCreateMode(args);
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
const result = { ok: false, code: 'INVALID_ARGS', error: error instanceof Error ? error.message : String(error) };
|
|
174
|
+
if (formatJson)
|
|
175
|
+
console.log(JSON.stringify(result));
|
|
176
|
+
else
|
|
177
|
+
console.error(`❌ ${result.error}`);
|
|
178
|
+
process.exitCode = 1;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if ((sub === 'new' && createMode === 'initialize') || sub === 'initialize') {
|
|
130
183
|
if (wantsHelp(args)) {
|
|
131
|
-
console.log(
|
|
184
|
+
console.log(`${MAIN_CLI_BIN} agent initialize <aid> --resume [--wait 0..300] [--format json]\n恢复一次性初始化;默认等待 60 秒。`);
|
|
132
185
|
return;
|
|
133
186
|
}
|
|
134
187
|
try {
|
|
@@ -155,23 +208,9 @@ Options:
|
|
|
155
208
|
}
|
|
156
209
|
return;
|
|
157
210
|
}
|
|
158
|
-
const { agentList, agentShow,
|
|
211
|
+
const { agentList, agentShow, agentCreateNonInteractive, agentReload, agentEnable, agentDisable, agentGet, agentSet, agentPersona, agentWelcome, agentRename, agentDelete, agentReady, runManagedAgentOperation, } = await import('./agent.js');
|
|
159
212
|
const { parseAgentOwnerArgs, parseAgentTags, resolveAgentCreatePlan, validateAgentCreatePlan } = await import('./agent-create.js');
|
|
160
213
|
if (process.env.EVOLCORE_SESSION_ID && !wantsHelp(args) && !new Set(['get', 'set', 'persona', 'welcome', 'ready']).has(sub)) {
|
|
161
|
-
if (sub === 'new' && !args.includes('--non-interactive') && !args.includes('--initialize')) {
|
|
162
|
-
const error = {
|
|
163
|
-
ok: false,
|
|
164
|
-
code: 'MANAGED_NON_INTERACTIVE_REQUIRED',
|
|
165
|
-
error: 'Managed Agent tasks must use `ec agent new <aid> --non-interactive`; interactive creation is unavailable here. Use ECWeb for interactive setup.',
|
|
166
|
-
data: { reasonCode: 'MANAGED_NON_INTERACTIVE_REQUIRED', nextStep: 'Use `ec agent new <aid> --non-interactive` or ECWeb.' },
|
|
167
|
-
};
|
|
168
|
-
if (formatJson)
|
|
169
|
-
console.log(JSON.stringify(error));
|
|
170
|
-
else
|
|
171
|
-
console.error(`❌ [${error.code}] ${error.error}`);
|
|
172
|
-
process.exitCode = 1;
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
214
|
const result = await runManagedAgentOperation(args);
|
|
176
215
|
if (!result.ok) {
|
|
177
216
|
if (formatJson)
|
|
@@ -298,39 +337,8 @@ Options:
|
|
|
298
337
|
}
|
|
299
338
|
// --- new ---
|
|
300
339
|
if (sub === 'new') {
|
|
301
|
-
if (wantsHelp(args)) {
|
|
302
|
-
console.log(`用法: ec agent new [aid] 交互式创建
|
|
303
|
-
ec agent new <aid> --non-interactive [选项]
|
|
304
|
-
|
|
305
|
-
非交互模式选项:
|
|
306
|
-
--initialize 使用显式名片直接完成初始化(隐含 --non-interactive)
|
|
307
|
-
--persona-file <path> 初始化人格 .md/.txt(或 --persona-text <text>)
|
|
308
|
-
--wait <seconds> 初始化等待 0–300 秒,默认 60
|
|
309
|
-
--project <path> 默认: 当前目录
|
|
310
|
-
--baseagent <claude|codex|gemini|ecagent>
|
|
311
|
-
默认: defaults 配置,否则检测本机可用基座
|
|
312
|
-
--owner <aid> 默认: daemon.json 第一个 owner
|
|
313
|
-
--owners <json-array> 多个 Owner;与 --owner 互斥
|
|
314
|
-
--handoff <context> 当前任务的 Bootstrap 上下文
|
|
315
|
-
--avatar-file <path> 头像图片文件(沿用 ec aid avatar)
|
|
316
|
-
--avatar-url <https-url> 头像 HTTPS 地址(沿用 ec aid avatar)
|
|
317
|
-
--name <display-name> 默认: package.json name,否则目录名
|
|
318
|
-
--description <text> 默认: package.json description,否则使用 EvolCore 默认描述
|
|
319
|
-
--type <type> 主体类型: human|agent|group|service|device|org|host(默认 agent)
|
|
320
|
-
--tags <json-array> 3 到 6 个标签,例如 '["coding","diagnostics","logs"]'
|
|
321
|
-
--dry-run 只预览最终参数,不注册 AID、不写文件
|
|
322
|
-
--force 覆盖已有 config.json
|
|
323
|
-
--format json 输出 JSON
|
|
324
|
-
|
|
325
|
-
示例:
|
|
326
|
-
ec agent new mybot.agentid.pub
|
|
327
|
-
ec agent new mybot.agentid.pub --non-interactive
|
|
328
|
-
ec agent new mybot.agentid.pub --non-interactive --dry-run --format json
|
|
329
|
-
ec agent new mybot.agentid.pub --non-interactive --project ../project --baseagent claude`);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
340
|
if (args.includes('--handoff')) {
|
|
333
|
-
const result = { ok: false, code: '
|
|
341
|
+
const result = { ok: false, code: 'INVALID_ARGS', error: 'Agent creation --handoff has been removed' };
|
|
334
342
|
if (formatJson)
|
|
335
343
|
console.log(JSON.stringify(result));
|
|
336
344
|
else
|
|
@@ -339,181 +347,111 @@ Options:
|
|
|
339
347
|
return;
|
|
340
348
|
}
|
|
341
349
|
const name = args[1];
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (
|
|
345
|
-
console.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
else
|
|
399
|
-
console.error(`❌ ${error.error}`);
|
|
400
|
-
process.exitCode = 1;
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
if (args.includes('--dry-run')) {
|
|
404
|
-
const preview = { ok: true, dryRun: true, plan };
|
|
405
|
-
if (formatJson)
|
|
406
|
-
console.log(JSON.stringify(preview, null, 2));
|
|
407
|
-
else {
|
|
408
|
-
console.log('EvolAgent 创建计划(dry-run)');
|
|
409
|
-
console.log(` AID: ${plan.aid}`);
|
|
410
|
-
console.log(` Project: ${plan.project}`);
|
|
411
|
-
console.log(` Baseagent: ${plan.baseagent} (${plan.baseagentSource})`);
|
|
412
|
-
console.log(` Owner: ${plan.owners?.join(', ') || plan.owner || '未设置'} (${plan.ownerSource})`);
|
|
413
|
-
console.log(` Name: ${plan.name} (${plan.nameSource})`);
|
|
414
|
-
if (plan.description)
|
|
415
|
-
console.log(` Description: ${plan.description} (${plan.descriptionSource})`);
|
|
416
|
-
console.log(` Existing config: ${plan.configExists ? (plan.force ? '将覆盖' : '是') : '否'}`);
|
|
417
|
-
}
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
const result = await agentCreateNonInteractive({
|
|
421
|
-
aid: plan.aid,
|
|
422
|
-
baseagent: plan.baseagent,
|
|
423
|
-
project: plan.project,
|
|
424
|
-
owner: plan.owner,
|
|
425
|
-
owners: plan.owners,
|
|
426
|
-
name: plan.name,
|
|
427
|
-
description: plan.description,
|
|
428
|
-
type: plan.type,
|
|
429
|
-
tags: plan.tags,
|
|
430
|
-
force: args.includes('--force'),
|
|
431
|
-
avatarFile: plan.avatarFile,
|
|
432
|
-
avatarUrl: plan.avatarUrl,
|
|
433
|
-
});
|
|
434
|
-
if (!result.ok) {
|
|
435
|
-
if (formatJson) {
|
|
436
|
-
console.log(JSON.stringify(result));
|
|
437
|
-
}
|
|
438
|
-
else {
|
|
439
|
-
console.error(`❌ ${result.error}`);
|
|
440
|
-
}
|
|
441
|
-
process.exit(1);
|
|
442
|
-
}
|
|
443
|
-
if (result.ownerBindInterrupted)
|
|
444
|
-
return;
|
|
445
|
-
if (formatJson) {
|
|
446
|
-
console.log(JSON.stringify(result, null, 2));
|
|
447
|
-
}
|
|
350
|
+
if (!name || name.startsWith('--')) {
|
|
351
|
+
const result = { ok: false, code: 'INVALID_ARGS', error: `${MAIN_CLI_BIN} agent new <aid> --bootstrap requires an AID` };
|
|
352
|
+
if (formatJson)
|
|
353
|
+
console.log(JSON.stringify(result));
|
|
354
|
+
else
|
|
355
|
+
console.error(result.error);
|
|
356
|
+
process.exitCode = 1;
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const getArg = (flag) => {
|
|
360
|
+
const idx = args.indexOf(flag);
|
|
361
|
+
return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
|
|
362
|
+
};
|
|
363
|
+
let ownerOptions;
|
|
364
|
+
let avatarOptions;
|
|
365
|
+
let tags;
|
|
366
|
+
try {
|
|
367
|
+
ownerOptions = parseAgentOwnerArgs(args);
|
|
368
|
+
avatarOptions = parseAgentAvatarArgs(args);
|
|
369
|
+
tags = parseAgentTags(getArg('--tags'));
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
const result = { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
373
|
+
if (formatJson)
|
|
374
|
+
console.log(JSON.stringify(result));
|
|
375
|
+
else
|
|
376
|
+
console.error(`❌ ${result.error}`);
|
|
377
|
+
process.exitCode = 1;
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const plan = resolveAgentCreatePlan({
|
|
381
|
+
aid: name,
|
|
382
|
+
project: getArg('--project'),
|
|
383
|
+
baseagent: getArg('--baseagent'),
|
|
384
|
+
...ownerOptions,
|
|
385
|
+
...avatarOptions,
|
|
386
|
+
name: getArg('--name'),
|
|
387
|
+
description: getArg('--description'),
|
|
388
|
+
type: getArg('--type'),
|
|
389
|
+
tags,
|
|
390
|
+
force: args.includes('--force'),
|
|
391
|
+
});
|
|
392
|
+
const validationError = validateAgentCreatePlan(plan);
|
|
393
|
+
if (validationError) {
|
|
394
|
+
const error = { ok: false, error: validationError };
|
|
395
|
+
if (formatJson)
|
|
396
|
+
console.log(JSON.stringify(error));
|
|
397
|
+
else
|
|
398
|
+
console.error(`❌ ${error.error}`);
|
|
399
|
+
process.exitCode = 1;
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (args.includes('--dry-run')) {
|
|
403
|
+
const preview = { ok: true, dryRun: true, plan };
|
|
404
|
+
if (formatJson)
|
|
405
|
+
console.log(JSON.stringify(preview, null, 2));
|
|
448
406
|
else {
|
|
449
|
-
console.log(
|
|
450
|
-
console.log(
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
console.log(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if (result.ownerContactsSynced?.length) {
|
|
459
|
-
console.log(` ✓ 已同步 Owner 联系人: ${result.ownerContactsSynced.join(', ')}`);
|
|
460
|
-
}
|
|
461
|
-
if (result.ownerContactsSkipped?.length) {
|
|
462
|
-
console.log(` ⚠ 无本地联系人簿,跳过 Owner: ${result.ownerContactsSkipped.join(', ')}`);
|
|
463
|
-
}
|
|
464
|
-
if (result.ownerContactSyncErrors?.length) {
|
|
465
|
-
console.log(` ⚠ Owner 联系人同步失败: ${result.ownerContactSyncErrors.join('; ')}`);
|
|
466
|
-
}
|
|
467
|
-
if (result.ownerBoundAid) {
|
|
468
|
-
console.log(` ✓ agent owner 已绑定: ${result.ownerBoundAid}`);
|
|
469
|
-
}
|
|
470
|
-
else if (result.ownerBindSkipped) {
|
|
471
|
-
console.log(' ⚠ agent owner 未通过二维码绑定');
|
|
472
|
-
}
|
|
407
|
+
console.log('EvolAgent 创建计划(dry-run)');
|
|
408
|
+
console.log(` AID: ${plan.aid}`);
|
|
409
|
+
console.log(` Project: ${plan.project}`);
|
|
410
|
+
console.log(` Baseagent: ${plan.baseagent} (${plan.baseagentSource})`);
|
|
411
|
+
console.log(` Owner: ${plan.owner || '未设置'} (${plan.ownerSource})`);
|
|
412
|
+
console.log(` Name: ${plan.name} (${plan.nameSource})`);
|
|
413
|
+
if (plan.description)
|
|
414
|
+
console.log(` Description: ${plan.description} (${plan.descriptionSource})`);
|
|
415
|
+
console.log(` Existing config: ${plan.configExists ? (plan.force ? '将覆盖' : '是') : '否'}`);
|
|
473
416
|
}
|
|
417
|
+
return;
|
|
474
418
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
419
|
+
const result = await agentCreateNonInteractive({
|
|
420
|
+
aid: plan.aid,
|
|
421
|
+
baseagent: plan.baseagent,
|
|
422
|
+
project: plan.project,
|
|
423
|
+
owner: plan.owner,
|
|
424
|
+
name: plan.name,
|
|
425
|
+
description: plan.description,
|
|
426
|
+
type: plan.type,
|
|
427
|
+
tags: plan.tags,
|
|
428
|
+
force: args.includes('--force'),
|
|
429
|
+
avatarFile: plan.avatarFile,
|
|
430
|
+
avatarUrl: plan.avatarUrl,
|
|
431
|
+
});
|
|
432
|
+
if (!result.ok) {
|
|
488
433
|
if (formatJson) {
|
|
489
|
-
console.log(JSON.stringify(result
|
|
434
|
+
console.log(JSON.stringify(result));
|
|
490
435
|
}
|
|
491
436
|
else {
|
|
492
|
-
console.
|
|
493
|
-
console.log(result.agentmdUploaded
|
|
494
|
-
? ' ✓ agent.md 已发布'
|
|
495
|
-
: ' ⚠ agent.md 上传失败(可用 ec aid agentmd put 重试)');
|
|
496
|
-
console.log(result.hotLoaded
|
|
497
|
-
? ' ✓ 已热重载,agent 已上线'
|
|
498
|
-
: result.hotLoadError
|
|
499
|
-
? ` ✗ 热重载失败:${result.hotLoadError}`
|
|
500
|
-
: ' ⚠ 服务未运行,下次 ec start 时生效');
|
|
501
|
-
if (result.ownerContactsSynced?.length) {
|
|
502
|
-
console.log(` ✓ 已同步 Owner 联系人: ${result.ownerContactsSynced.join(', ')}`);
|
|
503
|
-
}
|
|
504
|
-
if (result.ownerContactsSkipped?.length) {
|
|
505
|
-
console.log(` ⚠ 无本地联系人簿,跳过 Owner: ${result.ownerContactsSkipped.join(', ')}`);
|
|
506
|
-
}
|
|
507
|
-
if (result.ownerContactSyncErrors?.length) {
|
|
508
|
-
console.log(` ⚠ Owner 联系人同步失败: ${result.ownerContactSyncErrors.join('; ')}`);
|
|
509
|
-
}
|
|
510
|
-
if (result.ownerBoundAid) {
|
|
511
|
-
console.log(` ✓ agent owner 已绑定: ${result.ownerBoundAid}`);
|
|
512
|
-
}
|
|
513
|
-
else if (result.ownerBindSkipped) {
|
|
514
|
-
console.log(' ⚠ agent owner 未通过二维码绑定');
|
|
515
|
-
}
|
|
437
|
+
console.error(`❌ ${result.error}`);
|
|
516
438
|
}
|
|
439
|
+
process.exit(1);
|
|
440
|
+
}
|
|
441
|
+
if (formatJson) {
|
|
442
|
+
console.log(JSON.stringify(result, null, 2));
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
console.log(`✓ Created: ${result.configPath}`);
|
|
446
|
+
console.log(result.agentmdUploaded
|
|
447
|
+
? ' ✓ agent.md 已发布'
|
|
448
|
+
: ' ⚠ agent.md 上传失败(可用 ec aid agentmd put 重试)');
|
|
449
|
+
console.log(result.hotLoaded
|
|
450
|
+
? ' ✓ 已热重载,agent 已上线'
|
|
451
|
+
: result.hotLoadError
|
|
452
|
+
? ` ✗ 热重载失败:${result.hotLoadError}`
|
|
453
|
+
: ' ⚠ 服务未运行,下次 ec start 时生效');
|
|
454
|
+
printCreatedAgentOwner(result);
|
|
517
455
|
}
|
|
518
456
|
return;
|
|
519
457
|
}
|