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.
Files changed (200) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +22 -0
  3. package/dist/agents/claude-runner.js +26 -2
  4. package/dist/agents/codex/app-server-client.js +12 -0
  5. package/dist/agents/codex-runner.js +49 -8
  6. package/dist/agents/ecagent-runner.js +39 -15
  7. package/dist/agents/gemini-runner.js +15 -12
  8. package/dist/agents/tool-time-context.js +55 -0
  9. package/dist/aun/aid/agentmd.js +21 -1
  10. package/dist/aun/menu/client.js +1 -1
  11. package/dist/aun/model-headers.js +17 -0
  12. package/dist/aun/msg/p2p.js +7 -2
  13. package/dist/channels/aun.js +522 -50
  14. package/dist/channels/builtin-plugins.js +16 -11
  15. package/dist/channels/daemon.js +4 -0
  16. package/dist/channels/dingtalk.js +83 -31
  17. package/dist/channels/feishu.js +29 -13
  18. package/dist/channels/qqbot.js +32 -11
  19. package/dist/channels/wechat.js +13 -3
  20. package/dist/channels/wecom.js +67 -27
  21. package/dist/cli/agent-command.js +3 -86
  22. package/dist/cli/agent-create.js +20 -6
  23. package/dist/cli/agent.js +1 -79
  24. package/dist/cli/aun-commands.js +18 -19
  25. package/dist/cli/config.js +1 -1
  26. package/dist/cli/daemon-commands.js +47 -2
  27. package/dist/cli/data-command.js +9 -1
  28. package/dist/cli/debug-mode.js +1 -1
  29. package/dist/cli/diag.js +1 -1
  30. package/dist/cli/directory.js +149 -91
  31. package/dist/cli/getmeta-command.js +1 -1
  32. package/dist/cli/index.js +79 -22
  33. package/dist/cli/init.js +1 -23
  34. package/dist/cli/link-rules.js +1 -1
  35. package/dist/cli/managed-command-guard.js +0 -1
  36. package/dist/cli/pa-workspace-command.js +36 -2
  37. package/dist/cli/peer.js +3 -2
  38. package/dist/cli/restart-monitor.js +17 -3
  39. package/dist/cli/role.js +1 -1
  40. package/dist/cli/session-command.js +1 -1
  41. package/dist/cli/stats.js +2 -2
  42. package/dist/cli/task-context.js +3 -1
  43. package/dist/cli/thread-command.js +1 -1
  44. package/dist/cli/watch-msg.js +1 -1
  45. package/dist/config/builtin-role-templates.js +2 -2
  46. package/dist/config/builtin-roles.js +2 -1
  47. package/dist/config/config-field-policy.js +7 -2
  48. package/dist/config/config-manager.js +32 -10
  49. package/dist/config/peer-role-resolver.js +23 -1
  50. package/dist/config/role-schema.js +29 -4
  51. package/dist/config/role-service.js +12 -7
  52. package/dist/config/role-store.js +30 -8
  53. package/dist/config-store.js +75 -4
  54. package/dist/core/agent-ipc-registration.js +16 -59
  55. package/dist/core/auth/auth-gateway.js +14 -4
  56. package/dist/core/auth/authorization-audit.js +52 -14
  57. package/dist/core/auth/operation-authorizer.js +17 -11
  58. package/dist/core/auth/operation-catalog.js +5 -13
  59. package/dist/core/channel-loader.js +152 -16
  60. package/dist/core/channel-runtime.js +5 -0
  61. package/dist/core/command/agent-control.js +2 -1
  62. package/dist/core/command/agentmd-menu-request.js +50 -0
  63. package/dist/core/command/agentmd-menu.js +156 -0
  64. package/dist/core/command/cli-intent-parser.js +0 -8
  65. package/dist/core/command/command-handler.js +47 -40
  66. package/dist/core/command/connect-menu.js +7 -3
  67. package/dist/core/command/menu-catalog.js +16 -2
  68. package/dist/core/command/menu-handler.js +107 -14
  69. package/dist/core/command/menu-protocol.js +28 -0
  70. package/dist/core/command/role-menu.js +23 -9
  71. package/dist/core/command/slash-handler.js +139 -51
  72. package/dist/core/daemon-file-cache.js +3 -3
  73. package/dist/core/daemon-lifecycle.js +9 -1
  74. package/dist/core/evolagent-registry.js +5 -4
  75. package/dist/core/evolagent.js +10 -12
  76. package/dist/core/handoff/argv-parse.js +115 -0
  77. package/dist/core/handoff/ipc-registration.js +1 -1
  78. package/dist/core/ipc-registration.js +19 -2
  79. package/dist/core/lifecycle-notice.js +185 -0
  80. package/dist/core/memory/consolidation.js +8 -1
  81. package/dist/core/memory/relation-sweep.js +20 -8
  82. package/dist/core/message/aun-ipc-sender.js +35 -2
  83. package/dist/core/message/contact-admission.js +530 -0
  84. package/dist/core/message/im-renderer.js +111 -16
  85. package/dist/core/message/message-admission.js +29 -54
  86. package/dist/core/message/message-bridge.js +62 -8
  87. package/dist/core/message/message-utils.js +9 -5
  88. package/dist/core/message/peer-mode.js +55 -13
  89. package/dist/core/message/response-engine.js +298 -78
  90. package/dist/core/message/retry-scheduler.js +4 -0
  91. package/dist/core/ownership/owner-resolver.js +72 -34
  92. package/dist/core/permission/ec-command-parser.js +25 -38
  93. package/dist/core/permission/readonly-shell-query.js +34 -8
  94. package/dist/core/permission/tool-policy.js +50 -5
  95. package/dist/core/relation/pa-team.js +127 -0
  96. package/dist/core/role/runtime-policy.js +18 -5
  97. package/dist/core/session/session-manager.js +9 -1
  98. package/dist/core/soul.js +66 -0
  99. package/dist/core/system-session/memory.js +2 -2
  100. package/dist/core/thread/thread-service.js +6 -4
  101. package/dist/directory/contact-admission-paths.js +9 -0
  102. package/dist/directory/owner-directory-admission.js +125 -29
  103. package/dist/directory/owner-directory-cache.js +554 -58
  104. package/dist/directory/owner-directory-identity.js +60 -0
  105. package/dist/directory/owner-directory-markdown.js +154 -58
  106. package/dist/directory/owner-directory-policy.js +108 -0
  107. package/dist/directory/owner-directory-query-operation.js +399 -90
  108. package/dist/directory/owner-directory-remarks.js +29 -2
  109. package/dist/directory/owner-directory-request-operation.js +76 -0
  110. package/dist/directory/owner-directory-scope.js +35 -4
  111. package/dist/directory/owner-directory-search.js +118 -33
  112. package/dist/directory/owner-directory-store.js +117 -30
  113. package/dist/directory/owner-directory-text.js +60 -0
  114. package/dist/eck/kit-renderer.js +18 -8
  115. package/dist/eck/manifest-engine.js +55 -6
  116. package/dist/ecweb/basic-settings-service.js +2 -2
  117. package/dist/ecweb/message-context-service.js +28 -16
  118. package/dist/index.js +20 -5
  119. package/dist/ipc.js +1 -1
  120. package/dist/paths.js +29 -1
  121. package/dist/product.js +1 -0
  122. package/dist/response-system/config-resolver.js +1 -1
  123. package/dist/response-system/engines/v1/index.js +2 -1
  124. package/dist/response-system/modes/single-session/index.js +7 -2
  125. package/dist/trigger/scheduler.js +7 -4
  126. package/dist/trigger/validation.js +4 -0
  127. package/dist/utils/error-utils.js +12 -7
  128. package/dist/utils/logger.js +13 -4
  129. package/dist/utils/npm-ops.js +2 -2
  130. package/dist/utils/windows-autostart.js +1 -1
  131. package/ecagent/README.md +18 -0
  132. package/ecagent/dist/agent-loop.js +43 -1
  133. package/ecagent/dist/harness/agent-harness.d.ts +2 -0
  134. package/ecagent/dist/harness/agent-harness.js +24 -8
  135. package/ecagent/dist/harness/compaction/compaction.js +3 -0
  136. package/ecagent/dist/harness/types.d.ts +1 -0
  137. package/kits/docs/INDEX.md +1 -0
  138. package/kits/docs/channels/aun.md +1 -1
  139. package/kits/docs/context-assembly.md +21 -6
  140. package/kits/docs/eck_templates/INDEX.template.md +1 -2
  141. package/kits/docs/evolcore/INDEX.md +4 -1
  142. package/kits/docs/evolcore/agent-create.md +5 -5
  143. package/kits/docs/evolcore/agent.md +4 -9
  144. package/kits/docs/evolcore/directory.md +227 -0
  145. package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
  146. package/kits/docs/evolcore/file-navigation.md +265 -0
  147. package/kits/docs/evolcore/menu-protocol.md +55 -0
  148. package/kits/docs/evolcore/msg.md +1 -0
  149. package/kits/docs/evolcore/peer.md +2 -1
  150. package/kits/docs/evolcore/response.md +7 -1
  151. package/kits/docs/evolcore/task.md +2 -0
  152. package/kits/docs/evolcore/tool-authorization.md +1 -1
  153. package/kits/docs/evolcore/trigger.md +4 -0
  154. package/kits/docs/identity/ROLE_DETAIL.md +2 -0
  155. package/kits/docs/prompt-loading-architecture.md +6 -2
  156. package/kits/eck_manifest.auxiliary.json +1 -0
  157. package/kits/eck_manifest.json +64 -7
  158. package/kits/eck_manifest.memory.json +93 -4
  159. package/kits/rules/01-overview.md +2 -2
  160. package/kits/rules/03-identity.md +10 -9
  161. package/kits/rules/05-venue.md +2 -4
  162. package/kits/rules/06-channel.md +1 -1
  163. package/kits/schemas/_meta.json +44 -3
  164. package/kits/schemas/agent-config.schema.18.json +5 -0
  165. package/kits/schemas/agent-config.schema.19.json +924 -0
  166. package/kits/schemas/agent-config.schema.20.json +925 -0
  167. package/kits/schemas/relation-config.schema.12.json +289 -0
  168. package/kits/schemas/relation-config.schema.13.json +289 -0
  169. package/kits/schemas/role-config.schema.2.json +215 -0
  170. package/kits/schemas/role-config.schema.3.json +1038 -0
  171. package/kits/schemas/role-registry.schema.1.json +3 -2
  172. package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
  173. package/kits/skills/ec-trigger/SKILL.md +4 -4
  174. package/kits/skills/personal-assistant/SKILL.md +109 -53
  175. package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
  176. package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
  177. package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
  178. package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
  179. package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
  180. package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
  181. package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
  182. package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
  183. package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
  184. package/kits/templates/soul/00-GUIDE.md +39 -0
  185. package/kits/templates/soul/01-identity.md +5 -0
  186. package/kits/templates/soul/02-persona.md +11 -0
  187. package/kits/templates/soul/03-duties.md +5 -0
  188. package/kits/templates/soul/04-working-style.md +5 -0
  189. package/kits/templates/system-fragments/bootstrap.md +7 -7
  190. package/kits/templates/system-fragments/channel.md +2 -2
  191. package/kits/templates/system-fragments/commands.md +3 -2
  192. package/kits/templates/system-fragments/directory-contacts.md +9 -0
  193. package/kits/templates/system-fragments/memory.md +1 -1
  194. package/kits/templates/system-fragments/personal-assistant.md +50 -0
  195. package/kits/templates/system-fragments/reply.md +7 -0
  196. package/kits/templates/system-fragments/session.md +6 -2
  197. package/package.json +3 -2
  198. package/dist/cli/handoff-command.js +0 -353
  199. package/dist/directory/owner-directory-remark-operation.js +0 -147
  200. package/kits/docs/evolcore/self-summary.md +0 -29
@@ -0,0 +1,55 @@
1
+ // Tool-call time awareness: stamp the wall clock into the conversation at every
2
+ // natural tool-call pause point.
3
+ //
4
+ // 为什么需要:入站消息渲染层(eck/message-renderer.ts)只在消息到达时打时间戳,
5
+ // 工具调用期间模型完全不知道过去了多久。连续调用十几分钟的工具时,模型无法感知
6
+ // 时间推移,也就无从判断"该向 owner 报一声进度了"。
7
+ //
8
+ // 各 base agent 的注入通道不同,但渲染文本统一走这里,保证三个基座口径一致:
9
+ // - Claude Code:PostToolBatch hook 的 additionalContext(每批一次)
10
+ // - ecagent:harness 'context' hook,在下次请求前给末尾 toolResult 追加一段 text
11
+ // - Codex:app-server 无 PostToolUse hook,走 turn/steer 的 additionalContext
12
+ //
13
+ // 批次语义(与 PostToolBatch 定义一致):模型一次请求里可能并行发出多个 tool_use,
14
+ // 全部 resolve 后才是一次停顿。串行调用时每轮都会停顿一次,因此"每批一次"在串行
15
+ // 场景下等价于"每次工具一次"。
16
+ //
17
+ // 只注入时间点、不注入耗时:模型看到相邻停顿点的时间戳即可自行推算间隔,首条用户
18
+ // 消息也带时间戳,起点同样可得。省掉耗时字段后单行长度压到 20 字符以内。
19
+ /**
20
+ * 形如 "[⏱ 11-03 01:02:21]":本机时间,去掉年份与时区偏移,只为让模型感知"现在几点"。
21
+ * timeZone 仅测试用;生产走本机时区(不传即取进程默认)。
22
+ */
23
+ export function renderToolTime(now = Date.now(), timeZone) {
24
+ const parts = new Intl.DateTimeFormat('en-US', {
25
+ ...(timeZone ? { timeZone } : {}),
26
+ month: '2-digit',
27
+ day: '2-digit',
28
+ hour: '2-digit',
29
+ minute: '2-digit',
30
+ second: '2-digit',
31
+ hour12: false,
32
+ }).formatToParts(new Date(now));
33
+ const get = (type) => parts.find(part => part.type === type)?.value ?? '';
34
+ const hour = get('hour') === '24' ? '00' : get('hour'); // hour12:false may yield "24" at midnight
35
+ return `[⏱ ${get('month')}-${get('day')} ${hour}:${get('minute')}:${get('second')}]`;
36
+ }
37
+ /**
38
+ * ecagent 专用:在模型请求前给末尾的 toolResult 追加一段时间文本。
39
+ *
40
+ * 返回 null 表示不注入(末尾不是工具结果,即本轮还没跑过工具)。调用方据此跳过改写。
41
+ * 原消息不改动——它已进会话持久化,改写会污染历史;这里返回一个浅拷贝。
42
+ */
43
+ export function appendToolTimeToMessages(messages, now = Date.now()) {
44
+ const last = messages[messages.length - 1];
45
+ if (!last || last.role !== 'toolResult')
46
+ return null;
47
+ // toolResult 的 content 一定是 (TextContent | ImageContent)[];这里只按结构访问,
48
+ // 避免本模块反向依赖 ecagent 的运行时类型。
49
+ const content = last.content;
50
+ const stamped = {
51
+ ...last,
52
+ content: [...content, { type: 'text', text: renderToolTime(now) }],
53
+ };
54
+ return [...messages.slice(0, -1), stamped];
55
+ }
@@ -766,7 +766,7 @@ async function publishAgentMd(content, opts) {
766
766
  }
767
767
  const r = await store.uploadAgentMd(opts.aid, content);
768
768
  if (!r.ok)
769
- throw new Error(`upload agent.md failed for ${opts.aid}: ${r.error.message}`);
769
+ throw Object.assign(new Error(`upload agent.md failed for ${opts.aid}: ${r.error.message}`), { code: r.error.code });
770
770
  invalidateAgentDisplayName(opts.aid, aunPath);
771
771
  const remoteVersion = normalizeRemoteVersion({ exists: true, etag: r.data?.etag, last_modified: r.data?.last_modified ?? r.data?.lastModified });
772
772
  return {
@@ -789,6 +789,26 @@ export async function agentmdPut(content, opts) {
789
789
  const lockKey = `${path.resolve(aunPath)}\u0000${opts.aid.toLowerCase()}`;
790
790
  return withAgentMdWriteLock(lockKey, () => publishAgentMd(content, opts));
791
791
  }
792
+ /** Read, validate and replace a remote card in the same lock as CLI/profile writes. */
793
+ export async function agentmdUpdate(aid, update, opts = {}) {
794
+ const aunPath = resolveAgentMdAunPath(opts);
795
+ const lockKey = `${path.resolve(aunPath)}\u0000${aid.toLowerCase()}`;
796
+ return withAgentMdWriteLock(lockKey, async () => {
797
+ const store = opts.store ?? await getAidStore({ slotId: SLOT.cli, aunPath });
798
+ try {
799
+ const current = await agentmdGet(aid, { store, aunPath, withVerification: true, remoteOnly: true });
800
+ const content = await update(current);
801
+ return await publishAgentMd(content, { aid, store, aunPath, expectedRemoteVersion: current.remoteVersion });
802
+ }
803
+ finally {
804
+ if (!opts.store)
805
+ try {
806
+ store.close();
807
+ }
808
+ catch { /* ignore */ }
809
+ }
810
+ });
811
+ }
792
812
  /**
793
813
  * Apply a profile to an SDK-owned card. Ownership declarations are SDK output:
794
814
  * never reconstruct them from the form or replace the owned card with an
@@ -126,7 +126,7 @@ export class ManagedMenuClient {
126
126
  const sent = this.send({
127
127
  to: options.targetAid, payload: request, encrypt: true,
128
128
  ttl: MENU_MESSAGE_TTL_SECONDS, protected_headers: headers,
129
- })
129
+ }, options.beforeSend)
130
130
  .then(result => {
131
131
  if (!(result?.message_id ?? result?.message?.message_id))
132
132
  throw new MenuClientError('SEND_FAILED', 'message.send returned no message_id');
@@ -0,0 +1,17 @@
1
+ /** Per-message authenticated metadata. Never read the Agent's mutable model here:
2
+ * an in-flight turn must keep its model even after a configuration change. */
3
+ export function aunProtectedHeaders(context) {
4
+ const headers = {};
5
+ const raw = context?.metadata?.protectedHeaders;
6
+ if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
7
+ for (const [key, value] of Object.entries(raw)) {
8
+ const name = key.trim().toLowerCase();
9
+ if (/^[a-z0-9_-]+$/.test(name) && typeof value === 'string')
10
+ headers[name] = value;
11
+ }
12
+ }
13
+ const model = context?.model?.trim();
14
+ if (model)
15
+ headers.model = model;
16
+ return Object.keys(headers).length > 0 ? headers : undefined;
17
+ }
@@ -44,7 +44,8 @@ export function daemonTaskSendIpcTimeoutMs(file = false, requestTimeoutMs) {
44
44
  export function resolveAunMessageEncrypt(explicit) {
45
45
  if (typeof explicit === 'boolean')
46
46
  return explicit;
47
- return readDaemonConfigForSend().aun?.defaultEncrypt ?? true;
47
+ // 默认明文:只有显式 --encrypt 或 daemon.json 配置 aun.defaultEncrypt 才加密。
48
+ return readDaemonConfigForSend().aun?.defaultEncrypt ?? false;
48
49
  }
49
50
  function buildSimplePayload(body) {
50
51
  switch (body.mode) {
@@ -173,6 +174,9 @@ async function daemonMsgSendResult(args, payload, runtimeContext, daemonResult)
173
174
  target_session_id: daemonResult.target_session_id,
174
175
  request_id: daemonResult.request_id,
175
176
  request_state: daemonResult.request_state,
177
+ sent: daemonResult.sent,
178
+ retryable: daemonResult.retryable,
179
+ contact_request: daemonResult.contact_request,
176
180
  };
177
181
  }
178
182
  const completedRequest = args.returnPolicy === 'required' && !!daemonResult.request_id
@@ -184,7 +188,8 @@ async function daemonMsgSendResult(args, payload, runtimeContext, daemonResult)
184
188
  }
185
189
  const sent = {
186
190
  ok: true,
187
- message_id: daemonResult.message_id || daemonResult.handoff_id || '',
191
+ // handoff_id 是内部投递实例,不再冒充 message_id 回给调用方。
192
+ message_id: daemonResult.message_id || '',
188
193
  handoff_id: daemonResult.handoff_id,
189
194
  target_session_id: daemonResult.target_session_id,
190
195
  seq: daemonResult.seq,