evolcore 0.0.42 → 0.0.43-test.1
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 +35 -0
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/agent-runtime.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +5 -3
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
package/dist/cli/aun-commands.js
CHANGED
|
@@ -2,13 +2,13 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
import { agentMdPath, resolvePaths, resolveRoot } from '../paths.js';
|
|
5
|
-
import { normalizeGroupAid
|
|
5
|
+
import { normalizeGroupAid } from '../aun/group/index.js';
|
|
6
6
|
import { getArgValue, isHelpFlag, wantsHelp } from './help.js';
|
|
7
7
|
import { daemonUnavailableMessage, queryDaemon } from './help.js';
|
|
8
8
|
import { isValidAid as validSendAid } from '../aun/aid/validation.js';
|
|
9
|
-
import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
10
|
-
import {
|
|
11
|
-
import { readBestTaskRuntimeContext } from './task-context.js';
|
|
9
|
+
import { AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV, readDelegationCredential, } from '../core/auth/agent-delegation.js';
|
|
10
|
+
import { MAIN_CLI_BIN, SELF_AID_ENV, SESSION_ID_ENV } from '../product.js';
|
|
11
|
+
import { isTrustedFullAccessRuntimeContext, readBestTaskRuntimeContext, readVerifiedTaskRuntimeContext, RUNTIME_LOCK_DIR_ENV, SESSION_RUNTIME_DIR_ENV, TASK_RUNTIME_CONTEXT_ENV, } from './task-context.js';
|
|
12
12
|
import { assertEcSingleLine, parseTimeArg, TIME_ARG_FORMATS } from './cli-argv.js';
|
|
13
13
|
import { canonicalizeEvolcoreCommandArgv } from '../core/permission/ec-command-parser.js';
|
|
14
14
|
import { ManagedGroupOperationError } from '../aun/msg/managed-operation.js';
|
|
@@ -130,14 +130,6 @@ async function runManagedAid(args, formatJson) {
|
|
|
130
130
|
const parsed = resolveManagedAidOperation(['aid', ...args]);
|
|
131
131
|
if (!parsed.ok)
|
|
132
132
|
failManagedAid(formatJson, parsed.code, parsed.reason);
|
|
133
|
-
const runtime = await readBestTaskRuntimeContext();
|
|
134
|
-
const requiresSelfAid = parsed.command.kind === 'show'
|
|
135
|
-
|| parsed.command.kind === 'agentmd.put'
|
|
136
|
-
|| parsed.command.kind === 'agentmd.set'
|
|
137
|
-
|| parsed.command.kind === 'avatar';
|
|
138
|
-
if (requiresSelfAid && runtime?.selfAid && parsed.command.aid !== runtime.selfAid.replace(/^@/, '')) {
|
|
139
|
-
failManagedAid(formatJson, 'SCOPE_MISMATCH', `托管任务只能操作当前 self AID:${runtime.selfAid}`);
|
|
140
|
-
}
|
|
141
133
|
const { response, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
142
134
|
type: 'aid.op',
|
|
143
135
|
argv: ['aid', ...args],
|
|
@@ -160,6 +152,13 @@ async function runManagedAid(args, formatJson) {
|
|
|
160
152
|
failManagedAid(formatJson, response.code || 'AID_OPERATION_FAILED', error);
|
|
161
153
|
}
|
|
162
154
|
switch (response.result.kind) {
|
|
155
|
+
case 'list':
|
|
156
|
+
if (formatJson)
|
|
157
|
+
console.log(JSON.stringify(response.result.value, null, 2));
|
|
158
|
+
else
|
|
159
|
+
for (const item of response.result.value)
|
|
160
|
+
console.log(item.aid);
|
|
161
|
+
return;
|
|
163
162
|
case 'show':
|
|
164
163
|
renderAidShow(response.result.value, formatJson);
|
|
165
164
|
return;
|
|
@@ -220,8 +219,6 @@ async function runManagedGroup(args, formatJson) {
|
|
|
220
219
|
const parsed = resolveManagedGroupOperation(['group', ...args]);
|
|
221
220
|
if (!parsed.ok)
|
|
222
221
|
failManagedGroup(formatJson, parsed.code, parsed.reason);
|
|
223
|
-
const runtime = await readBestTaskRuntimeContext();
|
|
224
|
-
validateManagedGroupScope(parsed.command.from, parsed.command.groupId, runtime, formatJson);
|
|
225
222
|
const { response, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
226
223
|
type: 'group.op',
|
|
227
224
|
argv: ['group', ...args],
|
|
@@ -248,38 +245,6 @@ async function runManagedMsg(args, formatJson) {
|
|
|
248
245
|
const parsed = resolveManagedMsgOperation(['msg', ...args]);
|
|
249
246
|
if (!parsed.ok)
|
|
250
247
|
failManagedGroup(formatJson, parsed.code, parsed.reason);
|
|
251
|
-
const runtime = await readBestTaskRuntimeContext();
|
|
252
|
-
if (runtime?.selfAid
|
|
253
|
-
&& parsed.command.from !== runtime.selfAid.replace(/^@/, '')) {
|
|
254
|
-
failManagedGroup(formatJson, 'SCOPE_MISMATCH', `托管任务只能使用当前 self AID:${runtime.selfAid}`);
|
|
255
|
-
}
|
|
256
|
-
const isSelectorHistory = parsed.command.kind === 'history'
|
|
257
|
-
&& !!parsed.command.channelKey
|
|
258
|
-
&& !!parsed.command.peerId;
|
|
259
|
-
if (isSelectorHistory) {
|
|
260
|
-
// Trigger tasks retain their originating channel in runtime.channel. The
|
|
261
|
-
// daemon-created session route is the stable, non-spoofable discriminator.
|
|
262
|
-
if (runtime && !runtime.channelId?.startsWith('trigger:')) {
|
|
263
|
-
failManagedGroup(formatJson, 'SCOPE_MISMATCH', '跨渠道 history selector 仅允许可信 Trigger 会话使用');
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
// `--thread` 是话题作用域的读取:目标对端由话题推断,数据是本 agent 自己的
|
|
268
|
-
// 消息日志,因此既不受"当前必须是私聊"限制(群会话里也要能查 A↔C 的话题),
|
|
269
|
-
// 也不受"只能查当前对端"限制。不带 --thread 时保持原有边界。
|
|
270
|
-
const threadScoped = parsed.command.kind === 'history' && !!parsed.command.threadId;
|
|
271
|
-
if (runtime && (runtime.channel !== 'aun' || runtime.chatType !== 'private') && !threadScoped) {
|
|
272
|
-
failManagedGroup(formatJson, 'SCOPE_MISMATCH', 'ec msg history/online 只能读取当前 AUN 私聊关系');
|
|
273
|
-
}
|
|
274
|
-
// owner/admin 可以跨对端读历史(每次查询仍只针对一个对端)。这里只是快速
|
|
275
|
-
// 预检:角色未知时放行交给 daemon 判定,daemon 侧 handleMsgOperation 才是
|
|
276
|
-
// 权威关卡,member 由 currentRelationOnly 约束、visitor 直接拒绝。
|
|
277
|
-
const mayReadCrossPeer = parsed.command.kind === 'history'
|
|
278
|
-
&& (threadScoped || runtime?.peerRole === undefined || isManagementRole(runtime.peerRole));
|
|
279
|
-
if (!mayReadCrossPeer && runtime?.channelId && parsed.command.target !== runtime.channelId.replace(/^@/, '')) {
|
|
280
|
-
failManagedGroup(formatJson, 'SCOPE_MISMATCH', `只能读取当前 AUN 私聊对端:${runtime.channelId}`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
248
|
const { response, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
284
249
|
type: 'msg.op',
|
|
285
250
|
argv: ['msg', ...args],
|
|
@@ -294,21 +259,6 @@ async function runManagedMsg(args, formatJson) {
|
|
|
294
259
|
}
|
|
295
260
|
return response.result;
|
|
296
261
|
}
|
|
297
|
-
function validateManagedGroupScope(from, groupId, runtime, formatJson) {
|
|
298
|
-
if (!runtime)
|
|
299
|
-
return;
|
|
300
|
-
if (runtime.selfAid && from !== runtime.selfAid.replace(/^@/, '')) {
|
|
301
|
-
failManagedGroup(formatJson, 'SCOPE_MISMATCH', `托管任务只能使用当前 self AID:${runtime.selfAid}`);
|
|
302
|
-
}
|
|
303
|
-
if (!groupId || (runtime.peerRole !== 'member' && runtime.peerRole !== 'visitor'))
|
|
304
|
-
return;
|
|
305
|
-
if (runtime.channel !== 'aun' || runtime.chatType !== 'group') {
|
|
306
|
-
failManagedGroup(formatJson, 'ARGUMENT_MISMATCH', `当前角色 ${runtime.peerRole} 只能在 AUN 群聊任务中操作当前群`);
|
|
307
|
-
}
|
|
308
|
-
if (!runtime.channelId || !sameGroupAid(groupId, runtime.channelId)) {
|
|
309
|
-
failManagedGroup(formatJson, 'ARGUMENT_MISMATCH', `当前角色 ${runtime.peerRole} 只能操作当前群 ${runtime.channelId ?? '<unknown>'},不能操作 ${groupId}`);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
262
|
function renderManagedMsgResult(sub, result, formatJson) {
|
|
313
263
|
if (formatJson) {
|
|
314
264
|
console.log(JSON.stringify(result));
|
|
@@ -450,6 +400,77 @@ function renderManagedGroupResult(args, result, formatJson) {
|
|
|
450
400
|
}
|
|
451
401
|
console.log(`✓ group ${sub} 完成`);
|
|
452
402
|
}
|
|
403
|
+
async function cmdAidCert(args) {
|
|
404
|
+
const formatJson = getArgValue(args, '--format') === 'json';
|
|
405
|
+
if (!args[0] || isHelpFlag(args[0]) || wantsHelp(args)) {
|
|
406
|
+
console.log(`用法: ${MAIN_CLI_BIN} aid cert renew <aid> [--format json] [--aun-path <path>]
|
|
407
|
+
|
|
408
|
+
使用现有私钥续期证书,保留原 AID 和密钥;不会创建身份或重新注册。
|
|
409
|
+
缺失或空证书时尝试从 AUN PKI 恢复;损坏、过期或与本地私钥不匹配时返回错误。
|
|
410
|
+
本命令仅限独立宿主终端,托管 Agent 会话不可执行。
|
|
411
|
+
|
|
412
|
+
选项:
|
|
413
|
+
--format json 输出 JSON,包括新证书到期时间和指纹
|
|
414
|
+
--aun-path <path> 指定 AUN keystore 根;未传时沿用 AUN_HOME / EVOLCORE_HOME
|
|
415
|
+
--help, -h 显示帮助`);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const managedKeys = [
|
|
419
|
+
SESSION_ID_ENV,
|
|
420
|
+
AGENT_DELEGATION_TOKEN_ENV,
|
|
421
|
+
CODEX_SESSION_TOKEN_ENV,
|
|
422
|
+
TASK_RUNTIME_CONTEXT_ENV,
|
|
423
|
+
SESSION_RUNTIME_DIR_ENV,
|
|
424
|
+
RUNTIME_LOCK_DIR_ENV,
|
|
425
|
+
];
|
|
426
|
+
if (managedKeys.some(key => process.env[key] !== undefined)) {
|
|
427
|
+
failManagedAid(formatJson, 'NOT_ALLOWED', '证书续期仅允许在独立宿主终端执行,托管 Agent 会话不可操作本地密钥');
|
|
428
|
+
}
|
|
429
|
+
if (args[0] !== 'renew') {
|
|
430
|
+
failManagedAid(formatJson, 'INVALID_ARGUMENT', `用法: ${MAIN_CLI_BIN} aid cert renew <aid>`);
|
|
431
|
+
}
|
|
432
|
+
const aid = args[1];
|
|
433
|
+
if (!aid || aid.startsWith('-')) {
|
|
434
|
+
failManagedAid(formatJson, 'MISSING_AID', 'cert renew requires an AID');
|
|
435
|
+
}
|
|
436
|
+
if (!validSendAid(aid)) {
|
|
437
|
+
failManagedAid(formatJson, 'INVALID_AID', `invalid AID: ${aid}`);
|
|
438
|
+
}
|
|
439
|
+
let aunPath = resolveAunPath([]);
|
|
440
|
+
const seen = new Set();
|
|
441
|
+
for (let index = 2; index < args.length; index += 2) {
|
|
442
|
+
const option = args[index];
|
|
443
|
+
const value = args[index + 1];
|
|
444
|
+
if (seen.has(option) || !value?.trim() || value.startsWith('--')) {
|
|
445
|
+
failManagedAid(formatJson, 'INVALID_ARGUMENT', `Invalid or duplicate option: ${option}`);
|
|
446
|
+
}
|
|
447
|
+
seen.add(option);
|
|
448
|
+
if (option === '--format' && value === 'json')
|
|
449
|
+
continue;
|
|
450
|
+
if (option === '--aun-path') {
|
|
451
|
+
aunPath = value;
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
failManagedAid(formatJson, 'INVALID_ARGUMENT', `Unsupported option or value: ${option} ${value}`);
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
const { aidRenewCertificate } = await import('../aun/aid/index.js');
|
|
458
|
+
const result = await aidRenewCertificate(aid, { aunPath });
|
|
459
|
+
if (formatJson)
|
|
460
|
+
console.log(JSON.stringify({ ok: true, renewed: true, ...result }, null, 2));
|
|
461
|
+
else {
|
|
462
|
+
console.log(`✓ ${aid} 证书已续期(原密钥不变)`);
|
|
463
|
+
console.log(` 到期时间: ${result.newCertExpiresAt}`);
|
|
464
|
+
console.log(` 证书指纹: ${result.newFingerprint}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
catch (error) {
|
|
468
|
+
const code = error && typeof error === 'object' && 'code' in error
|
|
469
|
+
? String(error.code)
|
|
470
|
+
: 'CERT_RENEWAL_FAILED';
|
|
471
|
+
failManagedAid(formatJson, code, error instanceof Error ? error.message : String(error));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
453
474
|
export async function cmdAid(args) {
|
|
454
475
|
const sub = args[0];
|
|
455
476
|
const formatJson = getArgValue(args, '--format') === 'json';
|
|
@@ -460,6 +481,7 @@ export async function cmdAid(args) {
|
|
|
460
481
|
Commands:
|
|
461
482
|
list 列出本地所有 AID(实测 sign+verify)
|
|
462
483
|
show <aid> 查看本地 AID 详情(证书、私钥、签名能力)
|
|
484
|
+
cert renew <aid> 使用现有私钥续期证书(仅限独立宿主终端)
|
|
463
485
|
new <aid> 创建新 AID 身份
|
|
464
486
|
delete <aid> 删除指定本地 AID(无网络注销)
|
|
465
487
|
delete --orphan 批量清理无私钥的外部 AID 缓存
|
|
@@ -485,6 +507,7 @@ Options:
|
|
|
485
507
|
示例:
|
|
486
508
|
ec aid list
|
|
487
509
|
ec aid show toleiliang2.agentid.pub
|
|
510
|
+
ec aid cert renew reviewer.agentid.pub --format json
|
|
488
511
|
ec aid new reviewer.agentid.pub --owner owner.agentid.pub
|
|
489
512
|
ec aid delete --help
|
|
490
513
|
ec aid delete old.agentid.pub
|
|
@@ -496,6 +519,44 @@ Options:
|
|
|
496
519
|
ec aid agentmd set mybot.agentid.pub description "A helpful agent"`);
|
|
497
520
|
return;
|
|
498
521
|
}
|
|
522
|
+
if (process.env[SESSION_ID_ENV]) {
|
|
523
|
+
const runtime = await readVerifiedTaskRuntimeContext();
|
|
524
|
+
if (isTrustedFullAccessRuntimeContext(runtime)) {
|
|
525
|
+
const managedKeys = [
|
|
526
|
+
SESSION_ID_ENV,
|
|
527
|
+
AGENT_DELEGATION_TOKEN_ENV,
|
|
528
|
+
CODEX_SESSION_TOKEN_ENV,
|
|
529
|
+
TASK_RUNTIME_CONTEXT_ENV,
|
|
530
|
+
SESSION_RUNTIME_DIR_ENV,
|
|
531
|
+
RUNTIME_LOCK_DIR_ENV,
|
|
532
|
+
];
|
|
533
|
+
const previous = new Map(managedKeys.map(key => [key, process.env[key]]));
|
|
534
|
+
const previousSelfAid = process.env[SELF_AID_ENV];
|
|
535
|
+
managedKeys.forEach(key => delete process.env[key]);
|
|
536
|
+
if (runtime?.selfAid)
|
|
537
|
+
process.env[SELF_AID_ENV] = runtime.selfAid;
|
|
538
|
+
try {
|
|
539
|
+
await cmdAid(args);
|
|
540
|
+
}
|
|
541
|
+
finally {
|
|
542
|
+
for (const [key, value] of previous) {
|
|
543
|
+
if (value === undefined)
|
|
544
|
+
delete process.env[key];
|
|
545
|
+
else
|
|
546
|
+
process.env[key] = value;
|
|
547
|
+
}
|
|
548
|
+
if (previousSelfAid === undefined)
|
|
549
|
+
delete process.env[SELF_AID_ENV];
|
|
550
|
+
else
|
|
551
|
+
process.env[SELF_AID_ENV] = previousSelfAid;
|
|
552
|
+
}
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (sub === 'cert') {
|
|
557
|
+
await cmdAidCert(args.slice(1));
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
499
560
|
if (sub === 'bind' || sub === 'transfer') {
|
|
500
561
|
const { cmdAidBind } = await import('./aid-bind-command.js');
|
|
501
562
|
await cmdAidBind(args.slice(sub === 'bind' ? 1 : 0));
|
|
@@ -1087,7 +1148,7 @@ Options:
|
|
|
1087
1148
|
console.log(`✓ 头像已更新${result.publicUrl ? `: ${result.publicUrl}` : ''}${result.sha256 ? ` (sha256: ${result.sha256})` : ''}`);
|
|
1088
1149
|
return;
|
|
1089
1150
|
}
|
|
1090
|
-
console.error(`未知子命令: ${sub}\n用法: ec aid [list|show|new|delete|lookup|agentmd|avatar] <aid>`);
|
|
1151
|
+
console.error(`未知子命令: ${sub}\n用法: ec aid [list|show|cert|new|delete|lookup|agentmd|avatar] <aid>`);
|
|
1091
1152
|
process.exit(1);
|
|
1092
1153
|
}
|
|
1093
1154
|
// ==================== RPC ====================
|
|
@@ -1710,7 +1771,7 @@ Options:
|
|
|
1710
1771
|
--payload '<json>' 发送任意 JSON payload,不添加聊天字段
|
|
1711
1772
|
--payload-file <path> 从 UTF-8 文件读取 JSON payload(与 --payload 互斥)
|
|
1712
1773
|
--return none|required 是否等待关联响应(required 建立请求记录)
|
|
1713
|
-
--device-id <id> 定向到能力目录中的一台设备(device/status 查询不指定;其他业务能力必填,不写入 payload)
|
|
1774
|
+
--device-id <id> 定向到能力目录中的一台设备(protocol/discover 和 device/status 查询不指定;其他业务能力必填,不写入 payload)
|
|
1714
1775
|
--timeout <duration> required 的等待期限和 AUN volatile TTL,如 30s、60s、2m(默认 60s,最大 3600s)
|
|
1715
1776
|
--encrypt 强制端到端加密(未指定时使用 daemon 默认值)
|
|
1716
1777
|
--no-encrypt 强制明文发送(优先于 --encrypt)
|
|
@@ -2628,8 +2689,6 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2628
2689
|
catch (error) {
|
|
2629
2690
|
failManagedGroup(formatJson, 'INVALID_ARGUMENT', `Invalid group AID: ${error instanceof Error ? error.message : String(error)}`);
|
|
2630
2691
|
}
|
|
2631
|
-
const runtime = await readBestTaskRuntimeContext();
|
|
2632
|
-
validateManagedGroupScope(from, groupId, runtime, formatJson);
|
|
2633
2692
|
return runManagedSend(['group', ...args], formatJson);
|
|
2634
2693
|
}
|
|
2635
2694
|
const { groupSend, groupPull, groupAck, groupHistory, parseGroupHistoryArgs, groupCreate, groupInfo, groupList, groupUpdate, groupDissolve, groupSuspend, groupResume, groupJoin, groupLeave, groupInvite, groupInvites, groupAcceptInvite, groupRejectInvite, groupRevokeInvite, groupKick, groupMembers, groupOnline, groupSetRole, groupTransferOwner, groupBan, groupUnban, groupBanlist, groupBlock, groupUnblock, groupBlocklist, groupReportStatus, groupMemberStatuses, groupRules, groupUpdateRules, groupRulesFileGet, groupRulesFileSet, groupRulesFilePublish, } = await import('../aun/msg/index.js');
|
|
@@ -2816,26 +2875,6 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2816
2875
|
}
|
|
2817
2876
|
if (sub === 'send') {
|
|
2818
2877
|
const groupId = requireGroupId();
|
|
2819
|
-
// Group sends use the dedicated AUN message daemon route rather than the
|
|
2820
|
-
// managed group-operation IPC parser. Apply the same task scope checks
|
|
2821
|
-
// before building or uploading the payload, so a bad target fails locally
|
|
2822
|
-
// instead of reaching the transport layer first.
|
|
2823
|
-
if (process.env.EVOLCORE_SESSION_ID) {
|
|
2824
|
-
if (args.includes('--aun-path') || args.includes('--app')) {
|
|
2825
|
-
failManagedGroup(formatJson, 'NOT_ALLOWED', '--aun-path and --app are not allowed in a managed task');
|
|
2826
|
-
}
|
|
2827
|
-
const runtime = await readBestTaskRuntimeContext();
|
|
2828
|
-
// 跨话题发送:目标群由 --thread 话题决定,不受「只能操作当前群」限制;
|
|
2829
|
-
// 发送者仍必须是当前 self AID,daemon 侧按目标话题 relation 复核。
|
|
2830
|
-
const threadArg = getArgValue(args, '--thread');
|
|
2831
|
-
const { resolveThreadRouteTarget } = await import('../core/thread/thread-route.js');
|
|
2832
|
-
if (threadArg && resolveThreadRouteTarget(from, threadArg, 'group', groupId)) {
|
|
2833
|
-
validateManagedGroupScope(from, undefined, runtime, formatJson);
|
|
2834
|
-
}
|
|
2835
|
-
else {
|
|
2836
|
-
validateManagedGroupScope(from, groupId, runtime, formatJson);
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
2878
|
const optionsEnd = args.indexOf('--', 3);
|
|
2840
2879
|
const optionArgs = optionsEnd >= 0 ? args.slice(0, optionsEnd) : args;
|
|
2841
2880
|
const getSendArgValue = (flag) => getArgValue(optionArgs, flag);
|
|
@@ -10,14 +10,12 @@ import { resolveAnthropicConfig } from '../agents/baseagent.js';
|
|
|
10
10
|
import { migrateProject } from '../config-store.js';
|
|
11
11
|
import { ipcQuery, IpcTransportError } from '../ipc.js';
|
|
12
12
|
import { isHelpFlag } from './help.js';
|
|
13
|
-
// 注意:这里不要静态导入 ./init.js。init 带着 AUN 引导、控制 AID 生成等一整棵依赖,
|
|
14
|
-
// 而 `ec start` 在已初始化的机器上根本不会用到它(只有缺配置/缺控制 AID 时才走)。
|
|
15
|
-
// 需要时在分支里按需加载。
|
|
16
13
|
import * as platform from '../utils/cross-platform.js';
|
|
17
14
|
import { EventBus } from '../core/event-bus.js';
|
|
18
15
|
import { resolveGlobalPkg } from '../utils/npm-ops.js';
|
|
19
16
|
import { ensureFreshPackageVersionInfo } from '../utils/package-version-info.js';
|
|
20
|
-
import { ecwebVersionRequirementError, resolveEcwebLaunchCommand
|
|
17
|
+
import { ecwebVersionRequirementError, resolveEcwebLaunchCommand } from '../ecweb/runtime/launch.js';
|
|
18
|
+
import { resolveEcwebExternalUrl, fetchRemotePairingCode, buildEcwebPairingUrl } from '../ecweb/pairing.js';
|
|
21
19
|
import { isHostChinese } from '../utils/locale.js';
|
|
22
20
|
import { scanInstances, cleanupInstances, findOrphanProcesses } from '../utils/instance-registry.js';
|
|
23
21
|
import { filterLogFiles, deriveLogTypes, computePreChecked, validateLogTypes, shortLogName as shortLogNameLocal, isWatchLogFile } from './watch-logs.js';
|
|
@@ -31,8 +29,7 @@ import { readRestartRequest, updateRestartRequest } from '../utils/restart-safet
|
|
|
31
29
|
import { rotateStdoutLog } from '../utils/log-writer.js';
|
|
32
30
|
import { logLevelRank } from '../utils/logger.js';
|
|
33
31
|
import { inspectDataMigrationRequirement } from '../core/data-migration.js';
|
|
34
|
-
import {
|
|
35
|
-
import { readHostInfo } from '../utils/host-info.js';
|
|
32
|
+
import { readHostInfo, readVersionInfo } from '../utils/host-info.js';
|
|
36
33
|
import { queryStatusActivity, queryStatusActivityByAgent } from '../stats/query.js';
|
|
37
34
|
import { listCodexAppServerProcesses, unregisterCodexAppServerProcess } from '../agents/codex/app-server-registry.js';
|
|
38
35
|
import { DEFAULT_ECWEB_PORT, ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
|
|
@@ -121,18 +118,6 @@ export async function ensureCodexHookBeforeLifecycle(onRepaired) {
|
|
|
121
118
|
process.exitCode = 1;
|
|
122
119
|
return false;
|
|
123
120
|
}
|
|
124
|
-
async function runAutomaticInit(action) {
|
|
125
|
-
try {
|
|
126
|
-
return await action();
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
if (!isInitCancelledError(error))
|
|
130
|
-
throw error;
|
|
131
|
-
console.log('\n已退出初始化,未启动 EvolCore。');
|
|
132
|
-
process.exitCode = 130;
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
121
|
function printNoSelfAgentHints(options) {
|
|
137
122
|
const { daemonConfig, ecwebStarted, skipped } = options;
|
|
138
123
|
console.log('\nℹ 未配置任何 self-agent,Control Plane 已启动。');
|
|
@@ -691,63 +676,29 @@ export async function cmdStart(opts = {}) {
|
|
|
691
676
|
trace.mark('cli.configMigrate');
|
|
692
677
|
const { autoMigrateIfNeeded } = await import('../config-store.js');
|
|
693
678
|
autoMigrateIfNeeded();
|
|
694
|
-
|
|
695
|
-
trace.mark('cli.autoInit');
|
|
679
|
+
trace.mark('cli.initCheck');
|
|
696
680
|
const defaults = loadDefaults();
|
|
697
681
|
const hasAnyAgent = loadAllAgents().agents.length > 0;
|
|
698
|
-
if (!defaults && !hasAnyAgent) {
|
|
699
|
-
if (opts.bindBootstrap) {
|
|
700
|
-
console.log('⚡ 未检测到 agent,进入绑定 bootstrap 模式...\n');
|
|
701
|
-
}
|
|
702
|
-
else {
|
|
703
|
-
console.log('⚡ 未检测到初始化配置,自动启动初始化向导...\n');
|
|
704
|
-
// cmdStart 直接调用 cmdInit,不会经过 CLI 的 `init` 分发分支;
|
|
705
|
-
// 这里需显式抑制 AUN SDK 的常规 keystore 日志。
|
|
706
|
-
const { suppressSdkLogs } = await import('../aun/aid/index.js');
|
|
707
|
-
suppressSdkLogs();
|
|
708
|
-
const { cmdInit } = await import('./init.js');
|
|
709
|
-
if (!await runAutomaticInit(() => cmdInit({ invokedByStart: true }))) {
|
|
710
|
-
trace.finish(false);
|
|
711
|
-
if (process.exitCode == null)
|
|
712
|
-
console.log('⚠ 初始化未完成,未启动 EvolCore。');
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
if (!loadDefaults()) {
|
|
716
|
-
trace.finish(false);
|
|
717
|
-
console.log('⚠ 初始化未完成,未启动 EvolCore。');
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
console.log('\n初始化完成,开始启动 EvolCore ....');
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
// The initialization path can create the first Codex agent, so perform the
|
|
724
|
-
// machine-hook check after config migration/auto-init and before any daemon
|
|
725
|
-
// process is launched.
|
|
726
|
-
trace.mark('cli.codexHookCheck');
|
|
727
|
-
if (!await ensureCodexHookBeforeLifecycle()) {
|
|
682
|
+
if (!defaults && !hasAnyAgent && !opts.bindBootstrap) {
|
|
728
683
|
trace.finish(false);
|
|
684
|
+
process.exitCode = 1;
|
|
685
|
+
console.error('⚠ 未检测到初始化配置,请先运行 ec init;未启动 EvolCore。');
|
|
729
686
|
return;
|
|
730
687
|
}
|
|
731
|
-
// 控制 AID 门禁:缺 aid 且交互式 → 只补全控制 AID + owner(不重走 baseagent 向导)。
|
|
732
|
-
// 非 TTY(restart-monitor/systemd/管道)不补全(无法交互),只提示后继续启动,daemon 侧 warn 兜底。
|
|
733
688
|
trace.mark('cli.controlAidCheck');
|
|
734
689
|
const daemonCfgStart = loadDaemonConfig();
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
console.
|
|
739
|
-
const { suppressSdkLogs } = await import('../aun/aid/index.js');
|
|
740
|
-
suppressSdkLogs();
|
|
741
|
-
printInitCancelHint();
|
|
742
|
-
const { initTail } = await import('./init.js');
|
|
743
|
-
if (!await runAutomaticInit(() => initTail()))
|
|
744
|
-
return;
|
|
690
|
+
if (!daemonCfgStart.aid) {
|
|
691
|
+
trace.finish(false);
|
|
692
|
+
process.exitCode = 1;
|
|
693
|
+
console.error('⚠ 控制 AID 未配置,请先运行 ec init;未启动 EvolCore。');
|
|
745
694
|
return;
|
|
746
695
|
}
|
|
747
|
-
|
|
748
|
-
|
|
696
|
+
trace.mark('cli.codexHookCheck');
|
|
697
|
+
if (!await ensureCodexHookBeforeLifecycle()) {
|
|
698
|
+
trace.finish(false);
|
|
699
|
+
return;
|
|
749
700
|
}
|
|
750
|
-
|
|
701
|
+
if (process.stdin.isTTY) {
|
|
751
702
|
// 证书缺失时在 CLI 侧提示,daemon 是后台进程无终端不做交互
|
|
752
703
|
const certKey = path.join(resolvePaths().root, 'AIDs', daemonCfgStart.aid, 'private', 'key.json');
|
|
753
704
|
if (!fs.existsSync(certKey)) {
|
|
@@ -1617,15 +1568,6 @@ function renderStatusAgents(agents, aunAids, queue, controlAid, registered = age
|
|
|
1617
1568
|
}
|
|
1618
1569
|
renderAunAidsTable(safeAgents, controlAid);
|
|
1619
1570
|
}
|
|
1620
|
-
function readLocalPackageVersion() {
|
|
1621
|
-
try {
|
|
1622
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(getPackageRoot(), 'package.json'), 'utf8'));
|
|
1623
|
-
return typeof pkg.version === 'string' ? pkg.version : null;
|
|
1624
|
-
}
|
|
1625
|
-
catch {
|
|
1626
|
-
return null;
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
1571
|
function readEcwebPackageVersion() {
|
|
1630
1572
|
try {
|
|
1631
1573
|
const installed = resolveGlobalPkg(WEB_PACKAGE_NAME);
|
|
@@ -1772,7 +1714,8 @@ async function collectStatusSnapshot() {
|
|
|
1772
1714
|
diagnostics.push({
|
|
1773
1715
|
code: 'AGENT_STATUS_UNAVAILABLE', message: 'Agent 列表状态不可用',
|
|
1774
1716
|
});
|
|
1775
|
-
const
|
|
1717
|
+
const versions = readVersionInfo();
|
|
1718
|
+
const host = statusResponse?.host ?? readHostInfo(versions.evolcore, resolvePaths().root);
|
|
1776
1719
|
const packageRoot = getPackageRoot();
|
|
1777
1720
|
const runMode = statusResponse?.runMode ?? mainRecord?.runMode ?? null;
|
|
1778
1721
|
return {
|
|
@@ -1789,10 +1732,7 @@ async function collectStatusSnapshot() {
|
|
|
1789
1732
|
daemonExecution: statusResponse?.build?.runtimeMode ?? null,
|
|
1790
1733
|
processMetrics: readProcessMetrics(pid, processVisible),
|
|
1791
1734
|
},
|
|
1792
|
-
versions
|
|
1793
|
-
const { readVersionInfo } = await import('../utils/machine-info.js');
|
|
1794
|
-
return readVersionInfo();
|
|
1795
|
-
})(),
|
|
1735
|
+
versions,
|
|
1796
1736
|
daemon: {
|
|
1797
1737
|
pid, uptimeMs: statusResponse?.uptime ?? ping?.uptime ?? null,
|
|
1798
1738
|
ipc: { reachable: statusAvailable, latencyMs },
|
|
@@ -3227,9 +3167,11 @@ async function waitForExistingEcweb(p, timeoutMs = 3_000) {
|
|
|
3227
3167
|
async function collectEcwebStatus(p) {
|
|
3228
3168
|
let externalUrl = null;
|
|
3229
3169
|
let enabled = true;
|
|
3170
|
+
let configuredPort = DEFAULT_ECWEB_PORT;
|
|
3230
3171
|
try {
|
|
3231
3172
|
const cfg = loadDaemonConfig();
|
|
3232
3173
|
enabled = ecwebService(cfg.services)?.enabled !== false;
|
|
3174
|
+
configuredPort = ecwebService(cfg.services)?.port ?? DEFAULT_ECWEB_PORT;
|
|
3233
3175
|
externalUrl = resolveEcwebExternalUrl(cfg);
|
|
3234
3176
|
}
|
|
3235
3177
|
catch {
|
|
@@ -3282,15 +3224,19 @@ async function collectEcwebStatus(p) {
|
|
|
3282
3224
|
};
|
|
3283
3225
|
}
|
|
3284
3226
|
const occupiedPids = new Set();
|
|
3285
|
-
|
|
3286
|
-
|
|
3227
|
+
const ports = new Set([configuredPort, ...entries.map(entry => entry.record.port)]);
|
|
3228
|
+
let occupiedPort;
|
|
3229
|
+
for (const port of ports) {
|
|
3230
|
+
for (const processId of platform.findProcessByPort(port)) {
|
|
3287
3231
|
occupiedPids.add(processId);
|
|
3232
|
+
occupiedPort ??= port;
|
|
3233
|
+
}
|
|
3288
3234
|
}
|
|
3289
3235
|
if (aliveEntries.length > 0) {
|
|
3290
3236
|
return { source: 'instance+process', status: 'process-not-ready', pid: aliveEntries[0].record.pid, port: aliveEntries[0].record.port, url: null, externalUrl };
|
|
3291
3237
|
}
|
|
3292
3238
|
if (occupiedPids.size > 0) {
|
|
3293
|
-
return { source: 'port-scan', status: 'port-occupied', pids: [...occupiedPids], port:
|
|
3239
|
+
return { source: 'port-scan', status: 'port-occupied', pids: [...occupiedPids], port: occupiedPort, url: null, externalUrl };
|
|
3294
3240
|
}
|
|
3295
3241
|
if (entries.length > 0) {
|
|
3296
3242
|
return { source: 'instance-record', status: 'recorded-unavailable', port: entries[0].record.port, url: null, externalUrl };
|
|
@@ -3298,7 +3244,7 @@ async function collectEcwebStatus(p) {
|
|
|
3298
3244
|
return {
|
|
3299
3245
|
source: 'daemon-config',
|
|
3300
3246
|
status: externalUrl ? 'enabled-not-running' : 'stopped',
|
|
3301
|
-
port:
|
|
3247
|
+
port: configuredPort,
|
|
3302
3248
|
url: null,
|
|
3303
3249
|
externalUrl,
|
|
3304
3250
|
};
|
|
@@ -3328,13 +3274,13 @@ function renderEcwebStatus(status) {
|
|
|
3328
3274
|
}
|
|
3329
3275
|
}
|
|
3330
3276
|
else if (status.status === 'port-occupied') {
|
|
3331
|
-
console.log(`🔭 ECWeb:
|
|
3277
|
+
console.log(`🔭 ECWeb: 端口 ${status.port} 被未确认实例占用 (PID: ${status.pids.join(', ')});请先核实进程归属,未自动终止`);
|
|
3332
3278
|
}
|
|
3333
3279
|
else if (status.status === 'recorded-unavailable') {
|
|
3334
3280
|
console.log('🔭 ECWeb: instance 记录存在,但宿主 PID 不可见且 HTTP 未就绪');
|
|
3335
3281
|
}
|
|
3336
3282
|
else if (status.status === 'enabled-not-running') {
|
|
3337
|
-
console.log(
|
|
3283
|
+
console.log(`🔭 ECWeb: 已启用但未运行 (端口 ${status.port}),查看 logs/ecweb-daemon.log`);
|
|
3338
3284
|
}
|
|
3339
3285
|
else {
|
|
3340
3286
|
console.log('🔭 ECWeb: 未运行');
|
|
@@ -3552,6 +3498,9 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3552
3498
|
else if (pair) {
|
|
3553
3499
|
const mins = Math.max(0, Math.round((pair.expiresAt - Date.now()) / 60000));
|
|
3554
3500
|
console.log(` 配对码: ${pair.code} (约 ${mins} 分钟内有效,仅可配对一次,已配对过的浏览器无需重新配对)`);
|
|
3501
|
+
const pairingUrl = buildEcwebPairingUrl(cfg, pair.code);
|
|
3502
|
+
if (pairingUrl)
|
|
3503
|
+
console.log(` 一键登录: ${pairingUrl}`);
|
|
3555
3504
|
}
|
|
3556
3505
|
else {
|
|
3557
3506
|
console.log(' daemon 尚未提供配对码;EvolCore 启动后可通过 /pair 或 ECWeb 页面获取');
|
|
@@ -3591,6 +3540,9 @@ async function printEcwebAccess(port) {
|
|
|
3591
3540
|
if (pair) {
|
|
3592
3541
|
const mins = Math.max(0, Math.round((pair.expiresAt - Date.now()) / 60000));
|
|
3593
3542
|
console.log(` 配对码: ${pair.code} (约 ${mins} 分钟内有效,仅可配对一次,token 缓存 7 天,有访问自动续期)`);
|
|
3543
|
+
const pairingUrl = buildEcwebPairingUrl(loadDaemonConfig(), pair.code);
|
|
3544
|
+
if (pairingUrl)
|
|
3545
|
+
console.log(` 一键登录: ${pairingUrl}`);
|
|
3594
3546
|
}
|
|
3595
3547
|
else {
|
|
3596
3548
|
console.log(' 配对码: 暂不可用(稍后重试 ec watch web,或查看 logs/watch-web.log)');
|
package/dist/cli/index.js
CHANGED
|
@@ -24,6 +24,8 @@ const MAIN_HELP = `用法: ec <command> [选项]
|
|
|
24
24
|
start 启动服务
|
|
25
25
|
stop 停止服务
|
|
26
26
|
restart 重启服务并检查更新
|
|
27
|
+
upgrade 检查 EvolCore、EC Web 和 FASTAUN 更新
|
|
28
|
+
update 执行更新,或用 status 查询当前升级任务
|
|
27
29
|
status 查看运行状态
|
|
28
30
|
logs 持续查看 daemon 日志
|
|
29
31
|
watch 打开日志、AID、消息或 EC Web 监控
|
|
@@ -57,6 +59,7 @@ AUN:
|
|
|
57
59
|
配置与诊断:
|
|
58
60
|
config 读取、修改和检查分层配置
|
|
59
61
|
provider 管理 daemon 级 Provider 注册表与 JSON 导入
|
|
62
|
+
ability 按 AID 管理能力插件、运行、发布和作业
|
|
60
63
|
stats Token 用量与费用统计
|
|
61
64
|
diagnose 检查启动环境
|
|
62
65
|
version 显示组件版本
|
|
@@ -280,6 +283,12 @@ export async function main(args) {
|
|
|
280
283
|
}
|
|
281
284
|
await cmdRestart({ clear: strippedArgs.includes('--clear'), diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d') });
|
|
282
285
|
break;
|
|
286
|
+
case 'upgrade':
|
|
287
|
+
case 'update': {
|
|
288
|
+
const { cmdUpgrade } = await import('./upgrade-command.js');
|
|
289
|
+
await cmdUpgrade(strippedArgs);
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
283
292
|
case 'status':
|
|
284
293
|
if (wantsHelp(strippedArgs.slice(1))) {
|
|
285
294
|
printLifecycleHelp('status');
|
|
@@ -549,6 +558,11 @@ export async function main(args) {
|
|
|
549
558
|
await cmdProvider(strippedArgs.slice(1));
|
|
550
559
|
break;
|
|
551
560
|
}
|
|
561
|
+
case 'ability': {
|
|
562
|
+
const { cmdAbility } = await import('./ability-command.js');
|
|
563
|
+
await cmdAbility(strippedArgs.slice(1));
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
552
566
|
case 'config': {
|
|
553
567
|
const { cmdConfig } = await import('./config.js');
|
|
554
568
|
await cmdConfig(strippedArgs.slice(1));
|
package/dist/cli/init.js
CHANGED
|
@@ -126,6 +126,7 @@ function applyExplicitAutostart(enabled, runtimeRoot) {
|
|
|
126
126
|
const result = configureAutostart(enabled, runtimeRoot);
|
|
127
127
|
if (!result.ok) {
|
|
128
128
|
console.log(`❌ ${autostartPlatformLabel() || '登录自启'}配置失败: ${result.error || '未知错误'}`);
|
|
129
|
+
printWindowsAutostartRetryInstructions(enabled);
|
|
129
130
|
}
|
|
130
131
|
else {
|
|
131
132
|
const backend = enabled && result.backend ? `(方式:${result.backend})` : '';
|
|
@@ -137,10 +138,12 @@ function applyExplicitAutostart(enabled, runtimeRoot) {
|
|
|
137
138
|
}
|
|
138
139
|
return result.ok;
|
|
139
140
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
function printWindowsAutostartRetryInstructions(enabled) {
|
|
142
|
+
if (!enabled || process.platform !== 'win32')
|
|
143
|
+
return;
|
|
144
|
+
console.log(' 如果 PowerShell 因执行策略阻止 ec.ps1,请在 CMD 中依次执行:');
|
|
145
|
+
console.log(' powershell.exe -NoProfile -Command "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force"');
|
|
146
|
+
console.log(' ec.cmd init --auto-start');
|
|
144
147
|
}
|
|
145
148
|
function installErrorMessage(e) {
|
|
146
149
|
return String(e?.stderr || e?.message || e).trim();
|
|
@@ -404,7 +407,6 @@ export async function cmdInit(options) {
|
|
|
404
407
|
}
|
|
405
408
|
// ── 共享 tail(单一出口):提示创建 agent + 生成控制 AID ──
|
|
406
409
|
return initTail({
|
|
407
|
-
invokedByStart: options?.invokedByStart,
|
|
408
410
|
nonInteractive: options?.nonInteractive,
|
|
409
411
|
autoStart: options?.autoStart,
|
|
410
412
|
});
|
|
@@ -500,7 +502,7 @@ export async function cmdInit(options) {
|
|
|
500
502
|
export async function initTail(options = {}) {
|
|
501
503
|
// 提示创建 agent(两分支汇合后执行一次)
|
|
502
504
|
const { agents } = loadAllAgents();
|
|
503
|
-
if (agents.length === 0
|
|
505
|
+
if (agents.length === 0) {
|
|
504
506
|
console.log('\n提示:尚无 agent,运行以下命令创建:');
|
|
505
507
|
console.log(' ec agent new <aid>.example.com');
|
|
506
508
|
}
|
|
@@ -580,6 +582,7 @@ export async function initTail(options = {}) {
|
|
|
580
582
|
const result = configureAutostart(enabled, resolvePaths().root);
|
|
581
583
|
if (!result.ok) {
|
|
582
584
|
console.log(` ❌ ${autostartPlatformLabel() || '登录自启'}配置失败: ${result.error || '未知错误'}`);
|
|
585
|
+
printWindowsAutostartRetryInstructions(enabled);
|
|
583
586
|
return false;
|
|
584
587
|
}
|
|
585
588
|
const backend = enabled && result.backend ? `(方式:${result.backend})` : '';
|
|
@@ -617,10 +620,8 @@ export async function initTail(options = {}) {
|
|
|
617
620
|
console.log(`✓ 已配置进程级管理者: ${ownerAid}`);
|
|
618
621
|
}
|
|
619
622
|
if (daemonConfigForOwners.aid) {
|
|
620
|
-
console.log('\n
|
|
621
|
-
console.log('
|
|
622
|
-
console.log(' ec aid bind <ownerAid>');
|
|
623
|
-
console.log(' 使用 ec aid bind status 查看共识与运行态同步。');
|
|
623
|
+
console.log('\n协议 Owner 绑定:启动后运行 ec aid bind <ownerAid>。');
|
|
624
|
+
console.log('使用 ec aid bind status 查看绑定状态。');
|
|
624
625
|
}
|
|
625
626
|
return true;
|
|
626
627
|
}
|
|
@@ -647,9 +648,6 @@ export async function initTail(options = {}) {
|
|
|
647
648
|
}
|
|
648
649
|
}
|
|
649
650
|
}
|
|
650
|
-
// ec start 会接着启动 daemon,并在其 ready 后给出可用的 Agent 创建入口。
|
|
651
|
-
if (options.invokedByStart)
|
|
652
|
-
return controlAidReady && (!autoStartExplicit || autoStartReady);
|
|
653
651
|
if (!controlAidReady) {
|
|
654
652
|
console.error('\n❌ EvolCore 初始化未完成:控制 AID 未配置。联网后重新运行 ec init。');
|
|
655
653
|
return false;
|