evolcore 0.0.43-test.1 → 0.0.43-test.2

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 (170) hide show
  1. package/CHANGELOG.md +24 -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 +26 -9
  7. package/dist/agents/gemini-runner.js +15 -12
  8. package/dist/agents/tool-time-context.js +55 -0
  9. package/dist/aun/menu/client.js +1 -1
  10. package/dist/aun/model-headers.js +17 -0
  11. package/dist/aun/msg/p2p.js +3 -0
  12. package/dist/channels/aun.js +484 -43
  13. package/dist/channels/builtin-plugins.js +16 -11
  14. package/dist/channels/dingtalk.js +83 -31
  15. package/dist/channels/feishu.js +29 -13
  16. package/dist/channels/qqbot.js +32 -11
  17. package/dist/channels/wechat.js +13 -3
  18. package/dist/channels/wecom.js +67 -27
  19. package/dist/cli/agent-command.js +3 -86
  20. package/dist/cli/agent-create.js +22 -6
  21. package/dist/cli/agent.js +1 -79
  22. package/dist/cli/aun-commands.js +1 -0
  23. package/dist/cli/config.js +1 -1
  24. package/dist/cli/daemon-commands.js +47 -2
  25. package/dist/cli/data-command.js +9 -1
  26. package/dist/cli/debug-mode.js +1 -1
  27. package/dist/cli/diag.js +1 -1
  28. package/dist/cli/directory.js +77 -64
  29. package/dist/cli/getmeta-command.js +1 -1
  30. package/dist/cli/index.js +79 -22
  31. package/dist/cli/init.js +1 -23
  32. package/dist/cli/link-rules.js +1 -1
  33. package/dist/cli/managed-command-guard.js +0 -1
  34. package/dist/cli/pa-workspace-command.js +36 -2
  35. package/dist/cli/peer.js +1 -1
  36. package/dist/cli/restart-monitor.js +17 -3
  37. package/dist/cli/role.js +1 -1
  38. package/dist/cli/session-command.js +1 -1
  39. package/dist/cli/stats.js +2 -2
  40. package/dist/cli/thread-command.js +1 -1
  41. package/dist/cli/watch-msg.js +1 -1
  42. package/dist/config/access-policy.js +1 -0
  43. package/dist/config/config-field-policy.js +2 -2
  44. package/dist/config/config-manager.js +7 -0
  45. package/dist/config/role-schema.js +4 -3
  46. package/dist/config/role-service.js +3 -3
  47. package/dist/config-store.js +75 -4
  48. package/dist/core/agent-ipc-registration.js +16 -59
  49. package/dist/core/auth/authorization-audit.js +52 -14
  50. package/dist/core/auth/operation-authorizer.js +0 -11
  51. package/dist/core/auth/operation-catalog.js +0 -18
  52. package/dist/core/channel-loader.js +152 -16
  53. package/dist/core/command/agent-control.js +2 -1
  54. package/dist/core/command/cli-intent-parser.js +0 -8
  55. package/dist/core/command/command-handler.js +17 -46
  56. package/dist/core/command/connect-menu.js +7 -3
  57. package/dist/core/command/menu-catalog.js +3 -2
  58. package/dist/core/command/menu-handler.js +51 -8
  59. package/dist/core/command/menu-protocol.js +20 -0
  60. package/dist/core/command/slash-handler.js +101 -40
  61. package/dist/core/daemon-file-cache.js +3 -3
  62. package/dist/core/evolagent-registry.js +5 -4
  63. package/dist/core/evolagent.js +5 -8
  64. package/dist/core/handoff/argv-parse.js +115 -0
  65. package/dist/core/handoff/ipc-registration.js +1 -1
  66. package/dist/core/ipc-registration.js +19 -2
  67. package/dist/core/memory/consolidation.js +8 -1
  68. package/dist/core/memory/relation-sweep.js +20 -8
  69. package/dist/core/message/aun-ipc-sender.js +28 -1
  70. package/dist/core/message/contact-admission.js +548 -0
  71. package/dist/core/message/im-renderer.js +69 -10
  72. package/dist/core/message/message-admission.js +28 -3
  73. package/dist/core/message/message-bridge.js +46 -5
  74. package/dist/core/message/message-utils.js +0 -5
  75. package/dist/core/message/peer-mode.js +44 -10
  76. package/dist/core/message/response-engine.js +268 -69
  77. package/dist/core/message/retry-scheduler.js +4 -0
  78. package/dist/core/permission/ec-command-parser.js +1 -28
  79. package/dist/core/permission/readonly-shell-query.js +34 -8
  80. package/dist/core/permission/tool-policy.js +50 -5
  81. package/dist/core/role/runtime-policy.js +14 -2
  82. package/dist/core/session/session-manager.js +9 -1
  83. package/dist/core/soul.js +66 -0
  84. package/dist/core/system-session/memory.js +2 -2
  85. package/dist/directory/contact-admission-paths.js +9 -0
  86. package/dist/directory/owner-directory-admission.js +128 -29
  87. package/dist/directory/owner-directory-cache.js +364 -50
  88. package/dist/directory/owner-directory-identity.js +60 -0
  89. package/dist/directory/owner-directory-markdown.js +120 -47
  90. package/dist/directory/owner-directory-policy.js +108 -0
  91. package/dist/directory/owner-directory-query-operation.js +219 -32
  92. package/dist/directory/owner-directory-remarks.js +29 -2
  93. package/dist/directory/owner-directory-search.js +50 -18
  94. package/dist/directory/owner-directory-store.js +150 -30
  95. package/dist/eck/kit-renderer.js +12 -5
  96. package/dist/eck/manifest-engine.js +55 -6
  97. package/dist/eck/message-renderer.js +5 -2
  98. package/dist/eck/paactive-context.js +45 -0
  99. package/dist/ecweb/basic-settings-service.js +2 -2
  100. package/dist/ecweb/message-context-service.js +24 -16
  101. package/dist/index.js +9 -5
  102. package/dist/ipc.js +1 -1
  103. package/dist/paths.js +26 -0
  104. package/dist/response-system/config-resolver.js +1 -1
  105. package/dist/response-system/engines/v1/index.js +4 -1
  106. package/dist/response-system/engines/v1/paactive-flow.js +18 -0
  107. package/dist/response-system/modes/single-session/index.js +7 -2
  108. package/dist/trigger/scheduler.js +3 -5
  109. package/dist/trigger/validation.js +4 -0
  110. package/dist/utils/error-utils.js +5 -2
  111. package/dist/utils/logger.js +13 -4
  112. package/dist/utils/npm-ops.js +2 -2
  113. package/dist/utils/windows-autostart.js +1 -1
  114. package/ecagent/dist/agent-loop.js +43 -1
  115. package/kits/docs/INDEX.md +1 -0
  116. package/kits/docs/context-assembly.md +21 -6
  117. package/kits/docs/eck_templates/INDEX.template.md +1 -2
  118. package/kits/docs/evolcore/INDEX.md +1 -1
  119. package/kits/docs/evolcore/agent-create.md +5 -5
  120. package/kits/docs/evolcore/agent.md +4 -9
  121. package/kits/docs/evolcore/directory.md +137 -0
  122. package/kits/docs/evolcore/menu-protocol.md +55 -0
  123. package/kits/docs/evolcore/response.md +7 -1
  124. package/kits/docs/evolcore/tool-authorization.md +1 -1
  125. package/kits/docs/evolcore/trigger.md +4 -0
  126. package/kits/docs/prompt-loading-architecture.md +6 -2
  127. package/kits/eck_manifest.auxiliary.json +1 -0
  128. package/kits/eck_manifest.json +57 -4
  129. package/kits/eck_manifest.memory.json +67 -3
  130. package/kits/eck_manifest.paactive.json +528 -0
  131. package/kits/eck_message_manifest.paactive.json +233 -0
  132. package/kits/rules/01-overview.md +2 -2
  133. package/kits/rules/03-identity.md +10 -9
  134. package/kits/rules/05-venue.md +2 -4
  135. package/kits/rules/06-channel.md +1 -1
  136. package/kits/schemas/_meta.json +31 -3
  137. package/kits/schemas/agent-config.schema.18.json +5 -0
  138. package/kits/schemas/agent-config.schema.19.json +924 -0
  139. package/kits/schemas/relation-config.schema.12.json +289 -0
  140. package/kits/schemas/role-config.schema.2.json +215 -0
  141. package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
  142. package/kits/skills/ec-trigger/SKILL.md +4 -4
  143. package/kits/skills/personal-assistant/SKILL.md +109 -53
  144. package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
  145. package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
  146. package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
  147. package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
  148. package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
  149. package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
  150. package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
  151. package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
  152. package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
  153. package/kits/templates/message-fragments/paactive/item.md +3 -0
  154. package/kits/templates/soul/00-GUIDE.md +61 -0
  155. package/kits/templates/soul/01-identity.md +5 -0
  156. package/kits/templates/soul/02-persona.md +11 -0
  157. package/kits/templates/soul/03-duties.md +5 -0
  158. package/kits/templates/soul/04-working-style.md +5 -0
  159. package/kits/templates/system-fragments/bootstrap.md +7 -7
  160. package/kits/templates/system-fragments/commands.md +3 -2
  161. package/kits/templates/system-fragments/directory-contacts.md +9 -0
  162. package/kits/templates/system-fragments/memory.md +1 -1
  163. package/kits/templates/system-fragments/paactive/channel.md +25 -0
  164. package/kits/templates/system-fragments/paactive/reply.md +25 -0
  165. package/kits/templates/system-fragments/paactive/session.md +32 -0
  166. package/kits/templates/system-fragments/personal-assistant.md +65 -0
  167. package/package.json +3 -2
  168. package/dist/cli/handoff-command.js +0 -353
  169. package/dist/directory/owner-directory-remark-operation.js +0 -147
  170. package/kits/docs/evolcore/self-summary.md +0 -29
@@ -828,13 +828,16 @@ export function createConsolidationSessionFinalizer({ sessionManager, getAgent,
828
828
  // 读不到会话或批次目录时也要通知一次(只带 sessionId,链按它认领),否则链只能干等看门狗
829
829
  finalizedInfo = { sessionId, success, touchedPeerKeys: [] };
830
830
  const session = await sessionManager.getSessionById(sessionId);
831
- if (!session)
831
+ if (!session) {
832
+ success = false;
832
833
  return;
834
+ }
833
835
  const meta = (session.metadata ?? {});
834
836
  if (typeof meta.relationSweepId === 'string')
835
837
  finalizedInfo.relationSweepId = meta.relationSweepId;
836
838
  const batchDir = (meta.consolidationBatchDir ?? meta.consolidationLogBase);
837
839
  if (!batchDir) {
840
+ success = false;
838
841
  // 没有批次目录就没有流水可写;这是链路级的断裂,至少要能在日志里对上层
839
842
  logger.warn(`[Memory] 整理会话缺少批次目录,跳过收尾(session=${sessionId},`
840
843
  + `hasSession=${!!session},metadata 键=${Object.keys(meta).join(',') || '<空>'})`);
@@ -1113,6 +1116,7 @@ export function createConsolidationSessionFinalizer({ sessionManager, getAgent,
1113
1116
  }
1114
1117
  }
1115
1118
  catch (error) {
1119
+ success = false;
1116
1120
  logger.warn(`[Memory] 整理收尾失败(session=${sessionId}): ${error?.message}`);
1117
1121
  // 收尾本身抛错:批次目录可能已进入中间状态,把错误码与栈留在流水里
1118
1122
  if (batchDirForLog) {
@@ -1127,6 +1131,9 @@ export function createConsolidationSessionFinalizer({ sessionManager, getAgent,
1127
1131
  releaseSlot(releaseAid, sessionId);
1128
1132
  // 槽位释放之后再通知:链的下一步入队时,本 agent 的串行队列已经空出来
1129
1133
  if (finalizedInfo && onSessionFinalized) {
1134
+ finalizedInfo.success = success;
1135
+ if (!success)
1136
+ finalizedInfo.touchedPeerKeys = [];
1130
1137
  try {
1131
1138
  onSessionFinalized(finalizedInfo);
1132
1139
  }
@@ -22,7 +22,7 @@ import { logger } from '../../utils/logger.js';
22
22
  import { RELATION_SWEEP_ORDER, judgeRelationMode } from './consolidation-trigger.js';
23
23
  import { taskContextOfRoute } from './relation-idle-monitor.js';
24
24
  import { parsePeerKey } from '../relation/peer-identity.js';
25
- /** 单步整理会话迟迟不收尾时,链最多等这么久就放弃(整理会话自身 15 分钟超时,留余量)。 */
25
+ /** 单步整理会话迟迟不收尾时,链最多等这么久;队列自身 15 分钟超时后留出收尾余量。 */
26
26
  const DEFAULT_STEP_WATCHDOG_MS = 30 * 60_000;
27
27
  /**
28
28
  * 写进会话 metadata 的 relationSweepId 带上步骤序号:`<链 id>#<步骤序号>`。
@@ -77,8 +77,11 @@ export class RelationSweepRunner {
77
77
  if (peerKey !== state.request.peerKey)
78
78
  state.touched.add(peerKey);
79
79
  }
80
- if (!info.success)
80
+ if (!info.success) {
81
81
  state.failed = true;
82
+ this.stop(state);
83
+ return;
84
+ }
82
85
  this.stepDone(state);
83
86
  }
84
87
  /** 排队后拉起失败的通知(来自 ConsolidationQueue.setLaunchFailedListener)。 */
@@ -87,7 +90,7 @@ export class RelationSweepRunner {
87
90
  if (!state)
88
91
  return;
89
92
  state.failed = true;
90
- this.stepDone(state);
93
+ this.stop(state);
91
94
  }
92
95
  /** 回调对应的是某条链**正在等的那一步**时返回该链;过期步骤、无关会话返回 undefined。 */
93
96
  currentStep(tag, sessionId) {
@@ -121,6 +124,15 @@ export class RelationSweepRunner {
121
124
  state.waitingSessionId = undefined;
122
125
  void this.advance(state);
123
126
  }
127
+ stop(state) {
128
+ if (state.watchdog)
129
+ clearTimeout(state.watchdog);
130
+ state.watchdog = undefined;
131
+ state.waiting = undefined;
132
+ state.waitingSessionId = undefined;
133
+ state.remaining = [];
134
+ this.finish(state);
135
+ }
124
136
  async advance(state) {
125
137
  const { selfAid, peerKey, route, force } = state.request;
126
138
  while (state.remaining.length > 0) {
@@ -177,18 +189,18 @@ export class RelationSweepRunner {
177
189
  return;
178
190
  }
179
191
  if (!launched) {
180
- // 立即拉起失败:这一步作废,继续下一步
181
- state.waiting = undefined;
192
+ // 立即拉起失败:依赖当前步骤的后续步骤不再运行
182
193
  state.failed = true;
183
- continue;
194
+ this.stop(state);
195
+ return;
184
196
  }
185
197
  state.ran.push(mode);
186
198
  if (launched.executionSessionId)
187
199
  state.waitingSessionId = launched.executionSessionId;
188
200
  state.watchdog = setTimeout(() => {
189
- logger.warn(`[Memory] 关系整理链等待收尾超时,跳过该步(peerKey=${peerKey},mode=${mode})`);
201
+ logger.warn(`[Memory] 关系整理链等待收尾超时,停止后续步骤(peerKey=${peerKey},mode=${mode})`);
190
202
  state.failed = true;
191
- this.stepDone(state);
203
+ this.stop(state);
192
204
  }, this.stepWatchdogMs);
193
205
  state.watchdog.unref?.();
194
206
  return;
@@ -7,6 +7,7 @@ import { classifyAunPayloadForLog } from './message-log.js';
7
7
  import { isValidAunDeliveryForChannel } from './outbound.js';
8
8
  import { isHClassPath } from '../permission/protected-paths.js';
9
9
  import { evaluateOutboundContactAdmission } from './message-admission.js';
10
+ import { appContactAdmissionActive, contactIntroductionText, evaluateAppContactAdmission } from './contact-admission.js';
10
11
  import { normalizeAunMentionEntries, withAunAttention } from '../../aun/msg/mention-schema.js';
11
12
  import { resolveManagedSendArgv } from '../../cli/aun-commands.js';
12
13
  import { readTriggerLocalFile, resolveAttachmentLocalPath } from '../../trigger/local-files.js';
@@ -68,6 +69,7 @@ export function createAunHandoffSender(sessionManager, channelInstances, getOutb
68
69
  encrypt: handoff.request.encrypt,
69
70
  causation: handoff.causation,
70
71
  debug,
72
+ model: typeof debug?.model === 'string' ? debug.model : undefined,
71
73
  log,
72
74
  })
73
75
  : { ok: false, error: 'AUN channel does not support daemon group sends' }
@@ -78,6 +80,7 @@ export function createAunHandoffSender(sessionManager, channelInstances, getOutb
78
80
  encrypt: handoff.request.encrypt,
79
81
  causation: handoff.causation,
80
82
  debug,
83
+ model: typeof debug?.model === 'string' ? debug.model : undefined,
81
84
  log,
82
85
  })
83
86
  : { ok: false, error: 'AUN channel does not support daemon private sends' };
@@ -391,7 +394,29 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
391
394
  if (params.scope === 'msg') {
392
395
  const admission = await evaluateOutboundContactAdmission({ selfAid: params.aid, targetAid: params.to });
393
396
  if (!admission.allow) {
394
- return { ok: false, error: admission.error, code: admission.code };
397
+ const decision = appContactAdmissionActive(params.aid) ? evaluateAppContactAdmission(params.aid, params.to) : undefined;
398
+ const canRequestOwner = !!decision && (decision.reason === 'not_in_contacts' || decision.reason === 'scope_extension')
399
+ && !params.file && params.returnPolicy !== 'required' && contactIntroductionText(params.payload) !== undefined;
400
+ if (!canRequestOwner || typeof ch.requestOutboundContact !== 'function') {
401
+ return { ok: false, error: admission.error, code: admission.code, sent: false };
402
+ }
403
+ try {
404
+ // Retries of the same task message share an event; never queue the original peer send.
405
+ const sourceMessageId = 'outbound-' + crypto.createHash('sha256').update(JSON.stringify([
406
+ params.originSessionId, params.originMessageId, params.to, contactIntroductionText(params.payload),
407
+ ])).digest('hex');
408
+ const request = await ch.requestOutboundContact({ to: params.to, payload: params.payload, sourceMessageId });
409
+ if (!request.ok)
410
+ return { ok: false, code: request.code, error: request.error, sent: false };
411
+ const receipt = request.receipt;
412
+ return { ok: false, code: 'CONTACT_APPROVAL_REQUIRED', sent: false, retryable: false,
413
+ error: `目标 ${params.to} 未准入,${receipt.status === 'sent' ? '已向' : '已排队向'}本端 Owner ${receipt.owner_aid} 提交联系申请,等待审批;原消息未发送`,
414
+ contact_request: receipt };
415
+ }
416
+ catch (error) {
417
+ return { ok: false, code: 'CONTACT_OWNER_REQUEST_FAILED', sent: false,
418
+ error: `向本端 Owner 提交联系申请失败:${error instanceof Error ? error.message : String(error)};原消息未发送` };
419
+ }
395
420
  }
396
421
  }
397
422
  // The IPC command already carries the caller-selected transport scope.
@@ -591,6 +616,7 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
591
616
  mentions: params.mentions,
592
617
  encrypt,
593
618
  debug,
619
+ model: typeof debug?.model === 'string' ? debug.model : undefined,
594
620
  log: params.log ? { ...params.log, sessionId: targetSessionId ?? params.log.sessionId } : undefined,
595
621
  });
596
622
  if (params.thread && params.checkEveryMs !== undefined && sent.ok && sent.message_id && threadRoute) {
@@ -629,6 +655,7 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
629
655
  encrypt,
630
656
  causation: runtimeCausation,
631
657
  debug,
658
+ model: typeof debug?.model === 'string' ? debug.model : undefined,
632
659
  log: params.log ? { ...params.log, sessionId: targetSessionId ?? params.log.sessionId } : undefined,
633
660
  });
634
661
  if (preparedRequest) {