evolcore 0.0.43-test.4 → 0.0.43-test.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/bin/ecmsg.js +437 -91
- package/dist/agents/baseagent-availability.js +19 -4
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +19 -4
- package/dist/agents/codex/app-server-client.js +14 -3
- package/dist/agents/codex-runner.js +18 -23
- package/dist/aun/aid/agentmd.js +25 -0
- package/dist/aun/aid/control-aid.js +15 -0
- package/dist/aun/aid/identity.js +8 -0
- package/dist/aun/aid/ownership-operation.js +12 -3
- package/dist/aun/group/invite-service.js +3 -2
- package/dist/aun/service-proxy.js +18 -6
- package/dist/channels/aun.js +99 -23
- package/dist/channels/daemon.js +2 -2
- package/dist/cli/agent-create.js +19 -7
- package/dist/cli/aid-bind-command.js +3 -0
- package/dist/cli/aun-commands.js +19 -4
- package/dist/cli/code-stats.js +451 -213
- package/dist/cli/ctl-command.js +1 -3
- package/dist/cli/daemon-commands.js +42 -4
- package/dist/cli/directory.js +3 -1
- package/dist/cli/ecmsg-gateway.js +206 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/init.js +120 -13
- package/dist/cli/provider-command.js +82 -5
- package/dist/cli/restart-monitor.js +35 -24
- package/dist/cli/stats.js +8 -1
- package/dist/cli/task-context.js +41 -1
- package/dist/cli/watch-logs.js +6 -4
- package/dist/config/boot-log.js +16 -3
- package/dist/config/builtin-roles.js +2 -2
- package/dist/config/config-manager.js +5 -14
- package/dist/config/daemon-services.js +1 -0
- package/dist/config/peer-role-resolver.js +6 -6
- package/dist/config/provider-identity-migration.js +277 -0
- package/dist/config/provider-identity.js +37 -0
- package/dist/config/provider-ipc-service.js +40 -3
- package/dist/config/provider-local-sync.js +155 -0
- package/dist/config/providers-config.js +45 -4
- package/dist/config/providers-management.js +242 -76
- package/dist/config/providers.js +4 -1
- package/dist/config/role-service.js +8 -8
- package/dist/config/role-store.js +22 -22
- package/dist/config/schema-migration.js +143 -86
- package/dist/config/snapshot.js +70 -41
- package/dist/core/agent-runtime.js +48 -9
- package/dist/core/auth/auth-gateway.js +5 -3
- package/dist/core/auth/delegation-diagnostics.js +6 -2
- package/dist/core/auth/operation-authorizer.js +3 -1
- package/dist/core/auth/operation-catalog.js +6 -4
- package/dist/core/baseagent-loader.js +114 -11
- package/dist/core/channel-loader.js +36 -13
- package/dist/core/channel-runtime.js +112 -42
- package/dist/core/command/cli-intent-parser.js +2 -1
- package/dist/core/command/command-handler.js +16 -11
- package/dist/core/command/menu-handler.js +8 -3
- package/dist/core/command/menu-protocol.js +80 -7
- package/dist/core/command/provider-menu.js +4 -2
- package/dist/core/command/role-menu.js +29 -17
- package/dist/core/command/slash-handler.js +52 -16
- package/dist/core/daemon-control.js +42 -15
- package/dist/core/daemon-lifecycle.js +411 -67
- package/dist/core/handoff/dispatcher.js +9 -3
- package/dist/core/handoff/runtime.js +139 -45
- package/dist/core/handoff/store.js +190 -2
- package/dist/core/handoff/types.js +5 -0
- package/dist/core/initialization/service.js +7 -6
- package/dist/core/ipc-registration.js +5 -4
- package/dist/core/lifecycle-notice.js +10 -4
- package/dist/core/message/aun-ipc-sender.js +83 -5
- package/dist/core/message/message-admission.js +2 -0
- package/dist/core/message/message-bridge.js +53 -4
- package/dist/core/message/message-queue.js +46 -4
- package/dist/core/message/pending-hints.js +4 -10
- package/dist/core/message/response-engine.js +33 -25
- package/dist/core/message/send-options.js +40 -0
- package/dist/core/message/send-routing.js +320 -0
- package/dist/core/ownership/owner-resolver.js +112 -8
- package/dist/core/permission/ec-command-parser.js +159 -16
- package/dist/core/permission/readonly-shell-query.js +66 -7
- package/dist/core/permission/tool-error-code.js +13 -1
- package/dist/core/permission/tool-policy.js +74 -20
- package/dist/core/relation/same-owner-proof.js +131 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +24 -0
- package/dist/core/session/adapters/codex-session-file-adapter.js +80 -0
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +22 -0
- package/dist/core/session/adapters/gemini-session-file-adapter.js +39 -0
- package/dist/core/session/session-fs-store.js +164 -3
- package/dist/core/session/session-idle-monitor.js +103 -17
- package/dist/core/session/session-manager.js +105 -18
- package/dist/core/thread/thread-route.js +5 -2
- package/dist/directory/owner-directory-admission.js +26 -1
- package/dist/directory/owner-directory-cache.js +739 -109
- package/dist/directory/owner-directory-markdown.js +146 -36
- package/dist/directory/owner-directory-query-operation.js +6 -3
- package/dist/directory/owner-directory-scope.js +12 -0
- package/dist/directory/owner-directory-search.js +5 -1
- package/dist/directory/owner-directory-store.js +28 -0
- package/dist/ecweb/basic-settings-service.js +15 -1
- package/dist/ecweb/message-context-service.js +2 -2
- package/dist/ecweb/providers-service.js +3 -1
- package/dist/ecweb/runtime/lifecycle.js +26 -15
- package/dist/ecweb/runtime/supervisor.js +120 -51
- package/dist/index.js +551 -250
- package/dist/paths.js +2 -1
- package/dist/proxy/manager.js +40 -17
- package/dist/proxy/service-supervisor.js +67 -33
- package/dist/response-system/engines/v1/proactive-flow.js +4 -0
- package/dist/trigger/application-service.js +4 -1
- package/dist/trigger/audit.js +19 -4
- package/dist/trigger/authorization.js +14 -5
- package/dist/trigger/event-source.js +4 -0
- package/dist/trigger/feedback.js +26 -2
- package/dist/trigger/history.js +176 -7
- package/dist/trigger/manager.js +1 -3
- package/dist/trigger/scheduler.js +81 -8
- package/dist/trigger/system-definitions.js +2 -2
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/autostart.js +2 -2
- package/dist/utils/cross-platform.js +188 -12
- package/dist/utils/host-info.js +11 -8
- package/dist/utils/npm-ops.js +48 -0
- package/dist/utils/process-introspect.js +64 -1
- package/dist/utils/public-suffix.js +5811 -0
- package/dist/utils/startup-trace.js +160 -19
- package/dist/utils/windows-autostart.js +41 -7
- package/ecagent/dist/harness/env/nodejs.js +46 -2
- package/kits/docs/aun/ABILITY_CALLING.md +6 -6
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/channels/feishu.md +2 -2
- package/kits/docs/context-assembly.md +20 -4
- package/kits/docs/evolcore/INDEX.md +5 -3
- package/kits/docs/evolcore/agent.md +2 -2
- package/kits/docs/evolcore/aid.md +8 -2
- package/kits/docs/evolcore/ctl.md +15 -5
- package/kits/docs/evolcore/directory.md +48 -15
- package/kits/docs/evolcore/group.md +8 -8
- package/kits/docs/evolcore/memory-consolidation.md +1 -1
- package/kits/docs/evolcore/menu-exec-schema-commands.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +32 -3
- package/kits/docs/evolcore/msg.md +38 -30
- package/kits/docs/evolcore/provider.md +57 -5
- package/kits/docs/evolcore/response.md +2 -2
- package/kits/docs/evolcore/thread-chain.md +11 -13
- package/kits/docs/evolcore/tool-authorization.md +17 -0
- package/kits/docs/evolcore/trigger.md +2 -2
- package/kits/docs/identity/ROLE_DETAIL.md +1 -1
- package/kits/docs/prompt-loading-architecture.md +30 -20
- package/kits/eck_manifest.auxiliary.json +5 -5
- package/kits/eck_manifest.json +44 -32
- package/kits/eck_manifest.memory.json +18 -18
- package/kits/eck_message_manifest.json +3 -3
- package/kits/rules/01-overview.md +1 -1
- package/kits/rules/06-channel.md +7 -8
- package/kits/schemas/_meta.json +7 -1
- package/kits/schemas/daemon.schema.1.json +5 -0
- package/kits/schemas/daemon.schema.2.json +5 -0
- package/kits/schemas/daemon.schema.3.json +2 -1
- package/kits/schemas/daemon.schema.4.json +2 -1
- package/kits/schemas/daemon.schema.5.json +2 -1
- package/kits/schemas/daemon.schema.6.json +1 -1
- package/kits/schemas/daemon.schema.7.json +1 -1
- package/kits/schemas/daemon.schema.8.json +2 -1
- package/kits/schemas/daemon.schema.9.json +2 -1
- package/kits/schemas/providers.schema.2.json +74 -0
- package/kits/schemas/role-registry.schema.1.json +2 -2
- package/kits/schemas/single-session.schema.1.json +1 -1
- package/kits/schemas/single-session.schema.2.json +1 -1
- package/kits/schemas/single-session.schema.3.json +1 -1
- package/kits/skills/aid-ability/SKILL.md +7 -7
- package/kits/skills/ec-agent-create/SKILL.md +1 -0
- package/kits/skills/ec-group/SKILL.md +8 -5
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +3 -10
- package/kits/skills/ec-trigger/SKILL.md +9 -9
- package/kits/skills/ec-trigger/references/examples.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/system-fragments/channel.md +5 -5
- package/kits/templates/system-fragments/commands.md +7 -6
- package/kits/templates/system-fragments/directory-contacts.md +10 -3
- package/kits/templates/system-fragments/personal-assistant.md +22 -3
- package/kits/templates/system-fragments/reply.md +48 -28
- package/kits/templates/system-fragments/session.md +3 -10
- package/kits/templates/system-fragments/thread.md +5 -5
- package/package.json +4 -4
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 生命周期阶段埋点 —— 记录一次启动或停止里各阶段各花了多久,供 ECWeb 甘特图展示。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLI、重启监控器和 daemon 用同一 traceId 关联:
|
|
5
5
|
* - CLI(ec start / ec stop)source='cli'
|
|
6
6
|
* - Daemon(dist) source='daemon'
|
|
7
7
|
*
|
|
8
8
|
* 启动与停止共用同一套结构,只用 `kind` 区分('startup' / 'stop'):
|
|
9
|
-
*
|
|
9
|
+
* 主流程阶段首尾相接,后台任务可重叠;都用绝对毫秒时间戳对齐。
|
|
10
|
+
* daemon 在控制面 ready 和后台任务结束时追加快照,读取时保留同一进程的最后一版。
|
|
10
11
|
*
|
|
11
12
|
* 起算点(startedAtMs)对启动是本进程启动时刻;对停止是调用方显式传入的
|
|
12
13
|
* 起算点——CLI 传 `ec stop` 的进程启动时刻,daemon 传收到 shutdown 请求的时刻。
|
|
@@ -19,6 +20,78 @@ import fs from 'node:fs';
|
|
|
19
20
|
import path from 'node:path';
|
|
20
21
|
import crypto from 'node:crypto';
|
|
21
22
|
import { resolvePaths } from '../paths.js';
|
|
23
|
+
export const STARTUP_CPU_PROFILE_REQUEST = 'startup-cpu-profile.once';
|
|
24
|
+
export const STARTUP_CPU_PROFILE_MAX_MS = 90_000;
|
|
25
|
+
export async function startRequestedStartupCpuProfile(traceId) {
|
|
26
|
+
const paths = resolvePaths();
|
|
27
|
+
try {
|
|
28
|
+
fs.unlinkSync(path.join(paths.instanceDir, STARTUP_CPU_PROFILE_REQUEST));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error.code !== 'ENOENT') {
|
|
32
|
+
const { logger } = await import('./logger.js');
|
|
33
|
+
logger.warn('[StartupCPU] Failed to consume profiling request', error);
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const { logger } = await import('./logger.js');
|
|
38
|
+
let session;
|
|
39
|
+
try {
|
|
40
|
+
const { Session } = await import('node:inspector/promises');
|
|
41
|
+
session = new Session();
|
|
42
|
+
session.connect();
|
|
43
|
+
await session.post('Profiler.enable');
|
|
44
|
+
await session.post('Profiler.setSamplingInterval', { interval: 1_000 });
|
|
45
|
+
await session.post('Profiler.start');
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
try {
|
|
49
|
+
session?.disconnect();
|
|
50
|
+
}
|
|
51
|
+
catch { }
|
|
52
|
+
logger.warn('[StartupCPU] CPU profiling unavailable; startup continues', error);
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const activeSession = session;
|
|
56
|
+
const startedAt = Date.now();
|
|
57
|
+
const stamp = new Date(startedAt).toISOString().replace(/[-:.]/g, '');
|
|
58
|
+
const file = path.join(paths.logs, `startup-${stamp}-${process.pid}.cpuprofile`);
|
|
59
|
+
let stopping;
|
|
60
|
+
let timer;
|
|
61
|
+
const controller = {
|
|
62
|
+
file,
|
|
63
|
+
stop(reason) {
|
|
64
|
+
return stopping ??= (async () => {
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
const stoppedAt = Date.now();
|
|
67
|
+
try {
|
|
68
|
+
const { profile } = await activeSession.post('Profiler.stop');
|
|
69
|
+
await fs.promises.mkdir(paths.logs, { recursive: true });
|
|
70
|
+
await fs.promises.writeFile(file, JSON.stringify(profile), { encoding: 'utf8', flag: 'wx', mode: 0o600 });
|
|
71
|
+
logger.info(`[StartupCPU] Saved CPU profile: ${file} reason=${reason} durationMs=${stoppedAt - startedAt} traceId=${traceId}`);
|
|
72
|
+
await fs.promises.writeFile(`${file}.json`, JSON.stringify({
|
|
73
|
+
traceId, pid: process.pid, node: process.version, startedAt, stoppedAt,
|
|
74
|
+
durationMs: stoppedAt - startedAt, reason, samplingIntervalUs: 1_000,
|
|
75
|
+
boundary: 'daemon-election-won-to-normal-task-ready',
|
|
76
|
+
}, null, 2), { encoding: 'utf8', flag: 'wx', mode: 0o600 });
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
logger.warn('[StartupCPU] Failed to save CPU profile; startup continues', error);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
try {
|
|
83
|
+
activeSession.disconnect();
|
|
84
|
+
}
|
|
85
|
+
catch { }
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
timer = setTimeout(() => { void controller.stop('timeout'); }, STARTUP_CPU_PROFILE_MAX_MS);
|
|
91
|
+
timer.unref();
|
|
92
|
+
logger.info(`[StartupCPU] One-shot CPU profiling started: ${file} traceId=${traceId}`);
|
|
93
|
+
return controller;
|
|
94
|
+
}
|
|
22
95
|
/** 保留的启动/停止次数(按 traceId 去重后) */
|
|
23
96
|
export const STARTUP_TRACE_KEEP = 50;
|
|
24
97
|
/** CLI 传 traceId 给 daemon 的环境变量,让两侧记录落进同一次启动。 */
|
|
@@ -52,6 +125,9 @@ export class StartupTracer {
|
|
|
52
125
|
cursorStartMs = 0;
|
|
53
126
|
cursorDetail;
|
|
54
127
|
finished = false;
|
|
128
|
+
readyAtMs;
|
|
129
|
+
taskReadyAtMs;
|
|
130
|
+
pendingTasks = new Set();
|
|
55
131
|
constructor(source, opts = {}) {
|
|
56
132
|
this.source = source;
|
|
57
133
|
this.kind = opts.kind ?? 'startup';
|
|
@@ -87,10 +163,64 @@ export class StartupTracer {
|
|
|
87
163
|
this.cursorDetail = detail;
|
|
88
164
|
}
|
|
89
165
|
/** 直接登记一段已测好的区间(用于拿到外部时间戳的场景)。 */
|
|
90
|
-
addSpan(name, startMs, endMs, detail) {
|
|
166
|
+
addSpan(name, startMs, endMs, detail, status) {
|
|
91
167
|
if (this.finished)
|
|
92
168
|
return;
|
|
93
|
-
this.spans.push({ name, startMs, durationMs: Math.max(0, endMs - startMs), ...(detail ? { detail } : {}) });
|
|
169
|
+
this.spans.push({ name, startMs, durationMs: Math.max(0, endMs - startMs), ...(detail ? { detail } : {}), ...(status ? { status } : {}) });
|
|
170
|
+
}
|
|
171
|
+
/** 观察由已有生命周期回调报告完成的任务,不增加轮询或就绪依赖。 */
|
|
172
|
+
startTask(name, detail) {
|
|
173
|
+
if (this.finished)
|
|
174
|
+
return () => { };
|
|
175
|
+
const task = { name, startMs: Date.now(), ...(detail ? { detail } : {}) };
|
|
176
|
+
this.pendingTasks.add(task);
|
|
177
|
+
return (status = 'ok') => {
|
|
178
|
+
if (this.finished || !this.pendingTasks.has(task))
|
|
179
|
+
return;
|
|
180
|
+
this.addSpan(name, task.startMs, Date.now(), detail, status);
|
|
181
|
+
this.pendingTasks.delete(task);
|
|
182
|
+
if (this.readyAtMs !== undefined) {
|
|
183
|
+
if (this.pendingTasks.size === 0)
|
|
184
|
+
this.finish(true);
|
|
185
|
+
else
|
|
186
|
+
this.persist(true);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** 观察实际任务(含依赖等待),保持原有返回值和异常传播。 */
|
|
191
|
+
track(name, run, detail) {
|
|
192
|
+
const settle = this.startTask(name, detail);
|
|
193
|
+
try {
|
|
194
|
+
return run().then(value => {
|
|
195
|
+
settle(value === false ? 'cancelled' : 'ok');
|
|
196
|
+
return value;
|
|
197
|
+
}, error => {
|
|
198
|
+
settle('failed');
|
|
199
|
+
throw error;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
settle('failed');
|
|
204
|
+
return Promise.reject(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** 保存控制面就绪快照;后台任务结束后自动补写同一进程的最新快照。 */
|
|
208
|
+
ready() {
|
|
209
|
+
if (this.finished || this.readyAtMs !== undefined)
|
|
210
|
+
return;
|
|
211
|
+
this.readyAtMs = Date.now();
|
|
212
|
+
this.closeCursor(this.readyAtMs);
|
|
213
|
+
if (this.pendingTasks.size === 0)
|
|
214
|
+
this.finish(true);
|
|
215
|
+
else
|
|
216
|
+
this.persist(true);
|
|
217
|
+
}
|
|
218
|
+
/** 正常启动边界;由实际任务准入条件发布,与控制面早就绪分别记录。 */
|
|
219
|
+
tasksReady() {
|
|
220
|
+
if (this.finished || this.readyAtMs === undefined || this.taskReadyAtMs !== undefined)
|
|
221
|
+
return;
|
|
222
|
+
this.taskReadyAtMs = Date.now();
|
|
223
|
+
this.persist(true);
|
|
94
224
|
}
|
|
95
225
|
/** 瞬时事件(时长为 0 的标记)。 */
|
|
96
226
|
point(name, detail) {
|
|
@@ -115,9 +245,16 @@ export class StartupTracer {
|
|
|
115
245
|
return;
|
|
116
246
|
const now = Date.now();
|
|
117
247
|
this.closeCursor(now);
|
|
248
|
+
for (const task of this.pendingTasks) {
|
|
249
|
+
this.addSpan(task.name, task.startMs, now, task.detail, 'cancelled');
|
|
250
|
+
}
|
|
251
|
+
this.pendingTasks.clear();
|
|
118
252
|
this.finished = true;
|
|
119
253
|
if (this.cursorName)
|
|
120
254
|
this.cursorName = null;
|
|
255
|
+
this.persist(this.readyAtMs !== undefined || ok, now);
|
|
256
|
+
}
|
|
257
|
+
persist(ok, now = Date.now()) {
|
|
121
258
|
const record = {
|
|
122
259
|
traceId: this.traceId,
|
|
123
260
|
kind: this.kind,
|
|
@@ -127,6 +264,14 @@ export class StartupTracer {
|
|
|
127
264
|
startedAt: new Date(this.processStartMs).toISOString(),
|
|
128
265
|
ok,
|
|
129
266
|
totalMs: Math.max(0, now - this.processStartMs),
|
|
267
|
+
...(this.taskReadyAtMs === undefined ? {} : { taskReadyAtMs: this.taskReadyAtMs }),
|
|
268
|
+
...(this.readyAtMs === undefined ? {} : {
|
|
269
|
+
readyAtMs: this.readyAtMs,
|
|
270
|
+
backgroundState: this.pendingTasks.size ? 'pending'
|
|
271
|
+
: this.spans.some(span => span.status === 'failed') ? 'failed'
|
|
272
|
+
: this.spans.some(span => span.status === 'cancelled') ? 'interrupted' : 'complete',
|
|
273
|
+
pendingTasks: [...this.pendingTasks],
|
|
274
|
+
}),
|
|
130
275
|
meta: this.meta,
|
|
131
276
|
spans: this.spans,
|
|
132
277
|
};
|
|
@@ -175,25 +320,18 @@ function trimStartupTrace(file) {
|
|
|
175
320
|
const lines = raw.split('\n').filter(line => line.trim());
|
|
176
321
|
if (lines.length <= STARTUP_TRACE_KEEP * 2 + 20)
|
|
177
322
|
return;
|
|
178
|
-
const
|
|
323
|
+
const latest = new Map();
|
|
179
324
|
for (const line of lines) {
|
|
180
325
|
try {
|
|
181
|
-
const
|
|
326
|
+
const record = JSON.parse(line);
|
|
327
|
+
const id = record.traceId;
|
|
182
328
|
if (id)
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
catch { /* 坏行丢弃 */ }
|
|
186
|
-
}
|
|
187
|
-
const keep = new Set(Array.from(new Set(ids.sort())).slice(-STARTUP_TRACE_KEEP));
|
|
188
|
-
const kept = [];
|
|
189
|
-
for (const line of lines) {
|
|
190
|
-
try {
|
|
191
|
-
const id = JSON.parse(line).traceId;
|
|
192
|
-
if (id && keep.has(id))
|
|
193
|
-
kept.push(line);
|
|
329
|
+
latest.set(`${id}:${record.kind ?? 'startup'}:${record.source}:${record.pid}:${record.startedAtMs}`, { id, line });
|
|
194
330
|
}
|
|
195
331
|
catch { /* 坏行丢弃 */ }
|
|
196
332
|
}
|
|
333
|
+
const keep = new Set([...new Set([...latest.values()].map(record => record.id))].sort().slice(-STARTUP_TRACE_KEEP));
|
|
334
|
+
const kept = [...latest.values()].filter(record => keep.has(record.id)).map(record => record.line);
|
|
197
335
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
198
336
|
fs.writeFileSync(tmp, `${kept.join('\n')}\n`, 'utf-8');
|
|
199
337
|
fs.renameSync(tmp, file);
|
|
@@ -224,7 +362,7 @@ export function formatSlowestSpans(spans, limit = 3, prefixPattern = /^[a-z]+\./
|
|
|
224
362
|
* ——否则 `ec stop` 只报 CLI 的 1.2 秒,真正慢的 18 秒藏在对端。
|
|
225
363
|
*/
|
|
226
364
|
export function findTraceRecord(traceId, source) {
|
|
227
|
-
return readStartupTraces().find(record => record.traceId === traceId && record.source === source) ?? null;
|
|
365
|
+
return readStartupTraces().reverse().find(record => record.traceId === traceId && record.source === source) ?? null;
|
|
228
366
|
}
|
|
229
367
|
/** 读原始记录(ECWeb 侧也有一份独立实现,不复用本文件的路径工具)。 */
|
|
230
368
|
export function readStartupTraces() {
|
|
@@ -247,5 +385,8 @@ export function readStartupTraces() {
|
|
|
247
385
|
}
|
|
248
386
|
catch { /* 坏行跳过 */ }
|
|
249
387
|
}
|
|
250
|
-
|
|
388
|
+
// 同一进程在 ready 和各后台任务完成时追加快照,只读取最后一版。
|
|
389
|
+
return [...new Map(records.map(record => [
|
|
390
|
+
`${record.traceId}:${record.kind ?? 'startup'}:${record.source}:${record.pid}:${record.startedAtMs}`, record,
|
|
391
|
+
])).values()];
|
|
251
392
|
}
|
|
@@ -243,6 +243,27 @@ function taskOwnership(xml, runtimeRoot) {
|
|
|
243
243
|
&& !/<Enabled>\s*false\s*<\/Enabled>/i.test(xml);
|
|
244
244
|
return { managed, current };
|
|
245
245
|
}
|
|
246
|
+
function orphanedTaskMatches(xml, runtimeRoot) {
|
|
247
|
+
const actions = xmlBlocks(xml, 'Actions');
|
|
248
|
+
const entries = actions.length === 1 ? xmlBlocks(actions[0], 'Exec') : [];
|
|
249
|
+
if (entries.length !== 1 || actions[0].replace(/<Exec(?:\s[^>]*)?>[\s\S]*?<\/Exec>/i, '').trim())
|
|
250
|
+
return false;
|
|
251
|
+
const command = xmlElement(entries[0], 'Command');
|
|
252
|
+
const args = xmlElement(entries[0], 'Arguments');
|
|
253
|
+
if (!command || !args
|
|
254
|
+
|| normalizeWindowsPath(command) !== normalizeWindowsPath(powershellPath())
|
|
255
|
+
|| normalizeCommandLine(args) !== normalizeCommandLine(taskArguments(wrapperPath(runtimeRoot))))
|
|
256
|
+
return false;
|
|
257
|
+
return [wrapperPath(runtimeRoot), ...['', '_', '__'].map(suffix => statePath(runtimeRoot) + suffix)].every(file => {
|
|
258
|
+
try {
|
|
259
|
+
fs.lstatSync(file);
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
return error.code === 'ENOENT';
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
246
267
|
function probeWindowsTask(runtimeRoot, action = '启用') {
|
|
247
268
|
const result = runSchtasks(['/Query', '/TN', WINDOWS_AUTOSTART_TASK_NAME, '/XML']);
|
|
248
269
|
if (result.status === 0) {
|
|
@@ -533,7 +554,7 @@ function disableWindowsAutostart(runtimeRoot) {
|
|
|
533
554
|
: {}),
|
|
534
555
|
};
|
|
535
556
|
}
|
|
536
|
-
export function configureWindowsAutostart(enabled, runtimeRoot) {
|
|
557
|
+
export function configureWindowsAutostart(enabled, runtimeRoot, options = {}) {
|
|
537
558
|
if (!isWindows()) {
|
|
538
559
|
return {
|
|
539
560
|
ok: !enabled,
|
|
@@ -562,12 +583,18 @@ export function configureWindowsAutostart(enabled, runtimeRoot) {
|
|
|
562
583
|
error: previousTask.error,
|
|
563
584
|
};
|
|
564
585
|
}
|
|
565
|
-
|
|
586
|
+
const repairingTask = previousTask.state === 'installed' && !previousTask.managed
|
|
587
|
+
&& orphanedTaskMatches(previousTask.xml, absoluteRoot)
|
|
588
|
+
&& options.confirmedTaskXml === previousTask.xml;
|
|
589
|
+
if (previousTask.state === 'installed' && !previousTask.managed && !repairingTask) {
|
|
566
590
|
return {
|
|
567
591
|
ok: false,
|
|
568
592
|
enabled: false,
|
|
569
593
|
nonFatal: true,
|
|
570
|
-
error: `已存在同名计划任务 \\${WINDOWS_AUTOSTART_TASK_NAME}
|
|
594
|
+
error: `已存在同名计划任务 \\${WINDOWS_AUTOSTART_TASK_NAME},无法确认属于当前 EvolCore 安装;为避免覆盖已停止配置。`,
|
|
595
|
+
...(orphanedTaskMatches(previousTask.xml, absoluteRoot)
|
|
596
|
+
? { repairTask: { xml: previousTask.xml, wrapperPath: scriptPath } }
|
|
597
|
+
: {}),
|
|
571
598
|
};
|
|
572
599
|
}
|
|
573
600
|
let previousWrapper;
|
|
@@ -656,6 +683,12 @@ export function configureWindowsAutostart(enabled, runtimeRoot) {
|
|
|
656
683
|
error: `启动脚本 ${scriptPath} 已存在但不属于 EvolCore;为避免覆盖已停止配置。`,
|
|
657
684
|
};
|
|
658
685
|
}
|
|
686
|
+
if (repairingTask) {
|
|
687
|
+
const latest = probeWindowsTask(absoluteRoot);
|
|
688
|
+
if (latest.state !== 'installed' || latest.xml !== options.confirmedTaskXml || !orphanedTaskMatches(latest.xml, absoluteRoot)) {
|
|
689
|
+
return { ok: false, enabled: false, error: '确认后计划任务或本地文件已变化,已取消重建;请重新检查并确认。' };
|
|
690
|
+
}
|
|
691
|
+
}
|
|
659
692
|
try {
|
|
660
693
|
writeWrapper(scriptPath, desiredContent);
|
|
661
694
|
}
|
|
@@ -671,7 +704,7 @@ export function configureWindowsAutostart(enabled, runtimeRoot) {
|
|
|
671
704
|
}
|
|
672
705
|
const taskBeforeCreate = probeWindowsTask(absoluteRoot);
|
|
673
706
|
if (taskBeforeCreate.state === 'error') {
|
|
674
|
-
const restoreError = restoreWrapperUnlessNeeded(scriptPath, previousWrapper, previousTask.state === 'installed' || (existingRun.state === 'installed' && existingRun.managed));
|
|
707
|
+
const restoreError = restoreWrapperUnlessNeeded(scriptPath, previousWrapper, (!repairingTask && previousTask.state === 'installed') || (existingRun.state === 'installed' && existingRun.managed));
|
|
675
708
|
const rollbackSuffix = restoreError ? `;恢复原启动脚本失败:${restoreError}` : '';
|
|
676
709
|
return {
|
|
677
710
|
ok: false,
|
|
@@ -680,7 +713,8 @@ export function configureWindowsAutostart(enabled, runtimeRoot) {
|
|
|
680
713
|
error: `创建计划任务前的复核失败:${taskBeforeCreate.error}${rollbackSuffix}`,
|
|
681
714
|
};
|
|
682
715
|
}
|
|
683
|
-
if (taskBeforeCreate.state
|
|
716
|
+
if ((repairingTask && (taskBeforeCreate.state !== 'installed' || taskBeforeCreate.xml !== options.confirmedTaskXml))
|
|
717
|
+
|| (taskBeforeCreate.state === 'installed' && !taskBeforeCreate.managed)) {
|
|
684
718
|
const restoreError = restoreWrapperUnlessNeeded(scriptPath, previousWrapper, existingRun.state === 'installed' && existingRun.managed);
|
|
685
719
|
const rollbackSuffix = restoreError ? `;恢复原启动脚本失败:${restoreError}` : '';
|
|
686
720
|
return {
|
|
@@ -727,9 +761,9 @@ export function configureWindowsAutostart(enabled, runtimeRoot) {
|
|
|
727
761
|
error: `${taskError}${fallbackError}${rollbackSuffix}`,
|
|
728
762
|
};
|
|
729
763
|
}
|
|
730
|
-
const restoreError = restoreWrapperUnlessNeeded(scriptPath, previousWrapper, taskBeforeCreate.state === 'installed' || (existingRun.state === 'installed' && existingRun.managed));
|
|
764
|
+
const restoreError = restoreWrapperUnlessNeeded(scriptPath, previousWrapper, (!repairingTask && taskBeforeCreate.state === 'installed') || (existingRun.state === 'installed' && existingRun.managed));
|
|
731
765
|
const rollbackSuffix = restoreError ? `;恢复原启动脚本失败:${restoreError}` : '';
|
|
732
|
-
const previousBackend = taskBeforeCreate.state === 'installed'
|
|
766
|
+
const previousBackend = !repairingTask && taskBeforeCreate.state === 'installed'
|
|
733
767
|
? 'task'
|
|
734
768
|
: existingRun.state === 'installed' && existingRun.managed
|
|
735
769
|
? 'user-run'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { constants, createReadStream } from "node:fs";
|
|
3
|
+
import { constants, createReadStream, readdirSync, readFileSync } from "node:fs";
|
|
4
4
|
import { access, appendFile, lstat, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile, } from "node:fs/promises";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { isAbsolute, join, resolve } from "node:path";
|
|
@@ -210,6 +210,36 @@ function killProcessTree(pid) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
+
/** Pipe closure is not an exit acknowledgement for the other group members. */
|
|
214
|
+
async function waitForLinuxProcessGroupExit(groupId) {
|
|
215
|
+
const deadline = performance.now() + 2000;
|
|
216
|
+
while (true) {
|
|
217
|
+
let running = false;
|
|
218
|
+
for (const entry of readdirSync("/proc")) {
|
|
219
|
+
if (!/^\d+$/.test(entry))
|
|
220
|
+
continue;
|
|
221
|
+
let stat;
|
|
222
|
+
try {
|
|
223
|
+
stat = readFileSync(`/proc/${entry}/stat`, "utf8");
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
if (["ENOENT", "ESRCH"].includes(error.code ?? ""))
|
|
227
|
+
continue;
|
|
228
|
+
throw error;
|
|
229
|
+
}
|
|
230
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
231
|
+
if (Number(fields[2]) === groupId && fields[0] !== "Z" && fields[0] !== "X") {
|
|
232
|
+
running = true;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (!running)
|
|
237
|
+
return;
|
|
238
|
+
if (performance.now() >= deadline)
|
|
239
|
+
throw new Error("Signalled process group did not exit within 2000ms");
|
|
240
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
213
243
|
export class NodeExecutionEnv {
|
|
214
244
|
constructor(options) {
|
|
215
245
|
this.cwd = options.cwd;
|
|
@@ -366,9 +396,23 @@ export class NodeExecutionEnv {
|
|
|
366
396
|
processExited = true;
|
|
367
397
|
releaseOutput();
|
|
368
398
|
});
|
|
369
|
-
child.on("close", (code) => {
|
|
399
|
+
child.on("close", async (code) => {
|
|
400
|
+
// Cleanup may outlive the command deadline; retain the reason that
|
|
401
|
+
// closed the execution rather than timing out an aborted cleanup.
|
|
402
|
+
if (timeoutId)
|
|
403
|
+
clearTimeout(timeoutId);
|
|
370
404
|
stdout += pendingStdout;
|
|
371
405
|
stderr += pendingStderr;
|
|
406
|
+
if (interrupted && process.platform === "linux" && child?.pid) {
|
|
407
|
+
try {
|
|
408
|
+
await waitForLinuxProcessGroupExit(child.pid);
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
const cause = toError(error);
|
|
412
|
+
settle(err(new ExecutionError("unknown", cause.message, cause)));
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
372
416
|
if (callbackError) {
|
|
373
417
|
settle(err(callbackError));
|
|
374
418
|
return;
|
|
@@ -100,23 +100,23 @@ Agent 可以用该说明理解 Provider 特有的调用流程,但它仍是远
|
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
```text
|
|
103
|
-
|
|
103
|
+
ecmsg send --to <provider-aid> --payload-file <discover-json-file> --encrypt yes --return required --timeout 5s --format json
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
window_seconds 范围为 1–30,payload ttl 必须等于窗口,`--timeout` 取同一窗口。发送时补入 sent_at。Core 在窗口结束前保留各认证来源设备的结果,首条返回不结束等待;结果位于 responses / request.responses,逐项读取 responsePayload.result.capabilities,条目使用 path。设备身份取 responseDeviceId,不信任 payload 自报的 devices。零回包是 pending,不能据此确认全部设备离线。
|
|
107
107
|
|
|
108
108
|
## 原始 payload
|
|
109
109
|
|
|
110
|
-
`
|
|
110
|
+
`ecmsg send --payload` 直接透传 JSON,不为 Ability 添加 `text`、`chatmode` 或其它聊天字段。
|
|
111
111
|
Windows 或复杂 JSON 优先使用 `--payload-file`:通过文件工具把原始 UTF-8 JSON 写入当前会话
|
|
112
112
|
`$TMPDIR`,再单独执行发送。PowerShell 路径用 `"$env:TMPDIR/obs_payload.json"`,Git Bash 用
|
|
113
113
|
`"$TMPDIR/obs_payload.json"`;文件内容不加 Shell 转义。该选项与 `--payload` 及位置文本互斥,
|
|
114
114
|
设备选择、加密和请求等待规则相同,详见 `../evolcore/msg.md`。
|
|
115
|
-
在当前 Windows PowerShell 托管环境中,`
|
|
115
|
+
在当前 Windows PowerShell 托管环境中,`ecmsg` 的 `--payload` 使用单引号包裹,并在 JSON 内每个
|
|
116
116
|
双引号前加反斜杠,例如:
|
|
117
117
|
|
|
118
118
|
```text
|
|
119
|
-
|
|
119
|
+
ecmsg send --to <provider-aid> --payload '{\"type\":\"ability\",\"role\":\"call\",\"call_id\":\"<call-id>\",\"operation_id\":\"<operation-id>\",\"ability_path\":\"<path>\",\"definition_id\":\"<definition-id>\",\"params\":{},\"ttl\":<ttl-seconds>,\"async\":false}' --device-id <provider-device-id> --encrypt yes --return required --timeout <ttl-seconds>s --format json
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
`device/status` 且 `params.action=read` 是 AID 级在线设备状态查询,命令不要带 `--device-id`,
|
|
@@ -136,7 +136,7 @@ payload/params 也不指定设备。各支持并已发布该能力的在线设
|
|
|
136
136
|
payload 没有 `sent_at` 时,EvolCore 在实际发送前自动补当前 Unix 毫秒时间戳,Caller 不需要
|
|
137
137
|
自己取当前时间。时限按下方“时限估算”确定。
|
|
138
138
|
EvolApp v1 必须使用 `--encrypt`;不能沿用普通聊天的明文 `[reply]` 设置。
|
|
139
|
-
这套转义只针对当前 PowerShell 到 `
|
|
139
|
+
这套转义只针对当前 PowerShell 到 `ecmsg` 的调用链,不直接套用到其他 Shell。
|
|
140
140
|
|
|
141
141
|
Ability 调用通常由业务协议提供:
|
|
142
142
|
|
|
@@ -228,7 +228,7 @@ Provider 还可能发送 Ability `role=ack` 表示已受理调用。EvolCore 将
|
|
|
228
228
|
默认等待时间为 60 秒,可由调用方传入 `--timeout` 覆盖。例如:
|
|
229
229
|
|
|
230
230
|
```text
|
|
231
|
-
|
|
231
|
+
ecmsg send --to <provider-aid> --payload '<camera-call-json>' --device-id <provider-device-id> --encrypt yes --return required --timeout 120s --format json
|
|
232
232
|
```
|
|
233
233
|
|
|
234
234
|
上述请求实际使用顶层 `message.send.ttl=120`。正 TTL 消息只保存在 AUN 消息服务内存中,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# AUN 渠道
|
|
2
2
|
|
|
3
3
|
> 知识性文档:AUN 渠道的配置、参数与特有机制。**不依赖当前会话渠道**——任意会话都可按需 Read。
|
|
4
|
-
> 运行时回复方式由共用 `[reply]` 段按实际 chatMode 决定;active 的 `[channel]` 补充文件、链接、@ 等能力。AUN 主动发送使用托管的 `
|
|
4
|
+
> 运行时回复方式由共用 `[reply]` 段按实际 chatMode 决定;active 的 `[channel]` 补充文件、链接、@ 等能力。AUN 主动发送使用托管的 `ecmsg send`。
|
|
5
5
|
> 群聊使用 `evolcore/group.md`;群文件使用 `evolcore/fs.md`。
|
|
6
6
|
|
|
7
7
|
## 概述
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 飞书渠道
|
|
2
2
|
|
|
3
3
|
> 知识性文档:飞书渠道的配置、参数与特有机制。**不依赖当前会话渠道**——任意会话都可按需 Read(在 aun 会话里也可查飞书)。
|
|
4
|
-
> 运行时回复方式由共用 `[reply]` 段按实际 chatMode 决定:interactive 由 evolcore 自动投递普通输出,proactive 用 `
|
|
4
|
+
> 运行时回复方式由共用 `[reply]` 段按实际 chatMode 决定:interactive 由 evolcore 自动投递普通输出,proactive 用 `ecmsg send` 正式回复;active 的 `[channel]` 补充文件等能力。
|
|
5
5
|
|
|
6
6
|
## 概述
|
|
7
7
|
|
|
@@ -53,4 +53,4 @@ agent 级(config.json 顶层)相关开关:
|
|
|
53
53
|
- **合并转发解析**:飞书的 `merge_forward` 消息会被自动展开为文本注入上下文(含"以下是引用的原消息"包裹)。
|
|
54
54
|
- **交互卡片**:命令和交互请求可使用飞书卡片发送;卡片按钮**仅发起者可操作**,他人点击返回提示。
|
|
55
55
|
- **身份体系**:对端以 `user_id` 标识,关系层 peerKey 形如 `feishu#ou_xxx`。
|
|
56
|
-
- **自动回复**:飞书是非 aun 渠道,回复由 evolcore
|
|
56
|
+
- **自动回复**:飞书是非 aun 渠道,回复由 evolcore 自动完成;主动回复用 `ecmsg send '<text>'`。
|
|
@@ -303,13 +303,17 @@ coding 场景(无 channel/无身份)下,`chatType`、`channel`、`selfAid`
|
|
|
303
303
|
|
|
304
304
|
常规段均要求 `lifecycle=active`,下表的其它条件在此基础上叠加;Bootstrap 引导与共用回复段单独列出完整条件。
|
|
305
305
|
|
|
306
|
-
| order | id | 类型 | 加载条件(when) |
|
|
306
|
+
| order | id | 类型 | 加载条件(when) | 模板渲染 |
|
|
307
307
|
|-------|----|----|------------------|--------|
|
|
308
308
|
| 10 | rules | 目录 `$KITS_RULES` | active | ✗ |
|
|
309
309
|
| 15 | bootstrap-guide | `bootstrap.md` | lifecycle=bootstrapping | ✓ |
|
|
310
310
|
| 20 | identity-layer | fragment | active 且 chatType≠null | ✓ |
|
|
311
|
+
| 20.5 | skills-builtin | `$AGENT_DIR/skills/.index-builtin.md` | active(缺文件则跳过) | ✗ |
|
|
312
|
+
| 20.6 | skills-local | `$AGENT_DIR/skills/.index-local.md` | active(缺文件则跳过) | ✗ |
|
|
311
313
|
| 21 | soul | 目录 `$PERSONAL_DIR/soul`(`*.md`) | active 且 chatType≠null | ✗ |
|
|
312
|
-
|
|
|
314
|
+
| 28 | owner-directory | `$AGENT_DIR/directory/directory.md` | active 且 hasOwnerDirectory=true | ✗ |
|
|
315
|
+
| 29.4 | contacts-profile | fragment | active 且 hasOwnerDirectory=true 且 isPersonalAssistant≠true | ✓ |
|
|
316
|
+
| 29.5 | pa-profile | fragment | active 且 hasOwnerDirectory=true 且 isPersonalAssistant=true | ✓ |
|
|
313
317
|
| 30 | relation-layer | fragment | active 且 chatType∈{private,group} | ✓ |
|
|
314
318
|
| 35 | memory | `$KITS_FRAGMENTS/memory.md` | active 且 memoryEnableRelation≠false | ✓ |
|
|
315
319
|
| 36 | agent-memory | `$PERSONAL_DIR/memory/MEMORY.md` | active 且 memoryEnableAgent≠false | ✗ |
|
|
@@ -318,18 +322,30 @@ coding 场景(无 channel/无身份)下,`chatType`、`channel`、`selfAid`
|
|
|
318
322
|
| 40 | venue-fragment | fragment | active 且 chatType≠null | ✓ |
|
|
319
323
|
| 41 | venue-chattype | `$KITS_DOCS/venues/{{chatType}}.md` | active 且 chatType≠null | ✗ |
|
|
320
324
|
| 42 | venue-channel-chattype | `$KITS_DOCS/venues/{{channel}}-{{chatType}}.md` | active 且 chatType≠null | ✗ |
|
|
325
|
+
| 42.5 | group-history | fragment | active 且 channel=aun 且 chatType=group 且 groupHistoryAvailable=true | ✓ |
|
|
321
326
|
| 43.2 | relation-group-rules | `$RELATIONS_DIR/{{peerKey}}/rules.md` | active 且 groupRulesPath≠null | ✗ |
|
|
322
327
|
| 44 | venue-client | `$KITS_DOCS/venues/client-{{clientType}}.md` | active 且 clientType≠null | ✗ |
|
|
328
|
+
| 46 | thread | fragment | active 且 chatType∈{private,group} | ✗ |
|
|
323
329
|
| 49 | reply-contract | `reply.md` | channel≠null 且 lifecycle∈{active,bootstrapping} | ✓ |
|
|
324
330
|
| 50 | channel-layer | fragment | active 且 channel≠null | ✓ |
|
|
325
331
|
| 55 | commands | fragment | active 且 channel≠null | ✓ |
|
|
326
332
|
| 60 | session | fragment | active | ✓ |
|
|
327
333
|
| 70 | baseagent | fragment | active 且 baseAgent≠null | ✓ |
|
|
334
|
+
| 75 | bash-description | fragment | baseAgent∈{claude,ecagent} 且 lifecycle∈{active,bootstrapping} | ✓ |
|
|
328
335
|
| 80 | managed-runtime-notice | fragment | active | ✓ |
|
|
329
336
|
|
|
330
337
|
Bootstrap 只加载引导与有渠道时的最小通信上下文 `[reply]`,不加载完整身份/关系/渠道能力、个人记忆或普通任务命令。
|
|
331
338
|
`[reply]` 展示 selfAid、peerId、peerType、channel、chatType、chatMode;未知身份显示 unknown,回复方式只取运行时已解析的 chatMode,不从身份或私聊场景重新推断。命令经当前会话 delegated sender / daemon IPC 发送,遵守现有身份、目标、话题与加密约束。
|
|
332
|
-
`needsInjection`
|
|
339
|
+
`needsInjection` 仅是是否进行模板渲染的布尔开关,不是变量白名单,也不是注入开关:为 `false` 的段照样进上下文,只是内容原样输出、不展开 `{{...}}`。
|
|
340
|
+
|
|
341
|
+
### `description` 的用法
|
|
342
|
+
|
|
343
|
+
`description` 不是正文摘要,是 **section 的名字**——用来在对话里口头对指「哪一段」,以及作为每个文件内容的标题行出现在上下文里。写作口径:
|
|
344
|
+
|
|
345
|
+
- 写概念名(`身份层`、`对端记忆`、`群规则`),不写里面讲了什么,不写生效条件,不写维护者须知。
|
|
346
|
+
- 同一 `id` 在三份 manifest 里用同一个名字(`soul`、`memory` 这类段在不同会话侧重不同,但名字不跟着变)。
|
|
347
|
+
- 不写模板变量:`description` 不经过 `renderTemplate`,`{{...}}` 会原样输出。
|
|
348
|
+
- 目录段每个文件都带一次标题,名字越短越好。
|
|
333
349
|
|
|
334
350
|
> **v3 移除的段**:`order 22` working-memory、`23` preferences、`34` relation-working-memory、`35` peer-profile、`36.5` owner-working-memory 已从 manifest 删除。这些内容分别由 `memory-tags.md` 里的状态标签与 `profile` 标签的记忆取代。详见 `docs/memory/memory-system-v3.md`。
|
|
335
351
|
|
|
@@ -364,7 +380,7 @@ $KITS_DOCS/venues/ 通用环境文档(随包发布,只读
|
|
|
364
380
|
<system-reminder>
|
|
365
381
|
EvolCore Context Kit documents are shown below.
|
|
366
382
|
|
|
367
|
-
Contenu de <展示路径> (<id — description>):
|
|
383
|
+
Contenu de <展示路径> (<id — description>): ← description 即上文说的 section 名字
|
|
368
384
|
|
|
369
385
|
<文件内容>
|
|
370
386
|
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
运行时 evolcore 会通过 `commands` fragment 按当前场景(有无 peer/group、对端角色)
|
|
5
5
|
注入一张精简能力卡,指向本目录下对应文档;需要完整用法时 Read 对应文档。
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> 对外发送统一走 `ecmsg`(本端恒为当前会话本端,不写 `--from`);
|
|
8
|
+
> 当前渠道是否需要 CLI 回复,以运行时注入的
|
|
8
9
|
> `[reply]` 规则为准,active 的 `[channel]` 补充扩展能力。参数不是全局通用的:`--format json` 仅用于对应帮助中明确支持的命令,
|
|
9
10
|
> `--app <name>` 仅用于消息 pull/ack、消费类 RPC 和明确支持 app slot 的文件操作。
|
|
10
11
|
|
|
@@ -32,11 +33,12 @@ ECWeb 托管重启、端口占用与升级失败处理见 `ecweb-lifecycle.md`
|
|
|
32
33
|
|
|
33
34
|
Windows 上 Codex 托管任务出现 `helper_sandbox_lock_failed`、`SetNamedSecurityInfoW ... 5`、`unelevated ... cannot enforce deny-read` 或 daemon 管道 `EPERM` 时,参见 `codex-windows-sandbox.md`。
|
|
34
35
|
|
|
35
|
-
## 对外通信 / 网络类(连 AUN
|
|
36
|
+
## 对外通信 / 网络类(连 AUN,发送统一走 `ecmsg`)
|
|
36
37
|
|
|
37
38
|
| 命令集 | 用途 | 触发词 | 适用场景 | 文档 |
|
|
38
39
|
|--------|------|--------|----------|------|
|
|
39
|
-
| `
|
|
40
|
+
| `ecmsg` | **发送消息的统一入口**(当前会话 / `--thread` 跨话题 / `--to` 指定对端) | 回复/发消息/发文件/发链接/payload/加密/跨话题 | 有对端(peerId) | `msg.md` |
|
|
41
|
+
| `ec msg` | 私聊消息底层命令(宿主终端与历史兼容);托管会话内的发送用 `ecmsg` | 回复/发消息/拉取/撤回/查在线/payload-file/请求等待/结果查询/request_id/call_id | 有对端(peerId) | `msg.md` |
|
|
40
42
|
| `ec thread` | 话题管理与话题链 | 话题/thread/跨会话/委托/话题链/ThreadOrigin/summary/删除话题 | 有对端(私聊或群聊) | `thread-chain.md` |
|
|
41
43
|
| `ec group` | 群聊收发与群管理 | 群发/建群/本地群历史/邀请/踢人/退群/群成员/角色/封禁/屏蔽/成员状态/规则/@提及模式/协作 | AUN 群;可从私聊发起协作 | `group.md`;协作流程用 `ec-group-collaboration` 技能 |
|
|
42
44
|
| `/invites` / `ec group invites` | 收到群邀请、Owner 卡片审核与恢复 | 入群邀请/接受邀请/拒绝邀请/审核卡片/待处理邀请 | 当前 Agent Owner 的 AUN 私聊 | `group.md` |
|
|
@@ -36,7 +36,7 @@ ec agent new <aid> [--initialize] ...
|
|
|
36
36
|
|
|
37
37
|
# 创建 agent 并进入 Bootstrap
|
|
38
38
|
ec agent new <aid> --bootstrap [--non-interactive] \
|
|
39
|
-
[--project <路径>] [--baseagent claude|codex|gemini|ecagent] \
|
|
39
|
+
[--project <路径>] [--baseagent claude|codex|gemini|ecagent] [--provider <id>] \
|
|
40
40
|
[--owner <aid>] [--name "<显示名>"] [--description "<text>"] \
|
|
41
41
|
[--tags '<json-array>'] \
|
|
42
42
|
[--dry-run] [--force]
|
|
@@ -46,7 +46,7 @@ ec agent new <aid> --non-interactive ...
|
|
|
46
46
|
|
|
47
47
|
# 显式指定一次性初始化(隐含 --non-interactive)
|
|
48
48
|
ec agent new <aid> --initialize \
|
|
49
|
-
--project <路径> --baseagent <claude|codex|gemini|ecagent> \
|
|
49
|
+
--project <路径> --baseagent <claude|codex|gemini|ecagent> [--provider <id>] \
|
|
50
50
|
--owner <aid> --name "<显示名>" --description "<text>" \
|
|
51
51
|
--tags '<json-array>' [--persona-file <path> | --persona-text <text>] \
|
|
52
52
|
[--wait <seconds>] [--dry-run]
|
|
@@ -64,9 +64,11 @@ SDK 不持久化 Ownership task/WAL;`OwnershipTaskResult` 只是本次调用
|
|
|
64
64
|
ec aid bind status --subject <接收方本地AID> --format json
|
|
65
65
|
ec aid bind accept <operationId> --subject <接收方本地AID> --format json
|
|
66
66
|
ec aid bind reject <operationId> --subject <接收方本地AID> --reason '用户拒绝' --format json
|
|
67
|
+
ec aid bind reject --reset <ownerAid> --subject <发起绑定的本地AgentAID> --format json
|
|
67
68
|
```
|
|
68
69
|
|
|
69
70
|
`--subject` 始终指定执行审批的本地 AID。省略时,独立 CLI 使用 daemon Control AID,托管会话使用当前 self AID。
|
|
71
|
+
`reject --reset` 清除指定本地 Agent 对指定 Owner 的自动邀约拒绝记录,返回 `rejectionReset.ownerAid/cleared`,重复清除无副作用,并记录 `EC_OWNERSHIP` 的 `rejection.reset`。它沿用绑定变更的授权,只清本地记录及对应的拒绝任务投影,不发送邀约、不改变协议关系,也不重置当前进程的一次自动提交限制;需要立即重试时显式执行 `ec aid bind <ownerAid>`。尚未挂载 SDK client 的本地 Agent 也可通过获准管理入口清除此记录。
|
|
70
72
|
例如 B 请求由 A 担任 Owner,在 A 上确认时应选 `--subject A`。A 的状态中 `requests` 展示 SDK 已验证的
|
|
71
73
|
待确认绑定任务,包括 `operation_id`、`sub_aid`、`owner_aid`、`requester_aid`、本端 `local_role` 和关系版本。
|
|
72
74
|
本端既可以是拟任 Owner,也可以是接受 Owner 绑定的 sub;转让请求也通过这个入口审批,解绑和未验证请求不通过该入口。
|
|
@@ -137,9 +139,13 @@ Owner 目录同步在连接可用时建立单条核验和暂态故障退避链
|
|
|
137
139
|
|
|
138
140
|
Ownership 任务事件、修改本地 Owner 配置、相关名片或 Owner 关系材料变更只失效缓存,不主动发起复核。连接首次就绪、断线恢复和缓存到期均不触发提前刷新;下次实际消息、查询或授权需要 Owner 时才等待核验。相同任务事件和连接通知去重,无关对端、普通文件变更不触发失效。远端 Owner 的 Storage 事件只在本机确实收到时生效,不能假定事件完整覆盖远端变化。Owner 绑定提交前及修改 Owner 的授权仍要求显式核验成功。
|
|
139
141
|
|
|
140
|
-
|
|
142
|
+
生命周期有效的普通 Agent(包括已经 `active` 的存量 Agent)在 AUN 连接就绪后,优先取根级 `config.json.owner`,缺失时兼容旧 `owners` 数组的首个非空 AID;沿用首个配置 Owner 的选择规则,不向数组内所有 AID 发送邀约。没有绑定目标或生命周期无效时静默跳过。存在绑定目标且新鲜协议状态为 `unbound`、`released` 或 `single_sided` 时,每个 Agent 对同一 Owner 在本进程内最多自动提交一次绑定邀约,`active` 不再阻断启动补绑定。已有协议共识时不提交,也不自动转让 Owner。提交前记录 INFO 日志 `Submitting configured Owner binding invitation`,包含主体、目标 Owner 和协议状态;提交结果与失败继续记录 `EC_OWNERSHIP` 的 `bind.result` / `bind.failed`。等待确认、提交失败或回执不明均不定时重发,断线重连和渠道重建也不会再次提交;需要重发时显式执行绑定命令。自动尝试记录只保存在内存,不持久化;进程重启后重新检查并允许再自动提交一次。
|
|
141
143
|
|
|
142
|
-
|
|
144
|
+
普通 Agent 的创建、手动绑定、启动补绑定和转让,在提交关系修改前实时读取目标 Owner 的远端已验签名片,要求名片 AID 匹配且 `type: human`;非 human 返回 `INVALID_OWNER`,无法读取、未验签、类型缺失或名片不匹配返回 `OWNER_IDENTITY_UNAVAILABLE`。接受绑定或转让邀约也执行此限制;当前进程没有请求投影时,先从历史消息定位原请求的目标用于类型预检,原请求真实性及固定参与方仍由 SDK 在提交时核验。拒绝邀约不受目标类型限制。该限制面向普通 Agent,不把 daemon Control AID 的身份规则改成 Agent 规则,也不追溯修改已有协议关系。
|
|
145
|
+
|
|
146
|
+
整批删除旧配置后的冷启动不依赖静态 Owner 回退。普通入站、出站(包括持久发件箱)和敏感操作在实际需要时等待协议核验;核验前、查询失败或确认 `unbound/released` 时不授予 Owner 准入。敏感操作核验成功后按新鲜协议关系重建授权角色,避免沿用冷启动时的访客身份。不新增启动预刷新或定时重试。
|
|
147
|
+
|
|
148
|
+
每次提交前重读配置并检查连接是否仍有效。查询失败不消耗自动提交机会、不安排定时重试,可在后续连接就绪时重新检查。收到 SDK 验证的绑定拒绝事件或明确拒绝回执后,按 Agent 和 Owner 持久化拒绝记录;进程重启后也不再自动向该 Owner 发邀约。拒绝记录仅限制自动邀约,仍可显式执行绑定命令重新发起。超时、网络错误和其它失败不作为拒绝持久化。只有当前锁定、未失效且核验时间不超过 5 分钟的协议共识确认绑定后,才在同一次原子配置修改中整批删除根级标量 `owner` 和整个 `owners[]`,数组内其它旧值也一并删除,不单独安排过渡;其它配置字段保留。提交邀约或等待审批时保留两个字段。清理兼容字段不会撤销当前已核验的协议 Owner;后续冷启动通过协议核验恢复 Owner。
|
|
143
149
|
|
|
144
150
|
根级 `config.json.owner/owners` 在初次 Ownership 绑定前兼容现有 Owner 执行来源,同时作为绑定目标。Ownership 2.1 达成共识后,Owner 角色、权限校验、有效 Owner 列表和运行时配置投影只读取协议核验结果;手动重新写入这些配置字段不会恢复 Owner 权限。暂态故障容错仅使用本进程已成功核验的关系,配置值不能替代协议核验;尚未建立协议关系时仍保留兼容 Owner 行为。
|
|
145
151
|
|