evolcore 0.0.41-test.0 → 0.0.41-test.2
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 +62 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +88 -49
- package/dist/agents/claude-runner.js +177 -92
- package/dist/agents/codex-runner.js +146 -71
- package/dist/agents/ecagent-runner.js +1 -1
- package/dist/agents/gemini-runner.js +1 -1
- package/dist/aun/aid/agentmd.js +98 -11
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +26 -2
- package/dist/aun/aid/identity.js +91 -0
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/managed-operation.js +1 -1
- package/dist/aun/aid/ownership-operation.js +23 -22
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -21
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/menu/client.js +27 -0
- package/dist/aun/msg/managed-operation.js +68 -7
- package/dist/aun/msg/p2p.js +8 -8
- package/dist/aun/service-proxy.js +53 -12
- package/dist/channels/aun.js +633 -32
- package/dist/channels/daemon.js +15 -1
- package/dist/cli/agent-command.js +5 -2
- package/dist/cli/agent-create.js +991 -233
- package/dist/cli/agent.js +49 -10
- package/dist/cli/aid-bind-command.js +48 -19
- package/dist/cli/aun-commands.js +48 -36
- package/dist/cli/daemon-commands.js +679 -697
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +72 -5
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +17 -1
- package/dist/cli/model.js +40 -40
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/role.js +85 -0
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/access-policy.js +7 -2
- package/dist/config/boot-log.js +39 -1
- package/dist/config/config-field-policy.js +17 -39
- package/dist/config/config-manager.js +183 -44
- package/dist/config/config-operation-service.js +5 -19
- package/dist/config/contact-book-store.js +47 -21
- package/dist/config/contact-book.js +18 -12
- package/dist/config/contact-operation-service.js +3 -4
- package/dist/config/contact-request-service.js +11 -0
- package/dist/config/daemon-services.js +11 -0
- package/dist/config/gateway-config.js +88 -594
- package/dist/config/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +15 -12
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +11 -1
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +1000 -25
- package/dist/config-store.js +89 -4
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +4 -1
- package/dist/core/agent-application-service.js +60 -11
- package/dist/core/agent-create-status.js +203 -0
- package/dist/core/agent-creation-claim.js +177 -0
- package/dist/core/agent-ipc-registration.js +39 -18
- package/dist/core/agent-runtime.js +194 -24
- package/dist/core/auth/agent-delegation.js +6 -3
- package/dist/core/auth/auth-gateway.js +67 -2
- package/dist/core/auth/authorization-audit.js +58 -11
- package/dist/core/auth/delegation-authorization.js +5 -2
- package/dist/core/auth/operation-authorizer.js +43 -6
- package/dist/core/auth/operation-catalog.js +45 -7
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +260 -21
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +8 -3
- package/dist/core/command/command-handler.js +112 -154
- package/dist/core/command/connect-menu.js +11 -3
- package/dist/core/command/data-root-resolver.js +5 -4
- package/dist/core/command/memory-slash.js +16 -8
- package/dist/core/command/menu-catalog.js +10 -6
- package/dist/core/command/menu-handler.js +106 -73
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/role-menu.js +147 -30
- package/dist/core/command/slash-handler.js +125 -255
- package/dist/core/daemon-control.js +26 -27
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +7 -5
- package/dist/core/evolagent.js +10 -8
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +40 -24
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +96 -1
- package/dist/core/memory/consolidation-trigger.js +208 -191
- package/dist/core/memory/consolidation.js +333 -35
- package/dist/core/memory/index-manager.js +27 -5
- package/dist/core/memory/memory-admin.js +45 -5
- package/dist/core/memory/memory-writer.js +163 -18
- package/dist/core/memory/relation-idle-monitor.js +119 -58
- package/dist/core/memory/relation-sweep.js +55 -45
- package/dist/core/message/aun-ipc-sender.js +81 -69
- package/dist/core/message/im-renderer.js +25 -4
- package/dist/core/message/message-admission.js +89 -4
- package/dist/core/message/message-bridge.js +66 -21
- package/dist/core/message/response-engine.js +108 -35
- package/dist/core/model/catalog-service.js +5 -3
- package/dist/core/model/config-scope.js +29 -71
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +30 -41
- package/dist/core/model/model-diagnostics.js +4 -3
- package/dist/core/model/model-fallback.js +10 -7
- package/dist/core/model/model-permission.js +3 -2
- package/dist/core/ownership/owner-resolver.js +772 -158
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +62 -6
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +21 -46
- package/dist/core/relation/peer-identity.js +64 -1
- package/dist/core/role/runtime-policy.js +72 -13
- package/dist/core/session/session-capsule.js +1 -1
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +20 -0
- package/dist/core/session/session-renew.js +3 -3
- package/dist/core/skill/index-generator.js +15 -5
- package/dist/core/system-session/memory.js +43 -8
- package/dist/core/thread/thread-service.js +19 -6
- package/dist/directory/owner-directory-admission.js +95 -0
- package/dist/directory/owner-directory-authorization.js +309 -0
- package/dist/directory/owner-directory-cache.js +635 -0
- package/dist/eck/kit-renderer.js +2 -2
- package/dist/ecweb/basic-settings-service.js +33 -40
- package/dist/ecweb/init-menu.js +32 -0
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +93 -19
- package/dist/ipc.js +247 -29
- package/dist/paths.js +7 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +484 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/trigger/authorization.js +27 -17
- package/dist/trigger/feedback.js +2 -3
- package/dist/trigger/ipc-service.js +105 -78
- package/dist/trigger/local-files.js +2 -1
- package/dist/trigger/manager.js +5 -3
- package/dist/trigger/scheduler.js +88 -6
- package/dist/utils/atomic-write.js +28 -0
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +26 -2
- package/dist/utils/logger.js +92 -6
- package/dist/utils/package-version-info.js +4 -2
- package/dist/utils/welcome.js +1 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/aun/SDK.md +4 -1
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent.md +8 -1
- package/kits/docs/evolcore/aid.md +67 -17
- package/kits/docs/evolcore/config.md +28 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/fs.md +11 -0
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -2
- package/kits/docs/evolcore/memory-consolidation.md +32 -8
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +4 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +4 -7
- package/kits/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +8 -3
- package/kits/schemas/agent-config.schema.16.json +891 -0
- package/kits/schemas/daemon.schema.9.json +366 -0
- package/kits/schemas/defaults.schema.5.json +406 -127
- package/kits/schemas/relation-config.schema.11.json +277 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- package/kits/skills/personal-assistant/SKILL.md +176 -0
- package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
- package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
- package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
- package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
- package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
- package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
- package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
- package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
- package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
- package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
- package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
- package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
- package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
- package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
- package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
- package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
- package/kits/skills/thread-ops/SKILL.md +5 -0
- package/kits/templates/memory-consolidation/forget.md +19 -6
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/memory-consolidation/profile.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +20 -3
- package/kits/templates/roles/member.json +8 -1
- package/kits/templates/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/memory.md +4 -4
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +7 -3
- package/dist/core/message/create-status.js +0 -96
package/dist/cli/fs-command.js
CHANGED
|
@@ -6,7 +6,7 @@ import { agentmdGet, getAidStore, isValidAid, loadClient, SLOT } from '../aun/ai
|
|
|
6
6
|
import { daemonUnavailableMessage, queryDaemon } from './help.js';
|
|
7
7
|
import { resolvePaths } from '../paths.js';
|
|
8
8
|
import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
9
|
-
import { DEFAULT_FS_CAT_BYTES, MAX_FS_CAT_BYTES, FsReadBudgetError, downloadGroupFsBytes, readPersonalFsBytesWithinBudget, } from '../aun/group/fs-download.js';
|
|
9
|
+
import { DEFAULT_FS_CAT_BYTES, MAX_FS_CAT_BYTES, FsReadBudgetError, downloadGroupFsBytes, readPersonalFsBytesWithinBudget, readAuthoritativePersonalFsObject, } from '../aun/group/fs-download.js';
|
|
10
10
|
class FsCliError extends Error {
|
|
11
11
|
code;
|
|
12
12
|
suggestion;
|
|
@@ -39,6 +39,7 @@ Commands:
|
|
|
39
39
|
token issue|revoke|ls <path> 管理访问 token(personal storage)
|
|
40
40
|
find <AID>:<path> [filters] 查找节点
|
|
41
41
|
df <AID>: 查看容量/配额
|
|
42
|
+
link <AID>:<path> [--expires T] 生成下载直链(personal storage;T 如 24h/7d/0,0 为不过期)
|
|
42
43
|
mount <target> --volume <id> 挂载实体卷
|
|
43
44
|
mount <target> --source <src> 挂载远程子树
|
|
44
45
|
approve <AID>:<path> 批准待审挂载(personal storage)
|
|
@@ -73,6 +74,7 @@ Options:
|
|
|
73
74
|
--mtime <expr> find 修改时间过滤
|
|
74
75
|
--head-bytes <n> cat 二进制头部字节数,默认 256
|
|
75
76
|
--max-bytes <n> cat 读取预算,默认及最高 131072;超限终止读取
|
|
77
|
+
--authoritative cat 个人空间私有 ACL 完整对象;不使用 HTTP 下载票据
|
|
76
78
|
--aun-path <path> 指定 AUN keystore 根
|
|
77
79
|
--app <name> 指定 AUN app slot
|
|
78
80
|
|
|
@@ -126,6 +128,8 @@ export async function cmdFs(args) {
|
|
|
126
128
|
let opts;
|
|
127
129
|
try {
|
|
128
130
|
opts = parseCommonOptions(args);
|
|
131
|
+
if (opts.authoritative && sub !== 'cat')
|
|
132
|
+
throw new FsCliError('INVALID_ARGUMENT', '--authoritative 只用于 cat');
|
|
129
133
|
}
|
|
130
134
|
catch (e) {
|
|
131
135
|
outputError(e, formatJson);
|
|
@@ -186,6 +190,9 @@ export async function cmdFs(args) {
|
|
|
186
190
|
case 'df':
|
|
187
191
|
await fsDf(args.slice(1), opts);
|
|
188
192
|
return;
|
|
193
|
+
case 'link':
|
|
194
|
+
await fsLink(args.slice(1), opts);
|
|
195
|
+
return;
|
|
189
196
|
case 'mount':
|
|
190
197
|
await fsMount(args.slice(1), opts);
|
|
191
198
|
return;
|
|
@@ -275,6 +282,11 @@ async function runManagedFs(args, formatJson) {
|
|
|
275
282
|
case 'remove':
|
|
276
283
|
console.log(`✓ 已删除: ${result.path}`);
|
|
277
284
|
return;
|
|
285
|
+
case 'link':
|
|
286
|
+
console.log(`🔗 ${String(result.url ?? '')}`);
|
|
287
|
+
if (result.expireAt)
|
|
288
|
+
console.log(`有效期至: ${new Date(Number(result.expireAt)).toISOString()}`);
|
|
289
|
+
return;
|
|
278
290
|
case 'getfacl':
|
|
279
291
|
console.log(JSON.stringify(result.result ?? {}, null, 2));
|
|
280
292
|
return;
|
|
@@ -305,6 +317,7 @@ function parseCommonOptions(args) {
|
|
|
305
317
|
contentType: getArgValue(args, '--content-type'),
|
|
306
318
|
maxCatBytes,
|
|
307
319
|
headBytes,
|
|
320
|
+
authoritative: args.includes('--authoritative'),
|
|
308
321
|
};
|
|
309
322
|
}
|
|
310
323
|
function requireActor(opts) {
|
|
@@ -405,7 +418,15 @@ async function fsCat(args, opts) {
|
|
|
405
418
|
const route = await resolveRoute(target.aid, store);
|
|
406
419
|
let statInfo;
|
|
407
420
|
let bytes;
|
|
408
|
-
if (
|
|
421
|
+
if (opts.authoritative) {
|
|
422
|
+
if (route.backend !== 'personal' || opts.token) {
|
|
423
|
+
throw new FsCliError('INVALID_ARGUMENT', '--authoritative 仅支持按 AID 认证的个人空间对象');
|
|
424
|
+
}
|
|
425
|
+
const object = await readAuthoritativePersonalFsObject(client, target.path, target.aid, opts.maxCatBytes);
|
|
426
|
+
bytes = object.bytes;
|
|
427
|
+
statInfo = object.metadata;
|
|
428
|
+
}
|
|
429
|
+
else if (route.backend === 'group') {
|
|
409
430
|
statInfo = await client.group.fs.stat(remoteRef(target));
|
|
410
431
|
const size = numberFrom(statInfo, ['size', 'size_bytes', 'bytes']);
|
|
411
432
|
if (size !== undefined && size > opts.maxCatBytes)
|
|
@@ -997,6 +1018,47 @@ async function fsDf(args, opts) {
|
|
|
997
1018
|
}
|
|
998
1019
|
});
|
|
999
1020
|
}
|
|
1021
|
+
async function fsLink(args, opts) {
|
|
1022
|
+
const target = parseRemoteRequired(firstPositional(args), { command: 'link' });
|
|
1023
|
+
const expiresRaw = getArgValue(args, '--expires');
|
|
1024
|
+
let expiresSeconds;
|
|
1025
|
+
if (expiresRaw !== undefined) {
|
|
1026
|
+
const match = /^(\d+)([smhd])?$/i.exec(expiresRaw.trim());
|
|
1027
|
+
const unit = match?.[2]?.toLowerCase();
|
|
1028
|
+
const scale = unit === 'm' ? 60 : unit === 'h' ? 3600 : unit === 'd' ? 86400 : 1;
|
|
1029
|
+
const seconds = match ? Number(match[1]) * scale : Number.NaN;
|
|
1030
|
+
if (!match || !Number.isSafeInteger(seconds) || seconds > 7 * 24 * 3600) {
|
|
1031
|
+
throw new FsCliError('INVALID_ARGUMENT', '--expires 支持纯秒数或 30m / 12h / 7d,最长 7 天,0 表示不过期');
|
|
1032
|
+
}
|
|
1033
|
+
expiresSeconds = seconds;
|
|
1034
|
+
}
|
|
1035
|
+
await withClient(opts, async ({ client, store }) => {
|
|
1036
|
+
const route = await resolveRoute(target.aid, store);
|
|
1037
|
+
if (route.backend === 'group') {
|
|
1038
|
+
throw new FsCliError('NOT_ALLOWED', 'link 仅支持 personal storage');
|
|
1039
|
+
}
|
|
1040
|
+
const ticket = await client.call('storage.create_download_ticket', {
|
|
1041
|
+
owner_aid: target.aid,
|
|
1042
|
+
bucket: 'default',
|
|
1043
|
+
object_key: target.path.replace(/^\/+/, ''),
|
|
1044
|
+
...(expiresSeconds !== undefined ? { expire_in_seconds: expiresSeconds } : {}),
|
|
1045
|
+
});
|
|
1046
|
+
const url = typeof ticket?.download_url === 'string' && ticket.download_url
|
|
1047
|
+
? ticket.download_url
|
|
1048
|
+
: typeof ticket?.url === 'string' ? ticket.url : '';
|
|
1049
|
+
if (!url)
|
|
1050
|
+
throw new FsCliError('DEPENDENCY_UNAVAILABLE', 'storage 未返回下载链接');
|
|
1051
|
+
outputSuccess(opts, {
|
|
1052
|
+
command: 'link', backend: route.backend, route, path: remoteRef(target),
|
|
1053
|
+
url, expireAt: ticket.expire_at ?? null,
|
|
1054
|
+
}, () => {
|
|
1055
|
+
console.log(`🔗 ${url}`);
|
|
1056
|
+
if (expiresSeconds !== undefined) {
|
|
1057
|
+
console.log(expiresSeconds === 0 ? '有效期: 不过期' : `有效期: ${expiresSeconds} 秒`);
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1000
1062
|
async function fsMount(args, opts) {
|
|
1001
1063
|
const positional = collectPositionals(args);
|
|
1002
1064
|
const volumeId = getArgValue(args, '--volume');
|
package/dist/cli/index.js
CHANGED
|
@@ -40,6 +40,7 @@ Agent 与会话:
|
|
|
40
40
|
getmeta 按会话 id / threadId / agentSessionId 查询会话元数据
|
|
41
41
|
task 恢复暂停或异常中断的会话任务
|
|
42
42
|
trigger 管理定时与事件触发器
|
|
43
|
+
proxy 查询和管理 daemon 服务代理
|
|
43
44
|
handoff 查询和完成跨会话回流
|
|
44
45
|
model 查看或设置模型与推理强度
|
|
45
46
|
response 查看或设置响应模式
|
|
@@ -58,6 +59,7 @@ AUN:
|
|
|
58
59
|
|
|
59
60
|
配置与诊断:
|
|
60
61
|
config 读取、修改和检查分层配置
|
|
62
|
+
provider 管理 daemon 级 Provider 注册表与 JSON 导入
|
|
61
63
|
stats Token 用量与费用统计
|
|
62
64
|
diagnose 检查启动环境
|
|
63
65
|
version 显示组件版本
|
|
@@ -110,7 +112,7 @@ export async function main(args) {
|
|
|
110
112
|
// 注入完成后剥除 --as-session <sessionId> 两个参数,避免子命令把它们当作未知参数
|
|
111
113
|
const strippedArgs = stripAsSessionArgs(args);
|
|
112
114
|
try {
|
|
113
|
-
assertManagedTopLevelCommandAllowed(cmd, strippedArgs);
|
|
115
|
+
await assertManagedTopLevelCommandAllowed(cmd, strippedArgs);
|
|
114
116
|
}
|
|
115
117
|
catch (error) {
|
|
116
118
|
if (!(error instanceof ManagedCommandNotAllowedError))
|
|
@@ -142,6 +144,10 @@ export async function main(args) {
|
|
|
142
144
|
--baseagent <claude|codex|gemini|ecagent> 默认: PATH 中第一个可用项;ecagent 需显式选择
|
|
143
145
|
--force 已存在 defaults.json 时覆盖
|
|
144
146
|
|
|
147
|
+
通过 EC Web 完成首次初始化:
|
|
148
|
+
ec init --web 启动初始化所需服务并输出 EC Web 入口地址
|
|
149
|
+
默认 ec init 行为保持不变
|
|
150
|
+
|
|
145
151
|
云部署非交互式初始化(结构化 JSON 输出):
|
|
146
152
|
ec init --non-interactive --owner <aid> [--format json] [选项]
|
|
147
153
|
--owner <aid> 必填。控制 AID 创建后的 Owner 邀约目标,不等待审批
|
|
@@ -194,6 +200,19 @@ export async function main(args) {
|
|
|
194
200
|
process.exit(1);
|
|
195
201
|
}
|
|
196
202
|
else {
|
|
203
|
+
if (strippedArgs.includes("--web")) {
|
|
204
|
+
if (strippedArgs.length !== 2) {
|
|
205
|
+
console.error("❌ ec init --web 不能与其他初始化参数组合使用");
|
|
206
|
+
process.exitCode = 1;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
const { suppressSdkLogs } = await import("../aun/aid/index.js");
|
|
210
|
+
suppressSdkLogs();
|
|
211
|
+
const initialized = await cmdInit({ web: true });
|
|
212
|
+
if (!initialized && process.exitCode == null)
|
|
213
|
+
process.exitCode = 1;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
197
216
|
const { suppressSdkLogs } = await import('../aun/aid/index.js');
|
|
198
217
|
suppressSdkLogs();
|
|
199
218
|
const nonInteractive = strippedArgs.includes('--non-interactive');
|
|
@@ -280,11 +299,27 @@ export async function main(args) {
|
|
|
280
299
|
if (process.env.EVOLCORE_SESSION_ID) {
|
|
281
300
|
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
282
301
|
const delegationToken = readDelegationCredential();
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
302
|
+
let result;
|
|
303
|
+
try {
|
|
304
|
+
// Status includes a process-scope authorization round trip. Give a
|
|
305
|
+
// busy daemon enough time to answer and preserve transport failures
|
|
306
|
+
// instead of turning them into a misleading permission denial.
|
|
307
|
+
result = await ipcQuery(resolvePaths().socket, {
|
|
308
|
+
type: 'status.auth', sessionId, delegationToken, argv: ['status', ...statusArgs],
|
|
309
|
+
}, 10_000, { throwOnError: true });
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
console.error(`❌ status 查询失败:${error instanceof Error ? error.message : String(error)}`);
|
|
313
|
+
process.exitCode = 1;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
if (result === null) {
|
|
317
|
+
console.error('❌ status 查询失败:daemon 未返回授权结果');
|
|
318
|
+
process.exitCode = 1;
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
286
321
|
if (!result?.ok) {
|
|
287
|
-
console.error(`❌ ${result?.error || 'status
|
|
322
|
+
console.error(`❌ ${result?.error || 'status 权限校验失败'}`);
|
|
288
323
|
process.exitCode = 1;
|
|
289
324
|
break;
|
|
290
325
|
}
|
|
@@ -380,6 +415,28 @@ export async function main(args) {
|
|
|
380
415
|
await cmdTrigger(strippedArgs.slice(1));
|
|
381
416
|
}
|
|
382
417
|
break;
|
|
418
|
+
case 'proxy': {
|
|
419
|
+
const { cmdProxy } = await import('./proxy-command.js');
|
|
420
|
+
try {
|
|
421
|
+
await cmdProxy(strippedArgs.slice(1));
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
const result = {
|
|
425
|
+
ok: false,
|
|
426
|
+
code: typeof error?.code === 'string' ? error.code : 'PROXY_FAILED',
|
|
427
|
+
error: error?.message ?? String(error),
|
|
428
|
+
};
|
|
429
|
+
const formatIndex = strippedArgs.indexOf('--format');
|
|
430
|
+
if ((formatIndex >= 0 && strippedArgs[formatIndex + 1] === 'json') || strippedArgs.includes('--json')) {
|
|
431
|
+
console.log(JSON.stringify(result));
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
console.error(result.error + ' (' + result.code + ')');
|
|
435
|
+
}
|
|
436
|
+
process.exitCode = 1;
|
|
437
|
+
}
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
383
440
|
case 'agent': {
|
|
384
441
|
const { suppressSdkLogs } = await import('../aun/aid/index.js');
|
|
385
442
|
suppressSdkLogs();
|
|
@@ -482,6 +539,11 @@ export async function main(args) {
|
|
|
482
539
|
await cmdResponse(strippedArgs.slice(1));
|
|
483
540
|
break;
|
|
484
541
|
}
|
|
542
|
+
case 'provider': {
|
|
543
|
+
const { cmdProvider } = await import('./provider-command.js');
|
|
544
|
+
await cmdProvider(strippedArgs.slice(1));
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
485
547
|
case 'config': {
|
|
486
548
|
const { cmdConfig } = await import('./config.js');
|
|
487
549
|
await cmdConfig(strippedArgs.slice(1));
|
|
@@ -492,6 +554,11 @@ export async function main(args) {
|
|
|
492
554
|
await cmdContact(strippedArgs.slice(1));
|
|
493
555
|
break;
|
|
494
556
|
}
|
|
557
|
+
case 'role': {
|
|
558
|
+
const { cmdRole } = await import('./role.js');
|
|
559
|
+
await cmdRole(strippedArgs.slice(1));
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
495
562
|
case 'stats': {
|
|
496
563
|
const { handleStats } = await import('./stats.js');
|
|
497
564
|
await handleStats(strippedArgs.slice(1));
|
package/dist/cli/init-channel.js
CHANGED
|
@@ -696,7 +696,7 @@ export async function cmdInitWechat() {
|
|
|
696
696
|
// ==================== AUN ====================
|
|
697
697
|
export async function cmdInitAun() {
|
|
698
698
|
console.log('AUN 协议 Owner 统一使用 ec aid bind <ownerAid> [--subject <subjectAid>]');
|
|
699
|
-
console.log(`状态查询: ${MAIN_CLI_BIN} aid bind status [--subject <subjectAid>]
|
|
699
|
+
console.log(`状态查询: ${MAIN_CLI_BIN} aid bind status [--refresh] [--subject <subjectAid>];转让: ${MAIN_CLI_BIN} aid transfer <subAid> <newOwnerAid> --subject <currentOwnerAid>;邀约审批: ${MAIN_CLI_BIN} aid bind accept|reject <operationId>。`);
|
|
700
700
|
}
|
|
701
701
|
async function pickAunOwnerBindTarget(rl, daemonAid) {
|
|
702
702
|
const { agents } = loadAllAgents();
|
package/dist/cli/init.js
CHANGED
|
@@ -6,7 +6,7 @@ import { resolvePaths, ensureDataDirs } from '../paths.js';
|
|
|
6
6
|
import { commandExists } from '../utils/cross-platform.js';
|
|
7
7
|
import { scanInstances } from '../utils/instance-registry.js';
|
|
8
8
|
import { saveDefaultsSafe, loadAllAgents, loadDaemonConfig, saveDaemonConfig } from '../config-store.js';
|
|
9
|
-
import { ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
|
|
9
|
+
import { DEFAULT_ECWEB_PORT, ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
|
|
10
10
|
import { ensureControlAgentMd, generateControlAid, resolveControlAidDomain, submitControlAidRegistration, } from '../aun/aid/control-aid.js';
|
|
11
11
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
12
12
|
import { getCodexAppServerAvailability } from '../agents/codex-runner.js';
|
|
@@ -161,8 +161,82 @@ export async function ensureEcwebInstalledForInit(options = {}) {
|
|
|
161
161
|
return { ok: false, error };
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
+
export async function cmdInitWeb(dependencies = {}) {
|
|
165
|
+
const p = resolvePaths();
|
|
166
|
+
ensureDataDirs();
|
|
167
|
+
const daemonRunning = dependencies.isDaemonRunning?.()
|
|
168
|
+
?? scanInstances().mains.some(instance => instance.alive);
|
|
169
|
+
if (daemonRunning && !(dependencies.loadConfig ?? loadDaemonConfig)().aid) {
|
|
170
|
+
console.error("❌ EvolCore 正在运行但未配置控制 AID;请先停止服务后重试。");
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
const install = await (dependencies.ensureEcwebInstalled ?? ensureEcwebInstalledForInit)();
|
|
174
|
+
if (!install.ok)
|
|
175
|
+
return false;
|
|
176
|
+
let config = (dependencies.loadConfig ?? loadDaemonConfig)();
|
|
177
|
+
if (!config.aid) {
|
|
178
|
+
try {
|
|
179
|
+
const aidDomain = resolveControlAidDomain(config.aun?.defaultAidDomain);
|
|
180
|
+
const { aid } = await (dependencies.generateAid ?? generateControlAid)(aidDomain);
|
|
181
|
+
config = { ...config, $schema_version: config.$schema_version ?? 1, aid };
|
|
182
|
+
(dependencies.saveConfig ?? saveDaemonConfig)(config);
|
|
183
|
+
console.log(`✓ 已生成主机控制 AID: ${aid}`);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
console.error(`❌ 主机控制 AID 准备失败: ${installErrorMessage(error)}`);
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const controlAid = config.aid;
|
|
191
|
+
if (!controlAid) {
|
|
192
|
+
console.error("❌ 主机控制 AID 未配置。");
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
await (dependencies.ensureAgentMd ?? ensureControlAgentMd)(controlAid);
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
console.warn(`⚠️ 主机控制 AID 名片暂未发布,将由 daemon 后续重试: ${installErrorMessage(error)}`);
|
|
200
|
+
}
|
|
201
|
+
if (ecwebService(config.services)?.enabled !== true) {
|
|
202
|
+
config = { ...config, services: setEcwebEnabled(config.services, true) };
|
|
203
|
+
try {
|
|
204
|
+
(dependencies.saveConfig ?? saveDaemonConfig)(config);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
console.error(`❌ 启用 ECWeb 失败: ${installErrorMessage(error)}`);
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
if (!daemonRunning && dependencies.startDaemon) {
|
|
213
|
+
await dependencies.startDaemon();
|
|
214
|
+
}
|
|
215
|
+
else if (!daemonRunning) {
|
|
216
|
+
const { cmdStart } = await import("./daemon-commands.js");
|
|
217
|
+
await cmdStart({ bindBootstrap: true, webInit: true });
|
|
218
|
+
}
|
|
219
|
+
const started = dependencies.startEcweb
|
|
220
|
+
? await dependencies.startEcweb()
|
|
221
|
+
: await (await import("./daemon-commands.js")).startEcwebIfEnabled(p);
|
|
222
|
+
if (!started) {
|
|
223
|
+
console.error("❌ ECWeb 未能启动;可稍后运行 ec watch web 重试。");
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.error(`❌ 启动 ECweb 初始化环境失败: ${installErrorMessage(error)}`);
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
const currentConfig = (dependencies.loadConfig ?? loadDaemonConfig)();
|
|
232
|
+
const port = ecwebService(currentConfig.services)?.port ?? DEFAULT_ECWEB_PORT;
|
|
233
|
+
console.log(`\nECweb 初始化: http://localhost:${port}/init`);
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
164
236
|
// ==================== Main ====================
|
|
165
237
|
export async function cmdInit(options) {
|
|
238
|
+
if (options?.web)
|
|
239
|
+
return cmdInitWeb();
|
|
166
240
|
// 云部署非交互式路径:当带 --owner 或 --format json 时走结构化分支,与交互式 tail 完全隔离。
|
|
167
241
|
// 预留方案 B:当 daemon 支持 Control Plane 无 agent 启动时,可在此分支跳过 agent new 预创建。
|
|
168
242
|
if (options?.nonInteractive && (options.owner || options.format === 'json' || options.projectpath || options.ecweb)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isHelpFlag, wantsHelp } from './help.js';
|
|
2
|
+
import { isTrustedFullAccessRuntimeContext, readVerifiedTaskRuntimeContext } from './task-context.js';
|
|
2
3
|
const MANAGED_TASK_COMMANDS = new Set([
|
|
3
4
|
'aid',
|
|
4
5
|
'agent',
|
|
@@ -16,8 +17,13 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
16
17
|
'memory',
|
|
17
18
|
'model',
|
|
18
19
|
'msg',
|
|
20
|
+
'proxy',
|
|
21
|
+
'provider',
|
|
19
22
|
'queue',
|
|
20
23
|
'response',
|
|
24
|
+
// `role` 提交/审批关系角色提升申请,通过 role.op IPC 鉴权;
|
|
25
|
+
// 申请本身不改变权限,审批只接受本 Agent 的 owner。
|
|
26
|
+
'role',
|
|
21
27
|
// `session` 按 ec 会话 id 只读查询本地 session 存档(meta 文件尾行的
|
|
22
28
|
// agentSessionId 等),不触碰 daemon 与进程生命周期。
|
|
23
29
|
'session',
|
|
@@ -45,6 +51,7 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
45
51
|
'-V',
|
|
46
52
|
'--version',
|
|
47
53
|
]);
|
|
54
|
+
const SELF_PROTECTED_LIFECYCLE_COMMANDS = new Set(['start', 'stop', 'restart', 'restart-monitor']);
|
|
48
55
|
export class ManagedCommandNotAllowedError extends Error {
|
|
49
56
|
command;
|
|
50
57
|
code = 'NOT_ALLOWED';
|
|
@@ -58,9 +65,18 @@ export class ManagedCommandNotAllowedError extends Error {
|
|
|
58
65
|
* Local maintenance commands do not have daemon authorization entrypoints.
|
|
59
66
|
* Keep them outside managed tasks so they cannot read or mutate host state.
|
|
60
67
|
*/
|
|
61
|
-
export function assertManagedTopLevelCommandAllowed(command, args, env = process.env) {
|
|
68
|
+
export async function assertManagedTopLevelCommandAllowed(command, args, env = process.env) {
|
|
62
69
|
if (!env.EVOLCORE_SESSION_ID || isHelpFlag(command) || wantsHelp(args.slice(1)))
|
|
63
70
|
return;
|
|
71
|
+
// A trusted fullaccess task may enter any implemented CLI command. The
|
|
72
|
+
// command's own daemon/operation handler still performs its normal checks.
|
|
73
|
+
const verified = await readVerifiedTaskRuntimeContext(env);
|
|
74
|
+
if (isTrustedFullAccessRuntimeContext(verified)) {
|
|
75
|
+
if (SELF_PROTECTED_LIFECYCLE_COMMANDS.has(command)) {
|
|
76
|
+
throw new ManagedCommandNotAllowedError(command);
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
64
80
|
if (!MANAGED_TASK_COMMANDS.has(command))
|
|
65
81
|
throw new ManagedCommandNotAllowedError(command);
|
|
66
82
|
}
|
package/dist/cli/model.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ec model` —— 面向 agent 的模型管理命令集。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* --self →
|
|
6
|
-
*
|
|
4
|
+
* 模型参数只在 Agent 级配置:
|
|
5
|
+
* --self → agents/<aid>/config.json 的 baseagents.<ba>.{model,effort}
|
|
6
|
+
* --peer 保留只读:可用于查看按关系角色约束生效的模型(model current/list/check)。
|
|
7
7
|
* 角色模型策略由角色策略编辑器管理;--role 仅用于过滤和预览有效模型。
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* 改 Agent 级后,该 Agent 所有会话的下一条消息即时生效(运行时不缓存,每条消息解析)。
|
|
10
10
|
* 与对话内 slash(/model /effort /baseagent)互不影响。
|
|
11
11
|
* 设计见 docs/model-command-design.md。
|
|
12
12
|
*/
|
|
13
13
|
import { isHelpFlag, wantsHelp, getArgValue } from './help.js';
|
|
14
|
-
import { ModelScopeError, normalizePeer, determineScope, activeBaseagent,
|
|
14
|
+
import { ModelScopeError, normalizePeer, determineScope, activeBaseagent, writeAgentModelConfig, clearAgentModelConfig, } from '../core/model/config-scope.js';
|
|
15
15
|
import { resolveEffectiveFieldWithSource } from '../config/config-manager.js';
|
|
16
16
|
import { getCatalog, getModelInfo, catalogEfforts, resolveCatalogModel, assertCatalogSelectable } from '../core/model/model-catalog.js';
|
|
17
17
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole, } from '../core/model/model-permission.js';
|
|
@@ -119,14 +119,16 @@ function explicitOrDerivedRole(args, sel) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function determineWriteScope(sel, formatJson) {
|
|
122
|
+
if (!sel.self)
|
|
123
|
+
fail(formatJson, 'AGENT_REQUIRED', '模型参数只在 Agent 级配置,请指定 --self <aid>');
|
|
124
|
+
if (sel.peerKey)
|
|
125
|
+
fail(formatJson, 'MODEL_AGENT_ONLY', '模型参数不支持 --peer:写入只在 Agent 级,不在关系级');
|
|
122
126
|
const scope = determineScope(sel);
|
|
123
|
-
if (scope === 'global')
|
|
127
|
+
if (scope === 'global')
|
|
124
128
|
fail(formatJson, 'NO_GLOBAL_SCOPE', '全局 model 作用域已退役;请用 --self 选择 agent');
|
|
125
|
-
|
|
126
|
-
if (scope === 'role') {
|
|
129
|
+
if (scope === 'role')
|
|
127
130
|
fail(formatJson, 'ROLE_POLICY_MANAGED', '角色策略只能通过角色策略编辑器修改');
|
|
128
|
-
|
|
129
|
-
return scope;
|
|
131
|
+
return 'agent';
|
|
130
132
|
}
|
|
131
133
|
function selectorWithRole(sel, role) {
|
|
132
134
|
return role ? { ...sel, role } : sel;
|
|
@@ -158,7 +160,8 @@ function resolveModelConfig(sel, baseagent) {
|
|
|
158
160
|
const effectiveModel = modelDecision.model;
|
|
159
161
|
const modelSource = modelDecision.constrained ? 'role' : modelScopeFromSource(model.source);
|
|
160
162
|
const source = effectiveModel !== undefined ? modelSource : modelScopeFromSource(effort.source);
|
|
161
|
-
|
|
163
|
+
// 模型只在 Agent 级配置,角色策略只做约束。
|
|
164
|
+
const scopes = ['role', 'agent'];
|
|
162
165
|
return {
|
|
163
166
|
model: effectiveModel,
|
|
164
167
|
effort: effort.value,
|
|
@@ -173,27 +176,28 @@ function resolveModelConfig(sel, baseagent) {
|
|
|
173
176
|
const HELP = `用法: ec model <command> [options]
|
|
174
177
|
|
|
175
178
|
Commands:
|
|
176
|
-
list
|
|
177
|
-
current
|
|
179
|
+
list 列出可用模型,标注当前 Agent 级模型
|
|
180
|
+
current 显示 Agent 级模型(经角色约束)+ 来源
|
|
178
181
|
info <model-id> 查看单个模型详情(厂商/上下文/价格/模态/effort/状态)
|
|
179
|
-
use <model-id>
|
|
180
|
-
reset
|
|
181
|
-
effort <level>
|
|
182
|
+
use <model-id> 设置 Agent 级模型(需 --self)
|
|
183
|
+
reset 清除 Agent 级模型与推理强度;清除后该 Agent 无模型可用
|
|
184
|
+
effort <level> 设置 Agent 级推理强度(low|medium|high|xhigh|max|auto)
|
|
182
185
|
check 诊断网关连通性与模型可用性(分阶段输出进度)
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
--self <aid>
|
|
188
|
-
--self <aid> --
|
|
187
|
+
模型参数只在 Agent 级配置(agents/<aid>/config.json 的 baseagents.<ba>.{model,effort})。
|
|
188
|
+
关系级与 defaults 都不承载模型;Agent 级未设置模型即无模型可用。
|
|
189
|
+
(无参数) 本机 CLI 只读 catalog,不允许写入
|
|
190
|
+
--self <aid> Agent 级(读写)
|
|
191
|
+
--self <aid> --role <role> 按角色策略预览有效模型(只读)
|
|
192
|
+
--self <aid> --peer <X> 按该对端的关系角色预览有效模型(只读,不可写)
|
|
189
193
|
|
|
190
|
-
修改
|
|
194
|
+
修改 Agent 级后,该 Agent 所有会话的下一条消息即时生效。
|
|
191
195
|
角色策略请通过角色策略编辑器修改。
|
|
192
|
-
托管会话内省略 --self/--peer/--role
|
|
196
|
+
托管会话内省略 --self/--peer/--role 时,命令作用于当前会话;写操作仅当前 Agent 的 owner/admin 可用。
|
|
193
197
|
|
|
194
198
|
Options:
|
|
195
199
|
--self <aid> 本端 AID
|
|
196
|
-
--peer <X> 对端:channelType#channelId 或裸 aid(裸 aid 视为 aun#<aid
|
|
200
|
+
--peer <X> 对端:channelType#channelId 或裸 aid(裸 aid 视为 aun#<aid>),只读
|
|
197
201
|
--role <role> 按角色过滤列表或预览有效模型(只读)
|
|
198
202
|
--effort <level> (use 专用)同时设置推理强度
|
|
199
203
|
--format json 输出 JSON
|
|
@@ -204,9 +208,8 @@ Options:
|
|
|
204
208
|
ec model current --self bot.agentid.pub --peer aun#alice.agentid.pub
|
|
205
209
|
ec model info deepseek-v4-pro
|
|
206
210
|
ec model use opus --self bot.agentid.pub
|
|
207
|
-
ec model use deepseek-v4-pro --self bot.agentid.pub --peer alice.agentid.pub
|
|
208
211
|
ec model effort high --self bot.agentid.pub
|
|
209
|
-
ec model reset --self bot.agentid.pub
|
|
212
|
+
ec model reset --self bot.agentid.pub
|
|
210
213
|
ec model check --self bot.agentid.pub`;
|
|
211
214
|
async function dispatch(sub, args, formatJson) {
|
|
212
215
|
switch (sub) {
|
|
@@ -251,7 +254,7 @@ async function cmdList(args, formatJson) {
|
|
|
251
254
|
models,
|
|
252
255
|
}, () => {
|
|
253
256
|
const lines = [];
|
|
254
|
-
lines.push(`当前生效: ${resolved.model ?? '(
|
|
257
|
+
lines.push(`当前生效: ${resolved.model ?? '(未配置,Agent 级未设置模型,无模型可用)'}` +
|
|
255
258
|
(resolved.source ? ` (来源: ${SCOPE_LABEL[resolved.source]})` : ''));
|
|
256
259
|
lines.push('');
|
|
257
260
|
if (resolved.model && !cat.models.some(m => m.id === resolved.model))
|
|
@@ -286,7 +289,7 @@ async function cmdCurrent(args, formatJson) {
|
|
|
286
289
|
chain: resolved.chain.map((c) => ({ scope: c.scope, model: c.model ?? null, hit: c.hit })),
|
|
287
290
|
}, () => {
|
|
288
291
|
const lines = [];
|
|
289
|
-
lines.push(`当前生效模型: ${resolved.model ?? '(
|
|
292
|
+
lines.push(`当前生效模型: ${resolved.model ?? '(未配置,Agent 级未设置模型,无模型可用)'}`);
|
|
290
293
|
lines.push(`推理强度: ${resolved.effort ?? 'auto'}`);
|
|
291
294
|
lines.push(`来源: ${resolved.source ? SCOPE_LABEL[resolved.source] : '无'}`);
|
|
292
295
|
const chain = resolved.chain.map((c) => `${SCOPE_LABEL[c.scope]}${c.hit ? ' ✓' : ''}${c.model ? `(${c.model})` : ''}`).join(' > ');
|
|
@@ -328,17 +331,15 @@ function describeWrite(scope, sel, model, effort, formatJson) {
|
|
|
328
331
|
ok: true,
|
|
329
332
|
scope,
|
|
330
333
|
self: sel.self ?? null,
|
|
331
|
-
peerKey: sel.peerKey ?? null,
|
|
332
334
|
model: model ?? undefined,
|
|
333
335
|
effort: effort ?? undefined,
|
|
334
336
|
}, () => {
|
|
335
|
-
const lines = ['✓ 已设置', ` 作用域: ${SCOPE_LABEL[scope]}`
|
|
336
|
-
(sel.peerKey ? ` (${sel.peerKey})` : '') + (sel.self ? ` [self=${sel.self}]` : '')];
|
|
337
|
+
const lines = ['✓ 已设置', ` 作用域: ${SCOPE_LABEL[scope]} [self=${sel.self ?? '?'}]`];
|
|
337
338
|
if (model !== null)
|
|
338
339
|
lines.push(` 模型: ${model}`);
|
|
339
340
|
if (effort !== null)
|
|
340
341
|
lines.push(` 推理强度: ${effort}`);
|
|
341
|
-
lines.push(' 生效:
|
|
342
|
+
lines.push(' 生效: 该 Agent 所有会话的下一条消息起生效。');
|
|
342
343
|
return lines.join('\n');
|
|
343
344
|
});
|
|
344
345
|
}
|
|
@@ -378,14 +379,14 @@ async function cmdUse(args, formatJson) {
|
|
|
378
379
|
}
|
|
379
380
|
const effortVal = effort === 'auto' ? null : (effort ?? undefined);
|
|
380
381
|
try {
|
|
381
|
-
|
|
382
|
+
writeAgentModelConfig(sel.self, ba, { model: modelId, effort: effortVal });
|
|
382
383
|
}
|
|
383
384
|
catch (e) {
|
|
384
385
|
if (e instanceof ModelScopeError)
|
|
385
386
|
fail(formatJson, e.code, e.message);
|
|
386
387
|
throw e;
|
|
387
388
|
}
|
|
388
|
-
describeWrite(
|
|
389
|
+
describeWrite('agent', sel, modelId, effort ?? null, formatJson);
|
|
389
390
|
}
|
|
390
391
|
async function cmdEffort(args, formatJson) {
|
|
391
392
|
if (wantsHelp(args)) {
|
|
@@ -410,14 +411,14 @@ async function cmdEffort(args, formatJson) {
|
|
|
410
411
|
fail(formatJson, 'INVALID_EFFORT', `当前模型目录未声明支持推理强度: ${val}`);
|
|
411
412
|
}
|
|
412
413
|
try {
|
|
413
|
-
|
|
414
|
+
writeAgentModelConfig(sel.self, ba, { effort: val });
|
|
414
415
|
}
|
|
415
416
|
catch (e) {
|
|
416
417
|
if (e instanceof ModelScopeError)
|
|
417
418
|
fail(formatJson, e.code, e.message);
|
|
418
419
|
throw e;
|
|
419
420
|
}
|
|
420
|
-
describeWrite(
|
|
421
|
+
describeWrite('agent', sel, null, level, formatJson);
|
|
421
422
|
}
|
|
422
423
|
async function cmdReset(args, formatJson) {
|
|
423
424
|
if (wantsHelp(args)) {
|
|
@@ -428,7 +429,7 @@ async function cmdReset(args, formatJson) {
|
|
|
428
429
|
const scope = determineWriteScope(sel, formatJson);
|
|
429
430
|
const ba = activeBaseagent(sel.self);
|
|
430
431
|
try {
|
|
431
|
-
|
|
432
|
+
clearAgentModelConfig(sel.self, ba);
|
|
432
433
|
}
|
|
433
434
|
catch (e) {
|
|
434
435
|
if (e instanceof ModelScopeError)
|
|
@@ -436,9 +437,9 @@ async function cmdReset(args, formatJson) {
|
|
|
436
437
|
throw e;
|
|
437
438
|
}
|
|
438
439
|
emit(formatJson, {
|
|
439
|
-
ok: true, scope, self: sel.self ?? null, peerKey: sel.peerKey ?? null,
|
|
440
|
+
ok: true, scope: 'agent', self: sel.self ?? null, peerKey: sel.peerKey ?? null,
|
|
440
441
|
}, () => {
|
|
441
|
-
return `✓ 已清除
|
|
442
|
+
return `✓ 已清除 Agent 级模型设置(该 Agent 所有会话下条消息生效,无模型可用直到重新设置)`;
|
|
442
443
|
});
|
|
443
444
|
}
|
|
444
445
|
async function cmdCheck(args, formatJson) {
|
|
@@ -452,7 +453,6 @@ async function cmdCheck(args, formatJson) {
|
|
|
452
453
|
const steps = [];
|
|
453
454
|
const result = await runModelCheck({
|
|
454
455
|
self: sel.self,
|
|
455
|
-
peerKey: sel.peerKey,
|
|
456
456
|
role,
|
|
457
457
|
baseagent: ba,
|
|
458
458
|
onStep: step => steps.push(step),
|