evolcore 0.0.43-test.6 → 0.0.43-test.8

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 (249) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/bin/ecmsg.js +188 -58
  3. package/dist/agent-template/jobs.js +62 -0
  4. package/dist/agent-template/runtime.js +214 -0
  5. package/dist/agent-template/service.js +465 -0
  6. package/dist/agent-template/tool-runner.js +45 -0
  7. package/dist/agent-template/types.js +5 -0
  8. package/dist/agents/baseagent-availability.js +1 -1
  9. package/dist/agents/claude-runner.js +1 -1
  10. package/dist/agents/codex/app-server-client.js +22 -0
  11. package/dist/agents/codex-runner.js +69 -2
  12. package/dist/aun/aid/agentmd.js +56 -1
  13. package/dist/aun/aid/client.js +3 -1
  14. package/dist/aun/menu/client.js +3 -2
  15. package/dist/aun/msg/p2p.js +6 -1
  16. package/dist/channels/aun.js +277 -49
  17. package/dist/cli/agent-command.js +5 -0
  18. package/dist/cli/agent-create.js +7 -3
  19. package/dist/cli/agent-template.js +124 -0
  20. package/dist/cli/aun-commands.js +2 -2
  21. package/dist/cli/ctl-command.js +2 -1
  22. package/dist/cli/daemon-commands.js +11 -66
  23. package/dist/cli/daemon-lifecycle-client.js +61 -0
  24. package/dist/cli/ecmsg-gateway.js +35 -2
  25. package/dist/cli/events-command.js +109 -0
  26. package/dist/cli/index.js +60 -14
  27. package/dist/cli/invoke-command.js +182 -0
  28. package/dist/cli/managed-command-guard.js +6 -1
  29. package/dist/cli/net-check.js +1 -1
  30. package/dist/cli/restart-monitor.js +160 -83
  31. package/dist/cli/services-command.js +137 -0
  32. package/dist/cli/team-workspace-command.js +134 -0
  33. package/dist/cli/thread-command.js +103 -13
  34. package/dist/cli/watch-msg.js +1 -1
  35. package/dist/config/boot-log.js +8 -8
  36. package/dist/config/config-field-policy.js +2 -2
  37. package/dist/config/config-manager.js +0 -7
  38. package/dist/config/invoke-ipc-service.js +118 -0
  39. package/dist/config/schema-migration.js +45 -15
  40. package/dist/config-store.js +2 -1
  41. package/dist/core/agent-ipc-registration.js +25 -4
  42. package/dist/core/agent-reload-coordinator.js +6 -4
  43. package/dist/core/agent-runtime.js +106 -10
  44. package/dist/core/auth/delegation-authorization.js +66 -0
  45. package/dist/core/auth/operation-authorizer.js +2 -0
  46. package/dist/core/auth/operation-catalog.js +29 -0
  47. package/dist/core/baseagent-loader.js +60 -130
  48. package/dist/core/channel-loader.js +10 -1
  49. package/dist/core/channel-runtime.js +20 -12
  50. package/dist/core/command/agent-control.js +12 -2
  51. package/dist/core/command/agent-storage-menu.js +1 -1
  52. package/dist/core/command/agent-template-menu.js +147 -0
  53. package/dist/core/command/chatmode-config.js +2 -36
  54. package/dist/core/command/command-handler.js +80 -17
  55. package/dist/core/command/data-root-resolver.js +32 -23
  56. package/dist/core/command/eventcenter-menu.js +468 -0
  57. package/dist/core/command/menu-catalog.js +15 -0
  58. package/dist/core/command/menu-handler.js +216 -90
  59. package/dist/core/command/menu-protocol.js +71 -13
  60. package/dist/core/command/menu-query-batch.js +194 -0
  61. package/dist/core/command/slash-gate.js +1 -1
  62. package/dist/core/command/slash-handler.js +34 -42
  63. package/dist/core/command/team-workspace-bootstrap.js +350 -0
  64. package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
  65. package/dist/core/command/team-workspace-initializer.js +2 -0
  66. package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
  67. package/dist/core/command/team-workspace-job-store.js +88 -0
  68. package/dist/core/command/team-workspace-management-service.js +2 -0
  69. package/dist/core/command/team-workspace-management-store.js +96 -0
  70. package/dist/core/command/team-workspace-management.js +265 -0
  71. package/dist/core/command/team-workspace-members-menu.js +88 -0
  72. package/dist/core/command/team-workspace-store.js +612 -0
  73. package/dist/core/command/team-workspace-team.js +193 -0
  74. package/dist/core/daemon-control.js +22 -5
  75. package/dist/core/daemon-lifecycle.js +323 -191
  76. package/dist/core/handoff/runtime.js +45 -13
  77. package/dist/core/invoke/executors/index.js +13 -0
  78. package/dist/core/invoke/executors/media.js +283 -0
  79. package/dist/core/invoke/executors/text.js +198 -0
  80. package/dist/core/invoke/invoke-service.js +157 -0
  81. package/dist/core/invoke/style-router.js +48 -0
  82. package/dist/core/invoke/types.js +19 -0
  83. package/dist/core/ipc-registration.js +50 -7
  84. package/dist/core/legacy-rename.js +41 -0
  85. package/dist/core/memory/consolidation.js +7 -5
  86. package/dist/core/message/aun-ipc-sender.js +252 -17
  87. package/dist/core/message/im-renderer.js +116 -85
  88. package/dist/core/message/message-bridge.js +4 -0
  89. package/dist/core/message/message-queue.js +66 -15
  90. package/dist/core/message/message-utils.js +10 -2
  91. package/dist/core/message/peer-mode.js +7 -34
  92. package/dist/core/message/pending-hints.js +29 -5
  93. package/dist/core/message/response-engine.js +194 -61
  94. package/dist/core/message/send-options.js +7 -4
  95. package/dist/core/message/send-routing.js +50 -5
  96. package/dist/core/ownership/owner-resolver.js +7 -0
  97. package/dist/core/pack-auth.js +94 -0
  98. package/dist/core/pack-install.js +194 -0
  99. package/dist/core/permission/ec-command-parser.js +51 -17
  100. package/dist/core/permission/protected-paths.js +12 -2
  101. package/dist/core/permission/shell-environment.js +9 -0
  102. package/dist/core/rate-window.js +48 -0
  103. package/dist/core/relation/peer-identity.js +28 -0
  104. package/dist/core/session/session-file-health.js +243 -0
  105. package/dist/core/session/session-fs-store.js +67 -28
  106. package/dist/core/session/session-idle-monitor.js +59 -19
  107. package/dist/core/session/session-manager.js +13 -4
  108. package/dist/core/task/task-recovery-service.js +13 -2
  109. package/dist/core/thread/command-parser.js +9 -2
  110. package/dist/core/thread/thread-operation.js +21 -2
  111. package/dist/core/thread/thread-route.js +13 -2
  112. package/dist/core/thread/thread-service.js +52 -3
  113. package/dist/directory/owner-directory-admission.js +40 -53
  114. package/dist/directory/owner-directory-cache.js +89 -113
  115. package/dist/directory/owner-directory-query-operation.js +8 -10
  116. package/dist/eck/kit-renderer.js +7 -5
  117. package/dist/eck/message-renderer.js +2 -0
  118. package/dist/ecweb/basic-settings-service.js +1 -1
  119. package/dist/ecweb/message-context-service.js +0 -4
  120. package/dist/ecweb/runtime/lifecycle.js +6 -2
  121. package/dist/ecweb/runtime/supervisor.js +19 -4
  122. package/dist/event-center/admission-materializer.js +124 -0
  123. package/dist/event-center/bus-gate.js +154 -0
  124. package/dist/event-center/bus-host.js +307 -0
  125. package/dist/event-center/bus-resolver.js +120 -0
  126. package/dist/event-center/center-config.js +127 -0
  127. package/dist/event-center/daemon.js +44 -0
  128. package/dist/event-center/directory-source.js +55 -0
  129. package/dist/event-center/dispatcher.js +157 -0
  130. package/dist/event-center/event-log.js +110 -0
  131. package/dist/event-center/index-generator.js +73 -0
  132. package/dist/event-center/ipc-operation.js +423 -0
  133. package/dist/event-center/ledger.js +52 -0
  134. package/dist/event-center/pack-loader.js +207 -0
  135. package/dist/event-center/pack-manager.js +85 -0
  136. package/dist/event-center/registry.js +463 -0
  137. package/dist/event-center/runtime.js +837 -0
  138. package/dist/event-center/script-runner.js +356 -0
  139. package/dist/event-center/types.js +51 -0
  140. package/dist/event-center/validation.js +435 -0
  141. package/dist/index.js +424 -135
  142. package/dist/ipc.js +106 -12
  143. package/dist/paths.js +20 -0
  144. package/dist/product.js +14 -0
  145. package/dist/proxy/manager.js +5 -1
  146. package/dist/proxy/service-supervisor.js +13 -4
  147. package/dist/response-system/engines/v1/index.js +0 -1
  148. package/dist/response-system/engines/v1/proactive-flow.js +4 -2
  149. package/dist/response-system/modes/single-session/index.js +1 -1
  150. package/dist/services/dispatcher.js +100 -0
  151. package/dist/services/idempotency.js +90 -0
  152. package/dist/services/identity.js +52 -0
  153. package/dist/services/index-generator.js +70 -0
  154. package/dist/services/index.js +449 -0
  155. package/dist/services/ipc-operation.js +550 -0
  156. package/dist/services/ledger.js +52 -0
  157. package/dist/services/message-log.js +112 -0
  158. package/dist/services/pack-manager.js +215 -0
  159. package/dist/services/reply.js +55 -0
  160. package/dist/services/router.js +98 -0
  161. package/dist/services/script-runner.js +422 -0
  162. package/dist/services/service-payload.js +70 -0
  163. package/dist/services/types.js +18 -0
  164. package/dist/services/validation.js +297 -0
  165. package/dist/trigger/application-service.js +18 -0
  166. package/dist/trigger/event-source.js +1 -1
  167. package/dist/trigger/ipc-service.js +3 -1
  168. package/dist/trigger/scheduler.js +38 -0
  169. package/dist/trigger/script-sandbox.js +170 -24
  170. package/dist/utils/cross-platform.js +24 -10
  171. package/dist/utils/evolcore-version.js +69 -27
  172. package/dist/utils/instance-registry.js +19 -13
  173. package/dist/utils/npm-ops.js +2 -1
  174. package/dist/utils/package-version-info.js +6 -3
  175. package/dist/utils/process-introspect.js +45 -9
  176. package/dist/utils/startup-trace.js +74 -37
  177. package/dist/utils/windows-shell-trust.js +80 -6
  178. package/kits/docs/INDEX.md +2 -2
  179. package/kits/docs/aun/ABILITY_CALLING.md +9 -15
  180. package/kits/docs/context-assembly.md +1 -1
  181. package/kits/docs/evolcore/INDEX.md +3 -1
  182. package/kits/docs/evolcore/ability.md +4 -0
  183. package/kits/docs/evolcore/agent.md +22 -1
  184. package/kits/docs/evolcore/aid.md +1 -1
  185. package/kits/docs/evolcore/event-center.md +227 -0
  186. package/kits/docs/evolcore/file-navigation.md +10 -264
  187. package/kits/docs/evolcore/fs.md +5 -3
  188. package/kits/docs/evolcore/group.md +1 -1
  189. package/kits/docs/evolcore/memory-architecture.md +2 -0
  190. package/kits/docs/evolcore/menu-protocol.md +28 -1
  191. package/kits/docs/evolcore/msg.md +21 -9
  192. package/kits/docs/evolcore/provider.md +3 -1
  193. package/kits/docs/evolcore/response.md +5 -5
  194. package/kits/docs/evolcore/services.md +294 -0
  195. package/kits/docs/evolcore/task.md +2 -0
  196. package/kits/docs/evolcore/team-workspace.md +41 -0
  197. package/kits/docs/evolcore/thread-chain.md +15 -3
  198. package/kits/eck_manifest.json +26 -0
  199. package/kits/rules/02-navigation.md +10 -1
  200. package/kits/rules/06-channel.md +1 -0
  201. package/kits/schemas/_meta.json +17 -6
  202. package/kits/schemas/agent-config.schema.19.json +5 -7
  203. package/kits/schemas/agent-config.schema.20.json +936 -0
  204. package/kits/schemas/relation-config.schema.12.json +2 -3
  205. package/kits/schemas/role-config.schema.2.json +4 -4
  206. package/kits/skills/.switches.json +1 -5
  207. package/kits/skills/ability/SKILL.md +56 -0
  208. package/kits/skills/ability/references/calling.md +56 -0
  209. package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
  210. package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
  211. package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
  212. package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
  213. package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
  214. package/kits/skills/ec-agent-create/SKILL.md +0 -1
  215. package/kits/skills/ec-group/SKILL.md +5 -8
  216. package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
  217. package/kits/skills/ec-service-proxy/SKILL.md +34 -5
  218. package/kits/skills/ec-trigger/SKILL.md +4 -4
  219. package/kits/skills/personal-assistant/SKILL.md +6 -6
  220. package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
  221. package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
  222. package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
  223. package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
  224. package/kits/skills/thread-ops/SKILL.md +10 -10
  225. package/kits/templates/message-fragments/item.md +1 -1
  226. package/kits/templates/system-fragments/channel.md +3 -3
  227. package/kits/templates/system-fragments/commands.md +5 -3
  228. package/kits/templates/system-fragments/reply.md +1 -5
  229. package/kits/templates/system-fragments/thread.md +13 -10
  230. package/package.json +5 -6
  231. package/scripts/agent-template/index.mjs +40 -0
  232. package/scripts/agent-template/inspect.mjs +240 -0
  233. package/scripts/agent-template/overlay.mjs +71 -0
  234. package/scripts/agent-template/pack.mjs +169 -0
  235. package/scripts/agent-template/shared/common.mjs +235 -0
  236. package/scripts/agent-template/shared/evolcore.mjs +75 -0
  237. package/scripts/agent-template/shared/plan.mjs +129 -0
  238. package/scripts/agent-template/shared/team-schema.json +70 -0
  239. package/scripts/agent-template/shared/template-contract.mjs +154 -0
  240. package/scripts/agent-template/shared/template-package.mjs +265 -0
  241. package/scripts/agent-template/shared/template-runtime.mjs +80 -0
  242. package/scripts/agent-template/shared/template.mjs +142 -0
  243. package/dist/cli/pa-workspace-command.js +0 -225
  244. package/dist/core/command/pa-workspace-store.js +0 -468
  245. package/dist/core/relation/pa-team.js +0 -132
  246. package/kits/docs/evolcore/pa-workspace.md +0 -51
  247. package/kits/skills/aid-ability/SKILL.md +0 -244
  248. package/kits/skills/ec-ability/SKILL.md +0 -67
  249. package/kits/skills/ec-ability/references/workflows.md +0 -15
@@ -245,6 +245,8 @@ function parseDateString(value) {
245
245
  return Number.isNaN(parsed) ? null : parsed;
246
246
  }
247
247
  let snapshotCache = null;
248
+ let snapshotQuery = null;
249
+ let snapshotGeneration = 0;
248
250
  /**
249
251
  * 同一次启动流程里多处调用共享快照。
250
252
  *
@@ -267,9 +269,37 @@ export function getProcessSnapshot(options = {}) {
267
269
  snapshotCache = { at: now, snapshot };
268
270
  return snapshot;
269
271
  }
272
+ /** The restart monitor shares one snapshot per phase without blocking IPC/timers. */
273
+ export async function getProcessSnapshotAsync(options = {}) {
274
+ if (!options.fresh && snapshotCache && Date.now() - snapshotCache.at < SNAPSHOT_TTL_MS) {
275
+ return snapshotCache.snapshot;
276
+ }
277
+ if (snapshotQuery)
278
+ return snapshotQuery;
279
+ const generation = snapshotGeneration;
280
+ const query = (async () => {
281
+ const snapshot = isWindows
282
+ ? parseWindowsSnapshot(await processQuery('powershell', ['-NoProfile', '-NonInteractive', '-Command', WINDOWS_SNAPSHOT_SCRIPT], 8000))
283
+ ?? { complete: false, startedAt: new Map(), commandLines: new Map() }
284
+ : readProcessSnapshot();
285
+ if (generation === snapshotGeneration)
286
+ snapshotCache = { at: Date.now(), snapshot };
287
+ return snapshot;
288
+ })();
289
+ snapshotQuery = query;
290
+ try {
291
+ return await query;
292
+ }
293
+ finally {
294
+ if (snapshotQuery === query)
295
+ snapshotQuery = null;
296
+ }
297
+ }
270
298
  /** 让测试或长驻进程主动失效快照。 */
271
299
  export function invalidateProcessSnapshot() {
272
300
  snapshotCache = null;
301
+ snapshotQuery = null;
302
+ snapshotGeneration++;
273
303
  }
274
304
  function readProcessSnapshot() {
275
305
  if (isWindows) {
@@ -283,10 +313,13 @@ function readProcessSnapshot() {
283
313
  }
284
314
  return { complete: false, startedAt: new Map(), commandLines: new Map() };
285
315
  }
316
+ const WINDOWS_SNAPSHOT_SCRIPT = 'Get-CimInstance Win32_Process | Select-Object ProcessId,CreationDate,CommandLine | ConvertTo-Json -Compress';
286
317
  function readWindowsSnapshot() {
287
- const script = "Get-CimInstance Win32_Process | Select-Object ProcessId,CreationDate,CommandLine | ConvertTo-Json -Compress";
288
- const result = spawnSync('powershell', ['-NoProfile', '-NonInteractive', '-Command', script], { encoding: 'utf-8', timeout: 8000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true });
289
- const raw = (result.stdout || '').replace(/^/, '').trim();
318
+ const result = spawnSync('powershell', ['-NoProfile', '-NonInteractive', '-Command', WINDOWS_SNAPSHOT_SCRIPT], { encoding: 'utf-8', timeout: 8000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true });
319
+ return result.status === 0 ? parseWindowsSnapshot(result.stdout || '') : null;
320
+ }
321
+ function parseWindowsSnapshot(output) {
322
+ const raw = output.replace(/^\uFEFF/, '').trim();
290
323
  if (!raw)
291
324
  return null;
292
325
  let rows;
@@ -299,17 +332,19 @@ function readWindowsSnapshot() {
299
332
  }
300
333
  const startedAt = new Map();
301
334
  const commandLines = new Map();
335
+ const pids = new Set();
302
336
  for (const row of rows) {
303
- if (!Number.isInteger(row.ProcessId))
304
- continue;
337
+ if (!row || !Number.isInteger(row.ProcessId))
338
+ return null;
305
339
  const pid = row.ProcessId;
340
+ pids.add(pid);
306
341
  const started = coerceCimCreation(row.CreationDate);
307
342
  if (started !== null)
308
343
  startedAt.set(pid, started);
309
344
  if (typeof row.CommandLine === 'string')
310
345
  commandLines.set(pid, row.CommandLine);
311
346
  }
312
- return { complete: true, startedAt, commandLines };
347
+ return { complete: true, pids, startedAt, commandLines };
313
348
  }
314
349
  /**
315
350
  * ConvertTo-Json 对日期序列化的形状取决于 PowerShell 版本:可能是 CIM 字符串、
@@ -338,6 +373,7 @@ function coerceCimCreation(value) {
338
373
  }
339
374
  function readLinuxSnapshot() {
340
375
  const startedAt = new Map();
376
+ const pids = new Set();
341
377
  let complete = true;
342
378
  let btimeSec = null;
343
379
  try {
@@ -359,6 +395,7 @@ function readLinuxSnapshot() {
359
395
  if (!/^\d+$/.test(name))
360
396
  continue;
361
397
  const pid = Number(name);
398
+ pids.add(pid);
362
399
  try {
363
400
  const stat = fs.readFileSync(`/proc/${pid}/stat`, 'utf-8');
364
401
  const tail = stat.slice(stat.lastIndexOf(')') + 2).split(' ');
@@ -371,7 +408,7 @@ function readLinuxSnapshot() {
371
408
  // 进程在枚举过程中退出:从快照里缺席即视为不存在。
372
409
  }
373
410
  }
374
- return { complete, startedAt, commandLines: new Map() };
411
+ return { complete, pids, startedAt, commandLines: new Map() };
375
412
  }
376
413
  /**
377
414
  * 用快照判断「pid 是否仍是当初记录的那个进程」。
@@ -388,8 +425,7 @@ export function snapshotProcessState(snapshot, pid, recordedStartedAt) {
388
425
  return 'unknown';
389
426
  const actual = snapshot.startedAt.get(pid);
390
427
  if (actual === undefined)
391
- return 'dead';
392
- // 拿不到创建时间时保守认为活着(与 isAlive 的既有约定一致)。
428
+ return snapshot.pids?.has(pid) || snapshot.commandLines.has(pid) ? 'unknown' : 'dead';
393
429
  return startTimeMatches(recordedStartedAt, actual) ? 'alive' : 'dead';
394
430
  }
395
431
  /**
@@ -121,9 +121,7 @@ export class StartupTracer {
121
121
  spans = [];
122
122
  meta = {};
123
123
  processStartMs;
124
- cursorName = null;
125
- cursorStartMs = 0;
126
- cursorDetail;
124
+ cursor;
127
125
  finished = false;
128
126
  readyAtMs;
129
127
  taskReadyAtMs;
@@ -139,28 +137,46 @@ export class StartupTracer {
139
137
  }
140
138
  this.traceId = traceId ?? newStartupTraceId();
141
139
  this.processStartMs = opts.processStartMs ?? processStartOfThisProcess();
142
- this.cursorStartMs = this.processStartMs;
143
- if (opts.firstPhase)
144
- this.cursorName = opts.firstPhase;
140
+ if (opts.firstPhase) {
141
+ this.cursor = { name: opts.firstPhase, startMs: this.processStartMs, segments: [],
142
+ ...(opts.initialPhase ? { current: { phase: opts.initialPhase, startMs: this.processStartMs } } : {}) };
143
+ }
145
144
  }
146
145
  get id() { return this.traceId; }
147
146
  get startedAtMs() { return this.processStartMs; }
148
147
  get traceKind() { return this.kind; }
149
148
  /** 结束当前阶段,开始新阶段。 */
150
- mark(name, detail) {
149
+ mark(name, detail, options = {}) {
151
150
  if (this.finished)
152
151
  return;
153
152
  const now = Date.now();
154
153
  this.closeCursor(now);
155
- this.cursorName = name;
156
- this.cursorStartMs = now;
157
- this.cursorDetail = detail;
154
+ this.cursor = { name, startMs: now, detail, summary: options.summary, segments: [],
155
+ ...(options.initialPhase ? { current: { phase: options.initialPhase, startMs: now } } : {}) };
158
156
  }
159
157
  /** 给当前打开的阶段补一句附注。 */
160
158
  note(detail) {
161
- if (this.finished || !this.cursorName)
159
+ if (this.finished || !this.cursor)
160
+ return;
161
+ this.cursor.detail = detail;
162
+ }
163
+ /** 切换当前线性阶段的等待、排队或执行状态,不创建额外甘特行。 */
164
+ phase(phase, detail) {
165
+ if (this.finished || !this.cursor)
162
166
  return;
163
- this.cursorDetail = detail;
167
+ this.changePhase(this.cursor, phase, detail);
168
+ }
169
+ /** 只观察已有外部依赖,不增加等待、重试或超时。 */
170
+ async waitForDependency(promise, detail) {
171
+ const cursor = this.cursor;
172
+ this.phase('waiting', detail);
173
+ try {
174
+ return await promise;
175
+ }
176
+ finally {
177
+ if (this.cursor === cursor)
178
+ this.phase('running');
179
+ }
164
180
  }
165
181
  /** 直接登记一段已测好的区间(用于拿到外部时间戳的场景)。 */
166
182
  addSpan(name, startMs, endMs, detail, status) {
@@ -169,15 +185,16 @@ export class StartupTracer {
169
185
  this.spans.push({ name, startMs, durationMs: Math.max(0, endMs - startMs), ...(detail ? { detail } : {}), ...(status ? { status } : {}) });
170
186
  }
171
187
  /** 观察由已有生命周期回调报告完成的任务,不增加轮询或就绪依赖。 */
172
- startTask(name, detail) {
173
- if (this.finished)
174
- return () => { };
175
- const task = { name, startMs: Date.now(), ...(detail ? { detail } : {}) };
176
- this.pendingTasks.add(task);
177
- return (status = 'ok') => {
188
+ startTask(name, detail, options = {}) {
189
+ const task = { name, startMs: Date.now(), detail, summary: options.summary, segments: [] };
190
+ if (options.initialPhase)
191
+ task.current = { phase: options.initialPhase, startMs: task.startMs };
192
+ if (!this.finished)
193
+ this.pendingTasks.add(task);
194
+ const settle = (status = 'ok') => {
178
195
  if (this.finished || !this.pendingTasks.has(task))
179
196
  return;
180
- this.addSpan(name, task.startMs, Date.now(), detail, status);
197
+ this.spans.push({ ...this.taskSnapshot(task, Date.now()), status });
181
198
  this.pendingTasks.delete(task);
182
199
  if (this.readyAtMs !== undefined) {
183
200
  if (this.pendingTasks.size === 0)
@@ -186,12 +203,19 @@ export class StartupTracer {
186
203
  this.persist(true);
187
204
  }
188
205
  };
206
+ return Object.assign(settle, {
207
+ phase: (phase, phaseDetail) => {
208
+ if (this.finished || !this.pendingTasks.has(task))
209
+ return;
210
+ this.changePhase(task, phase, phaseDetail);
211
+ },
212
+ });
189
213
  }
190
214
  /** 观察实际任务(含依赖等待),保持原有返回值和异常传播。 */
191
- track(name, run, detail) {
192
- const settle = this.startTask(name, detail);
215
+ track(name, run, detail, options) {
216
+ const settle = this.startTask(name, detail, options);
193
217
  try {
194
- return run().then(value => {
218
+ return run(settle.phase).then(value => {
195
219
  settle(value === false ? 'cancelled' : 'ok');
196
220
  return value;
197
221
  }, error => {
@@ -246,12 +270,10 @@ export class StartupTracer {
246
270
  const now = Date.now();
247
271
  this.closeCursor(now);
248
272
  for (const task of this.pendingTasks) {
249
- this.addSpan(task.name, task.startMs, now, task.detail, 'cancelled');
273
+ this.spans.push({ ...this.taskSnapshot(task, now), status: 'cancelled' });
250
274
  }
251
275
  this.pendingTasks.clear();
252
276
  this.finished = true;
253
- if (this.cursorName)
254
- this.cursorName = null;
255
277
  this.persist(this.readyAtMs !== undefined || ok, now);
256
278
  }
257
279
  persist(ok, now = Date.now()) {
@@ -270,7 +292,10 @@ export class StartupTracer {
270
292
  backgroundState: this.pendingTasks.size ? 'pending'
271
293
  : this.spans.some(span => span.status === 'failed') ? 'failed'
272
294
  : this.spans.some(span => span.status === 'cancelled') ? 'interrupted' : 'complete',
273
- pendingTasks: [...this.pendingTasks],
295
+ pendingTasks: [...this.pendingTasks].map(task => {
296
+ const { durationMs, ...snapshot } = this.taskSnapshot(task, now);
297
+ return snapshot;
298
+ }),
274
299
  }),
275
300
  meta: this.meta,
276
301
  spans: this.spans,
@@ -283,18 +308,30 @@ export class StartupTracer {
283
308
  }
284
309
  }
285
310
  closeCursor(now) {
286
- if (!this.cursorName)
311
+ if (!this.cursor)
287
312
  return;
288
- const span = {
289
- name: this.cursorName,
290
- startMs: this.cursorStartMs,
291
- durationMs: Math.max(0, now - this.cursorStartMs),
292
- };
293
- if (this.cursorDetail)
294
- span.detail = this.cursorDetail;
295
- this.spans.push(span);
296
- this.cursorName = null;
297
- this.cursorDetail = undefined;
313
+ this.spans.push(this.taskSnapshot(this.cursor, now));
314
+ this.cursor = undefined;
315
+ }
316
+ changePhase(task, phase, detail) {
317
+ if (task.current?.phase === phase && task.current.detail === detail)
318
+ return;
319
+ const now = Date.now();
320
+ if (task.current && now > task.current.startMs) {
321
+ task.segments.push({ ...task.current, durationMs: now - task.current.startMs });
322
+ }
323
+ task.current = { phase, startMs: now, ...(detail ? { detail } : {}) };
324
+ }
325
+ /** Snapshot open segments without mutating their boundaries or writing at every transition. */
326
+ taskSnapshot(task, now) {
327
+ const segments = task.segments.slice();
328
+ if (task.current && now > task.current.startMs) {
329
+ segments.push({ ...task.current, durationMs: now - task.current.startMs });
330
+ }
331
+ return { name: task.name, startMs: task.startMs, durationMs: Math.max(0, now - task.startMs),
332
+ ...(task.detail ? { detail: task.detail } : {}),
333
+ ...(task.summary ? { summary: true } : {}),
334
+ ...(segments.length ? { segments } : {}) };
298
335
  }
299
336
  }
300
337
  /** 本进程启动时刻。用 uptime 回推,能覆盖 node 启动 + 模块加载 + tsx 编译。 */
@@ -1,8 +1,12 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { spawnSync } from 'node:child_process';
3
+ import { execFile, spawnSync } from 'node:child_process';
4
+ import { promisify } from 'node:util';
5
+ const execFileAsync = promisify(execFile);
4
6
  const MAX_CACHE_ENTRIES = 128;
5
7
  const signatureCache = new Map();
8
+ const pendingCmdSignatures = new Map();
9
+ let signatureGeneration = 0;
6
10
  /**
7
11
  * The signer name is checked only after Authenticode reports a trusted chain.
8
12
  * Keep this list deliberately small: an unsigned or unknown Bash distribution
@@ -108,8 +112,8 @@ function isAppExecutionAliasPath(value) {
108
112
  function shellQuote(value) {
109
113
  return `'${value.replaceAll("'", "''")}'`;
110
114
  }
111
- function probeAuthenticode(filePath) {
112
- const script = [
115
+ function authenticodeScript(filePath) {
116
+ return [
113
117
  '$ErrorActionPreference = "Stop"',
114
118
  `$p = ${shellQuote(filePath)}`,
115
119
  '$item = Get-Item -LiteralPath $p -Force',
@@ -121,8 +125,10 @@ function probeAuthenticode(filePath) {
121
125
  ' issuer = if ($sig.SignerCertificate) { [string]$sig.SignerCertificate.Issuer } else { "" }',
122
126
  '} | ConvertTo-Json -Compress',
123
127
  ].join('\n');
128
+ }
129
+ function probeAuthenticode(filePath) {
124
130
  const result = spawnSync(systemPowerShellPath(), [
125
- '-NoLogo', '-NoProfile', '-NonInteractive', '-Command', script,
131
+ '-NoLogo', '-NoProfile', '-NonInteractive', '-Command', authenticodeScript(filePath),
126
132
  ], {
127
133
  encoding: 'utf8',
128
134
  env: systemPowerShellEnvironment(),
@@ -132,8 +138,11 @@ function probeAuthenticode(filePath) {
132
138
  });
133
139
  if (result.status !== 0 || result.error || !String(result.stdout || '').trim())
134
140
  return undefined;
141
+ return parseAuthenticode(String(result.stdout));
142
+ }
143
+ function parseAuthenticode(output) {
135
144
  try {
136
- const parsed = JSON.parse(String(result.stdout));
145
+ const parsed = JSON.parse(output);
137
146
  return {
138
147
  status: typeof parsed.status === 'string' ? parsed.status : undefined,
139
148
  subject: typeof parsed.subject === 'string' ? parsed.subject : undefined,
@@ -207,6 +216,10 @@ export function isTrustedWindowsShellExecutable(executable, kind) {
207
216
  export function resolveTrustedWindowsCmdPath(comSpec) {
208
217
  if (process.platform !== 'win32')
209
218
  return comSpec || 'cmd.exe';
219
+ const systemReal = resolveWindowsCmdCandidate(comSpec);
220
+ return systemReal && isTrustedWindowsShellExecutable(systemReal, 'cmd') ? systemReal : undefined;
221
+ }
222
+ function resolveWindowsCmdCandidate(comSpec) {
210
223
  const systemCmd = windowsSystemCmdPath();
211
224
  const candidate = (comSpec || process.env.ComSpec || process.env.COMSPEC || systemCmd).trim();
212
225
  if (!candidate)
@@ -230,9 +243,70 @@ export function resolveTrustedWindowsCmdPath(comSpec) {
230
243
  if (path.win32.normalize(candidateReal).toLowerCase() !== path.win32.normalize(systemReal).toLowerCase()) {
231
244
  return undefined;
232
245
  }
233
- return isTrustedWindowsShellExecutable(systemReal, 'cmd') ? systemReal : undefined;
246
+ return systemReal;
247
+ }
248
+ /** Async probes keep the same system-path and signature policy without blocking I/O callbacks. */
249
+ export async function resolveTrustedWindowsCmdPathAsync(comSpec) {
250
+ if (process.platform !== 'win32')
251
+ return comSpec || 'cmd.exe';
252
+ const systemReal = resolveWindowsCmdCandidate(comSpec);
253
+ if (!systemReal || isAppExecutionAliasPath(systemReal))
254
+ return undefined;
255
+ let stat;
256
+ try {
257
+ stat = fs.statSync(systemReal);
258
+ if (!stat.isFile())
259
+ return undefined;
260
+ }
261
+ catch {
262
+ return undefined;
263
+ }
264
+ const key = cacheKey(systemReal);
265
+ const cached = signatureCache.get(key);
266
+ if (cached && cached.size === stat.size && cached.mtimeMs === stat.mtimeMs) {
267
+ return cached.trusted ? systemReal : undefined;
268
+ }
269
+ const identity = `${key}:${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`;
270
+ let pending = pendingCmdSignatures.get(identity);
271
+ if (!pending) {
272
+ const generation = signatureGeneration;
273
+ pending = (async () => {
274
+ try {
275
+ const { stdout } = await execFileAsync(systemPowerShellPath(), [
276
+ '-NoLogo', '-NoProfile', '-NonInteractive', '-Command', authenticodeScript(systemReal),
277
+ ], { encoding: 'utf8', env: systemPowerShellEnvironment(), timeout: 5000, windowsHide: true });
278
+ const current = fs.statSync(systemReal);
279
+ if (generation !== signatureGeneration || !current.isFile()
280
+ || current.size !== stat.size || current.mtimeMs !== stat.mtimeMs || current.ctimeMs !== stat.ctimeMs
281
+ || resolveWindowsCmdCandidate(comSpec) !== systemReal)
282
+ return false;
283
+ const trusted = isTrustedShellSignature('cmd', parseAuthenticode(stdout) ?? {});
284
+ signatureCache.set(key, { size: stat.size, mtimeMs: stat.mtimeMs, trusted });
285
+ while (signatureCache.size > MAX_CACHE_ENTRIES) {
286
+ const oldest = signatureCache.keys().next().value;
287
+ if (!oldest)
288
+ break;
289
+ signatureCache.delete(oldest);
290
+ }
291
+ return trusted;
292
+ }
293
+ catch {
294
+ return false;
295
+ }
296
+ })();
297
+ pendingCmdSignatures.set(identity, pending);
298
+ }
299
+ try {
300
+ return await pending ? systemReal : undefined;
301
+ }
302
+ finally {
303
+ if (pendingCmdSignatures.get(identity) === pending)
304
+ pendingCmdSignatures.delete(identity);
305
+ }
234
306
  }
235
307
  /** Test hook: clear cached signature decisions after a fixture is replaced. */
236
308
  export function clearWindowsShellTrustCache() {
309
+ signatureGeneration++;
237
310
  signatureCache.clear();
311
+ pendingCmdSignatures.clear();
238
312
  }
@@ -18,9 +18,9 @@
18
18
  | 速查表 | `aun/CHEATSHEET.md` | AUN 协议命名空间与常用操作速查 |
19
19
  | SDK 文档指引 | `aun/SDK.md` | AUN SDK 文档位置(`$AUN_SDK_DOCS`)、结构与常用入口;四语言版本共用同一份协议文档 |
20
20
  | 同步协议 | `aun/SYNC_PROTOCOL.md` | 上游协议同步 SOP |
21
- | Ability 调用 | `aun/ABILITY_CALLING.md` | AID 能力发现、JSON 文件调用、设备状态收集、ACK/等待与超时诊断 |
21
+ | Ability 调用 | `aun/ABILITY_CALLING.md` | AID 能力发现、payload、设备状态收集和请求关联的协议参考;实际流程用 `ability` 技能 |
22
22
 
23
- EvolCore 能力插件体系的实施设计位于源码仓库 `$PACKAGE_ROOT/docs/ability/plugin-system/README.md`。该设计尚未实现,不是当前可用的 Ability 插件命令手册。
23
+ AUN Ability 规范与按任务选择提供、发现、管理和调用流程,统一从 `ability` 技能进入(`ec skill load ability`)。EvolCore 能力插件的现行命令语法见 `evolcore/ability.md`;源码仓库 `$PACKAGE_ROOT/docs/ability/plugin-system/README.md` 提供实施设计与交付状态,不代替随包命令手册。
24
24
 
25
25
  ## EvolCore 命令
26
26
 
@@ -1,11 +1,13 @@
1
- # AUN Ability 调用
1
+ # AUN Ability 调用
2
2
 
3
- 本文是 EvolCore 当前实现下的通用 AID Ability Caller 规程。它描述能力发现、原始 JSON
3
+ 本文是 EvolCore 当前实现下的通用 AID Ability Caller 协议与 transport 参考。它描述能力发现、原始 JSON
4
4
  传输和请求结果查询,不定义任何具体 Provider 的能力。Caller 从 Provider 发布的索引或在线发现
5
5
  结果中选择能力设备,再通过 AUN 传输层定向;EvolCore 不替 Caller 选择设备,也不提供 runtime 或 slot 寻址。
6
6
 
7
7
  与当前 EvolApp 互调采用 `aid-ability/2`、`aun.ability.index.v1` 和 `aun.ability.release.v1`。双方是独立 Provider/Caller;调用和 ACK/result 使用加密私聊,能力寻址为 Provider AID + path,设备只由 transport 选择。
8
8
 
9
+ 理解 AUN Ability 规范并选择提供、管理或调用流程时统一使用 `ability` 技能(`ec skill load ability`),仅按当前任务读取相应指南。本文是当前通用 Caller 协议与 transport 的事实参考;payload 中的 `aid-ability/2` 仅为 wire 协议版本标识。CLI 参数见 `$KITS_DOCS/evolcore/msg.md`、`$KITS_DOCS/evolcore/fs.md`、`$KITS_DOCS/evolcore/storage.md`,本地插件实例命令见 `$KITS_DOCS/evolcore/ability.md`。
10
+
9
11
  ## 边界
10
12
 
11
13
  EvolCore 负责:
@@ -31,7 +33,7 @@ EvolCore 不负责:
31
33
  推荐按三层发现:
32
34
 
33
35
  ```text
34
- L1 https://<provider-aid>/ability/index.json
36
+ L1 <provider-aid>:/.well-known/ability/index.json
35
37
  发布者能力快照,可缓存但可能过期
36
38
 
37
39
  L2 protocol/discover
@@ -41,22 +43,14 @@ L3 detail_ref 指向的 JSON
41
43
  不可变能力契约,包含参数、结果、安全和幂等要求
42
44
  ```
43
45
 
44
- Provider 是当前 AUN 私聊对端时,托管会话直接读取明确的公开文本路径:
45
-
46
- ```text
47
- ec fs cat <provider-aid>:/ability/index.json
48
- ```
49
-
50
- 该入口只允许 `cat` 当前私聊对端,不开放目录枚举、其他 AID 或写操作;personal storage 仍按
51
- public/ACL 鉴权。单次读取预算默认及最高为 128 KiB,超限返回 FS_CAT_TOO_LARGE,不返回截断正文。
52
- 文件超出预算、Provider 不是当前私聊对端、文件非文本或者当前运行时尚不支持该入口时,
53
- 回退到下载,并把临时文件放在当前会话的 `$TMPDIR`:
46
+ 通过 `ec fs cat` 读取该 Provider 发布的 L1 索引:
54
47
 
55
48
  ```text
56
- ec storage download <self-aid> https://<provider-aid>/ability/index.json $TMPDIR/ability-index.json
49
+ ec fs cat <provider-aid>:/.well-known/ability/index.json
57
50
  ```
58
51
 
59
- 能力发现不能依赖目录枚举;只读取明确的 `index.json` 和 `detail_ref`。
52
+ 能力发现不能依赖目录枚举;只读取明确的 `index.json` 和契约给出的 `detail_ref`。该位置
53
+ object not found 时,旧版 Provider 仍在 `/ability/index.json` 发布,可回退读取一次。
60
54
 
61
55
  L1/L2/L3 中用于机器决策的字段只有结构化字段:
62
56
 
@@ -49,7 +49,7 @@ evolcore 收到消息 → 构造一份 **vars**(运行时变量,见下)→
49
49
  渲染时按 `session.sessionType`(缺省 `'main'`)依次查:`sessionManifests` 覆盖 → 内置映射 → `eck_manifest.json`(`resolveSessionManifest`)。bootstrapping 阶段固定用 `eck_manifest.json`。
50
50
  **每个 manifest 文件各自两级合并**(`$KITS/<file>` + `$ECK/<file>`),互不干扰。
51
51
 
52
- `chatMode=paactive` 是私聊文本展示分支,不是新的 `sessionType` 或独立上下文体系。active AUN 人类 Owner 私聊(含话题)继续使用按现有生命周期、sessionType 和 `sessionManifests` 选择的 system/message manifest,并复用基础 vars;`chatMode` 保持 `paactive`。派生变量 `activePush=true` 表示正式回复使用托管发送,供共用模板复用发送说明。Proactive 工具门禁变量仅在 proactive 任务注入。群聊固定 proactive;interactive 和 paactive 仅适用于私聊。
52
+ `chatMode` 只支持 interactive/proactive,均复用按生命周期、sessionType 和 sessionManifests 选择的 system/message manifest 与基础 vars。派生变量 `activePush` 仅在 proactive 时为 true,工具门禁变量也按 proactive 注入。PA 身份不改变 Agent 可见的模式、manifest 或 vars;仅在 active AUN 人类 Owner 私聊主会话及话题中,将 PA 的 proactive 过程 activity 经 message.send 可靠投递,任务成功提交后的自动最终正文为 custom/agent_final。其他 proactive 场景使用 thought.put,群聊固定 proactive。默认逐条消息头显示本轮可信 chatMode;两种模式均不展示明文/密文标签;原始 encrypted 变量及发送加密语义不变。
53
53
 
54
54
  ## section 字段
55
55
 
@@ -47,7 +47,7 @@ Windows 上 Codex 托管任务出现 `helper_sandbox_lock_failed`、`SetNamedSec
47
47
  | `ec aid` | AID 身份、名片与头像管理 | 身份/证书/名片/头像/换头像/探测对端 | 任意有渠道场景 | `aid.md` |
48
48
  | `ec fs` | AUN 文件系统统一入口 | 上传/下载/看文件/列目录/删文件/配额/群空间 | 任意有渠道场景 | `fs.md` |
49
49
  | `ec storage` | 文件存储底层调试入口 | storage 调试/旧命令/底层上传下载 | 任意有渠道场景 | `storage.md` |
50
- | `ec agent` | EvolAgent 生命周期与主机信息 | 创建/启停/热重载/改配置/查主机信息 | 管理操作按目标与角色鉴权 | `agent.md`;创建流程用 `ec-agent-create` 技能,Bootstrap 参考见 `agent-create.md` |
50
+ | `ec agent` | EvolAgent 生命周期、主机信息与模板 | 创建/启停/热重载/改配置/查主机信息/打包模板/安装模板 | 管理操作按目标与角色鉴权;template 要求双 Owner | `agent.md`;创建流程用 `ec-agent-create` 技能,Bootstrap 参考见 `agent-create.md` |
51
51
  | `ec peer` | 对端身份与本地拉黑 | 查已登记对端、拉黑/解除拉黑 | 拉黑为 Agent 自身行为;添加联系人与审批归 Owner | `peer.md` |
52
52
  | `ec directory` | Owner 名录查询、入录申请与本地备注 | 联系人/通讯录/名录/找人的 AID/申请添加联系人/这个人是谁/内外联系人/拉黑名单/记备注 | 查询需 Owner 名录授权;申请通过 `request` 发给本端 Owner | `directory.md` |
53
53
  | `ec rpc` | 底层 AUN RPC(逃生通道) | 直接调协议方法 | 仅宿主终端;托管会话仅可查看帮助 | `rpc.md` |
@@ -83,6 +83,8 @@ Windows 上 Codex 托管任务出现 `helper_sandbox_lock_failed`、`SetNamedSec
83
83
  | `ec stats` | Token 用量与费用统计 | 用量/费用/统计/预算/token/cost | `stats.md` |
84
84
  | `ec trigger` | 定时与事件触发器管理(创建用 `create`,`set` 为兼容别名) | 触发器/定时任务/cron/提醒/定时检查/自动执行/巡检/禁用 trigger/删除 trigger | `trigger.md` |
85
85
  | `ec trigger event` | EventBus 事件目录 | 事件触发/事件目录/EventBus/source.type=event/filter.match | `event.md` |
86
+ | `ec events` | AUN 事件中心:注册/发布/订阅事件,事件到达跑脚本 | 事件中心/注册事件/发布事件/订阅事件/事件包/pack.json/events-config.json/scripts/AUN 事件 | `event-center.md` |
87
+ | `ec services` | 服务路由:服务包状态/诊断/重载,对端 describe/schema/call | 服务路由/服务包/提供接口/被对端调用/pack.json/services.call/服务节点 | `services.md` |
86
88
  | `ec task` | 恢复暂停或异常中断的会话任务 | 任务恢复/异常中断/继续任务/resume | `task.md` |
87
89
  | `ec skill` | EC 技能管理(新建/安装/删除/启用/禁用/校验/查路径) | 创建技能/新建 skill/安装技能/装个 skill/删除技能/禁用技能/启用技能/看看有哪些技能/技能为什么没生效 | `ec-capabilities.md` |
88
90
  | `ec pa-workspace` | 在 Owner 的 AUN 私聊中查看和维护 PA 工作区入口导航 | 个人助理工作区/工作区入口调整/产物入口/报告入口/任务入口/隐藏入口/改名入口/排序入口 | `pa-workspace.md` |
@@ -2,6 +2,10 @@
2
2
 
3
3
  本手册描述已经实现的 CLI。默认输出 JSON;每条 `ec` 命令单独执行。下列 `<...>` 为实际运行结果或用户指定值,不能原样提交。
4
4
 
5
+ `ability` 技能介绍 AUN Ability 规范并组织提供、发现、管理和调用任务(`ec skill load ability`);本手册只维护 EvolCore 插件开发、实例管理与本地调用命令的语法和行为。远端 AUN 发现与调用协议见 `$KITS_DOCS/aun/ABILITY_CALLING.md`。
6
+
7
+ `ec ability invoke` 调用宿主内可管理的已安装实例,不是远端 AUN 调用。当前没有 `ec ability remote` 命令;远端发现、设备选择和调用由同一技能衔接 `$KITS_DOCS/aun/ABILITY_CALLING.md` 与 `ec fs`/`ec msg`,无需另装 Caller 技能。
8
+
5
9
  ## 身份与命令发现
6
10
 
7
11
  ```text
@@ -1,6 +1,27 @@
1
1
  # ec agent — EvolAgent 生命周期管理
2
2
 
3
- 管理本机托管的 EvolAgent(创建、启停、配置、热重载)。触发词:创建/新建/列出/查看/启用/禁用/删除/热重载/改配置。
3
+ 管理本机托管的 EvolAgent(创建、启停、配置、热重载、模板)。触发词:创建/新建/列出/查看/启用/禁用/删除/热重载/改配置/打包模板/安装模板。
4
+
5
+ ## Agent 模板
6
+
7
+ 一期覆盖现有 agent,保留其 AID、Owner、角色和默认项目目录。打包不带记忆、消息、私钥或 Provider 凭证;只将本次安装的 Trigger 停用,并携带其脚本。执行要求操作者同时是 DaemonOwner 和来源/目标 Agent 的协议 Owner。
8
+
9
+ ```bash
10
+ ec agent template inspect <aid>
11
+ ec agent template build <aid> --version 1.0.0 --name '研究助理' --workspace dist,docs --skill paper-digest
12
+ ec agent template push <buildId> --owner <owner-aid> --path /templates/<id>/<id>-1.0.0.ectpl
13
+ ec agent template pull <owner-aid>:/templates/<id>/<id>-1.0.0.ectpl --share-id <短码> --digest sha256:<摘要> --agent <target-aid>
14
+ ec agent template deploy <pullId> --providers-json '{"claude":{"provider":"provider-12345678","model":"opus"}}'
15
+ ec agent template status <jobId>
16
+ ```
17
+
18
+ 外来模板包可以包含多个成员。导入时用 `--targets-json '{"assistant":"assistant.agentid.cn","writer":"writer.agentid.cn"}'` 替代 `--agent`,将所有成员一对一映射到已有 Agent;不新建身份。deploy 可用 `--members-json '{"writer":{"providers":{"claude":{"provider":"provider-12345678","model":"writer-model"}}}}'` 指定逐成员选项。每个目标都须由请求者拥有,同包备份、安装与恢复作为一笔事务;不完整映射、重复目标或共享内容冲突会被拒绝。
19
+
20
+ 完整选项用 `ec agent template --help` 查看。build 版本显式传入;App 从 Owner 空间列版本后建议 patch +1。上传前由 App 授予打包 host 目录写权限;普通私有下载使用 `storage.create_share_link.allowed_aids` 指定目标 host,pull 接收其 Storage 分享短码;Owner/subaid 动态授权等待新 SDK,不由 daemon 代设权限。
21
+
22
+ 异步命令默认等待 60 秒,可用 `--wait 0..300`;超时返回可查询状态,不表示任务取消。`--request-id` 固定原请求用于恢复,Menu 还支持按原 requestId 查询。相同 pullId 的 deploy 只执行一次。预览后文件改变返回 CONFLICT;有活动任务返回 AGENT_BUSY。安装失败自动恢复实际写入文件与名片;INSTALL_BROKEN 表示恢复未完成,保留备份并停止目标接收新任务,需人工修复。
23
+
24
+ 工具随包位于 `scripts/agent-template/`。Evol App 调用、Provider 模型目录查询和事件契约详见仓库 `docs/agent-template/agent-template-app-integration.md`;真实 AUN 跨主机流程已在隔离实验室验证,本轮修复需宿主重新构建并重启,App 界面待联调。宿主 CLI 在 Control AUN 连接完成后可直接调用,不需要先发送一次 Menu 来刷新 Owner。
4
25
 
5
26
  ## 子命令
6
27
 
@@ -139,7 +139,7 @@ Owner 目录同步在连接可用时建立单条核验和暂态故障退避链
139
139
 
140
140
  Ownership 任务事件、修改本地 Owner 配置、相关名片或 Owner 关系材料变更只失效缓存,不主动发起复核。连接首次就绪、断线恢复和缓存到期均不触发提前刷新;下次实际消息、查询或授权需要 Owner 时才等待核验。相同任务事件和连接通知去重,无关对端、普通文件变更不触发失效。远端 Owner 的 Storage 事件只在本机确实收到时生效,不能假定事件完整覆盖远端变化。Owner 绑定提交前及修改 Owner 的授权仍要求显式核验成功。
141
141
 
142
- 生命周期有效的普通 Agent(包括已经 `active` 的存量 Agent)在 AUN 连接就绪后,优先取根级 `config.json.owner`,缺失时兼容旧 `owners` 数组的首个非空 AID;沿用首个配置 Owner 的选择规则,不向数组内所有 AID 发送邀约。没有绑定目标或生命周期无效时静默跳过。存在绑定目标且新鲜协议状态为 `unbound`、`released` 或 `single_sided` 时,每个 Agent 对同一 Owner 在本进程内最多自动提交一次绑定邀约,`active` 不再阻断启动补绑定。已有协议共识时不提交,也不自动转让 Owner。提交前记录 INFO 日志 `Submitting configured Owner binding invitation`,包含主体、目标 Owner 和协议状态;提交结果与失败继续记录 `EC_OWNERSHIP` 的 `bind.result` / `bind.failed`。等待确认、提交失败或回执不明均不定时重发,断线重连和渠道重建也不会再次提交;需要重发时显式执行绑定命令。自动尝试记录只保存在内存,不持久化;进程重启后重新检查并允许再自动提交一次。
142
+ 处于 `created`、`ownerpending` 或 `bootstrapping` 生命周期的普通 Agent 在 AUN 连接就绪后,优先取根级 `config.json.owner`,缺失时兼容旧 `owners` 数组的首个非空 AID;沿用首个配置 Owner 的选择规则,不向数组内所有 AID 发送邀约。没有绑定目标、生命周期无效或已经 `active` 时静默跳过,不因遗留配置重新绑定。存在绑定目标且新鲜协议状态为 `unbound`、`released` 或 `single_sided` 时,每个 Agent 对同一 Owner 在本进程内最多自动提交一次绑定邀约。已有协议共识时不提交,也不自动转让 Owner。提交前记录 INFO 日志 `Submitting configured Owner binding invitation`,包含主体、目标 Owner 和协议状态;提交结果与失败继续记录 `EC_OWNERSHIP` 的 `bind.result` / `bind.failed`。等待确认、提交失败或回执不明均不定时重发,断线重连和渠道重建也不会再次提交;需要重发时显式执行绑定命令。自动尝试记录只保存在内存,不持久化;进程重启后重新检查并允许再自动提交一次。
143
143
 
144
144
  普通 Agent 的创建、手动绑定、启动补绑定和转让,在提交关系修改前实时读取目标 Owner 的远端已验签名片,要求名片 AID 匹配且 `type: human`;非 human 返回 `INVALID_OWNER`,无法读取、未验签、类型缺失或名片不匹配返回 `OWNER_IDENTITY_UNAVAILABLE`。接受绑定或转让邀约也执行此限制;当前进程没有请求投影时,先从历史消息定位原请求的目标用于类型预检,原请求真实性及固定参与方仍由 SDK 在提交时核验。拒绝邀约不受目标类型限制。该限制面向普通 Agent,不把 daemon Control AID 的身份规则改成 Agent 规则,也不追溯修改已有协议关系。
145
145