module.exports=[65885,e=>{"use strict";var t=e.i(2157),s=e.i(60526),i=e.i(50227);e.i(66680),e.i(53533);let n=process.env.OPENCLAW_HOME??(0,i.join)((0,s.homedir)(),".openclaw");e.s(["buildPendingSessionKey",0,function(e,t){return`agent:${e}:${t}`},"findSessionBySessionId",0,function(e,s){let a=function(e){let s,a=(0,i.join)(n,"agents",e,"sessions","sessions.json");if(!(0,t.existsSync)(a))return[];try{s=JSON.parse((0,t.readFileSync)(a,"utf8"))}catch{return[]}let o=`agent:${e}:`,r=[];for(let[e,t]of Object.entries(s)){if(!t.sessionId)continue;let s=e.startsWith(o)?e.slice(o.length):e;r.push({sessionId:t.sessionId,label:s,sessionKey:e,lastInteractionAt:t.lastInteractionAt??t.updatedAt??0,pending:!1})}return r.sort((e,t)=>t.lastInteractionAt-e.lastInteractionAt),r}(e);return a.find(e=>e.label===s)??a.find(e=>e.sessionId===s)??null}])},43940,e=>{"use strict";var t=e.i(66680);e.s(["buildTaskKickoffMessage",0,function(e){let t=["(task assignment)","",`project_slug: ${e.project_slug}`,`agent_id:     ${e.agent_id}`,`task_id:      ${e.id}`,`Title:        ${e.title??"(untitled)"}`,"","Brief:",e.brief,""];return e.success_criteria&&t.push("Success criteria:",e.success_criteria,""),t.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."),t.join("\n")},"generateTaskThreadId",0,function(){return(0,t.randomUUID)()}])},74395,e=>{"use strict";var t=e.i(65885),s=e.i(82651),i=e.i(22117),n=e.i(60273),a=e.i(43940);async function o(e){if(!e.task_id)return;let o=(0,n.getTask)(e.task_id);if(!o||"done"===o.status||"failed"===o.status||"cancelled"===o.status)return;("approved"===e.status||"rejected"===e.status)&&(0,n.unblockTask)(o.id);let r=o.thread_id;if(!r){let e=(0,n.setTaskThreadIfMissing)(o.id,(0,a.generateTaskThreadId)());e?.thread_id&&(r=e.thread_id)}if(!r)return void console.error(`[approval-wakeup] no thread_id for task ${o.id}`);let d=(0,t.findSessionBySessionId)(o.agent_id,r),l=d?.sessionKey??(0,t.buildPendingSessionKey)(o.agent_id,r),u=function(e){let t="user"===e.decided_by_kind?"the user":"agent"===e.decided_by_kind?`another agent (${e.decided_by_id??"unknown"})`:"policy"===e.decided_by_kind?"an auto-approval policy":"an unknown party",s=e.decision_note?.trim();switch(e.status){case"approved":return[`[SYSTEM] Approval #${e.id.slice(0,8)} has been APPROVED by ${t}.`,`Action: ${e.action_summary}`,s?`Note: ${s}`: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 #${e.id.slice(0,8)} has been REJECTED by ${t}.`,`Action: ${e.action_summary}`,s?`Reason: ${s}`: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 #${e.id.slice(0,8)} needs revision per ${t}.`,`Action: ${e.action_summary}`,s?`Feedback: ${s}`:"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 #${e.id.slice(0,8)} resolved (${e.status}). Continue.`}}(e);(0,i.appendComment)({approval_id:e.id,author_kind:"system",body:`Delivered to ${o.agent_id} on thread ${r}.`});try{for await(let e of(0,s.streamChatViaGateway)({sessionKey:l,sessionId:r,message:u}))if("error"===e.kind)throw Error(e.message)}catch(e){console.error(`[approval-wakeup] gateway stream failed for task ${o.id}:`,e)}}e.s(["wakeTaskOnApprovalResolution",0,o],16605),e.i(16605),e.s(["wakeTaskOnApprovalResolution",0,o],74395)}];

//# sourceMappingURL=src_server_12plaxq._.js.map