evolcore 0.0.41 → 0.0.42
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 +36 -0
- package/bin/codex-managed-hook.mjs +9 -5
- package/dist/agents/baseagent.js +156 -16
- package/dist/agents/claude-runner.js +10 -3
- package/dist/agents/codex/catalog.js +8 -4
- package/dist/agents/codex-runner.js +236 -59
- package/dist/agents/ecagent-runner.js +82 -13
- package/dist/aun/aid/agentmd.js +106 -27
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +65 -13
- package/dist/aun/aid/identity.js +70 -4
- package/dist/aun/aid/index.js +2 -2
- package/dist/aun/service-proxy.js +25 -1
- package/dist/channels/aun.js +242 -209
- package/dist/channels/dingtalk.js +1 -1
- package/dist/channels/feishu.js +1 -1
- package/dist/channels/qqbot.js +1 -1
- package/dist/channels/wechat.js +1 -1
- package/dist/channels/wecom.js +1 -1
- package/dist/cli/agent-command.js +183 -3
- package/dist/cli/agent-create.js +92 -86
- package/dist/cli/agent.js +136 -1
- package/dist/cli/aun-commands.js +137 -35
- package/dist/cli/bench.js +8 -2
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +235 -51
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/directory.js +170 -0
- package/dist/cli/index.js +40 -30
- package/dist/cli/init-channel.js +4 -4
- package/dist/cli/init.js +47 -32
- package/dist/cli/managed-command-guard.js +4 -1
- package/dist/cli/model.js +27 -18
- package/dist/cli/pa-workspace-command.js +191 -0
- package/dist/cli/{contact.js → peer.js} +19 -25
- package/dist/cli/restart-monitor.js +11 -4
- package/dist/cli/thread-command.js +47 -18
- package/dist/cli/version.js +18 -18
- package/dist/config/access-policy.js +29 -12
- package/dist/config/boot-log.js +65 -10
- package/dist/config/builtin-roles.js +2 -4
- package/dist/config/config-field-policy.js +3 -0
- package/dist/config/config-manager.js +28 -20
- package/dist/config/{contact-bind-code.js → peer-bind-code.js} +6 -6
- package/dist/config/{contact-book-store.js → peer-book-store.js} +75 -75
- package/dist/config/{contact-book-v2-startup.js → peer-book-v2-startup.js} +2 -2
- package/dist/config/{contact-book.js → peer-book.js} +47 -47
- package/dist/config/peer-operation-service.js +132 -0
- package/dist/config/{contact-request-service.js → peer-request-service.js} +90 -90
- package/dist/config/peer-role-resolver.js +3 -3
- package/dist/config/providers-config.js +17 -8
- package/dist/config/providers.js +1 -1
- package/dist/config/schema-migration.js +336 -39
- package/dist/core/agent-application-service.js +8 -2
- package/dist/core/agent-create-status.js +4 -5
- package/dist/core/agent-ipc-registration.js +5 -4
- package/dist/core/agent-runtime.js +30 -17
- package/dist/core/auth/operation-authorizer.js +0 -24
- package/dist/core/auth/operation-catalog.js +4 -20
- package/dist/core/baseagent-loader.js +27 -3
- package/dist/core/bootstrap-service.js +5 -22
- package/dist/core/capability/capability-manager.js +52 -35
- package/dist/core/channel-loader.js +43 -2
- package/dist/core/channel-runtime.js +2 -2
- package/dist/core/command/agent-control.js +54 -18
- package/dist/core/command/command-handler.js +92 -72
- package/dist/core/command/connect-menu.js +35 -42
- package/dist/core/command/daemon-diagnostics.js +41 -5
- package/dist/core/command/data-root-error.js +10 -0
- package/dist/core/command/data-root-resolver.js +53 -13
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +163 -65
- package/dist/core/command/menu-protocol.js +52 -0
- package/dist/core/command/pa-workspace-calendar.js +223 -0
- package/dist/core/command/pa-workspace-store.js +459 -0
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +57 -41
- package/dist/core/daemon-lifecycle.js +90 -31
- package/dist/core/evolagent.js +6 -10
- package/dist/core/handoff/runtime.js +11 -4
- package/dist/core/host-snapshot.js +208 -0
- package/dist/core/initialization/service.js +152 -20
- package/dist/core/ipc-registration.js +33 -4
- package/dist/core/memory/batch-meta.js +27 -0
- package/dist/core/memory/consolidation-ops-records.js +44 -1
- package/dist/core/memory/consolidation.js +169 -27
- package/dist/core/message/aun-ipc-sender.js +2 -8
- package/dist/core/message/im-renderer.js +56 -3
- package/dist/core/message/message-admission.js +121 -124
- package/dist/core/message/message-bridge.js +38 -54
- package/dist/core/message/message-queue.js +7 -0
- package/dist/core/message/outbound.js +34 -9
- package/dist/core/message/response-engine.js +154 -73
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/model/config-scope.js +2 -2
- package/dist/core/model/model-catalog.js +5 -4
- package/dist/core/model/model-diagnostics.js +6 -5
- package/dist/core/model/model-fallback.js +3 -6
- package/dist/core/model/model-permission.js +1 -1
- package/dist/core/ownership/owner-resolver.js +9 -9
- package/dist/core/permission/approval-gateway.js +1 -1
- package/dist/core/permission/ec-command-parser.js +2 -2
- package/dist/core/permission/tool-canonical.js +96 -46
- package/dist/core/permission/tool-error-code.js +41 -0
- package/dist/core/permission/tool-policy.js +71 -47
- package/dist/core/role/runtime-policy.js +1 -1
- package/dist/core/session/session-idle-monitor.js +10 -0
- package/dist/core/session/session-manager.js +2 -4
- package/dist/core/session/session-title.js +36 -8
- package/dist/core/system-session/memory.js +2 -7
- package/dist/core/thread/command-parser.js +6 -2
- package/dist/core/thread/ipc-operation.js +51 -36
- package/dist/core/thread/thread-operation.js +29 -61
- package/dist/core/thread/thread-service.js +57 -13
- package/dist/directory/canonical-digest.js +54 -0
- package/dist/directory/owner-directory-admission.js +114 -43
- package/dist/directory/owner-directory-agentmd-sync.js +89 -0
- package/dist/directory/owner-directory-cache.js +847 -459
- package/dist/directory/owner-directory-markdown.js +272 -0
- package/dist/directory/owner-directory-query-operation.js +195 -0
- package/dist/directory/owner-directory-remark-operation.js +147 -0
- package/dist/directory/owner-directory-remarks.js +145 -0
- package/dist/directory/owner-directory-scope.js +55 -0
- package/dist/directory/owner-directory-search.js +148 -0
- package/dist/directory/owner-directory-store.js +227 -0
- package/dist/eck/kit-renderer.js +1 -0
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/message-context-service.js +13 -9
- package/dist/index.js +195 -37
- package/dist/ipc.js +86 -22
- package/dist/paths.js +11 -8
- package/dist/product.js +2 -0
- package/dist/proxy/manager.js +13 -2
- package/dist/proxy/service-supervisor.js +8 -1
- package/dist/trigger/history.js +23 -0
- package/dist/trigger/scheduler.js +3 -0
- package/dist/utils/atomic-write.js +21 -0
- package/dist/utils/cross-platform.js +35 -0
- package/dist/utils/ecweb-supervisor.js +42 -0
- package/dist/utils/error-utils.js +2 -1
- package/dist/utils/evolcore-version.js +19 -0
- package/dist/utils/host-info.js +242 -5
- package/dist/utils/instance-registry.js +28 -6
- package/dist/utils/logger.js +59 -14
- package/dist/utils/machine-info.js +46 -0
- package/dist/utils/process-introspect.js +166 -2
- package/dist/utils/startup-trace.js +245 -0
- package/ecagent/dist/agent-loop.js +27 -13
- package/ecagent/dist/harness/agent-harness.js +3 -3
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/ecagent/dist/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +72 -0
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent-create.md +17 -27
- package/kits/docs/evolcore/agent.md +4 -1
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +16 -5
- package/kits/docs/evolcore/ctl.md +9 -0
- package/kits/docs/evolcore/ec-capabilities.md +19 -0
- package/kits/docs/evolcore/memory-consolidation-batches.md +79 -5
- package/kits/docs/evolcore/menu-exec-schema-commands.md +2 -1
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +13 -4
- package/kits/docs/evolcore/msg.md +1 -1
- package/kits/docs/evolcore/pa-workspace.md +51 -0
- package/kits/docs/evolcore/peer.md +73 -0
- package/kits/docs/evolcore/thread-chain.md +4 -1
- package/kits/eck_manifest.json +21 -0
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/agent-config.schema.16.json +6 -0
- package/kits/schemas/agent-config.schema.17.json +897 -0
- package/kits/schemas/daemon.schema.9.json +8 -1
- package/kits/skills/ec-agent-create/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +45 -27
- package/kits/skills/ec-service-proxy/SKILL.md +7 -2
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +4 -5
- package/kits/skills/thread-ops/SKILL.md +11 -11
- package/kits/templates/bootstrap-welcome.md +3 -15
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/bootstrap.md +24 -23
- package/kits/templates/system-fragments/commands.md +12 -5
- package/kits/templates/system-fragments/thread.md +18 -3
- package/package.json +6 -4
- package/dist/config/contact-operation-service.js +0 -235
- package/dist/directory/owner-directory-authorization.js +0 -309
- package/kits/docs/evolcore/contact.md +0 -78
- /package/dist/config/{contact-alias.js → peer-alias.js} +0 -0
package/dist/cli/agent.js
CHANGED
|
@@ -4,7 +4,8 @@ import path from 'path';
|
|
|
4
4
|
import { SESSION_ID_ENV } from '../product.js';
|
|
5
5
|
import { resolvePaths, agentMdPath as getAgentMdPathFromPaths, agentPersonalDir, agentWelcomePath, aunPath as defaultAunPath } from '../paths.js';
|
|
6
6
|
import { loadDefaults, loadAllAgents, loadAgent, saveAgent, ensureAgentDirSkeleton } from '../config-store.js';
|
|
7
|
-
import { assertAgentAidAvailable, assertAgentModelConfigured, initConfigManager } from '../config/config-manager.js';
|
|
7
|
+
import { assertAgentAidAvailable, assertAgentModelConfigured, resolveEffective, initConfigManager } from '../config/config-manager.js';
|
|
8
|
+
import { resolveRuntimeBaseagentModelSelection } from '../agents/baseagent.js';
|
|
8
9
|
import { resolveConfigCommand } from '../config/resolved-config-op.js';
|
|
9
10
|
import { executeResolvedConfigCommandAsync } from '../config/config-operation-service.js';
|
|
10
11
|
import { ipcQuery, IpcTransportError } from '../ipc.js';
|
|
@@ -386,6 +387,10 @@ async function agentSetEnabled(aid, enabled, options = {}) {
|
|
|
386
387
|
}
|
|
387
388
|
if (enabled) {
|
|
388
389
|
try {
|
|
390
|
+
const effective = resolveEffective({ self: aid }, { cache: false });
|
|
391
|
+
const backend = effective.active_baseagent;
|
|
392
|
+
if (backend)
|
|
393
|
+
await resolveRuntimeBaseagentModelSelection(backend, effective.baseagents?.[backend]);
|
|
389
394
|
assertAgentModelConfigured(aid);
|
|
390
395
|
}
|
|
391
396
|
catch (error) {
|
|
@@ -826,3 +831,133 @@ export async function agentReady(aid, commandArgs) {
|
|
|
826
831
|
}
|
|
827
832
|
return { ...result, ok: true, aid, reloaded: result.reloaded === true };
|
|
828
833
|
}
|
|
834
|
+
/**
|
|
835
|
+
* 探测上限。正常一次 resolve 是 10~110ms(网关发现 + 健康检查,之后走缓存),
|
|
836
|
+
* 3s 对这台命令而言是在等一个几乎必然失败的结论:SDK 自己的 gateway discovery
|
|
837
|
+
* 带 3 次重试,实测不可达域名要 23~44s,所以这里必须自己截断。
|
|
838
|
+
*/
|
|
839
|
+
const AID_REGISTRATION_PROBE_TIMEOUT_MS = 1500;
|
|
840
|
+
async function probeAidRegistration(aid) {
|
|
841
|
+
const startedAt = performance.now();
|
|
842
|
+
const elapsed = () => Math.round(performance.now() - startedAt);
|
|
843
|
+
// 格式都不合法的 AID 不可能在 PKI 注册过,也不必惊动网络。
|
|
844
|
+
if (!isValidAid(aid)) {
|
|
845
|
+
return { status: 'absent', elapsedMs: elapsed() };
|
|
846
|
+
}
|
|
847
|
+
let timer;
|
|
848
|
+
const timeout = new Promise(resolve => {
|
|
849
|
+
timer = setTimeout(() => resolve({ status: 'unknown', elapsedMs: elapsed(), reason: `PKI 查询超时(>${AID_REGISTRATION_PROBE_TIMEOUT_MS}ms)` }), AID_REGISTRATION_PROBE_TIMEOUT_MS);
|
|
850
|
+
timer.unref?.();
|
|
851
|
+
});
|
|
852
|
+
const query = (async () => {
|
|
853
|
+
const { getAidStore, SLOT } = await import('../aun/aid/store.js');
|
|
854
|
+
const store = await getAidStore({ slotId: SLOT.cli });
|
|
855
|
+
try {
|
|
856
|
+
const r = await store.resolve(aid, { skipAgentMd: true });
|
|
857
|
+
if (r.ok)
|
|
858
|
+
return { status: 'registered', elapsedMs: elapsed() };
|
|
859
|
+
const code = String(r.error?.code ?? '');
|
|
860
|
+
if (code === 'CERT_NOT_FOUND')
|
|
861
|
+
return { status: 'absent', elapsedMs: elapsed() };
|
|
862
|
+
return {
|
|
863
|
+
status: 'unknown',
|
|
864
|
+
elapsedMs: elapsed(),
|
|
865
|
+
reason: `PKI 查询失败:${code || 'NETWORK_ERROR'} ${String(r.error?.message ?? '').slice(0, 120)}`.trim(),
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
finally {
|
|
869
|
+
try {
|
|
870
|
+
store.close();
|
|
871
|
+
}
|
|
872
|
+
catch { /* ignore */ }
|
|
873
|
+
}
|
|
874
|
+
})().catch((e) => ({
|
|
875
|
+
status: 'unknown',
|
|
876
|
+
elapsedMs: elapsed(),
|
|
877
|
+
reason: `PKI 查询异常:${e instanceof Error ? e.message : String(e)}`.slice(0, 160),
|
|
878
|
+
}));
|
|
879
|
+
try {
|
|
880
|
+
return await Promise.race([query, timeout]);
|
|
881
|
+
}
|
|
882
|
+
finally {
|
|
883
|
+
if (timer)
|
|
884
|
+
clearTimeout(timer);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* 两个门禁并行:
|
|
889
|
+
* - 网络门禁:AID 在 PKI 上注册过(`absent` 直接失败,`unknown` 不阻断)
|
|
890
|
+
* - 本地门禁:本机托管了该 agent(走快照 + EvolAgentRegistry,原逻辑不变)
|
|
891
|
+
*
|
|
892
|
+
* 主机信息由 daemon 提供:CLI 只发一次 IPC 读快照,不在本机重复探测。
|
|
893
|
+
* 托管会话下先过 status.auth(与 ec status 同一道授权),再读快照。
|
|
894
|
+
* 网络探测从第一行就开始跑,与授权/快照 IPC 重叠;判定为 `absent` 时
|
|
895
|
+
* 在读到快照之前就退出,不白拼一份主机信息。
|
|
896
|
+
*/
|
|
897
|
+
export async function agentHost(aid, args = []) {
|
|
898
|
+
const p = resolvePaths();
|
|
899
|
+
const sessionId = process.env[SESSION_ID_ENV];
|
|
900
|
+
const registrationPromise = probeAidRegistration(aid);
|
|
901
|
+
const notFound = (registration) => ({
|
|
902
|
+
ok: false,
|
|
903
|
+
code: 'AGENT_NOT_FOUND',
|
|
904
|
+
error: `Agent ${aid} not found`,
|
|
905
|
+
registration,
|
|
906
|
+
});
|
|
907
|
+
if (sessionId) {
|
|
908
|
+
// 授权与网络探测并行,谁先到都行。
|
|
909
|
+
const [auth] = await Promise.all([
|
|
910
|
+
queryDaemon(p.socket, {
|
|
911
|
+
type: 'status.auth',
|
|
912
|
+
sessionId,
|
|
913
|
+
delegationToken: readDelegationCredential(),
|
|
914
|
+
argv: ['agent', 'host', ...args, aid],
|
|
915
|
+
}, 10_000),
|
|
916
|
+
registrationPromise,
|
|
917
|
+
]);
|
|
918
|
+
const { response, transportError } = auth;
|
|
919
|
+
if (!response) {
|
|
920
|
+
return { ok: false, code: 'DAEMON_UNAVAILABLE', error: daemonUnavailableMessage(transportError, 'Unable to connect to the evolcore daemon') };
|
|
921
|
+
}
|
|
922
|
+
if (!response.ok) {
|
|
923
|
+
return { ok: false, code: response.code ?? 'NOT_ALLOWED', error: response.error || 'host 权限校验失败' };
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
const [snapshotQuery, registration] = await Promise.all([
|
|
927
|
+
queryDaemon(p.socket, { type: 'host.snapshot' }, 5000),
|
|
928
|
+
registrationPromise,
|
|
929
|
+
]);
|
|
930
|
+
// 网络门禁:网关已明确说不存在,后面的本地与快照工作全是白做。
|
|
931
|
+
if (registration.status === 'absent')
|
|
932
|
+
return notFound(registration);
|
|
933
|
+
const { response, transportError } = snapshotQuery;
|
|
934
|
+
if (!response?.ok || !response.snapshot) {
|
|
935
|
+
return {
|
|
936
|
+
ok: false,
|
|
937
|
+
code: 'DAEMON_UNAVAILABLE',
|
|
938
|
+
error: daemonUnavailableMessage(transportError, 'Unable to read host snapshot from the evolcore daemon'),
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
const snapshot = response.snapshot;
|
|
942
|
+
const known = Array.isArray(snapshot.agents) && snapshot.agents.some((agent) => agent.aid === aid);
|
|
943
|
+
if (!known) {
|
|
944
|
+
const { EvolAgentRegistry } = await import('../core/evolagent-registry.js');
|
|
945
|
+
const registry = new EvolAgentRegistry(p.agentsDir);
|
|
946
|
+
registry.loadAll();
|
|
947
|
+
if (!registry.get(aid))
|
|
948
|
+
return notFound(registration);
|
|
949
|
+
}
|
|
950
|
+
return {
|
|
951
|
+
ok: true,
|
|
952
|
+
aid,
|
|
953
|
+
sampledAt: snapshot.sampledAt,
|
|
954
|
+
daemon: snapshot.daemon,
|
|
955
|
+
queue: snapshot.queue,
|
|
956
|
+
agents: snapshot.agents,
|
|
957
|
+
host: snapshot.host,
|
|
958
|
+
versions: snapshot.versions,
|
|
959
|
+
runtime: snapshot.runtime,
|
|
960
|
+
probe: snapshot.probe,
|
|
961
|
+
registration,
|
|
962
|
+
};
|
|
963
|
+
}
|
package/dist/cli/aun-commands.js
CHANGED
|
@@ -485,7 +485,7 @@ Options:
|
|
|
485
485
|
示例:
|
|
486
486
|
ec aid list
|
|
487
487
|
ec aid show toleiliang2.agentid.pub
|
|
488
|
-
ec aid new reviewer.agentid.pub
|
|
488
|
+
ec aid new reviewer.agentid.pub --owner owner.agentid.pub
|
|
489
489
|
ec aid delete --help
|
|
490
490
|
ec aid delete old.agentid.pub
|
|
491
491
|
ec aid delete --orphan
|
|
@@ -506,7 +506,7 @@ Options:
|
|
|
506
506
|
await runManagedAid(args, formatJson);
|
|
507
507
|
return;
|
|
508
508
|
}
|
|
509
|
-
const { aidList, aidListVerified, aidCreate, aidShow, aidDelete, aidLookup, agentmdPut, agentmdGet, agentmdSet, buildInitialAgentMd, isValidAid } = await import('../aun/aid/index.js');
|
|
509
|
+
const { aidList, aidListVerified, aidCreate, aidShow, aidDelete, aidLookup, agentmdPut, agentmdPutInitializationProfile, agentmdGet, agentmdSet, buildInitialAgentMd, isValidAid, validateAgentType } = await import('../aun/aid/index.js');
|
|
510
510
|
if (sub === 'list') {
|
|
511
511
|
if (wantsHelp(args)) {
|
|
512
512
|
console.log(`用法: ec aid list [筛选选项] [--no-verify] [--format json]
|
|
@@ -603,26 +603,41 @@ Options:
|
|
|
603
603
|
}
|
|
604
604
|
if (sub === 'new') {
|
|
605
605
|
if (wantsHelp(args)) {
|
|
606
|
-
console.log(`用法: ec aid new <完整AID> [--force] [--format json]
|
|
606
|
+
console.log(`用法: ec aid new <完整AID> [--owner <ownerAid>] [--type <type>] [--force] [--format json]
|
|
607
607
|
|
|
608
608
|
创建新 AID 身份:生成 ECDSA 密钥对、向 Issuer 申请证书、构建并上传初始 agent.md。
|
|
609
609
|
|
|
610
610
|
选项:
|
|
611
|
-
--
|
|
611
|
+
--owner <aid> 主体 Owner;非 human、非 group/org 类型必填
|
|
612
|
+
(名片里会写入 owner 与 ownership.statement)
|
|
613
|
+
--type <type> 主体类型,默认 service
|
|
614
|
+
(human/agent/group/service/device/org/host/custom)
|
|
615
|
+
--force 强制重新注册,覆盖已存在的身份(即使签名验证失败)
|
|
612
616
|
--format json 输出 JSON
|
|
613
617
|
--aun-path <path> 指定 AUN keystore 根
|
|
614
618
|
|
|
615
|
-
例: ec aid new reviewer.agentid.pub
|
|
619
|
+
例: ec aid new reviewer.agentid.pub --owner owner.agentid.pub
|
|
620
|
+
ec aid new reviewer.agentid.pub --owner owner.agentid.pub --type service
|
|
616
621
|
ec aid new reviewer.agentid.pub --force`);
|
|
617
622
|
return;
|
|
618
623
|
}
|
|
619
624
|
const aid = args[1];
|
|
620
625
|
const force = args.includes('--force');
|
|
626
|
+
const optionValue = (name) => {
|
|
627
|
+
const index = args.indexOf(name);
|
|
628
|
+
if (index < 0)
|
|
629
|
+
return undefined;
|
|
630
|
+
const value = args[index + 1];
|
|
631
|
+
return value && !value.startsWith('--') ? value : '';
|
|
632
|
+
};
|
|
633
|
+
const ownerOption = optionValue('--owner');
|
|
634
|
+
const typeOption = optionValue('--type');
|
|
635
|
+
const owner = ownerOption?.trim().toLowerCase();
|
|
621
636
|
if (!aid) {
|
|
622
637
|
if (formatJson)
|
|
623
638
|
console.log(JSON.stringify({ ok: false, code: 'MISSING_AID', error: 'missing AID' }));
|
|
624
639
|
else
|
|
625
|
-
console.error('用法: ec aid new <完整AID> [--force]\n例: ec aid new reviewer.agentid.pub');
|
|
640
|
+
console.error('用法: ec aid new <完整AID> [--owner <ownerAid>] [--type <type>] [--force]\n例: ec aid new reviewer.agentid.pub --owner owner.agentid.pub');
|
|
626
641
|
process.exit(1);
|
|
627
642
|
}
|
|
628
643
|
if (!isValidAid(aid)) {
|
|
@@ -632,32 +647,80 @@ Options:
|
|
|
632
647
|
console.error(`❌ 无效 AID 格式: ${aid}`);
|
|
633
648
|
process.exit(1);
|
|
634
649
|
}
|
|
650
|
+
const agentType = (typeOption?.trim() || 'service');
|
|
651
|
+
const typeError = validateAgentType(agentType);
|
|
652
|
+
if (typeError) {
|
|
653
|
+
if (formatJson)
|
|
654
|
+
console.log(JSON.stringify({ ok: false, code: 'INVALID_TYPE', error: `invalid --type: ${typeError}` }));
|
|
655
|
+
else
|
|
656
|
+
console.error(`❌ 无效类型: ${typeError}`);
|
|
657
|
+
process.exit(1);
|
|
658
|
+
}
|
|
659
|
+
const ownerAid = ownerOption?.trim();
|
|
660
|
+
if (ownerOption === '') {
|
|
661
|
+
const error = '--owner requires an AID value';
|
|
662
|
+
if (formatJson)
|
|
663
|
+
console.log(JSON.stringify({ ok: false, code: 'INVALID_OWNER', error }));
|
|
664
|
+
else
|
|
665
|
+
console.error(`❌ ${error}`);
|
|
666
|
+
process.exit(1);
|
|
667
|
+
}
|
|
668
|
+
if (ownerAid && !isValidAid(ownerAid)) {
|
|
669
|
+
if (formatJson)
|
|
670
|
+
console.log(JSON.stringify({ ok: false, code: 'INVALID_OWNER', error: `invalid owner AID: ${ownerAid}` }));
|
|
671
|
+
else
|
|
672
|
+
console.error(`❌ 无效 Owner AID: ${ownerAid}`);
|
|
673
|
+
process.exit(1);
|
|
674
|
+
}
|
|
675
|
+
const requiresOwner = agentType !== 'human' && agentType !== 'group' && agentType !== 'org';
|
|
676
|
+
if (agentType === 'group' || agentType === 'org') {
|
|
677
|
+
const error = `${agentType} AIDs require their dedicated creation flow`;
|
|
678
|
+
if (formatJson)
|
|
679
|
+
console.log(JSON.stringify({ ok: false, code: 'DEDICATED_CREATION_REQUIRED', error }));
|
|
680
|
+
else
|
|
681
|
+
console.error(`❌ ${error}`);
|
|
682
|
+
process.exit(1);
|
|
683
|
+
}
|
|
684
|
+
if (requiresOwner && !ownerAid) {
|
|
685
|
+
const error = `--owner is required when creating a ${agentType} AID (the gateway rejects non-human agent.md without an ownership declaration)`;
|
|
686
|
+
if (formatJson)
|
|
687
|
+
console.log(JSON.stringify({ ok: false, code: 'MISSING_OWNER', error }));
|
|
688
|
+
else
|
|
689
|
+
console.error(`❌ ${error}`);
|
|
690
|
+
process.exit(1);
|
|
691
|
+
}
|
|
635
692
|
try {
|
|
636
|
-
|
|
637
|
-
|
|
693
|
+
if (requiresOwner && (!owner || !isValidAid(owner))) {
|
|
694
|
+
failManagedAid(formatJson, 'OWNER_REQUIRED', `${agentType} AID 创建必须提供有效 --owner <AID>`);
|
|
695
|
+
}
|
|
696
|
+
const result = await aidCreate(aid, { aunPath, force, type: agentType, ...(owner ? { owner } : {}) });
|
|
697
|
+
let agentmdUploaded = false;
|
|
638
698
|
let agentmdError;
|
|
639
|
-
|
|
640
|
-
const content = buildInitialAgentMd({ aid, type:
|
|
699
|
+
try {
|
|
700
|
+
const content = buildInitialAgentMd({ aid, type: agentType, owner });
|
|
701
|
+
if (owner)
|
|
702
|
+
await agentmdPutInitializationProfile(content, { aid, ownerAid: owner, aunPath, store: result.store });
|
|
703
|
+
else
|
|
704
|
+
await agentmdPut(content, { aid, aunPath, store: result.store });
|
|
705
|
+
agentmdUploaded = true;
|
|
706
|
+
if (!formatJson)
|
|
707
|
+
console.log('✓ agent.md 已发布');
|
|
708
|
+
}
|
|
709
|
+
catch (e) {
|
|
710
|
+
agentmdError = String(e?.message || e).slice(0, 100);
|
|
711
|
+
if (!formatJson)
|
|
712
|
+
console.warn(`⚠ agent.md 发布失败(首次连接将自动重试): ${agentmdError}`);
|
|
713
|
+
}
|
|
714
|
+
finally {
|
|
641
715
|
try {
|
|
642
|
-
await
|
|
643
|
-
agentmdUploaded = true;
|
|
644
|
-
if (!formatJson)
|
|
645
|
-
console.log('✓ agent.md 已发布');
|
|
716
|
+
await result.client.close();
|
|
646
717
|
}
|
|
647
|
-
catch
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
console.warn(`⚠ agent.md 发布失败(首次连接将自动重试): ${agentmdError}`);
|
|
718
|
+
catch { }
|
|
719
|
+
try {
|
|
720
|
+
result.store?.close();
|
|
651
721
|
}
|
|
722
|
+
catch { }
|
|
652
723
|
}
|
|
653
|
-
try {
|
|
654
|
-
await result.client.close();
|
|
655
|
-
}
|
|
656
|
-
catch { }
|
|
657
|
-
try {
|
|
658
|
-
result.store?.close();
|
|
659
|
-
}
|
|
660
|
-
catch { }
|
|
661
724
|
const verb = result.alreadyExisted ? '已存在且有效' : (force ? '已重新创建' : '已创建');
|
|
662
725
|
if (formatJson) {
|
|
663
726
|
console.log(JSON.stringify({
|
|
@@ -2036,10 +2099,17 @@ Options:
|
|
|
2036
2099
|
const payloadVal = getArgValue(args, '--payload');
|
|
2037
2100
|
const payloadFileVal = getArgValue(args, '--payload-file');
|
|
2038
2101
|
let body;
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2102
|
+
const modes = [
|
|
2103
|
+
...(fileVal !== undefined ? ['--file'] : []),
|
|
2104
|
+
...(textFromFileVal !== undefined ? ['--text-from-file'] : []),
|
|
2105
|
+
...(linkVal !== undefined ? ['--link'] : []),
|
|
2106
|
+
...(payloadVal !== undefined ? ['--payload'] : []),
|
|
2107
|
+
...(payloadFileVal !== undefined ? ['--payload-file'] : []),
|
|
2108
|
+
];
|
|
2109
|
+
const bodyPositionals = collectPositional(args, 3);
|
|
2110
|
+
const bodyModeError = sendBodyModeConflict('msg', modes, bodyPositionals.length > 0);
|
|
2111
|
+
if (bodyModeError) {
|
|
2112
|
+
console.error(`❌ ${bodyModeError}`);
|
|
2043
2113
|
process.exit(1);
|
|
2044
2114
|
}
|
|
2045
2115
|
if (fileVal) {
|
|
@@ -2104,7 +2174,7 @@ Options:
|
|
|
2104
2174
|
body = { mode: 'payload', payload: parsed };
|
|
2105
2175
|
}
|
|
2106
2176
|
else {
|
|
2107
|
-
const text =
|
|
2177
|
+
const text = bodyPositionals.join(' ');
|
|
2108
2178
|
if (!text) {
|
|
2109
2179
|
console.error('❌ 缺少消息内容(文本或 --file/--text-from-file/--link/--payload/--payload-file)');
|
|
2110
2180
|
process.exit(1);
|
|
@@ -3474,7 +3544,37 @@ async function runManagedSend(argv, formatJson) {
|
|
|
3474
3544
|
process.stderr.write(`⚠ 复查 Trigger 未创建: ${result.trigger_error}(消息已发出,需要复查请手动 ec trigger create)\n`);
|
|
3475
3545
|
}
|
|
3476
3546
|
}
|
|
3477
|
-
|
|
3547
|
+
const SEND_BODY_MODE_USAGE = {
|
|
3548
|
+
msg: {
|
|
3549
|
+
'--file': "ec msg send <from> <to> --file <path> [--as <type>] [--text '<说明>']",
|
|
3550
|
+
'--text-from-file': 'ec msg send <from> <to> --text-from-file <path>',
|
|
3551
|
+
'--link': "ec msg send <from> <to> --link <url> [--title '<title>'] [--description '<desc>']",
|
|
3552
|
+
'--payload': "ec msg send <from> <to> --payload '<json>'",
|
|
3553
|
+
'--payload-file': 'ec msg send <from> <to> --payload-file <path>',
|
|
3554
|
+
},
|
|
3555
|
+
group: {
|
|
3556
|
+
'--file': "ec group send <from> <group-id> --file <path> [--as <type>] [--text '<说明>']",
|
|
3557
|
+
'--payload': "ec group send <from> <group-id> --payload '<json>'",
|
|
3558
|
+
},
|
|
3559
|
+
};
|
|
3560
|
+
function sendBodyModeConflict(scope, modes, hasPositionText) {
|
|
3561
|
+
if (modes.length > 1) {
|
|
3562
|
+
const uniqueModes = [...new Set(modes)];
|
|
3563
|
+
const examples = uniqueModes
|
|
3564
|
+
.map(mode => SEND_BODY_MODE_USAGE[scope][mode])
|
|
3565
|
+
.filter((usage) => usage !== undefined);
|
|
3566
|
+
return `正文模式 ${uniqueModes.join('、')} 互斥,请保留一种${examples.length ? `。例如:${examples.join(';')}` : ''}`;
|
|
3567
|
+
}
|
|
3568
|
+
if (modes.length === 1 && hasPositionText) {
|
|
3569
|
+
const mode = modes[0];
|
|
3570
|
+
const usage = SEND_BODY_MODE_USAGE[scope][mode];
|
|
3571
|
+
const detail = mode === '--file'
|
|
3572
|
+
? '位置文本不能与 --file 同时使用;如需附件说明,请使用 --text。'
|
|
3573
|
+
: `位置文本不能与 ${mode} 同时使用;如需发送文本,请移除 ${mode}。`;
|
|
3574
|
+
return `${detail}${usage ? `示例:${usage}` : ''}`;
|
|
3575
|
+
}
|
|
3576
|
+
return undefined;
|
|
3577
|
+
}
|
|
3478
3578
|
export function resolveManagedSendArgv(argv, routing) {
|
|
3479
3579
|
if (!['msg', 'group'].includes(argv[0]) || argv[1] !== 'send')
|
|
3480
3580
|
throw new Error('Invalid managed send command');
|
|
@@ -3585,9 +3685,11 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3585
3685
|
throw new Error('Mentions require a group send');
|
|
3586
3686
|
if (scope === 'group' && (values.has('--link') || values.has('--text-from-file') || values.has('--payload-file')))
|
|
3587
3687
|
throw new Error('Unsupported group send body');
|
|
3588
|
-
const modes = ['--file', '--payload', '--payload-file', '--text-from-file', '--link']
|
|
3589
|
-
|
|
3590
|
-
|
|
3688
|
+
const modes = ['--file', '--payload', '--payload-file', '--text-from-file', '--link']
|
|
3689
|
+
.filter((flag) => values.has(flag));
|
|
3690
|
+
const bodyModeError = sendBodyModeConflict(scope, modes, text.length > 0);
|
|
3691
|
+
if (bodyModeError)
|
|
3692
|
+
throw new Error(bodyModeError);
|
|
3591
3693
|
let payload;
|
|
3592
3694
|
let file;
|
|
3593
3695
|
const payloadFile = values.get('--payload-file');
|
package/dist/cli/bench.js
CHANGED
|
@@ -486,12 +486,18 @@ Options:
|
|
|
486
486
|
const need = numAids - usableAids.length;
|
|
487
487
|
if (!formatJson)
|
|
488
488
|
console.log(warn(`仅 ${usableAids.length} 个可用,需创建 ${need} 个新 AID`));
|
|
489
|
-
const
|
|
489
|
+
const daemonConfig = loadDaemonConfig();
|
|
490
|
+
const aidDomain = resolveControlAidDomain(daemonConfig.aun?.defaultAidDomain);
|
|
491
|
+
const owner = daemonConfig.owner?.trim();
|
|
492
|
+
if (!owner) {
|
|
493
|
+
console.error(`${RED} ✗ 创建 benchmark AID 需要 daemon owner;请先运行 ec init --owner${RST}`);
|
|
494
|
+
process.exit(1);
|
|
495
|
+
}
|
|
490
496
|
for (let i = 0; i < need; i++) {
|
|
491
497
|
const hex = crypto.randomBytes(4).toString('hex');
|
|
492
498
|
const newAid = `bench-${hex}.${aidDomain}`;
|
|
493
499
|
try {
|
|
494
|
-
await aidCreate(newAid, { aunPath, type: 'service' });
|
|
500
|
+
await aidCreate(newAid, { aunPath, type: 'service', owner });
|
|
495
501
|
aids.push(newAid);
|
|
496
502
|
if (!formatJson)
|
|
497
503
|
console.log(ok(`创建 ${newAid}`));
|
package/dist/cli/command-log.js
CHANGED
|
@@ -92,7 +92,7 @@ function loggableArgs(args) {
|
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
94
|
const flag = arg.replace(/^--?/, '').replace(/=.*$/, '').toLowerCase();
|
|
95
|
-
if (/^(?:remote-token|ecweb-token|menu-token|token|password|secret)$/.test(flag)) {
|
|
95
|
+
if (/^(?:remote-token|ecweb-token|menu-token|token|password|secret|workspace)$/.test(flag)) {
|
|
96
96
|
output.push(arg.includes('=') ? `${arg.slice(0, arg.indexOf('=') + 1)}[REDACTED]` : arg);
|
|
97
97
|
redactNext = !arg.includes('=');
|
|
98
98
|
continue;
|