evolcore 0.0.49 → 0.0.50

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 (250) hide show
  1. package/CHANGELOG.md +64 -1
  2. package/bin/ecmsg.js +9 -4
  3. package/dist/ability/caller/authorization.js +21 -0
  4. package/dist/ability/caller/command.js +164 -0
  5. package/dist/ability/caller/contract.js +102 -0
  6. package/dist/ability/caller/daemon.js +158 -0
  7. package/dist/ability/caller/service.js +380 -0
  8. package/dist/ability/command-contract.js +5 -0
  9. package/dist/ability/daemon.js +5 -1
  10. package/dist/ability/interop-v1.js +10 -3
  11. package/dist/ability/management.js +1 -0
  12. package/dist/agent-template/jobs.js +173 -1
  13. package/dist/agent-template/runtime.js +280 -6
  14. package/dist/agent-template/service.js +1159 -40
  15. package/dist/agent-template/types.js +2 -1
  16. package/dist/agents/baseagent-availability.js +27 -3
  17. package/dist/agents/baseagent-capability-adapter.js +102 -0
  18. package/dist/agents/baseagent-plugin-descriptor.js +274 -0
  19. package/dist/agents/baseagent-plugin-loader.js +145 -0
  20. package/dist/agents/baseagent.js +68 -2
  21. package/dist/agents/claude-gateway/agent-registration.js +389 -0
  22. package/dist/agents/claude-gateway/binding.js +96 -0
  23. package/dist/agents/claude-gateway/inbox.js +138 -0
  24. package/dist/agents/claude-gateway/index.js +125 -0
  25. package/dist/agents/claude-gateway/listing.js +330 -0
  26. package/dist/agents/claude-gateway/router.js +328 -0
  27. package/dist/agents/claude-gateway/sessions.js +128 -0
  28. package/dist/agents/claude-gateway/terminal.js +250 -0
  29. package/dist/agents/claude-gateway/transcript.js +272 -0
  30. package/dist/agents/claude-gateway/types.js +14 -0
  31. package/dist/agents/claude-runner.js +6 -10
  32. package/dist/agents/codex-runner.js +4 -1
  33. package/dist/agents/{gemini-runner.js → gemini/gemini-runner.js} +17 -17
  34. package/dist/{core/session/adapters → agents/gemini}/gemini-session-file-adapter.js +2 -2
  35. package/dist/agents/gemini/index.js +51 -0
  36. package/dist/aun/aid/control-aid.js +52 -32
  37. package/dist/aun/group/invite-service.js +6 -36
  38. package/dist/aun/group/operations.js +6 -0
  39. package/dist/aun/msg/mention-schema.js +1 -1
  40. package/dist/aun/msg/p2p.js +29 -1
  41. package/dist/aun/msg/upload.js +126 -3
  42. package/dist/build-identity.json +1 -1
  43. package/dist/channels/aun.js +537 -189
  44. package/dist/cli/ability-command.js +42 -0
  45. package/dist/cli/agent-command.js +20 -1
  46. package/dist/cli/agent-create.js +78 -18
  47. package/dist/cli/agent-template.js +5 -3
  48. package/dist/cli/agent.js +91 -0
  49. package/dist/cli/aun-commands.js +92 -34
  50. package/dist/cli/bench.js +5 -2
  51. package/dist/cli/config.js +22 -6
  52. package/dist/cli/daemon-commands.js +245 -101
  53. package/dist/cli/ecmsg-gateway.js +11 -9
  54. package/dist/cli/index.js +23 -4
  55. package/dist/cli/init.js +39 -63
  56. package/dist/cli/managed-command-guard.js +1 -0
  57. package/dist/cli/menu-client.js +32 -7
  58. package/dist/cli/pay-command.js +30 -0
  59. package/dist/cli/provider-command.js +6 -2
  60. package/dist/cli/restart-monitor.js +2 -2
  61. package/dist/cli/services-command.js +11 -9
  62. package/dist/cli/thread-command.js +78 -12
  63. package/dist/config/access-policy.js +16 -3
  64. package/dist/config/config-field-policy.js +17 -8
  65. package/dist/config/config-manager.js +86 -46
  66. package/dist/config/config-operation-service.js +22 -1
  67. package/dist/config/gateway-config.js +9 -8
  68. package/dist/config/owner-config.js +0 -16
  69. package/dist/config/peer-role-resolver.js +1 -7
  70. package/dist/config/providers-config.js +99 -16
  71. package/dist/config/providers-management.js +35 -19
  72. package/dist/config/resolved-config-op.js +1 -42
  73. package/dist/config/schema-migration.js +78 -5
  74. package/dist/config/schema-registry.js +52 -7
  75. package/dist/config-store.js +1309 -17
  76. package/dist/core/agent-application-service.js +220 -1
  77. package/dist/core/agent-ipc-registration.js +19 -2
  78. package/dist/core/agent-reload-coordinator.js +5 -0
  79. package/dist/core/agent-runtime.js +198 -54
  80. package/dist/core/auth/agent-delegation.js +14 -0
  81. package/dist/core/auth/operation-authorizer.js +16 -1
  82. package/dist/core/auth/operation-catalog.js +50 -7
  83. package/dist/core/baseagent-loader.js +30 -3
  84. package/dist/core/capability/capability-manager.js +16 -7
  85. package/dist/core/channel-runtime.js +4 -2
  86. package/dist/core/command/agent-control.js +20 -2
  87. package/dist/core/command/agent-template-menu.js +4 -3
  88. package/dist/core/command/cli-intent-parser.js +15 -0
  89. package/dist/core/command/menu-catalog.js +20 -4
  90. package/dist/core/command/menu-file-path.js +70 -0
  91. package/dist/core/command/menu-handler.js +91 -72
  92. package/dist/core/command/menu-protocol.js +5 -0
  93. package/dist/core/command/menu-query-batch.js +2 -2
  94. package/dist/core/command/private-mention-menu.js +71 -0
  95. package/dist/core/command/slash-handler.js +17 -26
  96. package/dist/core/command/team-workspace-bootstrap.js +2 -1
  97. package/dist/core/command/topic-slash.js +7 -1
  98. package/dist/core/daemon-bootstrap.js +0 -4
  99. package/dist/core/daemon-control.js +2 -1
  100. package/dist/core/daemon-lifecycle.js +13 -5
  101. package/dist/core/evolagent-registry.js +12 -7
  102. package/dist/core/handoff/runtime.js +1 -1
  103. package/dist/core/host-snapshot.js +8 -3
  104. package/dist/core/initialization/service.js +3 -0
  105. package/dist/core/interaction-router.js +130 -0
  106. package/dist/core/ipc-registration.js +4 -0
  107. package/dist/core/memory/consolidation-context.js +2 -1
  108. package/dist/core/memory/consolidation.js +35 -64
  109. package/dist/core/message/aun-ipc-sender.js +98 -21
  110. package/dist/core/message/aun-request-registry.js +31 -0
  111. package/dist/core/message/message-bridge.js +105 -6
  112. package/dist/core/message/message-log.js +8 -0
  113. package/dist/core/message/message-queue.js +5 -3
  114. package/dist/core/message/peer-mode.js +15 -4
  115. package/dist/core/message/response-engine.js +23 -8
  116. package/dist/core/message/send-options.js +37 -3
  117. package/dist/core/message/send-routing.js +11 -7
  118. package/dist/core/model/model-catalog.js +5 -5
  119. package/dist/core/ownership/owner-resolver.js +12 -86
  120. package/dist/core/pack-auth.js +4 -0
  121. package/dist/core/permission/ec-command-parser.js +182 -58
  122. package/dist/core/permission/protected-paths.js +64 -9
  123. package/dist/core/permission/services-path-acl.js +9 -2
  124. package/dist/core/permission/tool-policy.js +21 -9
  125. package/dist/core/session/adapters/claude-session-file-adapter.js +6 -2
  126. package/dist/core/session/adapters/codex-session-file-adapter.js +4 -0
  127. package/dist/core/session/session-manager.js +47 -10
  128. package/dist/core/session/session-mapper.js +16 -0
  129. package/dist/core/skill/index-generator.js +2 -3
  130. package/dist/core/skill/switch-resolver.js +3 -0
  131. package/dist/core/thread/command-parser.js +4 -1
  132. package/dist/core/thread/ipc-operation.js +4 -2
  133. package/dist/core/thread/thread-operation.js +25 -10
  134. package/dist/core/thread/thread-service.js +294 -55
  135. package/dist/core/thread/topic-id.js +52 -2
  136. package/dist/core/thread/types.js +15 -1
  137. package/dist/eck/kit-renderer.js +2 -1
  138. package/dist/ecweb/basic-settings-service.js +5 -9
  139. package/dist/ecweb/providers-service.js +4 -2
  140. package/dist/index.js +116 -41
  141. package/dist/ipc.js +58 -2
  142. package/dist/paths.js +48 -1
  143. package/dist/pay/command.js +38 -0
  144. package/dist/pay/protocol.js +136 -0
  145. package/dist/pay/runtime.js +188 -0
  146. package/dist/pay/service.js +384 -0
  147. package/dist/pay/store.js +81 -0
  148. package/dist/response-system/engines/v1/proactive-flow.js +29 -2
  149. package/dist/services/dispatcher.js +23 -5
  150. package/dist/services/host/main.js +388 -0
  151. package/dist/services/host/protocol.js +118 -0
  152. package/dist/services/host/resident.js +310 -0
  153. package/dist/services/host-client.js +386 -0
  154. package/dist/services/host-deploy.js +180 -0
  155. package/dist/services/host-launch.js +117 -0
  156. package/dist/services/host-recycle.js +203 -0
  157. package/dist/services/host-runtime.js +802 -0
  158. package/dist/services/idempotency.js +44 -86
  159. package/dist/services/index-generator.js +4 -3
  160. package/dist/services/index.js +176 -18
  161. package/dist/services/ipc-operation.js +204 -44
  162. package/dist/services/script-runner.js +515 -83
  163. package/dist/services/validation.js +109 -4
  164. package/dist/trigger/application-service.js +6 -4
  165. package/dist/trigger/local-files.js +19 -9
  166. package/dist/trigger/scheduler.js +22 -12
  167. package/dist/trigger/script-sandbox.js +51 -20
  168. package/dist/utils/aid-bind.js +3 -0
  169. package/dist/utils/evolcore-version.js +2 -2
  170. package/dist/utils/host-info.js +73 -0
  171. package/dist/utils/logger.js +2 -2
  172. package/dist/utils/media-cache.js +190 -43
  173. package/dist/utils/restart-safety.js +14 -1
  174. package/dist/utils/system-memory.js +113 -25
  175. package/dist/utils/systemd-lifecycle.js +154 -0
  176. package/dist/utils/windows-shell-trust.js +7 -3
  177. package/kits/docs/INDEX.md +3 -2
  178. package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
  179. package/kits/docs/channels/aun.md +1 -1
  180. package/kits/docs/evolcore/INDEX.md +7 -6
  181. package/kits/docs/evolcore/agent.md +36 -1
  182. package/kits/docs/evolcore/aid.md +20 -3
  183. package/kits/docs/evolcore/config.md +1 -1
  184. package/kits/docs/evolcore/group.md +2 -1
  185. package/kits/docs/evolcore/memory-tags.md +2 -0
  186. package/kits/docs/evolcore/menu-client.md +3 -3
  187. package/kits/docs/evolcore/menu-protocol.md +7 -0
  188. package/kits/docs/evolcore/model.md +3 -0
  189. package/kits/docs/evolcore/msg.md +68 -10
  190. package/kits/docs/evolcore/pay.md +34 -0
  191. package/kits/docs/evolcore/provider.md +21 -0
  192. package/kits/docs/evolcore/services.md +46 -18
  193. package/kits/docs/evolcore/thread-chain.md +2 -0
  194. package/kits/docs/evolcore/tool-authorization.md +10 -0
  195. package/kits/rules/01-overview.md +11 -32
  196. package/kits/rules/02-navigation.md +7 -0
  197. package/kits/rules/06-channel.md +3 -3
  198. package/kits/schemas/_meta.json +38 -5
  199. package/kits/schemas/agent-config.schema.21.json +974 -0
  200. package/kits/schemas/agent-config.schema.22.json +977 -0
  201. package/kits/schemas/agent-config.schema.23.json +958 -0
  202. package/kits/schemas/daemon.schema.10.json +373 -0
  203. package/kits/schemas/daemon.schema.9.json +12 -0
  204. package/kits/schemas/defaults.schema.7.json +472 -0
  205. package/kits/schemas/providers.schema.3.json +18 -2
  206. package/kits/schemas/relation-config.schema.13.json +289 -0
  207. package/kits/skills/.switches.json +13 -1
  208. package/kits/skills/ability/SKILL.md +229 -34
  209. package/kits/skills/ability/STRUCTURE.md +333 -0
  210. package/kits/skills/ability/references/cli.md +208 -0
  211. package/kits/skills/ability/references/development.md +107 -37
  212. package/kits/skills/ability/references/management.md +106 -46
  213. package/kits/skills/ability/references/runtime-protocol.md +65 -63
  214. package/kits/skills/agent-output-cards/SKILL.md +12 -5
  215. package/kits/skills/ec-group/SKILL.md +8 -6
  216. package/kits/skills/ec-group/TASK.md +186 -0
  217. package/kits/skills/ec-group/WORKLOG.md +180 -0
  218. package/kits/skills/ec-group-collaboration/SKILL.md +3 -3
  219. package/kits/skills/ec-pay/SKILL.md +101 -0
  220. package/kits/skills/ec-pay/references/pay-cli.md +110 -0
  221. package/kits/skills/ec-provider/SKILL.md +1 -1
  222. package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
  223. package/kits/skills/ec-service-call/SKILL.md +135 -0
  224. package/kits/skills/ec-service-pack/SKILL.md +277 -0
  225. package/kits/skills/ec-trigger/SKILL.md +1 -1
  226. package/kits/templates/memory-consolidation/notes.md +2 -2
  227. package/kits/templates/memory-consolidation/workflow.md +46 -0
  228. package/kits/templates/system-fragments/channel.md +13 -4
  229. package/kits/templates/system-fragments/commands.md +4 -3
  230. package/kits/templates/system-fragments/reply.md +1 -0
  231. package/kits/templates/system-fragments/session.md +1 -1
  232. package/kits/templates/system-fragments/thread.md +27 -129
  233. package/kits/templates/system-fragments/venue.md +16 -0
  234. package/package.json +4 -5
  235. package/scripts/agent-template/inspect.mjs +37 -23
  236. package/scripts/agent-template/overlay.mjs +20 -2
  237. package/scripts/agent-template/shared/common.mjs +16 -4
  238. package/scripts/agent-template/shared/team-schema.json +20 -4
  239. package/scripts/agent-template/shared/template-contract.mjs +53 -13
  240. package/scripts/agent-template/shared/template-package.mjs +90 -26
  241. package/scripts/agent-template/shared/template-runtime.mjs +111 -1
  242. package/scripts/agent-template/shared/template.mjs +65 -7
  243. package/scripts/agent-template/team-pack.mjs +89 -33
  244. package/scripts/agent-template/team-preview.mjs +249 -5
  245. package/kits/docs/aun/ABILITY_CALLING.md +0 -280
  246. package/kits/docs/evolcore/ability.md +0 -185
  247. package/kits/skills/ability/references/calling.md +0 -56
  248. package/kits/skills/ability/references/contract-checklist.md +0 -37
  249. package/kits/skills/ability/references/recovery.md +0 -27
  250. /package/dist/{core/capability/providers → agents/gemini}/gemini-capability-provider.js +0 -0
@@ -27,7 +27,22 @@ function runtimeForExtension(script) {
27
27
  }
28
28
  const TIMEOUT_MIN = 1000;
29
29
  const TIMEOUT_MAX = 300_000;
30
- const TIMEOUT_DEFAULT = 30_000;
30
+ /**
31
+ * handler.name / handler.description 的长度上限。
32
+ *
33
+ * 比包级 `description`(200)更严:这两个字段会进 `services.skill` 的渲染文本,
34
+ * 而 skill 是给**另一个 Agent 读的**。一个包有 10 个 type 时,每个 200 字就是
35
+ * 2000 字噪音。收紧到 24 / 120,并配合 skill 渲染时的单行截断。
36
+ */
37
+ export const HANDLER_NAME_MAX = 24;
38
+ export const HANDLER_DESCRIPTION_MAX = 120;
39
+ /**
40
+ * 脚本默认超时。必须**短于**调用方的等待期(`SERVICE_CALL_TIMEOUT_MS`,12 秒),
41
+ * 否则脚本的默认执行窗口比调用方愿意等的时间还长:每次都必然白跑,
42
+ * 调用方只看到 NO_RESULT 而服务端还在跑。
43
+ */
44
+ export const DEFAULT_HANDLER_TIMEOUT_MS = 10_000;
45
+ const TIMEOUT_DEFAULT = DEFAULT_HANDLER_TIMEOUT_MS;
31
46
  const QUOTA_DEFAULT_BUILTIN = { perMinute: 20, perHour: 200 };
32
47
  const QUOTA_DEFAULT_SERVICE = { perMinute: 50, perHour: 1000 };
33
48
  function isRecord(value) {
@@ -44,6 +59,20 @@ function optionalString(value, field, errors, max) {
44
59
  errors.push(`${field} is too long (max ${max})`);
45
60
  return value;
46
61
  }
62
+ /**
63
+ * handler 的展示性文本(`name` / `description`)。
64
+ *
65
+ * 与 `optionalString` 的差别只有一点:**纯空白视为未声明**。这两个字段只用于展示,
66
+ * 写一个空串和没写没有任何区别;保留空串反而会让 `describe` 输出里出现
67
+ * `"name": ""`,调用方无法区分「有标题但为空」和「没标题」。
68
+ */
69
+ function optionalLabel(value, field, max, errors) {
70
+ const text = optionalString(value, field, errors, max);
71
+ if (text === undefined)
72
+ return undefined;
73
+ const trimmed = text.trim();
74
+ return trimmed ? trimmed : undefined;
75
+ }
47
76
  function intInRange(value, field, min, max, errors) {
48
77
  if (typeof value !== 'number' || !Number.isInteger(value) || value < min || value > max) {
49
78
  errors.push(`${field} must be an integer between ${min} and ${max}`);
@@ -118,10 +147,12 @@ function validateHandler(raw, errors) {
118
147
  errors.push('listen[].handler must be an object');
119
148
  return undefined;
120
149
  }
121
- const extra = Object.keys(raw).filter(key => !['script', 'runtime', 'args', 'timeoutMs'].includes(key));
150
+ const extra = Object.keys(raw).filter(key => !['script', 'runtime', 'args', 'timeoutMs', 'name', 'description', 'mode', 'resident'].includes(key));
122
151
  if (extra.length)
123
152
  errors.push(`listen[].handler has unknown fields: ${extra.join(', ')}`);
124
153
  const script = validateScriptPath(raw.script, errors);
154
+ const name = optionalLabel(raw.name, 'listen[].handler.name', HANDLER_NAME_MAX, errors);
155
+ const description = optionalLabel(raw.description, 'listen[].handler.description', HANDLER_DESCRIPTION_MAX, errors);
125
156
  if (raw.runtime !== undefined && !RUNTIME_WHITELIST.includes(raw.runtime)) {
126
157
  errors.push(`listen[].handler.runtime must be one of ${RUNTIME_WHITELIST.join('/')}`);
127
158
  }
@@ -140,6 +171,7 @@ function validateHandler(raw, errors) {
140
171
  const timeoutMs = raw.timeoutMs === undefined
141
172
  ? TIMEOUT_DEFAULT
142
173
  : intInRange(raw.timeoutMs, 'listen[].handler.timeoutMs', TIMEOUT_MIN, TIMEOUT_MAX, errors);
174
+ const mode = validateHandlerMode(raw.mode, raw.resident, errors);
143
175
  if (script === undefined)
144
176
  return undefined;
145
177
  return {
@@ -147,6 +179,60 @@ function validateHandler(raw, errors) {
147
179
  ...(raw.runtime !== undefined ? { runtime: raw.runtime } : {}),
148
180
  ...(Array.isArray(raw.args) ? { args: raw.args } : {}),
149
181
  timeoutMs: timeoutMs ?? TIMEOUT_DEFAULT,
182
+ ...(name !== undefined ? { name } : {}),
183
+ ...(description !== undefined ? { description } : {}),
184
+ ...(mode !== undefined ? { mode: mode.mode } : {}),
185
+ ...(mode?.resident ? { resident: mode.resident } : {}),
186
+ };
187
+ }
188
+ /**
189
+ * `handler.mode` / `handler.resident` 校验。
190
+ *
191
+ * `resident` 子对象只在 `mode:"resident"` 时有意义——其他形态下出现就报错,
192
+ * 因为静默忽略会让作者以为调参生效了,而实际写的是个死配置。
193
+ */
194
+ function validateHandlerMode(rawMode, rawResident, errors) {
195
+ if (rawMode !== undefined && rawMode !== 'spawn' && rawMode !== 'resident') {
196
+ errors.push('listen[].handler.mode must be "spawn" or "resident"');
197
+ return undefined;
198
+ }
199
+ // 未声明时**不落默认值**:让"没写"与"显式写 spawn"在输出里可区分——
200
+ // 否则 describe/status 会显示一个用户从未写过的 mode,排查时容易误判。
201
+ const declared = rawMode === 'spawn' || rawMode === 'resident' ? rawMode : undefined;
202
+ const mode = declared ?? 'spawn';
203
+ if (rawResident === undefined)
204
+ return declared ? { mode: declared } : undefined;
205
+ if (mode !== 'resident') {
206
+ errors.push('listen[].handler.resident is only meaningful when handler.mode is "resident"');
207
+ return declared ? { mode: declared } : undefined;
208
+ }
209
+ if (!isRecord(rawResident)) {
210
+ errors.push('listen[].handler.resident must be an object');
211
+ return { mode: declared };
212
+ }
213
+ const extra = Object.keys(rawResident).filter(key => !['startTimeoutMs', 'softTimeoutMs', 'hardTimeoutAfter'].includes(key));
214
+ if (extra.length)
215
+ errors.push(`listen[].handler.resident has unknown fields: ${extra.join(', ')}`);
216
+ const startTimeoutMs = rawResident.startTimeoutMs === undefined
217
+ ? undefined
218
+ : intInRange(rawResident.startTimeoutMs, 'listen[].handler.resident.startTimeoutMs', TIMEOUT_MIN, 120_000, errors);
219
+ const softTimeoutMs = rawResident.softTimeoutMs === undefined
220
+ ? undefined
221
+ : intInRange(rawResident.softTimeoutMs, 'listen[].handler.resident.softTimeoutMs', TIMEOUT_MIN, TIMEOUT_MAX, errors);
222
+ const hardTimeoutAfter = rawResident.hardTimeoutAfter === undefined
223
+ ? undefined
224
+ : intInRange(rawResident.hardTimeoutAfter, 'listen[].handler.resident.hardTimeoutAfter', 1, 100, errors);
225
+ return {
226
+ ...(declared ? { mode: declared } : {}),
227
+ ...((startTimeoutMs ?? softTimeoutMs ?? hardTimeoutAfter) !== undefined
228
+ ? {
229
+ resident: {
230
+ ...(startTimeoutMs !== undefined ? { startTimeoutMs } : {}),
231
+ ...(softTimeoutMs !== undefined ? { softTimeoutMs } : {}),
232
+ ...(hardTimeoutAfter !== undefined ? { hardTimeoutAfter } : {}),
233
+ },
234
+ }
235
+ : {}),
150
236
  };
151
237
  }
152
238
  function validateListenEntry(raw, errors) {
@@ -366,7 +452,7 @@ export function validateRouterConfig(raw) {
366
452
  const errors = [];
367
453
  if (!isRecord(raw))
368
454
  return { ok: false, errors: ['services-config.json must be a JSON object'] };
369
- const extra = Object.keys(raw).filter(key => !['v', 'enabled', 'rateLimit', 'rules'].includes(key));
455
+ const extra = Object.keys(raw).filter(key => !['v', 'enabled', 'rateLimit', 'rules', 'host'].includes(key));
370
456
  if (extra.length)
371
457
  errors.push(`unknown top-level fields: ${extra.join(', ')}`);
372
458
  if (raw.v !== 1)
@@ -391,11 +477,30 @@ export function validateRouterConfig(raw) {
391
477
  }
392
478
  }
393
479
  const rules = validateRules(raw.rules, errors);
480
+ const host = validateHostConfig(raw.host, errors);
394
481
  if (errors.length)
395
482
  return { ok: false, errors };
396
483
  return {
397
484
  ok: true,
398
485
  errors: [],
399
- value: { v: 1, enabled: raw.enabled !== false, rateLimit, rules },
486
+ value: { v: 1, enabled: raw.enabled !== false, rateLimit, rules, ...(host ? { host } : {}) },
400
487
  };
401
488
  }
489
+ /**
490
+ * `host` 段。当前只认 `enabled`;P3 的自管理参数(空闲窗口、间隔分级)上线时在这里扩,
491
+ * **未知字段一律报错**——静默忽略会让用户以为开关生效了。
492
+ */
493
+ function validateHostConfig(raw, errors) {
494
+ if (raw === undefined)
495
+ return undefined;
496
+ if (!isRecord(raw)) {
497
+ errors.push('host must be an object');
498
+ return undefined;
499
+ }
500
+ const extra = Object.keys(raw).filter(key => key !== 'enabled');
501
+ if (extra.length)
502
+ errors.push(`host has unknown fields: ${extra.join(', ')}`);
503
+ if (raw.enabled !== undefined && typeof raw.enabled !== 'boolean')
504
+ errors.push('host.enabled must be a boolean');
505
+ return { ...(raw.enabled !== undefined ? { enabled: raw.enabled } : {}) };
506
+ }
@@ -41,12 +41,12 @@ export class TriggerSchedulerRegistry {
41
41
  }
42
42
  return { enabled, today: { calls, failures } };
43
43
  }
44
- async replace(agentAid, createScheduler) {
44
+ async replace(agentAid, createScheduler, admit) {
45
45
  await this.schedulers.get(agentAid)?.stop();
46
46
  const scheduler = createScheduler();
47
47
  this.schedulers.set(agentAid, scheduler);
48
48
  try {
49
- await scheduler.init();
49
+ await scheduler.init(admit);
50
50
  }
51
51
  catch (error) {
52
52
  logger.error(`[Trigger] Scheduler init failed for ${agentAid}: ${error instanceof Error ? error.message : String(error)}`);
@@ -86,8 +86,10 @@ export class TriggerSchedulerRegistry {
86
86
  await Promise.all([...this.schedulers.values()].map(scheduler => scheduler.waitForIdle(timeoutMs)));
87
87
  }
88
88
  async suspendForDaemonExit() {
89
- await this.notify(listener => listener.suspending?.());
90
- await Promise.all([...this.schedulers.values()].map(scheduler => scheduler.suspendForDaemonExit()));
89
+ // Mark all resumable runs suspended before yielding: daemon queue interruption
90
+ // starts as soon as this method returns its promise. Listeners may be async.
91
+ const suspending = [...this.schedulers.values()].map(scheduler => scheduler.suspendForDaemonExit());
92
+ await Promise.all([...suspending, this.notify(listener => listener.suspending?.())]);
91
93
  }
92
94
  }
93
95
  export function createTriggerChannelResolver({ agentRegistry, channelInstances, daemonChannel, daemonTriggerOwner, }) {
@@ -114,6 +114,12 @@ function assertSessionRuntimeScope(candidate, runtime, errorMessage) {
114
114
  throw new Error(errorMessage);
115
115
  }
116
116
  }
117
+ function sameFileIdentity(left, right) {
118
+ return left.dev === right.dev && left.ino === right.ino;
119
+ }
120
+ function sameFileMetadata(left, right) {
121
+ return left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
122
+ }
117
123
  export function readManagedLocalFile(input, scope, kind) {
118
124
  const sourceLabel = kind === 'trigger' ? 'Trigger input' : 'Attachment source';
119
125
  const resolved = resolveManagedLocalPath(input, scope, kind);
@@ -126,16 +132,21 @@ export function readManagedLocalFile(input, scope, kind) {
126
132
  const descriptor = fs.openSync(resolved, fs.constants.O_RDONLY | noFollow);
127
133
  try {
128
134
  const opened = fs.fstatSync(descriptor);
129
- if (!opened.isFile() || opened.dev !== expected.dev || opened.ino !== expected.ino
130
- || (scope && opened.nlink !== 1)
135
+ const openedPath = fs.lstatSync(resolved);
136
+ // Windows path and handle stats can report different dev/ino values for the
137
+ // same file. Compare identities within each API and metadata across APIs;
138
+ // retain the additional path-to-handle identity check on POSIX.
139
+ if (!opened.isFile() || !openedPath.isFile() || openedPath.isSymbolicLink()
140
+ || !sameFileIdentity(openedPath, expected) || !sameFileMetadata(openedPath, expected)
141
+ || (process.platform !== 'win32' && !sameFileIdentity(opened, expected))
142
+ || !sameFileMetadata(opened, expected)
143
+ || (scope && (opened.nlink !== 1 || openedPath.nlink !== 1))
131
144
  || resolveManagedLocalPath(input, scope, kind) !== resolved) {
132
145
  throw new Error(`${sourceLabel} changed during validation`);
133
146
  }
134
147
  if (opened.size > TRIGGER_LOCAL_FILE_LIMIT) {
135
148
  throw new Error(`${sourceLabel} exceeds the 4 MiB limit`);
136
149
  }
137
- const openedMtime = opened.mtimeMs;
138
- const openedCtime = opened.ctimeMs;
139
150
  const buffer = Buffer.alloc(Math.min(opened.size + 1, TRIGGER_LOCAL_FILE_LIMIT + 1));
140
151
  let length = 0;
141
152
  while (length < buffer.length) {
@@ -146,11 +157,10 @@ export function readManagedLocalFile(input, scope, kind) {
146
157
  }
147
158
  const afterRead = fs.fstatSync(descriptor);
148
159
  const afterPath = fs.lstatSync(resolved);
149
- if (length !== opened.size || afterRead.size !== opened.size
150
- || afterRead.mtimeMs !== openedMtime || afterRead.ctimeMs !== openedCtime
151
- || afterPath.dev !== opened.dev || afterPath.ino !== opened.ino
152
- || !afterPath.isFile() || afterPath.isSymbolicLink()
153
- || afterPath.size !== opened.size || afterPath.mtimeMs !== openedMtime || afterPath.ctimeMs !== openedCtime
160
+ if (length !== opened.size || !afterRead.isFile()
161
+ || !sameFileIdentity(afterRead, opened) || !sameFileMetadata(afterRead, opened)
162
+ || !sameFileIdentity(afterPath, expected)
163
+ || !afterPath.isFile() || afterPath.isSymbolicLink() || !sameFileMetadata(afterPath, opened)
154
164
  || (scope && (afterRead.nlink !== 1 || afterPath.nlink !== 1))
155
165
  || resolveManagedLocalPath(input, scope, kind) !== resolved) {
156
166
  throw new Error(`${sourceLabel} changed during reading`);
@@ -84,7 +84,7 @@ export class TriggerRuntimeScheduler {
84
84
  });
85
85
  }
86
86
  }
87
- async init() {
87
+ async init(admit) {
88
88
  const stopped = this.stop();
89
89
  const generation = this.lifecycleGeneration;
90
90
  await stopped;
@@ -95,17 +95,27 @@ export class TriggerRuntimeScheduler {
95
95
  await this.audit.initializeHistory?.();
96
96
  if (this.stopping || generation !== this.lifecycleGeneration)
97
97
  return;
98
- await this.recoverOpenRuns();
99
- if (this.stopping || generation !== this.lifecycleGeneration)
100
- return;
101
- for (const definition of this.manager.list()) {
102
- if (this.recoveredOneShotIds.has(definition.id))
103
- continue;
104
- this.schedule(definition);
105
- }
106
- this.recoveredOneShotIds.clear();
107
- this.initialized = true;
108
- logger.info(`[Trigger] scheduler initialized for ${this.manager.agentAid}`);
98
+ // Shared history imports must register before bounded startup admission;
99
+ // otherwise each queue wave scans the same global audit files again.
100
+ const initialize = async () => {
101
+ if (this.stopping || generation !== this.lifecycleGeneration)
102
+ return;
103
+ await this.recoverOpenRuns();
104
+ if (this.stopping || generation !== this.lifecycleGeneration)
105
+ return;
106
+ for (const definition of this.manager.list()) {
107
+ if (this.recoveredOneShotIds.has(definition.id))
108
+ continue;
109
+ this.schedule(definition);
110
+ }
111
+ this.recoveredOneShotIds.clear();
112
+ this.initialized = true;
113
+ logger.info(`[Trigger] scheduler initialized for ${this.manager.agentAid}`);
114
+ };
115
+ if (admit)
116
+ await admit(initialize);
117
+ else
118
+ await initialize();
109
119
  }
110
120
  async stop() {
111
121
  this.lifecycleGeneration++;
@@ -193,6 +193,8 @@ export async function buildTriggerScriptLaunch(input) {
193
193
  process.execPath,
194
194
  path.dirname(process.execPath),
195
195
  snapshotDir,
196
+ // 服务常驻宿主:包脚本快照根(只读)。不传时这里是空数组,行为不变。
197
+ ...(input.extraReadRoots ?? []),
196
198
  ].filter(value => fs.existsSync(value));
197
199
  const entries = [
198
200
  { path: { type: 'special', value: { kind: 'root' } },
@@ -201,19 +203,16 @@ export async function buildTriggerScriptLaunch(input) {
201
203
  filesystemEntry(projectPath, readonly ? 'read' : 'write'),
202
204
  filesystemEntry(snapshotDir, 'read'),
203
205
  filesystemEntry(workDir, 'write'),
206
+ // 额外可写根(服务宿主的工作目录)。不存在时 `filesystemEntry` 仍是合法条目,
207
+ // 但策略里指向不存在的路径不会生效,所以调用方必须先建好目录。
208
+ ...(input.extraWriteRoots ?? []).map(value => filesystemEntry(value, 'write')),
204
209
  filesystemEntry(windowsBackend.home, 'deny'),
205
- // 服务包:脚本不能改写自己的代码与声明,只能读。
206
- //
207
- // 当前行为本来就是这样(`root: read` + 没有任何条目给 services 授 write),
208
- // 这条的价值是把它从「依赖默认拒绝」变成显式声明:将来若有重构把 services
209
- // 纳入 write 范围(例如为缓存/worker 方案放权),这里仍然读-写不对称。
210
- //
211
- // **不能写 `deny`**:Codex 的 deny 连读一起拒,而服务脚本要读自己的
212
- // pack.json。真需要拦写也拦不住显式子级 Allow——那由 ACL 层负责
213
- // (见 src/core/permission/services-path-acl.ts)。
214
- ...(input.trigger.labels?.kind === 'services'
215
- ? [filesystemEntry(path.join(root, 'agents', input.trigger.agentAid, 'services'), 'read')]
216
- : []),
210
+ // 这里不再为 `services` 单独追加条目。`services` 已由
211
+ // `getExistingLClassReadOnlyTargets` 纳入 L 类只读目标,win32 下写保护由
212
+ // 「没有任何条目授 write」+ ACL 的 DENY(写) 共同承担(见
213
+ // src/core/permission/services-path-acl.ts)。原先那条按
214
+ // `trigger.labels.kind === 'services'` 分流的 read 条目是空操作:实测有它无它,
215
+ // 服务脚本对 services 树的 list / read / write 结果完全相同。
217
216
  ...Object.entries(filesystem).flatMap(([value, access]) => typeof access === 'number' ? [] : [{
218
217
  path: /[*?[\]]/.test(value)
219
218
  ? { type: 'glob_pattern', pattern: value }
@@ -248,7 +247,7 @@ export async function buildTriggerScriptLaunch(input) {
248
247
  env: { ...env, CODEX_HOME: windowsBackend.home },
249
248
  cleanup,
250
249
  };
251
- launch.prepare = signal => verifyWindowsReadIsolation(launch, sandboxArgs, runDir, workDir, signal);
250
+ launch.prepare = signal => verifyWindowsReadIsolation(launch, sandboxArgs, runDir, workDir, signal, input.verifyGrandchild === true);
252
251
  return launch;
253
252
  }
254
253
  const launch = sandboxDecision.state === 'off'
@@ -266,7 +265,14 @@ export async function buildTriggerScriptLaunch(input) {
266
265
  const separator = launch.args.indexOf('--');
267
266
  if (separator < 0)
268
267
  throw new Error('bubblewrap launch is missing its command separator');
269
- const runMountArgs = ['--ro-bind', runDir, runDir, '--bind', workDir, workDir];
268
+ const runMountArgs = [
269
+ '--ro-bind', runDir, runDir,
270
+ '--bind', workDir, workDir,
271
+ ...(input.extraWriteRoots ?? []).flatMap(root => ['--bind', root, root]),
272
+ // 额外只读根(服务宿主的包脚本快照根)。bwrap 里**没有挂载就等于不存在**,
273
+ // 与 Windows 侧的 read 策略条目是同一件事的两平台写法,必须成对出现。
274
+ ...(input.extraReadRoots ?? []).flatMap(root => ['--ro-bind', root, root]),
275
+ ];
270
276
  if (!launch.args.slice(0, separator).includes('--chdir'))
271
277
  runMountArgs.push('--chdir', projectPath);
272
278
  launch.args.splice(separator, 0, ...runMountArgs);
@@ -375,7 +381,7 @@ function assertRealDirectory(value, label) {
375
381
  function samePath(left, right) {
376
382
  return isSameOrDescendant(left, right) && isSameOrDescendant(right, left);
377
383
  }
378
- function readScriptSnapshot(value, triggerDir) {
384
+ export function readScriptSnapshot(value, triggerDir) {
379
385
  const scriptPath = path.resolve(value);
380
386
  const validate = () => {
381
387
  if (!isSameOrDescendant(scriptPath, triggerDir))
@@ -439,7 +445,7 @@ const SCRIPT_STAGING_FILE_COUNT = 2_000;
439
445
  * `preserveNodeModuleType` 统一合成,避免 `wx` 冲突)。每个文件走与入口相同的
440
446
  * lstat/fd 校验(防 TOCTOU/软链),越界文件直接抛错走沙箱不可用降级。
441
447
  */
442
- function stageScriptSnapshot(scriptSource, triggerDir, scriptBytes, snapshotDir) {
448
+ export function stageScriptSnapshot(scriptSource, triggerDir, scriptBytes, snapshotDir) {
443
449
  const scriptName = path.basename(scriptSource);
444
450
  const scriptPath = path.join(snapshotDir, scriptName);
445
451
  fs.writeFileSync(scriptPath, scriptBytes, { flag: 'wx', mode: 0o400 });
@@ -477,7 +483,7 @@ function stageScriptSnapshot(scriptSource, triggerDir, scriptBytes, snapshotDir)
477
483
  stage(scriptDir, '');
478
484
  return scriptPath;
479
485
  }
480
- function preserveNodeModuleType(runtime, scriptPath, snapshotDir) {
486
+ export function preserveNodeModuleType(runtime, scriptPath, snapshotDir) {
481
487
  if (!/^node(?:\.exe)?$/i.test(path.basename(runtime)) || path.extname(scriptPath) !== '.js')
482
488
  return;
483
489
  let current = path.dirname(scriptPath);
@@ -537,7 +543,7 @@ function filesystemEntry(value, access) {
537
543
  * (证明 deny 真的被沙箱执行;这一步失败说明沙箱没起效,必须拒跑)
538
544
  * 3. 在 workDir 写文件 → 必须成功(证明 scoped 路径没有把整个文件系统锁死)
539
545
  */
540
- async function verifyWindowsReadIsolation(launch, sandboxArgs, runDir, workDir, signal) {
546
+ async function verifyWindowsReadIsolation(launch, sandboxArgs, runDir, workDir, signal, verifyGrandchild = false) {
541
547
  signal?.throwIfAborted();
542
548
  const canary = path.join(runDir, 'read-isolation-canary');
543
549
  const writableProbe = path.join(workDir, 'write-isolation-probe');
@@ -558,6 +564,30 @@ async function verifyWindowsReadIsolation(launch, sandboxArgs, runDir, workDir,
558
564
  'fs.writeFileSync(process.argv[2], "allowed");',
559
565
  'process.stdout.write("evolcore-trigger-sandbox-ready");',
560
566
  ].join('\n');
567
+ // 孙进程版:沙箱内的这个 node 再 spawn 一个 node,由**后者**去读 deny 路径。
568
+ // 服务宿主正是这个形状(宿主 → 脚本次进程),直接子进程被拦不能证明孙进程也被拦。
569
+ const grandchildDenyProbe = [
570
+ 'const { spawn } = require("node:child_process");',
571
+ 'const inner = [',
572
+ ' "const fs = require(\\"node:fs\\");",',
573
+ ' "let denied = false;",',
574
+ ' "try { fs.readFileSync(process.argv[1]); } catch (e) {",',
575
+ ' "if (e.code === \\"EACCES\\" || e.code === \\"EPERM\\" || e.code === \\"ENOENT\\") denied = true; else throw e;",',
576
+ ' "}",',
577
+ ' "process.stdout.write(denied ? \\"denied\\" : \\"readable\\");",',
578
+ '].join("\\n");',
579
+ 'const child = spawn(process.execPath, ["-e", inner, process.argv[1]], { stdio: ["ignore", "pipe", "inherit"] });',
580
+ 'let out = "";',
581
+ 'child.stdout.on("data", b => { out += b.toString(); });',
582
+ 'child.on("close", code => {',
583
+ ' if (code !== 0) { process.stderr.write("grandchild probe exited " + code); process.exit(92); }',
584
+ ' if (out.trim() !== "denied") {',
585
+ ' process.stderr.write("grandchild escaped the sandbox: denied path was readable from a grandchild process");',
586
+ ' process.exit(90);',
587
+ ' }',
588
+ ' process.stdout.write("evolcore-trigger-sandbox-ready");',
589
+ '});',
590
+ ].join('\n');
561
591
  const withExtraEntry = (extra) => {
562
592
  const args = [...sandboxArgs];
563
593
  const stateIndex = args.indexOf('--sandbox-state-json') + 1;
@@ -570,10 +600,11 @@ async function verifyWindowsReadIsolation(launch, sandboxArgs, runDir, workDir,
570
600
  };
571
601
  try {
572
602
  await runWindowsIsolationProbe(launch, withExtraEntry(filesystemEntry(canary, 'read')), readProbe, [canary], signal);
573
- await runWindowsIsolationProbe(launch, withExtraEntry(filesystemEntry(canary, 'deny')), denyProbe, [canary, writableProbe], signal);
603
+ await runWindowsIsolationProbe(launch, withExtraEntry(filesystemEntry(canary, 'deny')), verifyGrandchild ? grandchildDenyProbe : denyProbe, verifyGrandchild ? [canary] : [canary, writableProbe], signal);
574
604
  }
575
605
  catch (error) {
576
- throw new Error(`Windows sandbox cannot prove scoped read isolation; Trigger script execution is refused: ${error?.message || String(error)}`, { cause: error });
606
+ throw new Error(`Windows sandbox cannot prove scoped read isolation${verifyGrandchild ? ' (including grandchild processes)' : ''}; `
607
+ + `scoped execution is refused: ${error?.message || String(error)}`, { cause: error });
577
608
  }
578
609
  finally {
579
610
  try {
@@ -1,4 +1,5 @@
1
1
  import { randomBytes, randomUUID, timingSafeEqual, createHash } from 'crypto';
2
+ import os from 'node:os';
2
3
  import { loadAgent } from '../config-store.js';
3
4
  import { isValidAid } from '../aun/aid/validation.js';
4
5
  import { ownerResolver } from '../core/ownership/owner-resolver.js';
@@ -42,6 +43,8 @@ export class BindService {
42
43
  return { ok: true, taskId: session.id, expiresAt: session.expiresAt, qrData: {
43
44
  type: 'evolcore.bind', version: readInstalledEvolcoreVersion(),
44
45
  platform: process.platform === 'win32' ? 'windows' : process.platform,
46
+ // 机器名随二维码带给 App:主机列表的默认显示名要用它,而不是 agent 的名字。
47
+ hostName: os.hostname(),
45
48
  bindType: session.bindType, subjectAid, receiverAid: this.options.receiverAid,
46
49
  token: session.token, expiresAt: session.expiresAt,
47
50
  } };
@@ -5,8 +5,8 @@ import { fileURLToPath } from 'url';
5
5
  import { getPackageRoot } from '../paths.js';
6
6
  // Embedded by bin/ec-build.mjs; loaded processes retain these values across rebuilds.
7
7
  // @evolcore-build-identity:start
8
- export const RUNTIME_BUILD_ID = "sha256:12c2256a403ff169bb86c416";
9
- export const RUNTIME_BUILD_TIME = "2026-11-15T03:59:05.194Z";
8
+ export const RUNTIME_BUILD_ID = "sha256:3561d8e3c0e3ce13b94f99d2";
9
+ export const RUNTIME_BUILD_TIME = "2026-11-17T15:02:32.541Z";
10
10
  // @evolcore-build-identity:end
11
11
  let cachedVersion;
12
12
  let cachedFlavor;
@@ -255,6 +255,7 @@ export function readHostInfo(evolcoreVersion, evolcoreHomePath, options = {}) {
255
255
  os: {
256
256
  platform,
257
257
  platformName: detectPlatformName(platform),
258
+ productName: null,
258
259
  release: readOsReleaseVersion(),
259
260
  distributionId: release.id,
260
261
  version: release.version,
@@ -373,6 +374,78 @@ export async function probeVirtualization() {
373
374
  return 'unknown';
374
375
  }
375
376
  }
377
+ /** Windows 11 的 build 分界:22000 是 21H2 首发 build,Windows 10 最高到 19045。 */
378
+ const WINDOWS_11_MIN_BUILD = 22000;
379
+ /**
380
+ * 完整 OS 产品名。只能异步:Windows 走注册表(约 50ms 子进程),Linux 读
381
+ * os-release 的 PRETTY_NAME。macOS 没有等价的廉价来源,返回 null 由界面回落
382
+ * 到 platformName + release。
383
+ *
384
+ * Windows 不能直接用 ProductName:微软为兼容性在 Windows 11 上仍把它写成
385
+ * "Windows 10 Pro"(本机实测 ProductName=Windows 10 Pro,CurrentBuild=26200,
386
+ * 而 Caption 报的是 Windows 11 专业版)。所以产品名里的主版本必须按 build 号纠正,
387
+ * 不能用 `os.release()` 的 "10.0.x"——Win10 和 Win11 的主版本号都是 10.0。
388
+ */
389
+ export async function probeOsProductName() {
390
+ try {
391
+ if (process.platform === 'win32') {
392
+ const { ok, stdout } = await runExec('reg', [
393
+ 'query', 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion',
394
+ ], 4000);
395
+ if (!ok)
396
+ return null;
397
+ return readWindowsProductName(stdout);
398
+ }
399
+ if (process.platform === 'linux') {
400
+ const pretty = readOsReleasePrettyName();
401
+ if (pretty)
402
+ return pretty;
403
+ const release = readOsRelease();
404
+ return release.version ? `${release.id ?? 'Linux'} ${release.version}` : null;
405
+ }
406
+ return null;
407
+ }
408
+ catch {
409
+ return null;
410
+ }
411
+ }
412
+ /**
413
+ * 从 `reg query ...\CurrentVersion` 的输出里拼出可信的 Windows 产品名。
414
+ *
415
+ * 注册表值本身在 Win11 上是错的,唯一可靠的版本判据是 CurrentBuild。产品名可能有
416
+ * 本地化后缀("专业版"/"Pro"),所以只替换 "Windows <主版本>" 这一小段,其余原样
417
+ * 保留。build 就读不到时宁可返回原值,也不猜版本。
418
+ */
419
+ export function readWindowsProductName(registryOutput) {
420
+ const values = new Map();
421
+ for (const line of registryOutput.split(/\r?\n/u)) {
422
+ // 每行形如 " ProductName REG_SZ Windows 10 Pro"
423
+ const match = line.match(/^\s{2,}(\S+)\s+REG_(?:SZ|EXPAND_SZ)\s+(.+)$/u);
424
+ if (match)
425
+ values.set(match[1], match[2].trim());
426
+ }
427
+ const productName = values.get('ProductName');
428
+ if (!productName)
429
+ return null;
430
+ const build = Number(values.get('CurrentBuild') ?? values.get('CurrentBuildNumber') ?? '');
431
+ if (!Number.isSafeInteger(build) || build <= 0)
432
+ return productName;
433
+ const expectedMajor = build >= WINDOWS_11_MIN_BUILD ? 11 : 10;
434
+ // ProductName 的写法固定是 "Windows <主版本> <edition>";只认这个前缀,避免误改其它片段。
435
+ return productName.replace(/^Windows\s+(\d+)/u, (_all, major) => (Number(major) === expectedMajor ? `Windows ${major}` : `Windows ${expectedMajor}`));
436
+ }
437
+ /** Linux 发行版的 PRETTY_NAME,已含版本号,是最接近 Windows ProductName 的字段。 */
438
+ function readOsReleasePrettyName() {
439
+ try {
440
+ for (const line of fs.readFileSync('/etc/os-release', 'utf8').split(/\r?\n/u)) {
441
+ const match = line.match(/^PRETTY_NAME=(.*)$/u);
442
+ if (match)
443
+ return match[1].replace(/^"|"$/gu, '').trim() || null;
444
+ }
445
+ }
446
+ catch { }
447
+ return null;
448
+ }
376
449
  // 不要求词边界:go 输出是 "go1.27.0",数字前面紧跟字母,\b 会挡住匹配。
377
450
  const SEMVER = /\d+\.\d+\.\d+(?:[-+][\w.-]+)?/u;
378
451
  function firstVersionLine(output) {
@@ -271,7 +271,7 @@ export function ownershipErrorCode(error, fallback = 'OWNERSHIP_OPERATION_FAILED
271
271
  }
272
272
  export function logOwnershipEvent(event, fields, failed = false) {
273
273
  const record = { schema: 'ec.ownership.v1', event };
274
- for (const key of ['subjectAid', 'ownerAid', 'actorAid', 'localAid', 'configuredOwnerAid']) {
274
+ for (const key of ['subjectAid', 'ownerAid', 'actorAid', 'localAid']) {
275
275
  const value = fields[key];
276
276
  if (typeof value === 'string' && value.length <= 253
277
277
  && /^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?){2,}$/.test(value)) {
@@ -308,7 +308,7 @@ export function logOwnershipEvent(event, fields, failed = false) {
308
308
  if (typeof fields.relationVersion === 'number' && Number.isSafeInteger(fields.relationVersion)
309
309
  && fields.relationVersion >= 0)
310
310
  record.relationVersion = fields.relationVersion;
311
- for (const key of ['attemptId', 'processId', 'durationMs', 'maxAgeMs', 'timeoutMs', 'configuredOwnerCount']) {
311
+ for (const key of ['attemptId', 'processId', 'durationMs', 'maxAgeMs', 'timeoutMs']) {
312
312
  const value = fields[key];
313
313
  if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0)
314
314
  record[key] = value;