evolcore 0.0.43-test.1 → 0.0.43-test.3
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 +31 -1
- package/README.md +22 -0
- package/dist/agents/claude-runner.js +26 -2
- package/dist/agents/codex/app-server-client.js +12 -0
- package/dist/agents/codex-runner.js +49 -8
- package/dist/agents/ecagent-runner.js +39 -15
- package/dist/agents/gemini-runner.js +15 -12
- package/dist/agents/tool-time-context.js +55 -0
- package/dist/aun/aid/agentmd.js +21 -1
- package/dist/aun/menu/client.js +1 -1
- package/dist/aun/model-headers.js +17 -0
- package/dist/aun/msg/p2p.js +7 -2
- package/dist/channels/aun.js +522 -50
- package/dist/channels/builtin-plugins.js +16 -11
- package/dist/channels/daemon.js +4 -0
- package/dist/channels/dingtalk.js +83 -31
- package/dist/channels/feishu.js +29 -13
- package/dist/channels/qqbot.js +32 -11
- package/dist/channels/wechat.js +13 -3
- package/dist/channels/wecom.js +67 -27
- package/dist/cli/agent-command.js +3 -86
- package/dist/cli/agent-create.js +20 -6
- package/dist/cli/agent.js +1 -79
- package/dist/cli/aun-commands.js +18 -19
- package/dist/cli/config.js +1 -1
- package/dist/cli/daemon-commands.js +47 -2
- package/dist/cli/data-command.js +9 -1
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/diag.js +1 -1
- package/dist/cli/directory.js +149 -91
- package/dist/cli/getmeta-command.js +1 -1
- package/dist/cli/index.js +79 -22
- package/dist/cli/init.js +1 -23
- package/dist/cli/link-rules.js +1 -1
- package/dist/cli/managed-command-guard.js +0 -1
- package/dist/cli/pa-workspace-command.js +36 -2
- package/dist/cli/peer.js +3 -2
- package/dist/cli/restart-monitor.js +17 -3
- package/dist/cli/role.js +1 -1
- package/dist/cli/session-command.js +1 -1
- package/dist/cli/stats.js +2 -2
- package/dist/cli/task-context.js +3 -1
- package/dist/cli/thread-command.js +1 -1
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +7 -2
- package/dist/config/config-manager.js +32 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +29 -4
- package/dist/config/role-service.js +12 -7
- package/dist/config/role-store.js +30 -8
- package/dist/config-store.js +75 -4
- package/dist/core/agent-ipc-registration.js +16 -59
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/authorization-audit.js +52 -14
- package/dist/core/auth/operation-authorizer.js +17 -11
- package/dist/core/auth/operation-catalog.js +5 -13
- package/dist/core/channel-loader.js +152 -16
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +2 -1
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/cli-intent-parser.js +0 -8
- package/dist/core/command/command-handler.js +47 -40
- package/dist/core/command/connect-menu.js +7 -3
- package/dist/core/command/menu-catalog.js +16 -2
- package/dist/core/command/menu-handler.js +107 -14
- package/dist/core/command/menu-protocol.js +28 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +139 -51
- package/dist/core/daemon-file-cache.js +3 -3
- package/dist/core/daemon-lifecycle.js +9 -1
- package/dist/core/evolagent-registry.js +5 -4
- package/dist/core/evolagent.js +10 -12
- package/dist/core/handoff/argv-parse.js +115 -0
- package/dist/core/handoff/ipc-registration.js +1 -1
- package/dist/core/ipc-registration.js +19 -2
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/memory/consolidation.js +8 -1
- package/dist/core/memory/relation-sweep.js +20 -8
- package/dist/core/message/aun-ipc-sender.js +35 -2
- package/dist/core/message/contact-admission.js +530 -0
- package/dist/core/message/im-renderer.js +111 -16
- package/dist/core/message/message-admission.js +29 -54
- package/dist/core/message/message-bridge.js +62 -8
- package/dist/core/message/message-utils.js +9 -5
- package/dist/core/message/peer-mode.js +55 -13
- package/dist/core/message/response-engine.js +298 -78
- package/dist/core/message/retry-scheduler.js +4 -0
- package/dist/core/ownership/owner-resolver.js +72 -34
- package/dist/core/permission/ec-command-parser.js +25 -38
- package/dist/core/permission/readonly-shell-query.js +34 -8
- package/dist/core/permission/tool-policy.js +50 -5
- package/dist/core/relation/pa-team.js +127 -0
- package/dist/core/role/runtime-policy.js +18 -5
- package/dist/core/session/session-manager.js +9 -1
- package/dist/core/soul.js +66 -0
- package/dist/core/system-session/memory.js +2 -2
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/contact-admission-paths.js +9 -0
- package/dist/directory/owner-directory-admission.js +125 -29
- package/dist/directory/owner-directory-cache.js +554 -58
- package/dist/directory/owner-directory-identity.js +60 -0
- package/dist/directory/owner-directory-markdown.js +154 -58
- package/dist/directory/owner-directory-policy.js +108 -0
- package/dist/directory/owner-directory-query-operation.js +399 -90
- package/dist/directory/owner-directory-remarks.js +29 -2
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +118 -33
- package/dist/directory/owner-directory-store.js +117 -30
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +18 -8
- package/dist/eck/manifest-engine.js +55 -6
- package/dist/ecweb/basic-settings-service.js +2 -2
- package/dist/ecweb/message-context-service.js +28 -16
- package/dist/index.js +20 -5
- package/dist/ipc.js +1 -1
- package/dist/paths.js +29 -1
- package/dist/product.js +1 -0
- package/dist/response-system/config-resolver.js +1 -1
- package/dist/response-system/engines/v1/index.js +2 -1
- package/dist/response-system/modes/single-session/index.js +7 -2
- package/dist/trigger/scheduler.js +7 -4
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/error-utils.js +12 -7
- package/dist/utils/logger.js +13 -4
- package/dist/utils/npm-ops.js +2 -2
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +18 -0
- package/ecagent/dist/agent-loop.js +43 -1
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/compaction.js +3 -0
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +21 -6
- package/kits/docs/eck_templates/INDEX.template.md +1 -2
- package/kits/docs/evolcore/INDEX.md +4 -1
- package/kits/docs/evolcore/agent-create.md +5 -5
- package/kits/docs/evolcore/agent.md +4 -9
- package/kits/docs/evolcore/directory.md +227 -0
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +265 -0
- package/kits/docs/evolcore/menu-protocol.md +55 -0
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +7 -1
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/evolcore/trigger.md +4 -0
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/docs/prompt-loading-architecture.md +6 -2
- package/kits/eck_manifest.auxiliary.json +1 -0
- package/kits/eck_manifest.json +64 -7
- package/kits/eck_manifest.memory.json +93 -4
- package/kits/rules/01-overview.md +2 -2
- package/kits/rules/03-identity.md +10 -9
- package/kits/rules/05-venue.md +2 -4
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +44 -3
- package/kits/schemas/agent-config.schema.18.json +5 -0
- package/kits/schemas/agent-config.schema.19.json +924 -0
- package/kits/schemas/agent-config.schema.20.json +925 -0
- package/kits/schemas/relation-config.schema.12.json +289 -0
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/schemas/role-config.schema.2.json +215 -0
- package/kits/schemas/role-config.schema.3.json +1038 -0
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +109 -53
- package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
- package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
- package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
- package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
- package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
- package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
- package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
- package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
- package/kits/templates/soul/00-GUIDE.md +39 -0
- package/kits/templates/soul/01-identity.md +5 -0
- package/kits/templates/soul/02-persona.md +11 -0
- package/kits/templates/soul/03-duties.md +5 -0
- package/kits/templates/soul/04-working-style.md +5 -0
- package/kits/templates/system-fragments/bootstrap.md +7 -7
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +3 -2
- package/kits/templates/system-fragments/directory-contacts.md +9 -0
- package/kits/templates/system-fragments/memory.md +1 -1
- package/kits/templates/system-fragments/personal-assistant.md +50 -0
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +3 -2
- package/dist/cli/handoff-command.js +0 -353
- package/dist/directory/owner-directory-remark-operation.js +0 -147
- package/kits/docs/evolcore/self-summary.md +0 -29
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { resolvePaths } from '../paths.js';
|
|
3
|
-
import { daemonUnavailableMessage, queryDaemon } from './help.js';
|
|
4
|
-
import { HANDOFF_QUERY_DEFAULT_LIMIT, HANDOFF_QUERY_MAX_LIMIT, HANDOFF_STATES } from '../core/handoff/types.js';
|
|
5
|
-
import { HANDOFF_ID_RE } from '../core/handoff/store.js';
|
|
6
|
-
import { isHelpFlag, wantsHelp } from './help.js';
|
|
7
|
-
import { readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
8
|
-
import { canonicalizeEvolcoreCommandArgv } from '../core/permission/ec-command-parser.js';
|
|
9
|
-
import { MAIN_CLI_BIN } from '../product.js';
|
|
10
|
-
function parseLimit(value) {
|
|
11
|
-
const limit = Number(value);
|
|
12
|
-
if (!value || !Number.isInteger(limit) || limit < 1 || limit > HANDOFF_QUERY_MAX_LIMIT) {
|
|
13
|
-
throw new Error('INVALID_HANDOFF_LIMIT');
|
|
14
|
-
}
|
|
15
|
-
return limit;
|
|
16
|
-
}
|
|
17
|
-
export function parseList(args) {
|
|
18
|
-
const parsed = { limit: HANDOFF_QUERY_DEFAULT_LIMIT };
|
|
19
|
-
for (let index = 0; index < args.length; index++) {
|
|
20
|
-
const arg = args[index];
|
|
21
|
-
const value = args[index + 1];
|
|
22
|
-
if (arg === '--state') {
|
|
23
|
-
if (!value || !HANDOFF_STATES.includes(value))
|
|
24
|
-
throw new Error('INVALID_HANDOFF_STATE');
|
|
25
|
-
parsed.state = value;
|
|
26
|
-
index++;
|
|
27
|
-
}
|
|
28
|
-
else if (arg === '--session') {
|
|
29
|
-
if (!value)
|
|
30
|
-
throw new Error('HANDOFF_SESSION_REQUIRED');
|
|
31
|
-
parsed.sessionId = value;
|
|
32
|
-
index++;
|
|
33
|
-
}
|
|
34
|
-
else if (arg === '--agent') {
|
|
35
|
-
if (!value)
|
|
36
|
-
throw new Error('HANDOFF_AGENT_REQUIRED');
|
|
37
|
-
parsed.agent = value;
|
|
38
|
-
index++;
|
|
39
|
-
}
|
|
40
|
-
else if (arg === '--limit') {
|
|
41
|
-
parsed.limit = parseLimit(value);
|
|
42
|
-
index++;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
throw new Error(`UNKNOWN_HANDOFF_OPTION:${arg}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return parsed;
|
|
49
|
-
}
|
|
50
|
-
export function parseTrace(args) {
|
|
51
|
-
const handoffId = args[0];
|
|
52
|
-
if (!handoffId || !HANDOFF_ID_RE.test(handoffId))
|
|
53
|
-
throw new Error('INVALID_HANDOFF_ID');
|
|
54
|
-
const parsed = { handoffId, limit: HANDOFF_QUERY_DEFAULT_LIMIT };
|
|
55
|
-
for (let index = 1; index < args.length; index++) {
|
|
56
|
-
const arg = args[index];
|
|
57
|
-
const value = args[index + 1];
|
|
58
|
-
if (arg === '--agent') {
|
|
59
|
-
if (!value)
|
|
60
|
-
throw new Error('HANDOFF_AGENT_REQUIRED');
|
|
61
|
-
parsed.agent = value;
|
|
62
|
-
index++;
|
|
63
|
-
}
|
|
64
|
-
else if (arg === '--limit') {
|
|
65
|
-
parsed.limit = parseLimit(value);
|
|
66
|
-
index++;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
throw new Error(`UNKNOWN_HANDOFF_OPTION:${arg}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return parsed;
|
|
73
|
-
}
|
|
74
|
-
export function parseReturn(args, options = {}) {
|
|
75
|
-
if (!options.canonical)
|
|
76
|
-
args = canonicalizeEvolcoreCommandArgv([MAIN_CLI_BIN, 'handoff', 'return', ...args]).slice(3);
|
|
77
|
-
const dash = args.indexOf('--');
|
|
78
|
-
if (dash >= 0) {
|
|
79
|
-
const beforeDash = args.slice(0, dash);
|
|
80
|
-
const first = beforeDash[0];
|
|
81
|
-
if (first?.startsWith('h-') && !HANDOFF_ID_RE.test(first))
|
|
82
|
-
throw new Error(`INVALID_HANDOFF_ID:${first}`);
|
|
83
|
-
const handoffId = first && HANDOFF_ID_RE.test(first) ? first : undefined;
|
|
84
|
-
if (beforeDash.length > (handoffId ? 1 : 0))
|
|
85
|
-
throw new Error('HANDOFF_CONTENT_DELIMITER_CONFLICT');
|
|
86
|
-
return { handoffId, content: args.slice(dash + 1).join(' ') };
|
|
87
|
-
}
|
|
88
|
-
const fileIndex = args.indexOf('--text-from-file');
|
|
89
|
-
const filePath = fileIndex >= 0 ? args[fileIndex + 1] : undefined;
|
|
90
|
-
if (fileIndex >= 0 && !filePath)
|
|
91
|
-
throw new Error('HANDOFF_CONTENT_FILE_READ_FAILED');
|
|
92
|
-
const positional = args.filter((_, index) => fileIndex < 0 || (index !== fileIndex && index !== fileIndex + 1));
|
|
93
|
-
const first = positional[0];
|
|
94
|
-
if (first?.startsWith('h-') && !HANDOFF_ID_RE.test(first))
|
|
95
|
-
throw new Error(`INVALID_HANDOFF_ID:${first}`);
|
|
96
|
-
const handoffId = first && HANDOFF_ID_RE.test(first) ? first : undefined;
|
|
97
|
-
const contentArgs = handoffId ? positional.slice(1) : positional;
|
|
98
|
-
if (filePath && contentArgs.length > 0)
|
|
99
|
-
throw new Error('HANDOFF_CONTENT_FILE_CONFLICT');
|
|
100
|
-
if (filePath) {
|
|
101
|
-
if (options.deferFileRead)
|
|
102
|
-
return { handoffId, content: '' };
|
|
103
|
-
try {
|
|
104
|
-
return { handoffId, content: options.readFile ? options.readFile(filePath) : fs.readFileSync(filePath, 'utf8') };
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
throw new Error('HANDOFF_CONTENT_FILE_READ_FAILED');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return { handoffId, content: contentArgs.join(' ') };
|
|
111
|
-
}
|
|
112
|
-
function printReturn(result) {
|
|
113
|
-
if (result.ok) {
|
|
114
|
-
if (result.code === 'HANDOFF_RETURN_ALREADY_APPLIED') {
|
|
115
|
-
console.log(`✓ handoff ${result.handoff_id} 已接收过相同结果,未重复处理${result.result_id ? ` result_id=${result.result_id}` : ''}`);
|
|
116
|
-
}
|
|
117
|
-
else if (result.state === 'completed') {
|
|
118
|
-
console.log(`✓ handoff ${result.handoff_id} 已确认完成,不回流来源会话`);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
console.log(`✓ handoff ${result.handoff_id} 回流结果已接收${result.result_id ? ` result_id=${result.result_id}` : ''};后续仍可用同一 ID 追加结果`);
|
|
122
|
-
}
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
switch (result.code) {
|
|
126
|
-
case 'HANDOFF_RETURN_CONTENT_REQUIRED':
|
|
127
|
-
console.error(`✗ handoff ${result.handoff_id ?? ''} 必须提供非空回流内容`.trim());
|
|
128
|
-
break;
|
|
129
|
-
case 'HANDOFF_RETURN_CONTENT_FORBIDDEN':
|
|
130
|
-
console.error(`✗ handoff ${result.handoff_id ?? ''} 的策略为 none,不能提供回流内容`.trim());
|
|
131
|
-
break;
|
|
132
|
-
case 'HANDOFF_NOT_RETURNABLE':
|
|
133
|
-
console.error(`✗ handoff ${result.handoff_id ?? ''} 当前不可 return`.trim());
|
|
134
|
-
break;
|
|
135
|
-
case 'HANDOFF_ID_REQUIRED':
|
|
136
|
-
console.error('✗ 当前任务没有可自动选择的 handoff,请指定 ID');
|
|
137
|
-
break;
|
|
138
|
-
case 'HANDOFF_TARGET_SESSION_MISMATCH':
|
|
139
|
-
console.error(`✗ handoff ${result.handoff_id ?? ''} 不能从当前会话处理`.trim());
|
|
140
|
-
break;
|
|
141
|
-
case 'HANDOFF_RETURN_CONFLICT':
|
|
142
|
-
console.error(`✗ handoff ${result.handoff_id ?? ''} 已接收过不同结果,本次未覆盖`.trim());
|
|
143
|
-
break;
|
|
144
|
-
case 'HANDOFF_NOT_FOUND':
|
|
145
|
-
console.error(`✗ handoff 不存在:${result.handoff_id ?? ''}`.trim());
|
|
146
|
-
break;
|
|
147
|
-
default:
|
|
148
|
-
console.error(`✗ ${result.error}`);
|
|
149
|
-
}
|
|
150
|
-
process.exitCode = 1;
|
|
151
|
-
}
|
|
152
|
-
function printQueryError(result) {
|
|
153
|
-
console.error(`✗ ${result.error}`);
|
|
154
|
-
process.exitCode = 1;
|
|
155
|
-
}
|
|
156
|
-
function formatTimestamp(value) {
|
|
157
|
-
return new Date(value).toISOString();
|
|
158
|
-
}
|
|
159
|
-
export async function cmdHandoff(args) {
|
|
160
|
-
args = canonicalizeEvolcoreCommandArgv([MAIN_CLI_BIN, 'handoff', ...args]).slice(2);
|
|
161
|
-
const sub = args[0];
|
|
162
|
-
if (!sub || isHelpFlag(sub) || wantsHelp(args)) {
|
|
163
|
-
console.log(`用法: ec handoff <command> [args]
|
|
164
|
-
|
|
165
|
-
⚠ ec handoff 已废弃,请改用话题链(ec thread + ec msg send --thread)。
|
|
166
|
-
本命令保留以兼容现有脚本,将在 P2 后续版本中移除。
|
|
167
|
-
|
|
168
|
-
Commands:
|
|
169
|
-
return [handoff-id] [content] 提交一个回流结果;required 可用同一 ID 追加多个结果
|
|
170
|
-
return [handoff-id] --text-from-file <path>
|
|
171
|
-
recover-return <handoff-id> [content] owner-authorized recovery after target session replacement
|
|
172
|
-
recover-return <handoff-id> --text-from-file <path>
|
|
173
|
-
status <handoff-id> 查询 handoff 状态
|
|
174
|
-
list [--state <state>] [--session <id>] [--limit <n>] [--agent <aid>]
|
|
175
|
-
trace <handoff-id> [--limit <n>] [--agent <aid>]`);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (sub === 'return') {
|
|
179
|
-
let parsed;
|
|
180
|
-
try {
|
|
181
|
-
parsed = parseReturn(args.slice(1), { canonical: true, deferFileRead: !!process.env.EVOLCORE_SESSION_ID });
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
185
|
-
if (message.startsWith('INVALID_HANDOFF_ID:'))
|
|
186
|
-
console.error(`✗ handoff ID 格式无效:${message.slice(message.indexOf(':') + 1)}`);
|
|
187
|
-
else if (message === 'HANDOFF_CONTENT_FILE_READ_FAILED')
|
|
188
|
-
console.error('✗ 无法读取回流内容文件');
|
|
189
|
-
else
|
|
190
|
-
console.error('✗ --text-from-file 不能与位置正文同时使用');
|
|
191
|
-
process.exitCode = 1;
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const { response: result, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
195
|
-
type: 'handoff-return',
|
|
196
|
-
argv: ['handoff', ...args],
|
|
197
|
-
sessionId: process.env.EVOLCORE_SESSION_ID,
|
|
198
|
-
handoffId: parsed.handoffId,
|
|
199
|
-
content: parsed.content,
|
|
200
|
-
delegationToken: readDelegationCredential(),
|
|
201
|
-
}, 5000);
|
|
202
|
-
if (!result) {
|
|
203
|
-
console.error(`✗ ${daemonUnavailableMessage(transportError, 'daemon 暂时不可用')}`);
|
|
204
|
-
process.exitCode = 1;
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
printReturn(result);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (sub === 'recover-return') {
|
|
211
|
-
let parsed;
|
|
212
|
-
try {
|
|
213
|
-
parsed = parseReturn(args.slice(1), { canonical: true, deferFileRead: !!process.env.EVOLCORE_SESSION_ID });
|
|
214
|
-
}
|
|
215
|
-
catch (error) {
|
|
216
|
-
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
217
|
-
process.exitCode = 1;
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (!parsed.handoffId) {
|
|
221
|
-
console.error('✗ recover-return 必须指定 handoff ID');
|
|
222
|
-
process.exitCode = 1;
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const { response: result, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
226
|
-
type: 'handoff-recover-return',
|
|
227
|
-
argv: ['handoff', ...args],
|
|
228
|
-
sessionId: process.env.EVOLCORE_SESSION_ID,
|
|
229
|
-
handoffId: parsed.handoffId,
|
|
230
|
-
content: parsed.content,
|
|
231
|
-
delegationToken: readDelegationCredential(),
|
|
232
|
-
}, 5000);
|
|
233
|
-
if (!result) {
|
|
234
|
-
console.error(`✗ ${daemonUnavailableMessage(transportError, 'daemon 暂时不可用')}`);
|
|
235
|
-
process.exitCode = 1;
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
printReturn(result);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (sub === 'status') {
|
|
242
|
-
const handoffId = args[1];
|
|
243
|
-
if (!handoffId || !HANDOFF_ID_RE.test(handoffId)) {
|
|
244
|
-
console.error(`✗ handoff ID 格式无效:${handoffId ?? ''}`);
|
|
245
|
-
process.exitCode = 1;
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const { response: result, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
249
|
-
type: 'handoff-status', sessionId: process.env.EVOLCORE_SESSION_ID, handoffId,
|
|
250
|
-
argv: ['handoff', ...args],
|
|
251
|
-
delegationToken: readDelegationCredential(),
|
|
252
|
-
}, 5000);
|
|
253
|
-
if (!result) {
|
|
254
|
-
console.error(`✗ ${daemonUnavailableMessage(transportError, 'daemon 暂时不可用')}`);
|
|
255
|
-
process.exitCode = 1;
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
if (result.ok === false) {
|
|
259
|
-
console.error(`✗ ${result.error}`);
|
|
260
|
-
process.exitCode = 1;
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
console.log(`handoff ${result.handoff_id}: ${result.state}${result.attention_required ? ` (attention: ${result.attention_reason})` : ''}`);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
if (sub === 'list') {
|
|
267
|
-
let parsed;
|
|
268
|
-
try {
|
|
269
|
-
parsed = parseList(args.slice(1));
|
|
270
|
-
}
|
|
271
|
-
catch (error) {
|
|
272
|
-
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
273
|
-
process.exitCode = 1;
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
const { response: result, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
277
|
-
type: 'handoff-list',
|
|
278
|
-
argv: ['handoff', ...args],
|
|
279
|
-
sessionId: process.env.EVOLCORE_SESSION_ID,
|
|
280
|
-
agent: parsed.agent,
|
|
281
|
-
state: parsed.state,
|
|
282
|
-
filterSessionId: parsed.sessionId,
|
|
283
|
-
limit: parsed.limit,
|
|
284
|
-
delegationToken: readDelegationCredential(),
|
|
285
|
-
}, 5000);
|
|
286
|
-
if (!result) {
|
|
287
|
-
console.error(`✗ ${daemonUnavailableMessage(transportError, 'daemon 暂时不可用')}`);
|
|
288
|
-
process.exitCode = 1;
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
if (!result.ok)
|
|
292
|
-
return printQueryError(result);
|
|
293
|
-
if (result.handoffs.length === 0) {
|
|
294
|
-
console.log('没有匹配的 handoff');
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
console.log('ID\tSTATE\tRETURN_POLICY\tORIGIN\tTARGET\tUPDATED\tATTENTION');
|
|
298
|
-
for (const item of result.handoffs) {
|
|
299
|
-
console.log([
|
|
300
|
-
item.handoff_id,
|
|
301
|
-
item.state,
|
|
302
|
-
item.return_policy,
|
|
303
|
-
item.origin_session_id,
|
|
304
|
-
item.target_session_id,
|
|
305
|
-
formatTimestamp(item.updated_at),
|
|
306
|
-
item.attention_reason ?? '-',
|
|
307
|
-
].join('\t'));
|
|
308
|
-
}
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
if (sub === 'trace') {
|
|
312
|
-
let parsed;
|
|
313
|
-
try {
|
|
314
|
-
parsed = parseTrace(args.slice(1));
|
|
315
|
-
}
|
|
316
|
-
catch (error) {
|
|
317
|
-
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
318
|
-
process.exitCode = 1;
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const { response: result, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
322
|
-
type: 'handoff-trace',
|
|
323
|
-
argv: ['handoff', ...args],
|
|
324
|
-
sessionId: process.env.EVOLCORE_SESSION_ID,
|
|
325
|
-
agent: parsed.agent,
|
|
326
|
-
handoffId: parsed.handoffId,
|
|
327
|
-
limit: parsed.limit,
|
|
328
|
-
delegationToken: readDelegationCredential(),
|
|
329
|
-
}, 5000);
|
|
330
|
-
if (!result) {
|
|
331
|
-
console.error(`✗ ${daemonUnavailableMessage(transportError, 'daemon 暂时不可用')}`);
|
|
332
|
-
process.exitCode = 1;
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
if (!result.ok)
|
|
336
|
-
return printQueryError(result);
|
|
337
|
-
for (const event of result.events) {
|
|
338
|
-
const version = event.from_version === undefined && event.to_version === undefined
|
|
339
|
-
? '-'
|
|
340
|
-
: `${event.from_version ?? '-'}->${event.to_version ?? '-'}`;
|
|
341
|
-
console.log([
|
|
342
|
-
formatTimestamp(event.created_at),
|
|
343
|
-
event.event_type,
|
|
344
|
-
version,
|
|
345
|
-
event.operation_key ?? '-',
|
|
346
|
-
event.details ? JSON.stringify(event.details) : '-',
|
|
347
|
-
].join('\t'));
|
|
348
|
-
}
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
console.error(`未知 handoff 子命令: ${sub}`);
|
|
352
|
-
process.exitCode = 1;
|
|
353
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `ec directory remark` 的操作实现。
|
|
3
|
-
*
|
|
4
|
-
* 备注文件落在目标 Agent 的 `$AGENT_DIR/directory/remarks/` 下,而个人助理运行在
|
|
5
|
-
* 自己的沙箱里,直接写别人的目录会遇到权限问题——所以写操作统一由 daemon 执行,
|
|
6
|
-
* CLI 只负责把 argv 送过来。写完之后立刻重算 `directory.md`,注入内容当场生效。
|
|
7
|
-
*
|
|
8
|
-
* 命令形状:
|
|
9
|
-
* ec directory remark get <contact-aid> --self <agent-aid>
|
|
10
|
-
* ec directory remark set <contact-aid> --self <agent-aid> [--remark <text>] [--body <text> | --body-file <path>]
|
|
11
|
-
* ec directory remark rm <contact-aid> --self <agent-aid>
|
|
12
|
-
* ec directory remark list --self <agent-aid>
|
|
13
|
-
*/
|
|
14
|
-
import fs from 'node:fs';
|
|
15
|
-
import path from 'node:path';
|
|
16
|
-
import { agentDir } from '../paths.js';
|
|
17
|
-
import { isValidAid } from '../aun/aid/validation.js';
|
|
18
|
-
import { OwnerDirectoryCache } from './owner-directory-cache.js';
|
|
19
|
-
import { listRemarks, readRemark, removeRemark, writeRemark } from './owner-directory-remarks.js';
|
|
20
|
-
import { ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
21
|
-
const REMARK_BODY_MAX_BYTES = 16 * 1024;
|
|
22
|
-
export class DirectoryRemarkError extends Error {
|
|
23
|
-
code;
|
|
24
|
-
constructor(code, message) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.code = code;
|
|
27
|
-
this.name = 'DirectoryRemarkError';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/** 解析 `ec directory remark ...` 之后的 argv。 */
|
|
31
|
-
export function resolveDirectoryRemarkCommand(argv) {
|
|
32
|
-
const [action, ...rest] = argv;
|
|
33
|
-
if (action !== 'get' && action !== 'set' && action !== 'rm' && action !== 'list') {
|
|
34
|
-
throw new DirectoryRemarkError('INVALID_ACTION', 'directory remark requires one of: get, set, rm, list');
|
|
35
|
-
}
|
|
36
|
-
const selfAid = takeFlag(rest, '--self') ?? process.env.EVOLCORE_SELF_AID?.trim();
|
|
37
|
-
if (!selfAid)
|
|
38
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', '--self <agent-aid> is required');
|
|
39
|
-
if (!isValidAid(selfAid))
|
|
40
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', `invalid agent AID: ${selfAid}`);
|
|
41
|
-
const positional = rest.filter(arg => !arg.startsWith('--') && !isFlagValue(rest, arg));
|
|
42
|
-
if (action === 'list') {
|
|
43
|
-
if (positional.length > 0)
|
|
44
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', 'list takes no contact AID');
|
|
45
|
-
return { action, selfAid };
|
|
46
|
-
}
|
|
47
|
-
const contactAid = positional[0];
|
|
48
|
-
if (!contactAid)
|
|
49
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', 'a contact AID is required');
|
|
50
|
-
if (!isValidAid(contactAid))
|
|
51
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', `invalid contact AID: ${contactAid}`);
|
|
52
|
-
if (positional.length > 1)
|
|
53
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', 'only one contact AID is accepted');
|
|
54
|
-
if (action === 'get' || action === 'rm')
|
|
55
|
-
return { action, selfAid, contactAid };
|
|
56
|
-
const remark = takeFlag(rest, '--remark');
|
|
57
|
-
const inlineBody = takeFlag(rest, '--body');
|
|
58
|
-
const bodyFile = takeFlag(rest, '--body-file');
|
|
59
|
-
if (inlineBody !== undefined && bodyFile !== undefined) {
|
|
60
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', '--body and --body-file are mutually exclusive');
|
|
61
|
-
}
|
|
62
|
-
let body = inlineBody;
|
|
63
|
-
if (bodyFile !== undefined) {
|
|
64
|
-
try {
|
|
65
|
-
const stat = fs.statSync(bodyFile);
|
|
66
|
-
if (!stat.isFile())
|
|
67
|
-
throw new Error('not a regular file');
|
|
68
|
-
if (stat.size > REMARK_BODY_MAX_BYTES)
|
|
69
|
-
throw new Error(`exceeds ${REMARK_BODY_MAX_BYTES} bytes`);
|
|
70
|
-
body = fs.readFileSync(bodyFile, 'utf8');
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', `cannot read --body-file: ${error instanceof Error ? error.message : String(error)}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (remark === undefined && body === undefined) {
|
|
77
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', 'set requires --remark or --body');
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
action, selfAid, contactAid,
|
|
81
|
-
...(remark !== undefined ? { remark } : {}),
|
|
82
|
-
...(body !== undefined ? { body } : {}),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* 执行命令。写操作要求目标 Agent 存在且已落地名录:
|
|
87
|
-
* 给不在名录里的 AID 写备注没有意义,也容易变成越权写入的入口。
|
|
88
|
-
*/
|
|
89
|
-
export function executeDirectoryRemarkCommand(command) {
|
|
90
|
-
const directory = path.join(agentDir(command.selfAid), 'directory');
|
|
91
|
-
if (!fs.existsSync(agentDir(command.selfAid))) {
|
|
92
|
-
return { ok: false, code: 'AGENT_NOT_FOUND', error: `agent ${command.selfAid} does not exist` };
|
|
93
|
-
}
|
|
94
|
-
if (command.action === 'list') {
|
|
95
|
-
return { ok: true, action: 'list', remarks: listRemarks(directory) };
|
|
96
|
-
}
|
|
97
|
-
const contactAid = command.contactAid;
|
|
98
|
-
if (command.action === 'get') {
|
|
99
|
-
return { ok: true, action: 'get', remark: readRemark(directory, contactAid) ?? null };
|
|
100
|
-
}
|
|
101
|
-
if (command.action === 'rm') {
|
|
102
|
-
const removed = removeRemark(directory, contactAid);
|
|
103
|
-
return { ok: true, action: 'rm', removed, regenerated: removed ? regenerate(directory, command.selfAid) : false };
|
|
104
|
-
}
|
|
105
|
-
writeRemark(directory, {
|
|
106
|
-
aid: contactAid,
|
|
107
|
-
...(command.remark !== undefined ? { remark: command.remark } : {}),
|
|
108
|
-
...(command.body !== undefined ? { body: command.body } : {}),
|
|
109
|
-
updatedAt: Math.floor(Date.now() / 1000),
|
|
110
|
-
});
|
|
111
|
-
return {
|
|
112
|
-
ok: true, action: 'set',
|
|
113
|
-
remark: readRemark(directory, contactAid) ?? null,
|
|
114
|
-
regenerated: regenerate(directory, command.selfAid),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* 重算 `directory.md`。不依赖活着的 AUN channel:直接读本地快照重新渲染,
|
|
119
|
-
* 和名录落地后的那条路径产出同样的字节。
|
|
120
|
-
*/
|
|
121
|
-
function regenerate(directory, selfAid) {
|
|
122
|
-
const ownerAid = ownerResolver.owner(selfAid);
|
|
123
|
-
if (!ownerAid)
|
|
124
|
-
return false;
|
|
125
|
-
try {
|
|
126
|
-
const cache = new OwnerDirectoryCache({ selfAid, ownerAid, directory });
|
|
127
|
-
cache.refreshMarkdown();
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function takeFlag(args, flag) {
|
|
135
|
-
const index = args.indexOf(flag);
|
|
136
|
-
if (index < 0)
|
|
137
|
-
return undefined;
|
|
138
|
-
const value = args[index + 1];
|
|
139
|
-
if (value === undefined || value.startsWith('--')) {
|
|
140
|
-
throw new DirectoryRemarkError('INVALID_ARGUMENT', `${flag} requires a value`);
|
|
141
|
-
}
|
|
142
|
-
return value;
|
|
143
|
-
}
|
|
144
|
-
function isFlagValue(args, candidate) {
|
|
145
|
-
const index = args.indexOf(candidate);
|
|
146
|
-
return index > 0 && args[index - 1]?.startsWith('--') === true;
|
|
147
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# 自我总结流程指南
|
|
2
|
-
|
|
3
|
-
自我总结是 agent 的自省行为——在会话结束或空闲时,回顾本次交互,提炼值得记住的信息。
|
|
4
|
-
|
|
5
|
-
## 触发时机
|
|
6
|
-
|
|
7
|
-
- 会话结束时(`on_session_end: true`)
|
|
8
|
-
- 空闲超过 N 分钟(`on_idle_minutes: 30`)
|
|
9
|
-
- 每日定时(`daily_at: "03:00"`)
|
|
10
|
-
- 每周定时(`weekly_on: "Sunday"`)
|
|
11
|
-
|
|
12
|
-
## 总结目标
|
|
13
|
-
|
|
14
|
-
| 目标层 | 写入位置 | 内容 |
|
|
15
|
-
|---|---|---|
|
|
16
|
-
| 事件性记忆 | `personal/memory/episodic.jsonl` | "我经历了什么"——关键事件、决策、结果 |
|
|
17
|
-
| 语义性记忆 | `personal/memory/semantic.md` | 习得的事实、规律、结论 |
|
|
18
|
-
| 当前关注 | `personal/memory/working.md` | 短期关注点(下次会话开始时加载) |
|
|
19
|
-
| 反思日志 | `personal/journal.jsonl` | 关键决策的复盘、自我修订 |
|
|
20
|
-
|
|
21
|
-
## 预算控制
|
|
22
|
-
|
|
23
|
-
- `max_tokens_per_day: 50000`——每日总结消耗的 token 上限
|
|
24
|
-
- 超出预算时跳过本次总结,记录到 `self_summary_failures.jsonl`
|
|
25
|
-
|
|
26
|
-
## 去重
|
|
27
|
-
|
|
28
|
-
- episodic.jsonl 按时间窗口去重(同一小时内的重复事件合并)
|
|
29
|
-
- semantic.md 由 LLM 判断是否已有等价结论
|