evolcore 0.0.26 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/bin/codex-managed-acl.ps1 +43 -0
  3. package/dist/agents/baseagent-availability.js +68 -0
  4. package/dist/agents/baseagent.js +10 -5
  5. package/dist/agents/claude-runner.js +123 -22
  6. package/dist/agents/codex/app-server-client.js +70 -26
  7. package/dist/agents/codex/catalog.js +7 -1
  8. package/dist/agents/codex-runner.js +363 -421
  9. package/dist/agents/ecagent-runner.js +170 -25
  10. package/dist/agents/gemini-runner.js +6 -0
  11. package/dist/agents/runner-types.js +50 -2
  12. package/dist/aun/aid/agentmd.js +73 -31
  13. package/dist/aun/aid/client.js +1 -1
  14. package/dist/aun/aid/control-aid.js +180 -1
  15. package/dist/aun/aid/identity.js +3 -3
  16. package/dist/aun/group/history.js +303 -0
  17. package/dist/aun/group/identity.js +43 -0
  18. package/dist/aun/group/index.js +5 -0
  19. package/dist/aun/{msg/group.js → group/operations.js} +161 -38
  20. package/dist/aun/{menu-client.js → menu/client.js} +13 -7
  21. package/dist/aun/menu/index.js +2 -0
  22. package/dist/aun/menu/transport.js +49 -0
  23. package/dist/aun/msg/index.js +2 -1
  24. package/dist/aun/msg/managed-operation.js +84 -18
  25. package/dist/aun/msg/mention-schema.js +51 -0
  26. package/dist/aun/msg/p2p.js +13 -8
  27. package/dist/aun/msg/upload.js +43 -88
  28. package/dist/aun/outbox.js +29 -7
  29. package/dist/aun/rpc/client.js +1 -0
  30. package/dist/aun/storage/client.js +39 -50
  31. package/dist/channels/aun.js +544 -239
  32. package/dist/channels/daemon.js +10 -6
  33. package/dist/cli/agent-command.js +108 -6
  34. package/dist/cli/agent-create.js +515 -2
  35. package/dist/cli/agent.js +109 -8
  36. package/dist/cli/aun-commands.js +191 -42
  37. package/dist/cli/config.js +8 -5
  38. package/dist/cli/contact.js +2 -2
  39. package/dist/cli/ctl-command.js +2 -2
  40. package/dist/cli/daemon-commands.js +111 -162
  41. package/dist/cli/diag.js +3 -3
  42. package/dist/cli/fs-command.js +3 -3
  43. package/dist/cli/handoff-command.js +6 -6
  44. package/dist/cli/index.js +8 -2
  45. package/dist/cli/init.js +34 -1
  46. package/dist/cli/managed-command-guard.js +2 -1
  47. package/dist/cli/menu-client.js +13 -5
  48. package/dist/cli/model.js +3 -3
  49. package/dist/cli/queue-command.js +2 -2
  50. package/dist/cli/response.js +2 -2
  51. package/dist/cli/restart-monitor.js +81 -19
  52. package/dist/cli/task-command.js +59 -0
  53. package/dist/cli/task-context.js +97 -49
  54. package/dist/cli/trigger-command.js +20 -10
  55. package/dist/config/builtin-roles.js +10 -0
  56. package/dist/config/config-field-policy.js +11 -0
  57. package/dist/config/config-manager.js +32 -4
  58. package/dist/config/config-operation-service.js +20 -5
  59. package/dist/config/contact-book-store.js +1 -1
  60. package/dist/config/contact-book.js +1 -1
  61. package/dist/config/contact-operation-service.js +1 -1
  62. package/dist/config/peer-role-resolver.js +1 -1
  63. package/dist/config/resolved-config-op.js +3 -0
  64. package/dist/config-store.js +1 -1
  65. package/dist/core/agent-application-service.js +5 -0
  66. package/dist/core/audit/event-key.js +17 -2
  67. package/dist/core/audit/log-integrity.js +34 -8
  68. package/dist/core/auth/agent-delegation.js +48 -14
  69. package/dist/core/auth/auth-gateway.js +2 -0
  70. package/dist/core/auth/authorization-audit.js +34 -38
  71. package/dist/core/auth/operation-authorizer.js +67 -5
  72. package/dist/core/auth/operation-catalog.js +110 -0
  73. package/dist/core/auth/remote-access-store.js +115 -9
  74. package/dist/core/bootstrap-messages.js +66 -7
  75. package/dist/core/bootstrap-service.js +110 -19
  76. package/dist/core/command/agent-control.js +88 -7
  77. package/dist/core/command/agent-storage-menu.js +443 -0
  78. package/dist/core/command/cli-intent-parser.js +19 -0
  79. package/dist/core/command/command-handler.js +105 -40
  80. package/dist/core/command/data-root-resolver.js +273 -0
  81. package/dist/core/command/diag-service.js +292 -27
  82. package/dist/core/command/group-menu.js +7 -2
  83. package/dist/core/command/menu-catalog.js +34 -4
  84. package/dist/core/command/menu-handler.js +364 -96
  85. package/dist/core/command/menu-protocol.js +43 -6
  86. package/dist/core/command/role-menu.js +2 -2
  87. package/dist/core/command/slash-handler.js +61 -37
  88. package/dist/core/event-catalog.js +4 -0
  89. package/dist/core/evolagent-registry.js +28 -2
  90. package/dist/core/group/invite-service.js +924 -0
  91. package/dist/core/interaction-router.js +22 -8
  92. package/dist/core/message/im-renderer.js +94 -16
  93. package/dist/core/message/message-bridge.js +140 -13
  94. package/dist/core/message/message-log.js +5 -3
  95. package/dist/core/message/message-queue.js +73 -41
  96. package/dist/core/message/response-engine.js +729 -118
  97. package/dist/core/permission/approval-gateway.js +36 -3
  98. package/dist/core/permission/ec-command-parser.js +76 -36
  99. package/dist/core/permission/protected-paths.js +134 -16
  100. package/dist/core/permission/sandbox-runtime.js +72 -3
  101. package/dist/core/permission/tool-error-code.js +15 -0
  102. package/dist/core/permission/tool-policy.js +8 -8
  103. package/dist/core/relation/peer-identity.js +57 -6
  104. package/dist/core/relation/shared-data.js +106 -0
  105. package/dist/core/role/runtime-policy.js +64 -0
  106. package/dist/core/runtime-lock.js +10 -26
  107. package/dist/core/session/runner-task-history.js +170 -0
  108. package/dist/core/session/session-manager.js +38 -6
  109. package/dist/core/session/session-mapper.js +41 -0
  110. package/dist/core/session/session-turn-coordinator.js +37 -7
  111. package/dist/core/session/session-turns.js +48 -7
  112. package/dist/core/task/task-recovery-service.js +176 -0
  113. package/dist/core/task/task-resume-operation.js +32 -0
  114. package/dist/eck/group-rules-sync.js +5 -3
  115. package/dist/eck/kit-renderer.js +1 -0
  116. package/dist/index.js +322 -207
  117. package/dist/ipc.js +141 -15
  118. package/dist/paths.js +17 -4
  119. package/dist/product.js +3 -0
  120. package/dist/trigger/event-source.js +19 -0
  121. package/dist/trigger/feedback.js +233 -40
  122. package/dist/trigger/parser.js +55 -5
  123. package/dist/trigger/patch.js +9 -0
  124. package/dist/trigger/scheduler.js +30 -4
  125. package/dist/trigger/validation.js +20 -3
  126. package/dist/utils/atomic-write.js +98 -0
  127. package/dist/utils/cross-platform.js +87 -16
  128. package/dist/utils/ecweb-utils.js +1 -0
  129. package/dist/utils/error-utils.js +40 -2
  130. package/dist/utils/logger.js +23 -13
  131. package/dist/utils/npm-ops.js +119 -4
  132. package/dist/utils/package-version-info.js +244 -0
  133. package/dist/utils/tool-summary.js +59 -3
  134. package/dist/utils/welcome.js +174 -1
  135. package/dist/utils/windows-shell-trust.js +37 -0
  136. package/ecagent/dist/harness/agent-harness.js +3 -0
  137. package/ecagent/dist/harness/session/jsonl-storage.js +21 -2
  138. package/kits/docs/INDEX.md +0 -6
  139. package/kits/docs/channels/aun.md +23 -2
  140. package/kits/docs/channels/feishu.md +1 -1
  141. package/kits/docs/context-assembly.md +29 -17
  142. package/kits/docs/evolcore/INDEX.md +8 -3
  143. package/kits/docs/evolcore/agent-create.md +39 -7
  144. package/kits/docs/evolcore/agent.md +33 -1
  145. package/kits/docs/evolcore/aid.md +9 -1
  146. package/kits/docs/evolcore/config.md +40 -1
  147. package/kits/docs/evolcore/group-collaboration.md +1 -1
  148. package/kits/docs/evolcore/group.md +117 -2
  149. package/kits/docs/evolcore/menu-client.md +16 -0
  150. package/kits/docs/evolcore/msg.md +3 -0
  151. package/kits/docs/evolcore/storage.md +3 -0
  152. package/kits/docs/evolcore/task.md +14 -0
  153. package/kits/docs/evolcore/trigger.md +51 -3
  154. package/kits/docs/venues/group.md +5 -0
  155. package/kits/eck_manifest.json +27 -0
  156. package/kits/rules/01-overview.md +11 -7
  157. package/kits/rules/04-relation.md +2 -1
  158. package/kits/rules/05-venue.md +1 -1
  159. package/kits/rules/06-channel.md +6 -4
  160. package/kits/schemas/agent-config.schema.12.json +25 -1
  161. package/kits/schemas/daemon.schema.6.json +2 -2
  162. package/kits/schemas/defaults.schema.5.json +1 -1
  163. package/kits/schemas/relation-config.schema.1.json +1 -1
  164. package/kits/schemas/relation-config.schema.5.json +1 -1
  165. package/kits/schemas/role-config.schema.1.json +14 -0
  166. package/kits/templates/roles/member.json +5 -0
  167. package/kits/templates/roles/visitor.json +5 -0
  168. package/kits/templates/system-fragments/baseagent.md +1 -1
  169. package/kits/templates/system-fragments/bootstrap.md +26 -9
  170. package/kits/templates/system-fragments/channel.md +8 -44
  171. package/kits/templates/system-fragments/commands.md +10 -2
  172. package/kits/templates/system-fragments/group-unread-history.md +7 -0
  173. package/kits/templates/system-fragments/reply.md +56 -0
  174. package/package.json +7 -3
  175. package/dist/aun/group-identity.js +0 -9
  176. /package/dist/aun/{group-fs-download.js → group/fs-download.js} +0 -0
  177. /package/dist/aun/{msg/group-index.js → group/index-rpc.js} +0 -0
package/dist/ipc.js CHANGED
@@ -5,13 +5,14 @@ import fs from 'fs';
5
5
  import crypto from 'crypto';
6
6
  import os from 'os';
7
7
  import path from 'path';
8
+ import { execFile } from 'node:child_process';
8
9
  import { logger } from './utils/logger.js';
9
10
  import { withMenuProcessingTime, logMenuRequestCompleted, logMenuRequestReceived } from './core/command/menu-protocol.js';
10
11
  import { fileCache } from './core/daemon-file-cache.js';
11
12
  import { DAEMON_RUNTIME_EPOCH_ENV } from './cli/task-context.js';
12
13
  import { HANDOFF_QUERY_MAX_LIMIT, HANDOFF_STATES } from './core/handoff/types.js';
13
14
  import { AgentReloadBusyError } from './core/agent-reload-coordinator.js';
14
- import { getWindowsInstanceSocketPathCandidates, normalizeIpcEndpoint, resolvePaths } from './paths.js';
15
+ import { getPackageRoot, getWindowsInstanceSocketPathCandidates, normalizeIpcEndpoint, resolvePaths } from './paths.js';
15
16
  import { getProcessStartTime, isSameOrOlderProcess } from './utils/process-introspect.js';
16
17
  import { classifyProcessTree, ProcessTreeSampler, readProcessMetrics } from './utils/process-tree-stats.js';
17
18
  import { readSystemMemoryUsage } from './utils/system-memory.js';
@@ -73,10 +74,42 @@ function nextIpcQueryId(cmd) {
73
74
  return `ipc-${ipcQuerySequence}`;
74
75
  }
75
76
  function requiresLocalControlToken(cmd) {
76
- // Managed bootstrap completion is authenticated by the session delegation
77
- // ticket. A standalone CLI invocation still needs the daemon control token.
78
- return LOCAL_CONTROL_COMMANDS.has(String(cmd.type ?? ''))
79
- || ((cmd.type === 'evolagent.bootstrapComplete' || cmd.type === 'diag') && typeof cmd.sessionId !== 'string');
77
+ // Managed calls use task delegation. Standalone queries must not gain
78
+ // management scope merely by omitting (or emptying) sessionId.
79
+ return cmd.type === 'evolagent.initialize' || LOCAL_CONTROL_COMMANDS.has(String(cmd.type ?? ''))
80
+ || (['evolagent.bootstrapComplete', 'diag', 'handoff-status', 'handoff-list', 'handoff-trace', 'task.resume'].includes(String(cmd.type))
81
+ && !(typeof cmd.sessionId === 'string' && cmd.sessionId.trim()));
82
+ }
83
+ /** Preserve the pipe DACL and grant only the provisioned Codex users data I/O. */
84
+ function grantWindowsSandboxPipeAccess(endpoint) {
85
+ const powershell = path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
86
+ const request = Buffer.from(JSON.stringify({ action: 'pipe', path: endpoint })).toString('base64');
87
+ return new Promise((resolve, reject) => {
88
+ // Asynchronous: the ACL helper connects as a client, so Node must keep
89
+ // accepting pipe instances while it runs. Never interpolate shell source.
90
+ execFile(powershell, ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass',
91
+ '-File', path.join(getPackageRoot(), 'bin', 'codex-managed-acl.ps1'), '-Request', request], { windowsHide: true, timeout: 15_000, maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
92
+ if (error) {
93
+ reject(new Error(`Windows IPC sandbox ACL setup failed: ${stderr.trim() || error.message}`));
94
+ return;
95
+ }
96
+ try {
97
+ const result = JSON.parse(stdout.replace(/^\uFEFF/, '').trim());
98
+ if (!Array.isArray(result.granted))
99
+ throw new Error('invalid ACL helper response');
100
+ if (result.granted.length) {
101
+ logger.info(`[IPC] Sandbox pipe access granted to ${result.granted.join(', ')}`);
102
+ }
103
+ else {
104
+ logger.info('[IPC] Codex sandbox accounts are not provisioned; restart daemon after Windows sandbox setup');
105
+ }
106
+ resolve();
107
+ }
108
+ catch (parseError) {
109
+ reject(parseError);
110
+ }
111
+ });
112
+ });
80
113
  }
81
114
  export function summarizeMonitorAgents(agents, aids) {
82
115
  const connectedAgents = new Set(aids.filter(aid => aid.status === 'connected').map(aid => aid.agentName || aid.aid));
@@ -102,18 +135,22 @@ export class IpcServer {
102
135
  aunAidStatsRecorder;
103
136
  menuExecutor;
104
137
  agentOperationExecutor;
138
+ initializationExecutor;
105
139
  statsProvider;
106
140
  agentStatsProvider;
107
141
  queueSnapshotProvider;
108
142
  queueActionExecutor;
109
143
  queueOperationExecutor;
110
144
  statusAuthorizationExecutor;
145
+ taskResumeExecutor;
111
146
  storageAuthorizationExecutor;
147
+ storageUploadExecutor;
112
148
  triggerExecutor;
113
149
  bootstrapCompleteExecutor;
114
150
  agentReloadExecutor;
115
151
  shutdownExecutor;
116
152
  taskRuntimeContextProvider;
153
+ taskRuntimeContextAuthorizer;
117
154
  codexPreToolUseExecutor;
118
155
  aunMsgSender;
119
156
  diagExecutor;
@@ -211,6 +248,9 @@ export class IpcServer {
211
248
  setMenuExecutor(executor) {
212
249
  this.menuExecutor = executor;
213
250
  }
251
+ setInitializationExecutor(executor) {
252
+ this.initializationExecutor = executor;
253
+ }
214
254
  setAgentOperationExecutor(executor) {
215
255
  this.agentOperationExecutor = executor;
216
256
  }
@@ -354,9 +394,15 @@ export class IpcServer {
354
394
  setStatusAuthorizationExecutor(executor) {
355
395
  this.statusAuthorizationExecutor = executor;
356
396
  }
397
+ setTaskResumeExecutor(executor) {
398
+ this.taskResumeExecutor = executor;
399
+ }
357
400
  setStorageAuthorizationExecutor(executor) {
358
401
  this.storageAuthorizationExecutor = executor;
359
402
  }
403
+ setStorageUploadExecutor(executor) {
404
+ this.storageUploadExecutor = executor;
405
+ }
360
406
  /** Inject daemon-level trigger executor for ec trigger. */
361
407
  setTriggerExecutor(executor) {
362
408
  this.triggerExecutor = executor;
@@ -369,6 +415,9 @@ export class IpcServer {
369
415
  setTaskRuntimeContextProvider(provider) {
370
416
  this.taskRuntimeContextProvider = provider;
371
417
  }
418
+ setTaskRuntimeContextAuthorizer(authorizer) {
419
+ this.taskRuntimeContextAuthorizer = authorizer;
420
+ }
372
421
  setCodexPreToolUseExecutor(executor) {
373
422
  this.codexPreToolUseExecutor = executor;
374
423
  }
@@ -792,8 +841,17 @@ export class IpcServer {
792
841
  }
793
842
  catch { }
794
843
  }
795
- logger.info(`[IPC] Listening on ${this.socketPath}`);
796
- resolve();
844
+ const permissionsReady = isNamedPipe(this.socketPath)
845
+ ? grantWindowsSandboxPipeAccess(this.socketPath)
846
+ : Promise.resolve();
847
+ void permissionsReady.then(() => {
848
+ logger.info(`[IPC] Listening on ${this.socketPath}`);
849
+ resolve();
850
+ }, error => {
851
+ this.stop();
852
+ logger.error('[IPC] Unable to configure pipe permissions:', error);
853
+ reject(error);
854
+ });
797
855
  });
798
856
  });
799
857
  }
@@ -814,11 +872,10 @@ export class IpcServer {
814
872
  if (requiresLocalControlToken(cmd) && !this.hasValidControlToken(cmd.controlToken)) {
815
873
  return { ok: false, code: 'INVALID_CONTROL_TOKEN', error: 'valid local control token is required' };
816
874
  }
817
- if (typeof cmd.sessionId === 'string' && cmd.sessionId
818
- && typeof cmd.delegationToken === 'string' && cmd.delegationToken
875
+ if (typeof cmd.delegationToken === 'string' && cmd.delegationToken
819
876
  && this.daemonRuntimeEpoch
820
877
  && cmd.daemonRuntimeEpoch !== this.daemonRuntimeEpoch) {
821
- logger.warn(`[IPC] stale delegation rejected: session=${ipcLogToken(cmd.sessionId)} type=${ipcLogToken(cmd.type)} cause=daemon_runtime_epoch_mismatch`);
878
+ logger.warn(`[IPC] stale delegation rejected: session=${ipcLogToken(cmd.sessionId ?? cmd.originSessionId ?? cmd.actorSessionId)} type=${ipcLogToken(cmd.type)} cause=daemon_runtime_epoch_mismatch`);
822
879
  return {
823
880
  ok: false,
824
881
  code: 'DAEMON_RESTARTED',
@@ -910,16 +967,21 @@ export class IpcServer {
910
967
  });
911
968
  }
912
969
  case 'remote-auth.pair-code': {
970
+ // IPC issues local codes. Owner-authenticated /pair and Menu paths
971
+ // supply provenance in-process, never from a caller-supplied source.
972
+ if (cmd.source !== undefined && cmd.source !== 'host-cli' && cmd.source !== 'ecweb-local') {
973
+ return { ok: false, code: 'INVALID_ARGUMENT', error: 'invalid local pairing source' };
974
+ }
913
975
  const requestedOwner = typeof cmd.authorizedBy === 'string' ? cmd.authorizedBy.trim() : undefined;
914
976
  const authorizedBy = requestedOwner || this.remoteAccessOwnerProvider?.();
915
- const pair = this.remoteAccessService.getPairingCode(authorizedBy);
977
+ const pair = this.remoteAccessService.getPairingCode(authorizedBy, Date.now(), cmd.source ?? 'host-cli');
916
978
  return { ok: true, ...pair };
917
979
  }
918
980
  case 'remote-auth.issue-local': {
919
981
  return this.remoteAccessService.issueLocalToken(cmd.label);
920
982
  }
921
983
  case 'remote-auth.redeem': {
922
- return this.remoteAccessService.redeemPairingCode(cmd.code, cmd.label, cmd.authorizedBy);
984
+ return this.remoteAccessService.redeemPairingCode(cmd.code, cmd.label);
923
985
  }
924
986
  case 'remote-auth.validate': {
925
987
  return { ok: true, ...this.remoteAccessService.validateToken(cmd.token) };
@@ -1093,6 +1155,25 @@ export class IpcServer {
1093
1155
  delegationCommandHash: typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined,
1094
1156
  });
1095
1157
  }
1158
+ case 'storage.upload': {
1159
+ if (!this.storageUploadExecutor)
1160
+ return { ok: false, code: 'NOT_CONFIGURED', error: 'storage upload not configured' };
1161
+ if (typeof cmd.sessionId !== 'string' || !cmd.sessionId
1162
+ || typeof cmd.aid !== 'string' || !cmd.aid
1163
+ || typeof cmd.localFile !== 'string' || !cmd.localFile
1164
+ || typeof cmd.remotePath !== 'string' || !cmd.remotePath) {
1165
+ return { ok: false, code: 'INVALID_REQUEST', error: 'missing sessionId, aid, localFile, or remotePath' };
1166
+ }
1167
+ return await this.storageUploadExecutor({
1168
+ sessionId: cmd.sessionId,
1169
+ aid: cmd.aid,
1170
+ localFile: cmd.localFile,
1171
+ remotePath: cmd.remotePath,
1172
+ isPublic: cmd.isPublic === true,
1173
+ delegationToken: typeof cmd.delegationToken === 'string' ? cmd.delegationToken : undefined,
1174
+ delegationCommandHash: typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined,
1175
+ });
1176
+ }
1096
1177
  case 'aun-aid-stats-record-outbound': {
1097
1178
  if (!this.aunAidStatsRecorder)
1098
1179
  return { ok: false, error: 'recorder not configured' };
@@ -1110,11 +1191,47 @@ export class IpcServer {
1110
1191
  return { ok: false, error: String(e?.message || e) };
1111
1192
  }
1112
1193
  }
1194
+ case 'task.resume': {
1195
+ const allowed = new Set(['type', 'targetSessionId', 'sessionId', 'delegationToken',
1196
+ 'delegationCommandHash', 'controlToken', 'daemonRuntimeEpoch', 'requestId', 'id']);
1197
+ if (Object.keys(cmd).some(key => !allowed.has(key))
1198
+ || typeof cmd.targetSessionId !== 'string' || !cmd.targetSessionId.trim()
1199
+ || (cmd.sessionId !== undefined && (typeof cmd.sessionId !== 'string' || !cmd.sessionId.trim()))) {
1200
+ return { ok: false, code: 'INVALID_REQUEST', error: 'task.resume accepts only a target session and caller credentials' };
1201
+ }
1202
+ if (cmd.sessionId && (typeof cmd.delegationToken !== 'string' || !cmd.delegationToken)) {
1203
+ return { ok: false, code: 'DELEGATION_REQUIRED', error: 'managed task resume requires a delegation token' };
1204
+ }
1205
+ if (!this.taskResumeExecutor)
1206
+ return { ok: false, code: 'NOT_CONFIGURED', error: 'task.resume not configured' };
1207
+ try {
1208
+ return await this.taskResumeExecutor({
1209
+ targetSessionId: cmd.targetSessionId,
1210
+ sessionId: cmd.sessionId,
1211
+ delegationToken: typeof cmd.delegationToken === 'string' ? cmd.delegationToken : undefined,
1212
+ delegationCommandHash: typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined,
1213
+ localControl: !cmd.sessionId && this.hasValidControlToken(cmd.controlToken),
1214
+ });
1215
+ }
1216
+ catch (error) {
1217
+ return { ok: false, code: 'TASK_RESUME_FAILED', error: error instanceof Error ? error.message : String(error) };
1218
+ }
1219
+ }
1113
1220
  case 'task-runtime-context': {
1114
1221
  if (!this.taskRuntimeContextProvider)
1115
1222
  return { ok: false, error: 'task runtime context not configured' };
1116
1223
  if (!cmd.sessionId || typeof cmd.sessionId !== 'string')
1117
1224
  return { ok: false, error: 'missing sessionId' };
1225
+ if (!this.taskRuntimeContextAuthorizer) {
1226
+ return { ok: false, code: 'DELEGATION_REQUIRED', error: 'task runtime context authorization is not configured' };
1227
+ }
1228
+ const authorization = this.taskRuntimeContextAuthorizer({
1229
+ sessionId: cmd.sessionId,
1230
+ delegationToken: typeof cmd.delegationToken === 'string' ? cmd.delegationToken : undefined,
1231
+ delegationCommandHash: typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined,
1232
+ });
1233
+ if (!authorization.ok)
1234
+ return authorization;
1118
1235
  const context = this.taskRuntimeContextProvider({ sessionId: cmd.sessionId }) ?? null;
1119
1236
  return { ok: true, context };
1120
1237
  }
@@ -1361,6 +1478,13 @@ export class IpcServer {
1361
1478
  }
1362
1479
  return await this.fsOperationExecutor(argv, sessionId, delegationToken, typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined);
1363
1480
  }
1481
+ case 'evolagent.initialize': {
1482
+ if (cmd.sessionId || cmd.delegationToken)
1483
+ return { ok: false, code: 'NOT_ALLOWED', error: 'Managed callers must use agent.op' };
1484
+ if (!this.initializationExecutor)
1485
+ return { ok: false, code: 'NOT_CONFIGURED', error: 'Initialization service unavailable' };
1486
+ return this.initializationExecutor(cmd);
1487
+ }
1364
1488
  case 'agent.op': {
1365
1489
  if (!this.agentOperationExecutor)
1366
1490
  return { ok: false, code: 'NOT_CONFIGURED', error: 'agent.op not configured' };
@@ -1428,12 +1552,13 @@ export class IpcServer {
1428
1552
  if (!this.bootstrapCompleteExecutor)
1429
1553
  return { ok: false, error: 'bootstrap complete executor not configured' };
1430
1554
  try {
1431
- return await this.bootstrapCompleteExecutor(aid, {
1555
+ const auth = {
1432
1556
  sessionId: typeof cmd.sessionId === 'string' ? cmd.sessionId : undefined,
1433
1557
  delegationToken: typeof cmd.delegationToken === 'string' ? cmd.delegationToken : undefined,
1434
1558
  delegationCommandHash: typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined,
1435
1559
  controlToken: typeof cmd.controlToken === 'string' ? cmd.controlToken : undefined,
1436
- });
1560
+ };
1561
+ return await this.bootstrapCompleteExecutor(aid, auth);
1437
1562
  }
1438
1563
  catch (e) {
1439
1564
  return { ok: false, error: e?.message || String(e) };
@@ -1600,7 +1725,7 @@ export class IpcTransportError extends Error {
1600
1725
  endpoint;
1601
1726
  constructor(code, endpoint) {
1602
1727
  const hint = code === 'EPERM' || code === 'EACCES'
1603
- ? '权限被拒绝;Windows 下请检查 daemon 与 CLI 是否使用相同用户和提升权限级别。'
1728
+ ? '权限被拒绝;请检查 IPC 端点权限及沙箱隔离。Windows 下同用户进程也可能因受限令牌无法连接命名管道。'
1604
1729
  : code === 'ETIMEDOUT'
1605
1730
  ? '等待 daemon 响应超时;请求可能已执行,请先检查状态再重试。'
1606
1731
  : code === 'ENOENT' || code === 'ECONNREFUSED'
@@ -1671,6 +1796,7 @@ function ipcQueryOnce(socketPath, cmd, timeoutMs = 3000) {
1671
1796
  const request = {
1672
1797
  ...(delegationCommandHash ? { ...authenticatedCmd, delegationCommandHash } : authenticatedCmd),
1673
1798
  ...(process.env[DAEMON_RUNTIME_EPOCH_ENV]
1799
+ && authenticatedCmd.daemonRuntimeEpoch === undefined
1674
1800
  && typeof authenticatedCmd.delegationToken === 'string'
1675
1801
  ? { daemonRuntimeEpoch: process.env[DAEMON_RUNTIME_EPOCH_ENV] }
1676
1802
  : {}),
package/dist/paths.js CHANGED
@@ -72,11 +72,11 @@ export function aunPath() {
72
72
  export function aidsDir() {
73
73
  return path.join(resolveRoot(), 'AIDs');
74
74
  }
75
- export function aidLocalDir(aid) {
76
- return path.join(resolveRoot(), 'AIDs', aid);
75
+ export function aidLocalDir(aid, root = resolveRoot()) {
76
+ return path.join(root, 'AIDs', aid);
77
77
  }
78
- export function agentMdPath(aid) {
79
- return path.join(resolveRoot(), 'AIDs', aid, 'agent.md');
78
+ export function agentMdPath(aid, root = resolveRoot()) {
79
+ return path.join(root, 'AIDs', aid, 'agent.md');
80
80
  }
81
81
  // ── per-agent 路径(参数化,不进 resolvePaths() 的固定 map)──
82
82
  export function agentDir(aid) {
@@ -94,6 +94,10 @@ export function agentContactOperations(aid) {
94
94
  export function agentPersonalDir(aid) {
95
95
  return path.join(agentDir(aid), 'personal');
96
96
  }
97
+ /** Agent-owned Bootstrap completion welcome template. */
98
+ export function agentWelcomePath(aid) {
99
+ return path.join(agentPersonalDir(aid), 'welcome.md');
100
+ }
97
101
  export function agentRolesDir(aid) {
98
102
  return path.join(agentDir(aid), 'roles');
99
103
  }
@@ -106,6 +110,12 @@ export function agentRoleConfig(aid, roleId) {
106
110
  export function agentRelationsDir(aid) {
107
111
  return path.join(agentDir(aid), 'relations');
108
112
  }
113
+ export function agentRelationDir(aid, peerKey) {
114
+ return path.join(agentRelationsDir(aid), peerKey);
115
+ }
116
+ export function agentRelationSharedDir(aid, peerKey) {
117
+ return path.join(agentRelationDir(aid, peerKey), 'shared');
118
+ }
109
119
  /** @deprecated Use agentRelationsDir instead */
110
120
  export function agentIdentitiesDir(aid) {
111
121
  return agentRelationsDir(aid);
@@ -128,6 +138,9 @@ export function agentDataCacheDir(aid) {
128
138
  export function agentHandoffDir(aid) {
129
139
  return path.join(agentDataDir(aid), 'handoff');
130
140
  }
141
+ export function agentGroupInviteReviewsPath(aid) {
142
+ return path.join(agentDataDir(aid), 'aun', 'group-invite-reviews.json');
143
+ }
131
144
  export function agentOutboxPath(aid) {
132
145
  return path.join(resolvePaths().outboxDir, encodeURIComponent(aid), 'outbox.jsonl');
133
146
  }
package/dist/product.js CHANGED
@@ -14,6 +14,9 @@ export const MIN_ECWEB_VERSION = '0.0.8';
14
14
  export const DAEMON_CONFIG_FILENAME = 'daemon.json';
15
15
  export const DAEMON_SCHEMA_NAME = 'daemon';
16
16
  export const RUNTIME_HOME_ENV = 'EVOLCORE_HOME';
17
+ export const TARGET_PACKAGE_ROOT_ENV = 'EVOLCORE_TARGET_PACKAGE_ROOT';
18
+ export const SESSION_ID_ENV = 'EVOLCORE_SESSION_ID';
19
+ export const SELF_AID_ENV = 'EVOLCORE_SELF_AID';
17
20
  export const DEFAULT_RUNTIME_HOME_DIRNAME = '.evolcore';
18
21
  export const INSTANCE_SOCKET_FILENAME = 'daemon.sock';
19
22
  export const WINDOWS_PIPE_PREFIX = 'daemon';
@@ -1,4 +1,8 @@
1
1
  import { logger } from '../utils/logger.js';
2
+ export function isDaemonEventSessionTrigger(trigger) {
3
+ return trigger.feedback.strategy === 'event_session'
4
+ && (trigger.origin?.channelKey === 'daemon' || trigger.origin?.channelType === 'daemon');
5
+ }
2
6
  /** Match a real or simulated event without publishing it to the event bus. */
3
7
  export function matchTriggerEvent(source, event) {
4
8
  if (typeof event.type !== 'string' || !event.type.trim()) {
@@ -34,6 +38,21 @@ export class TriggerEventSource {
34
38
  return;
35
39
  if (event.type.startsWith('trigger:') && event.originTriggerId === trigger.id)
36
40
  return;
41
+ // Dynamic routing is agent-local for ordinary Agent Triggers. A
42
+ // daemon-origin event_session Trigger is explicitly allowed to route
43
+ // the event to the owning Agent discovered from the payload.
44
+ if (trigger.feedback.strategy === 'event_session') {
45
+ const payload = event;
46
+ const daemonScoped = isDaemonEventSessionTrigger(trigger);
47
+ if (daemonScoped && event.type === 'task:error' && payload.originTriggerId === trigger.id)
48
+ return;
49
+ if (typeof payload.agentAid !== 'string' || !payload.agentAid.trim()
50
+ || (!daemonScoped && payload.agentAid !== trigger.agentAid)
51
+ || typeof payload.sessionId !== 'string' || !payload.sessionId)
52
+ return;
53
+ }
54
+ if (event.causation?.trigger?.path.some(node => node.triggerId === trigger.id))
55
+ return;
37
56
  if (!matchTriggerEvent({ type: 'event', eventPattern, ...(filter ? { filter } : {}) }, event).matched)
38
57
  return;
39
58
  this.fire(trigger.id, {