blade-code 0.10.35 → 0.10.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/chunk-09qkatb5.js +10 -0
- package/dist/{chunk-0g7cjx1t.js → chunk-0dj2qm8a.js} +1 -1
- package/dist/{chunk-vpe44cnj.js → chunk-0evyrnx0.js} +2 -2
- package/dist/{chunk-b7xdtjh8.js → chunk-0m4s8r87.js} +358 -356
- package/dist/{chunk-wmvj44cr.js → chunk-1raz6s2b.js} +2 -2
- package/dist/{chunk-9h41rm97.js → chunk-1t8ebwsp.js} +2 -2
- package/dist/{chunk-nwtgx6p6.js → chunk-250vpvr5.js} +1 -1
- package/dist/{chunk-132q0hyf.js → chunk-2mvp3rqw.js} +2 -2
- package/dist/chunk-3pxn6gcj.js +1 -0
- package/dist/{chunk-pmxqjb29.js → chunk-3rjmkaey.js} +1 -1
- package/dist/{chunk-0zs3mn75.js → chunk-4bbnytq5.js} +1 -1
- package/dist/chunk-4f1g8f6q.js +1 -0
- package/dist/{chunk-7m5az521.js → chunk-4s0c6tkd.js} +1 -1
- package/dist/{chunk-aytg9gw0.js → chunk-4vq34v09.js} +2 -2
- package/dist/chunk-515mkr66.js +44 -0
- package/dist/chunk-5c5qh3ab.js +1 -0
- package/dist/{chunk-pgy1mtgw.js → chunk-5cgyevqj.js} +1 -1
- package/dist/chunk-5vkxcjn1.js +1 -0
- package/dist/chunk-5xc50n8e.js +1 -0
- package/dist/{chunk-znp4bexg.js → chunk-6360fg4j.js} +1 -1
- package/dist/{chunk-031n82db.js → chunk-6gcmfvfj.js} +2 -2
- package/dist/{chunk-t1zs40rj.js → chunk-6jpspf3v.js} +2 -2
- package/dist/chunk-738a282r.js +1 -0
- package/dist/{chunk-k5gv2phs.js → chunk-7c5tnz4y.js} +1 -1
- package/dist/{chunk-4en93rc4.js → chunk-8ft7j7aw.js} +1 -1
- package/dist/chunk-8m87dnk2.js +1 -0
- package/dist/{chunk-38ca5c9f.js → chunk-93jx06kq.js} +1 -1
- package/dist/{chunk-3nn4rth6.js → chunk-95k17p11.js} +1 -1
- package/dist/{chunk-2kzg80r3.js → chunk-95n8g52h.js} +1 -1
- package/dist/{chunk-rwtgrs8d.js → chunk-99ywfge1.js} +1 -1
- package/dist/{chunk-zj29g9rc.js → chunk-9g6rzbcv.js} +2 -2
- package/dist/{chunk-r84jsjnc.js → chunk-a7pvtxvz.js} +1 -1
- package/dist/{chunk-pf8rybpm.js → chunk-acw8q8w9.js} +2 -2
- package/dist/{chunk-xf03b657.js → chunk-atsw605q.js} +1 -1
- package/dist/{chunk-rcp5maxt.js → chunk-cc7dmst6.js} +3 -3
- package/dist/{chunk-015fx09x.js → chunk-ck5tvxkj.js} +2 -2
- package/dist/{chunk-hq8cbzfv.js → chunk-ckfc7j7m.js} +1 -1
- package/dist/chunk-cnctwxqn.js +1 -0
- package/dist/{chunk-ck9r8h1h.js → chunk-e23sz81n.js} +2 -2
- package/dist/chunk-e5yage6p.js +1 -0
- package/dist/{chunk-2y4qyct0.js → chunk-ekzck3x7.js} +1 -1
- package/dist/{chunk-83w81bma.js → chunk-g510tpqt.js} +1 -1
- package/dist/{chunk-a1wjgf44.js → chunk-gy8esxaa.js} +2 -2
- package/dist/chunk-hh158y4e.js +6 -0
- package/dist/{chunk-ytec29ph.js → chunk-hq18c6r9.js} +1 -1
- package/dist/{chunk-6v51xb9r.js → chunk-hq1wrf1g.js} +1 -1
- package/dist/chunk-j2tmdkmw.js +1 -0
- package/dist/{chunk-q30azbe2.js → chunk-m2w03hpc.js} +1 -1
- package/dist/{chunk-0hdsbwhf.js → chunk-m6dh31kb.js} +2 -2
- package/dist/{chunk-6b1vvq1f.js → chunk-n4555gej.js} +1 -1
- package/dist/{chunk-4s6w24r3.js → chunk-phgqzja3.js} +2 -2
- package/dist/chunk-psgt2pq7.js +6 -0
- package/dist/{chunk-7jja0242.js → chunk-q15qd9x4.js} +1 -1
- package/dist/chunk-q3r0zfec.js +1 -0
- package/dist/{chunk-d4hcy6p1.js → chunk-qgez5vw6.js} +1 -1
- package/dist/{chunk-qf357j45.js → chunk-qggnvzkc.js} +2 -2
- package/dist/{chunk-sqp79c1a.js → chunk-qvdcesry.js} +2 -2
- package/dist/{chunk-y5kp6fmy.js → chunk-qwrdss51.js} +1 -1
- package/dist/{chunk-hymw69m4.js → chunk-qxvk42rf.js} +1 -1
- package/dist/{chunk-6r9jb465.js → chunk-rshbnfr8.js} +4 -4
- package/dist/chunk-rv6kca90.js +1 -0
- package/dist/{chunk-4ncddyay.js → chunk-s4enbe93.js} +1 -1
- package/dist/chunk-thstqcg3.js +2 -0
- package/dist/{chunk-eqj58q4r.js → chunk-v11r4ahz.js} +1 -1
- package/dist/chunk-ve7kp9rr.js +1 -0
- package/dist/chunk-xf2kjb9a.js +1 -0
- package/dist/{chunk-gg179pdx.js → chunk-xrhtwcd0.js} +1 -1
- package/dist/{chunk-sbyyg6qg.js → chunk-y990fa4r.js} +3 -3
- package/dist/{chunk-3qmawdwf.js → chunk-y9nq48st.js} +2 -2
- package/dist/{chunk-1jagjybs.js → chunk-zwt7f9ab.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-39wa7cfr.js +0 -1
- package/dist/chunk-51b7jb2s.js +0 -1
- package/dist/chunk-7cbe8yjn.js +0 -1
- package/dist/chunk-cz1hb799.js +0 -1
- package/dist/chunk-dbwa9rwr.js +0 -6
- package/dist/chunk-fbxgxwfm.js +0 -1
- package/dist/chunk-gcyd5s5h.js +0 -1
- package/dist/chunk-h7v23pw2.js +0 -1
- package/dist/chunk-hk36a59x.js +0 -1
- package/dist/chunk-js5whev4.js +0 -44
- package/dist/chunk-mkmcwc5r.js +0 -1
- package/dist/chunk-pn2e99pn.js +0 -1
- package/dist/chunk-qhfbdp5e.js +0 -1
- package/dist/chunk-r9j56qcs.js +0 -1
- package/dist/chunk-se9krwes.js +0 -6
- package/dist/chunk-tencwrxf.js +0 -1
- package/dist/chunk-wf7ycftn.js +0 -1
- package/dist/chunk-z45qe8dg.js +0 -2
- package/dist/chunk-zhr1btfv.js +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as a,g as i,h as l,i as m}from"./chunk-rshbnfr8.js";import"./chunk-qxvk42rf.js";import"./chunk-4bbnytq5.js";import"./chunk-95n8g52h.js";import"./chunk-q15qd9x4.js";import"./chunk-0m4s8r87.js";import"./chunk-7c5tnz4y.js";import"./chunk-95k17p11.js";import"./chunk-y990fa4r.js";import"./chunk-5cgyevqj.js";import"./chunk-6gcmfvfj.js";import"./chunk-qgez5vw6.js";import"./chunk-phgqzja3.js";import{$c as n}from"./chunk-ck5tvxkj.js";import"./chunk-0evyrnx0.js";import{vd as s}from"./chunk-e23sz81n.js";import"./chunk-v508x7cg.js";import"./chunk-atsw605q.js";import"./chunk-4vq34v09.js";import"./chunk-6jpspf3v.js";import"./chunk-3rjmkaey.js";import"./chunk-acw8q8w9.js";import"./chunk-9g6rzbcv.js";import"./chunk-hq18c6r9.js";import"./chunk-zwt7f9ab.js";import"./chunk-ckfc7j7m.js";import"./chunk-cc7dmst6.js";import"./chunk-v11r4ahz.js";import"./chunk-515mkr66.js";import"./chunk-a7pvtxvz.js";import"./chunk-93jx06kq.js";import"./chunk-thstqcg3.js";import"./chunk-6360fg4j.js";import"./chunk-qvdcesry.js";import"./chunk-2mvp3rqw.js";import"./chunk-g510tpqt.js";import"./chunk-gy8esxaa.js";import"./chunk-m6dh31kb.js";import"./chunk-0dj2qm8a.js";import"./chunk-y9nq48st.js";import"./chunk-4s0c6tkd.js";import v from"chalk";var C={command:"serve",describe:"Start a headless Blade server (no browser)",builder:a,handler:async(p)=>{let r=i(p);if(await s(),!process.env.BLADE_SERVER_PASSWORD)console.log(v.yellow("Warning: BLADE_SERVER_PASSWORD is not set; server is unsecured."));let e=await m.listenAsync(r);if(console.log(`Blade server listening on http://${e.hostname}:${e.port}`),r.hostname==="0.0.0.0"){let o=l();for(let g of o)console.log(` Network: http://${g}:${e.port}`)}let t,c=new Promise((o)=>{t=o}),d=n(async()=>{await e.stop(),t()});try{await c}finally{d(),await e.stop()}}};export{C as serveCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as iJ,c as oJ,d as nJ}from"./chunk-
|
|
1
|
+
import{b as iJ,c as oJ,d as nJ}from"./chunk-8ft7j7aw.js";import{j as ZJ,k as XJ}from"./chunk-qxvk42rf.js";import{s as c8}from"./chunk-95n8g52h.js";import{B as qY,D as s2,E as a2,F as Z6,L as j1,N as f4,O as k4,S as Y8,T as AJ,U as PJ,X as RJ,Y as yJ,ba as y6,ca as M6,da as UY,ea as p4,ga as c4,ia as F6,z as N6}from"./chunk-0m4s8r87.js";import{ma as S9,na as D9,oa as V9,ra as KY}from"./chunk-7c5tnz4y.js";import"./chunk-95k17p11.js";import{Ua as a4,Va as i4,ib as o4,rb as u2}from"./chunk-y990fa4r.js";import{Ab as G8}from"./chunk-5cgyevqj.js";import{Tb as x4,Yb as I4,bc as T4,ic as D4,jc as x2,kc as V4,mc as V8,uc as J8,xc as P0}from"./chunk-6gcmfvfj.js";import"./chunk-qgez5vw6.js";import"./chunk-phgqzja3.js";import{Zc as rJ}from"./chunk-qggnvzkc.js";import{$c as x8,_c as K8,bd as T1}from"./chunk-ck5tvxkj.js";import"./chunk-0evyrnx0.js";import{Fd as g0,fd as I$,gd as d0,hd as Q$,id as yQ,jd as D$,kd as j8,ld as $9,md as uQ,nd as n9,od as Q9,pd as k$,qd as $1,rd as XY,sd as r0,td as dJ,ud as P2,vd as Z8,yd as g4}from"./chunk-e23sz81n.js";import"./chunk-v508x7cg.js";import"./chunk-atsw605q.js";import"./chunk-4vq34v09.js";import{Qd as lQ}from"./chunk-6jpspf3v.js";import"./chunk-3rjmkaey.js";import"./chunk-acw8q8w9.js";import{$d as A6,ce as jJ,ie as bJ,oe as GY}from"./chunk-9g6rzbcv.js";import"./chunk-hq18c6r9.js";import"./chunk-zwt7f9ab.js";import"./chunk-ckfc7j7m.js";import{Ce as IQ,Ee as O1}from"./chunk-cc7dmst6.js";import"./chunk-v11r4ahz.js";import{nf as YY,yf as wJ,zf as ZY}from"./chunk-515mkr66.js";import"./chunk-a7pvtxvz.js";import"./chunk-93jx06kq.js";import{Hf as V$,If as h8,Jf as TQ}from"./chunk-thstqcg3.js";import{Nf as u0}from"./chunk-6360fg4j.js";import{Of as JY,Rf as e1}from"./chunk-qvdcesry.js";import{Tf as QJ,Uf as JJ,Xf as h1}from"./chunk-2mvp3rqw.js";import"./chunk-g510tpqt.js";import{hg as u9}from"./chunk-gy8esxaa.js";import{ig as sQ}from"./chunk-m6dh31kb.js";import"./chunk-0dj2qm8a.js";import"./chunk-y9nq48st.js";import{ug as CQ}from"./chunk-4s0c6tkd.js";import{useMemoizedFn as S2}from"ahooks";import{useEffect as pX,useState as D2}from"react";import{useMemoizedFn as n0}from"ahooks";import{Box as z$}from"ink";import{useEffect as _$,useMemo as DX,useRef as f2}from"react";import{useShallow as zY}from"zustand/react/shallow";import{useStore as OY}from"zustand";function s($){return OY(k$,$)}var _Y=[],v$=()=>s(($)=>$.session.sessionId),I1=()=>s(($)=>$.session.workspaceRoot),eQ=()=>s(($)=>$.session.messages),$4=()=>s(($)=>$.session.clearCount),Q4=()=>s(($)=>$.session.isCompacting),J4=()=>s(($)=>$.session.tokenUsage.estimatedCostUsd),Y4=()=>s(($)=>$.session.providerRetry),Z4=()=>s(($)=>$.session.providerStall),X4=()=>s(($)=>$.session.actionStationarity),n1=()=>s(($)=>$.session.actions),G4=()=>s(($)=>{let{inputTokens:Q,maxContextTokens:Y}=$.session.tokenUsage;if(Y<=0)return 100;let J=Math.max(0,100-Q/Y*100);return Math.round(J)}),K4=()=>s(($)=>$.app.initializationStatus),q4=()=>s(($)=>$.app.initializationError),R8=()=>s(($)=>$.app.activeModal),U4=()=>s(($)=>$.app.tasks),O4=()=>s(($)=>$.app.modelEditorTarget),z4=()=>s(($)=>$.app.sessionSelectorData),_4=()=>s(($)=>$.app.awaitingSecondCtrlC),t1=()=>s(($)=>$.app.actions),y8=()=>s(($)=>$.app.initializationStatus==="ready"),N4=()=>s(($)=>$.app.tasks.length>0),S$=()=>s(($)=>$.config.config?.permissionMode||"default"),F4=()=>s(($)=>$.config.config?.models??_Y),M8=()=>s(($)=>{let Q=$.config.config;if(!Q)return;let Y=Q.currentModelId;return Q.models.find((Z)=>Z.id===Y)??Q.models[0]}),C8=()=>s(($)=>$.config.config?.currentModelId),A0=()=>s(($)=>{return d0.getTheme()}),H4=()=>s(($)=>$.config.config?.codeTheme??"default"),e0=()=>s(($)=>$.focus.currentFocus),W4=()=>s(($)=>$.focus.actions),s1=()=>s(($)=>$.command.isProcessing),L4=()=>s(($)=>$.command.actions),I8=()=>s(($)=>$.command.pendingCommands),B4=()=>s(($)=>$.command.recoveredSteeringCount),T8=()=>s(($)=>$.app.thinkingModeEnabled),f8=()=>s(($)=>$.app.reasoningEffort),k8=()=>s(($)=>$.app.serviceTier),v8=()=>s(($)=>$.app.responseVerbosity),S8=()=>s(($)=>$.app.communicationStyle),w4=()=>s(($)=>$.session.currentThinkingContent),b4=()=>s(($)=>$.session.thinkingExpanded),A4=()=>s(($)=>$.session.currentStreamingMessageId),P4=()=>s(zY(($)=>({lines:$.session.currentStreamingLines,tail:$.session.currentStreamingTail,lineCount:$.session.currentStreamingLineCount,version:$.session.currentStreamingVersion}))),R4=()=>s(($)=>$.session.finalizingStreamingMessageId),y4=()=>s(($)=>$.session.historyExpanded),M4=()=>s(($)=>$.session.expandedMessageCount);import{useMemoizedFn as h$}from"ahooks";import{useEffect as l8,useRef as r4}from"react";function NY($){if(!($ instanceof Error))return"未知错误";let J=$.lastError??$;if(J.responseBody)try{let G=JSON.parse(J.responseBody)?.error?.message;if(G){let q=J.statusCode?` (HTTP ${J.statusCode})`:"";return`${G}${q}`}}catch{}let Z=$.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return $.message}function FY($){if(!($ instanceof Error))return!1;return $.name==="AbortError"||$.message.includes("aborted")}function HY($){if(!($ instanceof Error))return!1;let Q=$.message;return Q.includes("can only concatenate str")||Q.includes("image_url")||Q.includes("multimodal")||Q.includes("vision")||Q.includes("does not support images")}function D8($){let Q=FY($),Y=HY($),J;if(Y)J="当前模型不支持图片理解功能。请切换到支持视觉能力的模型(如 Claude 4.5、GPT-5.2、Gemini 3 Pro、Qwen3-VL-Plus 等)后重试。";else J=NY($);return{displayMessage:J,isAbort:Q,isVisionNotSupported:Y}}import{appendFileSync as WY,mkdirSync as LY,writeFileSync as BY}from"node:fs";import wY from"node:os";import h2 from"node:path";var C4=null;function bY(){let $=process.env.BLADE_STORAGE_ROOT||h2.join(wY.homedir(),".blade");return h2.join($,"logs","stream-debug.log")}function AY($){if(C4===$)return;let Q=h2.dirname($);LY(Q,{recursive:!0,mode:493}),BY($,`=== Stream Debug Log Started: ${new Date().toISOString()} ===
|
|
2
2
|
`),C4=$}function E2($,Q,Y){try{let J=bY();AY(J);let Z=new Date().toISOString(),X=Y?` | ${JSON.stringify(Y)}`:"",G=`[${Z}] [${$}] ${Q}${X}
|
|
3
3
|
`;WY(J,G)}catch{}}var Q8=e1("UI");function v4($,Q){let Y=!1;return(J)=>{switch(J.kind){case"content_delta":if(Y||$.signal.aborted)break;Q.contentDeltaCount++,Q.contentDeltaTotalLen+=J.delta.length,E2("loopEventHandler","onContentDelta",{callCount:Q.contentDeltaCount,deltaLen:J.delta.length,totalLen:Q.contentDeltaTotalLen}),$.streamingBuffer.batchAppendContent(J.delta);break;case"thinking_delta":if(Y||$.signal.aborted)break;if($.thinkingModeEnabled)$.streamingBuffer.batchAppendThinking(J.delta);break;case"stream_end":{if($.sessionActions.setProviderRetry(null),$.sessionActions.setProviderStall(null),Q8.debug("[loopEventHandler] stream_end",{contentDeltaCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),E2("loopEventHandler","onStreamEnd",{contentDeltaCallCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),Y||$.signal.aborted){Y=!0;break}let{extraContent:Z,extraThinking:X}=$.streamingBuffer.drainPendingBuffers(),G=$.getStreamingMessageId();if(G){if(Z)D$(G,Z);j8(G)}$.sessionActions.finalizeStreamingMessage(Z,X),Y=!0;break}case"model_fallback":Y=!0,$.sessionActions.setProviderRetry(null),$.sessionActions.setProviderStall(null),$.streamingBuffer.resetStreamingBuffers(),$.sessionActions.discardStreamingMessage(),$.sessionActions.setCurrentThinkingContent(null);break;case"provider_retry":{let{kind:Z,...X}=J;$.sessionActions.setProviderRetry(J.phase==="scheduled"||J.phase==="attempt"?X:null);break}case"provider_stall":{let{kind:Z,...X}=J;$.sessionActions.setProviderStall(J.phase==="detected"?X:null);break}case"action_stationarity":{let{kind:Z,...X}=J;$.sessionActions.setActionStationarity(J.phase==="recovered"?null:X);break}case"tool_start":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===V8)break;if(Q8.debug("[loopEventHandler] tool_start",{toolName:Z.function.name,toolKind:J.toolKind}),["TaskCreate","TaskUpdate","TaskList"].includes(Z.function.name))break;try{let X=JSON.parse(Z.function.arguments),G=f4(Z.function.name,X);$.sessionActions.addToolMessage(G,{toolCallId:Z.id,toolName:Z.function.name,phase:"start",summary:G,params:X})}catch(X){Q8.error("[loopEventHandler] onToolStart error:",X)}break}case"tool_progress":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===V8)break;let X=J.update.total!==void 0?` ${Math.max(0,Math.min(100,Math.round((J.update.progress??0)/J.update.total*100)))}%`:"",G=`${Z.function.name}${X}: ${J.update.message}`;$.sessionActions.addToolMessage(G,{toolCallId:Z.id,toolName:Z.function.name,phase:"progress",summary:G,...J.update.admission?{admission:J.update.admission}:{}});break}case"tool_result":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===V8)break;Q8.debug("[loopEventHandler] tool_result",{toolName:Z.function.name,success:J.result.success});let X=T4(k4(Z.function.name,J.result),I4);$.sessionActions.addToolMessage(X.summary,{toolCallId:Z.id,toolName:Z.function.name,phase:"complete",summary:X.summary,detail:X.detail});break}case"structured_output":$.sessionActions.replaceLastAssistantMessage(JSON.stringify(J.output,null,2));break;case"token_usage":$.sessionActions.updateTokenUsage(J.usage);break;case"compaction":if($.sessionActions.setCompacting(J.phase==="start"),J.phase==="end"){if($.sessionActions.resetContextUsage(),J.outcome!=="failed")Q.compactionCount=(Q.compactionCount??0)+1}break;case"turn_start":Q8.debug("[loopEventHandler] turn_start",{turn:J.turn,maxTurns:J.maxTurns}),$.sessionActions.updateTokenUsage({turnCount:J.turn}),$.sessionActions.setProviderRetry(null),$.sessionActions.setProviderStall(null),Y=!1;break;case"task_update":$.appActions.setTasks(J.tasks);break;case"mcp_catalog_changed":{let Z=`MCP catalog r${J.revision}: +${J.added.length} -${J.removed.length} ~${J.updated.length}`;$.sessionActions.addToolMessage(Z,{toolName:"MCP Catalog",phase:"complete",summary:Z,detail:[J.added.length>0?`Added: ${J.added.join(", ")}`:"",J.removed.length>0?`Removed: ${J.removed.join(", ")}`:"",J.updated.length>0?`Updated: ${J.updated.join(", ")}`:""].filter(Boolean).join(`
|
|
4
4
|
`)});break}case"mcp_content_changed":{let Z=`MCP ${J.contentKind} r${J.revision}: +${J.added.length} -${J.removed.length} ~${J.updated.length}`;$.sessionActions.addToolMessage(Z,{toolName:"MCP Content",phase:"complete",summary:Z,detail:[J.added.length>0?`Added: ${J.added.join(", ")}`:"",J.removed.length>0?`Removed: ${J.removed.join(", ")}`:"",J.updated.length>0?`Updated: ${J.updated.join(", ")}`:""].filter(Boolean).join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{spawn as I}from"node:child_process";var X=500;function x(j){return new Promise((q)=>setTimeout(q,j))}function Z(j){return j&&typeof j==="object"&&"code"in j?String(j.code):void 0}function L(j){return j()||j()}function G(j,q=process.platform,y=process.kill.bind(process)){if(q==="win32"||!Number.isInteger(j)||j<=1||j===process.pid)return!1;try{return y(-j,0),!0}catch(z){let B=Z(z);if(B==="ESRCH")return!1;if(B==="EPERM")return!0;throw z}}function N(j,q){return new Promise((y)=>{let z=["/PID",String(j),"/T"];if(q)z.push("/F");let B=I("taskkill",z,{stdio:"ignore",windowsHide:!0}),K=!1,J=(H)=>{if(K)return;K=!0,y(H)};B.once("error",()=>J(!1)),B.once("close",(H)=>J(H===0))})}async function F(j,q={}){if(!Number.isInteger(j)||j<=1||j===process.pid)return{success:!1,alreadyExited:!1,forced:!1};let y=q.platform??process.platform,z=q.gracePeriodMs??X,B=q.killProcess??process.kill.bind(process),K=q.taskkill??N,J=q.wait??x,H=q.validatePidOwnership??(()=>!0);if(!L(H))return{success:!1,alreadyExited:!1,forced:!1};if(y==="win32"){let V=await K(j,!1);if(await J(z),!H())return{success:V,alreadyExited:!1,forced:!1};let Y=await K(j,!0);return{success:V||Y,alreadyExited:!V&&!Y,forced:Y}}let Q=(V,Y)=>{try{return B(V,Y)}catch(D){return Z(D)==="ESRCH"}},W=Q(-j,"SIGTERM")||Q(j,"SIGTERM");if(await J(z),!H())return{success:W,alreadyExited:!1,forced:!1};let $=Q(-j,"SIGKILL")||Q(j,"SIGKILL");return{success:W||$,alreadyExited:!1,forced:$}}async function R(j,q={}){if(!Number.isInteger(j)||j<=1||j===process.pid)return{success:!1,alreadyExited:!1,forced:!1};if((q.platform??process.platform)==="win32")return{success:!1,alreadyExited:!1,forced:!1};let z=q.gracePeriodMs??X,B=q.killProcess??process.kill.bind(process),K=q.wait??x,J=q.validatePidOwnership??(()=>!0);if(!J())return{success:!1,alreadyExited:!1,forced:!1};let H=($)=>{try{return B(-j,$),"sent"}catch(V){return Z(V)==="ESRCH"?"missing":"failed"}},Q=H("SIGTERM");if(Q==="missing")return{success:!0,alreadyExited:!0,forced:!1};if(Q==="failed")return{success:!1,alreadyExited:!1,forced:!1};if(await K(z),!J())return{success:!1,alreadyExited:!1,forced:!1};let W=H("SIGKILL");return{success:W!=="failed",alreadyExited:W==="missing",forced:W==="sent"}}class b{child;state="owned";terminationPromise;terminationResult;platform;gracePeriodMs;killProcess;taskkill;wait;constructor(j,q={}){this.child=j;if(this.platform=q.platform??process.platform,this.gracePeriodMs=q.gracePeriodMs??X,this.killProcess=q.killProcess??process.kill.bind(process),this.taskkill=q.taskkill??N,this.wait=q.wait??x,q.releaseOnExit!==!1){let y=()=>{if(this.state==="owned")this.state="released"};j.once("close",y),j.once("error",y)}}release(){if(this.state==="owned")this.state="released"}terminate(){if(this.terminationPromise)return this.terminationPromise;if(this.terminationResult)return Promise.resolve(this.terminationResult);if(this.state==="released")return this.terminationResult={success:!0,alreadyExited:!0,forced:!1},Promise.resolve(this.terminationResult);return this.state="terminating",this.terminationPromise=this.terminateOwnedTree().then((j)=>{return this.state="released",this.terminationResult=j,j}),this.terminationPromise}async terminateOwnedTree(){let j=this.child.pid;if(!j)return{success:!1,alreadyExited:!0,forced:!1};if(this.platform==="win32"){let z=await this.taskkill(j,!1);await this.wait(this.gracePeriodMs);let B=await this.taskkill(j,!0);if(!z&&!B)return{success:this.signalDirectChild("SIGKILL"),alreadyExited:!1,forced:!0};return{success:!0,alreadyExited:!1,forced:!0}}let q=this.signalPosixTree(j,"SIGTERM");await this.wait(this.gracePeriodMs);let y=this.signalPosixTree(j,"SIGKILL");return{success:q||y,alreadyExited:!1,forced:y}}signalPosixTree(j,q){if(j<=1||j===process.pid)return this.signalDirectChild(q);try{return this.killProcess(-j,q)}catch(y){if(Z(y)==="ESRCH")return!0;return this.signalDirectChild(q)}}signalDirectChild(j){try{return this.child.kill(j)}catch(q){return Z(q)==="ESRCH"}}}function v(j,q,y={},z={}){let B=I(j,q,{...y,detached:process.platform==="win32"?y.detached:!0,windowsHide:y.windowsHide??!0});return{child:B,processTree:new b(B,z)}}
|
|
2
|
-
export{G as
|
|
2
|
+
export{G as Fe,F as Ge,R as He,v as Ie};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$a as a,ab as b,cb as c,gb as d,hb as e,ib as f,jb as g,kb as h,lb as i,mb as j,nb as k,sb as l,tb as m,ub as n,vb as o,xb as p,yb as q,zb as r}from"./chunk-y990fa4r.js";import"./chunk-5cgyevqj.js";import"./chunk-6gcmfvfj.js";import"./chunk-qgez5vw6.js";import"./chunk-phgqzja3.js";import"./chunk-atsw605q.js";import"./chunk-4vq34v09.js";import"./chunk-3rjmkaey.js";import"./chunk-hq18c6r9.js";import"./chunk-zwt7f9ab.js";import"./chunk-cc7dmst6.js";import"./chunk-v11r4ahz.js";import"./chunk-a7pvtxvz.js";import"./chunk-93jx06kq.js";import"./chunk-thstqcg3.js";import"./chunk-6360fg4j.js";import"./chunk-qvdcesry.js";import"./chunk-2mvp3rqw.js";import"./chunk-g510tpqt.js";import"./chunk-gy8esxaa.js";import"./chunk-0dj2qm8a.js";import"./chunk-y9nq48st.js";import"./chunk-4s0c6tkd.js";export{g as saveUserMessage,i as saveToolUse,j as saveToolResult,k as saveCompaction,h as saveAssistantMessage,d as isRootSystemPrompt,m as handleTaskListUpdate,n as handleSkillActivation,o as extractModelSwitch,r as executeLoopGenerator,f as drainLoop,c as checkStopHook,a as checkOutputRecovery,b as checkIncompleteIntent,q as checkAndCompactInLoop,p as applyToolDomainEffects,l as StreamingToolExecutor,e as ConversationState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Wc as a,Xc as b,Yc as c}from"./chunk-hh158y4e.js";import"./chunk-qggnvzkc.js";import"./chunk-e23sz81n.js";import"./chunk-v508x7cg.js";import"./chunk-atsw605q.js";import"./chunk-ckfc7j7m.js";import"./chunk-515mkr66.js";import"./chunk-a7pvtxvz.js";import"./chunk-93jx06kq.js";import"./chunk-thstqcg3.js";import"./chunk-6360fg4j.js";import"./chunk-qvdcesry.js";import"./chunk-2mvp3rqw.js";import"./chunk-g510tpqt.js";import"./chunk-gy8esxaa.js";import"./chunk-m6dh31kb.js";import"./chunk-0dj2qm8a.js";import"./chunk-y9nq48st.js";import"./chunk-4s0c6tkd.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{l as i}from"./chunk-
|
|
1
|
+
import{l as i}from"./chunk-4bbnytq5.js";import{Nf as s}from"./chunk-6360fg4j.js";import"./chunk-y9nq48st.js";import"./chunk-4s0c6tkd.js";import m from"node:path";var r={registry:i,currentWorkspace:s,inputCwd:()=>process.cwd(),write:console.log};function c(t,e){return m.resolve(e.inputCwd(),t)}function p(t){return t.map((e)=>{let o=e.isCurrent?"*":" ",n=e.gitBranch?` · ${e.gitBranch}`:"",d=e.available?"":" · unavailable";return`${o} ${e.name}${n}${d}
|
|
2
2
|
${e.path}`}).join(`
|
|
3
3
|
`)}async function l(t,e=r){let o=await e.registry.list(e.currentWorkspace());return e.write(t.json?JSON.stringify(o,null,2):p(o)),o}async function u(t,e=r){let o=await e.registry.bind(c(t.path,e),e.currentWorkspace());return e.write(t.json?JSON.stringify(o,null,2):`Bound project: ${o.path}`),o}async function j(t,e=r){let o=c(t.path,e),n=await e.registry.unbind(o);return e.write(t.json?JSON.stringify({path:o,removed:n},null,2):n?`Unbound project: ${o}`:`Project was not bound: ${o}`),n}var a={type:"boolean",default:!1,describe:"Print machine-readable JSON"},P={command:"list",aliases:["ls"],describe:"List bound projects",builder:(t)=>t.option("json",a),handler:async(t)=>{await l(t)}},b={command:"add <path>",aliases:["bind"],describe:"Bind a project folder",builder:(t)=>t.positional("path",{type:"string",demandOption:!0,describe:"Absolute or relative project folder"}).option("json",a),handler:async(t)=>{await u(t)}},h={command:"remove <path>",aliases:["rm","unbind"],describe:"Unbind a project folder",builder:(t)=>t.positional("path",{type:"string",demandOption:!0,describe:"Absolute or relative project folder"}).option("json",a),handler:async(t)=>{await j(t)}},y={command:"projects",aliases:["project"],describe:"Manage project bindings shared with Blade Web",builder:(t)=>t.command(P).command(b).command(h).demandCommand(1,"Choose list, add, or remove"),handler:()=>{return}};export{j as runProjectsRemove,l as runProjectsList,u as runProjectsAdd,y as projectsCommands,p as formatProjectList};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Db as ZJ}from"./chunk-pgy1mtgw.js";import{Eb as l0,Lb as L6,Mb as q6,Nb as t1,Ob as e1,Vb as Z6,bc as C$,lc as U0,nc as L2,oc as X1,pc as q2,wc as f$}from"./chunk-031n82db.js";import{Bc as t,Ec as z6,Fc as G0}from"./chunk-4s6w24r3.js";import{Fd as A6}from"./chunk-xf03b657.js";import{Gd as e6,Hd as C0,Id as r6,Jd as $J,Kd as j2,Md as J6}from"./chunk-aytg9gw0.js";import{qe as I0,re as A0,ue as JJ}from"./chunk-ytec29ph.js";import{De as Z$}from"./chunk-rcp5maxt.js";import{Jf as a}from"./chunk-znp4bexg.js";import{Nf as O0}from"./chunk-sqp79c1a.js";import{$f as j6}from"./chunk-a1wjgf44.js";import{hg as K$,jg as r2,kg as z0,lg as H1,ng as D6,pg as w6}from"./chunk-3qmawdwf.js";import{qg as U8}from"./chunk-7m5az521.js";function $$($){return $.role==="system"&&Array.isArray($.content)}function e0($){if($.role!=="system"||!$.metadata||Array.isArray($.metadata))return!1;return typeof $.metadata==="object"&&$.metadata.contextualProjectRules===!0}class a${systemMessages;_contextualSystemMessages;_history;_pending=[];context;constructor($,J){this.context=$;let Z=$.messages.find($$);if(this._contextualSystemMessages=$.messages.filter(e0),Z)this.systemMessages=[Z,...this._contextualSystemMessages];else if(J)this.systemMessages=[{role:"system",content:[{type:"text",text:J,providerOptions:{anthropic:{cacheControl:{type:"ephemeral"}}}}]},...this._contextualSystemMessages];else this.systemMessages=[...this._contextualSystemMessages];this._history=$.messages.filter((W)=>!$$(W)&&!e0(W))}get historyLength(){return this._history.length}get history(){return this._history}get pending(){return this._pending}toLLMMessages(){return[...this.systemMessages,...this._history,...this._pending]}getMessagesForLLM(){return this.toLLMMessages()}getHistory(){return this._history}appendPending($){this._pending.push($)}appendUser($){this._pending.push($)}appendAssistant($){this._pending.push($)}appendToolResult($){this._pending.push($)}appendContextualProjectInstructions($){if(!e0($))throw Error("Contextual project instructions require safe metadata");this._contextualSystemMessages.push($),this.systemMessages.push($)}syncContextualSystemMessages(){let $=this.systemMessages.filter($$);this.systemMessages.splice(0,this.systemMessages.length,...$,...this._contextualSystemMessages)}appendControl($,J){if($==="system")throw Error("Cannot append system control message via appendControl. Use constructor for root system prompt.");this._pending.push(J)}appendToHistory($){this._history.push($)}commitPending(){if(this._pending.length>0)this._history.push(...this._pending),this._pending=[]}replaceHistory($){this._history=$.filter((J)=>!$$(J)&&!e0(J))}restoreDurableHistory($){this._contextualSystemMessages=$.filter(e0),this._history=$.filter((J)=>!$$(J)&&!e0(J)),this._pending=[],this.syncContextualSystemMessages()}removeMessages($){this._history=this._history.filter((J)=>!$(J)),this._pending=this._pending.filter((J)=>!$(J)),this._contextualSystemMessages=this._contextualSystemMessages.filter((J)=>!$(J)),this.syncContextualSystemMessages()}writeback(){this.commitPending(),this.context.messages=[...this._contextualSystemMessages,...this._history]}get hasSystemPrompt(){return this.systemMessages.length>0}}function f2($){if($.isSubagent)return"continue";if(!$.budget||$.budget<=0)return"continue";if($.consecutiveContinuations>=3&&$.lastOutputDelta<500)return"stop";if($.usage/$.budget>=0.9)return"stop";return"continue"}function T2($){return{budget:$.budget,usage:0,consecutiveContinuations:0,lastOutputDelta:0,isSubagent:$.isSubagent??!1}}function k2($,J,Z){return{...$,usage:$.usage+J,lastOutputDelta:J,consecutiveContinuations:Z?$.consecutiveContinuations+1:0}}import i0 from"node:path";var VJ=new Set(["GOEXPERIMENT","GOOS","GOARCH","CGO_ENABLED","GO111MODULE","RUST_BACKTRACE","RUST_LOG","NODE_ENV","PYTHONUNBUFFERED","PYTHONDONTWRITEBYTECODE","GIT_TERMINAL_PROMPT","LANG","LANGUAGE","LC_ALL","LC_CTYPE","LC_TIME","CHARSET","TERM","COLORTERM","NO_COLOR","FORCE_COLOR","TZ","LS_COLORS","LSCOLORS","GREP_COLOR","GREP_COLORS"]),DJ=/^(LD_.+|DYLD_.+|PATH)$/,x2=/^([A-Za-z_][A-Za-z0-9_]*)=([\w./:@-]*)$/;function S$($){let J=$;while(!0){let Z=J.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!Z)break;let W=Z[1],Y=Z[2],K=W.match(x2);if(!K)break;let H=K[1];if(!VJ.has(H))break;J=Y}return J}function p4($){let J=$;while(!0){let Z=J.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!Z)break;let W=Z[1],Y=Z[2],K=W.match(x2);if(!K)break;let H=K[1];if(DJ.test(H))break;J=Y}return J}var wJ=[/^timeout[ \t]+(?:--foreground[ \t]+|--preserve-status[ \t]+|-v[ \t]+|--verbose[ \t]+|-k[ \t]+\S+[ \t]+|--kill-after[= ]\S+[ \t]+|-s[ \t]+\S+[ \t]+|--signal[= ]\S+[ \t]+)*\S+[ \t]+/,/^time[ \t]+/,/^nice[ \t]+(?:-n[ \t]+\d+[ \t]+|-\d+[ \t]+)?/,/^nohup[ \t]+/];function C1($){let J=$,Z=!0;while(Z){Z=!1;for(let W of wJ){let Y=J.match(W);if(Y){J=J.slice(Y[0].length),Z=!0;break}}if(J.startsWith("-- "))J=J.slice(3),Z=!0}return J}function s$($){let J=[],Z="",W=!1,Y=!1,K=!1;for(let H=0;H<$.length;H++){let X=$[H];if(K){Z+=X,K=!1;continue}if(X==="\\"&&!W){Z+=X,K=!0;continue}if(X==="'"&&!Y){W=!W,Z+=X;continue}if(X==='"'&&!W){Y=!Y,Z+=X;continue}if(W||Y){Z+=X;continue}if(X==="|"){if(H+1<$.length&&$[H+1]==="|"){if(Z.trim())J.push(Z.trim());Z="",H++;continue}return null}if(X===">"||X==="<")return null;if(X==="&"&&H+1<$.length&&$[H+1]==="&"){if(Z.trim())J.push(Z.trim());Z="",H++;continue}if(X==="&")return null;if(X===";"){if(Z.trim())J.push(Z.trim());Z="";continue}Z+=X}if(Z.trim())J.push(Z.trim());return J.length>0?J:null}function M2($){let J=!1,Z=!1,W=!1;for(let Y=0;Y<$.length;Y++){let K=$[Y];if(W){W=!1;continue}if(K==="\\"&&!J){W=!0;continue}if(K==="'"&&!Z){J=!J;continue}if(K==='"'&&!J){Z=!Z;continue}if(J)continue;if(K==="$"){let H=$[Y+1];if(H&&/[A-Za-z_@*#?!$0-9({]/.test(H))return!0}if(K==="`")return!0;if(Z)continue;if(K==="|")return!0;if(K===">"||K==="<")return!0;if(K==="{"){let H=$.slice(Y);if(/^\{[^}]*,[^}]*\}/.test(H)||/^\{[^}]*\.\.[^}]*\}/.test(H))return!0}}return!1}function A$($){let J=[],Z="",W=!1,Y=!1,K=!1;for(let H=0;H<$.length;H++){let X=$[H];if(K){Z+=X,K=!1;continue}if(X==="\\"&&!W){if(K=!0,Y){let Q=$[H+1];if(Q&&'$`"\\'.includes(Q))continue;Z+=X,K=!1}continue}if(X==="'"&&!Y){W=!W;continue}if(X==='"'&&!W){Y=!Y;continue}if(!W&&!Y&&/[ \t]/.test(X)){if(Z)J.push(Z),Z="";continue}Z+=X}if(Z)J.push(Z);return J}var jJ=new Set(["npm","pnpm","yarn","bun"]),h2=new Set(["biome","eslint","jest","mypy","pyright","pytest","ruff","tsc","vitest"]),LJ=new Set(["-u","--fix","--update","--update-snapshot","--updateSnapshot","--watch","--watchAll","--write"]);function qJ($){return $!==void 0&&/^(?:test|lint|build|type-?check)(?::[\w.-]+)*$/i.test($)}function OJ($){return $.replace(/\s+2>&1\s*$/,"").trim()}function GJ($,J,Z){if(!Z||J.length!==2)return;let W=/^(.+?)[ \t]+&&[ \t]+([\s\S]+)$/.exec($);if(!W)return;let Y=A$(W[1]??"");if(Y.length!==2||Y[0]!=="cd")return;let K=Y[1];if(!K||K==="-")return;let H=i0.isAbsolute(K)?i0.resolve(K):i0.resolve(Z,K);if(!l0.isWithinWorkspace(H,Z))return;return W[2]?.trim()||void 0}function J$($,J){let Z=S$(OJ($)),W=s$(Z);if(!W||M2(Z)||/[\r\n]/.test(Z))return!1;let Y=W.length===1?W[0]:GJ(Z,W,J);if(!Y)return!1;let K=A$(Y);if(K.length===0||K.some((z)=>[...LJ].some((D)=>z===D||z.startsWith(`${D}=`))))return!1;let[H,X,Q]=K;if(jJ.has(H??""))return qJ(X==="run"?Q:X)||X==="--test";if((H==="npx"||H==="bunx")&&h2.has(X??""))return!0;if(h2.has(H??""))return!0;if(H==="node"&&X==="--test")return!0;if(H==="go"&&["build","test","vet"].includes(X??""))return!0;return H==="cargo"&&["build","check","clippy","test"].includes(X??"")}function c4($,J){if($===void 0)return!0;if(typeof $!=="string"||$.split(/[\\/]/).includes(".."))return!1;if(!J)return!i0.isAbsolute($);let Z=i0.isAbsolute($)?i0.resolve($):i0.resolve(J,$);return l0.isWithinWorkspace(Z,J)}var v1=O0("Agent"),yJ=3;function I1($,J,Z){if($!=="length")return{action:"none"};if(J>=yJ)return{action:"truncated"};if(f2(Z)==="stop")return v1.info("[Loop] Token budget: diminishing returns detected, skipping recovery"),{action:"budget_stop"};return{action:"recover"}}var UJ=[/:\s*$/,/:\s*$/,/\.\.\.\s*$/,/让我(先|来|开始|查看|检查|修复)/,/Let me (first|start|check|look|fix)/i,/I('ll| will) (now |)(create|write|edit|update|modify|fix|add|implement)/i,/我(现在就|来|要)(创建|写入|编辑|修改|修复|添加|实现)/,/\d+\.\s+(First|Next|Then|Finally)/i],FJ=/```[\s\S]{50,}```/,R2="请执行你提到的操作,不要只是描述。使用 Edit/Write/ApplyPatch/Bash 工具来实际修改文件。",_J=2;function p1($,J,Z=!0){if(!$||J>=_J)return{action:"none"};if(!Z&&FJ.test($))return{action:"retry",prompt:R2};let W=$.slice(-200),Y=W.match(/```/g);if(Y&&Y.length%2!==0)return{action:"none"};if(UJ.some((H)=>H.test(W)))return{action:"retry",prompt:R2};return{action:"none"}}var bJ=[/\b(?:run|execute|rerun|re-run)\b[\s\S]{0,60}\b(?:tests?|test suite|lint|type-?check|build)\b/i,/\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:test|lint|build|type-?check)\b/i,/(?:运行|执行|跑|重新运行).{0,30}(?:测试|单测|集成测试|检查|构建)/],C2={test:/\b(?:tests?|test suite)\b|(?:测试|单测|集成测试)/i,lint:/\blint(?:ing)?\b/i,"type-check":/\btype[\s-]?check(?:ing)?\b|\btsc\b|类型检查/i,build:/\bbuild\b|构建/i},NJ={test:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test\b|(?:^|\s)(?:node|bun)\s+--test\b|(?:^|\s)(?:vitest|jest|pytest|go\s+test|cargo\s+test)\b/i,lint:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?lint\b/i,"type-check":/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?type-?check\b|(?:^|\s)tsc\b/i,build:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?build\b/i},PJ="The user explicitly required verification, but it has not run successfully. Do not finish or explain. Your next action must be a Bash tool call that runs the requested test, lint, type-check, or build command. Inspect the command result and fix any failure before finishing.",SJ="Required verification did not run successfully before the retry limit.",AJ=3;function I2($,J,Z,W){if(!Z.success)return;if(["Edit","Write","ApplyPatch","NotebookEdit"].includes(J)){$.clear();return}if(J==="Bash"&&typeof Z.metadata?.command==="string"&&Z.metadata.exit_code===0&&J$(Z.metadata.command,W)){$.add(Z.metadata.command);return}if(!["Task","TaskOutput"].includes(J))return;let Y=Z.metadata?.verificationCommands;if(!Array.isArray(Y))return;for(let K of Y)if(typeof K==="string"&&J$(K,W))$.add(K)}function g1($,J,Z){if(!$||!bJ.some((Q)=>Q.test($)))return{action:"none"};let W=Object.keys(C2).filter((Q)=>C2[Q].test($)),Y=[...J],K=W.filter((Q)=>!Y.some((z)=>NJ[Q].test(z)));if(W.length>0?K.length===0:Y.some((Q)=>J$(Q)))return{action:"none"};if(Z>=AJ)return{action:"fail",message:SJ};let X=W.length>1&&K.length>0?` Missing successful verification categories: ${K.join(", ")}.`:"";return{action:"retry",prompt:`${PJ}${X}`}}var EJ=[/\bdelegate\b[\s\S]{0,120}\b(?:Task tool|subagent|agent)\b/i,/\b(?:call|use|invoke)\b[\s\S]{0,80}\bTask tool\b/i,/(?:委派|交给|调用|使用).{0,60}(?:Task|子代理|子智能体)/],p2=[/\b(?:do not|don't|never)\s+(?:delegate|call|use|invoke)\b/i,/(?:不要|禁止|无需)(?:委派|调用|使用).{0,20}(?:Task|子代理|子智能体)?/];function g2($){return typeof $==="string"&&p2.some((J)=>J.test($))}var fJ=[/\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b[\s\S]{0,30}\bexactly once\b/i,/\bexactly once\b[\s\S]{0,30}\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b/i,/\bexactly one\b[\s\S]{0,30}\bTask(?: tool)? calls?\b/i,/(?:Task|子代理).{0,20}(?:恰好|仅|只)(?:调用|使用)?一次/,/(?:恰好|仅|只)(?:调用|使用)?一次.{0,20}(?:Task|子代理)/],TJ=[/\b(?:do not|don't|never)\s+(?:call|use|invoke)\s+(?:the\s+)?Task\b[\s\S]{0,30}\bexactly once\b/i,/\bTask\b[\s\S]{0,30}\b(?:does not|doesn't|need not)\b[\s\S]{0,30}\bexactly once\b/i,/\bmultiple\s+Task(?: tool)?\s+calls?\s+(?:are\s+)?allowed\b/i,/(?:不要|禁止).{0,12}(?:Task|子代理).{0,12}(?:恰好|仅|只)(?:调用|使用)?一次/];function kJ($){if(typeof $!=="string")return;if(TJ.some((J)=>J.test($)))return"multiple-allowed";return fJ.some((J)=>J.test($))?"required":void 0}function e$($){for(let J of $){let Z=kJ(J);if(Z!==void 0)return Z==="required"}return!1}var xJ="The user explicitly required delegation, but no Task tool call completed successfully. Do not solve the task directly or explain. Your next action must be a Task tool call using the requested subagent.",MJ="Required delegation did not complete before the retry limit.",hJ=3;function m2($,J,Z){let W=(typeof $==="string"?[$]:$??[]).map((H)=>H.trim()).filter(Boolean),Y=e$(W),K=!1;if(!Y)for(let H of W){if(p2.some((X)=>X.test(H)))break;if(EJ.some((X)=>X.test(H))){K=!0;break}}if(W.length===0||!Y&&!K||J.has("Task"))return{action:"none"};if(Z>=hJ)return{action:"fail",message:MJ};return{action:"retry",prompt:xJ}}var RJ=[/\b(?:use|create|enter|start|work\s+(?:in|inside))\b.{0,60}\bworktree\b/i,/(?:使用|创建|进入).{0,30}(?:worktree|工作树)/i],CJ=[/\b(?:exit|leave)\b.{0,40}\bworktree\b/i,/\bworktree\b.{0,60}\b(?:action\s+)?(?:keep|remove)\b/i,/(?:退出|离开).{0,30}(?:worktree|工作树)/i],vJ=[/\b(?:do not|don't|never|must not|should not)\b[^.!?;\n]{0,80}\b(?:git\s+)?worktree\b/gi,/\bwithout\b[^.!?;\n]{0,60}\b(?:git\s+)?worktree\b/gi,/(?:不要|禁止|不得|无需)[^。!?;\n]{0,50}(?:worktree|工作树)/gi];function u2($){return vJ.reduce((J,Z)=>J.replace(Z," "),$)}function $1($){if(typeof $!=="string")return!1;let J=u2($);return RJ.some((Z)=>Z.test(J))}var IJ="The user explicitly required git worktree isolation, but EnterWorktree has not completed successfully. Do not continue in the original workspace. Your next action must be an EnterWorktree tool call. Wait for its result before using file or Bash tools.",pJ="The user explicitly required leaving the managed worktree, but ExitWorktree has not completed successfully. Do not finish or explain. Your next action must be an ExitWorktree tool call using the action requested by the user.",gJ="Required worktree lifecycle did not complete before the retry limit.",mJ=3;function d2($,J,Z){if(!$)return{action:"none"};let W=u2($);if(!$1(W))return{action:"none"};let Y=CJ.some((H)=>H.test(W));if(J.has("TaskWorktree"))return{action:"none"};let K=!J.has("EnterWorktree")?"EnterWorktree":Y&&!J.has("ExitWorktree")?"ExitWorktree":void 0;if(!K)return{action:"none"};if(Z>=mJ)return{action:"fail",message:gJ};return{action:"retry",tool:K,prompt:K==="EnterWorktree"?IJ:pJ}}var v2=30000;async function m1($){try{let Z=Z$.getInstance().executeStopHooks({projectDir:$.workspaceRoot??a(),sessionId:$.sessionId,permissionMode:$.permissionMode,reason:$.reason,abortSignal:$.abortSignal}),W,Y=new Promise((K)=>{W=setTimeout(()=>K("timeout"),v2)});try{let K=await Promise.race([Z,Y]);if(K==="timeout")return v1.warn(`[Loop] Stop hook 超时 (${v2}ms),按 shouldStop: true 处理`),{action:"stop"};let H=K;if(!H.shouldStop)return{action:"continue",reason:H.continueReason};return{action:"stop"}}finally{clearTimeout(W)}}catch(J){return v1.warn("[Loop] Stop hook execution failed:",J),{action:"stop"}}}async function uJ($,J){let Z;while(!(Z=await $.next()).done)if(J)await J(Z.value);return Z.value}var dJ=[/<system-reminder>[\s\S]*?<\/system-reminder>/gi,/<file[^>]*>[\s\S]*?<\/file>/gi,/<hooks_context>[\s\S]*?<\/hooks_context>/gi,/<[^>]+>/g];function cJ($){if(typeof $==="string")return $;if(Array.isArray($))return $.map((J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"&&"text"in J){let Z=J.text;return typeof Z==="string"?Z:""}return""}).join(" ");return""}function iJ($){let J=$;for(let Q of dJ)J=J.replace(Q," ");J=J.replace(/^\s*\/[a-zA-Z][\w-]*\s+/,"");let Z=J.replace(/\s+/g," ").trim();if(!Z)return"";let W=Z.match(/^(.+?)(?:[.!?]\s|[。!?](?=\S|$)|$)/),Y=W&&W[1].length>=6?W[1]:Z;if(Y=Y.trim().replace(/[\s.。!!??,,;;::-]+$/,""),Y.length<=60)return Y;let K=Y.slice(0,60),H=K.lastIndexOf(" ");return`${(H>36?K.slice(0,H):K).trimEnd()}…`}function c2($){return iJ(cJ($))}import{EventEmitter as lJ}from"events";import i2 from"node:path";function u1($){if(r2($.sessionId),!i2.isAbsolute($.projectPath))throw Error("projectPath must be absolute");return{sessionId:$.sessionId,projectPath:i2.resolve($.projectPath)}}function l2($){let J=u1($);return JSON.stringify([J.projectPath,J.sessionId])}function Z5($,J){return l2($)===l2(J)}class W$ extends lJ{static instance;constructor(){super();this.setMaxListeners(100)}static getInstance(){if(!W$.instance)W$.instance=new W$;return W$.instance}publish($,J,Z,W){let Y=u1($);this.emit("event",{sessionId:Y.sessionId,projectPath:Y.projectPath,type:J,...W!==void 0?{seq:W}:{},properties:Z})}subscribe($){return this.on("event",$),()=>this.off("event",$)}}var E$=W$.getInstance();var M0=O0("Agent"),J1=new Set;async function rJ($,J){let Z=$.sessionId;if(!Z||$.subagentInfo)return;if(J1.has(Z))return;if(J1.size>=5000)J1.clear();J1.add(Z);try{let W=$.workspaceRoot,Y=await f$.findSessionMetadata(Z,W);if(!Y)return;if(Y.title&&Y.title.trim())return;let K=c2(J);if(!K)return;await f$.updateSessionMetadata(Z,Y.projectPath,{title:K}),E$.publish({sessionId:Z,projectPath:Y.projectPath},"session.updated",{title:K})}catch(W){M0.debug?.("[Loop] 自动生成会话标题失败:",W)}}var d1=`<turn_aborted>
|
|
1
|
+
import{Eb as ZJ}from"./chunk-5cgyevqj.js";import{Fb as l0,Mb as L6,Nb as q6,Ob as t1,Pb as e1,Wb as Z6,cc as C$,mc as U0,oc as L2,pc as X1,qc as q2,xc as f$}from"./chunk-6gcmfvfj.js";import{Cc as t,Fc as z6,Gc as G0}from"./chunk-phgqzja3.js";import{Gd as A6}from"./chunk-atsw605q.js";import{Hd as e6,Id as C0,Jd as r6,Kd as $J,Ld as j2,Nd as J6}from"./chunk-4vq34v09.js";import{re as I0,se as A0,ve as JJ}from"./chunk-hq18c6r9.js";import{Ee as Z$}from"./chunk-cc7dmst6.js";import{Nf as a}from"./chunk-6360fg4j.js";import{Rf as O0}from"./chunk-qvdcesry.js";import{dg as j6}from"./chunk-gy8esxaa.js";import{lg as K$,ng as r2,og as z0,pg as H1,rg as D6,tg as w6}from"./chunk-y9nq48st.js";import{ug as U8}from"./chunk-4s0c6tkd.js";function $$($){return $.role==="system"&&Array.isArray($.content)}function e0($){if($.role!=="system"||!$.metadata||Array.isArray($.metadata))return!1;return typeof $.metadata==="object"&&$.metadata.contextualProjectRules===!0}class a${systemMessages;_contextualSystemMessages;_history;_pending=[];context;constructor($,J){this.context=$;let Z=$.messages.find($$);if(this._contextualSystemMessages=$.messages.filter(e0),Z)this.systemMessages=[Z,...this._contextualSystemMessages];else if(J)this.systemMessages=[{role:"system",content:[{type:"text",text:J,providerOptions:{anthropic:{cacheControl:{type:"ephemeral"}}}}]},...this._contextualSystemMessages];else this.systemMessages=[...this._contextualSystemMessages];this._history=$.messages.filter((W)=>!$$(W)&&!e0(W))}get historyLength(){return this._history.length}get history(){return this._history}get pending(){return this._pending}toLLMMessages(){return[...this.systemMessages,...this._history,...this._pending]}getMessagesForLLM(){return this.toLLMMessages()}getHistory(){return this._history}appendPending($){this._pending.push($)}appendUser($){this._pending.push($)}appendAssistant($){this._pending.push($)}appendToolResult($){this._pending.push($)}appendContextualProjectInstructions($){if(!e0($))throw Error("Contextual project instructions require safe metadata");this._contextualSystemMessages.push($),this.systemMessages.push($)}syncContextualSystemMessages(){let $=this.systemMessages.filter($$);this.systemMessages.splice(0,this.systemMessages.length,...$,...this._contextualSystemMessages)}appendControl($,J){if($==="system")throw Error("Cannot append system control message via appendControl. Use constructor for root system prompt.");this._pending.push(J)}appendToHistory($){this._history.push($)}commitPending(){if(this._pending.length>0)this._history.push(...this._pending),this._pending=[]}replaceHistory($){this._history=$.filter((J)=>!$$(J)&&!e0(J))}restoreDurableHistory($){this._contextualSystemMessages=$.filter(e0),this._history=$.filter((J)=>!$$(J)&&!e0(J)),this._pending=[],this.syncContextualSystemMessages()}removeMessages($){this._history=this._history.filter((J)=>!$(J)),this._pending=this._pending.filter((J)=>!$(J)),this._contextualSystemMessages=this._contextualSystemMessages.filter((J)=>!$(J)),this.syncContextualSystemMessages()}writeback(){this.commitPending(),this.context.messages=[...this._contextualSystemMessages,...this._history]}get hasSystemPrompt(){return this.systemMessages.length>0}}function f2($){if($.isSubagent)return"continue";if(!$.budget||$.budget<=0)return"continue";if($.consecutiveContinuations>=3&&$.lastOutputDelta<500)return"stop";if($.usage/$.budget>=0.9)return"stop";return"continue"}function T2($){return{budget:$.budget,usage:0,consecutiveContinuations:0,lastOutputDelta:0,isSubagent:$.isSubagent??!1}}function k2($,J,Z){return{...$,usage:$.usage+J,lastOutputDelta:J,consecutiveContinuations:Z?$.consecutiveContinuations+1:0}}import i0 from"node:path";var VJ=new Set(["GOEXPERIMENT","GOOS","GOARCH","CGO_ENABLED","GO111MODULE","RUST_BACKTRACE","RUST_LOG","NODE_ENV","PYTHONUNBUFFERED","PYTHONDONTWRITEBYTECODE","GIT_TERMINAL_PROMPT","LANG","LANGUAGE","LC_ALL","LC_CTYPE","LC_TIME","CHARSET","TERM","COLORTERM","NO_COLOR","FORCE_COLOR","TZ","LS_COLORS","LSCOLORS","GREP_COLOR","GREP_COLORS"]),DJ=/^(LD_.+|DYLD_.+|PATH)$/,x2=/^([A-Za-z_][A-Za-z0-9_]*)=([\w./:@-]*)$/;function S$($){let J=$;while(!0){let Z=J.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!Z)break;let W=Z[1],Y=Z[2],K=W.match(x2);if(!K)break;let H=K[1];if(!VJ.has(H))break;J=Y}return J}function p4($){let J=$;while(!0){let Z=J.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!Z)break;let W=Z[1],Y=Z[2],K=W.match(x2);if(!K)break;let H=K[1];if(DJ.test(H))break;J=Y}return J}var wJ=[/^timeout[ \t]+(?:--foreground[ \t]+|--preserve-status[ \t]+|-v[ \t]+|--verbose[ \t]+|-k[ \t]+\S+[ \t]+|--kill-after[= ]\S+[ \t]+|-s[ \t]+\S+[ \t]+|--signal[= ]\S+[ \t]+)*\S+[ \t]+/,/^time[ \t]+/,/^nice[ \t]+(?:-n[ \t]+\d+[ \t]+|-\d+[ \t]+)?/,/^nohup[ \t]+/];function C1($){let J=$,Z=!0;while(Z){Z=!1;for(let W of wJ){let Y=J.match(W);if(Y){J=J.slice(Y[0].length),Z=!0;break}}if(J.startsWith("-- "))J=J.slice(3),Z=!0}return J}function s$($){let J=[],Z="",W=!1,Y=!1,K=!1;for(let H=0;H<$.length;H++){let X=$[H];if(K){Z+=X,K=!1;continue}if(X==="\\"&&!W){Z+=X,K=!0;continue}if(X==="'"&&!Y){W=!W,Z+=X;continue}if(X==='"'&&!W){Y=!Y,Z+=X;continue}if(W||Y){Z+=X;continue}if(X==="|"){if(H+1<$.length&&$[H+1]==="|"){if(Z.trim())J.push(Z.trim());Z="",H++;continue}return null}if(X===">"||X==="<")return null;if(X==="&"&&H+1<$.length&&$[H+1]==="&"){if(Z.trim())J.push(Z.trim());Z="",H++;continue}if(X==="&")return null;if(X===";"){if(Z.trim())J.push(Z.trim());Z="";continue}Z+=X}if(Z.trim())J.push(Z.trim());return J.length>0?J:null}function M2($){let J=!1,Z=!1,W=!1;for(let Y=0;Y<$.length;Y++){let K=$[Y];if(W){W=!1;continue}if(K==="\\"&&!J){W=!0;continue}if(K==="'"&&!Z){J=!J;continue}if(K==='"'&&!J){Z=!Z;continue}if(J)continue;if(K==="$"){let H=$[Y+1];if(H&&/[A-Za-z_@*#?!$0-9({]/.test(H))return!0}if(K==="`")return!0;if(Z)continue;if(K==="|")return!0;if(K===">"||K==="<")return!0;if(K==="{"){let H=$.slice(Y);if(/^\{[^}]*,[^}]*\}/.test(H)||/^\{[^}]*\.\.[^}]*\}/.test(H))return!0}}return!1}function A$($){let J=[],Z="",W=!1,Y=!1,K=!1;for(let H=0;H<$.length;H++){let X=$[H];if(K){Z+=X,K=!1;continue}if(X==="\\"&&!W){if(K=!0,Y){let Q=$[H+1];if(Q&&'$`"\\'.includes(Q))continue;Z+=X,K=!1}continue}if(X==="'"&&!Y){W=!W;continue}if(X==='"'&&!W){Y=!Y;continue}if(!W&&!Y&&/[ \t]/.test(X)){if(Z)J.push(Z),Z="";continue}Z+=X}if(Z)J.push(Z);return J}var jJ=new Set(["npm","pnpm","yarn","bun"]),h2=new Set(["biome","eslint","jest","mypy","pyright","pytest","ruff","tsc","vitest"]),LJ=new Set(["-u","--fix","--update","--update-snapshot","--updateSnapshot","--watch","--watchAll","--write"]);function qJ($){return $!==void 0&&/^(?:test|lint|build|type-?check)(?::[\w.-]+)*$/i.test($)}function OJ($){return $.replace(/\s+2>&1\s*$/,"").trim()}function GJ($,J,Z){if(!Z||J.length!==2)return;let W=/^(.+?)[ \t]+&&[ \t]+([\s\S]+)$/.exec($);if(!W)return;let Y=A$(W[1]??"");if(Y.length!==2||Y[0]!=="cd")return;let K=Y[1];if(!K||K==="-")return;let H=i0.isAbsolute(K)?i0.resolve(K):i0.resolve(Z,K);if(!l0.isWithinWorkspace(H,Z))return;return W[2]?.trim()||void 0}function J$($,J){let Z=S$(OJ($)),W=s$(Z);if(!W||M2(Z)||/[\r\n]/.test(Z))return!1;let Y=W.length===1?W[0]:GJ(Z,W,J);if(!Y)return!1;let K=A$(Y);if(K.length===0||K.some((z)=>[...LJ].some((D)=>z===D||z.startsWith(`${D}=`))))return!1;let[H,X,Q]=K;if(jJ.has(H??""))return qJ(X==="run"?Q:X)||X==="--test";if((H==="npx"||H==="bunx")&&h2.has(X??""))return!0;if(h2.has(H??""))return!0;if(H==="node"&&X==="--test")return!0;if(H==="go"&&["build","test","vet"].includes(X??""))return!0;return H==="cargo"&&["build","check","clippy","test"].includes(X??"")}function c4($,J){if($===void 0)return!0;if(typeof $!=="string"||$.split(/[\\/]/).includes(".."))return!1;if(!J)return!i0.isAbsolute($);let Z=i0.isAbsolute($)?i0.resolve($):i0.resolve(J,$);return l0.isWithinWorkspace(Z,J)}var v1=O0("Agent"),yJ=3;function I1($,J,Z){if($!=="length")return{action:"none"};if(J>=yJ)return{action:"truncated"};if(f2(Z)==="stop")return v1.info("[Loop] Token budget: diminishing returns detected, skipping recovery"),{action:"budget_stop"};return{action:"recover"}}var UJ=[/:\s*$/,/:\s*$/,/\.\.\.\s*$/,/让我(先|来|开始|查看|检查|修复)/,/Let me (first|start|check|look|fix)/i,/I('ll| will) (now |)(create|write|edit|update|modify|fix|add|implement)/i,/我(现在就|来|要)(创建|写入|编辑|修改|修复|添加|实现)/,/\d+\.\s+(First|Next|Then|Finally)/i],FJ=/```[\s\S]{50,}```/,R2="请执行你提到的操作,不要只是描述。使用 Edit/Write/ApplyPatch/Bash 工具来实际修改文件。",_J=2;function p1($,J,Z=!0){if(!$||J>=_J)return{action:"none"};if(!Z&&FJ.test($))return{action:"retry",prompt:R2};let W=$.slice(-200),Y=W.match(/```/g);if(Y&&Y.length%2!==0)return{action:"none"};if(UJ.some((H)=>H.test(W)))return{action:"retry",prompt:R2};return{action:"none"}}var bJ=[/\b(?:run|execute|rerun|re-run)\b[\s\S]{0,60}\b(?:tests?|test suite|lint|type-?check|build)\b/i,/\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:test|lint|build|type-?check)\b/i,/(?:运行|执行|跑|重新运行).{0,30}(?:测试|单测|集成测试|检查|构建)/],C2={test:/\b(?:tests?|test suite)\b|(?:测试|单测|集成测试)/i,lint:/\blint(?:ing)?\b/i,"type-check":/\btype[\s-]?check(?:ing)?\b|\btsc\b|类型检查/i,build:/\bbuild\b|构建/i},NJ={test:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test\b|(?:^|\s)(?:node|bun)\s+--test\b|(?:^|\s)(?:vitest|jest|pytest|go\s+test|cargo\s+test)\b/i,lint:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?lint\b/i,"type-check":/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?type-?check\b|(?:^|\s)tsc\b/i,build:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?build\b/i},PJ="The user explicitly required verification, but it has not run successfully. Do not finish or explain. Your next action must be a Bash tool call that runs the requested test, lint, type-check, or build command. Inspect the command result and fix any failure before finishing.",SJ="Required verification did not run successfully before the retry limit.",AJ=3;function I2($,J,Z,W){if(!Z.success)return;if(["Edit","Write","ApplyPatch","NotebookEdit"].includes(J)){$.clear();return}if(J==="Bash"&&typeof Z.metadata?.command==="string"&&Z.metadata.exit_code===0&&J$(Z.metadata.command,W)){$.add(Z.metadata.command);return}if(!["Task","TaskOutput"].includes(J))return;let Y=Z.metadata?.verificationCommands;if(!Array.isArray(Y))return;for(let K of Y)if(typeof K==="string"&&J$(K,W))$.add(K)}function g1($,J,Z){if(!$||!bJ.some((Q)=>Q.test($)))return{action:"none"};let W=Object.keys(C2).filter((Q)=>C2[Q].test($)),Y=[...J],K=W.filter((Q)=>!Y.some((z)=>NJ[Q].test(z)));if(W.length>0?K.length===0:Y.some((Q)=>J$(Q)))return{action:"none"};if(Z>=AJ)return{action:"fail",message:SJ};let X=W.length>1&&K.length>0?` Missing successful verification categories: ${K.join(", ")}.`:"";return{action:"retry",prompt:`${PJ}${X}`}}var EJ=[/\bdelegate\b[\s\S]{0,120}\b(?:Task tool|subagent|agent)\b/i,/\b(?:call|use|invoke)\b[\s\S]{0,80}\bTask tool\b/i,/(?:委派|交给|调用|使用).{0,60}(?:Task|子代理|子智能体)/],p2=[/\b(?:do not|don't|never)\s+(?:delegate|call|use|invoke)\b/i,/(?:不要|禁止|无需)(?:委派|调用|使用).{0,20}(?:Task|子代理|子智能体)?/];function g2($){return typeof $==="string"&&p2.some((J)=>J.test($))}var fJ=[/\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b[\s\S]{0,30}\bexactly once\b/i,/\bexactly once\b[\s\S]{0,30}\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b/i,/\bexactly one\b[\s\S]{0,30}\bTask(?: tool)? calls?\b/i,/(?:Task|子代理).{0,20}(?:恰好|仅|只)(?:调用|使用)?一次/,/(?:恰好|仅|只)(?:调用|使用)?一次.{0,20}(?:Task|子代理)/],TJ=[/\b(?:do not|don't|never)\s+(?:call|use|invoke)\s+(?:the\s+)?Task\b[\s\S]{0,30}\bexactly once\b/i,/\bTask\b[\s\S]{0,30}\b(?:does not|doesn't|need not)\b[\s\S]{0,30}\bexactly once\b/i,/\bmultiple\s+Task(?: tool)?\s+calls?\s+(?:are\s+)?allowed\b/i,/(?:不要|禁止).{0,12}(?:Task|子代理).{0,12}(?:恰好|仅|只)(?:调用|使用)?一次/];function kJ($){if(typeof $!=="string")return;if(TJ.some((J)=>J.test($)))return"multiple-allowed";return fJ.some((J)=>J.test($))?"required":void 0}function e$($){for(let J of $){let Z=kJ(J);if(Z!==void 0)return Z==="required"}return!1}var xJ="The user explicitly required delegation, but no Task tool call completed successfully. Do not solve the task directly or explain. Your next action must be a Task tool call using the requested subagent.",MJ="Required delegation did not complete before the retry limit.",hJ=3;function m2($,J,Z){let W=(typeof $==="string"?[$]:$??[]).map((H)=>H.trim()).filter(Boolean),Y=e$(W),K=!1;if(!Y)for(let H of W){if(p2.some((X)=>X.test(H)))break;if(EJ.some((X)=>X.test(H))){K=!0;break}}if(W.length===0||!Y&&!K||J.has("Task"))return{action:"none"};if(Z>=hJ)return{action:"fail",message:MJ};return{action:"retry",prompt:xJ}}var RJ=[/\b(?:use|create|enter|start|work\s+(?:in|inside))\b.{0,60}\bworktree\b/i,/(?:使用|创建|进入).{0,30}(?:worktree|工作树)/i],CJ=[/\b(?:exit|leave)\b.{0,40}\bworktree\b/i,/\bworktree\b.{0,60}\b(?:action\s+)?(?:keep|remove)\b/i,/(?:退出|离开).{0,30}(?:worktree|工作树)/i],vJ=[/\b(?:do not|don't|never|must not|should not)\b[^.!?;\n]{0,80}\b(?:git\s+)?worktree\b/gi,/\bwithout\b[^.!?;\n]{0,60}\b(?:git\s+)?worktree\b/gi,/(?:不要|禁止|不得|无需)[^。!?;\n]{0,50}(?:worktree|工作树)/gi];function u2($){return vJ.reduce((J,Z)=>J.replace(Z," "),$)}function $1($){if(typeof $!=="string")return!1;let J=u2($);return RJ.some((Z)=>Z.test(J))}var IJ="The user explicitly required git worktree isolation, but EnterWorktree has not completed successfully. Do not continue in the original workspace. Your next action must be an EnterWorktree tool call. Wait for its result before using file or Bash tools.",pJ="The user explicitly required leaving the managed worktree, but ExitWorktree has not completed successfully. Do not finish or explain. Your next action must be an ExitWorktree tool call using the action requested by the user.",gJ="Required worktree lifecycle did not complete before the retry limit.",mJ=3;function d2($,J,Z){if(!$)return{action:"none"};let W=u2($);if(!$1(W))return{action:"none"};let Y=CJ.some((H)=>H.test(W));if(J.has("TaskWorktree"))return{action:"none"};let K=!J.has("EnterWorktree")?"EnterWorktree":Y&&!J.has("ExitWorktree")?"ExitWorktree":void 0;if(!K)return{action:"none"};if(Z>=mJ)return{action:"fail",message:gJ};return{action:"retry",tool:K,prompt:K==="EnterWorktree"?IJ:pJ}}var v2=30000;async function m1($){try{let Z=Z$.getInstance().executeStopHooks({projectDir:$.workspaceRoot??a(),sessionId:$.sessionId,permissionMode:$.permissionMode,reason:$.reason,abortSignal:$.abortSignal}),W,Y=new Promise((K)=>{W=setTimeout(()=>K("timeout"),v2)});try{let K=await Promise.race([Z,Y]);if(K==="timeout")return v1.warn(`[Loop] Stop hook 超时 (${v2}ms),按 shouldStop: true 处理`),{action:"stop"};let H=K;if(!H.shouldStop)return{action:"continue",reason:H.continueReason};return{action:"stop"}}finally{clearTimeout(W)}}catch(J){return v1.warn("[Loop] Stop hook execution failed:",J),{action:"stop"}}}async function uJ($,J){let Z;while(!(Z=await $.next()).done)if(J)await J(Z.value);return Z.value}var dJ=[/<system-reminder>[\s\S]*?<\/system-reminder>/gi,/<file[^>]*>[\s\S]*?<\/file>/gi,/<hooks_context>[\s\S]*?<\/hooks_context>/gi,/<[^>]+>/g];function cJ($){if(typeof $==="string")return $;if(Array.isArray($))return $.map((J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"&&"text"in J){let Z=J.text;return typeof Z==="string"?Z:""}return""}).join(" ");return""}function iJ($){let J=$;for(let Q of dJ)J=J.replace(Q," ");J=J.replace(/^\s*\/[a-zA-Z][\w-]*\s+/,"");let Z=J.replace(/\s+/g," ").trim();if(!Z)return"";let W=Z.match(/^(.+?)(?:[.!?]\s|[。!?](?=\S|$)|$)/),Y=W&&W[1].length>=6?W[1]:Z;if(Y=Y.trim().replace(/[\s.。!!??,,;;::-]+$/,""),Y.length<=60)return Y;let K=Y.slice(0,60),H=K.lastIndexOf(" ");return`${(H>36?K.slice(0,H):K).trimEnd()}…`}function c2($){return iJ(cJ($))}import{EventEmitter as lJ}from"events";import i2 from"node:path";function u1($){if(r2($.sessionId),!i2.isAbsolute($.projectPath))throw Error("projectPath must be absolute");return{sessionId:$.sessionId,projectPath:i2.resolve($.projectPath)}}function l2($){let J=u1($);return JSON.stringify([J.projectPath,J.sessionId])}function Z5($,J){return l2($)===l2(J)}class W$ extends lJ{static instance;constructor(){super();this.setMaxListeners(100)}static getInstance(){if(!W$.instance)W$.instance=new W$;return W$.instance}publish($,J,Z,W){let Y=u1($);this.emit("event",{sessionId:Y.sessionId,projectPath:Y.projectPath,type:J,...W!==void 0?{seq:W}:{},properties:Z})}subscribe($){return this.on("event",$),()=>this.off("event",$)}}var E$=W$.getInstance();var M0=O0("Agent"),J1=new Set;async function rJ($,J){let Z=$.sessionId;if(!Z||$.subagentInfo)return;if(J1.has(Z))return;if(J1.size>=5000)J1.clear();J1.add(Z);try{let W=$.workspaceRoot,Y=await f$.findSessionMetadata(Z,W);if(!Y)return;if(Y.title&&Y.title.trim())return;let K=c2(J);if(!K)return;await f$.updateSessionMetadata(Z,Y.projectPath,{title:K}),E$.publish({sessionId:Z,projectPath:Y.projectPath},"session.updated",{title:K})}catch(W){M0.debug?.("[Loop] 自动生成会话标题失败:",W)}}var d1=`<turn_aborted>
|
|
2
2
|
The previous turn was interrupted. Commands or tool calls may have partially completed; inspect the workspace and running processes before retrying.
|
|
3
3
|
</turn_aborted>`,r0="Tool execution was blocked because its durable call record could not be committed. No tool side effect was started.",n2="Tool execution completed, but its durable result record could not be committed. Further model and tool execution was stopped. The operation may have completed; inspect external state before retrying.";class Y$ extends Error{phase;constructor($,J){super($==="user_message"?"Conversation input could not be committed. No further model request was started.":"Model output could not be committed. The run was stopped before any further model request or successful completion.",J);this.phase=$;this.name="DurableConversationPersistenceError"}}function n0($){return $.executionEngine?.getContextManager()}async function H0($,J,Z,W=null,Y,K={}){let H=K.required??$.executionEngine!==void 0;try{let X=n0($),Q=typeof Z==="string"?Z.trim()!=="":Z.some((z)=>z.type==="text"?z.text.trim()!=="":!0);if(X&&J.sessionId&&Q){let z=await X.saveMessage(J.sessionId,"user",Z,W,Y,J.subagentInfo);if(H&&!z)throw Error("Durable user-message commit returned no identity");if(Y?.clientVisible!==!1)rJ(J,Z);return z}if(H&&J.sessionId&&Q)throw Error("Durable user-message storage is unavailable")}catch(X){if(M0.warn("[Loop] 保存用户消息失败:",X),H)throw new Y$("user_message",{cause:X})}return null}async function g($,J,Z,W,Y,K,H={}){let X=H.required??$.executionEngine!==void 0;try{let Q=n0($),z=Boolean(Z.trim()||Y?.trim());if(Q&&J.sessionId&&z){let D=await Q.saveMessage(J.sessionId,"assistant",Z,W,K,J.subagentInfo,Y);if(X&&!D)throw Error("Durable assistant-message commit returned no identity");return D}if(X&&J.sessionId&&z)throw Error("Durable assistant-message storage is unavailable")}catch(Q){if(M0.warn("[Loop] 保存助手消息失败:",Q),X)throw new Y$("assistant_message",{cause:Q})}return null}async function o2($,J,Z){try{let W=n0($);if(W&&J.sessionId)return await W.saveMessage(J.sessionId,"system",d1,Z,void 0,J.subagentInfo)}catch(W){M0.warn("[Loop] 保存中断边界失败:",W)}return null}async function a2($,J,Z,W,Y){try{let K=n0($);if(!K||!J.sessionId||Z.length===0)return null;return await K.saveMessage(J.sessionId,"system",`<contextual-project-instructions-ref count="${Z.length}" />`,Y,{contextualProjectRules:!0,ruleReferences:JSON.parse(JSON.stringify(Z.map((H)=>({...H})))),triggerPaths:[...W]},J.subagentInfo)}catch(K){M0.warn("[Loop] 保存 contextual project rules provenance 失败:",K)}return null}async function c1($,J,Z,W,Y,K={}){try{let H=n0($);if(H&&J.sessionId){let X=await H.saveToolUse(J.sessionId,Z,W,Y,J.subagentInfo);if(K.required&&!X)throw Error("Durable tool-use commit returned no identity");return X}if(K.required&&J.sessionId)throw Error("Durable tool-use storage is unavailable")}catch(H){if(M0.warn("[Loop] 保存工具调用失败:",H),K.required)throw H}return null}async function Z1($,J,Z,W,Y,K,H,X,Q,z={}){try{let D=n0($);if(D&&J.sessionId){let q=await D.saveToolResult(J.sessionId,Z,W,Y,K,H,J.subagentInfo,X,Q);if(z.required&&!q)throw Error("Durable tool-result commit returned no identity");return q}if(z.required&&J.sessionId)throw Error("Durable tool-result storage is unavailable")}catch(D){if(M0.warn("[Loop] 保存工具结果失败:",D),z.required)throw D}return null}async function T$($,J,Z,W,Y={}){try{let K=n0($);if(K&&J.sessionId){let H=await K.saveCompaction(J.sessionId,Z,W,null);if(Y.required&&!H)throw Error("Compaction checkpoint commit returned no identity");return H||null}if(Y.required&&J.sessionId)throw Error("Compaction checkpoint storage is unavailable")}catch(K){if(M0.warn("[Loop] 保存压缩数据失败:",K),Y.required)throw K}return null}import{createHash as G4}from"node:crypto";import{promises as W8}from"node:fs";import Y8 from"node:path";import{nanoid as R0}from"nanoid";import*as i from"node:fs/promises";import*as o0 from"node:path";var s2={enabled:!0,maxIndexLines:200};var nJ="memory",t2="MEMORY.md";class i1{memoryDir;config;initialized=!1;constructor($,J,Z){if(Z)this.memoryDir=Z;else{let W=K$($);this.memoryDir=o0.join(W,nJ)}this.config={...s2,...J}}async initialize(){if(this.initialized)return;await i.mkdir(this.memoryDir,{recursive:!0}),this.initialized=!0}async loadIndex(){if(!this.config.enabled)return null;await this.initialize();let $=o0.join(this.memoryDir,t2);try{let J=await i.readFile($,"utf-8");if(!J.trim())return null;let Z=J.split(`
|
|
4
4
|
`),Y=Z.slice(0,this.config.maxIndexLines).join(`
|
|
@@ -118,7 +118,7 @@ Full output saved to: ${X}`}catch{return`${J}
|
|
|
118
118
|
|
|
119
119
|
${Y}`}}import{Mutex as k8}from"async-mutex";import{nanoid as x8}from"nanoid";import*as j0 from"node:fs/promises";import*as B6 from"node:path";import{Mutex as L8}from"async-mutex";import q8 from"write-file-atomic";var K1=1,M$=8388608;function Q6($,J){let Z={version:K1,sessionId:$,messages:J.map(({recovered:W,...Y})=>Y)};return`${JSON.stringify(Z)}
|
|
120
120
|
`}function o1($,J){return $ instanceof Error&&"code"in $&&$.code===J}function O8($){if(typeof $==="string")return!0;if(!Array.isArray($))return!1;return $.every((J)=>{if(!J||typeof J!=="object"||!("type"in J))return!1;if(J.type==="text")return"text"in J&&typeof J.text==="string";return J.type==="image_url"&&"image_url"in J&&typeof J.image_url==="object"&&J.image_url!==null&&"url"in J.image_url&&typeof J.image_url.url==="string"})}function G8($,J,Z){let W;try{W=JSON.parse($)}catch(K){throw Error(`Invalid steering inbox JSON: ${J}`,{cause:K})}if(!W||typeof W!=="object"||!("version"in W)||W.version!==K1||!("sessionId"in W)||W.sessionId!==Z||!("messages"in W)||!Array.isArray(W.messages))throw Error(`Invalid steering inbox record: ${J}`);let Y=W.messages.map((K)=>{if(!K||typeof K!=="object"||!("id"in K)||typeof K.id!=="string"||!("content"in K)||!O8(K.content)||!("queuedAt"in K)||typeof K.queuedAt!=="number"||"persisted"in K&&typeof K.persisted!=="boolean"||"origin"in K&&K.origin!=="user"&&K.origin!=="background_subagent"||"metadata"in K&&(K.metadata===null||typeof K.metadata!=="object"||Array.isArray(K.metadata))||"outputSchema"in K&&K.outputSchema!==void 0&&(!K.outputSchema||typeof K.outputSchema!=="object"||Array.isArray(K.outputSchema)))throw Error(`Invalid steering inbox message: ${J}`);let H="outputSchema"in K&&K.outputSchema!==void 0?X1(K.outputSchema).schema:void 0;return{id:K.id,content:K.content,queuedAt:K.queuedAt,..."persisted"in K&&K.persisted===!0?{persisted:!0}:{},..."origin"in K&&K.origin?{origin:K.origin}:{},..."metadata"in K&&K.metadata?{metadata:JSON.parse(JSON.stringify(K.metadata))}:{},...H?{outputSchema:H}:{}}});return{version:K1,sessionId:Z,messages:Y}}function y8($){return new Set($.flatMap((J)=>J.type==="inbox_acknowledged"?J.data.messageIds:[]))}class Q1{workspaceRoot;sessionId;filePath;mutex=new L8;messages=[];constructor($,J,Z){this.workspaceRoot=$;this.sessionId=J;this.filePath=Z}static async open($,J){let Z=new Q1($,J,H1($,J));return await Z.loadAndReconcile(),Z}async enqueue($,J){return this.mutex.runExclusive(async()=>{if(J&&!J(this.messages))return!1;let Z=[...this.messages,{...$,recovered:!1}],W=Q6(this.sessionId,Z);if(Buffer.byteLength(W)>M$)return!1;return await this.persist(Z,W),this.messages=Z,!0})}async acknowledge($){if($.length===0)return;let J=new Set($);await this.mutex.runExclusive(async()=>{let Z=this.messages.filter((W)=>!J.has(W.id));this.messages=Z,await this.persist(Z)})}list(){return this.messages.map(($)=>({...$,content:typeof $.content==="string"?$.content:$.content.map((J)=>J.type==="text"?{...J}:{...J,image_url:{...J.image_url}}),...$.outputSchema?{outputSchema:JSON.parse(JSON.stringify($.outputSchema))}:{},...$.metadata?{metadata:JSON.parse(JSON.stringify($.metadata))}:{}}))}count(){return this.messages.length}recoveredCount(){return this.messages.filter(($)=>$.recovered).length}async loadAndReconcile(){await this.mutex.runExclusive(async()=>{let $={version:K1,sessionId:this.sessionId,messages:[]};try{if((await j0.stat(this.filePath)).size>M$)throw Error(`Steering inbox exceeds ${M$} bytes: ${this.filePath}`);await j0.chmod(this.filePath,384),$=G8(await j0.readFile(this.filePath,"utf8"),this.filePath,this.sessionId)}catch(Y){if(!o1(Y,"ENOENT"))throw Y}let J=z0(this.workspaceRoot,this.sessionId),Z=new Set;try{Z=y8(z6(await j0.readFile(J,"utf8"),J))}catch(Y){if(!o1(Y,"ENOENT"))throw Y}let W=$.messages.filter((Y)=>!Z.has(Y.id)).map((Y)=>({...Y,recovered:!0}));if(this.messages=W,W.length!==$.messages.length)await this.persist(W)})}async persist($,J){if(await j0.mkdir(B6.dirname(this.filePath),{recursive:!0,mode:448}),$.length===0){await j0.unlink(this.filePath).catch((W)=>{if(!o1(W,"ENOENT"))throw W});return}let Z=J??Q6(this.sessionId,$);if(Buffer.byteLength(Z)>M$)throw Error(`Steering inbox exceeds ${M$} bytes: ${this.filePath}`);await q8(this.filePath,Z,{encoding:"utf8",mode:384,fsync:!0})}}import*as y0 from"node:fs/promises";import*as O6 from"node:path";import{nanoid as s}from"nanoid";class a0{sessionId;projectPath;static instances=new Map;store;subscribers=new Set;highestSeq=0;constructor($,J){this.sessionId=$;this.projectPath=J;this.store=new G0(z0(J,$))}static for($,J){let Z=`${J}\x00${$}`,W=a0.instances.get(Z);if(!W)W=new a0($,J),a0.instances.set(Z,W);return W}static release($,J){a0.instances.delete(`${J}\x00${$}`)}get lastSeq(){return this.highestSeq}async commit($){let J=await this.store.append($);return this.record(J),J}async commitBatch($){if($.length===0)return[];let J=await this.store.appendBatch($);for(let Z of J)this.record(Z);return J}async commitValidated($){let J=await this.store.appendValidated($);return this.record(J),J}async commitValidatedBatch($){let J=await this.store.appendValidatedBatch($);for(let Z of J)this.record(Z);return J}emitDelta($){for(let J of this.subscribers)J.onDelta?.($);E$.publish({sessionId:this.sessionId,projectPath:this.projectPath},"delta",{delta:$})}subscribe($,J){if(this.subscribers.add($),J?.fromSeq!==void 0)this.replay($,J.fromSeq);return()=>{this.subscribers.delete($)}}async replay($,J){let Z=await this.store.readFromSeq(J);for(let W of Z)await $.onCommitted(W)}record($){if(typeof $.seq==="number"&&$.seq>this.highestSeq)this.highestSeq=$.seq;for(let J of this.subscribers){let Z=J.onCommitted($);if(Z)Promise.resolve(Z).catch(()=>{return})}E$.publish({sessionId:this.sessionId,projectPath:this.projectPath},`committed.${$.type}`,{event:$},$.seq)}}function Q$($){let J=null,Z=null;for(let W of $){if(W.type==="turn_started"){J=W.data;continue}if(W.type==="turn_completed")Z={type:"turn_completed",data:W.data};else if(W.type==="turn_aborted")Z={type:"turn_aborted",data:W.data};else continue;if(J?.turnId===Z.data.turnId)J=null}return{active:J,lastTerminal:Z}}class S0 extends Error{}var F8="Tool execution was interrupted by a process restart. The operation may have partially completed. Inspect the workspace, running processes, and external state before deciding whether to retry it.",_8=20,b8=1e4,N8=1e5,P8=2592000000,V6=128,S8=1e6;function A8($){if(!$||typeof $!=="object"||Array.isArray($))return;let J=$;if(typeof J.goalId!=="string"||J.goalId.length===0||J.goalId.length>V6||typeof J.verificationAttempt!=="number"||!Number.isSafeInteger(J.verificationAttempt)||J.verificationAttempt<1||J.verificationAttempt>S8||typeof J.verifierSessionId!=="string"||J.verifierSessionId.length===0||J.verifierSessionId.length>V6||typeof J.evidenceSha256!=="string"||!/^[a-f0-9]{64}$/.test(J.evidenceSha256)||typeof J.goalUpdatedAt!=="string"||!Number.isFinite(Date.parse(J.goalUpdatedAt)))return;return{goalId:J.goalId,verificationAttempt:J.verificationAttempt,verifierSessionId:J.verifierSessionId,evidenceSha256:J.evidenceSha256,goalUpdatedAt:J.goalUpdatedAt}}function G6($,J){let Z=$.data.metadata;if(!Z||typeof Z!=="object"||Array.isArray(Z))return;let W=Z.turnFinalization;if(!W||typeof W!=="object"||Array.isArray(W))return;let Y=W,K=Y.turnId,H=Y.inputMessageIds,X=Y.turnsCount,Q=Y.toolCallsCount,z=Y.durationMs,D=Array.isArray(H)?H.filter((V)=>typeof V==="string"&&V.length>0&&V.length<=128):[];if(typeof K!=="string"||K.length===0||K.length>128||J!==void 0&&K!==J||!Array.isArray(H)||H.length>_8||D.length!==H.length||typeof X!=="number"||!Number.isSafeInteger(X)||X<0||X>b8||typeof Q!=="number"||!Number.isSafeInteger(Q)||Q<0||Q>N8||typeof z!=="number"||!Number.isSafeInteger(z)||z<0||z>P8)return;let q;if("goalFinalization"in Y){if(q=A8(Y.goalFinalization),!q)return}return{turnId:K,inputMessageIds:[...new Set(D)],turnsCount:X,toolCallsCount:Q,durationMs:z,...q?{goalFinalization:q}:{}}}function E8($,J){let Z=t($),W=Z.findLastIndex((Y)=>Y.type==="turn_started"&&Y.data.turnId===J);if(W<0)return;for(let Y=Z.length-1;Y>W;Y--){let K=Z[Y];if(K?.type!=="message_created")continue;let H=G6(K,J);if(H)return H}return}function f8($){let J=t($);for(let Z=J.length-1;Z>=0;Z--){let W=J[Z];if(W?.type!=="message_created")continue;let Y=G6(W);if(!Y?.goalFinalization)continue;if(!J.slice(0,Z).some((H)=>H.type==="turn_started"&&H.data.turnId===Y.turnId))continue;return{turnId:Y.turnId,finalization:Y}}return}function a1($,J){let Z=t($),W=J?Z.findLastIndex((Q)=>Q.type==="turn_started"&&Q.data.turnId===J):-1;if(J&&W<0)return{all:[],orphaned:[]};let Y=new Map,K=new Set,H=new Set;for(let Q of Z.slice(W+1)){if(Q.type==="interaction_requested"){H.add(Q.data.toolCallId);continue}if(Q.type!=="part_created")continue;let z=Q.data.payload&&typeof Q.data.payload==="object"&&!Array.isArray(Q.data.payload)?Q.data.payload:{},D=typeof z.toolCallId==="string"?z.toolCallId:Q.data.partId;if(Q.data.partType==="tool_call")Y.set(D,{toolCallId:D,messageId:Q.data.messageId,toolName:typeof z.toolName==="string"?z.toolName:"unknown",input:z.input??null});else if(Q.data.partType==="tool_result")K.add(D),K.add(Q.data.partId),K.add(Q.data.messageId)}let X=[...Y.values()];return{all:X,orphaned:X.filter((Q)=>!K.has(Q.toolCallId)&&!H.has(Q.toolCallId))}}class v0{projectPath;maxSessions;version;constructor($=a(),J=100,Z=j6()){this.projectPath=$,this.maxSessions=J,this.version=Z}createEvent($,J,Z){return{id:s(),sessionId:J,projectPath:this.projectPath,timestamp:new Date().toISOString(),type:$,cwd:this.projectPath,gitBranch:D6(this.projectPath),version:this.version,data:Z}}log($){return a0.for($,this.projectPath)}async ensureSessionCreated($,J){let Z=z0(this.projectPath,$);if((await new G0(Z).readAll()).length>0)return;let K=new Date().toISOString(),H={sessionId:$,rootId:J?.parentSessionId??$,parentId:J?.parentSessionId,relationType:J?"subagent":void 0,resumedFrom:J?.resumedFrom,rootAgentId:J?.rootAgentId,resumeDepth:J?.resumeDepth,title:void 0,status:"running",taskStatus:J?"running":"queued",taskFailure:null,agentType:J?.subagentType,model:void 0,permission:void 0,createdAt:K,updatedAt:K},X=this.createEvent("session_created",$,H);await this.log($).commit(X)}buildCompactionMetadata($){let J={trigger:$.trigger,preTokens:$.preTokens};if($.reason)J.reason=$.reason;if($.strategy)J.strategy=$.strategy;if($.postTokens!==void 0)J.postTokens=$.postTokens;if($.filesIncluded)J.filesIncluded=$.filesIncluded;if($.replacementMessages)J.checkpointVersion=L6;return J}async initialize(){try{let $=K$(this.projectPath);await y0.mkdir($,{recursive:!0,mode:493}),console.log(`[PersistentStore] 初始化存储目录: ${$}`)}catch($){console.warn("[PersistentStore] 无法创建持久化存储目录:",$)}}async saveMessage($,J,Z,W=null,Y,K,H){try{await this.ensureSessionCreated($,K);let X=new Date().toISOString(),Q=s(),z={messageId:Q,role:J,parentMessageId:W??void 0,inboxMessageId:Y?.inboxMessageId,createdAt:X,model:Y?.model,usage:Y?.usage,metadata:Y?JSON.parse(JSON.stringify(Y)):void 0},D=this.createEvent("message_created",$,z),q=J==="assistant"&&H?.trim()?[this.createEvent("part_created",$,{partId:s(),messageId:Q,partType:"reasoning",payload:{text:H},createdAt:X})]:[],V=typeof Z==="string"?[this.createEvent("part_created",$,{partId:s(),messageId:Q,partType:"text",payload:{text:Z},createdAt:X})]:Z.map((w)=>this.createEvent("part_created",$,{partId:s(),messageId:Q,partType:w.type==="text"?"text":"image",payload:w.type==="text"?{text:w.text}:{mimeType:T8(w.image_url.url)??"image/png",dataUrl:w.image_url.url},createdAt:X}));return await this.log($).commitBatch([D,...q,...V]),Q}catch(X){throw console.error(`[PersistentStore] 保存消息失败 (session: ${$}):`,X),X}}async acknowledgeInboxMessages($,J){if(J.length===0)return;await this.ensureSessionCreated($);let Z=new Date().toISOString();await this.log($).commit(this.createEvent("inbox_acknowledged",$,{messageIds:[...J],acknowledgedAt:Z}))}async persistBackgroundSubagentCompletion($,J){if(J.inboxMessageId!==`background-subagent-completion:${J.childSessionId}`)return{eligible:!1,acknowledged:!1,persisted:!1};await this.ensureSessionCreated($);let Z={eligible:!1,acknowledged:!1,persisted:!1};return await this.log($).commitValidatedBatch((W)=>{let Y=t(W),K=Y.some((V)=>V.type==="inbox_acknowledged"&&V.data.messageIds.includes(J.inboxMessageId)),H=Y.find((V)=>V.type==="message_created"&&V.data.inboxMessageId===J.inboxMessageId),X=Y.findLast((V)=>{if(V.type!=="part_created"||V.data.partType!=="tool_call"||!V.data.payload||typeof V.data.payload!=="object"||Array.isArray(V.data.payload))return!1;let w=V.data.payload;if(w.toolName!=="Task"||!w.input||typeof w.input!=="object"||Array.isArray(w.input))return!1;let b=w.input,T=b.resume_from??b.resume;return b.run_in_background===!0&&b.subagent_session_id===J.childSessionId&&b.description===J.subagentRef.subagentDescription&&(b.subagent_type===void 0||b.subagent_type===J.subagentRef.subagentType)&&(b.resume_from===void 0||b.resume===void 0||b.resume_from===b.resume)&&(T===void 0?J.subagentRef.subagentResumedFrom===void 0:T===J.subagentRef.subagentResumedFrom)});if(!X)return Z={eligible:!1,acknowledged:K,persisted:!1,...H?{messageId:H.data.messageId}:{}},[];if(K)return Z={eligible:!0,acknowledged:!0,persisted:!1,...H?{messageId:H.data.messageId}:{}},[];let Q=Y.find((V)=>V.type==="part_created"&&V.data.partType==="subtask_ref"&&V.data.payload!==null&&typeof V.data.payload==="object"&&!Array.isArray(V.data.payload)&&V.data.payload.childSessionId===J.childSessionId&&V.data.payload.status===J.subagentRef.subagentStatus);if(H&&Q)return Z={eligible:!0,acknowledged:!1,persisted:!1,messageId:H.data.messageId},[];let z=new Date().toISOString(),D=H?.data.messageId??s(),q=[];if(!H){let V={messageId:D,role:"user",inboxMessageId:J.inboxMessageId,createdAt:z,metadata:JSON.parse(JSON.stringify(J.metadata))};q.push(this.createEvent("message_created",$,V)),q.push(this.createEvent("part_created",$,{partId:s(),messageId:D,partType:"text",payload:{text:J.content},createdAt:z}))}if(!Q){let V=Y.findLast((b)=>b.type==="part_created"&&b.data.partType==="subtask_ref"&&b.data.messageId===X.data.messageId&&b.data.payload!==null&&typeof b.data.payload==="object"&&!Array.isArray(b.data.payload)&&b.data.payload.childSessionId===J.childSessionId),w=V?.data.payload&&typeof V.data.payload==="object"&&!Array.isArray(V.data.payload)?V.data.payload:void 0;q.push(this.createEvent("part_created",$,{partId:s(),messageId:X.data.messageId,partType:"subtask_ref",payload:{childSessionId:J.subagentRef.subagentSessionId,agentType:J.subagentRef.subagentType,description:J.subagentRef.subagentDescription??"",status:J.subagentRef.subagentStatus,summary:J.subagentRef.subagentSummary??"",resumedFrom:J.subagentRef.subagentResumedFrom??null,rootAgentId:J.subagentRef.subagentRootId??J.subagentRef.subagentSessionId,resumeDepth:J.subagentRef.subagentResumeDepth??0,verificationVerdict:J.subagentRef.verificationVerdict??null,startedAt:typeof w?.startedAt==="string"?w.startedAt:z,finishedAt:z},createdAt:z}))}return Z={eligible:!0,acknowledged:!1,persisted:q.length>0,messageId:D},q}),Z}async saveTurnStart($,J){await this.ensureSessionCreated($);try{await this.log($).commitValidated((Z)=>{let W=t(Z);if(W.some((K)=>K.type==="turn_started"&&K.data.turnId===J.turnId))throw new S0;let Y=Q$(W).active;if(Y)throw Error(`Session already has an active turn: ${Y.turnId}`);return this.createEvent("turn_started",$,J)})}catch(Z){if(!(Z instanceof S0))throw Z}}async saveTurnCompletion($,J,Z=[]){await this.ensureSessionCreated($);try{await this.log($).commitValidatedBatch((W)=>{let Y=t(W),K=new Set(Y.flatMap((z)=>z.type==="inbox_acknowledged"?z.data.messageIds:[])),H=[...new Set(Z)].filter((z)=>!K.has(z)),X=Y.findLast((z)=>(z.type==="turn_completed"||z.type==="turn_aborted")&&z.data.turnId===J.turnId);if(X){if(X.type==="turn_aborted"||H.length===0)throw new S0;return[this.createEvent("inbox_acknowledged",$,{messageIds:H,acknowledgedAt:J.completedAt})]}let Q=Q$(Y).active;if(!Q||Q.turnId!==J.turnId)throw Error(`Turn is not active: ${J.turnId}`);return[...H.length>0?[this.createEvent("inbox_acknowledged",$,{messageIds:H,acknowledgedAt:J.completedAt})]:[],this.createEvent("turn_completed",$,J)]})}catch(W){if(!(W instanceof S0))throw W}}async saveTurnAbort($,J){await this.saveTurnTerminal($,"turn_aborted",J)}async loadInterruptedToolCalls($){let J=await this.loadEvents($);if(!J)return[];let Z=t(J),W=Q$(Z).active;return W?a1(Z,W.turnId).orphaned.map((Y)=>({...Y,input:structuredClone(Y.input)})):[]}async loadBackgroundTaskChildIds($){let J=await this.loadEvents($);if(!J)return new Set;let Z=t(J).flatMap((W)=>{if(W.type!=="part_created"||W.data.partType!=="tool_call"||!W.data.payload||typeof W.data.payload!=="object"||Array.isArray(W.data.payload))return[];let Y=W.data.payload;if(Y.toolName!=="Task"||!Y.input||typeof Y.input!=="object"||Array.isArray(Y.input))return[];let K=Y.input;return K.run_in_background===!0&&typeof K.subagent_session_id==="string"?[K.subagent_session_id]:[]});return new Set(Z)}async recoverInterruptedTurn($,J={}){await this.ensureSessionCreated($);let Z;try{await this.log($).commitValidatedBatch((W)=>{let Y=t(W),K=Q$(Y).active,H=a1(Y);if(!K&&H.orphaned.length===0)throw new S0;let X=K?E8(Y,K.turnId):void 0;if(K&&X&&H.orphaned.length===0){Z={turnId:K.turnId,outcome:"completed",finalization:X};let V=new Set(Y.flatMap((T)=>T.type==="inbox_acknowledged"?T.data.messageIds:[])),w=X.inputMessageIds.filter((T)=>!V.has(T)),b=new Date().toISOString();return[...w.length>0?[this.createEvent("inbox_acknowledged",$,{messageIds:w,acknowledgedAt:b})]:[],this.createEvent("turn_completed",$,{turnId:K.turnId,completedAt:b,turnsCount:X.turnsCount,toolCallsCount:X.toolCallsCount,durationMs:X.durationMs})]}Z=K?{turnId:K.turnId,outcome:"aborted"}:void 0;let Q=K?a1(Y,K.turnId).all.length:0,z=new Date().toISOString(),D=K?Date.parse(K.startedAt):Number.NaN,q=H.orphaned.flatMap((V)=>{let w=J.adoptedToolResults?.get(V.toolCallId),b=w?.toolCallId===V.toolCallId&&w.toolName===V.toolName?w:void 0,T=this.createEvent("part_created",$,{partId:V.toolCallId,messageId:b?V.messageId:V.toolCallId,partType:"tool_result",payload:b?{toolCallId:V.toolCallId,toolName:V.toolName,output:b.output,error:b.error??null,...b.metadata===void 0?{}:{metadata:b.metadata}}:{toolCallId:V.toolCallId,toolName:V.toolName,output:null,error:F8,metadata:{processRestartRecovery:!0,sideEffectsUncertain:!0}},createdAt:z});if(!b?.subagentRef)return[T];let A=b.subagentRef;return[T,this.createEvent("part_created",$,{partId:s(),messageId:V.messageId,partType:"subtask_ref",payload:{childSessionId:A.subagentSessionId,agentType:A.subagentType,description:A.subagentDescription??"",status:A.subagentStatus,summary:A.subagentSummary??"",resumedFrom:A.subagentResumedFrom??null,rootAgentId:A.subagentRootId??A.subagentSessionId,resumeDepth:A.subagentResumeDepth??0,verificationVerdict:A.verificationVerdict??null,startedAt:z,finishedAt:z},createdAt:z})]});return K?[...q,this.createEvent("turn_aborted",$,{turnId:K.turnId,cause:"process_restart",abortedAt:z,turnsCount:0,toolCallsCount:Q,durationMs:Number.isFinite(D)?Math.max(0,Date.now()-D):0})]:q})}catch(W){if(!(W instanceof S0))throw W}return Z}async loadLatestGoalFinalization($){let J=await this.loadEvents($);return J?f8(J):void 0}async saveInteractionRequest($,J){await this.ensureSessionCreated($),await this.log($).commitValidated((Z)=>{if(Z.some((Y)=>Y.type==="interaction_requested"&&Y.data.requestId===J.requestId))throw Error(`Interaction request already exists: ${J.requestId}`);return this.createEvent("interaction_requested",$,J)})}async saveInteractionResponse($,J){await this.ensureSessionCreated($),await this.log($).commitValidated((Z)=>{if(!Z.some((K)=>K.type==="interaction_requested"&&K.data.requestId===J.requestId))throw Error(`Interaction request not found: ${J.requestId}`);if(Z.some((K)=>K.type==="interaction_responded"&&K.data.requestId===J.requestId))throw Error(`Interaction already responded: ${J.requestId}`);return this.createEvent("interaction_responded",$,J)})}async saveInteractionRecovery($,J){await this.ensureSessionCreated($),await this.log($).commitValidated((Z)=>{if(!Z.some((K)=>K.type==="interaction_responded"&&K.data.requestId===J.requestId))throw Error(`Interaction response not found: ${J.requestId}`);if(Z.some((K)=>K.type==="interaction_recovered"&&K.data.requestId===J.requestId))throw Error(`Interaction already recovered: ${J.requestId}`);return this.createEvent("interaction_recovered",$,J)})}async saveReviewStart($,J){await this.ensureSessionCreated($),await this.log($).commitValidated((Z)=>{if(Z.some((K)=>K.type==="review_started"&&K.data.reviewId===J.reviewId))throw Error(`Review already exists: ${J.reviewId}`);if(Z.some((K)=>K.type==="review_started"&&!Z.some((H)=>H.type==="review_completed"&&H.data.reviewId===K.data.reviewId)))throw Error("Session already has an active review");return this.createEvent("review_started",$,J)})}async saveReviewCompletion($,J){await this.ensureSessionCreated($),await this.log($).commitValidated((Z)=>{if(!Z.some((K)=>K.type==="review_started"&&K.data.reviewId===J.reviewId))throw Error(`Review not found: ${J.reviewId}`);if(Z.some((K)=>K.type==="review_completed"&&K.data.reviewId===J.reviewId))throw Error(`Review already completed: ${J.reviewId}`);return this.createEvent("review_completed",$,J)})}async saveToolUse($,J,Z,W=null,Y){try{await this.ensureSessionCreated($,Y);let K=new Date().toISOString(),H=W??s(),X=[];if(!W){let D={messageId:H,role:"assistant",parentMessageId:void 0,createdAt:K};X.push(this.createEvent("message_created",$,D))}let Q=s(),z={partId:Q,messageId:H,partType:"tool_call",payload:{toolCallId:Q,toolName:J,input:Z},createdAt:K};if(X.push(this.createEvent("part_created",$,z)),J==="Task"&&Z&&typeof Z==="object"){let D=Z,q=typeof D.subagent_session_id==="string"?D.subagent_session_id:void 0,V=typeof D.subagent_type==="string"?D.subagent_type:void 0;if(q&&V){let w={partId:s(),messageId:H,partType:"subtask_ref",payload:{childSessionId:q,agentType:V,status:"running",summary:typeof D.description==="string"?D.description:"",startedAt:K},createdAt:K};X.push(this.createEvent("part_created",$,w))}}return await this.log($).commitBatch(X),Q}catch(K){throw console.error(`[PersistentStore] 保存工具调用失败 (session: ${$}):`,K),K}}async saveToolResult($,J,Z,W,Y=null,K,H,X,Q){try{await this.ensureSessionCreated($,H);let z=new Date().toISOString(),D=Y??s();return await this.log($).commitValidatedBatch((q)=>{let V=X?.subagentStatus==="running"?t(q).findLast((k)=>k.type==="part_created"&&k.data.partType==="subtask_ref"&&k.data.payload!==null&&typeof k.data.payload==="object"&&!Array.isArray(k.data.payload)&&k.data.payload.childSessionId===X.subagentSessionId&&(k.data.payload.status==="completed"||k.data.payload.status==="failed"||k.data.payload.status==="cancelled")):void 0,w=V?.data.payload,b=Q&&typeof Q==="object"&&!Array.isArray(Q)?Q:{},T=w?{...b,subagentSessionId:w.childSessionId,subagentType:w.agentType,description:w.description,subagentStatus:w.status,subagentSummary:w.summary,subagentResumedFrom:w.resumedFrom,subagentRootId:w.rootAgentId,subagentResumeDepth:w.resumeDepth,verificationVerdict:w.verificationVerdict}:Q,A=[];if(!Y){let k={messageId:D,role:"assistant",parentMessageId:void 0,createdAt:z};A.push(this.createEvent("message_created",$,k))}let x={partId:J,messageId:D,partType:"tool_result",payload:{toolCallId:J,toolName:Z,output:W,error:K??null,...T===void 0?{}:{metadata:T}},createdAt:z};if(A.push(this.createEvent("part_created",$,x)),X&&!V){let k=X.subagentStatus==="running"?null:z,W0={partId:s(),messageId:D,partType:"subtask_ref",payload:{childSessionId:X.subagentSessionId,agentType:X.subagentType,description:X.subagentDescription??"",status:X.subagentStatus,summary:X.subagentSummary??"",resumedFrom:X.subagentResumedFrom??null,rootAgentId:X.subagentRootId??X.subagentSessionId,resumeDepth:X.subagentResumeDepth??0,verificationVerdict:X.verificationVerdict??null,startedAt:z,finishedAt:k},createdAt:z};A.push(this.createEvent("part_created",$,W0))}return A}),J}catch(z){throw console.error(`[PersistentStore] 保存工具结果失败 (session: ${$}):`,z),z}}async saveCompaction($,J,Z,W=null){try{await this.ensureSessionCreated($);let Y=new Date().toISOString(),K=s(),H={messageId:K,role:"system",parentMessageId:W??void 0,createdAt:Y},X=this.buildCompactionMetadata(Z),Q={partId:s(),messageId:K,partType:"summary",payload:{text:J,metadata:X,...Z.replacementMessages?{replacementMessages:q6(Z.replacementMessages)}:{}},createdAt:Y},z=[this.createEvent("message_created",$,H),this.createEvent("part_created",$,Q)];return await this.log($).commitBatch(z),K}catch(Y){throw console.error(`[PersistentStore] 保存压缩失败 (session: ${$}):`,Y),Y}}async initSession($,J){await this.ensureSessionCreated($,J)}async loadEvents($){try{let J=z0(this.projectPath,$),W=await new G0(J).readAll();return W.length>0?t(W):null}catch{return null}}async loadSession($){try{let J=z0(this.projectPath,$),Z=new G0(J),W=t(await Z.readAll());if(W.length===0)return null;let Y=W.find((K)=>K.type==="session_created");return{sessionId:$,userId:void 0,preferences:{},configuration:{},startTime:new Date(Y?.timestamp??W[0].timestamp).getTime()}}catch{return null}}async loadConversation($){try{let J=z0(this.projectPath,$),Z=new G0(J),W=t(await Z.readAll());if(W.length===0)return null;let Y=new Map;for(let Q of W){if(Q.type==="message_created")Y.set(Q.data.messageId,{id:Q.data.messageId,role:Q.data.role,content:"",timestamp:new Date(Q.timestamp).getTime()});if(Q.type==="part_created"&&Q.data.partType==="text"){let z=Y.get(Q.data.messageId);if(z){let D=Q.data.payload;z.content=D.text??""}}if(Q.type==="part_created"&&Q.data.partType==="image"){let z=Y.get(Q.data.messageId);if(z)z.content=z.content?`${z.content}
|
|
121
|
-
[Image]`:"[Image]"}}let K=Array.from(Y.values()),H=W[W.length-1],X=new Date(H.timestamp).getTime();return{messages:K,topics:[],lastActivity:X}}catch{return null}}async listSessions(){try{let $=K$(this.projectPath);return(await y0.readdir($)).filter((Z)=>Z.endsWith(".jsonl")).map((Z)=>Z.replace(".jsonl","")).sort()}catch{return[]}}async getSessionSummary($){try{let J=z0(this.projectPath,$),Z=new G0(J);if(!(await Z.getStats()).exists)return null;let Y=await Z.readAll();if(Y.length===0)return null;let K=t(Y),H=Y[Y.length-1],X=K.filter((Q)=>Q.type==="message_created"&&["user","assistant"].includes(Q.data.role)).length;return{sessionId:$,lastActivity:new Date(H.timestamp).getTime(),messageCount:X,topics:[]}}catch{return null}}async deleteSession($){try{let J=z0(this.projectPath,$);await new G0(J).delete(),await y0.unlink(H1(this.projectPath,$)).catch((W)=>{if(W.code!=="ENOENT")throw W});try{let{getProjectionDb:W,removeSessionFromProjection:Y}=await import("./chunk-
|
|
121
|
+
[Image]`:"[Image]"}}let K=Array.from(Y.values()),H=W[W.length-1],X=new Date(H.timestamp).getTime();return{messages:K,topics:[],lastActivity:X}}catch{return null}}async listSessions(){try{let $=K$(this.projectPath);return(await y0.readdir($)).filter((Z)=>Z.endsWith(".jsonl")).map((Z)=>Z.replace(".jsonl","")).sort()}catch{return[]}}async getSessionSummary($){try{let J=z0(this.projectPath,$),Z=new G0(J);if(!(await Z.getStats()).exists)return null;let Y=await Z.readAll();if(Y.length===0)return null;let K=t(Y),H=Y[Y.length-1],X=K.filter((Q)=>Q.type==="message_created"&&["user","assistant"].includes(Q.data.role)).length;return{sessionId:$,lastActivity:new Date(H.timestamp).getTime(),messageCount:X,topics:[]}}catch{return null}}async deleteSession($){try{let J=z0(this.projectPath,$);await new G0(J).delete(),await y0.unlink(H1(this.projectPath,$)).catch((W)=>{if(W.code!=="ENOENT")throw W});try{let{getProjectionDb:W,removeSessionFromProjection:Y}=await import("./chunk-5xc50n8e.js"),K=await W();if(K)Y(K,$,this.projectPath)}catch{}}catch(J){console.warn(`[PersistentStore] 删除会话失败 (session: ${$}):`,J)}}async cleanupOldSessions(){try{let $=await this.listSessions();if($.length<=this.maxSessions)return;let W=(await Promise.all($.map((Y)=>this.getSessionSummary(Y)))).filter((Y)=>Y!==null).sort((Y,K)=>K.lastActivity-Y.lastActivity).slice(this.maxSessions).map((Y)=>Y.sessionId);await Promise.all(W.map((Y)=>this.deleteSession(Y))),console.log(`[PersistentStore] 已清理 ${W.length} 个旧会话`)}catch($){console.error("[PersistentStore] 清理旧会话失败:",$)}}async saveTurnTerminal($,J,Z){await this.ensureSessionCreated($);try{await this.log($).commitValidated((W)=>{let Y=t(W);if(Y.some((X)=>(X.type==="turn_completed"||X.type==="turn_aborted")&&X.data.turnId===Z.turnId))throw new S0;let H=Q$(Y).active;if(!H||H.turnId!==Z.turnId)throw Error(`Turn is not active: ${Z.turnId}`);return J==="turn_completed"?this.createEvent("turn_completed",$,Z):this.createEvent("turn_aborted",$,Z)})}catch(W){if(!(W instanceof S0))throw W}}async getStorageStats(){try{let $=await this.listSessions(),J=0;for(let Z of $){let W=z0(this.projectPath,Z),K=await new G0(W).getStats();J+=K.size}return{totalSessions:$.length,totalSize:J,projectPath:this.projectPath}}catch{return{totalSessions:0,totalSize:0,projectPath:this.projectPath}}}async checkStorageHealth(){try{let $=K$(this.projectPath);await y0.mkdir($,{recursive:!0,mode:493});let J=O6.join($,".health-check");return await y0.writeFile(J,"test","utf-8"),await y0.unlink(J),{isAvailable:!0,canWrite:!0}}catch($){return{isAvailable:!1,canWrite:!1,error:$ instanceof Error?$.message:String($)}}}static async listAllProjects(){return w6()}}function T8($){return/^data:([^;,]+)[;,]/.exec($)?.[1]??null}var y6=131072,U6=new Map;function s1($,J){let Z=`${$}\x00${J}`,W=U6.get(Z);if(!W)W=new k8,U6.set(Z,W);return W}function $2($,J){let Z=JSON.stringify($);if(Z===void 0)throw Error(`${J} is not JSON serializable`);if(Buffer.byteLength(Z,"utf8")>y6)throw Error(`${J} exceeds ${y6} bytes`);return JSON.parse(Z)}function F6($){if($.type==="askUserQuestion")return"question";if($.type==="mcpElicitation")return"elicitation";if($.type==="permission"||$.type==="mcpSampling")return"permission";return}function M8($,J){return JSON.stringify($)===JSON.stringify(J)}function h8($,J){if($.request.interactionType!=="elicitation")return $2(J,"Interaction response");return $2({approved:J.approved,...J.reason?{reason:J.reason}:{},...J.elicitation?{elicitation:{action:J.elicitation.action}}:{},...J.openExternalUrl?{openExternalUrl:!0}:{}},"Interaction response")}function _6($){let J=$.request.details;if(!J||typeof J!=="object"||Array.isArray(J))throw Error(`Invalid durable interaction details: ${$.request.requestId}`);return J}function R8($){let J=$.response?.response;if(!J||typeof J!=="object"||Array.isArray(J))throw Error(`Invalid durable interaction response: ${$.request.requestId}`);return J}function C8($){if(!$.answers||Object.keys($.answers).length===0)return"No structured answers were provided.";return Object.entries($.answers).map(([J,Z])=>{let W=Array.isArray(Z)?Z.join(", "):Z;return`${J}: ${W}`}).join(`
|
|
122
122
|
`)}function v8($,J){let{request:Z}=$;if(Z.interactionType==="question"){let H=C8(J);return{toolOutput:`User answers:
|
|
123
123
|
${H}`,inbox:`The process restarted while waiting for a structured answer. The recovered user response is:
|
|
124
124
|
${H}
|
|
@@ -201,4 +201,4 @@ ${E}`}if(typeof M==="object"&&M!==null)M=JSON.stringify(M,null,2);if(typeof M===
|
|
|
201
201
|
${S6(c0)}
|
|
202
202
|
</system-reminder>`,metadata:C$};O.appendControl("user",L);let B=await H0($,Z,L.content,Q,C$);if(B)Q=B}}if(W?.signal?.aborted)return D(H,X.length,W.signal);if(H>=w$&&(YJ||v)){if(C.info(`Warning: 达到轮次上限 ${w$} 轮`),W?.onTurnLimitReached){let L=await W.onTurnLimitReached({turnsCount:H});if(L?.continue){O.writeback();let B="failed",P,_,c;yield{kind:"compaction",phase:"start",reason:"turn_limit"};try{let N=$.chatService.getConfig(),U=await H$.compact(Z.messages,{trigger:"auto",modelName:N.model,modelProvider:N.provider,maxContextTokens:N.maxContextTokens??0,apiKey:N.apiKey,baseURL:N.baseUrl,actualPreTokens:G1,signal:W?.signal,activeTask:w0,workspaceRoot:Z.workspaceRoot||a(),sessionId:Z.sessionId});if(U.usage)yield{kind:"token_usage",usage:O1(U.usage,N.maxContextTokens??0)};let S={role:"user",content:`This session is being continued from a previous conversation. The conversation is summarized above.
|
|
203
203
|
|
|
204
|
-
Please continue the conversation from where we left it off without asking the user any further questions. Continue with the last task that you were asked to work on.`},M=[...U.compactedMessages,S];P=U.success?"llm":"fallback",_=U.preTokens,c=U.postTokens,await T$($,Z,U.summary,{trigger:"auto",reason:"turn_limit",strategy:P,preTokens:U.preTokens,postTokens:U.postTokens,filesIncluded:U.filesIncluded,replacementMessages:M},{required:$.executionEngine!==void 0}),Z.messages=M,O.replaceHistory(Z.messages),B=U.success?"completed":"fallback"}catch(N){throw C.error("[Loop] 轮次上限压缩失败,停止继续执行:",N),N}finally{yield{kind:"compaction",phase:"end",reason:"turn_limit",outcome:B,strategy:P,preTokens:_,postTokens:c}}H=0;continue}return{success:!0,finalMessage:L?.reason||"已达到对话轮次上限,用户选择停止",metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K,tokensUsed:n}}}return{success:!1,error:{type:"max_turns_exceeded",message:v?`子代理已达到轮次上限 (${w$} 轮)。`:`已达到轮次上限 (${w$} 轮)。`},metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K,tokensUsed:n}}}}}catch(G){if(G instanceof Y$)try{let y=Z.sessionId?await f$.loadSessionModelContext(Z.sessionId,Z.workspaceRoot):B0;O.restoreDurableHistory(y)}catch(y){C.error("[Loop] Failed to reload durable context after message commit failure:",y),O.restoreDurableHistory(B0)}throw G}finally{if(W?.transientInput==="goal_continuation")O.removeMessages((G)=>{let y=G.metadata;return y!==null&&typeof y==="object"&&!Array.isArray(y)&&y.transientGoalContinuation===!0});O.writeback()}}catch(q){if(C0(q))return D(H,X.length,W?.signal);if(q instanceof Y$)return{success:!1,error:{type:"message_persistence_failed",message:q.message},metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K}};let V=A4(q);return C.error(`API 调用失败: ${V}`),{success:!1,error:{type:"api_error",message:V,details:q},metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K}}}finally{if(z)Z.messages.push({role:"system",content:d1}),await o2($,Z,Q)}}export{i1 as Ma,S$ as Na,p4 as Oa,C1 as Pa,
|
|
204
|
+
Please continue the conversation from where we left it off without asking the user any further questions. Continue with the last task that you were asked to work on.`},M=[...U.compactedMessages,S];P=U.success?"llm":"fallback",_=U.preTokens,c=U.postTokens,await T$($,Z,U.summary,{trigger:"auto",reason:"turn_limit",strategy:P,preTokens:U.preTokens,postTokens:U.postTokens,filesIncluded:U.filesIncluded,replacementMessages:M},{required:$.executionEngine!==void 0}),Z.messages=M,O.replaceHistory(Z.messages),B=U.success?"completed":"fallback"}catch(N){throw C.error("[Loop] 轮次上限压缩失败,停止继续执行:",N),N}finally{yield{kind:"compaction",phase:"end",reason:"turn_limit",outcome:B,strategy:P,preTokens:_,postTokens:c}}H=0;continue}return{success:!0,finalMessage:L?.reason||"已达到对话轮次上限,用户选择停止",metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K,tokensUsed:n}}}return{success:!1,error:{type:"max_turns_exceeded",message:v?`子代理已达到轮次上限 (${w$} 轮)。`:`已达到轮次上限 (${w$} 轮)。`},metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K,tokensUsed:n}}}}}catch(G){if(G instanceof Y$)try{let y=Z.sessionId?await f$.loadSessionModelContext(Z.sessionId,Z.workspaceRoot):B0;O.restoreDurableHistory(y)}catch(y){C.error("[Loop] Failed to reload durable context after message commit failure:",y),O.restoreDurableHistory(B0)}throw G}finally{if(W?.transientInput==="goal_continuation")O.removeMessages((G)=>{let y=G.metadata;return y!==null&&typeof y==="object"&&!Array.isArray(y)&&y.transientGoalContinuation===!0});O.writeback()}}catch(q){if(C0(q))return D(H,X.length,W?.signal);if(q instanceof Y$)return{success:!1,error:{type:"message_persistence_failed",message:q.message},metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K}};let V=A4(q);return C.error(`API 调用失败: ${V}`),{success:!1,error:{type:"api_error",message:V,details:q},metadata:{turnsCount:H,toolCallsCount:X.length,duration:Date.now()-K}}}finally{if(z)Z.messages.push({role:"system",content:d1}),await o2($,Z,Q)}}export{i1 as Ma,S$ as Na,p4 as Oa,C1 as Pa,s$ as Qa,Q$ as Ra,u1 as Sa,l2 as Ta,Z5 as Ua,E$ as Va,a0 as Wa,v0 as Xa,OJ as Ya,J$ as Za,c4 as _a,I1 as $a,p1 as ab,I2 as bb,m1 as cb,m6 as db,u6 as eb,c6 as fb,$$ as gb,a$ as hb,uJ as ib,H0 as jb,g as kb,c1 as lb,Z1 as mb,T$ as nb,h0 as ob,H$ as pb,Q1 as qb,e as rb,q1 as sb,n6 as tb,o6 as ub,a6 as vb,O4 as wb,D2 as xb,WJ as yb,h4 as zb};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{M as
|
|
1
|
+
import{ug as F}from"./chunk-4s0c6tkd.js";import{execSync as G}from"node:child_process";import*as C from"node:os";import*as v from"node:path";function H(k){return v.resolve(k).replace(/[/\\]/g,"-").replace(/:/g,"_")}function M(k){let q=k.replace(/_/g,":");if(q.startsWith("-"))q="/"+q.slice(1);return q.replace(/-/g,"/")}function z(k){let q=H(k);return v.join(E(),"projects",q)}function J(k){return typeof k==="string"&&k!=="."&&k!==".."&&/^[A-Za-z0-9_-][A-Za-z0-9._-]{0,199}$/.test(k)}function A(k){if(!J(k))throw Error(`Invalid session ID: ${k}`)}function N(k,q){return A(q),v.join(z(k),`${q}.jsonl`)}function O(k,q){return A(q),v.join(z(k),`${q}.inbox.json`)}function Q(k,q){return A(q),v.join(z(k),`${q}.goal.json`)}function T(k){try{return G("git rev-parse --abbrev-ref HEAD",{cwd:k,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}function E(){return process.env.BLADE_STORAGE_ROOT||v.join(C.homedir(),".blade")}async function U(){let{readdir:k}=await import("node:fs/promises");try{let q=v.join(E(),"projects");return(await k(q,{withFileTypes:!0})).filter((w)=>w.isDirectory()).map((w)=>w.name)}catch{return[]}}
|
|
2
|
+
export{M as kg,z as lg,J as mg,A as ng,N as og,O as pg,Q as qg,T as rg,E as sg,U as tg};
|
package/package.json
CHANGED
package/dist/chunk-39wa7cfr.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Lc as a,Mc as b,Nc as c,Oc as d,Pc as e,Qc as f,Rc as g,Sc as h}from"./chunk-4s6w24r3.js";import"./chunk-sqp79c1a.js";import"./chunk-3qmawdwf.js";import"./chunk-7m5az521.js";export{d as syncSession,e as syncAll,h as searchProjectionText,c as resetProjectionDbCache,f as removeSessionFromProjection,g as rebuildProjectionIndex,b as getProjectionDb,a as getIndexDbPath};
|
package/dist/chunk-51b7jb2s.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Tc as a,Uc as b}from"./chunk-9h41rm97.js";import"./chunk-a1wjgf44.js";import"./chunk-7m5az521.js";export{a as globalOptions,b as cliConfig};
|
package/dist/chunk-7cbe8yjn.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as a,g as i,h as l,i as m}from"./chunk-6r9jb465.js";import"./chunk-hymw69m4.js";import"./chunk-0zs3mn75.js";import"./chunk-2kzg80r3.js";import"./chunk-7jja0242.js";import"./chunk-b7xdtjh8.js";import"./chunk-k5gv2phs.js";import"./chunk-3nn4rth6.js";import"./chunk-sbyyg6qg.js";import"./chunk-pgy1mtgw.js";import"./chunk-031n82db.js";import"./chunk-d4hcy6p1.js";import"./chunk-4s6w24r3.js";import{_c as n}from"./chunk-015fx09x.js";import"./chunk-vpe44cnj.js";import{ud as s}from"./chunk-ck9r8h1h.js";import"./chunk-v508x7cg.js";import"./chunk-xf03b657.js";import"./chunk-aytg9gw0.js";import"./chunk-t1zs40rj.js";import"./chunk-pmxqjb29.js";import"./chunk-pf8rybpm.js";import"./chunk-zj29g9rc.js";import"./chunk-ytec29ph.js";import"./chunk-1jagjybs.js";import"./chunk-hq8cbzfv.js";import"./chunk-rcp5maxt.js";import"./chunk-eqj58q4r.js";import"./chunk-js5whev4.js";import"./chunk-r84jsjnc.js";import"./chunk-38ca5c9f.js";import"./chunk-z45qe8dg.js";import"./chunk-znp4bexg.js";import"./chunk-sqp79c1a.js";import"./chunk-132q0hyf.js";import"./chunk-83w81bma.js";import"./chunk-a1wjgf44.js";import"./chunk-0hdsbwhf.js";import"./chunk-0g7cjx1t.js";import"./chunk-3qmawdwf.js";import"./chunk-7m5az521.js";import v from"chalk";var C={command:"serve",describe:"Start a headless Blade server (no browser)",builder:a,handler:async(p)=>{let r=i(p);if(await s(),!process.env.BLADE_SERVER_PASSWORD)console.log(v.yellow("Warning: BLADE_SERVER_PASSWORD is not set; server is unsecured."));let e=await m.listenAsync(r);if(console.log(`Blade server listening on http://${e.hostname}:${e.port}`),r.hostname==="0.0.0.0"){let o=l();for(let g of o)console.log(` Network: http://${g}:${e.port}`)}let t,c=new Promise((o)=>{t=o}),d=n(async()=>{await e.stop(),t()});try{await c}finally{d(),await e.stop()}}};export{C as serveCommand};
|
package/dist/chunk-cz1hb799.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{le as a,me as b,ne as c,oe as d,pe as e}from"./chunk-zj29g9rc.js";import"./chunk-ytec29ph.js";import"./chunk-1jagjybs.js";import"./chunk-hq8cbzfv.js";import"./chunk-rcp5maxt.js";import"./chunk-eqj58q4r.js";import"./chunk-js5whev4.js";import"./chunk-r84jsjnc.js";import"./chunk-38ca5c9f.js";import"./chunk-z45qe8dg.js";import"./chunk-znp4bexg.js";import"./chunk-sqp79c1a.js";import"./chunk-132q0hyf.js";import"./chunk-83w81bma.js";import"./chunk-a1wjgf44.js";import"./chunk-0hdsbwhf.js";import"./chunk-0g7cjx1t.js";import"./chunk-3qmawdwf.js";import"./chunk-7m5az521.js";export{d as snapshotWorkspaceAgentResources,c as resolveWorkspaceAgentResources,e as resetWorkspaceAgentResources,a as refreshWorkspaceCommunicationStyles,b as configureInvocationPluginDirs};
|
package/dist/chunk-dbwa9rwr.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{Yc as I}from"./chunk-qf357j45.js";import{pd as E}from"./chunk-ck9r8h1h.js";import{jf as f,of as y,pf as T,qf as w,rf as M,uf as k,vf as N}from"./chunk-js5whev4.js";import{wf as c}from"./chunk-r84jsjnc.js";import{Cf as m,xf as S,zf as n}from"./chunk-38ca5c9f.js";import{Hf as O}from"./chunk-znp4bexg.js";import{Nf as h}from"./chunk-sqp79c1a.js";import{promises as R}from"node:fs";import A from"node:path";var C=["systemPrompt","appendSystemPrompt","initialMessage","resumeSessionId","forkSession","allowedTools","disallowedTools","mcpConfigPaths","strictMcpConfig","model","addDirs","outputFormat","inputFormat","print","includePartialMessages","replayUserMessages","agentsConfig","settingSources"],U=new Set([...Object.keys(f),...C]),p=n.Number({exclusiveMinimum:0}),e=n.String({minLength:1}),r=n.Array(n.String()),B=n.Object({currentModelId:n.Optional(n.String()),modelProviders:n.Optional(n.Record(e,n.Object({name:e,baseUrl:e,wireApi:m(["openai-completions","anthropic-messages"]),apiKeyEnv:n.Optional(e)}))),models:n.Optional(n.Array(n.Object({id:e,displayName:n.Optional(e),provider:e,model:e,overrides:n.Optional(n.Object({baseUrl:n.Optional(n.String()),temperature:n.Optional(n.Number()),maxOutputTokens:n.Optional(p),timeout:n.Optional(p),streamIdleTimeout:n.Optional(n.Number({minimum:1000})),apiVersion:n.Optional(n.String()),customHeaders:n.Optional(n.Record(n.String(),n.String())),maxRetries:n.Optional(n.Integer({minimum:0})),enablePromptCaching:n.Optional(n.Boolean())})),fallbackModels:n.Optional(n.Array(n.Object({provider:e,model:e})))}))),temperature:n.Optional(n.Number()),maxOutputTokens:n.Optional(p),stream:n.Optional(n.Boolean()),topP:n.Optional(n.Number()),topK:n.Optional(n.Number()),timeout:n.Optional(p),codeTheme:n.Optional(n.String()),uiTheme:n.Optional(m(["light","dark","system"])),language:n.Optional(n.String()),fontSize:n.Optional(p),autoSaveSessions:n.Optional(n.Boolean()),notifyBuild:n.Optional(n.Boolean()),notifyErrors:n.Optional(n.Boolean()),notifySounds:n.Optional(n.Boolean()),privacyTelemetry:n.Optional(n.Boolean()),privacyCrash:n.Optional(n.Boolean()),debug:n.Optional(n.Union([n.Boolean(),n.String()])),mcpEnabled:n.Optional(n.Boolean()),mcpServers:n.Optional(n.Record(n.String(),n.Record(n.String(),n.Unknown()))),lspServers:n.Optional(n.Record(e,n.Object({command:e,args:n.Optional(n.Array(n.String())),extensionToLanguage:n.Record(e,e),env:n.Optional(n.Record(n.String(),n.String())),initializationOptions:n.Optional(n.Unknown()),settings:n.Optional(n.Unknown()),enabled:n.Optional(n.Boolean()),priority:n.Optional(n.Integer()),startupTimeout:n.Optional(n.Integer({minimum:100})),shutdownTimeout:n.Optional(n.Integer({minimum:100})),requestTimeout:n.Optional(n.Integer({minimum:100})),diagnosticWaitTimeout:n.Optional(n.Integer({minimum:0})),maxRestarts:n.Optional(n.Integer({minimum:0,maximum:10}))}))),permissionMode:n.Optional(n.Enum(c)),maxTurns:n.Optional(n.Integer({minimum:-1})),maxConcurrentTasks:n.Optional(n.Integer({minimum:y,maximum:T})),maxQueuedTasks:n.Optional(n.Integer({minimum:w,maximum:M})),systemPrompt:n.Optional(n.String()),appendSystemPrompt:n.Optional(n.String()),initialMessage:n.Optional(n.String()),resumeSessionId:n.Optional(n.String()),forkSession:n.Optional(n.Boolean()),allowedTools:n.Optional(n.Array(e)),disallowedTools:n.Optional(n.Array(e)),mcpConfigPaths:n.Optional(n.Array(e)),strictMcpConfig:n.Optional(n.Boolean()),model:n.Optional(e),addDirs:n.Optional(n.Array(e)),outputFormat:n.Optional(m(["text","json","stream-json","jsonl"])),inputFormat:n.Optional(m(["text","stream-json"])),print:n.Optional(n.Boolean()),includePartialMessages:n.Optional(n.Boolean()),replayUserMessages:n.Optional(n.Boolean()),agentsConfig:n.Optional(n.String()),settingSources:n.Optional(n.String()),permissions:n.Optional(n.Object({allow:n.Optional(r),ask:n.Optional(r),deny:n.Optional(r)})),env:n.Optional(n.Record(n.String(),n.String())),hooks:n.Optional(n.Record(n.String(),n.Unknown())),enabledPlugins:n.Optional(n.Record(e,n.Boolean())),pluginSourcePolicy:n.Optional(n.Object({restrictToAllowedSources:n.Optional(n.Boolean()),requireGitCommitSha:n.Optional(n.Boolean()),allowedGitHosts:n.Optional(n.Array(e)),allowedMarketplaces:n.Optional(n.Array(e)),allowedLocalRoots:n.Optional(n.Array(e))})),disableAllHooks:n.Optional(n.Boolean())}),x=[["systemPrompt","systemPrompt"],["appendSystemPrompt","appendSystemPrompt"],["initialMessage","initialMessage"],["resumeSessionId","sessionId"],["forkSession","forkSession"],["allowedTools","allowedTools"],["disallowedTools","disallowedTools"],["mcpConfigPaths","mcpConfig"],["strictMcpConfig","strictMcpConfig"],["model","model"],["addDirs","addDir"],["outputFormat","outputFormat"],["inputFormat","inputFormat"],["print","print"],["includePartialMessages","includePartialMessages"],["replayUserMessages","replayUserMessages"],["agentsConfig","agents"],["settingSources","settingSources"],["permissionMode","permissionMode"],["maxTurns","maxTurns"],["maxConcurrentTasks","maxConcurrentTasks"],["maxQueuedTasks","maxQueuedTasks"]];function d(o,i){let t;try{t=JSON.parse(o)}catch(s){let a=s instanceof Error?`: ${s.message}`:"";throw Error(`Invalid JSON provided to --settings (${i})${a}`)}if(!t||typeof t!=="object"||Array.isArray(t))throw Error("--settings must contain a JSON object");for(let s of Object.keys(t))if(!U.has(s))throw Error(`Unknown --settings field: ${s}`);let l=S(B,t);if(!l.success){let s=l.error.issues.map((a)=>`${a.path.join(".")||"settings"}: ${a.message}`).join("; ");throw Error(`Invalid --settings value: ${s}`)}return l.data}async function P(o){if(o===void 0)return;let i=o.trim();if(!i)throw Error("--settings requires a JSON object or file path");if(i.startsWith("{"))return d(i,"inline JSON");let t=A.resolve(O(),i),l;try{l=await R.readFile(t,"utf8")}catch(s){let a=s instanceof Error?`: ${s.message}`:"";throw Error(`Unable to read --settings file ${t}${a}`)}return d(l,t)}function b(o,i){if(!i)return;let t=i;for(let[l,s]of x){if(l==="permissionMode"&&o.yolo===!0)continue;if(o[s]===void 0&&t[l]!==void 0)o[s]=t[l]}}var u=h("General"),V=(o)=>{if(o.yolo){if(o.permissionMode&&o.permissionMode!=="yolo")throw Error("Cannot use both --yolo and --permission-mode with different values");o.permissionMode="yolo"}if(Array.isArray(o.allowedTools))o.allowedTools=o.allowedTools.flatMap((i)=>i.split(",").map((t)=>t.trim()).filter((t)=>t.length>0));if(Array.isArray(o.disallowedTools))o.disallowedTools=o.disallowedTools.flatMap((i)=>i.split(",").map((t)=>t.trim()).filter((t)=>t.length>0));if(Array.isArray(o.allowedTools)&&Array.isArray(o.disallowedTools)){let i=o.allowedTools.filter((t)=>o.disallowedTools.includes(t));if(i.length>0)throw Error(`Tools cannot be both allowed and disallowed: ${i.join(", ")}`)}},Y=async(o)=>{let i=await P(typeof o.settings==="string"?o.settings:void 0);if(b(o,i),typeof o.agents==="string")I(o.agents);F(o);try{let l=await k.getInstance().initialize(i),s=N(l,o);if(E().config.actions.setConfig(s),o.debug)u.info("[CLI] 配置已加载到 Store")}catch(t){u.error("[CLI] [FAIL] 配置初始化失败",t instanceof Error?t.message:t),console.error(`
|
|
2
|
-
[FAIL] 配置初始化失败
|
|
3
|
-
`),console.error("原因:",t instanceof Error?t.message:"未知错误"),console.error(`
|
|
4
|
-
请检查:`),console.error(" 1. 配置文件格式是否正确 (~/.blade/config.json)"),console.error(" 2. 是否需要运行 blade 进行首次配置"),console.error(` 3. 配置文件权限是否正确
|
|
5
|
-
`),process.exit(1)}};function F(o){if(o.continue&&o.resume)throw Error("Cannot use both --continue and --resume flags simultaneously");if(o.forkSession&&!o.continue&&!o.resume)throw Error("--fork-session requires --resume or --continue");if(o.sessionId&&(o.continue||o.resume)&&!o.forkSession)throw Error("--session-id can only be combined with --resume or --continue when --fork-session is set")}var Z=(o)=>{if(o.jsonSchema&&o.outputSchema)throw Error("--json-schema cannot be combined with --output-schema");if((o.jsonSchema||o.outputSchema)&&!o.print&&!o.headless)throw Error("--json-schema and --output-schema can only be used with --print or --headless");if(o.outputFormat&&o.outputFormat!=="text"&&!o.print&&!o.headless)throw Error("--output-format can only be used with --print or --headless");if(o.headless&&o.outputFormat&&!["text","jsonl"].includes(o.outputFormat))throw Error(`--headless only supports --output-format text|jsonl, but got "${o.outputFormat}". Use --print for json|stream-json support.`);if(o.print&&o.outputFormat&&!["text","json","stream-json"].includes(o.outputFormat))throw Error(`--print only supports --output-format text|json|stream-json, but got "${o.outputFormat}". Use --headless for jsonl support.`);if(o.inputFormat==="stream-json"&&o.print)u.warn("[WARN] Warning: stream-json input format may not work as expected with --print")};
|
|
6
|
-
export{V as Vc,Y as Wc,Z as Xc};
|
package/dist/chunk-fbxgxwfm.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$f as b,_f as a,ag as c,bg as d,cg as e,dg as f}from"./chunk-a1wjgf44.js";import"./chunk-7m5az521.js";export{b as getVersion,c as getPackageName,a as getPackageInfo,e as getFormattedVersion,d as getDescription,f as getCopyright};
|
package/dist/chunk-gcyd5s5h.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$a as b,_a as a,bb as c,fb as d,gb as e,hb as f,ib as g,jb as h,kb as i,lb as j,mb as k,rb as l,sb as m,tb as n,ub as o,wb as p,xb as q,yb as r}from"./chunk-sbyyg6qg.js";import"./chunk-pgy1mtgw.js";import"./chunk-031n82db.js";import"./chunk-d4hcy6p1.js";import"./chunk-4s6w24r3.js";import"./chunk-xf03b657.js";import"./chunk-aytg9gw0.js";import"./chunk-pmxqjb29.js";import"./chunk-ytec29ph.js";import"./chunk-1jagjybs.js";import"./chunk-rcp5maxt.js";import"./chunk-eqj58q4r.js";import"./chunk-r84jsjnc.js";import"./chunk-38ca5c9f.js";import"./chunk-z45qe8dg.js";import"./chunk-znp4bexg.js";import"./chunk-sqp79c1a.js";import"./chunk-132q0hyf.js";import"./chunk-83w81bma.js";import"./chunk-a1wjgf44.js";import"./chunk-0g7cjx1t.js";import"./chunk-3qmawdwf.js";import"./chunk-7m5az521.js";export{g as saveUserMessage,i as saveToolUse,j as saveToolResult,k as saveCompaction,h as saveAssistantMessage,d as isRootSystemPrompt,m as handleTaskListUpdate,n as handleSkillActivation,o as extractModelSwitch,r as executeLoopGenerator,f as drainLoop,c as checkStopHook,a as checkOutputRecovery,b as checkIncompleteIntent,q as checkAndCompactInLoop,p as applyToolDomainEffects,l as StreamingToolExecutor,e as ConversationState};
|
package/dist/chunk-h7v23pw2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-4en93rc4.js";import"./chunk-a1wjgf44.js";import"./chunk-7m5az521.js";export{b as setSkipUntilVersion,d as performUpgrade,c as getUpgradeCommand,e as checkVersionOnStartup,a as checkVersion};
|
package/dist/chunk-hk36a59x.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Nd as a,Od as b,Pd as c}from"./chunk-t1zs40rj.js";import"./chunk-pmxqjb29.js";import"./chunk-132q0hyf.js";import"./chunk-83w81bma.js";import"./chunk-3qmawdwf.js";import"./chunk-7m5az521.js";export{b as resolveModelConfig,c as getModelDisplayName,a as getModelApiKeyEnvironmentVariable};
|