evolcore 0.0.46 → 0.0.48
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 +93 -0
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +139 -39
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +43 -18
- package/dist/agents/codex/app-server-client.js +32 -23
- package/dist/agents/codex-runner.js +31 -16
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/group/fs-download.js +1 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +100 -32
- package/dist/channels/daemon.js +10 -26
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +65 -76
- package/dist/cli/daemon-lifecycle-client.js +17 -3
- package/dist/cli/directory.js +7 -1
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +2 -8
- package/dist/cli/init-channel.js +6 -8
- package/dist/cli/init.js +74 -46
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/restart-monitor.js +104 -28
- package/dist/cli/role.js +61 -17
- package/dist/cli/stats.js +3 -3
- package/dist/cli/task-context.js +83 -15
- package/dist/cli/thread-command.js +16 -51
- package/dist/cli/upgrade-command.js +4 -2
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-manager.js +31 -23
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +59 -218
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +161 -6
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +59 -8
- package/dist/config/providers-management.js +467 -49
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +228 -20
- package/dist/config/schema-registry.js +6 -2
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +10 -5
- package/dist/core/auth/agent-delegation.js +10 -4
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +3 -0
- package/dist/core/auth/delegation-diagnostics.js +56 -15
- package/dist/core/auth/operation-authorizer.js +26 -1
- package/dist/core/auth/operation-catalog.js +28 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/command-handler.js +81 -85
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +65 -153
- package/dist/core/command/menu-protocol.js +7 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +30 -49
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +19 -10
- package/dist/core/daemon-control.js +8 -10
- package/dist/core/daemon-lifecycle.js +50 -40
- package/dist/core/evolagent-registry.js +22 -3
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/host-snapshot.js +9 -4
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +31 -8
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +6 -4
- package/dist/core/memory/consolidation.js +6 -6
- package/dist/core/message/aun-ipc-sender.js +165 -55
- package/dist/core/message/im-renderer.js +1 -1
- package/dist/core/message/message-bridge.js +51 -334
- package/dist/core/message/message-log.js +5 -0
- package/dist/core/message/message-queue.js +22 -0
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +429 -116
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/ownership/owner-resolver.js +355 -60
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/relation/peer-identity.js +28 -2
- package/dist/core/relation/same-owner-proof.js +81 -111
- package/dist/core/session/adapters/claude-session-file-adapter.js +1 -1
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +49 -14
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-image-resources.js +1 -1
- package/dist/core/task/task-recovery-service.js +12 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/directory/owner-directory-admission.js +1 -1
- package/dist/directory/owner-directory-cache.js +45 -28
- package/dist/directory/owner-directory-markdown.js +13 -1
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/eck/message-renderer.js +84 -24
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +82 -23
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +6 -17
- package/dist/event-center/registry.js +13 -2
- package/dist/event-center/runtime.js +103 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +129 -93
- package/dist/ipc.js +15 -3
- package/dist/outputs/events.js +62 -0
- package/dist/outputs/protocol.js +102 -0
- package/dist/outputs/service.js +279 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +89 -4
- package/dist/services/ipc-operation.js +4 -15
- package/dist/services/pack-manager.js +12 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +305 -24
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +11 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +9 -3
- package/dist/trigger/state.js +7 -0
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/aid-bind.js +155 -18
- package/dist/utils/atomic-write.js +3 -3
- package/dist/utils/cross-platform.js +97 -31
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +40 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/instance-registry.js +61 -0
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/process-introspect.js +158 -8
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/upgrade-jobs.js +4 -4
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -2
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +12 -0
- package/kits/docs/evolcore/directory.md +22 -3
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +133 -5
- package/kits/docs/evolcore/role.md +80 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +10 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +221 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +3 -3
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +6 -5
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +4 -1
- package/scripts/agent-template/shared/common.mjs +2 -3
- package/scripts/agent-template/shared/template-contract.mjs +2 -1
- package/scripts/agent-template/shared/template-package.mjs +9 -2
- package/scripts/agent-template/shared/template-runtime.mjs +20 -5
- package/scripts/agent-template/team-pack.mjs +6 -3
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
|
@@ -44,11 +44,14 @@ export async function isRecordedProcessGone(pid, expectedStartedAt) {
|
|
|
44
44
|
return !startTimeMatches(expectedStartedAt, actual);
|
|
45
45
|
}
|
|
46
46
|
/** Clean up only registered, identity-verified EvolCore Codex app-server children. */
|
|
47
|
-
export async function stopCodexAppServerOrphans() {
|
|
47
|
+
export async function stopCodexAppServerOrphans(snapshot) {
|
|
48
48
|
const entries = listCodexAppServerProcesses();
|
|
49
49
|
if (entries.length === 0)
|
|
50
50
|
return 0;
|
|
51
|
-
|
|
51
|
+
// The restart monitor already captured all Windows command lines after the
|
|
52
|
+
// daemon exited. Reuse that enumeration, but never its stale signal authority.
|
|
53
|
+
const reuseSnapshot = platform.isWindows && snapshot?.complete;
|
|
54
|
+
const codexProcs = reuseSnapshot ? undefined : new Set(platform.findProcesses('codex app-server'));
|
|
52
55
|
const exits = [];
|
|
53
56
|
for (const entry of entries) {
|
|
54
57
|
const { pid, startedAt } = entry.record;
|
|
@@ -58,7 +61,18 @@ export async function stopCodexAppServerOrphans() {
|
|
|
58
61
|
unregisterCodexAppServerProcess(entry.filePath);
|
|
59
62
|
continue;
|
|
60
63
|
}
|
|
61
|
-
if (
|
|
64
|
+
if (reuseSnapshot) {
|
|
65
|
+
const command = snapshot.commandLines.get(pid) ?? '';
|
|
66
|
+
const capturedStart = snapshot.startedAt.get(pid);
|
|
67
|
+
if (capturedStart === undefined || !startTimeMatches(startedAt, capturedStart))
|
|
68
|
+
continue;
|
|
69
|
+
// Native executables and npm's cmd wrapper both carry the app-server
|
|
70
|
+
// token. Registration and fresh identity verification scope termination.
|
|
71
|
+
if (!/(?:^|[\\/"'\s])codex(?:\.(?:exe|cmd|bat|js|mjs))?(?=$|["'\s])/i.test(command)
|
|
72
|
+
|| !/(?:^|["'\s^])app-server(?=$|["'\s^])/.test(command))
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
else if (!codexProcs.has(pid))
|
|
62
76
|
continue;
|
|
63
77
|
if (platform.killProcess(pid, true)) {
|
|
64
78
|
// Signal acceptance is not proof of exit. Confirm children concurrently
|
package/dist/cli/directory.js
CHANGED
|
@@ -3,7 +3,7 @@ import { daemonUnavailableMessage, getArgValue, isHelpFlag, queryDaemon, wantsHe
|
|
|
3
3
|
import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
4
4
|
import { DirectoryQueryError, executeDirectoryQueryCommand, resolveDirectoryQueryCommand, } from '../directory/owner-directory-query-operation.js';
|
|
5
5
|
import { executeDirectoryRequestCommand, resolveDirectoryRequestCommand, } from '../directory/owner-directory-request-operation.js';
|
|
6
|
-
const QUERY_ACTIONS = new Set(['list', 'info', 'refresh', 'blocked']);
|
|
6
|
+
const QUERY_ACTIONS = new Set(['list', 'info', 'refresh', 'blocked', 'block', 'unblock']);
|
|
7
7
|
/**
|
|
8
8
|
* `ec directory ...`
|
|
9
9
|
*
|
|
@@ -119,6 +119,10 @@ function output(result, json) {
|
|
|
119
119
|
: '没有可用连接,未拉取;本地名录已按当前备注重算');
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
+
case 'block':
|
|
123
|
+
case 'unblock':
|
|
124
|
+
console.log(result.changed ? '✓ 本 Agent 的黑名单已更新' : '无需变更');
|
|
125
|
+
return;
|
|
122
126
|
case 'blocked': {
|
|
123
127
|
if (result.entries.length === 0)
|
|
124
128
|
console.log('(没有被拉黑的主体)');
|
|
@@ -185,6 +189,8 @@ function printHelp() {
|
|
|
185
189
|
ec directory info <contact-aid|名字> [--limit <n>]
|
|
186
190
|
ec directory refresh
|
|
187
191
|
ec directory blocked
|
|
192
|
+
ec directory block <target-aid>
|
|
193
|
+
ec directory unblock <target-aid>
|
|
188
194
|
ec directory request <target-aid> [--note <申请介绍>]
|
|
189
195
|
|
|
190
196
|
request:向目标发送 app-v1 friend.invite.v1 加好友申请;介绍默认为“你好,我想添加你为联系人。”。
|
|
@@ -152,8 +152,11 @@ export function buildDownstreamArgv(route, text, passthrough) {
|
|
|
152
152
|
// 所以按普通私聊发出,会话随这条消息建立,也就不建复查。
|
|
153
153
|
if (route.crossTopic && route.threadId && !route.firstContact) {
|
|
154
154
|
argv.push('--thread', route.threadId);
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
// 进入本分支后 `checkEveryMs === undefined` 只可能是显式 `--check-every none`:
|
|
156
|
+
// 未指定时 resolveSendRoute 已补默认周期,firstContact 又进不了本分支。
|
|
157
|
+
// 必须把 `none` 透传下去——漏传会让下游 `resolveManagedSendArgv` 看到
|
|
158
|
+
// 「有 --thread 没 --check-every」,直接报 Cross-thread sends require …。
|
|
159
|
+
argv.push('--check-every', route.checkEveryMs ? formatDuration(route.checkEveryMs) : 'none');
|
|
157
160
|
}
|
|
158
161
|
argv.push(route.encryptResolved ? '--encrypt' : '--no-encrypt');
|
|
159
162
|
// 保留网关正文的字面量语义,包括经 `--` 传入的 --encrypt 等文本。
|
package/dist/cli/index.js
CHANGED
|
@@ -62,9 +62,8 @@ AUN:
|
|
|
62
62
|
rpc 调用底层 AUN RPC
|
|
63
63
|
menu-client 向远程 daemon 发送标准 Menu 请求
|
|
64
64
|
diag 邀请远程诊断 Agent,或 stop 撤销诊断授权
|
|
65
|
-
peer 联系人黑名单与已登记对端查询
|
|
66
65
|
directory 名录查询与发起加好友申请
|
|
67
|
-
role
|
|
66
|
+
role 角色配额/限额设置、关系角色提升申请与审批
|
|
68
67
|
net AUN 网络链路诊断
|
|
69
68
|
|
|
70
69
|
配置与诊断:
|
|
@@ -241,7 +240,7 @@ export async function main(args) {
|
|
|
241
240
|
--owner <aid> 必填。控制 AID 创建后的 Owner 邀约目标,不等待审批
|
|
242
241
|
--baseagent <claude|codex|gemini|ecagent> 可选。默认从 PATH 检测,ecagent 需显式选择
|
|
243
242
|
--projectpath <abs-path> 可选。默认项目目录(必须绝对路径,自动创建)
|
|
244
|
-
--ecweb
|
|
243
|
+
--ecweb 兼容选项。检查 EC Web 安装;默认随 ec start 启动
|
|
245
244
|
--auto-start Windows/macOS 上启用 EvolCore 登录自启动
|
|
246
245
|
--no-auto-start Windows/macOS 上禁用 EvolCore 登录自启动
|
|
247
246
|
--format json 可选但推荐。stdout 输出 init.result JSON
|
|
@@ -677,11 +676,6 @@ export async function main(args) {
|
|
|
677
676
|
await cmdConfig(strippedArgs.slice(1));
|
|
678
677
|
break;
|
|
679
678
|
}
|
|
680
|
-
case 'peer': {
|
|
681
|
-
const { cmdPeer } = await import('./peer.js');
|
|
682
|
-
await cmdPeer(strippedArgs.slice(1));
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
685
679
|
case 'directory': {
|
|
686
680
|
const { cmdDirectory } = await import('./directory.js');
|
|
687
681
|
await cmdDirectory(strippedArgs.slice(1));
|
package/dist/cli/init-channel.js
CHANGED
|
@@ -19,7 +19,7 @@ import { ipcQuery } from '../ipc.js';
|
|
|
19
19
|
import { cmdStart } from './daemon-commands.js';
|
|
20
20
|
import * as platform from '../utils/cross-platform.js';
|
|
21
21
|
import { cleanupInstances } from '../utils/instance-registry.js';
|
|
22
|
-
import { bindPeerAlias,
|
|
22
|
+
import { bindPeerAlias, isPeerBindingEligible } from '../config/peer-book.js';
|
|
23
23
|
import { listStaticAgentAdmins } from '../config/peer-role-resolver.js';
|
|
24
24
|
import { askInit, InitCancelledError, isInitCancelledError, setupInitRawKeyListener, waitForInitDelay, } from './init-cancel.js';
|
|
25
25
|
function ask(rl, question) {
|
|
@@ -179,11 +179,11 @@ async function reloadAgentAfterBind(aid) {
|
|
|
179
179
|
console.log(' ✓ agent owner 已热重载');
|
|
180
180
|
}
|
|
181
181
|
else if (result?.error) {
|
|
182
|
-
console.log(` ⚠
|
|
182
|
+
console.log(` ⚠ Agent Owner 协议绑定已确认,热重载失败:${result.error}`);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
catch {
|
|
186
|
-
console.log(' ⚠
|
|
186
|
+
console.log(' ⚠ Agent Owner 协议绑定已确认,daemon 未响应热重载;下次启动恢复');
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
async function printQr(qrData) {
|
|
@@ -1408,7 +1408,6 @@ async function confirmOverwriteChannel(rl, displayName, channelName) {
|
|
|
1408
1408
|
}
|
|
1409
1409
|
async function pickContactForChannelBinding(rl, agentConfig, channelType) {
|
|
1410
1410
|
const candidates = preferredContactBindingCandidates(agentConfig);
|
|
1411
|
-
const contacts = getPeerSnapshot(agentConfig.aid).contacts;
|
|
1412
1411
|
console.log(`\n请选择 ${channelType} 账号要绑定到的联系人 AID:`);
|
|
1413
1412
|
candidates.forEach((candidate, index) => {
|
|
1414
1413
|
console.log(` ${index + 1}. ${candidate.primaryId} (${candidate.label})`);
|
|
@@ -1425,7 +1424,7 @@ async function pickContactForChannelBinding(rl, agentConfig, channelType) {
|
|
|
1425
1424
|
}
|
|
1426
1425
|
if (selected === manualChoice) {
|
|
1427
1426
|
const primaryId = (await ask(rl, '请输入要绑定的联系人 AID: ')).trim();
|
|
1428
|
-
if (isValidAid(primaryId) &&
|
|
1427
|
+
if (isValidAid(primaryId) && isPeerBindingEligible(agentConfig.aid, primaryId))
|
|
1429
1428
|
return { primaryId, label: 'contact' };
|
|
1430
1429
|
if (isValidAid(primaryId)) {
|
|
1431
1430
|
console.log('该 AID 不是当前 Agent 的联系人,请先添加联系人或将其设为 Owner。');
|
|
@@ -1438,11 +1437,10 @@ async function pickContactForChannelBinding(rl, agentConfig, channelType) {
|
|
|
1438
1437
|
}
|
|
1439
1438
|
}
|
|
1440
1439
|
function preferredContactBindingCandidates(agentConfig) {
|
|
1441
|
-
const contacts = getPeerSnapshot(agentConfig.aid).contacts;
|
|
1442
1440
|
const labels = new Map();
|
|
1443
1441
|
const add = (value, label) => {
|
|
1444
1442
|
const aid = String(value || '').trim();
|
|
1445
|
-
if (!isValidAid(aid) || !
|
|
1443
|
+
if (!isValidAid(aid) || !isPeerBindingEligible(agentConfig.aid, aid))
|
|
1446
1444
|
return;
|
|
1447
1445
|
let set = labels.get(aid);
|
|
1448
1446
|
if (!set) {
|
|
@@ -1465,7 +1463,7 @@ function bindQrActorToContact(aid, binding, channelType, actorId, channelKey) {
|
|
|
1465
1463
|
return;
|
|
1466
1464
|
const normalizedActor = firstNonEmpty(actorId);
|
|
1467
1465
|
if (!normalizedActor) {
|
|
1468
|
-
console.log(` ⚠ ${channelType} 扫码流程未返回可绑定的用户 ID,未写入
|
|
1466
|
+
console.log(` ⚠ ${channelType} 扫码流程未返回可绑定的用户 ID,未写入 peers.json`);
|
|
1469
1467
|
return;
|
|
1470
1468
|
}
|
|
1471
1469
|
try {
|
package/dist/cli/init.js
CHANGED
|
@@ -8,6 +8,9 @@ import { scanInstances } from '../utils/instance-registry.js';
|
|
|
8
8
|
import { saveDefaultsSafe, loadDaemonConfig, saveDaemonConfig } from '../config-store.js';
|
|
9
9
|
import { currentVersion } from '../config/schema-registry.js';
|
|
10
10
|
import { DEFAULT_ECWEB_PORT, ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
|
|
11
|
+
import { buildEcwebPairingUrl, fetchRemotePairingCode } from '../ecweb/pairing.js';
|
|
12
|
+
import { waitForEcwebProxyAccess } from '../ecweb/runtime/proxy-access.js';
|
|
13
|
+
import { ipcQuery } from '../ipc.js';
|
|
11
14
|
import { ensureControlAgentMd, generateControlAid, hasLocalControlIdentity, missingControlIdentityMessage, resolveControlAidDomain, submitControlAidRegistration, } from '../aun/aid/control-aid.js';
|
|
12
15
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
13
16
|
/**
|
|
@@ -22,7 +25,7 @@ async function probeCodexAvailability() {
|
|
|
22
25
|
}
|
|
23
26
|
import { resolveCodexCliPath, resolveCodexPowerShellShimPath, } from '../agents/baseagent.js';
|
|
24
27
|
import { assertProjectPathReference, defaultProjectsRoot, hasProjectPathEnvironmentReference } from '../utils/project-path.js';
|
|
25
|
-
import { WEB_CLI_BIN, WEB_PACKAGE_LATEST } from '../product.js';
|
|
28
|
+
import { WEB_CLI_BIN, WEB_PACKAGE_NAME, WEB_PACKAGE_LATEST } from '../product.js';
|
|
26
29
|
import { autostartInstalled, autostartPlatformLabel, configureAutostart } from '../utils/autostart.js';
|
|
27
30
|
import { askInit, printInitCancelHint } from './init-cancel.js';
|
|
28
31
|
import { AUTO_BASEAGENT_CANDIDATES, BASEAGENT_CANDIDATES, detectAvailableBaseagents, detectBaseagentDetails, } from '../agents/baseagent-availability.js';
|
|
@@ -174,7 +177,7 @@ export async function importProvidersForCliInit(available, options = {}) {
|
|
|
174
177
|
for (const item of warnings) {
|
|
175
178
|
const hint = item.baseagent === 'ecagent'
|
|
176
179
|
? '请在内部配置中为内置 ecagent 选择可用 Provider。'
|
|
177
|
-
: '可使用 ec provider
|
|
180
|
+
: '可使用 ec provider templates 查看内置模板,再用 ec provider create --template <id> 配置;也可在 ECWEB 中添加。';
|
|
178
181
|
console.warn(`⚠ ${item.baseagent}: ${messages[item.code]}(${item.code});${hint}`);
|
|
179
182
|
}
|
|
180
183
|
}
|
|
@@ -250,8 +253,8 @@ function installErrorMessage(e) {
|
|
|
250
253
|
return String(e?.stderr || e?.message || e).trim();
|
|
251
254
|
}
|
|
252
255
|
export async function ensureEcwebInstalledForInit(options = {}) {
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
256
|
+
const installed = options.isInstalled ? options.isInstalled() : !!(await (await import('../utils/npm-ops.js')).resolveGlobalPkgAsync(WEB_PACKAGE_NAME)) || commandExists(WEB_CLI_BIN);
|
|
257
|
+
if (installed)
|
|
255
258
|
return { ok: true, installedNow: false };
|
|
256
259
|
if (!options.quiet)
|
|
257
260
|
console.log(` 📦 EC Web 组件未安装,正在安装 ${WEB_PACKAGE_LATEST}...`);
|
|
@@ -278,6 +281,10 @@ export async function cmdInitWeb(dependencies = {}) {
|
|
|
278
281
|
const p = resolvePaths();
|
|
279
282
|
const hasIdentity = dependencies.hasLocalIdentity ?? hasLocalControlIdentity;
|
|
280
283
|
const existingConfig = (dependencies.loadConfig ?? loadDaemonConfig)();
|
|
284
|
+
if (ecwebService(existingConfig.services).enabled === false) {
|
|
285
|
+
console.error('❌ ECWeb 已被手动关闭,未修改设置;请先启用 ECWeb 后重试初始化。');
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
281
288
|
if (existingConfig.aid && !hasIdentity(existingConfig.aid)) {
|
|
282
289
|
console.error(`❌ ${missingControlIdentityMessage(existingConfig.aid)}`);
|
|
283
290
|
return false;
|
|
@@ -285,9 +292,21 @@ export async function cmdInitWeb(dependencies = {}) {
|
|
|
285
292
|
ensureDataDirs();
|
|
286
293
|
const daemonRunning = dependencies.isDaemonRunning?.()
|
|
287
294
|
?? scanInstances().mains.some(instance => instance.alive);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
295
|
+
const readRuntimeAid = dependencies.runtimeAid ?? (async () => {
|
|
296
|
+
const status = await ipcQuery(p.socket, { type: 'status' }, 3000);
|
|
297
|
+
if (!status)
|
|
298
|
+
throw new Error('无法确认运行中 daemon 的身份,未执行重启;请稍后重试');
|
|
299
|
+
return status.controlAid?.aid;
|
|
300
|
+
});
|
|
301
|
+
let runtimeAid;
|
|
302
|
+
if (daemonRunning) {
|
|
303
|
+
try {
|
|
304
|
+
runtimeAid = await readRuntimeAid();
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
console.error(`❌ ${installErrorMessage(error)}`);
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
291
310
|
}
|
|
292
311
|
const install = await (dependencies.ensureEcwebInstalled ?? ensureEcwebInstalledForInit)();
|
|
293
312
|
if (!install.ok)
|
|
@@ -334,18 +353,32 @@ export async function cmdInitWeb(dependencies = {}) {
|
|
|
334
353
|
else {
|
|
335
354
|
console.log('ℹ 主机名片将在 Web 初始化完成 Owner 绑定后发布。');
|
|
336
355
|
}
|
|
337
|
-
if (ecwebService(config.services)?.enabled
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
(dependencies.saveConfig ?? saveDaemonConfig)(config);
|
|
341
|
-
}
|
|
342
|
-
catch (error) {
|
|
343
|
-
console.error(`❌ 启用 ECWeb 失败: ${installErrorMessage(error)}`);
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
356
|
+
if (ecwebService(config.services)?.enabled === false) {
|
|
357
|
+
console.error('❌ ECWeb 已被手动关闭,未修改设置;请先启用 ECWeb 后重试初始化。');
|
|
358
|
+
return false;
|
|
346
359
|
}
|
|
347
360
|
try {
|
|
348
|
-
if (
|
|
361
|
+
if (daemonRunning && runtimeAid !== controlAid) {
|
|
362
|
+
console.log('ℹ 主机控制 AID 已准备,正在重启 EvolCore 使身份生效...');
|
|
363
|
+
const accepted = dependencies.restartDaemon ? await dependencies.restartDaemon()
|
|
364
|
+
: await (await import('./daemon-commands.js')).cmdRestart({ applyPackageUpgrades: false });
|
|
365
|
+
if (!accepted)
|
|
366
|
+
throw new Error('控制 AID 已保存,但重启未确认受理;请检查 ec status 后重试');
|
|
367
|
+
const deadline = Date.now() + 60000;
|
|
368
|
+
let activated = false;
|
|
369
|
+
do {
|
|
370
|
+
try {
|
|
371
|
+
activated = await readRuntimeAid() === controlAid;
|
|
372
|
+
}
|
|
373
|
+
catch { /* IPC is temporarily absent during restart. */ }
|
|
374
|
+
if (activated)
|
|
375
|
+
break;
|
|
376
|
+
await new Promise(resolve => setTimeout(resolve, 250));
|
|
377
|
+
} while (Date.now() < deadline);
|
|
378
|
+
if (!activated)
|
|
379
|
+
throw new Error('控制 AID 已保存,但重启后身份尚未验证;请检查 ec status,勿重复发起重启');
|
|
380
|
+
}
|
|
381
|
+
else if (!daemonRunning && dependencies.startDaemon) {
|
|
349
382
|
await dependencies.startDaemon();
|
|
350
383
|
}
|
|
351
384
|
else if (!daemonRunning) {
|
|
@@ -354,7 +387,7 @@ export async function cmdInitWeb(dependencies = {}) {
|
|
|
354
387
|
}
|
|
355
388
|
const started = dependencies.startEcweb
|
|
356
389
|
? await dependencies.startEcweb()
|
|
357
|
-
: await (await import("./daemon-commands.js")).startEcwebIfEnabled(p);
|
|
390
|
+
: await (await import("./daemon-commands.js")).startEcwebIfEnabled(p, { initialization: true });
|
|
358
391
|
if (!started) {
|
|
359
392
|
console.error("❌ ECWeb 未能启动;可稍后运行 ec watch web 重试。");
|
|
360
393
|
return false;
|
|
@@ -366,7 +399,23 @@ export async function cmdInitWeb(dependencies = {}) {
|
|
|
366
399
|
}
|
|
367
400
|
const currentConfig = (dependencies.loadConfig ?? loadDaemonConfig)();
|
|
368
401
|
const port = ecwebService(currentConfig.services)?.port ?? DEFAULT_ECWEB_PORT;
|
|
369
|
-
|
|
402
|
+
const access = await (dependencies.waitForProxy ?? waitForEcwebProxyAccess)(currentConfig);
|
|
403
|
+
console.log('\nECweb 初始化:');
|
|
404
|
+
console.log(` 本地访问: http://localhost:${port}/init`);
|
|
405
|
+
console.log(` 外网代理: ${access.message}`);
|
|
406
|
+
if (access.state === 'ready' && access.url) {
|
|
407
|
+
console.log(` 外网访问: ${access.url}/init`);
|
|
408
|
+
const pair = await (dependencies.fetchPairingCode ?? fetchRemotePairingCode)();
|
|
409
|
+
const pairingUrl = pair ? buildEcwebPairingUrl(currentConfig, pair.code, true) : null;
|
|
410
|
+
if (pair && pairingUrl) {
|
|
411
|
+
console.log(` 配对码: ${pair.code}(仅可配对一次,约 ${Math.max(0, Math.round((pair.expiresAt - Date.now()) / 60000))} 分钟内有效)`);
|
|
412
|
+
console.log(` 一键初始化: ${pairingUrl}`);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
console.log(' 配对码暂不可用,可在本机初始化页面获取,或稍后重试 ec init --web。');
|
|
416
|
+
}
|
|
417
|
+
console.log(' 远程首次访问需要配对;已有有效 token 可直接继续。');
|
|
418
|
+
}
|
|
370
419
|
return true;
|
|
371
420
|
}
|
|
372
421
|
// ==================== Main ====================
|
|
@@ -746,23 +795,13 @@ export async function initTail(options = {}) {
|
|
|
746
795
|
}
|
|
747
796
|
async function handleEcwebPrompt() {
|
|
748
797
|
const daemonConfigForEcweb = loadDaemonConfig();
|
|
749
|
-
if (ecwebService(daemonConfigForEcweb.services)
|
|
798
|
+
if (ecwebService(daemonConfigForEcweb.services).enabled !== false) {
|
|
750
799
|
const installResult = await ensureEcwebInstalledForInit();
|
|
751
800
|
if (installResult.ok) {
|
|
752
|
-
const cfg = loadDaemonConfig();
|
|
753
|
-
saveDaemonConfig({
|
|
754
|
-
...cfg,
|
|
755
|
-
services: setEcwebEnabled(cfg.services, true),
|
|
756
|
-
});
|
|
757
801
|
console.log(' ✓ 已启用 ECWeb(ec start 将自动在后台启动)');
|
|
758
802
|
console.log(' 提示:首次访问运行 ec watch web 查看配对码和 URL');
|
|
759
803
|
}
|
|
760
804
|
else {
|
|
761
|
-
const cfg = loadDaemonConfig();
|
|
762
|
-
saveDaemonConfig({
|
|
763
|
-
...cfg,
|
|
764
|
-
services: setEcwebEnabled(cfg.services, false),
|
|
765
|
-
});
|
|
766
805
|
console.log(' 提示:安装完成后运行 ec start;如需立即打开控制台,运行 ec watch web');
|
|
767
806
|
}
|
|
768
807
|
}
|
|
@@ -924,25 +963,17 @@ export async function cmdInitNonInteractive(opts, dependencies = {}) {
|
|
|
924
963
|
projectsDefaultPath = opts.projectpath;
|
|
925
964
|
}
|
|
926
965
|
// ── 5. 读取现有配置;协议冲突由 SDK 注册意图及共识判定 ──
|
|
927
|
-
|
|
966
|
+
let existingCfg = loadDaemonConfig();
|
|
928
967
|
// ── 6. EC Web 安装(先安装成功,再写 enabled 配置)──
|
|
929
968
|
if (opts.ecweb === true) {
|
|
930
969
|
const ensureEcweb = dependencies.ensureEcweb ?? (() => ensureEcwebInstalledForInit({ quiet: true }));
|
|
931
970
|
const installResult = await ensureEcweb();
|
|
932
971
|
if (!installResult.ok) {
|
|
933
|
-
if (ecwebService(existingCfg.services)?.enabled === true) {
|
|
934
|
-
try {
|
|
935
|
-
saveDaemonConfig({
|
|
936
|
-
...existingCfg,
|
|
937
|
-
services: setEcwebEnabled(existingCfg.services, false),
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
catch (e) {
|
|
941
|
-
fail('ECWEB_INSTALL_FAILED', `failed to install ${WEB_PACKAGE_LATEST}: ${installResult.error}; failed to disable ecweb: ${e?.message || e}`, EXIT_RUNTIME, format);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
972
|
fail('ECWEB_INSTALL_FAILED', `failed to install ${WEB_PACKAGE_LATEST}: ${installResult.error}`, EXIT_RUNTIME, format);
|
|
945
973
|
}
|
|
974
|
+
if (ecwebService(existingCfg.services).enabled === false) {
|
|
975
|
+
existingCfg = { ...existingCfg, services: setEcwebEnabled(existingCfg.services, true) };
|
|
976
|
+
}
|
|
946
977
|
}
|
|
947
978
|
// ── 7. 写 defaults.json ──
|
|
948
979
|
try {
|
|
@@ -988,9 +1019,6 @@ export async function cmdInitNonInteractive(opts, dependencies = {}) {
|
|
|
988
1019
|
...existingCfg,
|
|
989
1020
|
$schema_version: existingCfg.$schema_version ?? 1,
|
|
990
1021
|
aid: controlAid,
|
|
991
|
-
...(opts.ecweb === true
|
|
992
|
-
? { services: setEcwebEnabled(existingCfg.services, true) }
|
|
993
|
-
: {}),
|
|
994
1022
|
};
|
|
995
1023
|
saveDaemonConfig(next);
|
|
996
1024
|
}
|
|
@@ -1029,7 +1057,7 @@ export async function cmdInitNonInteractive(opts, dependencies = {}) {
|
|
|
1029
1057
|
success: true,
|
|
1030
1058
|
controlAid: controlAid,
|
|
1031
1059
|
ownerAid,
|
|
1032
|
-
ecwebEnabled:
|
|
1060
|
+
ecwebEnabled: ecwebService(existingCfg.services).enabled === true,
|
|
1033
1061
|
baseagent: chosenBaseagent,
|
|
1034
1062
|
providers,
|
|
1035
1063
|
projectsDefaultPath: projectsDefaultPath ?? null,
|
|
@@ -145,7 +145,7 @@ export async function cmdInvoke(args) {
|
|
|
145
145
|
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
146
146
|
const delegationToken = readDelegationCredential();
|
|
147
147
|
// 托管与非托管都走 daemon:密钥解析($VAR)与 providers.json 的合理归属都在 daemon。
|
|
148
|
-
const argv = [
|
|
148
|
+
const argv = sessionId !== undefined || delegationToken ? ['invoke', ...args] : [
|
|
149
149
|
'invoke',
|
|
150
150
|
'--provider', parsed.providerId,
|
|
151
151
|
'--service', parsed.serviceType,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { createInterface } from 'node:readline/promises';
|
|
4
|
+
import { Writable } from 'node:stream';
|
|
5
|
+
import { providerTemplateDetail } from '../config/provider-templates.js';
|
|
3
6
|
import { resolvePaths } from '../paths.js';
|
|
4
7
|
import { readDelegationCredential, hashCurrentDelegatedCommand } from '../core/auth/agent-delegation.js';
|
|
5
8
|
import { parseProviderCommand } from '../config/provider-ipc-service.js';
|
|
@@ -11,7 +14,14 @@ function providerText(command, data) {
|
|
|
11
14
|
for (const [alias, target] of Object.entries(data.aliases ?? {}))
|
|
12
15
|
lines.push(` ${label(alias)} → ${label(target)}`);
|
|
13
16
|
};
|
|
14
|
-
if (command.operation === '
|
|
17
|
+
if (command.operation === 'templates') {
|
|
18
|
+
for (const item of data.templates ?? [data]) {
|
|
19
|
+
lines.push(`${label(item.templateId)} ${label(item.label)} (${label(item.product)})`, ` 服务:${Object.keys(item.provider.services ?? {}).join(', ')} 密钥入口:${label(item.credential.helpUrl)}`);
|
|
20
|
+
for (const field of item.fields)
|
|
21
|
+
lines.push(` 输入:${label(field.name)} ${label(field.label)}${field.required ? '(必填)' : ''}${field.default ? ' 默认 ' + label(field.default) : ''}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (command.operation === 'sync') {
|
|
15
25
|
lines.push('✓ Provider 同步完成', `地址固化:${data.materializedBaseUrls ?? 0} 项`, `配置变更:${data.changedFiles ?? 0} 个文件,更新 ${data.referencesUpdated ?? 0} 处引用`);
|
|
16
26
|
if (data.imports?.length) {
|
|
17
27
|
lines.push('本机导入:');
|
|
@@ -52,14 +62,16 @@ function providerText(command, data) {
|
|
|
52
62
|
lines.push(`${indent}${label(field)}:${label(value)}`);
|
|
53
63
|
};
|
|
54
64
|
const provider = structuredClone(data.provider ?? {});
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
for (const connection of [provider.common, ...Object.values(provider.services ?? {})]) {
|
|
66
|
+
if (!connection)
|
|
67
|
+
continue;
|
|
68
|
+
const key = connection.apiKey;
|
|
57
69
|
if (key && !/^\$(?:[A-Za-z_][A-Za-z0-9_]*|\{[A-Za-z_][A-Za-z0-9_]*\})$/u.test(key))
|
|
58
|
-
|
|
70
|
+
connection.apiKey = '<redacted>';
|
|
59
71
|
for (const field of ['headers', 'queryParams']) {
|
|
60
|
-
if (
|
|
61
|
-
for (const key of Object.keys(
|
|
62
|
-
|
|
72
|
+
if (connection[field])
|
|
73
|
+
for (const key of Object.keys(connection[field]))
|
|
74
|
+
connection[field][key] = '<redacted>';
|
|
63
75
|
}
|
|
64
76
|
}
|
|
65
77
|
for (const [field, value] of Object.entries(provider))
|
|
@@ -73,11 +85,47 @@ function providerText(command, data) {
|
|
|
73
85
|
lines.push(`配置版本:${label(data.revision)}`);
|
|
74
86
|
return lines.join('\n');
|
|
75
87
|
}
|
|
88
|
+
async function completeTemplateArgs(args, parsed) {
|
|
89
|
+
if (!parsed.templateId || parsed.operation === 'templates' || parsed.file)
|
|
90
|
+
return args;
|
|
91
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
92
|
+
return args;
|
|
93
|
+
const template = providerTemplateDetail(parsed.templateId);
|
|
94
|
+
const result = [...args];
|
|
95
|
+
for (const field of template.fields) {
|
|
96
|
+
if (!field.required || field.default || parsed.templateInput?.inputs?.[field.name])
|
|
97
|
+
continue;
|
|
98
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
99
|
+
try {
|
|
100
|
+
result.push('--input', field.name + '=' + (await prompt.question(field.label + ': ')).trim());
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
prompt.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!parsed.templateInput?.apiKey) {
|
|
107
|
+
process.stdout.write(template.credential.label + '(输入不回显): ');
|
|
108
|
+
const silent = new Writable({ write(_chunk, _encoding, callback) { callback(); } });
|
|
109
|
+
const prompt = createInterface({ input: process.stdin, output: silent, terminal: true });
|
|
110
|
+
try {
|
|
111
|
+
result.push('--api-key', (await prompt.question('')).trim());
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
prompt.close();
|
|
115
|
+
silent.end();
|
|
116
|
+
process.stdout.write('\n');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
76
121
|
export async function cmdProvider(args) {
|
|
77
122
|
if (!args.length || wantsHelp(args)) {
|
|
78
123
|
console.log('用法: ec provider <命令> [--format json]\n\n'
|
|
79
|
-
+ ' list\n show <provider-id>\n create --file <path>\n import --file <path>\n'
|
|
124
|
+
+ ' list\n show <provider-id>\n templates [template-id]\n create --file <path>\n import --file <path>\n'
|
|
80
125
|
+ ' update <provider-id> --file <path>\n delete <provider-id>\n sync\n\n'
|
|
126
|
+
+ '模板:create / update <id> --template <template-id> --file <inputs.json>\n'
|
|
127
|
+
+ '宿主终端也可用 --api-key、--name、--services ecagent,claude,codex、可重复 --input 字段=值;TTY 自动补齐。\n'
|
|
128
|
+
+ '托管任务模板写入仅接受 --file;同域合并需显式 update,不自动覆盖。\n'
|
|
81
129
|
+ 'sync 扫描导入本机 Provider、固化环境变量地址、迁移 ID 与配置引用,并切换全局默认到 ecagent;不覆盖 Agent 显式基座选择。\n'
|
|
82
130
|
+ '默认输出可读文本;--format json 输出完整结构化响应,适合脚本处理。\n'
|
|
83
131
|
+ '宿主控制终端或 daemon 验证的 trusted fullaccess 任务可管理 process 级 Provider。\n'
|
|
@@ -88,15 +136,28 @@ export async function cmdProvider(args) {
|
|
|
88
136
|
}
|
|
89
137
|
const json = args.some((value, index) => value === '--format=json' || (value === '--format' && args[index + 1] === 'json'));
|
|
90
138
|
try {
|
|
91
|
-
|
|
139
|
+
let parsed = parseProviderCommand(['provider', ...args]);
|
|
92
140
|
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
93
141
|
const delegationToken = readDelegationCredential();
|
|
142
|
+
if (sessionId !== undefined || delegationToken) {
|
|
143
|
+
if (parsed.templateId && parsed.operation !== 'templates' && (!parsed.file || parsed.templateInput)) {
|
|
144
|
+
throw new Error('托管任务模板写入仅支持 --file');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
args = await completeTemplateArgs(args, parsed);
|
|
149
|
+
parsed = parseProviderCommand(['provider', ...args]);
|
|
150
|
+
}
|
|
94
151
|
// Keep managed argv identical to the command bound by task approval.
|
|
95
152
|
// The daemon resolves relative input paths against the session project.
|
|
96
|
-
const argv =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
153
|
+
const argv = ['provider', ...args];
|
|
154
|
+
if (sessionId === undefined && !delegationToken && parsed.file) {
|
|
155
|
+
const index = argv.findIndex(value => value === '--file' || value.startsWith('--file='));
|
|
156
|
+
if (argv[index] === '--file')
|
|
157
|
+
argv[index + 1] = path.resolve(parsed.file);
|
|
158
|
+
else
|
|
159
|
+
argv[index] = '--file=' + path.resolve(parsed.file);
|
|
160
|
+
}
|
|
100
161
|
let controlToken;
|
|
101
162
|
if (!sessionId && !delegationToken) {
|
|
102
163
|
try {
|