evolcore 0.0.26 → 0.0.28

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 (177) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/bin/codex-managed-acl.ps1 +43 -0
  3. package/dist/agents/baseagent-availability.js +68 -0
  4. package/dist/agents/baseagent.js +10 -5
  5. package/dist/agents/claude-runner.js +123 -22
  6. package/dist/agents/codex/app-server-client.js +70 -26
  7. package/dist/agents/codex/catalog.js +7 -1
  8. package/dist/agents/codex-runner.js +363 -421
  9. package/dist/agents/ecagent-runner.js +170 -25
  10. package/dist/agents/gemini-runner.js +6 -0
  11. package/dist/agents/runner-types.js +50 -2
  12. package/dist/aun/aid/agentmd.js +73 -31
  13. package/dist/aun/aid/client.js +1 -1
  14. package/dist/aun/aid/control-aid.js +180 -1
  15. package/dist/aun/aid/identity.js +3 -3
  16. package/dist/aun/group/history.js +303 -0
  17. package/dist/aun/group/identity.js +43 -0
  18. package/dist/aun/group/index.js +5 -0
  19. package/dist/aun/{msg/group.js → group/operations.js} +161 -38
  20. package/dist/aun/{menu-client.js → menu/client.js} +13 -7
  21. package/dist/aun/menu/index.js +2 -0
  22. package/dist/aun/menu/transport.js +49 -0
  23. package/dist/aun/msg/index.js +2 -1
  24. package/dist/aun/msg/managed-operation.js +84 -18
  25. package/dist/aun/msg/mention-schema.js +51 -0
  26. package/dist/aun/msg/p2p.js +13 -8
  27. package/dist/aun/msg/upload.js +43 -88
  28. package/dist/aun/outbox.js +29 -7
  29. package/dist/aun/rpc/client.js +1 -0
  30. package/dist/aun/storage/client.js +39 -50
  31. package/dist/channels/aun.js +544 -239
  32. package/dist/channels/daemon.js +10 -6
  33. package/dist/cli/agent-command.js +108 -6
  34. package/dist/cli/agent-create.js +515 -2
  35. package/dist/cli/agent.js +109 -8
  36. package/dist/cli/aun-commands.js +191 -42
  37. package/dist/cli/config.js +8 -5
  38. package/dist/cli/contact.js +2 -2
  39. package/dist/cli/ctl-command.js +2 -2
  40. package/dist/cli/daemon-commands.js +111 -162
  41. package/dist/cli/diag.js +3 -3
  42. package/dist/cli/fs-command.js +3 -3
  43. package/dist/cli/handoff-command.js +6 -6
  44. package/dist/cli/index.js +8 -2
  45. package/dist/cli/init.js +34 -1
  46. package/dist/cli/managed-command-guard.js +2 -1
  47. package/dist/cli/menu-client.js +13 -5
  48. package/dist/cli/model.js +3 -3
  49. package/dist/cli/queue-command.js +2 -2
  50. package/dist/cli/response.js +2 -2
  51. package/dist/cli/restart-monitor.js +81 -19
  52. package/dist/cli/task-command.js +59 -0
  53. package/dist/cli/task-context.js +97 -49
  54. package/dist/cli/trigger-command.js +20 -10
  55. package/dist/config/builtin-roles.js +10 -0
  56. package/dist/config/config-field-policy.js +11 -0
  57. package/dist/config/config-manager.js +32 -4
  58. package/dist/config/config-operation-service.js +20 -5
  59. package/dist/config/contact-book-store.js +1 -1
  60. package/dist/config/contact-book.js +1 -1
  61. package/dist/config/contact-operation-service.js +1 -1
  62. package/dist/config/peer-role-resolver.js +1 -1
  63. package/dist/config/resolved-config-op.js +3 -0
  64. package/dist/config-store.js +1 -1
  65. package/dist/core/agent-application-service.js +5 -0
  66. package/dist/core/audit/event-key.js +17 -2
  67. package/dist/core/audit/log-integrity.js +34 -8
  68. package/dist/core/auth/agent-delegation.js +48 -14
  69. package/dist/core/auth/auth-gateway.js +2 -0
  70. package/dist/core/auth/authorization-audit.js +34 -38
  71. package/dist/core/auth/operation-authorizer.js +67 -5
  72. package/dist/core/auth/operation-catalog.js +110 -0
  73. package/dist/core/auth/remote-access-store.js +115 -9
  74. package/dist/core/bootstrap-messages.js +66 -7
  75. package/dist/core/bootstrap-service.js +110 -19
  76. package/dist/core/command/agent-control.js +88 -7
  77. package/dist/core/command/agent-storage-menu.js +443 -0
  78. package/dist/core/command/cli-intent-parser.js +19 -0
  79. package/dist/core/command/command-handler.js +105 -40
  80. package/dist/core/command/data-root-resolver.js +273 -0
  81. package/dist/core/command/diag-service.js +292 -27
  82. package/dist/core/command/group-menu.js +7 -2
  83. package/dist/core/command/menu-catalog.js +34 -4
  84. package/dist/core/command/menu-handler.js +364 -96
  85. package/dist/core/command/menu-protocol.js +43 -6
  86. package/dist/core/command/role-menu.js +2 -2
  87. package/dist/core/command/slash-handler.js +61 -37
  88. package/dist/core/event-catalog.js +4 -0
  89. package/dist/core/evolagent-registry.js +28 -2
  90. package/dist/core/group/invite-service.js +924 -0
  91. package/dist/core/interaction-router.js +22 -8
  92. package/dist/core/message/im-renderer.js +94 -16
  93. package/dist/core/message/message-bridge.js +140 -13
  94. package/dist/core/message/message-log.js +5 -3
  95. package/dist/core/message/message-queue.js +73 -41
  96. package/dist/core/message/response-engine.js +729 -118
  97. package/dist/core/permission/approval-gateway.js +36 -3
  98. package/dist/core/permission/ec-command-parser.js +76 -36
  99. package/dist/core/permission/protected-paths.js +134 -16
  100. package/dist/core/permission/sandbox-runtime.js +72 -3
  101. package/dist/core/permission/tool-error-code.js +15 -0
  102. package/dist/core/permission/tool-policy.js +8 -8
  103. package/dist/core/relation/peer-identity.js +57 -6
  104. package/dist/core/relation/shared-data.js +106 -0
  105. package/dist/core/role/runtime-policy.js +64 -0
  106. package/dist/core/runtime-lock.js +10 -26
  107. package/dist/core/session/runner-task-history.js +170 -0
  108. package/dist/core/session/session-manager.js +38 -6
  109. package/dist/core/session/session-mapper.js +41 -0
  110. package/dist/core/session/session-turn-coordinator.js +37 -7
  111. package/dist/core/session/session-turns.js +48 -7
  112. package/dist/core/task/task-recovery-service.js +176 -0
  113. package/dist/core/task/task-resume-operation.js +32 -0
  114. package/dist/eck/group-rules-sync.js +5 -3
  115. package/dist/eck/kit-renderer.js +1 -0
  116. package/dist/index.js +322 -207
  117. package/dist/ipc.js +141 -15
  118. package/dist/paths.js +17 -4
  119. package/dist/product.js +3 -0
  120. package/dist/trigger/event-source.js +19 -0
  121. package/dist/trigger/feedback.js +233 -40
  122. package/dist/trigger/parser.js +55 -5
  123. package/dist/trigger/patch.js +9 -0
  124. package/dist/trigger/scheduler.js +30 -4
  125. package/dist/trigger/validation.js +20 -3
  126. package/dist/utils/atomic-write.js +98 -0
  127. package/dist/utils/cross-platform.js +87 -16
  128. package/dist/utils/ecweb-utils.js +1 -0
  129. package/dist/utils/error-utils.js +40 -2
  130. package/dist/utils/logger.js +23 -13
  131. package/dist/utils/npm-ops.js +119 -4
  132. package/dist/utils/package-version-info.js +244 -0
  133. package/dist/utils/tool-summary.js +59 -3
  134. package/dist/utils/welcome.js +174 -1
  135. package/dist/utils/windows-shell-trust.js +37 -0
  136. package/ecagent/dist/harness/agent-harness.js +3 -0
  137. package/ecagent/dist/harness/session/jsonl-storage.js +21 -2
  138. package/kits/docs/INDEX.md +0 -6
  139. package/kits/docs/channels/aun.md +23 -2
  140. package/kits/docs/channels/feishu.md +1 -1
  141. package/kits/docs/context-assembly.md +29 -17
  142. package/kits/docs/evolcore/INDEX.md +8 -3
  143. package/kits/docs/evolcore/agent-create.md +39 -7
  144. package/kits/docs/evolcore/agent.md +33 -1
  145. package/kits/docs/evolcore/aid.md +9 -1
  146. package/kits/docs/evolcore/config.md +40 -1
  147. package/kits/docs/evolcore/group-collaboration.md +1 -1
  148. package/kits/docs/evolcore/group.md +117 -2
  149. package/kits/docs/evolcore/menu-client.md +16 -0
  150. package/kits/docs/evolcore/msg.md +3 -0
  151. package/kits/docs/evolcore/storage.md +3 -0
  152. package/kits/docs/evolcore/task.md +14 -0
  153. package/kits/docs/evolcore/trigger.md +51 -3
  154. package/kits/docs/venues/group.md +5 -0
  155. package/kits/eck_manifest.json +27 -0
  156. package/kits/rules/01-overview.md +11 -7
  157. package/kits/rules/04-relation.md +2 -1
  158. package/kits/rules/05-venue.md +1 -1
  159. package/kits/rules/06-channel.md +6 -4
  160. package/kits/schemas/agent-config.schema.12.json +25 -1
  161. package/kits/schemas/daemon.schema.6.json +2 -2
  162. package/kits/schemas/defaults.schema.5.json +1 -1
  163. package/kits/schemas/relation-config.schema.1.json +1 -1
  164. package/kits/schemas/relation-config.schema.5.json +1 -1
  165. package/kits/schemas/role-config.schema.1.json +14 -0
  166. package/kits/templates/roles/member.json +5 -0
  167. package/kits/templates/roles/visitor.json +5 -0
  168. package/kits/templates/system-fragments/baseagent.md +1 -1
  169. package/kits/templates/system-fragments/bootstrap.md +26 -9
  170. package/kits/templates/system-fragments/channel.md +8 -44
  171. package/kits/templates/system-fragments/commands.md +10 -2
  172. package/kits/templates/system-fragments/group-unread-history.md +7 -0
  173. package/kits/templates/system-fragments/reply.md +56 -0
  174. package/package.json +7 -3
  175. package/dist/aun/group-identity.js +0 -9
  176. /package/dist/aun/{group-fs-download.js → group/fs-download.js} +0 -0
  177. /package/dist/aun/{msg/group-index.js → group/index-rpc.js} +0 -0
@@ -1,3 +1,4 @@
1
+ import { ExecutionTimeoutError } from '../utils/error-utils.js';
1
2
  import { normalizeExecutionMode } from '../trigger/validation.js';
2
3
  import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
3
4
  const DEFAULT_WATCHDOG_MS = 11 * 60 * 1000;
@@ -349,7 +350,7 @@ export class DaemonChannel {
349
350
  watchdogMs: this.watchdogMs,
350
351
  }))
351
352
  return;
352
- this.cancelDeliveryInBackground(slot);
353
+ this.cancelDeliveryInBackground(slot, new ExecutionTimeoutError('daemon_watchdog_timeout', this.watchdogMs));
353
354
  this.settleTerminal(runId, slot);
354
355
  }
355
356
  resetWatchdog(runId, slot) {
@@ -373,20 +374,23 @@ export class DaemonChannel {
373
374
  totalExecutionMs,
374
375
  }))
375
376
  return;
376
- this.cancelDeliveryInBackground(slot);
377
+ this.cancelDeliveryInBackground(slot, new ExecutionTimeoutError('daemon_total_execution_timeout', totalExecutionMs));
377
378
  this.settleTerminal(runId, slot);
378
379
  }
379
- cancelDeliveryInBackground(slot) {
380
- const cancellation = this.cancelDelivery(slot.messageId);
380
+ cancelDeliveryInBackground(slot, timeout) {
381
+ const cancellation = this.cancelDelivery(slot.messageId, timeout);
381
382
  slot.cancellationBarrier = cancellation;
382
383
  void cancellation.then(() => undefined, () => undefined);
383
384
  }
384
- async cancelDelivery(messageId) {
385
+ async cancelDelivery(messageId, timeout) {
385
386
  const queue = this.messageQueue;
386
387
  if (queue.cancel?.(messageId))
387
388
  return;
388
389
  if (queue.cancelActiveAndWait) {
389
- await queue.cancelActiveAndWait(messageId);
390
+ if (timeout)
391
+ await queue.cancelActiveAndWait(messageId, undefined, timeout);
392
+ else
393
+ await queue.cancelActiveAndWait(messageId);
390
394
  return;
391
395
  }
392
396
  queue.cancelActive?.(messageId);
@@ -1,7 +1,23 @@
1
1
  import path from 'path';
2
+ import { MAIN_CLI_BIN, SELF_AID_ENV, SESSION_ID_ENV } from '../product.js';
2
3
  import { getArgValue, isHelpFlag, wantsHelp } from './help.js';
3
4
  import { isHostChinese } from '../utils/locale.js';
4
5
  import { readTaskRuntimeContextFromEnv } from './task-context.js';
6
+ import { parseAgentWelcomeArgs } from './agent-create.js';
7
+ function printBootstrapDeliveries(result) {
8
+ for (const delivery of result?.deliveries ?? []) {
9
+ if (delivery.status === 'sent')
10
+ console.log(` ${delivery.owner}: 消息已被网关接受 (${delivery.messageId})`);
11
+ else if (delivery.status === 'queued')
12
+ console.log(` ${delivery.owner}: 消息已入队,等待重试 (${delivery.outboxId})`);
13
+ else if (delivery.status === 'failed')
14
+ console.error(` ${delivery.owner}: 消息发送失败 [${delivery.code ?? 'unknown'}] ${delivery.error}`);
15
+ else
16
+ console.log(` ${delivery.owner}: 没有消息投递记录`);
17
+ }
18
+ if (result?.error)
19
+ console.error(` 消息状态异常: ${result.error}`);
20
+ }
5
21
  function formatTimeAgo(ms) {
6
22
  const sec = Math.floor(ms / 1000);
7
23
  if (sec < 60)
@@ -26,7 +42,7 @@ function formatBytes(bytes) {
26
42
  export async function cmdAgent(args) {
27
43
  const sub = args[0];
28
44
  const formatJson = getArgValue(args, '--format') === 'json';
29
- const commands = new Set(['list', 'show', 'new', 'enable', 'disable', 'get', 'set', 'persona', 'rename', 'ready', 'reload', 'delete']);
45
+ const commands = new Set(['list', 'show', 'new', 'initialize', 'enable', 'disable', 'get', 'set', 'persona', 'welcome', 'rename', 'ready', 'reload', 'delete']);
30
46
  if (sub === 'create') {
31
47
  const error = { ok: false, code: 'INVALID_COMMAND', error: '`ec agent create` is not a command; use `ec agent new`.' };
32
48
  if (formatJson)
@@ -44,6 +60,8 @@ Commands:
44
60
  show <aid> 查看 agent 详情(身份 + 配置 + 连接 + 会话 + 路径)
45
61
  new [aid] 交互式创建 agent
46
62
  new <aid> --non-interactive ... 非交互式创建
63
+ new <aid> --initialize ... 创建并激活(隐含非交互)
64
+ initialize <aid> --resume 恢复一次性初始化
47
65
  enable <aid> 启用 agent
48
66
  disable <aid> 停用 agent
49
67
  get <aid> <key> 读取单个配置字段(支持点路径)
@@ -51,6 +69,8 @@ Commands:
51
69
  persona show 查看当前 Agent 的 persona.md
52
70
  persona --text <text> 用文本设置当前 Agent 的 persona.md
53
71
  persona --file <path> 用 .md/.txt 文件设置当前 Agent 的 persona.md
72
+ welcome show 查看已确认的 Bootstrap welcome 文案
73
+ welcome --text <text> 保存 Owner 已确认的 Bootstrap welcome 文案
54
74
  rename <aid> <name> 修改 agent.md 中的显示名称
55
75
  ready <aid> 标记 bootstrap 完成,进入 active 状态
56
76
  reload [aid] 热重载配置(无参数=全量 resync)
@@ -73,10 +93,39 @@ Options:
73
93
  ec agent delete mybot.agentid.pub --purge`);
74
94
  return;
75
95
  }
76
- const { agentList, agentShow, agentCreateInteractive, agentCreateNonInteractive, agentReload, agentEnable, agentDisable, agentGet, agentSet, agentPersona, agentRename, agentDelete, agentReady, runManagedAgentOperation, } = await import('./agent.js');
96
+ if ((sub === 'new' && args.includes('--initialize')) || sub === 'initialize') {
97
+ if (wantsHelp(args)) {
98
+ console.log('ec agent new <aid> --initialize --name <name> --description <text> --tags <json> [--owner <aid> | --owners <json>] [--persona-file <path> | --persona-text <text>] [--wait 0..300] [--dry-run] [--format json]\nec agent initialize <aid> --resume [--wait 0..300] [--format json]\n--initialize implies --non-interactive; waits for activation (default 60 seconds).');
99
+ return;
100
+ }
101
+ try {
102
+ const { runInitializationCommand } = await import('./agent-create.js');
103
+ const result = await runInitializationCommand(args);
104
+ if (formatJson)
105
+ console.log(JSON.stringify(result, null, 2));
106
+ else if (result.dryRun)
107
+ console.log(JSON.stringify(result, null, 2));
108
+ else if (result.ok)
109
+ console.log(`✓ ${result.aid} initialized (active)`);
110
+ else
111
+ console.error(`[${result.code}] ${result.error ?? result.phase ?? 'Initialization failed'}`);
112
+ if (!result.ok)
113
+ process.exitCode = result.code === 'INITIALIZE_PENDING' ? 2 : 1;
114
+ }
115
+ catch (error) {
116
+ const result = { ok: false, code: 'INVALID_ARGS', error: error instanceof Error ? error.message : String(error) };
117
+ if (formatJson)
118
+ console.log(JSON.stringify(result));
119
+ else
120
+ console.error(result.error);
121
+ process.exitCode = 1;
122
+ }
123
+ return;
124
+ }
125
+ const { agentList, agentShow, agentCreateInteractive, agentCreateNonInteractive, agentReload, agentEnable, agentDisable, agentGet, agentSet, agentPersona, agentWelcome, agentRename, agentDelete, agentReady, runManagedAgentOperation, } = await import('./agent.js');
77
126
  const { parseAgentOwnerArgs, parseAgentTags, resolveAgentCreatePlan, validateAgentCreatePlan } = await import('./agent-create.js');
78
- if (process.env.EVOLCORE_SESSION_ID && !wantsHelp(args) && !new Set(['get', 'set', 'persona', 'ready']).has(sub)) {
79
- if (sub === 'new' && !args.includes('--non-interactive')) {
127
+ if (process.env.EVOLCORE_SESSION_ID && !wantsHelp(args) && !new Set(['get', 'set', 'persona', 'welcome', 'ready']).has(sub)) {
128
+ if (sub === 'new' && !args.includes('--non-interactive') && !args.includes('--initialize')) {
80
129
  const error = {
81
130
  ok: false,
82
131
  code: 'MANAGED_NON_INTERACTIVE_REQUIRED',
@@ -212,6 +261,9 @@ Options:
212
261
  ec agent new <aid> --non-interactive [选项]
213
262
 
214
263
  非交互模式选项:
264
+ --initialize 使用显式名片直接完成初始化(隐含 --non-interactive)
265
+ --persona-file <path> 初始化人格 .md/.txt(或 --persona-text <text>)
266
+ --wait <seconds> 初始化等待 0–300 秒,默认 60
215
267
  --project <path> 默认: 当前目录
216
268
  --baseagent <claude|codex|gemini|ecagent>
217
269
  默认: defaults 配置,否则检测本机可用基座
@@ -220,7 +272,7 @@ Options:
220
272
  --handoff <context> 当前任务的 Bootstrap 上下文
221
273
  --name <display-name> 默认: package.json name,否则目录名
222
274
  --description <text> 默认: package.json description,否则使用 EvolCore 默认描述
223
- --type <type> 主体类型: human|agent|group|service|device|org(默认 agent)
275
+ --type <type> 主体类型: human|agent|group|service|device|org|host(默认 agent)
224
276
  --tags <json-array> 3 到 6 个标签,例如 '["coding","diagnostics","logs"]'
225
277
  --dry-run 只预览最终参数,不注册 AID、不写文件
226
278
  --force 覆盖已有 config.json
@@ -617,6 +669,55 @@ Options:
617
669
  console.log(result.content ?? '(persona.md 不存在)');
618
670
  return;
619
671
  }
672
+ if (sub === 'welcome') {
673
+ if (args.length === 2 && isHelpFlag(args[1])) {
674
+ console.log(`用法: ${MAIN_CLI_BIN} agent welcome show [--format json]
675
+ ${MAIN_CLI_BIN} agent welcome --text <text> [--format json]
676
+
677
+ 读取或保存当前 Agent 在 Bootstrap 中经 Owner 确认的 welcome 文案。文案固定保存到 personal/welcome.md。`);
678
+ return;
679
+ }
680
+ let text;
681
+ try {
682
+ ({ text } = parseAgentWelcomeArgs(args.slice(1)));
683
+ }
684
+ catch (error) {
685
+ const result = { ok: false, code: 'INVALID_ARGS', error: error.message };
686
+ if (formatJson)
687
+ console.log(JSON.stringify(result));
688
+ else
689
+ console.error(`❌ ${result.error}`);
690
+ process.exitCode = 1;
691
+ return;
692
+ }
693
+ const taskAid = process.env[SESSION_ID_ENV] ? (readTaskRuntimeContextFromEnv()?.selfAid || '') : '';
694
+ const aid = taskAid || process.env[SELF_AID_ENV] || '';
695
+ if (!aid) {
696
+ const result = { ok: false, code: 'INVALID_ARGS', error: '无法确定当前 Agent AID' };
697
+ if (formatJson)
698
+ console.log(JSON.stringify(result));
699
+ else
700
+ console.error(`❌ ${result.error}`);
701
+ process.exitCode = 1;
702
+ return;
703
+ }
704
+ const result = await agentWelcome(aid, { text });
705
+ if (!result.ok) {
706
+ if (formatJson)
707
+ console.log(JSON.stringify(result));
708
+ else
709
+ console.error(`❌ ${result.error}`);
710
+ process.exitCode = 1;
711
+ return;
712
+ }
713
+ if (formatJson)
714
+ console.log(JSON.stringify(result, null, 2));
715
+ else if (result.saved)
716
+ console.log(`✓ ${aid} welcome.md 已保存`);
717
+ else
718
+ console.log(result.content ?? '(welcome.md 不存在)');
719
+ return;
720
+ }
620
721
  if (sub === 'get') {
621
722
  if (wantsHelp(args)) {
622
723
  console.log(`用法: ec agent get <aid> <key> [--format json]
@@ -722,7 +823,8 @@ Options:
722
823
  console.log(JSON.stringify(result, null, 2));
723
824
  }
724
825
  else {
725
- console.log(`✓ ${aid} lifecycle=active${result.reloaded ? ' (runtime updated)' : ' (daemon offline or not updated)'}`);
826
+ console.log(`✓ ${aid} lifecycle=active${result.reloaded ? ' (runtime updated)' : ''}`);
827
+ printBootstrapDeliveries(result.welcome);
726
828
  }
727
829
  return;
728
830
  }