evolcore 0.0.43-test.3 → 0.0.43-test.4

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 (109) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/bin/ecmsg.js +229 -0
  3. package/bin/install-codex-managed-hooks.mjs +130 -8
  4. package/dist/ability/application-service.js +37 -0
  5. package/dist/ability/resources.js +28 -0
  6. package/dist/ability/runtime.js +6 -1
  7. package/dist/agents/claude-runner.js +7 -5
  8. package/dist/agents/codex/app-server-client.js +0 -12
  9. package/dist/agents/codex-runner.js +0 -37
  10. package/dist/agents/ecagent-runner.js +130 -35
  11. package/dist/aun/aid/agentmd.js +31 -12
  12. package/dist/aun/menu/client.js +8 -7
  13. package/dist/aun/menu/index.js +1 -1
  14. package/dist/aun/menu/transport.js +8 -5
  15. package/dist/aun/service-proxy.js +3 -0
  16. package/dist/channels/aun.js +26 -5
  17. package/dist/channels/daemon.js +10 -2
  18. package/dist/cli/agent-command.js +5 -0
  19. package/dist/cli/agent-create.js +28 -6
  20. package/dist/cli/agent.js +9 -3
  21. package/dist/cli/aun-commands.js +2 -2
  22. package/dist/cli/daemon-commands.js +30 -18
  23. package/dist/cli/directory.js +4 -7
  24. package/dist/cli/getmeta-command.js +2 -1
  25. package/dist/cli/init.js +13 -5
  26. package/dist/cli/trigger-command.js +20 -14
  27. package/dist/config/boot-log.js +12 -2
  28. package/dist/config/config-field-policy.js +2 -0
  29. package/dist/config/config-manager.js +9 -4
  30. package/dist/config/peer-role-resolver.js +1 -1
  31. package/dist/config/role-schema.js +3 -3
  32. package/dist/config/schema-migration.js +121 -0
  33. package/dist/core/agent-application-service.js +11 -0
  34. package/dist/core/agent-ipc-registration.js +2 -0
  35. package/dist/core/agent-runtime.js +41 -9
  36. package/dist/core/auth/auth-gateway.js +3 -3
  37. package/dist/core/auth/operation-authorizer.js +2 -1
  38. package/dist/core/baseagent-loader.js +11 -3
  39. package/dist/core/bootstrap-service.js +8 -0
  40. package/dist/core/channel-loader.js +61 -23
  41. package/dist/core/command/agent-control.js +4 -1
  42. package/dist/core/command/chatmode-config.js +46 -0
  43. package/dist/core/command/command-handler.js +5 -14
  44. package/dist/core/command/daemon-diagnostics.js +2 -1
  45. package/dist/core/command/menu-catalog.js +1 -1
  46. package/dist/core/command/menu-handler.js +16 -16
  47. package/dist/core/command/slash-handler.js +4 -26
  48. package/dist/core/daemon-lifecycle.js +35 -17
  49. package/dist/core/event-catalog.js +19 -0
  50. package/dist/core/evolagent-registry.js +3 -0
  51. package/dist/core/ipc-registration.js +6 -0
  52. package/dist/core/message/im-renderer.js +24 -19
  53. package/dist/core/message/message-admission.js +11 -2
  54. package/dist/core/message/response-engine.js +17 -18
  55. package/dist/core/model/model-capabilities.js +37 -0
  56. package/dist/core/model/model-catalog.js +6 -2
  57. package/dist/core/ownership/owner-resolver.js +6 -6
  58. package/dist/core/permission/ec-command-parser.js +47 -12
  59. package/dist/core/plugin-lifecycle.js +6 -2
  60. package/dist/core/relation/pa-team.js +7 -2
  61. package/dist/directory/owner-directory-cache.js +4 -2
  62. package/dist/directory/owner-directory-query-operation.js +5 -7
  63. package/dist/ecweb/runtime/lifecycle.js +29 -5
  64. package/dist/ecweb/runtime/supervisor.js +83 -27
  65. package/dist/index.js +198 -38
  66. package/dist/proxy/service-supervisor.js +377 -141
  67. package/dist/trigger/audit.js +3 -2
  68. package/dist/trigger/authorization.js +2 -3
  69. package/dist/trigger/history.js +4 -3
  70. package/dist/trigger/ipc-service.js +24 -19
  71. package/dist/trigger/manager.js +3 -5
  72. package/dist/trigger/parser.js +4 -21
  73. package/dist/trigger/patch.js +3 -15
  74. package/dist/trigger/scheduler.js +45 -10
  75. package/dist/trigger/validation.js +0 -13
  76. package/dist/utils/error-utils.js +8 -0
  77. package/dist/utils/macos-autostart.js +31 -0
  78. package/dist/utils/model-prices.jsonl +15 -8
  79. package/dist/utils/process-introspect.js +21 -1
  80. package/dist/utils/startup-trace.js +7 -1
  81. package/dist/utils/windows-autostart.js +1 -0
  82. package/ecagent/dist/harness/compaction/branch-summarization.js +1 -1
  83. package/ecagent/dist/harness/compaction/compaction.js +4 -4
  84. package/kits/docs/evolcore/INDEX.md +1 -1
  85. package/kits/docs/evolcore/file-navigation.md +63 -49
  86. package/kits/docs/evolcore/menu-protocol.md +1 -0
  87. package/kits/docs/evolcore/model.md +5 -3
  88. package/kits/docs/evolcore/response.md +2 -0
  89. package/kits/docs/evolcore/thread-chain.md +1 -1
  90. package/kits/docs/evolcore/tool-authorization.md +4 -1
  91. package/kits/docs/evolcore/trigger.md +10 -7
  92. package/kits/eck_manifest.json +0 -21
  93. package/kits/rules/01-overview.md +42 -44
  94. package/kits/rules/02-navigation.md +44 -53
  95. package/kits/rules/03-identity.md +21 -25
  96. package/kits/rules/04-relation.md +23 -33
  97. package/kits/rules/05-venue.md +24 -25
  98. package/kits/schemas/_meta.json +13 -26
  99. package/kits/schemas/agent-config.schema.19.json +10 -6
  100. package/kits/schemas/relation-config.schema.12.json +2 -2
  101. package/kits/schemas/role-config.schema.2.json +5 -5
  102. package/kits/skills/ec-service-proxy/SKILL.md +10 -0
  103. package/kits/skills/ec-trigger/SKILL.md +1 -1
  104. package/kits/templates/system-fragments/commands.md +1 -1
  105. package/kits/templates/system-fragments/identity.md +0 -1
  106. package/package.json +18 -13
  107. package/kits/schemas/agent-config.schema.20.json +0 -925
  108. package/kits/schemas/relation-config.schema.13.json +0 -289
  109. package/kits/schemas/role-config.schema.3.json +0 -1038
@@ -92,7 +92,8 @@ export class TriggerAuditLogger {
92
92
  if (record.status !== 'completed'
93
93
  && record.status !== 'degraded'
94
94
  && record.status !== 'noop'
95
- && record.status !== 'failed')
95
+ && record.status !== 'failed'
96
+ && record.status !== 'interrupted')
96
97
  continue;
97
98
  out.fireCount += 1;
98
99
  if (record.status === 'failed')
@@ -100,7 +101,7 @@ export class TriggerAuditLogger {
100
101
  if (record.finishedAt > latestFinishedAt) {
101
102
  latestFinishedAt = record.finishedAt;
102
103
  out.lastFiredAt = record.finishedAt;
103
- out.lastResult = record.status === 'failed' ? 'failed' : 'completed';
104
+ out.lastResult = record.status === 'failed' ? 'failed' : record.status === 'interrupted' ? 'interrupted' : 'completed';
104
105
  }
105
106
  }
106
107
  }
@@ -143,7 +143,7 @@ export function validateTriggerDefinitionForActor(definition, actor, dependencie
143
143
  const agent = dependencies.getAgent(definition.agentAid);
144
144
  const modelDecision = validateModelSelectionForRole({
145
145
  role: actor.role,
146
- baseagent: definition.execution.baseagent ?? agent?.baseagent,
146
+ baseagent: agent?.baseagent,
147
147
  requestedModel: definition.execution.model,
148
148
  selfAid: definition.agentAid,
149
149
  });
@@ -151,8 +151,7 @@ export function validateTriggerDefinitionForActor(definition, actor, dependencie
151
151
  throw new Error(modelDecision.message || 'trigger model is not allowed by current role');
152
152
  }
153
153
  if (definition.execution.effort && !actor.daemonPrivileged) {
154
- const baseagent = definition.execution.baseagent
155
- ?? dependencies.getAgent(definition.agentAid)?.baseagent;
154
+ const baseagent = dependencies.getAgent(definition.agentAid)?.baseagent;
156
155
  if (!baseagent)
157
156
  throw new Error('cannot determine Trigger baseagent');
158
157
  const effortDecision = validateRuntimeStringFieldOverride({
@@ -101,7 +101,7 @@ export class TriggerHistoryStore {
101
101
  const finishedAt = event.audit.finishedAt;
102
102
  if (finishedAt < fromTs || finishedAt >= toTs)
103
103
  continue;
104
- if (!['completed', 'degraded', 'noop', 'failed'].includes(event.audit.status))
104
+ if (!['completed', 'degraded', 'noop', 'failed', 'interrupted'].includes(event.audit.status))
105
105
  continue;
106
106
  calls++;
107
107
  if (event.audit.status === 'failed')
@@ -192,7 +192,8 @@ export class TriggerHistoryStore {
192
192
  if (record.status !== 'completed'
193
193
  && record.status !== 'degraded'
194
194
  && record.status !== 'noop'
195
- && record.status !== 'failed')
195
+ && record.status !== 'failed'
196
+ && record.status !== 'interrupted')
196
197
  continue;
197
198
  current.fireCount += 1;
198
199
  if (record.status === 'failed')
@@ -200,7 +201,7 @@ export class TriggerHistoryStore {
200
201
  if (record.finishedAt > latestFinishedAt) {
201
202
  latestFinishedAt = record.finishedAt;
202
203
  current.lastFiredAt = record.finishedAt;
203
- current.lastResult = record.status === 'failed' ? 'failed' : 'completed';
204
+ current.lastResult = record.status === 'failed' ? 'failed' : record.status === 'interrupted' ? 'interrupted' : 'completed';
204
205
  }
205
206
  }
206
207
  return this.mergeRunStats(legacyMatched ? legacy : undefined, current);
@@ -20,32 +20,25 @@ export function createTriggerBaseagentResolver({ daemonTriggerOwnerAid, getAgent
20
20
  export function registerTriggerIpcExecutor(ipcServer, dependencies) {
21
21
  ipcServer.setTriggerExecutor(createTriggerIpcExecutor(dependencies));
22
22
  }
23
- export function materializeTriggerCreateBaseagent(input, agentAid, dependencies) {
23
+ export function validateTriggerCreateBaseagent(input, agentAid, dependencies) {
24
24
  const rawExecution = input.execution;
25
25
  if (!rawExecution || typeof rawExecution !== 'object' || Array.isArray(rawExecution))
26
26
  return input;
27
27
  const execution = rawExecution;
28
- if (execution.type !== 'trigger_session') {
29
- if (execution.baseagent !== undefined) {
30
- throw new Error('execution.baseagent is only allowed when execution.type=trigger_session');
31
- }
32
- return input;
28
+ if ('baseagent' in execution) {
29
+ throw new Error('execution.baseagent is no longer supported; Trigger uses its owning Agent baseagent');
33
30
  }
34
- if (execution.baseagent !== undefined
35
- && (typeof execution.baseagent !== 'string' || !execution.baseagent.trim())) {
36
- throw new Error('execution.baseagent must be a non-empty string');
37
- }
38
- const baseagent = typeof execution.baseagent === 'string'
39
- ? execution.baseagent.trim()
40
- : dependencies.getAgentBaseagent(agentAid)
41
- ?? (agentAid === dependencies.daemonTriggerOwnerAid ? dependencies.daemonTriggerBaseagent : undefined);
31
+ if (execution.type !== 'trigger_session')
32
+ return input;
33
+ const baseagent = dependencies.getAgentBaseagent(agentAid)
34
+ ?? (agentAid === dependencies.daemonTriggerOwnerAid ? dependencies.daemonTriggerBaseagent : undefined);
42
35
  if (!baseagent)
43
36
  throw new Error('unable to resolve Trigger session baseagent');
44
37
  const available = dependencies.getAvailableBaseagents(agentAid);
45
38
  if (!available.includes(baseagent)) {
46
39
  throw new Error(`Trigger baseagent unavailable for ${agentAid}: ${baseagent} (available: ${available.join(', ') || 'none'})`);
47
40
  }
48
- return { ...input, execution: { ...execution, baseagent } };
41
+ return input;
49
42
  }
50
43
  export async function authorizeTriggerActorOperation(agentAid, operation, actor, triggerId) {
51
44
  if (actor.permissionMode === 'readonly' && !actor.fullAccess
@@ -119,7 +112,7 @@ export function prepareTriggerCreateDefinition(rawDefinition, agentAid, actor, d
119
112
  feedback: rawDefinition.feedback,
120
113
  operatorPeers: undefined,
121
114
  });
122
- const materialized = materializeTriggerCreateBaseagent({ ...rawDefinition, origin: actor.origin, operatorPeers }, agentAid, dependencies);
115
+ const materialized = validateTriggerCreateBaseagent({ ...rawDefinition, origin: actor.origin, operatorPeers }, agentAid, dependencies);
123
116
  let definition = normalizeTriggerDefinition(materialized);
124
117
  if (definition.labels?.kind === 'cross-thread-review') {
125
118
  definition.labels = { ...definition.labels, originAuthorization: 'creator-session-v1' };
@@ -277,7 +270,11 @@ export function createTriggerIpcExecutor(dependencies) {
277
270
  delegationCommandHash: cmd.delegationCommandHash };
278
271
  approvedAgentAid = requireAgent(command.agentAid);
279
272
  approvedOperation = command.type;
280
- approvedActor = await authorizeTrigger(approvedAgentAid, approvedOperation, command.triggerId);
273
+ const approvedTriggerId = command.triggerId
274
+ ?? (typeof command.runId === 'string'
275
+ ? schedulerFor(approvedAgentAid).activeRunTriggerId(command.runId)
276
+ : undefined);
277
+ approvedActor = await authorizeTrigger(approvedAgentAid, approvedOperation, approvedTriggerId);
281
278
  const args = argv.slice(2);
282
279
  const usesFiles = args.some(value => ['--file', '--prompt-file', '--script-path', '--script-file']
283
280
  .some(flag => value === flag || value.startsWith(`${flag}=`)));
@@ -478,10 +475,18 @@ export function createTriggerIpcExecutor(dependencies) {
478
475
  }
479
476
  case 'trigger.cancel': {
480
477
  const agentAid = requireAgent(cmd.agentAid);
478
+ const scheduler = schedulerFor(agentAid);
479
+ if (typeof cmd.runId === 'string' && cmd.runId) {
480
+ const triggerId = scheduler.activeRunTriggerId(cmd.runId);
481
+ if (!triggerId)
482
+ throw new Error(`Trigger run is not active: ${cmd.runId}`);
483
+ await authorizeTrigger(agentAid, 'trigger.cancel', triggerId);
484
+ return { ok: true, result: await scheduler.cancelRun(cmd.runId), runId: cmd.runId, triggerId };
485
+ }
481
486
  if (!cmd.triggerId)
482
- throw new Error('missing triggerId');
487
+ throw new Error('missing runId');
483
488
  await authorizeTrigger(agentAid, 'trigger.cancel', cmd.triggerId);
484
- const trigger = schedulerFor(agentAid).cancel(cmd.triggerId);
489
+ const trigger = scheduler.cancel(cmd.triggerId);
485
490
  return { ok: true, trigger };
486
491
  }
487
492
  case 'trigger.delete': {
@@ -38,6 +38,9 @@ export class TriggerDefinitionManager {
38
38
  const raw = JSON.parse(fs.readFileSync(file, 'utf-8'));
39
39
  const definition = normalizeTriggerDefinition(raw, { allowLegacyZeroRetryAttempts: true });
40
40
  const migrations = [];
41
+ if (isRecord(raw.execution) && Object.prototype.hasOwnProperty.call(raw.execution, 'baseagent')) {
42
+ migrations.push('inherit-owner-baseagent');
43
+ }
41
44
  if (legacyFeedbackTargetNeedsMigration(raw, definition)) {
42
45
  definition.feedback.target.chatType ??= 'private';
43
46
  migrations.push('legacy-aun-target-chat-type');
@@ -99,11 +102,6 @@ export class TriggerDefinitionManager {
99
102
  }, { now: Date.now() });
100
103
  assertExplicitAunDeliveryRoutes(updated);
101
104
  this.assertAgent(updated);
102
- if (existing.execution.baseagent !== updated.execution.baseagent) {
103
- if (existing.execution.type !== 'trigger_session' || updated.execution.type !== 'trigger_session') {
104
- throw new Error('execution.baseagent is only mutable between trigger_session Triggers');
105
- }
106
- }
107
105
  updated.createdAt = existing.createdAt;
108
106
  updated.updatedAt = Date.now();
109
107
  this.assertUnique(updated, triggerId);
@@ -4,7 +4,7 @@ const TRIGGER_UPDATE_FLAGS = new Set([
4
4
  'prompt', 'name', 'description',
5
5
  'script-file', 'script-runtime', 'script-args', 'script-timeout', 'execution-timeout',
6
6
  'feedback', 'target-channel', 'target-channel-id', 'target-chat-type', 'target-session', 'target-thread-id',
7
- 'trigger-thread', 'baseagent',
7
+ 'trigger-thread',
8
8
  'on-error', 'noop-sentinel', 'retry-attempts', 'retry-backoff',
9
9
  'model', 'effort', 'permission',
10
10
  'max-runs', 'max-duration', 'concurrency', 'missed-policy',
@@ -14,7 +14,7 @@ const TRIGGER_CREATE_FLAGS = new Set([
14
14
  'exec', 'prompt', 'name', 'description', 'agent', 'label',
15
15
  'script-path', 'script-runtime', 'script-args', 'script-timeout', 'execution-timeout',
16
16
  'feedback', 'target-channel', 'target-channel-id', 'target-chat-type', 'target-session', 'target-thread-id',
17
- 'trigger-thread', 'baseagent',
17
+ 'trigger-thread',
18
18
  'model', 'effort', 'permission', 'max-runs', 'max-duration',
19
19
  ]);
20
20
  // Note: unquoted multi-word values (e.g. --prompt=hello world) are not supported.
@@ -198,14 +198,6 @@ function parseModelFlag(flags) {
198
198
  return { ok: false, error: '--model 不能为空' };
199
199
  return { ok: true, value: raw };
200
200
  }
201
- function parseBaseagentFlag(flags) {
202
- if (!flags.has('baseagent'))
203
- return { ok: true };
204
- const raw = flags.get('baseagent');
205
- if (!raw || raw === true || !raw.trim())
206
- return { ok: false, error: '--baseagent 不能为空' };
207
- return { ok: true, value: raw.trim() };
208
- }
209
201
  function parseEffortFlag(flags) {
210
202
  if (!flags.has('effort'))
211
203
  return { ok: true };
@@ -218,6 +210,8 @@ function parseEffortFlag(flags) {
218
210
  return { ok: true, value: raw };
219
211
  }
220
212
  function rejectDeprecatedFlags(flags) {
213
+ if (flags.has('baseagent'))
214
+ return '--baseagent 已移除;Trigger 使用所属 Agent 当前的 baseagent';
221
215
  if (flags.has('mode'))
222
216
  return '--mode 已废弃,请使用 --exec script|trigger-session|target-session';
223
217
  if (flags.has('session'))
@@ -423,9 +417,6 @@ function commonParsed(flags, opts = {}) {
423
417
  const model = parseModelFlag(flags);
424
418
  if (!model.ok)
425
419
  return model;
426
- const baseagent = parseBaseagentFlag(flags);
427
- if (!baseagent.ok)
428
- return baseagent;
429
420
  const effort = parseEffortFlag(flags);
430
421
  if (!effort.ok)
431
422
  return effort;
@@ -491,9 +482,6 @@ function commonParsed(flags, opts = {}) {
491
482
  // 全部交给 patch/validation 按现有定义执行。
492
483
  const inferredExecution = execution.value;
493
484
  if (!opts.update) {
494
- if (baseagent.value && inferredExecution !== 'trigger_session') {
495
- return { ok: false, error: '--baseagent 仅适用于 --exec trigger-session' };
496
- }
497
485
  if (inferredExecution === 'script') {
498
486
  if (!scriptPath)
499
487
  return { ok: false, error: '--exec script 需要 --script-path' };
@@ -537,7 +525,6 @@ function commonParsed(flags, opts = {}) {
537
525
  scriptTimeoutMs: scriptTimeout.value,
538
526
  executionTimeoutMs: executionTimeout.value,
539
527
  triggerThread: triggerThread.value,
540
- baseagent: baseagent.value,
541
528
  maxRuns: maxRuns.value,
542
529
  maxDuration: maxDuration.value,
543
530
  model: model.value,
@@ -582,7 +569,6 @@ export function parseTriggerSet(args) {
582
569
  scriptTimeoutMs: value.scriptTimeoutMs,
583
570
  executionTimeoutMs: value.executionTimeoutMs,
584
571
  triggerThread: value.triggerThread,
585
- baseagent: value.baseagent,
586
572
  maxRuns: value.maxRuns,
587
573
  maxDuration: value.maxDuration,
588
574
  model: value.model,
@@ -629,7 +615,6 @@ export function parseTriggerSetArgv(args, opts = {}) {
629
615
  scriptTimeoutMs: value.scriptTimeoutMs,
630
616
  executionTimeoutMs: value.executionTimeoutMs,
631
617
  triggerThread: value.triggerThread,
632
- baseagent: value.baseagent,
633
618
  maxRuns: value.maxRuns,
634
619
  maxDuration: value.maxDuration,
635
620
  model: value.model,
@@ -790,8 +775,6 @@ function parseTriggerUpdateFlags(nameOrId, flags, opts = {}) {
790
775
  update.targetThreadId = value.targetThreadId;
791
776
  if (value.triggerThread !== undefined)
792
777
  update.triggerThread = value.triggerThread;
793
- if (value.baseagent !== undefined)
794
- update.baseagent = value.baseagent;
795
778
  const onError = optionalFlagString(flags, 'on-error');
796
779
  if ('error' in onError)
797
780
  return { ok: false, error: onError.error };
@@ -21,7 +21,6 @@ const PATCH_KEYS = new Set([
21
21
  'targetChatType',
22
22
  'targetSession',
23
23
  'targetThreadId',
24
- 'baseagent',
25
24
  'triggerThread',
26
25
  'onError',
27
26
  'noopSentinel',
@@ -126,12 +125,6 @@ export function applyTriggerPatch(definition, input, opts = {}) {
126
125
  updated.feedback.strategy = 'target';
127
126
  }
128
127
  // execution fields
129
- if (patch.baseagent !== undefined) {
130
- if (updated.execution.type !== 'trigger_session') {
131
- throw new Error('baseagent 仅适用于 trigger_session 类型');
132
- }
133
- setOptional(updated.execution, 'baseagent', patch.baseagent);
134
- }
135
128
  if (patch.triggerThread !== undefined)
136
129
  setOptional(updated.execution, 'thread', patch.triggerThread);
137
130
  if (patch.onError !== undefined)
@@ -188,6 +181,9 @@ export function replaceEditableTriggerDefinition(existing, input) {
188
181
  throw new Error('trigger definition update must be an object');
189
182
  }
190
183
  const editable = input;
184
+ if (editable.execution && typeof editable.execution === 'object' && 'baseagent' in editable.execution) {
185
+ throw new Error('execution.baseagent is no longer supported; Trigger uses its owning Agent baseagent');
186
+ }
191
187
  const replacement = normalizeTriggerDefinition({
192
188
  ...editable,
193
189
  $schema_version: TRIGGER_SCHEMA_VERSION,
@@ -198,16 +194,8 @@ export function replaceEditableTriggerDefinition(existing, input) {
198
194
  updatedAt: existing.updatedAt,
199
195
  origin: existing.origin,
200
196
  });
201
- assertBaseagentImmutable(existing, replacement);
202
197
  return replacement;
203
198
  }
204
- function assertBaseagentImmutable(existing, updated) {
205
- if (existing.execution.baseagent !== updated.execution.baseagent) {
206
- if (existing.execution.type !== 'trigger_session' || updated.execution.type !== 'trigger_session') {
207
- throw new Error('execution.baseagent is only mutable between trigger_session Triggers');
208
- }
209
- }
210
- }
211
199
  function applySourcePatch(updated, patch) {
212
200
  const previous = updated.source;
213
201
  if (patch.scheduleType !== undefined || patch.scheduleValue !== undefined) {
@@ -284,6 +284,27 @@ export class TriggerRuntimeScheduler {
284
284
  cancel(triggerId) {
285
285
  return this.setEnabled(triggerId, false);
286
286
  }
287
+ activeRunTriggerId(runId) {
288
+ for (const [triggerId, runs] of this.running) {
289
+ if (runs.has(runId))
290
+ return triggerId;
291
+ }
292
+ return undefined;
293
+ }
294
+ async cancelRun(runId) {
295
+ const triggerId = this.activeRunTriggerId(runId);
296
+ if (!triggerId)
297
+ throw new Error(`Trigger run is not active: ${runId}`);
298
+ this.manager.require(triggerId);
299
+ const runtime = this.running.get(triggerId)?.get(runId);
300
+ if (!runtime)
301
+ throw new Error(`Trigger run is not active: ${runId}`);
302
+ await this.terminateRun(runId, runtime, {
303
+ reason: 'cancelled',
304
+ message: 'Trigger run cancelled by operator',
305
+ });
306
+ return { triggerId, runId, status: 'interrupted' };
307
+ }
287
308
  delete(triggerId) {
288
309
  const definition = this.manager.require(triggerId);
289
310
  this.clearTimer(triggerId);
@@ -614,8 +635,8 @@ export class TriggerRuntimeScheduler {
614
635
  ok: false,
615
636
  runId,
616
637
  triggerId: definition.id,
617
- status: 'failed',
618
- reason,
638
+ status: runningRuntime?.termination?.reason === 'cancelled' ? 'interrupted' : 'failed',
639
+ reason: runningRuntime?.termination?.reason === 'cancelled' ? 'cancelled' : reason,
619
640
  };
620
641
  }
621
642
  if (!payload.dryRun) {
@@ -665,8 +686,8 @@ export class TriggerRuntimeScheduler {
665
686
  ok: false,
666
687
  runId,
667
688
  triggerId: definition.id,
668
- status: 'failed',
669
- reason,
689
+ status: runningRuntime?.termination?.reason === 'cancelled' ? 'interrupted' : 'failed',
690
+ reason: runningRuntime?.termination?.reason === 'cancelled' ? 'cancelled' : reason,
670
691
  };
671
692
  }
672
693
  const audit = this.buildAudit({
@@ -727,8 +748,8 @@ export class TriggerRuntimeScheduler {
727
748
  ok: false,
728
749
  runId,
729
750
  triggerId: definition.id,
730
- status: 'failed',
731
- reason,
751
+ status: runningRuntime?.termination?.reason === 'cancelled' ? 'interrupted' : 'failed',
752
+ reason: runningRuntime?.termination?.reason === 'cancelled' ? 'cancelled' : reason,
732
753
  error: message,
733
754
  };
734
755
  }
@@ -980,8 +1001,7 @@ export class TriggerRuntimeScheduler {
980
1001
  return { branch: branchFromReply(reply), script: null, processing, reply };
981
1002
  }
982
1003
  try {
983
- const runtimeBaseagent = definition.execution.baseagent
984
- ?? this.runtime.getBaseagent?.()
1004
+ const runtimeBaseagent = this.runtime.getBaseagent?.()
985
1005
  ?? this.runtime.baseagent;
986
1006
  const originPath = causation.trigger?.path ?? [];
987
1007
  logger.info(`[Trigger] execution context triggerId=${definition.id}`
@@ -1170,6 +1190,8 @@ export class TriggerRuntimeScheduler {
1170
1190
  logger.warn(`[Trigger] resumable session unavailable: trigger=${definition.id} run=${run.runId} session=${run.executionSessionId}`);
1171
1191
  return false;
1172
1192
  }
1193
+ if (session.baseagent !== (this.runtime.getBaseagent?.() ?? this.runtime.baseagent))
1194
+ return false;
1173
1195
  const entered = enterTrigger(undefined, definition.id, run.runId);
1174
1196
  if (!entered.ok)
1175
1197
  return false;
@@ -1414,6 +1436,9 @@ export class TriggerRuntimeScheduler {
1414
1436
  async runRecoveredExecutionAttempt(definition, runtime, session) {
1415
1437
  const { run, source, controller, causation } = runtime;
1416
1438
  try {
1439
+ if (session.baseagent !== (this.runtime.getBaseagent?.() ?? this.runtime.baseagent)) {
1440
+ throw new Error('Trigger session baseagent no longer matches its owning Agent');
1441
+ }
1417
1442
  const daemonReply = await this.daemonChannel.converse(TRIGGER_RESTART_RESUME_PROMPT, {
1418
1443
  trigger: definition,
1419
1444
  runId: run.runId,
@@ -1780,7 +1805,7 @@ export class TriggerRuntimeScheduler {
1780
1805
  definition: runtime.definition,
1781
1806
  runId,
1782
1807
  startedAt: runtime.run.startedAt,
1783
- status: 'failed',
1808
+ status: termination.reason === 'cancelled' ? 'interrupted' : 'failed',
1784
1809
  reason: termination.reason,
1785
1810
  source: runtime.source,
1786
1811
  script: null,
@@ -1795,7 +1820,7 @@ export class TriggerRuntimeScheduler {
1795
1820
  this.audit.write(audit);
1796
1821
  this.publishTriggerRunOutcome(runtime.definition, audit);
1797
1822
  recordCausationSpan(runtime.causation, 'trigger.run', {
1798
- status: 'failed',
1823
+ status: termination.reason === 'cancelled' ? 'interrupted' : 'failed',
1799
1824
  refs: { triggerId: runtime.definition.id, runId },
1800
1825
  reason: termination.reason,
1801
1826
  });
@@ -1957,6 +1982,16 @@ export class TriggerRuntimeScheduler {
1957
1982
  });
1958
1983
  return;
1959
1984
  }
1985
+ if (audit.status === 'interrupted') {
1986
+ this.eventBus.publish({
1987
+ type: 'trigger:interrupted',
1988
+ ...base,
1989
+ messageId: this.triggerOutcomeMessageId(audit),
1990
+ reason: audit.reason ?? 'interrupted',
1991
+ error: audit.error?.message ?? audit.reason ?? 'trigger interrupted',
1992
+ });
1993
+ return;
1994
+ }
1960
1995
  if (audit.status === 'skipped') {
1961
1996
  this.eventBus.publish({
1962
1997
  type: 'trigger:skipped',
@@ -486,7 +486,6 @@ function normalizeExecution(value, _opts) {
486
486
  prompt: type === 'script' ? optionalString(raw.prompt) : requiredString(raw.prompt, 'execution.prompt'),
487
487
  script: type === 'script' ? normalizeScript(raw.script) : undefined,
488
488
  thread: type === 'trigger_session' ? (thread ?? 'by_trigger') : thread,
489
- baseagent: normalizeExecutionBaseagent(raw.baseagent),
490
489
  model: optionalString(raw.model),
491
490
  effort: normalizeEffort(raw.effort),
492
491
  permissionMode: normalizeTriggerPermissionMode(raw.permissionMode),
@@ -517,14 +516,6 @@ function normalizeMemoryScope(value) {
517
516
  }
518
517
  return value;
519
518
  }
520
- function normalizeExecutionBaseagent(value) {
521
- if (value === undefined)
522
- return undefined;
523
- if (typeof value !== 'string' || !value.trim()) {
524
- throw new Error('execution.baseagent must be a non-empty string');
525
- }
526
- return value.trim();
527
- }
528
519
  function normalizeExecutionThread(value) {
529
520
  const thread = optionalString(value);
530
521
  if (thread === undefined)
@@ -728,8 +719,6 @@ function validateTriggerSemantics(definition) {
728
719
  throw new Error('execution.prompt is not allowed when execution.type=script');
729
720
  if (execution.thread !== undefined)
730
721
  throw new Error('execution.thread is not allowed when execution.type=script');
731
- if (execution.baseagent !== undefined)
732
- throw new Error('execution.baseagent is only allowed when execution.type=trigger_session');
733
722
  }
734
723
  if (execution.type === 'trigger_session') {
735
724
  if (!execution.prompt)
@@ -744,8 +733,6 @@ function validateTriggerSemantics(definition) {
744
733
  throw new Error('execution.script is not allowed when execution.type=target_session');
745
734
  if (execution.thread !== undefined)
746
735
  throw new Error('execution.thread is not allowed when execution.type=target_session');
747
- if (execution.baseagent !== undefined)
748
- throw new Error('execution.baseagent is only allowed when execution.type=trigger_session');
749
736
  if (definition.feedback.strategy === 'silent')
750
737
  throw new Error('feedback.strategy=silent is not allowed when execution.type=target_session');
751
738
  }
@@ -99,6 +99,7 @@ export var ErrorType;
99
99
  ErrorType["STREAM_ERROR"] = "stream_error";
100
100
  ErrorType["MAX_OUTPUT_TOKENS"] = "max_output_tokens";
101
101
  ErrorType["CONTEXT_TOO_LONG"] = "context_too_long";
102
+ ErrorType["COMPACTION_FAILED"] = "compaction_failed";
102
103
  ErrorType["MODEL_UNAVAILABLE"] = "model_unavailable";
103
104
  ErrorType["SESSION_UNAVAILABLE"] = "session_unavailable";
104
105
  ErrorType["SANDBOX_INITIALIZATION_FAILED"] = "sandbox_initialization_failed";
@@ -493,6 +494,9 @@ export function classifyError(error) {
493
494
  if (error?.code === 'TOPIC_BACKEND_UNAVAILABLE') {
494
495
  return ErrorType.SESSION_UNAVAILABLE;
495
496
  }
497
+ if (msg.includes('summarization failed') || msg.includes('turn prefix summarization failed')) {
498
+ return ErrorType.COMPACTION_FAILED;
499
+ }
496
500
  // Startup-size failures are deterministic local failures and must win over
497
501
  // dictionary rules that would otherwise turn them into generic retries.
498
502
  if (isClaudeStartupArgumentsTooLong(error)) {
@@ -559,6 +563,8 @@ export function isRetryableError(error) {
559
563
  const lower = msg.toLowerCase();
560
564
  if (lower.includes('invalid jsonl session file') || lower.includes('invalid session file'))
561
565
  return false;
566
+ if (lower.includes('summarization failed') || lower.includes('turn prefix summarization failed'))
567
+ return false;
562
568
  if (lower.includes('context_compact_failed') || isContextTooLongText(getErrorRawText(error)))
563
569
  return false;
564
570
  // The idle watchdog emits this exact terminal error when a runner stops
@@ -640,6 +646,8 @@ export function getErrorMessage(error, terminalReason, includeEmoji = true) {
640
646
  return `${warnPrefix}API 限流中,请稍后重试`;
641
647
  case 'context_compact_failed':
642
648
  return `${warnPrefix}上下文过长,自动压缩失败,请手动输入 /compact 重试`;
649
+ case ErrorType.COMPACTION_FAILED:
650
+ return `${warnPrefix}会话压缩的摘要请求失败,已停止自动重试以避免重复压缩;检查模型网关后可重试`;
643
651
  case 'model_error':
644
652
  return `${prefix}模型服务异常,请稍后重试`;
645
653
  case 'tool_error':
@@ -110,6 +110,37 @@ export function configureMacosAutostart(enabled, runtimeRoot) {
110
110
  }
111
111
  const file = plistPath();
112
112
  if (!enabled) {
113
+ try {
114
+ const stat = fs.lstatSync(file);
115
+ if (!stat.isFile() || stat.isSymbolicLink()) {
116
+ return { ok: false, enabled: true, error: `登录自启配置不是普通文件,已保留: ${file}` };
117
+ }
118
+ const read = spawnSync('/usr/bin/plutil', ['-convert', 'json', '-o', '-', file], { encoding: 'utf8', timeout: 15_000 });
119
+ if (read.status !== 0) {
120
+ return { ok: false, enabled: true, error: commandError(read, '无法校验 macOS 登录自启归属,已保留配置') };
121
+ }
122
+ const plist = JSON.parse(read.stdout);
123
+ const args = plist.ProgramArguments;
124
+ if (plist.Label !== MACOS_AUTOSTART_LABEL
125
+ || typeof plist.EnvironmentVariables?.EVOLCORE_HOME !== 'string'
126
+ || path.resolve(plist.EnvironmentVariables.EVOLCORE_HOME) !== path.resolve(runtimeRoot)
127
+ || !Array.isArray(args) || args.length !== 4
128
+ || args[1] !== '--no-warnings=ExperimentalWarning'
129
+ || typeof args[2] !== 'string'
130
+ || path.resolve(args[2]) !== path.join(getPackageRoot(), 'dist', 'cli', 'index.js')
131
+ || args[3] !== 'start') {
132
+ return { ok: true, enabled: false, warning: `同名 LaunchAgent 不属于当前 EvolCore 安装或运行目录,已保留: ${file}` };
133
+ }
134
+ }
135
+ catch (error) {
136
+ if (error?.code === 'ENOENT') {
137
+ if (macosAutostartInstalled()) {
138
+ return { ok: false, enabled: true, error: 'LaunchAgent 正在运行但 plist 缺失,无法核验归属,已保留。' };
139
+ }
140
+ return { ok: true, enabled: false };
141
+ }
142
+ return { ok: false, enabled: true, error: `校验 macOS 登录自启归属失败,已保留配置: ${error instanceof Error ? error.message : String(error)}` };
143
+ }
113
144
  const result = launchctl(['bootout', `${domain}/${MACOS_AUTOSTART_LABEL}`]);
114
145
  if (result.status !== 0 && macosAutostartInstalled()) {
115
146
  return {
@@ -1,16 +1,23 @@
1
+ {"model":"claude-opus-5-5","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":4,"price_output":20,"price_cache_creation":5,"price_cache_read":0.2,"context_window":1000000,"max_input_tokens":900000,"max_output_tokens":131072,"supports_cache":true,"supports_vision":true}
2
+ {"model":"claude-sonnet-5-5","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":2,"price_output":10,"price_cache_creation":2.5,"price_cache_read":0.1,"context_window":1000000,"max_input_tokens":900000,"max_output_tokens":131072,"supports_cache":true,"supports_vision":true}
3
+ {"model":"claude-haiku-5-5","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":0.1,"price_output":0.5,"price_cache_creation":0.125,"price_cache_read":0.01,"context_window":1000000,"max_input_tokens":900000,"max_output_tokens":131072,"supports_cache":true,"supports_vision":true}
4
+ {"model":"claude-fable-5-1","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":10,"price_output":50,"price_cache_creation":12.5,"price_cache_read":1,"context_window":1000000,"max_input_tokens":900000,"max_output_tokens":131072,"supports_cache":true,"supports_vision":true}
1
5
  {"model":"claude-opus-4-8","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":15,"price_output":75,"price_cache_creation":18.75,"price_cache_read":1.5,"context_window":1000000,"max_input_tokens":900000,"max_output_tokens":32768,"supports_cache":true,"supports_vision":true}
2
6
  {"model":"claude-opus-4-7","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":15,"price_output":75,"price_cache_creation":18.75,"price_cache_read":1.5,"context_window":1000000,"max_input_tokens":900000,"max_output_tokens":32768,"supports_cache":true,"supports_vision":true}
3
7
  {"model":"claude-opus-4-6","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":15,"price_output":75,"price_cache_creation":18.75,"price_cache_read":1.5,"context_window":1000000,"max_input_tokens":900000,"max_output_tokens":32768,"supports_cache":true,"supports_vision":true}
4
8
  {"model":"claude-sonnet-4-6","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":3,"price_output":15,"price_cache_creation":3.75,"price_cache_read":0.3,"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384,"supports_cache":true,"supports_vision":true}
5
9
  {"model":"claude-haiku-4-5-20251001","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":0.8,"price_output":4,"price_cache_creation":1,"price_cache_read":0.08,"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384,"supports_cache":true,"supports_vision":false}
6
- {"model":"gpt-5.6-sol","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":5,"price_output":30,"price_cache_creation":6.25,"price_cache_read":0.5,"tiers":[{"up_to_input_tokens":272000,"price_input":5,"price_output":30,"price_cache_creation":6.25,"price_cache_read":0.5},{"up_to_input_tokens":null,"price_input":10,"price_output":45,"price_cache_creation":12.5,"price_cache_read":1}],"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384}
7
- {"model":"gpt-5.6-terra","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":2.5,"price_output":15,"price_cache_creation":3.125,"price_cache_read":0.25,"tiers":[{"up_to_input_tokens":272000,"price_input":2.5,"price_output":15,"price_cache_creation":3.125,"price_cache_read":0.25},{"up_to_input_tokens":null,"price_input":5,"price_output":22.5,"price_cache_creation":6.25,"price_cache_read":0.5}],"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384}
8
- {"model":"gpt-5.6-luna","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":1,"price_output":6,"price_cache_creation":1.25,"price_cache_read":0.1,"tiers":[{"up_to_input_tokens":272000,"price_input":1,"price_output":6,"price_cache_creation":1.25,"price_cache_read":0.1},{"up_to_input_tokens":null,"price_input":2,"price_output":9,"price_cache_creation":2.5,"price_cache_read":0.2}],"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384}
9
- {"model":"gpt-5.5","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":5,"price_output":30,"price_cache_creation":0,"price_cache_read":0.5,"tiers":[{"up_to_input_tokens":272000,"price_input":5,"price_output":30,"price_cache_creation":0,"price_cache_read":0.5},{"up_to_input_tokens":null,"price_input":10,"price_output":45,"price_cache_creation":0,"price_cache_read":1}],"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384}
10
- {"model":"gpt-5.4","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":2.5,"price_output":15,"price_cache_creation":0,"price_cache_read":0.25,"tiers":[{"up_to_input_tokens":272000,"price_input":2.5,"price_output":15,"price_cache_creation":0,"price_cache_read":0.25},{"up_to_input_tokens":null,"price_input":5,"price_output":22.5,"price_cache_creation":0,"price_cache_read":0.5}],"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384}
11
- {"model":"gpt-5.3-codex","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":1.75,"price_output":14,"price_cache_creation":0,"price_cache_read":0.175,"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384}
12
- {"model":"deepseek-v4-pro","effective_from":0,"billing_fn":"per_token_deepseek_v1","currency":"CNY","price_cache_hit":0.5,"price_cache_miss":2,"price_output":8,"context_window":1000000,"max_input_tokens":950000,"max_output_tokens":8192,"supports_cache":true}
13
- {"model":"deepseek-v4-flash","effective_from":0,"billing_fn":"per_token_deepseek_v1","currency":"CNY","price_cache_hit":0.1,"price_cache_miss":0.5,"price_output":2,"context_window":1000000,"max_input_tokens":950000,"max_output_tokens":8192,"supports_cache":true}
10
+ {"model":"gpt-6.1-sol","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":2,"price_output":10,"price_cache_creation":0,"price_cache_read":0.1,"context_window":1050000,"max_input_tokens":1000000,"max_output_tokens":32768,"supports_cache":true}
11
+ {"model":"gpt-6.1-terra","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":1,"price_output":5,"price_cache_creation":0,"price_cache_read":0.05,"context_window":1050000,"max_input_tokens":1000000,"max_output_tokens":32768,"supports_cache":true}
12
+ {"model":"gpt-6-astra","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":10,"price_output":50,"price_cache_creation":12.5,"price_cache_read":1,"context_window":1050000,"max_input_tokens":1000000,"max_output_tokens":32768,"supports_cache":true}
13
+ {"model":"gpt-5.6-sol","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":4,"price_output":20,"price_cache_creation":5,"price_cache_read":0.4,"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384,"supports_cache":true}
14
+ {"model":"gpt-5.6-cyber","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":12.5,"price_output":75,"price_cache_creation":15.625,"price_cache_read":1.25,"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384,"supports_cache":true}
15
+ {"model":"chat-latest","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":5,"price_output":30,"price_cache_creation":0,"price_cache_read":0.5,"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384,"supports_cache":true}
16
+ {"model":"gpt-5.3-codex","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":1.75,"price_output":14,"price_cache_creation":0,"price_cache_read":0.175,"context_window":200000,"max_input_tokens":180000,"max_output_tokens":16384,"supports_cache":true}
17
+ {"model":"gpt-rosalind-research","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":5,"price_output":25,"price_cache_creation":0,"price_cache_read":0.5,"context_window":128000,"max_input_tokens":120000,"max_output_tokens":8192,"supports_cache":true}
18
+ {"model":"gpt-rosalind-discovery","effective_from":0,"billing_fn":"per_token_v1","currency":"USD","price_input":5,"price_output":25,"price_cache_creation":0,"price_cache_read":0.5,"context_window":128000,"max_input_tokens":120000,"max_output_tokens":8192,"supports_cache":true}
19
+ {"model":"deepseek-v4-pro","effective_from":0,"billing_fn":"per_token_deepseek_v1","currency":"CNY","price_cache_hit":0.022,"price_cache_miss":0.66,"price_output":1.98,"context_window":1000000,"max_input_tokens":950000,"max_output_tokens":8192,"supports_cache":true,"notes":"off-peak rates, peak 2x"}
20
+ {"model":"deepseek-v4.1-flash","effective_from":0,"billing_fn":"per_token_deepseek_v1","currency":"CNY","price_cache_hit":0.015,"price_cache_miss":0.15,"price_output":0.6,"context_window":1000000,"max_input_tokens":950000,"max_output_tokens":8192,"supports_cache":true,"notes":"off-peak rates, peak 2x"}
14
21
  {"model":"deepseek-v3.2","effective_from":0,"billing_fn":"per_token_deepseek_v1","currency":"CNY","price_cache_hit":0.5,"price_cache_miss":2,"price_output":8,"context_window":128000,"max_input_tokens":120000,"max_output_tokens":8192,"supports_cache":true}
15
22
  {"model":"kimi-k2.6","effective_from":0,"billing_fn":"per_token_v1","currency":"CNY","price_input":2,"price_output":8,"price_cache_creation":0,"price_cache_read":0,"context_window":128000,"max_input_tokens":120000,"max_output_tokens":8192}
16
23
  {"model":"kimi-k2.5","effective_from":0,"billing_fn":"per_token_v1","currency":"CNY","price_input":2,"price_output":8,"price_cache_creation":0,"price_cache_read":0,"context_window":128000,"max_input_tokens":120000,"max_output_tokens":8192}