evolcore 0.0.45 → 0.0.46
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 +75 -0
- package/bin/ecmsg.js +33 -23
- package/dist/ability/application-service.js +1 -2
- package/dist/ability/package.js +28 -0
- package/dist/agent-template/jobs.js +158 -36
- package/dist/agent-template/runtime.js +401 -34
- package/dist/agent-template/service.js +764 -369
- package/dist/agent-template/tool-runner.js +35 -17
- package/dist/agent-template/types.js +7 -4
- package/dist/agents/baseagent.js +10 -9
- package/dist/agents/claude-runner.js +13 -5
- package/dist/agents/codex/app-server-client.js +2 -4
- package/dist/agents/codex/diagnostics.js +18 -1
- package/dist/agents/codex-runner.js +3 -1
- package/dist/agents/ecagent-runner.js +3 -1
- package/dist/agents/gemini-runner.js +2 -1
- package/dist/aun/menu/client.js +142 -182
- package/dist/aun/rpc/client.js +33 -17
- package/dist/aun/service-proxy.js +6 -23
- package/dist/channels/aun.js +656 -112
- package/dist/cli/agent-create.js +37 -10
- package/dist/cli/agent-template.js +105 -84
- package/dist/cli/agent.js +31 -18
- package/dist/cli/daemon-commands.js +15 -17
- package/dist/cli/daemon-lifecycle-client.js +40 -18
- package/dist/cli/directory.js +12 -4
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/events-command.js +2 -1
- package/dist/cli/init.js +50 -20
- package/dist/cli/integrity-command.js +2 -0
- package/dist/cli/managed-command-guard.js +20 -1
- package/dist/cli/menu-client.js +7 -5
- package/dist/cli/restart-monitor.js +33 -20
- package/dist/cli/services-command.js +28 -5
- package/dist/config/config-field-policy.js +24 -0
- package/dist/config/config-manager.js +20 -2
- package/dist/config/peer-book-store.js +152 -120
- package/dist/config/peer-role-resolver.js +24 -4
- package/dist/config/provider-identity-migration.js +1 -1
- package/dist/config/provider-identity.js +10 -4
- package/dist/config/provider-ipc-service.js +10 -2
- package/dist/config/provider-local-sync.js +2 -2
- package/dist/config/providers-config.js +95 -10
- package/dist/config/providers-import.js +4 -6
- package/dist/config/providers.js +14 -3
- package/dist/config/role-store.js +1 -1
- package/dist/config-store.js +9 -1
- package/dist/core/agent-application-service.js +56 -29
- package/dist/core/agent-create-status.js +3 -1
- package/dist/core/agent-creation-claim.js +1 -0
- package/dist/core/agent-ipc-registration.js +2 -2
- package/dist/core/agent-reload-coordinator.js +38 -1
- package/dist/core/agent-runtime.js +85 -38
- package/dist/core/auth/agent-delegation.js +5 -0
- package/dist/core/auth/operation-authorizer.js +1 -1
- package/dist/core/auth/operation-catalog.js +3 -3
- package/dist/core/bootstrap-service.js +3 -0
- package/dist/core/capability/capability-manager.js +3 -1
- package/dist/core/channel-loader.js +29 -3
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-control.js +6 -5
- package/dist/core/command/agent-template-menu.js +32 -97
- package/dist/core/command/eventcenter-menu.js +61 -13
- package/dist/core/command/menu-catalog.js +11 -4
- package/dist/core/command/menu-handler.js +35 -8
- package/dist/core/command/menu-protocol.js +8 -16
- package/dist/core/command/skill-slash.js +6 -2
- package/dist/core/command/team-workspace-bootstrap.js +1 -2
- package/dist/core/command/team-workspace-management-store.js +83 -0
- package/dist/core/command/team-workspace-management.js +1 -2
- package/dist/core/command/team-workspace-team.js +26 -3
- package/dist/core/daemon-control.js +3 -4
- package/dist/core/daemon-lifecycle.js +146 -110
- package/dist/core/evolagent-registry.js +42 -0
- package/dist/core/evolagent.js +2 -1
- package/dist/core/file-integrity/read.js +9 -16
- package/dist/core/file-integrity/store.js +94 -34
- package/dist/core/handoff/dispatcher.js +33 -7
- package/dist/core/handoff/runtime.js +8 -0
- package/dist/core/inference/text-inference.js +12 -2
- package/dist/core/invoke/invoke-service.js +24 -3
- package/dist/core/ipc-registration.js +3 -0
- package/dist/core/message/aun-ipc-sender.js +109 -7
- package/dist/core/message/contact-admission.js +6 -2
- package/dist/core/message/message-bridge.js +13 -0
- package/dist/core/message/message-queue.js +131 -30
- package/dist/core/message/pending-hints.js +8 -0
- package/dist/core/message/response-engine.js +48 -2
- package/dist/core/message/send-routing.js +3 -12
- package/dist/core/model/catalog-service.js +13 -0
- package/dist/core/model/model-catalog.js +57 -18
- package/dist/core/pack-auth.js +163 -31
- package/dist/core/pack-install.js +42 -1
- package/dist/{services/ledger.js → core/pack-ledger.js} +17 -6
- package/dist/core/permission/ec-command-parser.js +3 -1
- package/dist/core/permission/shell-environment.js +23 -0
- package/dist/core/rate-window.js +6 -1
- package/dist/core/session/session-idle-monitor.js +0 -1
- package/dist/core/session/session-manager.js +14 -0
- package/dist/core/session/session-title.js +26 -6
- package/dist/core/skill/index-generator.js +3 -4
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/core/thread/topic-id.js +8 -0
- package/dist/directory/owner-directory-admission.js +17 -0
- package/dist/directory/owner-directory-cache.js +3 -1
- package/dist/directory/owner-directory-markdown.js +145 -23
- package/dist/directory/owner-directory-policy.js +23 -0
- package/dist/directory/owner-directory-query-operation.js +20 -6
- package/dist/directory/owner-directory-search.js +47 -0
- package/dist/eck/message-renderer.js +171 -32
- package/dist/ecweb/basic-settings-service.js +7 -3
- package/dist/ecweb/providers-service.js +17 -10
- package/dist/ecweb/runtime/lifecycle.js +1 -1
- package/dist/ecweb/runtime/supervisor.js +77 -35
- package/dist/event-center/admission-materializer.js +1 -1
- package/dist/event-center/bus-gate.js +48 -4
- package/dist/event-center/bus-host.js +3 -3
- package/dist/event-center/center-config.js +57 -28
- package/dist/event-center/dispatcher.js +8 -0
- package/dist/event-center/event-log.js +69 -27
- package/dist/event-center/index-generator.js +6 -1
- package/dist/event-center/ipc-operation.js +66 -25
- package/dist/event-center/pack-loader.js +12 -55
- package/dist/event-center/pack-manager.js +5 -3
- package/dist/event-center/registry.js +48 -52
- package/dist/event-center/runtime.js +219 -81
- package/dist/event-center/script-runner.js +18 -7
- package/dist/event-center/types.js +9 -1
- package/dist/event-center/validation.js +33 -4
- package/dist/index.js +96 -42
- package/dist/ipc.js +33 -7
- package/dist/product.js +1 -0
- package/dist/proxy/manager.js +52 -11
- package/dist/proxy/service-supervisor.js +265 -67
- package/dist/services/dispatcher.js +26 -3
- package/dist/services/idempotency.js +128 -0
- package/dist/services/identity.js +3 -27
- package/dist/services/index-generator.js +5 -1
- package/dist/services/index.js +244 -45
- package/dist/services/ipc-operation.js +164 -20
- package/dist/services/pack-manager.js +37 -9
- package/dist/services/router.js +100 -31
- package/dist/services/script-runner.js +15 -4
- package/dist/services/service-payload.js +50 -2
- package/dist/services/validation.js +107 -3
- package/dist/trigger/scheduler.js +14 -4
- package/dist/trigger/script-sandbox.js +39 -2
- package/dist/utils/cross-platform.js +35 -11
- package/dist/utils/error-utils.js +13 -1
- package/dist/utils/instance-registry.js +33 -35
- package/dist/utils/process-introspect.js +35 -20
- package/dist/utils/project-path.js +47 -3
- package/dist/utils/windows-shell-trust.js +174 -68
- package/kits/docs/context-assembly.md +3 -3
- package/kits/docs/evolcore/agent.md +28 -10
- package/kits/docs/evolcore/config.md +22 -0
- package/kits/docs/evolcore/directory.md +46 -12
- package/kits/docs/evolcore/event-center.md +6 -6
- package/kits/docs/evolcore/group-collaboration.md +1 -1
- package/kits/docs/evolcore/menu-client.md +7 -5
- package/kits/docs/evolcore/menu-protocol.md +5 -3
- package/kits/docs/evolcore/msg.md +10 -3
- package/kits/docs/evolcore/provider.md +7 -3
- package/kits/docs/evolcore/services.md +145 -12
- package/kits/docs/evolcore/thread-chain.md +17 -9
- package/kits/docs/prompt-loading-architecture.md +4 -4
- package/kits/eck_message_manifest.json +46 -3
- package/kits/rules/04-relation.md +10 -2
- package/kits/rules/06-channel.md +2 -1
- package/kits/schemas/providers.schema.2.json +1 -0
- package/kits/skills/ec-group/SKILL.md +4 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +1 -1
- package/kits/skills/ec-skill/scripts/skill.mjs +13 -2
- package/kits/skills/thread-ops/SKILL.md +8 -5
- package/kits/templates/message-fragments/group-batch-item.md +3 -0
- package/kits/templates/message-fragments/group-batch.md +1 -0
- package/kits/templates/message-fragments/item-group.md +4 -0
- package/kits/templates/message-fragments/item-private.md +4 -0
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/system-fragments/commands.md +5 -5
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +11 -7
- package/package.json +3 -2
- package/scripts/agent-template/index.mjs +9 -4
- package/scripts/agent-template/inspect.mjs +16 -9
- package/scripts/agent-template/shared/plan.mjs +3 -33
- package/scripts/agent-template/shared/template-contract.mjs +186 -3
- package/scripts/agent-template/shared/template-package.mjs +119 -10
- package/scripts/agent-template/shared/template-runtime.mjs +49 -6
- package/scripts/agent-template/shared/template.mjs +5 -5
- package/scripts/agent-template/team-pack.mjs +245 -0
- package/scripts/agent-template/team-preview.mjs +111 -0
- package/scripts/aid-batch/identity-batch.mjs +143 -0
- package/dist/ability/versions.js +0 -32
- package/dist/aun/model-headers.js +0 -17
- package/dist/channels/builtin-plugins.js +0 -19
- package/dist/core/command/team-workspace-initializer.js +0 -2
- package/dist/core/command/team-workspace-job-store.js +0 -88
- package/dist/core/command/team-workspace-management-service.js +0 -2
- package/dist/core/contact-bind-registry.js +0 -27
- package/dist/event-center/ledger.js +0 -52
- package/dist/services/reply.js +0 -55
- package/kits/templates/message-fragments/item.md +0 -3
- package/scripts/agent-template/pack.mjs +0 -169
|
@@ -10,6 +10,8 @@ import fs from 'fs';
|
|
|
10
10
|
import { execFile, spawnSync } from 'child_process';
|
|
11
11
|
const isWindows = process.platform === 'win32';
|
|
12
12
|
const isMacOS = process.platform === 'darwin';
|
|
13
|
+
// ps localizes weekday/month names; Date.parse requires the C locale here.
|
|
14
|
+
const C_LOCALE_ENV = { LC_ALL: 'C', LANG: 'C' };
|
|
13
15
|
function readLinuxClockTicks() {
|
|
14
16
|
if (process.platform !== 'linux')
|
|
15
17
|
return 100;
|
|
@@ -46,25 +48,28 @@ function approximateSelfStartTime() {
|
|
|
46
48
|
/**
|
|
47
49
|
* 身份校验路径上同一个 PID 会被连着查两三次(`sameProcess()` 在优雅停止前后各查一次,
|
|
48
50
|
* 端口候选还要再查一次),Windows 上每次都是一整个 PowerShell 进程(约 0.5–1s)。
|
|
49
|
-
*
|
|
50
|
-
* 需要在一个 TTL 内退出并复刻出同一个 PID,实际不可能,且 `startTimeMatches` 本身
|
|
51
|
-
* 有 2s 容差。TTL 取短一些,避免让「进程已换人」的判断比容差更迟钝。
|
|
51
|
+
* 普通观测短时复用缓存。终止进程前必须传 fresh,避免 PID 在缓存期内被其他进程复用。
|
|
52
52
|
*/
|
|
53
53
|
const START_TIME_CACHE_TTL_MS = 5000;
|
|
54
54
|
const startTimeCache = new Map();
|
|
55
55
|
const startTimeQueries = new Map();
|
|
56
56
|
/** Daemon lifecycle queries must not block IPC, probes or startup timers. */
|
|
57
|
-
export async function getProcessStartTimeAsync(pid) {
|
|
57
|
+
export async function getProcessStartTimeAsync(pid, options = {}) {
|
|
58
58
|
if (!Number.isInteger(pid) || pid <= 0)
|
|
59
59
|
return null;
|
|
60
60
|
if (pid === process.pid)
|
|
61
61
|
return getProcessStartTime(pid);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
if (!options.fresh) {
|
|
63
|
+
const cached = startTimeCache.get(pid);
|
|
64
|
+
if (cached && Date.now() - cached.at < START_TIME_CACHE_TTL_MS)
|
|
65
|
+
return cached.startedAt;
|
|
66
|
+
const pending = startTimeQueries.get(pid);
|
|
67
|
+
if (pending)
|
|
68
|
+
return pending;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
startTimeCache.delete(pid);
|
|
72
|
+
}
|
|
68
73
|
const query = (async () => {
|
|
69
74
|
let startedAt;
|
|
70
75
|
if (isWindows) {
|
|
@@ -78,7 +83,7 @@ export async function getProcessStartTimeAsync(pid) {
|
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
85
|
else if (isMacOS) {
|
|
81
|
-
startedAt = parseDateString(await processQuery('ps', ['-p', String(pid), '-o', 'lstart='], 5000));
|
|
86
|
+
startedAt = parseDateString(await processQuery('ps', ['-p', String(pid), '-o', 'lstart='], 5000, { ...process.env, ...C_LOCALE_ENV }));
|
|
82
87
|
}
|
|
83
88
|
else {
|
|
84
89
|
startedAt = getStartTimeLinux(pid);
|
|
@@ -93,24 +98,28 @@ export async function getProcessStartTimeAsync(pid) {
|
|
|
93
98
|
startedAt = null;
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
|
-
if (startedAt === null)
|
|
97
|
-
startTimeCache.delete(pid);
|
|
98
|
-
else
|
|
99
|
-
startTimeCache.set(pid, { at: Date.now(), startedAt });
|
|
100
101
|
return startedAt;
|
|
101
102
|
})();
|
|
102
103
|
startTimeQueries.set(pid, query);
|
|
103
104
|
try {
|
|
104
|
-
|
|
105
|
+
const startedAt = await query;
|
|
106
|
+
// An older lookup must not overwrite a newer, explicitly refreshed result.
|
|
107
|
+
if (startTimeQueries.get(pid) === query) {
|
|
108
|
+
if (startedAt === null)
|
|
109
|
+
startTimeCache.delete(pid);
|
|
110
|
+
else
|
|
111
|
+
startTimeCache.set(pid, { at: Date.now(), startedAt });
|
|
112
|
+
}
|
|
113
|
+
return startedAt;
|
|
105
114
|
}
|
|
106
115
|
finally {
|
|
107
116
|
if (startTimeQueries.get(pid) === query)
|
|
108
117
|
startTimeQueries.delete(pid);
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
|
-
function processQuery(command, args, timeout) {
|
|
120
|
+
function processQuery(command, args, timeout, env) {
|
|
112
121
|
return new Promise(resolve => {
|
|
113
|
-
execFile(command, args, { encoding: 'utf8', timeout, windowsHide: true }, (error, stdout) => {
|
|
122
|
+
execFile(command, args, { encoding: 'utf8', timeout, windowsHide: true, env }, (error, stdout) => {
|
|
114
123
|
resolve(error ? '' : stdout.replace(/^\uFEFF/, '').trim());
|
|
115
124
|
});
|
|
116
125
|
});
|
|
@@ -119,16 +128,20 @@ function processQuery(command, args, timeout) {
|
|
|
119
128
|
* 获取进程启动时间(Unix 毫秒)。
|
|
120
129
|
* 拿不到时返回 null,调用方应保守处理(不杀该 PID)。
|
|
121
130
|
*/
|
|
122
|
-
export function getProcessStartTime(pid) {
|
|
131
|
+
export function getProcessStartTime(pid, options = {}) {
|
|
123
132
|
if (pid === process.pid) {
|
|
124
133
|
// 自身不查 CIM:近似值已在容差内,省掉一次 PowerShell 进程启动。
|
|
125
134
|
if (selfStartTime === null)
|
|
126
135
|
selfStartTime = approximateSelfStartTime();
|
|
127
136
|
return selfStartTime;
|
|
128
137
|
}
|
|
138
|
+
if (options.fresh) {
|
|
139
|
+
startTimeCache.delete(pid);
|
|
140
|
+
startTimeQueries.delete(pid);
|
|
141
|
+
}
|
|
129
142
|
const cached = startTimeCache.get(pid);
|
|
130
143
|
const now = Date.now();
|
|
131
|
-
if (cached && now - cached.at < START_TIME_CACHE_TTL_MS)
|
|
144
|
+
if (!options.fresh && cached && now - cached.at < START_TIME_CACHE_TTL_MS)
|
|
132
145
|
return cached.startedAt;
|
|
133
146
|
const startedAt = readProcessStartTime(pid);
|
|
134
147
|
// 只缓存成功结果:查不到往往是权限或瞬时失败,缓存成 null 会掩盖后续可查到的情形。
|
|
@@ -142,6 +155,7 @@ export function getProcessStartTime(pid) {
|
|
|
142
155
|
export function resetSelfStartTimeCache() {
|
|
143
156
|
selfStartTime = null;
|
|
144
157
|
startTimeCache.clear();
|
|
158
|
+
startTimeQueries.clear();
|
|
145
159
|
}
|
|
146
160
|
function readProcessStartTime(pid) {
|
|
147
161
|
try {
|
|
@@ -207,6 +221,7 @@ function getStartTimeMacOS(pid) {
|
|
|
207
221
|
encoding: 'utf-8',
|
|
208
222
|
timeout: 5000,
|
|
209
223
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
224
|
+
env: { ...process.env, ...C_LOCALE_ENV },
|
|
210
225
|
});
|
|
211
226
|
const out = result.stdout?.trim();
|
|
212
227
|
if (!out)
|
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
const PROJECT_ENV_REFERENCE = /\$(?:([A-Za-z_][A-Za-z0-9_]*)|\{([A-Za-z_][A-Za-z0-9_]*)\})/gu;
|
|
5
|
+
const PROJECT_ENV_SYNTAX = /\$\{|\$ENV:|\$[A-Za-z_][A-Za-z0-9_]*/u;
|
|
6
|
+
/** Configuration reads preserve references; only path consumers resolve them. */
|
|
7
|
+
export function hasProjectPathEnvironmentReference(value) {
|
|
8
|
+
return value.search(PROJECT_ENV_REFERENCE) !== -1;
|
|
9
|
+
}
|
|
10
|
+
export function assertProjectPathReference(value) {
|
|
11
|
+
const literal = value.replace(PROJECT_ENV_REFERENCE, '');
|
|
12
|
+
if (/\$ENV:/u.test(value) || /\$\{/u.test(literal)) {
|
|
13
|
+
throw Object.assign(new Error('projects.defaultPath supports only $VAR or ${VAR} environment references'), {
|
|
14
|
+
code: 'INVALID_ARGUMENT',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Validate stored syntax without requiring the deployment environment to exist. */
|
|
19
|
+
export function assertProjectPathConfig(value, options = {}) {
|
|
20
|
+
assertProjectPathReference(value);
|
|
21
|
+
if (!hasProjectPathEnvironmentReference(value) && !pathForPlatform(options.platform ?? process.platform).isAbsolute(value)) {
|
|
22
|
+
throw new Error('projects.defaultPath must be an absolute path or use environment references');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function resolveProjectDefaultPath(value, options = {}) {
|
|
26
|
+
if (!value)
|
|
27
|
+
return value;
|
|
28
|
+
assertProjectPathReference(value);
|
|
29
|
+
// Keep existing literal paths and omitted-path fallbacks unchanged.
|
|
30
|
+
if (!hasProjectPathEnvironmentReference(value))
|
|
31
|
+
return value;
|
|
32
|
+
const resolved = value.replace(PROJECT_ENV_REFERENCE, (_match, plain, braced) => {
|
|
33
|
+
const variable = (plain || braced);
|
|
34
|
+
const replacement = process.env[variable]?.trim();
|
|
35
|
+
if (!replacement) {
|
|
36
|
+
throw Object.assign(new Error(`projects.defaultPath references unset or empty environment variable ${variable}`), {
|
|
37
|
+
code: 'INVALID_ARGUMENT',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return replacement;
|
|
41
|
+
});
|
|
42
|
+
if (PROJECT_ENV_SYNTAX.test(resolved) || resolved.includes('\0')
|
|
43
|
+
|| !pathForPlatform(options.platform ?? process.platform).isAbsolute(resolved)) {
|
|
44
|
+
throw Object.assign(new Error('projects.defaultPath must resolve to an absolute path without nested environment references'), {
|
|
45
|
+
code: 'INVALID_ARGUMENT',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return resolved;
|
|
49
|
+
}
|
|
4
50
|
function pathForPlatform(platform) {
|
|
5
51
|
return platform === 'win32' ? path.win32 : path.posix;
|
|
6
52
|
}
|
|
@@ -51,9 +97,7 @@ export function defaultProjectsRoot(evolcoreRoot, options = {}) {
|
|
|
51
97
|
return pathImpl.join(evolcoreRoot, 'projects');
|
|
52
98
|
}
|
|
53
99
|
export function agentProjectRootFromDefaults(defaults, evolcoreRoot, options = {}) {
|
|
54
|
-
const
|
|
55
|
-
const pathImpl = pathForPlatform(platform);
|
|
56
|
-
const configuredRoot = defaults?.projects?.defaultPath
|
|
100
|
+
const configuredRoot = resolveProjectDefaultPath(defaults?.projects?.defaultPath, options)
|
|
57
101
|
|| defaultProjectsRoot(evolcoreRoot, options);
|
|
58
102
|
return sanitizeProjectRoot(configuredRoot, options);
|
|
59
103
|
}
|
|
@@ -3,6 +3,24 @@ import path from 'node:path';
|
|
|
3
3
|
import { execFile, spawnSync } from 'node:child_process';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
5
|
const execFileAsync = promisify(execFile);
|
|
6
|
+
export class WindowsShellTrustError extends Error {
|
|
7
|
+
reason;
|
|
8
|
+
diagnostics;
|
|
9
|
+
code = 'WINDOWS_SHELL_TRUST_FAILED';
|
|
10
|
+
constructor(reason, detail, diagnostics = {}, cause) {
|
|
11
|
+
super(`Windows CLI 启动校验失败 [WINDOWS_SHELL_TRUST_FAILED:${reason}]:${detail}`, { cause });
|
|
12
|
+
this.reason = reason;
|
|
13
|
+
this.diagnostics = diagnostics;
|
|
14
|
+
this.name = 'WindowsShellTrustError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Also recognize errors after runners have serialized them to plain text. */
|
|
18
|
+
export function isWindowsShellTrustError(error) {
|
|
19
|
+
const record = error;
|
|
20
|
+
return record?.code === 'WINDOWS_SHELL_TRUST_FAILED'
|
|
21
|
+
|| String(record?.message ?? error ?? '').includes('[WINDOWS_SHELL_TRUST_FAILED:');
|
|
22
|
+
}
|
|
23
|
+
const SIGNATURE_PROBE_TIMEOUT_MS = 5_000;
|
|
6
24
|
const MAX_CACHE_ENTRIES = 128;
|
|
7
25
|
const signatureCache = new Map();
|
|
8
26
|
const pendingCmdSignatures = new Map();
|
|
@@ -126,31 +144,91 @@ function authenticodeScript(filePath) {
|
|
|
126
144
|
'} | ConvertTo-Json -Compress',
|
|
127
145
|
].join('\n');
|
|
128
146
|
}
|
|
147
|
+
function signatureProbeFailure(filePath, result) {
|
|
148
|
+
const cause = result.error;
|
|
149
|
+
const timedOut = cause?.code === 'ETIMEDOUT' || (cause?.killed && result.signal === 'SIGTERM');
|
|
150
|
+
const startFailed = cause?.syscall?.startsWith('spawn')
|
|
151
|
+
|| ['ENOENT', 'EACCES', 'EPERM'].includes(cause?.code ?? '');
|
|
152
|
+
const reason = timedOut ? 'SIGNATURE_PROBE_TIMEOUT'
|
|
153
|
+
: startFailed ? 'POWERSHELL_START_FAILED' : 'SIGNATURE_PROBE_FAILED';
|
|
154
|
+
const detail = timedOut ? `签名检查超过 ${SIGNATURE_PROBE_TIMEOUT_MS} 毫秒:${filePath}`
|
|
155
|
+
: reason === 'POWERSHELL_START_FAILED'
|
|
156
|
+
? `无法启动签名检查程序 ${systemPowerShellPath()}(${cause?.code})`
|
|
157
|
+
: `签名检查程序执行失败:${filePath}(退出码 ${result.status ?? '未知'},信号 ${result.signal ?? '无'})`;
|
|
158
|
+
return new WindowsShellTrustError(reason, detail, {
|
|
159
|
+
path: filePath, probePath: systemPowerShellPath(), timeoutMs: SIGNATURE_PROBE_TIMEOUT_MS,
|
|
160
|
+
exitCode: result.status, signal: result.signal, causeCode: cause?.code, causeMessage: cause?.message,
|
|
161
|
+
stdout: String(result.stdout ?? ''), stderr: String(result.stderr ?? ''),
|
|
162
|
+
}, cause);
|
|
163
|
+
}
|
|
129
164
|
function probeAuthenticode(filePath) {
|
|
130
165
|
const result = spawnSync(systemPowerShellPath(), [
|
|
131
166
|
'-NoLogo', '-NoProfile', '-NonInteractive', '-Command', authenticodeScript(filePath),
|
|
132
167
|
], {
|
|
133
168
|
encoding: 'utf8',
|
|
134
169
|
env: systemPowerShellEnvironment(),
|
|
135
|
-
timeout:
|
|
170
|
+
timeout: SIGNATURE_PROBE_TIMEOUT_MS,
|
|
136
171
|
windowsHide: true,
|
|
137
|
-
stdio: ['ignore', 'pipe', '
|
|
172
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
138
173
|
});
|
|
139
|
-
if (result.status !== 0 || result.error
|
|
140
|
-
|
|
141
|
-
return parseAuthenticode(String(result.stdout));
|
|
174
|
+
if (result.status !== 0 || result.error)
|
|
175
|
+
throw signatureProbeFailure(filePath, result);
|
|
176
|
+
return parseAuthenticode(String(result.stdout ?? ''), filePath, String(result.stderr ?? ''));
|
|
142
177
|
}
|
|
143
|
-
function parseAuthenticode(output) {
|
|
178
|
+
function parseAuthenticode(output, filePath, stderr) {
|
|
144
179
|
try {
|
|
145
|
-
const parsed = JSON.parse(output);
|
|
180
|
+
const parsed = JSON.parse(output.replace(/^\uFEFF/, '').trim());
|
|
181
|
+
if (!parsed || Array.isArray(parsed) || typeof parsed.status !== 'string' || !parsed.status.trim()) {
|
|
182
|
+
throw new Error('签名结果缺少有效 status 字段');
|
|
183
|
+
}
|
|
146
184
|
return {
|
|
147
185
|
status: typeof parsed.status === 'string' ? parsed.status : undefined,
|
|
148
186
|
subject: typeof parsed.subject === 'string' ? parsed.subject : undefined,
|
|
149
187
|
issuer: typeof parsed.issuer === 'string' ? parsed.issuer : undefined,
|
|
188
|
+
stdout: output,
|
|
189
|
+
stderr,
|
|
190
|
+
probePath: systemPowerShellPath(),
|
|
150
191
|
};
|
|
151
192
|
}
|
|
152
|
-
catch {
|
|
153
|
-
|
|
193
|
+
catch (cause) {
|
|
194
|
+
throw new WindowsShellTrustError('SIGNATURE_OUTPUT_INVALID', `签名检查输出无法解析:${filePath}`, {
|
|
195
|
+
path: filePath, probePath: systemPowerShellPath(), stdout: output, stderr,
|
|
196
|
+
}, cause);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function assertTrustedSignature(kind, filePath, evidence) {
|
|
200
|
+
if (isTrustedShellSignature(kind, evidence))
|
|
201
|
+
return;
|
|
202
|
+
const valid = isValidStatus(evidence.status);
|
|
203
|
+
throw new WindowsShellTrustError(valid ? 'SIGNER_UNTRUSTED' : 'SIGNATURE_INVALID', valid ? `签名发布者不受信任:${filePath}(${evidence.subject || '无签名证书'})`
|
|
204
|
+
: `数字签名未通过:${filePath}(状态 ${evidence.status})`, { path: filePath, ...evidence });
|
|
205
|
+
}
|
|
206
|
+
function shellFileStat(filePath) {
|
|
207
|
+
let stat;
|
|
208
|
+
try {
|
|
209
|
+
stat = fs.statSync(filePath);
|
|
210
|
+
}
|
|
211
|
+
catch (cause) {
|
|
212
|
+
throw fileAccessFailure(filePath, cause);
|
|
213
|
+
}
|
|
214
|
+
if (!stat.isFile()) {
|
|
215
|
+
throw new WindowsShellTrustError('NOT_A_FILE', `命令解释器路径不是文件:${filePath}`, { path: filePath });
|
|
216
|
+
}
|
|
217
|
+
return stat;
|
|
218
|
+
}
|
|
219
|
+
function fileAccessFailure(filePath, cause) {
|
|
220
|
+
const code = cause?.code;
|
|
221
|
+
return new WindowsShellTrustError('FILE_ACCESS_FAILED', `无法访问命令解释器:${filePath}(${code ?? '未知错误'})`, {
|
|
222
|
+
path: filePath, causeCode: code, causeMessage: cause instanceof Error ? cause.message : String(cause),
|
|
223
|
+
}, cause);
|
|
224
|
+
}
|
|
225
|
+
function rememberSignature(key, stat, error) {
|
|
226
|
+
signatureCache.set(key, { size: stat.size, mtimeMs: stat.mtimeMs, error });
|
|
227
|
+
while (signatureCache.size > MAX_CACHE_ENTRIES) {
|
|
228
|
+
const oldest = signatureCache.keys().next().value;
|
|
229
|
+
if (!oldest)
|
|
230
|
+
break;
|
|
231
|
+
signatureCache.delete(oldest);
|
|
154
232
|
}
|
|
155
233
|
}
|
|
156
234
|
function cacheKey(filePath) {
|
|
@@ -168,9 +246,19 @@ function cacheKey(filePath) {
|
|
|
168
246
|
export function isTrustedWindowsShellExecutable(executable, kind) {
|
|
169
247
|
if (process.platform !== 'win32')
|
|
170
248
|
return true;
|
|
171
|
-
|
|
172
|
-
|
|
249
|
+
try {
|
|
250
|
+
verifyWindowsShellExecutable(executable, kind);
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
173
254
|
return false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function verifyWindowsShellExecutable(executable, kind) {
|
|
258
|
+
const resolved = resolveShellPath(executable, kind);
|
|
259
|
+
if (!resolved) {
|
|
260
|
+
throw new WindowsShellTrustError('SHELL_PATH_UNRESOLVED', `无法解析命令解释器路径:${executable}`);
|
|
261
|
+
}
|
|
174
262
|
let finalPath = resolved;
|
|
175
263
|
try {
|
|
176
264
|
finalPath = fs.realpathSync.native(resolved);
|
|
@@ -182,31 +270,27 @@ export function isTrustedWindowsShellExecutable(executable, kind) {
|
|
|
182
270
|
// If realpath could not escape an App Execution Alias, do not authenticate
|
|
183
271
|
// the alias stub itself. A resolved WindowsApps package binary is allowed
|
|
184
272
|
// and is checked below like any other signed executable.
|
|
185
|
-
if (isAppExecutionAliasPath(finalPath))
|
|
186
|
-
|
|
187
|
-
let stat;
|
|
188
|
-
try {
|
|
189
|
-
stat = fs.statSync(finalPath);
|
|
190
|
-
if (!stat.isFile())
|
|
191
|
-
return false;
|
|
273
|
+
if (isAppExecutionAliasPath(finalPath)) {
|
|
274
|
+
throw new WindowsShellTrustError('APP_EXECUTION_ALIAS', `命令解释器仍指向应用执行别名:${finalPath}`, { path: finalPath });
|
|
192
275
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
const key = cacheKey(finalPath);
|
|
276
|
+
const stat = shellFileStat(finalPath);
|
|
277
|
+
const key = `${kind}:${cacheKey(finalPath)}`;
|
|
197
278
|
const previous = signatureCache.get(key);
|
|
198
279
|
if (previous && previous.size === stat.size && previous.mtimeMs === stat.mtimeMs) {
|
|
199
|
-
|
|
280
|
+
if (previous.error)
|
|
281
|
+
throw previous.error;
|
|
282
|
+
return finalPath;
|
|
200
283
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
284
|
+
try {
|
|
285
|
+
assertTrustedSignature(kind, finalPath, probeAuthenticode(finalPath));
|
|
286
|
+
rememberSignature(key, stat);
|
|
287
|
+
return finalPath;
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
if (error instanceof WindowsShellTrustError)
|
|
291
|
+
rememberSignature(key, stat, error);
|
|
292
|
+
throw error;
|
|
208
293
|
}
|
|
209
|
-
return trusted;
|
|
210
294
|
}
|
|
211
295
|
/**
|
|
212
296
|
* Resolve an inherited ComSpec to the system cmd.exe and authenticate it.
|
|
@@ -214,90 +298,112 @@ export function isTrustedWindowsShellExecutable(executable, kind) {
|
|
|
214
298
|
* validates only the interpreter and never the `.cmd`/`.bat` target.
|
|
215
299
|
*/
|
|
216
300
|
export function resolveTrustedWindowsCmdPath(comSpec) {
|
|
301
|
+
try {
|
|
302
|
+
return requireTrustedWindowsCmdPath(comSpec);
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/** CLI launches require the full failure, while permission predicates retain their boolean API. */
|
|
309
|
+
export function requireTrustedWindowsCmdPath(comSpec) {
|
|
217
310
|
if (process.platform !== 'win32')
|
|
218
311
|
return comSpec || 'cmd.exe';
|
|
219
312
|
const systemReal = resolveWindowsCmdCandidate(comSpec);
|
|
220
|
-
return
|
|
313
|
+
return verifyWindowsShellExecutable(systemReal, 'cmd');
|
|
221
314
|
}
|
|
222
315
|
function resolveWindowsCmdCandidate(comSpec) {
|
|
223
316
|
const systemCmd = windowsSystemCmdPath();
|
|
224
317
|
const candidate = (comSpec || process.env.ComSpec || process.env.COMSPEC || systemCmd).trim();
|
|
225
|
-
|
|
226
|
-
return undefined;
|
|
318
|
+
const diagnostics = { candidatePath: candidate, systemPath: systemCmd };
|
|
227
319
|
let candidatePath = candidate;
|
|
228
320
|
if (!isAbsoluteWindowsPath(candidatePath)) {
|
|
229
321
|
if (/^cmd(?:\.exe)?$/i.test(candidatePath))
|
|
230
322
|
candidatePath = systemCmd;
|
|
231
323
|
else
|
|
232
|
-
|
|
324
|
+
throw new WindowsShellTrustError('CMD_PATH_INVALID', `ComSpec 不是有效的系统 cmd 路径:${candidate || '空值'}(预期 ${systemCmd})`, diagnostics);
|
|
233
325
|
}
|
|
234
326
|
let candidateReal;
|
|
235
327
|
let systemReal;
|
|
236
328
|
try {
|
|
237
329
|
candidateReal = fs.realpathSync.native(candidatePath);
|
|
330
|
+
}
|
|
331
|
+
catch (cause) {
|
|
332
|
+
throw fileAccessFailure(candidatePath, cause);
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
238
335
|
systemReal = fs.realpathSync.native(systemCmd);
|
|
239
336
|
}
|
|
240
|
-
catch {
|
|
241
|
-
|
|
337
|
+
catch (cause) {
|
|
338
|
+
throw fileAccessFailure(systemCmd, cause);
|
|
242
339
|
}
|
|
243
340
|
if (path.win32.normalize(candidateReal).toLowerCase() !== path.win32.normalize(systemReal).toLowerCase()) {
|
|
244
|
-
|
|
341
|
+
throw new WindowsShellTrustError('CMD_PATH_MISMATCH', `ComSpec 指向 ${candidateReal},预期系统 cmd 为 ${systemReal}`, {
|
|
342
|
+
...diagnostics, candidateRealPath: candidateReal, systemRealPath: systemReal,
|
|
343
|
+
});
|
|
245
344
|
}
|
|
246
345
|
return systemReal;
|
|
247
346
|
}
|
|
248
347
|
/** Async probes keep the same system-path and signature policy without blocking I/O callbacks. */
|
|
249
348
|
export async function resolveTrustedWindowsCmdPathAsync(comSpec) {
|
|
250
|
-
if (process.platform !== 'win32')
|
|
251
|
-
return comSpec || 'cmd.exe';
|
|
252
|
-
const systemReal = resolveWindowsCmdCandidate(comSpec);
|
|
253
|
-
if (!systemReal || isAppExecutionAliasPath(systemReal))
|
|
254
|
-
return undefined;
|
|
255
|
-
let stat;
|
|
256
349
|
try {
|
|
257
|
-
|
|
258
|
-
if (!stat.isFile())
|
|
259
|
-
return undefined;
|
|
350
|
+
return await requireTrustedWindowsCmdPathAsync(comSpec);
|
|
260
351
|
}
|
|
261
352
|
catch {
|
|
262
353
|
return undefined;
|
|
263
354
|
}
|
|
264
|
-
|
|
355
|
+
}
|
|
356
|
+
export async function requireTrustedWindowsCmdPathAsync(comSpec) {
|
|
357
|
+
if (process.platform !== 'win32')
|
|
358
|
+
return comSpec || 'cmd.exe';
|
|
359
|
+
const systemReal = resolveWindowsCmdCandidate(comSpec);
|
|
360
|
+
if (isAppExecutionAliasPath(systemReal)) {
|
|
361
|
+
throw new WindowsShellTrustError('APP_EXECUTION_ALIAS', `命令解释器仍指向应用执行别名:${systemReal}`, { path: systemReal });
|
|
362
|
+
}
|
|
363
|
+
const stat = shellFileStat(systemReal);
|
|
364
|
+
const key = `cmd:${cacheKey(systemReal)}`;
|
|
265
365
|
const cached = signatureCache.get(key);
|
|
266
366
|
if (cached && cached.size === stat.size && cached.mtimeMs === stat.mtimeMs) {
|
|
267
|
-
|
|
367
|
+
if (cached.error)
|
|
368
|
+
throw cached.error;
|
|
369
|
+
return systemReal;
|
|
268
370
|
}
|
|
269
371
|
const identity = `${key}:${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`;
|
|
270
372
|
let pending = pendingCmdSignatures.get(identity);
|
|
271
373
|
if (!pending) {
|
|
272
374
|
const generation = signatureGeneration;
|
|
273
375
|
pending = (async () => {
|
|
376
|
+
let failure;
|
|
274
377
|
try {
|
|
275
|
-
const { stdout } = await execFileAsync(systemPowerShellPath(), [
|
|
378
|
+
const { stdout, stderr } = await execFileAsync(systemPowerShellPath(), [
|
|
276
379
|
'-NoLogo', '-NoProfile', '-NonInteractive', '-Command', authenticodeScript(systemReal),
|
|
277
|
-
], {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
break;
|
|
289
|
-
signatureCache.delete(oldest);
|
|
290
|
-
}
|
|
291
|
-
return trusted;
|
|
380
|
+
], {
|
|
381
|
+
encoding: 'utf8', env: systemPowerShellEnvironment(), timeout: SIGNATURE_PROBE_TIMEOUT_MS, windowsHide: true,
|
|
382
|
+
});
|
|
383
|
+
assertTrustedSignature('cmd', systemReal, parseAuthenticode(stdout, systemReal, stderr));
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
const result = error;
|
|
387
|
+
failure = error instanceof WindowsShellTrustError ? error : signatureProbeFailure(systemReal, {
|
|
388
|
+
error, status: typeof result.code === 'number' ? result.code : undefined,
|
|
389
|
+
signal: result.signal, stdout: result.stdout, stderr: result.stderr,
|
|
390
|
+
});
|
|
292
391
|
}
|
|
293
|
-
|
|
294
|
-
|
|
392
|
+
const current = shellFileStat(systemReal);
|
|
393
|
+
if (generation !== signatureGeneration || current.size !== stat.size
|
|
394
|
+
|| current.mtimeMs !== stat.mtimeMs || current.ctimeMs !== stat.ctimeMs
|
|
395
|
+
|| resolveWindowsCmdCandidate(comSpec) !== systemReal) {
|
|
396
|
+
throw new WindowsShellTrustError('TRUST_CHECK_CHANGED', `校验期间文件或信任上下文发生变化:${systemReal}`, { path: systemReal });
|
|
295
397
|
}
|
|
398
|
+
rememberSignature(key, stat, failure);
|
|
399
|
+
if (failure)
|
|
400
|
+
throw failure;
|
|
296
401
|
})();
|
|
297
402
|
pendingCmdSignatures.set(identity, pending);
|
|
298
403
|
}
|
|
299
404
|
try {
|
|
300
|
-
|
|
405
|
+
await pending;
|
|
406
|
+
return systemReal;
|
|
301
407
|
}
|
|
302
408
|
finally {
|
|
303
409
|
if (pendingCmdSignatures.get(identity) === pending)
|
|
@@ -49,7 +49,7 @@ evolcore 收到消息 → 构造一份 **vars**(运行时变量,见下)→
|
|
|
49
49
|
渲染时按 `session.sessionType`(缺省 `'main'`)依次查:`sessionManifests` 覆盖 → 内置映射 → `eck_manifest.json`(`resolveSessionManifest`)。bootstrapping 阶段固定用 `eck_manifest.json`。
|
|
50
50
|
**每个 manifest 文件各自两级合并**(`$KITS/<file>` + `$ECK/<file>`),互不干扰。
|
|
51
51
|
|
|
52
|
-
`chatMode` 只支持 interactive/proactive,均复用按生命周期、sessionType 和 sessionManifests 选择的 system/message manifest 与基础 vars。派生变量 `activePush` 仅在 proactive 时为 true,工具门禁变量也按 proactive 注入。PA 身份不改变 Agent 可见的模式、manifest 或 vars;仅在 active AUN 人类 Owner 私聊主会话及话题中,将 PA 的 proactive 过程 activity 经 message.send 可靠投递,任务成功提交后的自动最终正文为 custom/agent_final。其他 proactive 场景使用 thought.put,群聊固定 proactive
|
|
52
|
+
`chatMode` 只支持 interactive/proactive,均复用按生命周期、sessionType 和 sessionManifests 选择的 system/message manifest 与基础 vars。派生变量 `activePush` 仅在 proactive 时为 true,工具门禁变量也按 proactive 注入。PA 身份不改变 Agent 可见的模式、manifest 或 vars;仅在 active AUN 人类 Owner 私聊主会话及话题中,将 PA 的 proactive 过程 activity 经 message.send 可靠投递,任务成功提交后的自动最终正文为 custom/agent_final。其他 proactive 场景使用 thought.put,群聊固定 proactive。默认逐条消息信封显示本轮可信 chatType/chatMode,并携带发送者身份、`与发言人` 角色、消息 ID 与来源话题;两种模式均不展示明文/密文标签;原始 encrypted 变量及发送加密语义不变。
|
|
53
53
|
|
|
54
54
|
## section 字段
|
|
55
55
|
|
|
@@ -193,7 +193,7 @@ manifest 是 `{ "$schema_version": 1, "sections": [...] }`。每个 section:
|
|
|
193
193
|
改加载条件(仅 owner/admin 才载入对端档案):
|
|
194
194
|
|
|
195
195
|
```json
|
|
196
|
-
{ "sections": [ { "id": "peer-profile", "when": { "var": "
|
|
196
|
+
{ "sections": [ { "id": "peer-profile", "when": { "var": "speakerRelation", "in": ["owner", "admin"] } } ] }
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
新增自定义段:
|
|
@@ -273,7 +273,7 @@ vars 由 evolcore 在 `message-processor.ts` 按当前会话构造。分两类
|
|
|
273
273
|
| `selfAid` / `selfName` | 当前 agent 身份 |
|
|
274
274
|
| `hasPersona` | 是否有自我定义内容(soul/ 下除指南外有非空文件) |
|
|
275
275
|
| `peerId` / `peerKey` / `peerName` | 对端原生 ID / 跨渠道键 / 显示名 |
|
|
276
|
-
| `
|
|
276
|
+
| `speakerRelation` / `peerType` | 发言人与我的关系角色(owner/admin/member/visitor/自定义角色/none)/ 类型(human/agent) |
|
|
277
277
|
| `groupId` | 群 ID(群聊时) |
|
|
278
278
|
| `chatType` | `private` / `group` / `null`(coding) |
|
|
279
279
|
| `channel` | 渠道类型(aun/feishu/...)|
|
|
@@ -4,24 +4,35 @@
|
|
|
4
4
|
|
|
5
5
|
## Agent 模板
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
单成员、多成员共用 `ec agent template`。新建支持一个或多个成员,只创建成员 AID,沿用本机 Host 和经鉴权的 Owner;覆盖仅支持一个已有 Agent,保留其 AID、Owner、角色和默认项目目录。打包不带记忆、消息、私钥或 Provider 凭证;导入的 Trigger 默认停用并携带脚本。来源采集和覆盖要求操作者同时是 DaemonOwner 和对应 Agent 的协议 Owner。
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
ec agent template inspect
|
|
11
|
-
ec agent template build
|
|
12
|
-
ec agent template push
|
|
13
|
-
ec agent template pull
|
|
14
|
-
ec agent template
|
|
10
|
+
ec agent template inspect --input-file inspect.json --request-id <稳定ID>
|
|
11
|
+
ec agent template build --input-file build.json --request-id <稳定ID>
|
|
12
|
+
ec agent template push --input-file push.json --request-id <稳定ID>
|
|
13
|
+
ec agent template pull --input-file pull.json --request-id <稳定ID>
|
|
14
|
+
ec agent template preview --input-file preview.json --request-id <稳定ID>
|
|
15
|
+
ec agent template deploy --preview-id <previewId> --plan-digest sha256:<摘要> --request-id <稳定ID>
|
|
15
16
|
ec agent template status <jobId>
|
|
17
|
+
ec agent template status --request-id <原请求ID>
|
|
18
|
+
ec agent template resume <jobId> --request-id <本次恢复ID>
|
|
19
|
+
ec agent template cancel <jobId> --request-id <本次取消ID>
|
|
20
|
+
ec agent template capabilities
|
|
16
21
|
```
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
`inspect/build/push/pull/preview` 的业务参数通过 JSON 文件传入。`capabilities` 返回动作输入 schema、状态及平台能力;文件模板沿用原 v1 的 `agents[]/key`、PACKAGE/MANIFEST 和资源结构。Core 作业以成员 key 关联,不按数组位置配对。Menu 使用进程级 `name: "template"`,动作与 CLI 一致;查询使用 `args.view: "job"` 或 `"capabilities"`。
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
inspect 输入示例:`{"members":{"writer":{"source":{"kind":"agent","aid":"writer.agentid.cn"}}}}`。全组必须空闲,任一忙碌立即返回 AGENT_BUSY;成功后冻结任务启动与 Trigger,无确认操作 15 分钟自动释放,查询不续期。build 承接 inspectionJobId、inventoryDigest、metadata 和各成员 include;接管后由构建作业持有冻结直到结束,取消统一使用 jobId。
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
完整选项用 `ec agent template --help` 查看。上传前由 App 以 Owner 身份授予来源 Host 目录读写权限,SDK 上传需读取元数据;普通私有下载使用 `storage.create_share_link.allowed_aids` 指定目标 Host,pull 的 source 带 location、分享短码和摘要。Owner/subaid 动态授权等待新 SDK;daemon 不代设权限,模板签名延期。
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
preview 传 packageId、installMode 和成员 key → target/providers/externalAids。新建目标示例:`{"members":{"writer":{"target":{"aid":"auto","project":"/work/writer"},"providers":{"ecagent":{"provider":"provider-12345678","model":"model-a"}}}}}`;aid=auto 时另传 issuer。预览不注册身份;deploy 只引用可执行 previewId 和 planDigest。多成员必须全部新建,不提供已有成员配对。
|
|
30
|
+
|
|
31
|
+
异步命令默认 `--wait 0`,可设 0..300 秒,超时不取消作业。失败/取消退出码 1、参数错误 2、暂停或等待超时 3。先以原 requestId 或 jobId 查询,再恢复原作业,不用新部署请求重试未知结果。Menu 事件统一为 `template.job`,seq 单调递增;状态包括 queued/running/paused/failed/cancelling/cancelled/succeeded。
|
|
32
|
+
|
|
33
|
+
成员注册和 Owner 绑定使用随包的 `scripts/aid-batch/identity-batch.mjs`,持久检查点保存原操作与收据;Owner 待确认时暂停,恢复不重复注册或绑定。全组准备并验证后才提交并开放任务;取消保留已创建身份。覆盖失败恢复本次实际写入的文件与名片,恢复未确认时保持目标暂停。
|
|
34
|
+
|
|
35
|
+
工具随包位于 `scripts/agent-template/`;本机 CLI 经控制令牌 IPC,托管 CLI 经原委派通道,Menu 发往 Host Control AID。远端 Menu 不读取任意本机路径。Provider 模型通过进程级 model Menu 的 catalog 查询;作业 readiness 分别表示运行、名录和团队就绪,不以本地成员表代替 Owner 名录授权。接口细节及当前验收边界见 `docs/agent-template/agent-template-app-integration.md`。真实容器已验证注册/绑定/Storage/恢复及覆盖;App 界面、真实模型推理和名录互聊待验收。
|
|
25
36
|
|
|
26
37
|
## 子命令
|
|
27
38
|
|
|
@@ -100,6 +111,13 @@ ec agent reload [aid]
|
|
|
100
111
|
ec agent delete <aid> [--purge]
|
|
101
112
|
```
|
|
102
113
|
|
|
114
|
+
停用和删除按目标 AID 清理运行状态。配置文件已缺失而 daemon 仍持有该 Agent 时,停用会清除
|
|
115
|
+
残留并返回 `configMissing: true`,不会重建配置;两处都不存在时停用返回 `NOT_FOUND`。
|
|
116
|
+
删除允许重复执行,配置和运行实例均不存在也返回成功。普通删除保留个人数据,`--purge`
|
|
117
|
+
继续按原范围清除数据。忙碌拒绝发生在删文件之前;卸载失败返回具体错误,可在排除故障后重试。
|
|
118
|
+
宿主 CLI 在线时经本地控制令牌调用同一应用服务,仅在 daemon 明确未运行时使用离线文件操作;
|
|
119
|
+
请求超时不会自动转为离线删除。
|
|
120
|
+
|
|
103
121
|
## 创建模式与参数
|
|
104
122
|
|
|
105
123
|
`welcome --text`、创建时的 `--description` / `--persona-text` 按一次 `\n` / `\r` / `\t` / `\\` 解码;已传入的物理换行保留。不要使用 PowerShell 反引号换行转义;Windows PowerShell 中直接使用命令名,不要用批处理入口传物理多行。文件、路径、`--tags` JSON 不解码;`--name` / `rename` 名称不允许换行。
|