evolcore 0.0.42 → 0.0.43-test.1

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 (189) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/bin/ec-safe-output.js +4 -1
  3. package/dist/ability/application-service.js +882 -0
  4. package/dist/ability/authorization.js +70 -0
  5. package/dist/ability/command-contract.js +105 -0
  6. package/dist/ability/daemon.js +137 -0
  7. package/dist/ability/development.js +450 -0
  8. package/dist/ability/environment.js +75 -0
  9. package/dist/ability/interop-v1.js +547 -0
  10. package/dist/ability/management.js +79 -0
  11. package/dist/ability/package.js +264 -0
  12. package/dist/ability/provider.js +73 -0
  13. package/dist/ability/publication.js +107 -0
  14. package/dist/ability/resources.js +106 -0
  15. package/dist/ability/runtime.js +212 -0
  16. package/dist/ability/secrets.js +47 -0
  17. package/dist/ability/store.js +112 -0
  18. package/dist/ability/toolchain.js +69 -0
  19. package/dist/ability/types.js +14 -0
  20. package/dist/ability/versions.js +32 -0
  21. package/dist/agents/baseagent.js +2 -2
  22. package/dist/agents/claude-runner.js +4 -0
  23. package/dist/agents/codex-runner.js +81 -17
  24. package/dist/agents/ecagent-plugin-lazy.js +41 -0
  25. package/dist/agents/ecagent-runner.js +18 -11
  26. package/dist/aun/ability-device-routing.js +12 -1
  27. package/dist/aun/aid/agentmd.js +2 -2
  28. package/dist/aun/aid/client.js +1 -1
  29. package/dist/aun/aid/identity.js +45 -0
  30. package/dist/aun/aid/index.js +1 -0
  31. package/dist/aun/aid/managed-operation.js +73 -2
  32. package/dist/channels/aun.js +64 -18
  33. package/dist/channels/builtin-plugins.js +14 -0
  34. package/dist/channels/dingtalk.js +78 -26
  35. package/dist/channels/feishu.js +89 -14
  36. package/dist/channels/qqbot.js +84 -19
  37. package/dist/channels/wechat.js +77 -19
  38. package/dist/channels/wecom.js +67 -22
  39. package/dist/cli/ability-command.js +92 -0
  40. package/dist/cli/aun-commands.js +124 -85
  41. package/dist/cli/daemon-commands.js +37 -85
  42. package/dist/cli/index.js +14 -0
  43. package/dist/cli/init.js +11 -13
  44. package/dist/cli/managed-command-guard.js +6 -0
  45. package/dist/cli/model.js +101 -104
  46. package/dist/cli/provider-command.js +6 -4
  47. package/dist/cli/restart-monitor.js +52 -11
  48. package/dist/cli/upgrade-command.js +102 -0
  49. package/dist/cli/version.js +1 -1
  50. package/dist/config/access-policy.js +4 -2
  51. package/dist/config/builtin-roles.js +1 -0
  52. package/dist/config/config-field-policy.js +4 -0
  53. package/dist/config/config-manager.js +7 -0
  54. package/dist/config/provider-ipc-service.js +10 -0
  55. package/dist/config/providers-config.js +12 -3
  56. package/dist/config/providers-management.js +45 -9
  57. package/dist/config/schema-migration.js +40 -22
  58. package/dist/contracts/ecweb-service-protocol.js +2 -1
  59. package/dist/core/agent-runtime.js +2 -1
  60. package/dist/core/auth/agent-delegation.js +21 -5
  61. package/dist/core/auth/auth-gateway.js +31 -9
  62. package/dist/core/auth/authorization-audit.js +52 -4
  63. package/dist/core/auth/delegation-authorization.js +140 -4
  64. package/dist/core/auth/operation-authorizer.js +114 -13
  65. package/dist/core/auth/operation-catalog.js +118 -4
  66. package/dist/core/baseagent-loader.js +14 -1
  67. package/dist/core/channel-loader.js +47 -9
  68. package/dist/core/channel-runtime.js +1 -1
  69. package/dist/core/command/agent-storage-menu.js +1 -1
  70. package/dist/core/command/cli-intent-parser.js +26 -13
  71. package/dist/core/command/command-handler.js +232 -76
  72. package/dist/core/command/connect-menu.js +10 -4
  73. package/dist/core/command/daemon-diagnostics.js +3 -3
  74. package/dist/core/command/data-root-resolver.js +2 -3
  75. package/dist/core/command/menu-catalog.js +10 -3
  76. package/dist/core/command/menu-handler.js +321 -46
  77. package/dist/core/command/menu-protocol.js +53 -7
  78. package/dist/core/command/pa-workspace-calendar.js +1 -2
  79. package/dist/core/command/pa-workspace-items.js +486 -0
  80. package/dist/core/command/pa-workspace-store.js +10 -1
  81. package/dist/core/command/slash-gate.js +2 -2
  82. package/dist/core/command/slash-handler.js +67 -25
  83. package/dist/core/contact-bind-registry.js +27 -0
  84. package/dist/core/daemon-control.js +3 -3
  85. package/dist/core/daemon-lifecycle.js +2 -1
  86. package/dist/core/event-bus.js +9 -2
  87. package/dist/core/handoff/ipc-registration.js +1 -0
  88. package/dist/core/host-snapshot.js +1 -2
  89. package/dist/core/initialization/service.js +32 -11
  90. package/dist/core/ipc-registration.js +18 -5
  91. package/dist/core/memory/consolidation-context.js +2 -2
  92. package/dist/core/message/aun-request-registry.js +99 -18
  93. package/dist/core/message/im-renderer.js +16 -11
  94. package/dist/core/message/message-admission.js +25 -20
  95. package/dist/core/message/message-bridge.js +21 -47
  96. package/dist/core/message/message-queue.js +3 -0
  97. package/dist/core/message/response-engine.js +7 -5
  98. package/dist/core/model/catalog-service.js +1 -1
  99. package/dist/core/permission/ec-command-parser.js +41 -9
  100. package/dist/core/permission/permission-result.js +1 -0
  101. package/dist/core/permission/protected-paths.js +25 -14
  102. package/dist/core/permission/tool-policy.js +108 -107
  103. package/dist/core/plugin-lifecycle.js +133 -0
  104. package/dist/core/runner-reload-transaction.js +4 -1
  105. package/dist/core/system-session/memory.js +16 -3
  106. package/dist/core/task/task-activity-store.js +50 -0
  107. package/dist/core/task/task-image-resources.js +140 -0
  108. package/dist/core/thread/ipc-operation.js +1 -1
  109. package/dist/core/thread/thread-service.js +0 -1
  110. package/dist/directory/canonical-digest.js +5 -3
  111. package/dist/directory/owner-directory-admission.js +22 -2
  112. package/dist/directory/owner-directory-cache.js +394 -60
  113. package/dist/directory/owner-directory-markdown.js +29 -2
  114. package/dist/directory/owner-directory-scope.js +35 -16
  115. package/dist/ecweb/basic-settings-service.js +4 -1
  116. package/dist/ecweb/pairing.js +41 -0
  117. package/dist/ecweb/providers-service.js +8 -1
  118. package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
  119. package/dist/ecweb/runtime/lifecycle.js +184 -0
  120. package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
  121. package/dist/index.js +34 -25
  122. package/dist/ipc.js +124 -7
  123. package/dist/response-system/engines/v1/proactive-flow.js +1 -1
  124. package/dist/trigger/authorization.js +2 -2
  125. package/dist/utils/atomic-write.js +24 -0
  126. package/dist/utils/avatar-upload.js +3 -1
  127. package/dist/utils/cross-platform.js +31 -2
  128. package/dist/utils/host-info.js +36 -0
  129. package/dist/utils/instance-registry.js +38 -11
  130. package/dist/utils/logger.js +9 -0
  131. package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
  132. package/dist/utils/tool-summary.js +9 -1
  133. package/dist/utils/upgrade-jobs.js +96 -15
  134. package/dist/utils/windows-autostart.js +1 -1
  135. package/ecagent/README.md +19 -0
  136. package/ecagent/dist/harness/agent-harness.js +9 -0
  137. package/ecagent/dist/harness/env/nodejs.js +71 -11
  138. package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
  139. package/ecagent/dist/harness/env/windows-shell.js +132 -0
  140. package/kits/docs/aun/ABILITY_CALLING.md +38 -9
  141. package/kits/docs/evolcore/INDEX.md +5 -1
  142. package/kits/docs/evolcore/ability.md +181 -0
  143. package/kits/docs/evolcore/aid.md +20 -0
  144. package/kits/docs/evolcore/config.md +10 -6
  145. package/kits/docs/evolcore/menu-protocol.md +40 -1
  146. package/kits/docs/evolcore/provider.md +2 -2
  147. package/kits/docs/evolcore/tool-authorization.md +270 -0
  148. package/kits/runtime/ability-job.ps1 +41 -0
  149. package/kits/runtime/ability-runner.mjs +67 -0
  150. package/kits/runtime/ability-secret.ps1 +59 -0
  151. package/kits/runtime/ability-templates/go/main.go +59 -0
  152. package/kits/runtime/ability-templates/java/Json.java +67 -0
  153. package/kits/runtime/ability-templates/java/Runner.java +42 -0
  154. package/kits/runtime/ability-templates/python/runner.py +48 -0
  155. package/kits/runtime/ability-templates/rust/json.rs +87 -0
  156. package/kits/runtime/ability-templates/rust/runner.rs +35 -0
  157. package/kits/schemas/_meta.json +12 -1
  158. package/kits/schemas/ability-plugin.schema.1.json +107 -0
  159. package/kits/schemas/ability-project.schema.1.json +31 -0
  160. package/kits/schemas/agent-config.schema.16.json +20 -0
  161. package/kits/schemas/agent-config.schema.17.json +20 -0
  162. package/kits/schemas/agent-config.schema.18.json +917 -0
  163. package/kits/skills/.switches.json +4 -0
  164. package/kits/skills/aid-ability/SKILL.md +5 -4
  165. package/kits/skills/ec-ability/SKILL.md +67 -0
  166. package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
  167. package/kits/skills/ec-ability/references/development.md +104 -0
  168. package/kits/skills/ec-ability/references/management.md +117 -0
  169. package/kits/skills/ec-ability/references/recovery.md +27 -0
  170. package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
  171. package/kits/skills/ec-ability/references/workflows.md +15 -0
  172. package/kits/skills/ec-service-proxy/SKILL.md +12 -0
  173. package/kits/skills/personal-assistant/SKILL.md +240 -6
  174. package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
  175. package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
  176. package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
  177. package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
  178. package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
  179. package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
  180. package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
  181. package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
  182. package/kits/templates/memory-consolidation/notes.md +1 -1
  183. package/kits/templates/system-fragments/channel.md +2 -1
  184. package/kits/templates/system-fragments/commands.md +1 -0
  185. package/package.json +5 -3
  186. package/dist/core/command/data-root-error.js +0 -10
  187. package/dist/utils/machine-info.js +0 -46
  188. package/dist/utils/process-tree-worker.js +0 -31
  189. package/dist/utils/windows-output.js +0 -36
@@ -7,6 +7,8 @@
7
7
  */
8
8
  import { logger } from '../utils/logger.js';
9
9
  import { assertAgentAidAvailable } from '../config/config-manager.js';
10
+ import { PluginHandle } from './plugin-lifecycle.js';
11
+ import { ContactBindRegistry } from './contact-bind-registry.js';
10
12
  // ── Shared helpers for plugins ─────────────────────────────────────────────
11
13
  /** Resolve showActivities for a single instance (instance overrides default). */
12
14
  export function resolveShowActivities(inst) {
@@ -30,6 +32,7 @@ export class ChannelLoader {
30
32
  processDebug;
31
33
  aunDefaultEncrypt;
32
34
  plugins = new Map();
35
+ contactBindRegistry = new ContactBindRegistry();
33
36
  constructor(processDebug, aunDefaultEncrypt) {
34
37
  this.processDebug = processDebug;
35
38
  this.aunDefaultEncrypt = aunDefaultEncrypt;
@@ -38,6 +41,8 @@ export class ChannelLoader {
38
41
  if (this.plugins.has(plugin.name)) {
39
42
  throw new Error(`Channel plugin '${plugin.name}' already registered`);
40
43
  }
44
+ if (plugin.contactBind)
45
+ this.contactBindRegistry.register(plugin.name, plugin.contactBind);
41
46
  this.plugins.set(plugin.name, plugin);
42
47
  logger.debug(`Registered channel plugin: ${plugin.name}`);
43
48
  }
@@ -86,7 +91,7 @@ export class ChannelLoader {
86
91
  continue;
87
92
  }
88
93
  try {
89
- const runtime = await plugin.createInstance(inst, ctx);
94
+ const runtime = await this.createInstance(inst, ctx);
90
95
  if (runtime) {
91
96
  result.push(runtime);
92
97
  logger.info(`✓ Channel '${inst.name}' (${inst.type}) created`);
@@ -101,6 +106,35 @@ export class ChannelLoader {
101
106
  }
102
107
  return result;
103
108
  }
109
+ async createInstance(inst, ctx) {
110
+ const plugin = this.plugins.get(inst.type);
111
+ if (!plugin)
112
+ throw new Error(`No plugin for channel type ${inst.type}`);
113
+ let teardown;
114
+ const lifecycle = new PluginHandle(`${ctx.agentName}::${inst.name}`, () => teardown?.());
115
+ try {
116
+ const runtime = await plugin.createInstance(inst, { ...ctx, lifecycle });
117
+ if (!runtime) {
118
+ await lifecycle.dispose();
119
+ return null;
120
+ }
121
+ teardown = runtime.disconnect.bind(runtime);
122
+ const connect = runtime.connect.bind(runtime);
123
+ runtime.lifecycle = lifecycle;
124
+ runtime.disconnect = () => lifecycle.dispose();
125
+ runtime.connect = () => { lifecycle.assertActive(); return connect(); };
126
+ return runtime;
127
+ }
128
+ catch (error) {
129
+ try {
130
+ await lifecycle.dispose();
131
+ }
132
+ catch (disposeError) {
133
+ logger.warn(`[ChannelLoader] Cleanup failed for ${lifecycle.owner}:`, disposeError);
134
+ }
135
+ throw error;
136
+ }
137
+ }
104
138
  async connectAll(instances, { concurrency = 3, intervalMs = 50, onConnected, onFailed } = {}) {
105
139
  const connected = [];
106
140
  const failed = [];
@@ -162,11 +196,12 @@ export class ChannelLoader {
162
196
  const name = inst.adapter.channelName || inst.channelType || 'unknown';
163
197
  const startedAt = Date.now();
164
198
  let timedOut = false;
199
+ let timeout;
165
200
  try {
166
201
  await Promise.race([
167
202
  inst.disconnect(),
168
203
  new Promise(resolve => {
169
- setTimeout(() => { timedOut = true; resolve(); }, timeoutMs);
204
+ timeout = setTimeout(() => { timedOut = true; resolve(); }, timeoutMs);
170
205
  }),
171
206
  ]);
172
207
  }
@@ -174,6 +209,8 @@ export class ChannelLoader {
174
209
  logger.warn(`[Shutdown] channel disconnect failed: ${name}: ${error instanceof Error ? error.message : String(error)}`);
175
210
  }
176
211
  finally {
212
+ if (timeout)
213
+ clearTimeout(timeout);
177
214
  const durationMs = Date.now() - startedAt;
178
215
  timings.push({ name, durationMs, timedOut });
179
216
  if (timedOut) {
@@ -270,17 +307,18 @@ export function buildReloadHooks(deps) {
270
307
  }
271
308
  try {
272
309
  await inst.disconnect();
273
- const idx = channelInstances.indexOf(inst);
274
- if (idx >= 0)
275
- channelInstances.splice(idx, 1);
276
- // 从 core 各 map 注销,避免死实例残留在 /status「未归属渠道」、菜单路由和 adapter 查找里
277
- unregisterChannelInstance?.(channelName);
278
310
  logger.info(`[Reload] Disconnected channel: ${channelName}`);
279
311
  }
280
312
  catch (e) {
281
313
  logger.error(`[Reload] Failed to disconnect ${channelName}: ${e}`);
282
314
  throw e;
283
315
  }
316
+ finally {
317
+ const idx = channelInstances.indexOf(inst);
318
+ if (idx >= 0)
319
+ channelInstances.splice(idx, 1);
320
+ unregisterChannelInstance?.(channelName);
321
+ }
284
322
  },
285
323
  async startChannel(agent, channelName) {
286
324
  // The implicit AUN channel is synthesised from agent.aid (not in config.channels[]).
@@ -319,7 +357,7 @@ export function buildReloadHooks(deps) {
319
357
  if (!plugin)
320
358
  throw new Error(`[Reload] No plugin for channel type '${cfgInst.type}'`);
321
359
  const effInst = { ...cfgInst, name: channelName };
322
- const newInst = await plugin.createInstance(effInst, ctx);
360
+ const newInst = await channelLoader.createInstance(effInst, ctx);
323
361
  if (!newInst) {
324
362
  // createInstance returns null for a disabled / invalid-credential channel.
325
363
  // Not an error: skip it. Throwing here would propagate to reload(), which
@@ -327,8 +365,8 @@ export function buildReloadHooks(deps) {
327
365
  logger.warn(`[Reload] Channel ${channelName} (${cfgInst.type}) disabled or invalid credentials, skipping`);
328
366
  return;
329
367
  }
330
- registerChannelInstance(newInst);
331
368
  try {
369
+ registerChannelInstance(newInst);
332
370
  onChannelStarted?.(newInst);
333
371
  await newInst.connect();
334
372
  channelInstances.push(newInst);
@@ -140,7 +140,7 @@ export function registerChannelInstance(inst, dependencies) {
140
140
  registerAdapterInteractions(inst.adapter, interactionRouter);
141
141
  const channelType = inst.channelType || inst.adapter.channelName;
142
142
  inst.registerBridge?.(messageBridge, channelType);
143
- inst.registerHooks?.({ eventBus, sessionManager });
143
+ inst.registerHooks?.({ eventBus, sessionManager, lifecycle: inst.lifecycle });
144
144
  const channelForObserver = inst.channel;
145
145
  if (typeof channelForObserver.setObserverConfigResolver === 'function') {
146
146
  const channelKey = inst.adapter.channelKey;
@@ -4,7 +4,7 @@ import { readAunPeerKind } from '../relation/peer-identity.js';
4
4
  import { listStaticAgentOwners } from '../../config/peer-role-resolver.js';
5
5
  import { authorizeOperation } from '../auth/auth-gateway.js';
6
6
  import { auditCommandAuthorization } from '../auth/authorization-audit.js';
7
- import { DataRootError } from './data-root-resolver.js';
7
+ import { DataRootError } from './pa-workspace-store.js';
8
8
  const ROOT_TTL_MS = 10 * 60_000;
9
9
  const OPERATIONS = {
10
10
  root: 'file.root.storage', list: 'file.storage.list', query: 'file.storage.query',
@@ -2,6 +2,7 @@ import { parseAgentWelcomeArgs, parseInitializationArgs, resolveAgentCreateMode
2
2
  import { parseOwnershipCommand } from '../../aun/aid/ownership-operation.js';
3
3
  import { normalizeCliArgv } from '../../cli/cli-argv.js';
4
4
  import { resolveConfigCommand, } from '../../config/resolved-config-op.js';
5
+ import { getOperationMeta } from '../auth/operation-catalog.js';
5
6
  export { normalizeCliArgv, parseLegacyCliCommand, validateCliArgv } from '../../cli/cli-argv.js';
6
7
  // 只读 model 子命令默认补 --peer(按对端关系查模型生效值);写操作(use/effort/reset)只在 Agent 级,不补 --peer。
7
8
  const MODEL_RELATION_DEFAULT_SUBCOMMANDS = new Set(['list', 'current', 'info', 'check']);
@@ -24,20 +25,31 @@ export function parseCliIntent(inputArgv, source = 'menu.cli', options = {}) {
24
25
  }
25
26
  const argv = normalizeCliArgv(inputArgv);
26
27
  const cmd = argv[0];
28
+ let result;
27
29
  if (cmd === 'model')
28
- return parseModelCommand(argv, source);
29
- if (cmd === 'thread')
30
- return parseThreadCommand(argv, source);
31
- if (cmd === 'config')
32
- return parseConfigCommand(argv, source, options.defaultRelation);
33
- if (cmd === 'stats')
34
- return parseStatsCommand(argv, source);
35
- if (cmd === 'agent')
36
- return parseAgentCommand(argv, source);
37
- if (cmd === 'aid')
38
- return parseAidCommand(argv, source, options.defaultRelation?.self);
39
- if (cmd === 'storage')
40
- return parseStorageCommand(argv, source);
30
+ result = parseModelCommand(argv, source);
31
+ else if (cmd === 'thread')
32
+ result = parseThreadCommand(argv, source);
33
+ else if (cmd === 'config')
34
+ result = parseConfigCommand(argv, source, options.defaultRelation);
35
+ else if (cmd === 'stats')
36
+ result = parseStatsCommand(argv, source);
37
+ else if (cmd === 'agent')
38
+ result = parseAgentCommand(argv, source);
39
+ else if (cmd === 'aid')
40
+ result = parseAidCommand(argv, source, options.defaultRelation?.self);
41
+ else if (cmd === 'storage')
42
+ result = parseStorageCommand(argv, source);
43
+ if (result) {
44
+ if (result.kind === 'recognized' && getOperationMeta(result.intent.operation)?.authorizationTarget) {
45
+ delete result.intent.args.targetAgentAid;
46
+ const explicitAid = typeof result.intent.args.aid === 'string' ? result.intent.args.aid
47
+ : typeof result.intent.args.self === 'string' ? result.intent.args.self
48
+ : options.defaultRelation?.self;
49
+ result.intent.args.targetAgentAid = explicitAid;
50
+ }
51
+ return result;
52
+ }
41
53
  if (cmd === 'version') {
42
54
  const parsed = parseArgs(argv.slice(1));
43
55
  if (parsed.positionals.length > 0)
@@ -161,6 +173,7 @@ function recognizedConfig(command, source) {
161
173
  ...(command.kind === 'scoped' && command.field ? { field: command.field } : {}),
162
174
  configScope: command.configScope,
163
175
  ...(command.self ? { self: command.self } : {}),
176
+ ...(command.self ? { targetAgentAid: command.self } : {}),
164
177
  ...(command.peerKey ? { peer: command.peerKey, peerKey: command.peerKey } : {}),
165
178
  ...(command.configScope === 'process' ? { process: true } : {}),
166
179
  ...(command.configScope === 'defaults' ? { default: true } : {}),