refactor(main): simplify escalation trigger map + unify api-section curl guidance
- P3-52: replace 5-deep if-chain in deriveEscalationWakeTrigger with two lookup maps (status takes precedence over rule trigger), which removes the cognitive overhead of reading the chain and makes the two inputs' roles explicit. - P3-53: rewrite the Windows-only curl warning as platform-neutral guidance that matches the surrounding examples. The old text said 'prefer fetch on Windows' while the doc showed curl POSTs everywhere; the new text recommends fetch universally and explains when the curl temp-file pattern is needed.
This commit is contained in:
1 parent
9227e5f7c4
commit
e892bf3366
2 files changed
+14
-7
No files matched your search
@@ -20,11 +20,18 @@ function deriveHeartbeatWakeTrigger(triggerType: string, previousStatus: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Map the run/state combination → wake trigger for escalation to manager.
|
// 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<string, string> = {
|
||||||
|
in_review: "subtask_completed",
|
||||||
|
blocked: "report_blocked",
|
||||||
|
};
|
||||||
|
const ESCALATION_RULE_TRIGGER_MAP: Record<string, string> = {
|
||||||
|
run_completed: "subtask_completed",
|
||||||
|
run_failed: "report_failed",
|
||||||
|
};
|
||||||
function deriveEscalationWakeTrigger(newStatus: string | null, ruleTrigger: string | null): string {
|
function deriveEscalationWakeTrigger(newStatus: string | null, ruleTrigger: string | null): string {
|
||||||
if (newStatus === "in_review") return "subtask_completed";
|
if (newStatus && ESCALATION_STATUS_TRIGGER_MAP[newStatus]) return ESCALATION_STATUS_TRIGGER_MAP[newStatus];
|
||||||
if (newStatus === "blocked") return "report_blocked";
|
if (ruleTrigger && ESCALATION_RULE_TRIGGER_MAP[ruleTrigger]) return ESCALATION_RULE_TRIGGER_MAP[ruleTrigger];
|
||||||
if (ruleTrigger === "run_completed") return "subtask_completed";
|
|
||||||
if (ruleTrigger === "run_failed") return "report_failed";
|
|
||||||
return "report_blocked";
|
return "report_blocked";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ Every API call MUST include these headers:
|
|||||||
Content-Type: application/json; charset=utf-8
|
Content-Type: application/json; charset=utf-8
|
||||||
X-Agent-Company-Run-Id: ${ctx.runId}
|
X-Agent-Company-Run-Id: ${ctx.runId}
|
||||||
|
|
||||||
IMPORTANT: On Windows, prefer using Node.js fetch() for API calls instead of curl,
|
Prefer Node.js fetch() over curl so non-ASCII bodies (Chinese, Japanese, etc.) are transmitted
|
||||||
because curl on Windows may corrupt non-ASCII characters (Chinese, Japanese, etc.).
|
correctly across all platforms. When curl is the only option, write the JSON body to a temp
|
||||||
If you must use curl, write the JSON body to a temp file first and use curl -d @file.
|
file first and pass it via \`-d @file\` (shown in the POST example below).
|
||||||
|
|
||||||
Example using fetch (Node.js) — PREFERRED:
|
Example using fetch (Node.js) — PREFERRED:
|
||||||
const res = await fetch(\`\${process.env.AGENT_COMPANY_API_URL}/api/agents/me\`, {
|
const res = await fetch(\`\${process.env.AGENT_COMPANY_API_URL}/api/agents/me\`, {
|
||||||
|
|||||||
Reference in new issue
Block a user