evolcore 0.0.10 → 0.0.12

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 (131) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +3 -3
  3. package/bin/codex-managed-hook.mjs +80 -0
  4. package/dist/agents/baseagent.js +4 -0
  5. package/dist/agents/claude-runner.js +158 -44
  6. package/dist/agents/codex-app-server-client.js +153 -23
  7. package/dist/agents/codex-runner.js +331 -43
  8. package/dist/agents/ecagent-runner.js +53 -6
  9. package/dist/agents/gemini-runner.js +1 -0
  10. package/dist/agents/request-identity.js +55 -0
  11. package/dist/aun/aid/client.js +11 -21
  12. package/dist/aun/aid/managed-operation.js +107 -0
  13. package/dist/aun/msg/group.js +81 -12
  14. package/dist/aun/msg/managed-operation.js +804 -0
  15. package/dist/aun/msg/mention-schema.js +20 -0
  16. package/dist/aun/msg/p2p.js +7 -0
  17. package/dist/aun/outbox.js +28 -31
  18. package/dist/channels/aun.js +418 -235
  19. package/dist/channels/daemon.js +13 -0
  20. package/dist/cli/agent-command.js +72 -17
  21. package/dist/cli/agent.js +249 -22
  22. package/dist/cli/aun-commands.js +270 -69
  23. package/dist/cli/bench.js +12 -3
  24. package/dist/cli/daemon-commands.js +52 -33
  25. package/dist/cli/fs-command.js +60 -0
  26. package/dist/cli/handoff-command.js +3 -0
  27. package/dist/cli/index.js +106 -63
  28. package/dist/cli/init-cancel.js +208 -0
  29. package/dist/cli/init-channel.js +343 -195
  30. package/dist/cli/init.js +21 -9
  31. package/dist/cli/managed-command-guard.js +41 -0
  32. package/dist/cli/model.js +11 -4
  33. package/dist/cli/queue-command.js +11 -1
  34. package/dist/cli/response.js +71 -0
  35. package/dist/cli/restart-monitor.js +4 -18
  36. package/dist/cli/trigger-command.js +4 -0
  37. package/dist/config/builtin-roles.js +5 -0
  38. package/dist/config/contact-book-store.js +11 -3
  39. package/dist/config/contact-request-service.js +161 -15
  40. package/dist/config/gateway-config.js +26 -10
  41. package/dist/config/mention-mode.js +8 -24
  42. package/dist/core/agent-reload-coordinator.js +53 -0
  43. package/dist/core/auth/agent-delegation.js +0 -1
  44. package/dist/core/auth/operation-authorizer.js +62 -154
  45. package/dist/core/auth/operation-catalog.js +264 -22
  46. package/dist/core/bootstrap-messages.js +68 -0
  47. package/dist/core/bootstrap-service.js +144 -10
  48. package/dist/core/capability/providers/claude-capability-provider.js +9 -31
  49. package/dist/core/capability/providers/codex-capability-provider.js +4 -15
  50. package/dist/core/capability/skill-discovery.js +55 -0
  51. package/dist/core/channel-loader.js +24 -7
  52. package/dist/core/command/agent-control.js +14 -11
  53. package/dist/core/command/cli-intent-parser.js +9 -0
  54. package/dist/core/command/command-handler.js +467 -6
  55. package/dist/core/command/connect-menu.js +15 -0
  56. package/dist/core/command/group-menu.js +4 -4
  57. package/dist/core/command/menu-catalog.js +366 -0
  58. package/dist/core/command/menu-handler.js +213 -110
  59. package/dist/core/command/menu-protocol.js +71 -0
  60. package/dist/core/command/slash-gate.js +5 -2
  61. package/dist/core/command/slash-handler.js +45 -25
  62. package/dist/core/daemon-file-cache.js +2 -1
  63. package/dist/core/data-migration.js +9 -2
  64. package/dist/core/evolagent-registry.js +125 -35
  65. package/dist/core/evolagent.js +12 -5
  66. package/dist/core/handoff/dispatcher.js +5 -2
  67. package/dist/core/handoff/runtime.js +145 -21
  68. package/dist/core/handoff/store.js +24 -0
  69. package/dist/core/handoff/types.js +1 -0
  70. package/dist/core/inference/text-inference.js +38 -4
  71. package/dist/core/message/logical-queue-bridge.js +1 -0
  72. package/dist/core/message/mention-schema.js +126 -0
  73. package/dist/core/message/message-bridge.js +237 -79
  74. package/dist/core/message/message-log.js +23 -0
  75. package/dist/core/message/message-queue.js +20 -4
  76. package/dist/core/message/response-engine.js +54 -36
  77. package/dist/core/model/model-catalog.js +143 -24
  78. package/dist/core/model/model-diagnostics.js +28 -10
  79. package/dist/core/permission/ec-command-parser.js +156 -10
  80. package/dist/core/permission/index.js +1 -0
  81. package/dist/core/permission/readonly-shell-query.js +532 -0
  82. package/dist/core/permission/sandbox-runtime.js +22 -1
  83. package/dist/core/permission/shell-environment.js +46 -0
  84. package/dist/core/permission/tool-policy.js +292 -111
  85. package/dist/core/protected-paths.js +17 -9
  86. package/dist/core/runner-reload-transaction.js +57 -0
  87. package/dist/core/session/session-manager.js +21 -2
  88. package/dist/eck/manifest-engine.js +39 -13
  89. package/dist/index.js +644 -180
  90. package/dist/ipc.js +246 -19
  91. package/dist/response-system/coordinator.js +6 -4
  92. package/dist/response-system/engines/v1/proactive-flow.js +26 -8
  93. package/dist/response-system/modes/single-session/index.js +14 -1
  94. package/dist/response-system/selector.js +6 -5
  95. package/dist/trigger/anomaly-store.js +4 -0
  96. package/dist/trigger/script-executor.js +1 -0
  97. package/dist/utils/aid-bind.js +3 -8
  98. package/dist/utils/codex-app-server-registry.js +90 -0
  99. package/dist/utils/codex-cli.js +5 -1
  100. package/dist/utils/cross-platform.js +15 -0
  101. package/dist/utils/log-writer.js +6 -10
  102. package/dist/utils/logger.js +5 -5
  103. package/dist/utils/npm-ops.js +5 -12
  104. package/dist/utils/tool-summary.js +11 -0
  105. package/kits/docs/channels/aun.md +1 -1
  106. package/kits/docs/context-assembly.md +2 -2
  107. package/kits/docs/evolcore/agent.md +11 -6
  108. package/kits/docs/evolcore/aid.md +14 -0
  109. package/kits/docs/evolcore/msg.md +13 -0
  110. package/kits/docs/prompt-loading-architecture.md +1 -2
  111. package/kits/docs/venues/group.md +1 -1
  112. package/kits/eck_manifest.json +0 -12
  113. package/kits/rules/01-overview.md +9 -0
  114. package/kits/rules/04-relation.md +1 -1
  115. package/kits/rules/05-venue.md +2 -2
  116. package/kits/schemas/agent-config.schema.3.json +1 -1
  117. package/kits/schemas/agent-config.schema.4.json +1 -1
  118. package/kits/schemas/relation-config.schema.2.json +1 -1
  119. package/kits/schemas/role-config.schema.1.json +1 -1
  120. package/kits/schemas/single-session.schema.1.json +3 -3
  121. package/kits/schemas/single-session.schema.2.json +3 -3
  122. package/kits/templates/roles/admin.json +27 -0
  123. package/kits/templates/roles/member.json +44 -0
  124. package/kits/templates/roles/visitor.json +40 -2
  125. package/kits/templates/system-fragments/bootstrap.md +12 -6
  126. package/kits/templates/system-fragments/channel.md +6 -0
  127. package/kits/templates/system-fragments/session.md +2 -0
  128. package/package.json +3 -2
  129. package/skills/eclink/SKILL.md +15 -3
  130. package/skills/eclink/agents/openai.yaml +3 -3
  131. package/dist/core/command/evol-menu-version-gate.js +0 -39
@@ -0,0 +1,20 @@
1
+ import { MentionSchemaError, normalizeMentionEntries, } from '../../core/message/mention-schema.js';
2
+ const AUN_MENTION_KEYS = new Set(['aid', 'scope', 'display', 'offset', 'length']);
3
+ /**
4
+ * Validate the AUN wire schema. `userId` is deliberately excluded here:
5
+ * it identifies users in platform-native adapters such as Feishu/DingTalk,
6
+ * while AUN addresses agents with `aid` and uses `scope: 'all'` for broadcast.
7
+ */
8
+ export function normalizeAunMentionEntries(raw) {
9
+ const entries = normalizeMentionEntries(raw);
10
+ for (const [index, entry] of entries.entries()) {
11
+ if ('userId' in entry) {
12
+ throw new MentionSchemaError('userId is not valid in AUN mentions; use {aid: "..."}', index);
13
+ }
14
+ const unsupported = Object.keys(entry).find(key => !AUN_MENTION_KEYS.has(key));
15
+ if (unsupported) {
16
+ throw new MentionSchemaError(`${unsupported} is not valid AUN mention metadata`, index);
17
+ }
18
+ }
19
+ return entries;
20
+ }
@@ -10,6 +10,7 @@ import { resolvePaths } from '../../paths.js';
10
10
  import { ipcQuery } from '../../ipc.js';
11
11
  import { AGENT_DELEGATION_TOKEN_ENV } from '../../core/auth/agent-delegation.js';
12
12
  import { loadDaemonConfig } from '../../config-store.js';
13
+ import { normalizeAunMentionEntries } from './mention-schema.js';
13
14
  const DEFAULT_TASK_EXECUTION_MS = 60 * 60 * 1000;
14
15
  const DAEMON_SEND_TIMEOUT_GRACE_MS = 10_000;
15
16
  const MAX_TIMER_MS = 2_147_483_647;
@@ -206,6 +207,9 @@ export async function msgSend(args) {
206
207
  let payload;
207
208
  if (args.body.mode !== 'file') {
208
209
  payload = buildSimplePayload(args.body);
210
+ if (Object.prototype.hasOwnProperty.call(payload, 'mentions')) {
211
+ payload.mentions = normalizeAunMentionEntries(payload.mentions);
212
+ }
209
213
  applyRoutingPayloadFields(payload, args, runtimeContext, false);
210
214
  const daemonResult = await tryDaemonMsgSend(args, payload, runtimeContext);
211
215
  if (daemonResult)
@@ -265,6 +269,9 @@ export async function msgSend(args) {
265
269
  // 5. 写入 payload.thread_id/ref_message_id(如果指定)
266
270
  applyRoutingPayloadFields(payload, args, runtimeContext, false);
267
271
  applyRoutingPayloadFields(payload, args, runtimeContext);
272
+ if (Object.prototype.hasOwnProperty.call(payload, 'mentions')) {
273
+ payload.mentions = normalizeAunMentionEntries(payload.mentions);
274
+ }
268
275
  const encrypt = resolveAunMessageEncrypt(args.encrypt);
269
276
  const sendParams = { to: args.to, payload, encrypt };
270
277
  const result = await conn.call('message.send', sendParams);
@@ -1,7 +1,6 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
1
  import crypto from 'crypto';
4
2
  import { agentOutboxPath } from '../paths.js';
3
+ import { atomicRead, atomicWrite } from '../utils/atomic-write.js';
5
4
  const MAX_ENTRIES_PER_AID = 20;
6
5
  const DEFAULT_TTL = 300_000; // 5 minutes
7
6
  function outboxFile(aid) {
@@ -13,14 +12,14 @@ function generateId() {
13
12
  return `out-${ts}-${rand}`;
14
13
  }
15
14
  function isExpired(entry) {
15
+ if (entry.critical)
16
+ return false;
16
17
  return Date.now() - entry.ts > entry.ttl;
17
18
  }
18
19
  function readEntries(aid) {
19
20
  const file = outboxFile(aid);
20
- if (!fs.existsSync(file))
21
- return [];
22
21
  try {
23
- const content = fs.readFileSync(file, 'utf-8').trim();
22
+ const content = atomicRead(file)?.trim();
24
23
  if (!content)
25
24
  return [];
26
25
  return content.split('\n').map(line => {
@@ -38,22 +37,25 @@ function readEntries(aid) {
38
37
  }
39
38
  function writeEntries(aid, entries) {
40
39
  const file = outboxFile(aid);
41
- if (entries.length === 0) {
42
- try {
43
- fs.unlinkSync(file);
44
- }
45
- catch { }
46
- return;
47
- }
48
- fs.mkdirSync(path.dirname(file), { recursive: true });
49
- fs.writeFileSync(file, entries.map(e => JSON.stringify(e)).join('\n') + '\n');
40
+ const content = entries.length > 0
41
+ ? entries.map(e => JSON.stringify(e)).join('\n') + '\n'
42
+ : '';
43
+ atomicWrite(file, content);
50
44
  }
51
45
  export function enqueue(aid, opts) {
46
+ const existingEntries = readEntries(aid);
47
+ if (opts.dedupeKey) {
48
+ const existing = existingEntries.find(entry => entry.dedupeKey === opts.dedupeKey && !isExpired(entry));
49
+ if (existing)
50
+ return existing;
51
+ }
52
52
  const entry = {
53
53
  id: generateId(),
54
54
  ts: Date.now(),
55
55
  aid,
56
56
  channelId: opts.channelId,
57
+ dedupeKey: opts.dedupeKey,
58
+ critical: opts.critical,
57
59
  type: opts.type,
58
60
  contentKind: opts.contentKind,
59
61
  payload: opts.payload,
@@ -65,17 +67,18 @@ export function enqueue(aid, opts) {
65
67
  ttl: opts.ttl ?? DEFAULT_TTL,
66
68
  postSend: opts.postSend,
67
69
  };
68
- const file = outboxFile(aid);
69
- fs.mkdirSync(path.dirname(file), { recursive: true });
70
70
  // Enforce cap: read existing, drop oldest if over limit
71
- let entries = readEntries(aid);
72
- if (entries.length >= MAX_ENTRIES_PER_AID) {
73
- entries = entries.slice(entries.length - MAX_ENTRIES_PER_AID + 1);
74
- writeEntries(aid, [...entries, entry]);
71
+ let entries = existingEntries;
72
+ if (entries.filter(candidate => !candidate.critical).length >= MAX_ENTRIES_PER_AID) {
73
+ const dropIndex = entries.findIndex(candidate => !candidate.critical);
74
+ if (dropIndex >= 0)
75
+ entries.splice(dropIndex, 1);
76
+ entries = [...entries, entry];
75
77
  }
76
78
  else {
77
- fs.appendFileSync(file, JSON.stringify(entry) + '\n');
79
+ entries = [...entries, entry];
78
80
  }
81
+ writeEntries(aid, entries);
79
82
  return entry;
80
83
  }
81
84
  export function remove(aid, id) {
@@ -105,6 +108,9 @@ export function removeInteractionCards(aid, requestId) {
105
108
  export function load(aid) {
106
109
  return readEntries(aid).filter(e => !isExpired(e));
107
110
  }
111
+ export function findByDedupeKey(aid, dedupeKey) {
112
+ return load(aid).find(entry => entry.dedupeKey === dedupeKey);
113
+ }
108
114
  export function cleanup(aid) {
109
115
  const all = readEntries(aid);
110
116
  const valid = all.filter(e => !isExpired(e));
@@ -185,16 +191,7 @@ export async function drain(aid, sender) {
185
191
  }
186
192
  }
187
193
  export function hasPending(aid) {
188
- const file = outboxFile(aid);
189
- if (!fs.existsSync(file))
190
- return false;
191
- try {
192
- const stat = fs.statSync(file);
193
- return stat.size > 0;
194
- }
195
- catch {
196
- return false;
197
- }
194
+ return readEntries(aid).some(entry => !isExpired(entry));
198
195
  }
199
196
  /**
200
197
  * 当前 outbox 中待发送条目数。用于诊断发送管线堵塞:depth 持续增长说明