evolcore 0.0.31 → 0.0.33

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 (179) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/bin/install-codex-managed-hooks.mjs +124 -37
  3. package/dist/agents/claude-runner.js +29 -2
  4. package/dist/agents/codex/app-server-client.js +3 -0
  5. package/dist/agents/codex/diagnostics.js +76 -44
  6. package/dist/agents/codex-runner.js +51 -24
  7. package/dist/agents/ecagent-runner.js +9 -13
  8. package/dist/agents/gemini-runner.js +4 -0
  9. package/dist/aun/aid/store.js +0 -81
  10. package/dist/aun/group/fs-download.js +1 -10
  11. package/dist/aun/group/operations.js +0 -1
  12. package/dist/aun/msg/history.js +1 -0
  13. package/dist/aun/msg/managed-operation.js +130 -32
  14. package/dist/aun/msg/p2p.js +0 -1
  15. package/dist/aun/outbox.js +50 -1
  16. package/dist/aun/service-proxy.js +12 -18
  17. package/dist/aun/storage/index.js +29 -0
  18. package/dist/channels/aun.js +38 -137
  19. package/dist/channels/daemon.js +257 -2
  20. package/dist/cli/agent-command.js +64 -31
  21. package/dist/cli/agent-create.js +43 -24
  22. package/dist/cli/agent.js +16 -70
  23. package/dist/cli/aun-commands.js +512 -32
  24. package/dist/cli/contact.js +8 -2
  25. package/dist/cli/ctl-command.js +1 -2
  26. package/dist/cli/daemon-commands.js +82 -13
  27. package/dist/cli/debug-mode.js +154 -0
  28. package/dist/cli/diag.js +2 -2
  29. package/dist/cli/handoff-command.js +18 -5
  30. package/dist/cli/index.js +81 -64
  31. package/dist/cli/init.js +2 -2
  32. package/dist/cli/managed-command-guard.js +5 -0
  33. package/dist/cli/memory-command.js +93 -12
  34. package/dist/cli/model.js +14 -138
  35. package/dist/cli/queue-command.js +51 -0
  36. package/dist/cli/response.js +5 -54
  37. package/dist/cli/session-command.js +194 -0
  38. package/dist/cli/skill-command.js +85 -3
  39. package/dist/cli/stats.js +10 -4
  40. package/dist/cli/task-command.js +1 -0
  41. package/dist/cli/task-context.js +16 -0
  42. package/dist/cli/thread-command.js +620 -0
  43. package/dist/cli/trigger-command.js +76 -50
  44. package/dist/config/builtin-roles.js +9 -7
  45. package/dist/config/config-field-policy.js +2 -3
  46. package/dist/config/config-manager.js +7 -2
  47. package/dist/config/resolved-config-op.js +3 -0
  48. package/dist/config-store.js +15 -0
  49. package/dist/core/agent-ipc-registration.js +65 -22
  50. package/dist/core/auth/agent-delegation.js +42 -2
  51. package/dist/core/auth/debug-context.js +139 -0
  52. package/dist/core/auth/delegation-authorization.js +1 -0
  53. package/dist/core/auth/operation-authorizer.js +24 -1
  54. package/dist/core/auth/operation-catalog.js +44 -3
  55. package/dist/core/background-session/session-cleanup.js +212 -0
  56. package/dist/core/background-session/types.js +10 -0
  57. package/dist/core/bootstrap-messages.js +1 -1
  58. package/dist/core/bootstrap-service.js +6 -3
  59. package/dist/core/command/command-handler.js +224 -45
  60. package/dist/core/command/diag-service.js +5 -1
  61. package/dist/core/command/memory-slash.js +6 -2
  62. package/dist/core/command/menu-catalog.js +48 -1
  63. package/dist/core/command/menu-handler.js +92 -16
  64. package/dist/core/command/menu-protocol.js +24 -1
  65. package/dist/core/command/skill-slash.js +322 -0
  66. package/dist/core/command/slash-gate.js +6 -4
  67. package/dist/core/command/slash-handler.js +193 -13
  68. package/dist/core/command/topic-slash.js +528 -0
  69. package/dist/core/evolagent-registry.js +20 -5
  70. package/dist/core/handoff/ipc-registration.js +38 -0
  71. package/dist/core/handoff/runtime.js +5 -11
  72. package/dist/core/handoff/store.js +5 -0
  73. package/dist/core/ipc-registration.js +210 -9
  74. package/dist/core/memory/consolidation-context.js +49 -16
  75. package/dist/core/memory/consolidation-ops-records.js +35 -0
  76. package/dist/core/memory/consolidation-queue-format.js +21 -0
  77. package/dist/core/memory/consolidation.js +174 -180
  78. package/dist/core/message/aun-ipc-sender.js +207 -8
  79. package/dist/core/message/im-renderer.js +149 -6
  80. package/dist/core/message/message-bridge.js +13 -3
  81. package/dist/core/message/message-log.js +1 -0
  82. package/dist/core/message/message-queue.js +131 -3
  83. package/dist/core/message/peer-mode.js +6 -1
  84. package/dist/core/message/response-engine.js +379 -69
  85. package/dist/core/message/subtask-tool-projection.js +140 -0
  86. package/dist/core/model/catalog-service.js +17 -12
  87. package/dist/core/permission/ec-command-parser.js +126 -7
  88. package/dist/core/permission/sandbox-runtime.js +14 -1
  89. package/dist/core/session/session-idle-monitor.js +249 -22
  90. package/dist/core/session/session-manager.js +54 -9
  91. package/dist/core/skill/command-parser.js +13 -0
  92. package/dist/core/skill/index-generator.js +4 -1
  93. package/dist/core/skill/startup.js +41 -0
  94. package/dist/core/skill/switch-resolver.js +55 -29
  95. package/dist/core/task/task-recovery-service.js +2 -0
  96. package/dist/core/task/task-resume-operation.js +11 -0
  97. package/dist/core/thread/command-parser.js +125 -0
  98. package/dist/core/thread/index.js +1 -0
  99. package/dist/core/thread/ipc-operation.js +95 -0
  100. package/dist/core/thread/thread-context-storage.js +131 -0
  101. package/dist/core/thread/thread-operation.js +258 -0
  102. package/dist/core/thread/thread-route.js +33 -0
  103. package/dist/core/thread/thread-service.js +777 -0
  104. package/dist/core/thread/types.js +1 -0
  105. package/dist/eck/message-renderer.js +35 -0
  106. package/dist/index.js +10 -7
  107. package/dist/ipc.js +234 -17
  108. package/dist/paths.js +23 -0
  109. package/dist/response-system/engines/v1/proactive-flow.js +169 -80
  110. package/dist/trigger/authorization.js +59 -29
  111. package/dist/trigger/feedback.js +7 -1
  112. package/dist/trigger/ipc-service.js +49 -35
  113. package/dist/trigger/parser.js +63 -1
  114. package/dist/trigger/script-sandbox.js +58 -77
  115. package/dist/trigger/validation.js +14 -0
  116. package/dist/utils/error-utils.js +22 -1
  117. package/kits/docs/AUTHORING.md +1 -1
  118. package/kits/docs/channels/aun.md +8 -0
  119. package/kits/docs/context-assembly.md +1 -0
  120. package/kits/docs/evolcore/INDEX.md +3 -2
  121. package/kits/docs/evolcore/agent-create.md +39 -28
  122. package/kits/docs/evolcore/agent.md +19 -4
  123. package/kits/docs/evolcore/ec-capabilities.md +4 -0
  124. package/kits/docs/evolcore/group-collaboration.md +3 -5
  125. package/kits/docs/evolcore/group.md +3 -4
  126. package/kits/docs/evolcore/memory-consolidation.md +1 -1
  127. package/kits/docs/evolcore/menu-exec-schema-commands.md +2 -2
  128. package/kits/docs/evolcore/menu-protocol.md +7 -0
  129. package/kits/docs/evolcore/msg.md +5 -8
  130. package/kits/docs/evolcore/task.md +2 -0
  131. package/kits/docs/evolcore/thread-chain.md +267 -0
  132. package/kits/docs/evolcore/trigger.md +2 -2
  133. package/kits/docs/prompt-loading-architecture.md +1 -0
  134. package/kits/eck_manifest.json +61 -26
  135. package/kits/eck_message_manifest.json +169 -10
  136. package/kits/rules/01-overview.md +0 -9
  137. package/kits/rules/05-venue.md +1 -1
  138. package/kits/rules/06-channel.md +7 -1
  139. package/kits/rules/07-memory-and-thread.md +202 -0
  140. package/kits/schemas/relation-config.schema.9.json +18 -3
  141. package/kits/schemas/role-config.schema.1.json +6 -6
  142. package/kits/schemas/single-session.schema.1.json +6 -6
  143. package/kits/schemas/single-session.schema.2.json +6 -6
  144. package/kits/schemas/single-session.schema.3.json +6 -6
  145. package/kits/skills/.switches.json +12 -1
  146. package/kits/skills/ec-group/SKILL.md +234 -0
  147. package/kits/skills/ec-skill/SKILL.md +10 -1
  148. package/kits/skills/ec-skill/scripts/cli.mjs +15 -1
  149. package/kits/skills/scrapling-article-fetch/SKILL.md +128 -0
  150. package/kits/skills/scrapling-article-fetch/scripts/check_python_env.py +54 -0
  151. package/kits/skills/scrapling-article-fetch/scripts/render_markdown_reply.py +35 -0
  152. package/kits/skills/scrapling-article-fetch/scripts/run_pipeline.sh +16 -0
  153. package/kits/skills/scrapling-article-fetch/scripts/scrapling_fetch.py +344 -0
  154. package/kits/skills/thread-ops/SKILL.md +492 -0
  155. package/kits/skills/wechat-article-media-download/SKILL.md +65 -0
  156. package/kits/skills/wechat-article-media-download/scripts/download.py +163 -0
  157. package/kits/skills/wechat-article-reader/SKILL.md +97 -0
  158. package/kits/skills/wechat-article-reader/scripts/fetch.mjs +256 -0
  159. package/kits/templates/bootstrap-welcome.md +7 -7
  160. package/kits/templates/memory-consolidation/forget.md +5 -0
  161. package/kits/templates/memory-consolidation/generalize.md +5 -0
  162. package/kits/templates/memory-consolidation/profile.md +5 -0
  163. package/kits/templates/memory-consolidation/promote.md +5 -0
  164. package/kits/templates/message-fragments/item.md +2 -1
  165. package/kits/templates/message-fragments/thread-context.md +6 -0
  166. package/kits/templates/message-fragments/trigger-session.md +2 -0
  167. package/kits/templates/message-fragments/trigger-thread-check.md +2 -0
  168. package/kits/templates/roles/member.json +2 -0
  169. package/kits/templates/roles/visitor.json +2 -0
  170. package/kits/templates/system-fragments/bootstrap.md +66 -72
  171. package/kits/templates/system-fragments/channel.md +3 -6
  172. package/kits/templates/system-fragments/commands.md +2 -1
  173. package/kits/templates/system-fragments/managed-runtime.md +15 -0
  174. package/kits/templates/system-fragments/reply.md +3 -2
  175. package/kits/templates/system-fragments/session.md +5 -14
  176. package/package.json +3 -1
  177. package/kits/docs/evolcore/group-fs.md +0 -17
  178. package/kits/docs/venues/aun-group.md +0 -45
  179. package/kits/docs/venues/group.md +0 -43
package/dist/cli/agent.js CHANGED
@@ -14,7 +14,6 @@ import { isValidChannelName } from '../core/channel-loader.js';
14
14
  import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
15
15
  import { readTaskRuntimeContextFromEnv } from './task-context.js';
16
16
  import { isValidAid } from '../aun/aid/validation.js';
17
- import { isHClassPath, isLClassPath, isSameOrDescendant } from '../core/permission/protected-paths.js';
18
17
  import { findPostBootstrapWelcomeOutbox } from '../core/bootstrap-messages.js';
19
18
  import { resolveAgentLifecycle } from '../config/lifecycle.js';
20
19
  import { initializationSummary } from './agent-create.js';
@@ -22,7 +21,7 @@ import { parseAgentWelcomeMetadata, readAgentWelcomeTemplate, renderPostBootstra
22
21
  import { RUNTIME_ENVIRONMENT_NAMES } from '../config/runtime-env.js';
23
22
  export { agentCreateInteractive, agentCreateNonInteractive, parseAgentOwnerArgs, resolveAgentCreatePlan, validateAgentCreatePlan, validateAgentOwnerOptions, } from './agent-create.js';
24
23
  /** Route agent lifecycle commands from a managed task through daemon IPC. */
25
- export async function runManagedAgentOperation(argv) {
24
+ export async function runManagedAgentOperation(argv, timeoutMs = 60_000) {
26
25
  const sessionId = process.env.EVOLCORE_SESSION_ID;
27
26
  if (!sessionId)
28
27
  return { ok: false, code: 'MANAGED_ONLY', error: 'agent operation is not running in a managed task' };
@@ -36,7 +35,7 @@ export async function runManagedAgentOperation(argv) {
36
35
  argv: ['agent', ...argv],
37
36
  sessionId,
38
37
  delegationToken,
39
- }, 60_000);
38
+ }, timeoutMs);
40
39
  if (!response)
41
40
  return { ok: false, code: 'DAEMON_UNAVAILABLE', error: 'Unable to connect to the evolcore daemon' };
42
41
  if (!response.ok)
@@ -398,37 +397,12 @@ async function agentSetEnabled(aid, enabled, options = {}) {
398
397
  return { ok: true, aid, enabled, reloaded };
399
398
  }
400
399
  async function runManagedAgentConfig(args, options) {
401
- const sessionId = process.env.EVOLCORE_SESSION_ID;
402
- if (!sessionId || options.trustedLocal)
400
+ if (!process.env.EVOLCORE_SESSION_ID || options.trustedLocal)
403
401
  return { managed: false };
404
- const delegationToken = readDelegationCredential();
405
- if (!delegationToken) {
406
- return {
407
- managed: true,
408
- error: { ok: false, code: 'DELEGATION_REQUIRED', error: `${AGENT_DELEGATION_TOKEN_ENV} is not set for the active task` },
409
- };
410
- }
411
- try {
412
- const response = await ipcQuery(resolvePaths().socket, {
413
- type: 'config.op',
414
- argv: ['config', ...args],
415
- sessionId,
416
- delegationToken,
417
- }, 10_000);
418
- if (!response) {
419
- return { managed: true, error: { ok: false, code: 'DAEMON_UNAVAILABLE', error: 'Unable to connect to the evolcore daemon' } };
420
- }
421
- if (!response.ok || !response.result?.ok) {
422
- return {
423
- managed: true,
424
- error: { ok: false, code: response.code || 'CONFIG_AUTH_FAILED', error: response.error || 'config operation failed' },
425
- };
426
- }
427
- return { managed: true, response };
428
- }
429
- catch {
430
- return { managed: true, error: { ok: false, code: 'DAEMON_UNAVAILABLE', error: 'Unable to connect to the evolcore daemon' } };
431
- }
402
+ const result = await runManagedAgentOperation(options.argv ?? args, 10_000);
403
+ return result.ok
404
+ ? { managed: true, response: { ok: true, result } }
405
+ : { managed: true, error: result };
432
406
  }
433
407
  async function executeLocalAgentConfig(args) {
434
408
  initConfigManager();
@@ -448,7 +422,7 @@ async function executeLocalAgentConfig(args) {
448
422
  });
449
423
  }
450
424
  export async function agentGet(aid, key, options = {}) {
451
- const managed = await runManagedAgentConfig(['get', key, '--self', aid], options);
425
+ const managed = await runManagedAgentConfig(['get', aid, key], options);
452
426
  if (managed.managed) {
453
427
  if ('error' in managed)
454
428
  return managed.error;
@@ -472,7 +446,7 @@ export async function agentGet(aid, key, options = {}) {
472
446
  }
473
447
  }
474
448
  export async function agentSet(aid, key, rawValue, options = {}) {
475
- const managed = await runManagedAgentConfig(['set', key, rawValue, '--self', aid], options);
449
+ const managed = await runManagedAgentConfig(['set', aid, key, rawValue], options);
476
450
  if (managed.managed) {
477
451
  if ('error' in managed)
478
452
  return managed.error;
@@ -539,36 +513,7 @@ export async function agentPersona(aid, options = {}) {
539
513
  return { ok: false, code: 'INVALID_ARGS', error: '--text 与 --file 不能同时使用' };
540
514
  const managedSession = !!process.env.EVOLCORE_SESSION_ID && !options.trustedLocal;
541
515
  let text = options.text;
542
- if (options.file !== undefined) {
543
- if (managedSession) {
544
- const resolved = path.resolve(options.file);
545
- const projectRoot = path.resolve(process.cwd());
546
- const tempRoot = process.env.TMPDIR?.trim() && path.isAbsolute(process.env.TMPDIR)
547
- ? path.resolve(process.env.TMPDIR)
548
- : undefined;
549
- const allowed = isSameOrDescendant(resolved, projectRoot)
550
- || (!!tempRoot && isSameOrDescendant(resolved, tempRoot));
551
- if (!allowed || isHClassPath(resolved) || isLClassPath(resolved)) {
552
- return { ok: false, code: 'INVALID_ARGS', error: '--file 必须位于当前项目或会话 $TMPDIR,且不能读取 EvolCore 受保护路径' };
553
- }
554
- try {
555
- const stat = fs.lstatSync(resolved);
556
- if (stat.isSymbolicLink() || !stat.isFile()) {
557
- return { ok: false, code: 'INVALID_ARGS', error: '--file 必须指向当前项目或会话 $TMPDIR 内的普通文件' };
558
- }
559
- const realPath = fs.realpathSync(resolved);
560
- const realProjectRoot = fs.realpathSync(projectRoot);
561
- const realTempRoot = tempRoot ? fs.realpathSync(tempRoot) : undefined;
562
- const realAllowed = isSameOrDescendant(realPath, realProjectRoot)
563
- || (!!realTempRoot && isSameOrDescendant(realPath, realTempRoot));
564
- if (!realAllowed || isHClassPath(realPath) || isLClassPath(realPath)) {
565
- return { ok: false, code: 'INVALID_ARGS', error: '--file 解析后越出允许目录或命中 EvolCore 受保护路径' };
566
- }
567
- }
568
- catch (e) {
569
- return { ok: false, code: 'READ_FAILED', error: `无法校验 --file: ${e?.message || e}` };
570
- }
571
- }
516
+ if (options.file !== undefined && !managedSession) {
572
517
  const source = readPersonaSource(options.file);
573
518
  if (!source.ok)
574
519
  return source;
@@ -582,10 +527,10 @@ export async function agentPersona(aid, options = {}) {
582
527
  const managedArgs = options.text !== undefined
583
528
  ? ['persona', '--text', text]
584
529
  : options.file !== undefined
585
- ? ['persona', '--text', text]
530
+ ? ['persona', '--file', options.file]
586
531
  : ['persona', 'show'];
587
532
  if (managedSession) {
588
- const managed = await runManagedAgentOperation(managedArgs);
533
+ const managed = await runManagedAgentOperation(options.argv ?? managedArgs);
589
534
  if (!managed.ok)
590
535
  return managed;
591
536
  return { ok: true, aid, content: managed.content ?? null, ...(managed.path ? { path: managed.path } : {}), ...(managed.saved ? { saved: true } : {}) };
@@ -608,7 +553,7 @@ export async function agentPersona(aid, options = {}) {
608
553
  return { ok: false, code: 'WRITE_FAILED', error: e?.message || String(e) };
609
554
  }
610
555
  }
611
- /** Read or replace the current Agent's confirmed Bootstrap welcome template. */
556
+ /** Read or replace the current Agent's self-prepared Bootstrap welcome template. */
612
557
  export async function agentWelcome(aid, options = {}) {
613
558
  if (!isValidAid(aid))
614
559
  return { ok: false, code: 'INVALID_ARGS', error: 'Invalid Agent AID' };
@@ -625,7 +570,7 @@ export async function agentWelcome(aid, options = {}) {
625
570
  if (readTaskRuntimeContextFromEnv()?.selfAid !== aid) {
626
571
  return { ok: false, code: 'SELF_AGENT_REQUIRED', error: 'welcome only targets the current Agent' };
627
572
  }
628
- const managed = await runManagedAgentOperation(managedArgs);
573
+ const managed = await runManagedAgentOperation(options.argv ?? managedArgs);
629
574
  if (!managed.ok)
630
575
  return managed;
631
576
  return {
@@ -803,7 +748,7 @@ export async function agentRename(aid, name) {
803
748
  return { ok: true, aid, name };
804
749
  }
805
750
  // ==================== agentReady ====================
806
- export async function agentReady(aid) {
751
+ export async function agentReady(aid, commandArgs) {
807
752
  const managedSessionId = process.env.EVOLCORE_SESSION_ID;
808
753
  const taskSelfAid = managedSessionId ? readTaskRuntimeContextFromEnv()?.selfAid : undefined;
809
754
  if (taskSelfAid && taskSelfAid.replace(/^@/, '') !== aid.replace(/^@/, '')) {
@@ -822,6 +767,7 @@ export async function agentReady(aid) {
822
767
  const result = await ipcQuery(p.socket, {
823
768
  type: 'evolagent.bootstrapComplete',
824
769
  aid,
770
+ ...(managedSessionId ? { argv: ['agent', ...(commandArgs ?? ['ready', aid])] } : {}),
825
771
  ...(managedSessionId ? { sessionId: managedSessionId, delegationToken } : {}),
826
772
  }, 30_000);
827
773
  if (!result)