diff --git a/src/main/automation/automation-actions.ts b/src/main/automation/automation-actions.ts index 89ff9346..68d347f4 100644 --- a/src/main/automation/automation-actions.ts +++ b/src/main/automation/automation-actions.ts @@ -20,11 +20,18 @@ function deriveHeartbeatWakeTrigger(triggerType: string, previousStatus: string } // Map the run/state combination → wake trigger for escalation to manager. +// Status-based mapping takes precedence; rule-trigger mapping is the fallback. +const ESCALATION_STATUS_TRIGGER_MAP: Record = { + in_review: "subtask_completed", + blocked: "report_blocked", +}; +const ESCALATION_RULE_TRIGGER_MAP: Record = { + run_completed: "subtask_completed", + run_failed: "report_failed", +}; function deriveEscalationWakeTrigger(newStatus: string | null, ruleTrigger: string | null): string { - if (newStatus === "in_review") return "subtask_completed"; - if (newStatus === "blocked") return "report_blocked"; - if (ruleTrigger === "run_completed") return "subtask_completed"; - if (ruleTrigger === "run_failed") return "report_failed"; + if (newStatus && ESCALATION_STATUS_TRIGGER_MAP[newStatus]) return ESCALATION_STATUS_TRIGGER_MAP[newStatus]; + if (ruleTrigger && ESCALATION_RULE_TRIGGER_MAP[ruleTrigger]) return ESCALATION_RULE_TRIGGER_MAP[ruleTrigger]; return "report_blocked"; } diff --git a/src/main/prompt-builder/api-section.ts b/src/main/prompt-builder/api-section.ts index 58052dd1..390e08ae 100644 --- a/src/main/prompt-builder/api-section.ts +++ b/src/main/prompt-builder/api-section.ts @@ -13,9 +13,9 @@ Every API call MUST include these headers: Content-Type: application/json; charset=utf-8 X-Agent-Company-Run-Id: ${ctx.runId} -IMPORTANT: On Windows, prefer using Node.js fetch() for API calls instead of curl, -because curl on Windows may corrupt non-ASCII characters (Chinese, Japanese, etc.). -If you must use curl, write the JSON body to a temp file first and use curl -d @file. +Prefer Node.js fetch() over curl so non-ASCII bodies (Chinese, Japanese, etc.) are transmitted +correctly across all platforms. When curl is the only option, write the JSON body to a temp +file first and pass it via \`-d @file\` (shown in the POST example below). Example using fetch (Node.js) — PREFERRED: const res = await fetch(\`\${process.env.AGENT_COMPANY_API_URL}/api/agents/me\`, {