evolcore 0.0.43-test.2 → 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.
- package/CHANGELOG.md +44 -1
- package/bin/ecmsg.js +229 -0
- package/bin/install-codex-managed-hooks.mjs +130 -8
- package/dist/ability/application-service.js +37 -0
- package/dist/ability/resources.js +28 -0
- package/dist/ability/runtime.js +6 -1
- package/dist/agents/claude-runner.js +7 -5
- package/dist/agents/codex/app-server-client.js +0 -12
- package/dist/agents/codex-runner.js +0 -37
- package/dist/agents/ecagent-runner.js +138 -36
- package/dist/aun/aid/agentmd.js +52 -13
- package/dist/aun/menu/client.js +8 -7
- package/dist/aun/menu/index.js +1 -1
- package/dist/aun/menu/transport.js +8 -5
- package/dist/aun/msg/p2p.js +4 -2
- package/dist/aun/service-proxy.js +3 -0
- package/dist/channels/aun.js +105 -53
- package/dist/channels/daemon.js +14 -2
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +31 -11
- package/dist/cli/agent.js +9 -3
- package/dist/cli/aun-commands.js +19 -21
- package/dist/cli/daemon-commands.js +30 -18
- package/dist/cli/directory.js +98 -56
- package/dist/cli/getmeta-command.js +2 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/init.js +13 -5
- package/dist/cli/peer.js +2 -1
- package/dist/cli/task-context.js +3 -1
- package/dist/cli/trigger-command.js +20 -14
- package/dist/config/access-policy.js +0 -1
- package/dist/config/boot-log.js +12 -2
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +7 -0
- package/dist/config/config-manager.js +30 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +25 -1
- package/dist/config/role-service.js +9 -4
- package/dist/config/role-store.js +30 -8
- package/dist/config/schema-migration.js +121 -0
- package/dist/core/agent-application-service.js +11 -0
- package/dist/core/agent-ipc-registration.js +2 -0
- package/dist/core/agent-runtime.js +41 -9
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/operation-authorizer.js +19 -1
- package/dist/core/auth/operation-catalog.js +12 -2
- package/dist/core/baseagent-loader.js +11 -3
- package/dist/core/bootstrap-service.js +8 -0
- package/dist/core/channel-loader.js +61 -23
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +5 -2
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/chatmode-config.js +46 -0
- package/dist/core/command/command-handler.js +44 -17
- package/dist/core/command/daemon-diagnostics.js +2 -1
- package/dist/core/command/menu-catalog.js +14 -1
- package/dist/core/command/menu-handler.js +74 -24
- package/dist/core/command/menu-protocol.js +8 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +52 -47
- package/dist/core/daemon-lifecycle.js +43 -17
- package/dist/core/event-catalog.js +19 -0
- package/dist/core/evolagent-registry.js +3 -0
- package/dist/core/evolagent.js +5 -4
- package/dist/core/ipc-registration.js +6 -0
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/message/aun-ipc-sender.js +30 -24
- package/dist/core/message/contact-admission.js +1 -19
- package/dist/core/message/im-renderer.js +81 -40
- package/dist/core/message/message-admission.js +21 -62
- package/dist/core/message/message-bridge.js +18 -5
- package/dist/core/message/message-utils.js +9 -0
- package/dist/core/message/peer-mode.js +16 -8
- package/dist/core/message/response-engine.js +67 -47
- package/dist/core/model/model-capabilities.js +37 -0
- package/dist/core/model/model-catalog.js +6 -2
- package/dist/core/ownership/owner-resolver.js +74 -36
- package/dist/core/permission/ec-command-parser.js +62 -13
- package/dist/core/plugin-lifecycle.js +6 -2
- package/dist/core/relation/pa-team.js +132 -0
- package/dist/core/role/runtime-policy.js +4 -3
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/owner-directory-admission.js +0 -3
- package/dist/directory/owner-directory-cache.js +201 -17
- package/dist/directory/owner-directory-markdown.js +44 -21
- package/dist/directory/owner-directory-policy.js +1 -1
- package/dist/directory/owner-directory-query-operation.js +218 -98
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +76 -23
- package/dist/directory/owner-directory-store.js +5 -38
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +6 -3
- package/dist/eck/message-renderer.js +2 -5
- package/dist/ecweb/message-context-service.js +4 -0
- package/dist/ecweb/runtime/lifecycle.js +29 -5
- package/dist/ecweb/runtime/supervisor.js +83 -27
- package/dist/index.js +209 -38
- package/dist/paths.js +4 -2
- package/dist/product.js +1 -0
- package/dist/proxy/service-supervisor.js +377 -141
- package/dist/response-system/engines/v1/index.js +2 -4
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/trigger/audit.js +3 -2
- package/dist/trigger/authorization.js +2 -3
- package/dist/trigger/history.js +4 -3
- package/dist/trigger/ipc-service.js +24 -19
- package/dist/trigger/manager.js +3 -5
- package/dist/trigger/parser.js +4 -21
- package/dist/trigger/patch.js +3 -15
- package/dist/trigger/scheduler.js +53 -13
- package/dist/trigger/validation.js +0 -13
- package/dist/utils/error-utils.js +15 -5
- package/dist/utils/macos-autostart.js +31 -0
- package/dist/utils/model-prices.jsonl +15 -8
- package/dist/utils/process-introspect.js +21 -1
- package/dist/utils/startup-trace.js +7 -1
- package/dist/utils/windows-autostart.js +1 -0
- package/ecagent/README.md +18 -0
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/branch-summarization.js +1 -1
- package/ecagent/dist/harness/compaction/compaction.js +7 -4
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +5 -2
- package/kits/docs/evolcore/directory.md +125 -35
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +279 -0
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +5 -3
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +4 -2
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +1 -1
- package/kits/docs/evolcore/tool-authorization.md +4 -1
- package/kits/docs/evolcore/trigger.md +10 -7
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/eck_manifest.json +6 -23
- package/kits/eck_manifest.memory.json +26 -1
- package/kits/rules/01-overview.md +42 -44
- package/kits/rules/02-navigation.md +44 -53
- package/kits/rules/03-identity.md +21 -25
- package/kits/rules/04-relation.md +23 -33
- package/kits/rules/05-venue.md +24 -25
- package/kits/schemas/_meta.json +10 -10
- package/kits/schemas/agent-config.schema.19.json +10 -6
- package/kits/schemas/relation-config.schema.12.json +2 -2
- package/kits/schemas/role-config.schema.2.json +5 -5
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/skills/ec-service-proxy/SKILL.md +10 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/soul/00-GUIDE.md +20 -42
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/directory-contacts.md +1 -1
- package/kits/templates/system-fragments/identity.md +0 -1
- package/kits/templates/system-fragments/personal-assistant.md +2 -17
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +18 -13
- package/dist/eck/paactive-context.js +0 -45
- package/dist/response-system/engines/v1/paactive-flow.js +0 -18
- package/kits/eck_manifest.paactive.json +0 -528
- package/kits/eck_message_manifest.paactive.json +0 -233
- package/kits/templates/message-fragments/paactive/item.md +0 -3
- package/kits/templates/system-fragments/paactive/channel.md +0 -25
- package/kits/templates/system-fragments/paactive/reply.md +0 -25
- package/kits/templates/system-fragments/paactive/session.md +0 -32
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* V1 引擎 —— 单会话处理行为的载体。
|
|
3
3
|
*
|
|
4
|
-
* 对外只暴露 flowForChatMode:按 chatMode
|
|
4
|
+
* 对外只暴露 flowForChatMode:按 chatMode 取对应执行流(interactive / proactive)。
|
|
5
5
|
* chatMode 分流收拢于此,模式层(modes/single-session)与调用方不再散布分支。
|
|
6
6
|
*/
|
|
7
7
|
import { interactiveFlow } from './interactive-flow.js';
|
|
8
8
|
import { proactiveFlow } from './proactive-flow.js';
|
|
9
|
-
import { paactiveFlow } from './paactive-flow.js';
|
|
10
9
|
const FLOWS = {
|
|
11
10
|
interactive: interactiveFlow,
|
|
12
11
|
proactive: proactiveFlow,
|
|
13
|
-
paactive:
|
|
12
|
+
paactive: interactiveFlow,
|
|
14
13
|
};
|
|
15
14
|
/** 按 chatMode 取处理流。 */
|
|
16
15
|
export function flowForChatMode(chatMode) {
|
|
@@ -21,4 +20,3 @@ export function flowForChatMode(chatMode) {
|
|
|
21
20
|
}
|
|
22
21
|
export { interactiveFlow } from './interactive-flow.js';
|
|
23
22
|
export { proactiveFlow } from './proactive-flow.js';
|
|
24
|
-
export { paactiveFlow } from './paactive-flow.js';
|
|
@@ -16,7 +16,7 @@ import { isChatMode } from '../../../core/message/peer-mode.js';
|
|
|
16
16
|
* 单会话响应模式(architecture.md §4.1)—— 合并原 interactive / proactive。
|
|
17
17
|
*
|
|
18
18
|
* 本层是薄包装:不含处理行为,全部钩子委托 V1 引擎的 flow。chatMode 决定用哪个
|
|
19
|
-
* flow(interactive / proactive
|
|
19
|
+
* flow(interactive / proactive;paactive 复用 interactive),取值来自 modeConfig.chatMode(宿主按配置层级
|
|
20
20
|
* 解析后注入,见 implementation-plan.md §三;无 auto 值)。
|
|
21
21
|
*/
|
|
22
22
|
export class SingleSessionMode {
|
package/dist/trigger/audit.js
CHANGED
|
@@ -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:
|
|
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.
|
|
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({
|
package/dist/trigger/history.js
CHANGED
|
@@ -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
|
|
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 (
|
|
29
|
-
|
|
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.
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
|
487
|
+
throw new Error('missing runId');
|
|
483
488
|
await authorizeTrigger(agentAid, 'trigger.cancel', cmd.triggerId);
|
|
484
|
-
const trigger =
|
|
489
|
+
const trigger = scheduler.cancel(cmd.triggerId);
|
|
485
490
|
return { ok: true, trigger };
|
|
486
491
|
}
|
|
487
492
|
case 'trigger.delete': {
|
package/dist/trigger/manager.js
CHANGED
|
@@ -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);
|
package/dist/trigger/parser.js
CHANGED
|
@@ -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',
|
|
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',
|
|
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 };
|
package/dist/trigger/patch.js
CHANGED
|
@@ -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) {
|
|
@@ -2,8 +2,9 @@ import crypto from 'crypto';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { CronExpressionParser } from 'cron-parser';
|
|
4
4
|
import { logger } from '../utils/logger.js';
|
|
5
|
+
import { isNoopText } from '../core/message/message-utils.js';
|
|
5
6
|
import { matchTriggerEvent, TriggerEventSource } from './event-source.js';
|
|
6
|
-
import { definitionRevision, executionTimeoutMs,
|
|
7
|
+
import { definitionRevision, executionTimeoutMs, parseDurationMs, previewText, renderTemplate, resolveScriptPath, sha256, validateConcurrencyCombination, } from './validation.js';
|
|
7
8
|
import { TargetSessionLockRegistry } from './session-lock.js';
|
|
8
9
|
import { enterTrigger, formatTriggerPath } from '../core/causation/context.js';
|
|
9
10
|
import { createRootCausation } from '../core/causation/context.js';
|
|
@@ -283,6 +284,27 @@ export class TriggerRuntimeScheduler {
|
|
|
283
284
|
cancel(triggerId) {
|
|
284
285
|
return this.setEnabled(triggerId, false);
|
|
285
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
|
+
}
|
|
286
308
|
delete(triggerId) {
|
|
287
309
|
const definition = this.manager.require(triggerId);
|
|
288
310
|
this.clearTimer(triggerId);
|
|
@@ -613,8 +635,8 @@ export class TriggerRuntimeScheduler {
|
|
|
613
635
|
ok: false,
|
|
614
636
|
runId,
|
|
615
637
|
triggerId: definition.id,
|
|
616
|
-
status: 'failed',
|
|
617
|
-
reason,
|
|
638
|
+
status: runningRuntime?.termination?.reason === 'cancelled' ? 'interrupted' : 'failed',
|
|
639
|
+
reason: runningRuntime?.termination?.reason === 'cancelled' ? 'cancelled' : reason,
|
|
618
640
|
};
|
|
619
641
|
}
|
|
620
642
|
if (!payload.dryRun) {
|
|
@@ -664,8 +686,8 @@ export class TriggerRuntimeScheduler {
|
|
|
664
686
|
ok: false,
|
|
665
687
|
runId,
|
|
666
688
|
triggerId: definition.id,
|
|
667
|
-
status: 'failed',
|
|
668
|
-
reason,
|
|
689
|
+
status: runningRuntime?.termination?.reason === 'cancelled' ? 'interrupted' : 'failed',
|
|
690
|
+
reason: runningRuntime?.termination?.reason === 'cancelled' ? 'cancelled' : reason,
|
|
669
691
|
};
|
|
670
692
|
}
|
|
671
693
|
const audit = this.buildAudit({
|
|
@@ -726,8 +748,8 @@ export class TriggerRuntimeScheduler {
|
|
|
726
748
|
ok: false,
|
|
727
749
|
runId,
|
|
728
750
|
triggerId: definition.id,
|
|
729
|
-
status: 'failed',
|
|
730
|
-
reason,
|
|
751
|
+
status: runningRuntime?.termination?.reason === 'cancelled' ? 'interrupted' : 'failed',
|
|
752
|
+
reason: runningRuntime?.termination?.reason === 'cancelled' ? 'cancelled' : reason,
|
|
731
753
|
error: message,
|
|
732
754
|
};
|
|
733
755
|
}
|
|
@@ -979,8 +1001,7 @@ export class TriggerRuntimeScheduler {
|
|
|
979
1001
|
return { branch: branchFromReply(reply), script: null, processing, reply };
|
|
980
1002
|
}
|
|
981
1003
|
try {
|
|
982
|
-
const runtimeBaseagent =
|
|
983
|
-
?? this.runtime.getBaseagent?.()
|
|
1004
|
+
const runtimeBaseagent = this.runtime.getBaseagent?.()
|
|
984
1005
|
?? this.runtime.baseagent;
|
|
985
1006
|
const originPath = causation.trigger?.path ?? [];
|
|
986
1007
|
logger.info(`[Trigger] execution context triggerId=${definition.id}`
|
|
@@ -1042,9 +1063,11 @@ export class TriggerRuntimeScheduler {
|
|
|
1042
1063
|
},
|
|
1043
1064
|
});
|
|
1044
1065
|
const sentinel = definition.execution.noopSentinel ?? '[[NOOP]]';
|
|
1066
|
+
const isNoop = daemonReply.outcome === 'success' && isNoopText(daemonReply.text, sentinel);
|
|
1045
1067
|
const reply = {
|
|
1046
1068
|
...daemonReply,
|
|
1047
|
-
outcome:
|
|
1069
|
+
outcome: isNoop ? 'noop' : daemonReply.outcome,
|
|
1070
|
+
text: isNoop ? '' : daemonReply.text,
|
|
1048
1071
|
};
|
|
1049
1072
|
return {
|
|
1050
1073
|
branch: branchFromReply(reply),
|
|
@@ -1167,6 +1190,8 @@ export class TriggerRuntimeScheduler {
|
|
|
1167
1190
|
logger.warn(`[Trigger] resumable session unavailable: trigger=${definition.id} run=${run.runId} session=${run.executionSessionId}`);
|
|
1168
1191
|
return false;
|
|
1169
1192
|
}
|
|
1193
|
+
if (session.baseagent !== (this.runtime.getBaseagent?.() ?? this.runtime.baseagent))
|
|
1194
|
+
return false;
|
|
1170
1195
|
const entered = enterTrigger(undefined, definition.id, run.runId);
|
|
1171
1196
|
if (!entered.ok)
|
|
1172
1197
|
return false;
|
|
@@ -1411,6 +1436,9 @@ export class TriggerRuntimeScheduler {
|
|
|
1411
1436
|
async runRecoveredExecutionAttempt(definition, runtime, session) {
|
|
1412
1437
|
const { run, source, controller, causation } = runtime;
|
|
1413
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
|
+
}
|
|
1414
1442
|
const daemonReply = await this.daemonChannel.converse(TRIGGER_RESTART_RESUME_PROMPT, {
|
|
1415
1443
|
trigger: definition,
|
|
1416
1444
|
runId: run.runId,
|
|
@@ -1443,9 +1471,11 @@ export class TriggerRuntimeScheduler {
|
|
|
1443
1471
|
},
|
|
1444
1472
|
});
|
|
1445
1473
|
const sentinel = definition.execution.noopSentinel ?? '[[NOOP]]';
|
|
1474
|
+
const isNoop = daemonReply.outcome === 'success' && isNoopText(daemonReply.text, sentinel);
|
|
1446
1475
|
const reply = {
|
|
1447
1476
|
...daemonReply,
|
|
1448
|
-
outcome:
|
|
1477
|
+
outcome: isNoop ? 'noop' : daemonReply.outcome,
|
|
1478
|
+
text: isNoop ? '' : daemonReply.text,
|
|
1449
1479
|
};
|
|
1450
1480
|
return {
|
|
1451
1481
|
branch: branchFromReply(reply),
|
|
@@ -1775,7 +1805,7 @@ export class TriggerRuntimeScheduler {
|
|
|
1775
1805
|
definition: runtime.definition,
|
|
1776
1806
|
runId,
|
|
1777
1807
|
startedAt: runtime.run.startedAt,
|
|
1778
|
-
status: 'failed',
|
|
1808
|
+
status: termination.reason === 'cancelled' ? 'interrupted' : 'failed',
|
|
1779
1809
|
reason: termination.reason,
|
|
1780
1810
|
source: runtime.source,
|
|
1781
1811
|
script: null,
|
|
@@ -1790,7 +1820,7 @@ export class TriggerRuntimeScheduler {
|
|
|
1790
1820
|
this.audit.write(audit);
|
|
1791
1821
|
this.publishTriggerRunOutcome(runtime.definition, audit);
|
|
1792
1822
|
recordCausationSpan(runtime.causation, 'trigger.run', {
|
|
1793
|
-
status: 'failed',
|
|
1823
|
+
status: termination.reason === 'cancelled' ? 'interrupted' : 'failed',
|
|
1794
1824
|
refs: { triggerId: runtime.definition.id, runId },
|
|
1795
1825
|
reason: termination.reason,
|
|
1796
1826
|
});
|
|
@@ -1952,6 +1982,16 @@ export class TriggerRuntimeScheduler {
|
|
|
1952
1982
|
});
|
|
1953
1983
|
return;
|
|
1954
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
|
+
}
|
|
1955
1995
|
if (audit.status === 'skipped') {
|
|
1956
1996
|
this.eventBus.publish({
|
|
1957
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";
|
|
@@ -450,7 +451,7 @@ export function _setDictPath(p) {
|
|
|
450
451
|
// - 中文:上下文过长
|
|
451
452
|
//
|
|
452
453
|
// ⚠️ 新增措辞统一往这里加,不要再在各模块本地复制正则。
|
|
453
|
-
export const CONTEXT_TOO_LONG_PATTERN = /prompt is too long|input is too long|context too long|context limit|context_length_exceeded|context_window_exceeded|context window limit|reached its context window|exceed(?:s|ed)? the context window|maximum context length
|
|
454
|
+
export const CONTEXT_TOO_LONG_PATTERN = /prompt is too long|input is too long|context (?:is )?too (?:long|large)|context limit|context_length_exceeded|context_window_exceeded|context window limit|reached its context window|exceed(?:s|ed)? the context window|maximum context length|上下文(?:过长|过大)/i;
|
|
454
455
|
/** 判断一段文本是否为「上下文过长」类错误。空文本返回 false。 */
|
|
455
456
|
export function isContextTooLongText(text) {
|
|
456
457
|
if (!text)
|
|
@@ -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)) {
|
|
@@ -501,6 +505,9 @@ export function classifyError(error) {
|
|
|
501
505
|
if (error?.code === CLAUDE_CODE_STARTUP_FAILED) {
|
|
502
506
|
return ErrorType.CLAUDE_CODE_STARTUP_FAILED;
|
|
503
507
|
}
|
|
508
|
+
if (msg.includes('context_compact_failed') || isContextTooLongText(getErrorRawText(error))) {
|
|
509
|
+
return ErrorType.CONTEXT_TOO_LONG;
|
|
510
|
+
}
|
|
504
511
|
// 字典优先 — 命中则直接返回
|
|
505
512
|
const rule = matchErrorRule(msg);
|
|
506
513
|
if (rule) {
|
|
@@ -513,9 +520,6 @@ export function classifyError(error) {
|
|
|
513
520
|
return ErrorType.UNKNOWN;
|
|
514
521
|
}
|
|
515
522
|
// 内置兜底规则(结构性、稳定的错误模式)
|
|
516
|
-
if (msg.includes('context_compact_failed') || isContextTooLongText(msg)) {
|
|
517
|
-
return ErrorType.CONTEXT_TOO_LONG;
|
|
518
|
-
}
|
|
519
523
|
if (msg.includes('invalid_model') || msg.includes('model_not_found')
|
|
520
524
|
|| msg.includes('no such model') || msg.includes('unknown model')
|
|
521
525
|
|| /api error: 404\b/.test(msg)) {
|
|
@@ -559,6 +563,10 @@ 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;
|
|
568
|
+
if (lower.includes('context_compact_failed') || isContextTooLongText(getErrorRawText(error)))
|
|
569
|
+
return false;
|
|
562
570
|
// The idle watchdog emits this exact terminal error when a runner stops
|
|
563
571
|
// producing events. The provider session remains resumable, so the task
|
|
564
572
|
// recovery trigger must be allowed to continue the original session.
|
|
@@ -638,6 +646,8 @@ export function getErrorMessage(error, terminalReason, includeEmoji = true) {
|
|
|
638
646
|
return `${warnPrefix}API 限流中,请稍后重试`;
|
|
639
647
|
case 'context_compact_failed':
|
|
640
648
|
return `${warnPrefix}上下文过长,自动压缩失败,请手动输入 /compact 重试`;
|
|
649
|
+
case ErrorType.COMPACTION_FAILED:
|
|
650
|
+
return `${warnPrefix}会话压缩的摘要请求失败,已停止自动重试以避免重复压缩;检查模型网关后可重试`;
|
|
641
651
|
case 'model_error':
|
|
642
652
|
return `${prefix}模型服务异常,请稍后重试`;
|
|
643
653
|
case 'tool_error':
|
|
@@ -679,7 +689,7 @@ export function getErrorMessage(error, terminalReason, includeEmoji = true) {
|
|
|
679
689
|
}
|
|
680
690
|
// 字典优先 — 命中且有自定义消息则直接返回
|
|
681
691
|
const rule = matchErrorRule(msg.toLowerCase());
|
|
682
|
-
if (rule?.message)
|
|
692
|
+
if (rule?.message && (!isContextTooLongText(msg) || rule.type === ErrorType.CONTEXT_TOO_LONG))
|
|
683
693
|
return rule.message;
|
|
684
694
|
// 内置兜底规则(结构性错误)
|
|
685
695
|
if (msg.includes('CONTEXT_COMPACT_FAILED') || isContextTooLongText(msg)) {
|