|
3 | 3 | */ |
4 | 4 |
|
5 | 5 | import type { AgentRunner } from "../runner.js"; |
6 | | -import type { Task } from "../api-client.js"; |
| 6 | +import { createAuthHeaders, type Task } from "../api-client.js"; |
7 | 7 | import { buildAgentPrompt } from "../prompt.js"; |
8 | 8 | import { getEngine, resolveModel, resolveModelForRole } from "../agent-engine.js"; |
9 | 9 | import { matchTemplate, executeActions, type ActionContext } from "../agent-templates.js"; |
@@ -141,7 +141,7 @@ export async function runLoop(cliArgs: CliArgs, runner: AgentRunner, shutdownSta |
141 | 141 | // Auto-run Strategist proposals when sprint enters retrospective (once only) |
142 | 142 | if (sprint?.status === "retrospective") { |
143 | 143 | try { |
144 | | - const headers = { Authorization: `Bearer ${cliArgs.apiKey}`, "Content-Type": "application/json" }; |
| 144 | + const headers = createAuthHeaders(cliArgs.apiKey); |
145 | 145 | const plansRes = await fetch(`${cliArgs.apiUrl}/api/v1/sprints/${sprint.number}/plan`, { headers }); |
146 | 146 | if (plansRes.ok) { |
147 | 147 | const plan = (await plansRes.json()) as { status: string; id: string }; |
@@ -186,7 +186,7 @@ export async function runLoop(cliArgs: CliArgs, runner: AgentRunner, shutdownSta |
186 | 186 | try { |
187 | 187 | await fetch(`${cliArgs.apiUrl}/api/v1/sprints/${sprint.number}`, { |
188 | 188 | method: "PATCH", |
189 | | - headers: { "Content-Type": "application/json", Authorization: `Bearer ${cliArgs.apiKey}` }, |
| 189 | + headers: createAuthHeaders(cliArgs.apiKey), |
190 | 190 | body: JSON.stringify({ status: "review" }), |
191 | 191 | }); |
192 | 192 | wsServer?.broadcast({ type: "data_update" as const, entity: "sprint", task_id: String(sprint.number), changes: { status: "review" }, timestamp: new Date().toISOString() }); |
@@ -220,7 +220,7 @@ export async function runLoop(cliArgs: CliArgs, runner: AgentRunner, shutdownSta |
220 | 220 | for (const sub of subtasks) { |
221 | 221 | await fetch(`${cliArgs.apiUrl}/api/v1/tasks`, { |
222 | 222 | method: "POST", |
223 | | - headers: { "Content-Type": "application/json", Authorization: `Bearer ${cliArgs.apiKey}` }, |
| 223 | + headers: createAuthHeaders(cliArgs.apiKey), |
224 | 224 | body: JSON.stringify({ ...sub, sprint: sprintNum, parent_task: t.id, status: "todo" }), |
225 | 225 | }); |
226 | 226 | } |
@@ -515,7 +515,7 @@ export async function runLoop(cliArgs: CliArgs, runner: AgentRunner, shutdownSta |
515 | 515 |
|
516 | 516 | await fetch(`${cliArgs.apiUrl}/api/v1/sprints/${sprintData.sprint.number}/retro`, { |
517 | 517 | method: "POST", |
518 | | - headers: { "Content-Type": "application/json", Authorization: `Bearer ${cliArgs.apiKey}` }, |
| 518 | + headers: createAuthHeaders(cliArgs.apiKey), |
519 | 519 | body: JSON.stringify({ |
520 | 520 | agent_name: agentConfig.name, |
521 | 521 | went_well: safeWentWell, |
|
0 commit comments