module.exports=[26341,a=>{"use strict";var b=a.i(66680);a.s(["buildTaskKickoffMessage",0,function(a){let b=["(task assignment)","",`project_slug: ${a.project_slug}`,`agent_id:     ${a.agent_id}`,`task_id:      ${a.id}`,`Title:        ${a.title??"(untitled)"}`,"","Brief:",a.brief,""];return a.success_criteria&&b.push("Success criteria:",a.success_criteria,""),b.push("Acknowledge this task in 1-2 sentences (what you'll do + roughly how","long), then start working. Use your domain tools to actually do the","thing — don't just describe what you'd do. Close the task out when","you're done."),b.join("\n")},"generateTaskThreadId",0,function(){return(0,b.randomUUID)()}])},74799,a=>{"use strict";var b=a.i(22486),c=a.i(48836),d=a.i(81181),e=a.i(19078),f=a.i(26341);async function g(a){if(!a.task_id)return;let g=(0,e.getTask)(a.task_id);if(!g||"done"===g.status||"failed"===g.status||"cancelled"===g.status)return;("approved"===a.status||"rejected"===a.status)&&(0,e.unblockTask)(g.id);let h=g.thread_id;if(!h){let a=(0,e.setTaskThreadIfMissing)(g.id,(0,f.generateTaskThreadId)());a?.thread_id&&(h=a.thread_id)}if(!h)return void console.error(`[approval-wakeup] no thread_id for task ${g.id}`);let i=(0,b.findSessionBySessionId)(g.agent_id,h),j=i?.sessionKey??(0,b.buildPendingSessionKey)(g.agent_id,h),k=function(a){let b="user"===a.decided_by_kind?"the user":"agent"===a.decided_by_kind?`another agent (${a.decided_by_id??"unknown"})`:"policy"===a.decided_by_kind?"an auto-approval policy":"an unknown party",c=a.decision_note?.trim();switch(a.status){case"approved":return[`[SYSTEM] Approval #${a.id.slice(0,8)} has been APPROVED by ${b}.`,`Action: ${a.action_summary}`,c?`Note: ${c}`:null,"","You may now proceed with the action. When you're finished, call the `submit_task_status` MCP tool with status `done` (or `working` if you're posting an interim update). Do NOT invent new status values."].filter(Boolean).join("\n");case"rejected":return[`[SYSTEM] Approval #${a.id.slice(0,8)} has been REJECTED by ${b}.`,`Action: ${a.action_summary}`,c?`Reason: ${c}`:null,"","Do NOT perform the rejected action. Decide whether to propose an alternative or stop here. Either way, call the `submit_task_status` MCP tool — use status `done` if you have nothing further to do, or `working` if you're proposing an alternative. The valid statuses are exactly: working, done, blocked, failed."].filter(Boolean).join("\n");case"revision_requested":return[`[SYSTEM] Approval #${a.id.slice(0,8)} needs revision per ${b}.`,`Action: ${a.action_summary}`,c?`Feedback: ${c}`:"Feedback: (no note left — re-read the request and propose a refined version)","","Re-evaluate the request given the feedback, then call the notfair-orchestration `request_approval` MCP tool again with the revised plan. Keep status `working` via `submit_task_status` in the meantime. Do NOT emit pseudo-XML blocks."].filter(Boolean).join("\n");default:return`[SYSTEM] Approval #${a.id.slice(0,8)} resolved (${a.status}). Continue.`}}(a);(0,d.appendComment)({approval_id:a.id,author_kind:"system",body:`Delivered to ${g.agent_id} on thread ${h}.`});try{for await(let a of(0,c.streamChatViaGateway)({sessionKey:j,sessionId:h,message:k}))if("error"===a.kind)throw Error(a.message)}catch(a){console.error(`[approval-wakeup] gateway stream failed for task ${g.id}:`,a)}}a.s(["wakeTaskOnApprovalResolution",0,g])},28151,a=>{"use strict";var b=a.i(74799);a.i(81181),a.s(["wakeTaskOnApprovalResolution",()=>b.wakeTaskOnApprovalResolution])}];

//# sourceMappingURL=src_server_orchestration_0i_x~ej._.js.map