blade-code 0.6.0 → 0.6.2
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-yjrx2q95.js → chunk-1cm8qqth.js} +1 -1
- package/dist/{chunk-dr1bb8ya.js → chunk-1t0cavth.js} +1 -1
- package/dist/{chunk-6c5v0yas.js → chunk-21zps3hb.js} +1 -1
- package/dist/{chunk-7qy4kfe7.js → chunk-2ahbedmp.js} +1 -1
- package/dist/{chunk-wre40mf1.js → chunk-39h8jdm3.js} +1 -1
- package/dist/{chunk-50qc4e5g.js → chunk-3ak4p05x.js} +1 -1
- package/dist/{chunk-yz1nbhxn.js → chunk-3j3v297d.js} +1 -1
- package/dist/chunk-4e20kfa4.js +1 -0
- package/dist/chunk-563zye36.js +1 -0
- package/dist/{chunk-49pjm1fc.js → chunk-63954vzc.js} +1 -1
- package/dist/{chunk-t1ex4e6g.js → chunk-67dzm8te.js} +1 -1
- package/dist/{chunk-nhmdze8s.js → chunk-6gycrrb9.js} +1 -1
- package/dist/{chunk-4h4y84d6.js → chunk-6vwc66b4.js} +1 -1
- package/dist/{chunk-h9q2wpcp.js → chunk-7010r8zb.js} +1 -1
- package/dist/chunk-7v6xxyd3.js +613 -0
- package/dist/{chunk-hhtpxjqn.js → chunk-8a2z6mgp.js} +1 -1
- package/dist/{chunk-1cb2kqqm.js → chunk-9ce1fadm.js} +2 -2
- package/dist/{chunk-ekfmr2cb.js → chunk-9pg8nttx.js} +373 -372
- package/dist/chunk-9zbmef4r.js +6 -0
- package/dist/{chunk-vwcjwzw3.js → chunk-b5nhr3na.js} +1 -1
- package/dist/{chunk-9x5w4as8.js → chunk-caw1bxy6.js} +1 -1
- package/dist/{chunk-gky78ctd.js → chunk-cydswa20.js} +1 -1
- package/dist/{chunk-n5xfrmrp.js → chunk-dyaxme6k.js} +1 -1
- package/dist/chunk-fkttsa1n.js +2 -0
- package/dist/chunk-g7xh4e99.js +1 -0
- package/dist/chunk-j1ehsp0x.js +3 -0
- package/dist/{chunk-tcqrc6pc.js → chunk-k4sbqc14.js} +1 -1
- package/dist/{chunk-hy4dsdpp.js → chunk-kevt8v3j.js} +1 -1
- package/dist/{chunk-3z8h9j4f.js → chunk-m7xm1ssb.js} +1 -1
- package/dist/{chunk-w0hbjyzt.js → chunk-mpafvahb.js} +1 -1
- package/dist/{chunk-3w1zqywq.js → chunk-t44946na.js} +3 -3
- package/dist/{chunk-v0z4bwcv.js → chunk-t7hd45rg.js} +2 -2
- package/dist/{chunk-bs9fg1qz.js → chunk-y57hcnk6.js} +1 -1
- package/dist/{chunk-02dgzrzh.js → chunk-ythh98wk.js} +1 -1
- package/package.json +3 -2
- package/dist/chunk-4s0brhtr.js +0 -1
- package/dist/chunk-cwbszfye.js +0 -6
- package/dist/chunk-e5ngx3x1.js +0 -612
- package/dist/chunk-ktag2d1c.js +0 -3
- package/dist/chunk-mganjb5p.js +0 -1
- package/dist/chunk-qv3wcc4p.js +0 -2
- package/dist/chunk-szbfafff.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{va as z}from"./chunk-
|
|
1
|
+
import{va as z}from"./chunk-21zps3hb.js";import{Ia as w}from"./chunk-67dzm8te.js";import{Ib as u}from"./chunk-j1ehsp0x.js";var q=u("General"),F=(b)=>{if(b.yolo){if(b.permissionMode&&b.permissionMode!=="yolo")throw Error("Cannot use both --yolo and --permission-mode with different values");b.permissionMode="yolo"}if(Array.isArray(b.allowedTools))b.allowedTools=b.allowedTools.flatMap((h)=>h.split(",").map((k)=>k.trim()).filter((k)=>k.length>0));if(Array.isArray(b.disallowedTools))b.disallowedTools=b.disallowedTools.flatMap((h)=>h.split(",").map((k)=>k.trim()).filter((k)=>k.length>0));if(Array.isArray(b.allowedTools)&&Array.isArray(b.disallowedTools)){let h=b.allowedTools.filter((k)=>b.disallowedTools.includes(k));if(h.length>0)throw Error(`Tools cannot be both allowed and disallowed: ${h.join(", ")}`)}},G=async(b)=>{try{let k=await w.getInstance().initialize();if(z().config.actions.setConfig(k),b.debug)q.info("[CLI] 配置已加载到 Store")}catch(h){q.error("[CLI] [FAIL] 配置初始化失败",h instanceof Error?h.message:h),console.error(`
|
|
2
2
|
[FAIL] 配置初始化失败
|
|
3
3
|
`),console.error("原因:",h instanceof Error?h.message:"未知错误"),console.error(`
|
|
4
4
|
请检查:`),console.error(" 1. 配置文件格式是否正确 (~/.blade/config.json)"),console.error(" 2. 是否需要运行 blade 进行首次配置"),console.error(` 3. 配置文件权限是否正确
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as E2,f as h2}from"./chunk-
|
|
1
|
+
import{e as E2,f as h2}from"./chunk-m7xm1ssb.js";import{h as A4,i as v4,j as R4}from"./chunk-zfy765hj.js";import{l as D$,m as k4,o as o1}from"./chunk-63954vzc.js";import{B as r8,C as e6,D as f4,E as X8,F as e1,G as h6,I as f6,J as D6,M as f$,N as M8,O as D4,P as _1,Q as wJ,R as bJ,S as M6,T as V4,U as C6,W as KJ,y as UJ}from"./chunk-9pg8nttx.js";import{Y as S4}from"./chunk-3j3v297d.js";import"./chunk-1t0cavth.js";import{fa as I2}from"./chunk-fkttsa1n.js";import{ga as S8}from"./chunk-b5nhr3na.js";import{Aa as x6,Ga as p0,ha as O$,ia as m0,ja as E1,ka as vQ,la as i1,ma as T$,na as iJ,oa as mQ,pa as D2,qa as nJ,sa as K4,ua as iQ,va as H1,wa as C4,xa as w1,ya as b4}from"./chunk-21zps3hb.js";import{Ha as I4,Ja as M4}from"./chunk-67dzm8te.js";import{Oa as G4,Pa as T4,Ta as d6}from"./chunk-7v6xxyd3.js";import"./chunk-3ak4p05x.js";import{nb as yQ,ob as L1}from"./chunk-t44946na.js";import{rb as o2}from"./chunk-t7hd45rg.js";import{vb as AJ,yb as A0}from"./chunk-39h8jdm3.js";import{Fb as P4,Ib as j1}from"./chunk-j1ehsp0x.js";import{Kb as s$}from"./chunk-s53zeref.js";import{useMemoizedFn as dQ}from"ahooks";import{useEffect as c5,useState as lQ}from"react";import{useMemoizedFn as r0}from"ahooks";import{Box as l1}from"ink";import{useEffect as r1,useRef as T8}from"react";import{useShallow as nQ}from"zustand/react/shallow";import{useStore as c4}from"zustand";function Q0($){return c4(iQ,$)}var u4=[],tQ=()=>Q0(($)=>$.session.sessionId),sQ=()=>Q0(($)=>$.session.messages),eQ=()=>Q0(($)=>$.session.clearCount),$6=()=>Q0(($)=>$.session.isCompacting),Q6=()=>Q0(($)=>$.session.tokenUsage.estimatedCostUsd),f1=()=>Q0(($)=>$.session.actions),J6=()=>Q0(($)=>{let{inputTokens:Q,maxContextTokens:J}=$.session.tokenUsage;if(J<=0)return 100;let Y=Math.max(0,100-Q/J*100);return Math.round(Y)}),Y6=()=>Q0(($)=>$.app.initializationStatus),Z6=()=>Q0(($)=>$.app.initializationError),a$=()=>Q0(($)=>$.app.activeModal),X6=()=>Q0(($)=>$.app.tasks),q6=()=>Q0(($)=>$.app.modelEditorTarget),G6=()=>Q0(($)=>$.app.sessionSelectorData),U6=()=>Q0(($)=>$.app.awaitingSecondCtrlC),D1=()=>Q0(($)=>$.app.actions),o$=()=>Q0(($)=>$.app.initializationStatus==="ready"),K6=()=>Q0(($)=>$.app.tasks.length>0),_$=()=>Q0(($)=>$.config.config?.permissionMode||"default"),O6=()=>Q0(($)=>$.config.config?.models??u4),i$=()=>Q0(($)=>{let Q=$.config.config;if(!Q)return;let J=Q.currentModelId;return Q.models.find((Z)=>Z.id===J)??Q.models[0]}),z6=()=>Q0(($)=>$.config.config?.currentModelId),_0=()=>Q0(($)=>{return m0.getTheme()}),_6=()=>Q0(($)=>$.config.config?.theme??"default"),i0=()=>Q0(($)=>$.focus.currentFocus),N6=()=>Q0(($)=>$.focus.actions),V1=()=>Q0(($)=>$.command.isProcessing),F6=()=>Q0(($)=>$.command.actions),W6=()=>Q0(($)=>$.command.pendingCommands),n$=()=>Q0(($)=>$.app.thinkingModeEnabled),H6=()=>Q0(($)=>$.session.currentThinkingContent),L6=()=>Q0(($)=>$.session.thinkingExpanded),w6=()=>Q0(($)=>$.session.currentStreamingMessageId),b6=()=>Q0(nQ(($)=>({lines:$.session.currentStreamingLines,tail:$.session.currentStreamingTail,lineCount:$.session.currentStreamingLineCount,version:$.session.currentStreamingVersion}))),B6=()=>Q0(($)=>$.session.finalizingStreamingMessageId),A6=()=>Q0(($)=>$.session.historyExpanded),v6=()=>Q0(($)=>$.session.expandedMessageCount),R6=()=>Q0(nQ(($)=>{let Q=$.spec.currentSpec;if(!Q)return{phase:null,completed:0,total:0};let J=Q.tasks??[],Y=J.filter((Z)=>Z.status==="completed").length;return{phase:Q.phase,completed:Y,total:J.length}}));import{useMemoizedFn as u8}from"ahooks";import{useEffect as c6,useRef as Y9}from"react";function x4($){if(!($ instanceof Error))return"未知错误";let Y=$.lastError??$;if(Y.responseBody)try{let X=JSON.parse(Y.responseBody)?.error?.message;if(X){let G=Y.statusCode?` (HTTP ${Y.statusCode})`:"";return`${X}${G}`}}catch{}let Z=$.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return $.message}function d4($){if(!($ instanceof Error))return!1;return $.name==="AbortError"||$.message.includes("aborted")}function l4($){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 m8($){let Q=d4($),J=l4($),Y;if(J)Y="当前模型不支持图片理解功能。请切换到支持视觉能力的模型(如 Claude 4.5、GPT-5.2、Gemini 3 Pro、Qwen3-VL-Plus 等)后重试。";else Y=x4($);return{displayMessage:Y,isAbort:Q,isVisionNotSupported:J}}function y6($){let{text:Q,images:J,parts:Y}=$;if(J.length===0)return Q;let Z=[];for(let q of Y)if(q.type==="text")Z.push({type:"text",text:q.text});else Z.push({type:"image_url",image_url:{url:`data:${q.mimeType};base64,${q.base64}`}});return Z}function P6($){return{role:$.role,content:$.content}}function I6($){if(!$.restoredContextMessages||$.restoredVisibleMessageCount<=0)return $.messages.map(P6);let Q=$.messages.slice($.restoredVisibleMessageCount).map(P6);return[...$.restoredContextMessages,...Q]}function r4($){return typeof $==="object"&&$!==null&&$.action==="invoke_skill"&&typeof $.skillName==="string"}function a4($){return typeof $==="object"&&$!==null&&$.action==="invoke_custom_command"&&typeof $.commandName==="string"&&typeof $.processedContent==="string"}function o4($){return typeof $==="object"&&$!==null&&$.action==="invoke_plugin_command"&&typeof $.commandName==="string"&&typeof $.processedContent==="string"}function i4($){return typeof $==="object"&&$!==null&&$.action==="invoke_once_model"&&typeof $.modelId==="string"&&typeof $.prompt==="string"}function n4($,Q,J,Y){switch($){case"show_theme_selector":return J.setActiveModal("themeSelector"),!0;case"show_model_selector":return J.setActiveModal("modelSelector"),!0;case"show_model_add_wizard":return J.setActiveModal("modelAddWizard"),!0;case"show_permissions_manager":return J.setActiveModal("permissionsManager"),!0;case"show_agents_manager":return J.setActiveModal("agentsManager"),!0;case"show_skills_manager":return J.setActiveModal("skillsManager"),!0;case"show_hooks_manager":return J.setActiveModal("hooksManager"),!0;case"show_plugins_manager":return J.setActiveModal("pluginsManager"),!0;case"show_agent_creation_wizard":return J.setActiveModal("agentCreationWizard"),!0;case"show_session_selector":{let Z=Q?.sessions;return J.showSessionSelector(Z),!0}case"clear_screen":return Y.clearMessages(),Y.setError(null),Y.resetTokenUsage(),J.setTasks([]),!0;case"compact_completed":case"compact_fallback":return Y.resetTokenUsage(),!0;case"exit_application":return o1(0),!0;default:return!1}}async function k6($,Q,J,Y){let{text:Z}=$;if(!M6(Z))return{type:"not_slash"};let q={cwd:A0(),signal:Y},X=await C6(Z,q);if(X.message){if(n4(X.message,X.data,Q,J))return{type:"handled",commandResult:{success:!0}}}if(r4(X.data)){let{skillName:K,skillArgs:U}=X.data,F=U?`Please use the "${K}" skill to help me with: ${U}`:`Please use the "${K}" skill.`;return J.addUserMessage(F),{type:"continue_as_agent",result:{userDisplayMessage:F,agentInput:{displayText:F,text:F,images:[],parts:[{type:"text",text:F}]},userMessageAlreadyAdded:!0}}}if(a4(X.data)){let{commandName:K,processedContent:U}=X.data;J.addUserMessage(Z);let F=`# Custom Command: /${K}
|
|
2
2
|
|
|
3
3
|
The user has invoked the custom command "/${K}". Follow the instructions below to complete the task.
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ ${F}
|
|
|
21
21
|
Remember: Follow the above instructions carefully to complete the user's request.`;return{type:"continue_as_agent",result:{userDisplayMessage:Z,agentInput:{displayText:Z,text:O,images:[],parts:[{type:"text",text:O}]},userMessageAlreadyAdded:!0}}}if(i4(X.data)){let{modelId:K,prompt:U}=X.data;return J.addUserMessage(U),{type:"continue_as_agent",result:{userDisplayMessage:U,agentInput:{displayText:U,text:U,images:[],parts:[{type:"text",text:U}]},userMessageAlreadyAdded:!0,onceModelId:K}}}if(!X.success&&X.error)return J.addAssistantMessage(`${X.error}`),{type:"handled",commandResult:{success:X.success,output:X.message,error:X.error,metadata:X.data}};let G=X.message;if(X.success&&typeof G==="string"&&G.trim()!=="")J.addAssistantMessage(G);return{type:"handled",commandResult:{success:X.success,output:X.message,error:X.error,metadata:X.data}}}import{appendFileSync as t4,mkdirSync as s4,writeFileSync as e4}from"node:fs";import $9 from"node:os";import T6 from"node:path";var g8=T6.join($9.homedir(),".blade","logs","stream-debug.log"),S6=!1;function Q9(){if(S6)return;let $=T6.dirname(g8);s4($,{recursive:!0,mode:493}),e4(g8,`=== Stream Debug Log Started: ${new Date().toISOString()} ===
|
|
22
22
|
`),S6=!0}function p8($,Q,J){Q9();let Y=new Date().toISOString(),Z=J?` | ${JSON.stringify(J)}`:"",q=`[${Y}] [${$}] ${Q}${Z}
|
|
23
23
|
`;t4(g8,q)}var S$=j1("UI");function V6($,Q){let J=!1;return(Y)=>{switch(Y.kind){case"content_delta":if(J||$.signal.aborted)break;Q.contentDeltaCount++,Q.contentDeltaTotalLen+=Y.delta.length,p8("loopEventHandler","onContentDelta",{callCount:Q.contentDeltaCount,deltaLen:Y.delta.length,totalLen:Q.contentDeltaTotalLen}),$.streamingBuffer.batchAppendContent(Y.delta);break;case"thinking_delta":if(J||$.signal.aborted)break;if($.thinkingModeEnabled)$.streamingBuffer.batchAppendThinking(Y.delta);break;case"stream_end":{if(S$.debug("[loopEventHandler] stream_end",{contentDeltaCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:J,signalAborted:$.signal.aborted}),p8("loopEventHandler","onStreamEnd",{contentDeltaCallCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:J,signalAborted:$.signal.aborted}),J||$.signal.aborted){J=!0;break}let{extraContent:Z,extraThinking:q}=$.streamingBuffer.drainPendingBuffers(),X=$.getStreamingMessageId();if(X){if(Z)i1(X,Z);T$(X)}$.sessionActions.finalizeStreamingMessage(Z,q),J=!0;break}case"model_fallback":J=!0,$.streamingBuffer.resetStreamingBuffers(),$.sessionActions.discardStreamingMessage(),$.sessionActions.setCurrentThinkingContent(null);break;case"tool_start":{let Z=Y.toolCall;if(!("function"in Z))break;if(S$.debug("[loopEventHandler] tool_start",{toolName:Z.function.name,toolKind:Y.toolKind}),["TaskCreate","TaskUpdate","TaskList"].includes(Z.function.name))break;try{let q=JSON.parse(Z.function.arguments),X=f6(Z.function.name,q);$.sessionActions.addToolMessage(X,{toolName:Z.function.name,phase:"start",summary:X,params:q})}catch(q){S$.error("[loopEventHandler] onToolStart error:",q)}break}case"tool_result":{let Z=Y.toolCall;if(!("function"in Z))break;S$.debug("[loopEventHandler] tool_result",{toolName:Z.function.name,success:Y.result.success});let q=D6(Z.function.name,Y.result);$.sessionActions.addToolMessage(q.summary,{toolName:Z.function.name,phase:"complete",summary:q.summary,detail:q.detail});break}case"token_usage":$.sessionActions.updateTokenUsage(Y.usage);break;case"compaction":if($.sessionActions.setCompacting(Y.phase==="start"),Y.phase==="end")$.sessionActions.resetTokenUsage();break;case"turn_start":S$.debug("[loopEventHandler] turn_start",{turn:Y.turn,maxTurns:Y.maxTurns}),$.sessionActions.updateTokenUsage({turnCount:Y.turn}),J=!1;break;case"task_update":$.appActions.setTasks(Y.tasks);break;case"subagent_spawned":case"subagent_completed":break;default:{let Z=Y}}}}import{useMemoizedFn as j6}from"ahooks";import{useRef as E6}from"react";function m6($){let Q=E6(void 0),J=E6(void 0),Y=j6(async(q)=>{let X=q?.sessionId??$.sessionId,G=!!q?.modelId&&q.modelId!==$.modelId,K;if(!G&&X){if(J.current&&J.current.sessionId!==X)await J.current.dispose(),J.current=void 0;if(!J.current)J.current=await h6.create({sessionId:X,modelId:q?.modelId??$.modelId});else await J.current.refresh({modelId:q?.modelId??$.modelId});K=await f$.createWithRuntime(J.current,{sessionId:X,systemPrompt:q?.systemPrompt??$.systemPrompt,appendSystemPrompt:q?.appendSystemPrompt??$.appendSystemPrompt,maxTurns:q?.maxTurns??$.maxTurns,modelId:q?.modelId??$.modelId})}else K=await f$.create({systemPrompt:q?.systemPrompt??$.systemPrompt,appendSystemPrompt:q?.appendSystemPrompt??$.appendSystemPrompt,maxTurns:q?.maxTurns??$.maxTurns,modelId:q?.modelId??$.modelId});return Q.current=K,K}),Z=j6(()=>{if(Q.current)Q.current=void 0});return{agentRef:Q,createAgent:Y,cleanupAgent:Z}}import{useMemoizedFn as N$}from"ahooks";import{useEffect as J9,useRef as t$}from"react";function g6($){let Q=0;for(let J of $)if(J===`
|
|
24
|
-
`)Q++;return Q}function p6($,Q){let J=Q?.flushTimeout??300,Y=Q?.minLinesToFlush??5,Z=Q?.minCharsToFlush??400,q=t$(""),X=t$(null),G=t$(""),K=t$(null),U=N$(()=>{if(q.current){let W=q.current,w=$.appendAssistantContent(W);i1(w,W),q.current=""}if(X.current)clearTimeout(X.current),X.current=null}),F=N$(()=>{if(G.current)$.appendThinkingContent(G.current),G.current="";if(K.current)clearTimeout(K.current),K.current=null}),O=N$((W)=>{q.current+=W;let w=q.current;if(g6(w)>=Y||w.length>=Z){U();return}if(!X.current)X.current=setTimeout(U,J)}),N=N$((W)=>{G.current+=W;let w=G.current;if(g6(w)>=Y||w.length>=Z){F();return}if(!K.current)K.current=setTimeout(F,J)}),z=N$(()=>{if(q.current="",X.current)clearTimeout(X.current),X.current=null;if(G.current="",K.current)clearTimeout(K.current),K.current=null}),_=N$(()=>{if(X.current)clearTimeout(X.current),X.current=null;if(K.current)clearTimeout(K.current),K.current=null;let W=q.current,w=G.current;return q.current="",G.current="",{extraContent:W,extraThinking:w}});return J9(()=>{return()=>{z()}},[z]),{batchAppendContent:O,batchAppendThinking:N,flushContentBuffer:U,flushThinkingBuffer:F,resetStreamingBuffers:z,drainPendingBuffers:_}}var u6=j1("UI"),l6=($,Q,J,Y,Z)=>{let q=V1(),X=tQ(),G=_$(),K=n$(),U=f1(),F=D1(),O=F6(),N=Y9(!1),{createAgent:z,cleanupAgent:_}=m6({sessionId:X,systemPrompt:$,appendSystemPrompt:Q,maxTurns:Y}),W=p6(U);c6(()=>{return()=>{_(),W.resetStreamingBuffers()}},[_,W.resetStreamingBuffers]),c6(()=>{if(!K)U.setCurrentThinkingContent(null)},[K,U]);let w=u8(()=>{if(!q)return;Z?.();let{extraContent:R,extraThinking:I}=W.drainPendingBuffers();O.abort("user-cancel"),F.setTasks([]);let v=H1().session.currentStreamingMessageId;if(v){if(R)i1(v,R);T$(v)}if(U.finalizeStreamingMessage(R,I),!N.current)U.addAssistantMessage("任务已停止"),N.current=!0}),L=u8(async(R)=>{let I=!1,v,B=R;try{await x6();let A=O.getAbortController()??O.createAbortController(),b=await k6(R,F,U,A.signal);if(b.type==="handled")return b.commandResult;if(b.type==="continue_as_agent")I=b.result.userMessageAlreadyAdded,v=b.result.onceModelId,B=b.result.agentInput;let k=L1.getInstance(),V,p=await k.executeUserPromptSubmitHooks(B.text,{projectDir:A0(),sessionId:X,permissionMode:G,hasImages:B.images.length>0,imageCount:B.images.length});if(!p.proceed){if(p.warning)U.addAssistantMessage(`${p.warning}`);return{success:!1,error:"blocked by hook"}}if(p.updatedPrompt)B={...B,text:p.updatedPrompt,displayText:p.updatedPrompt,parts:[{type:"text",text:p.updatedPrompt}]};if(p.contextInjection)V=p.contextInjection;try{let{SpecManager:P}=await import("./chunk-
|
|
24
|
+
`)Q++;return Q}function p6($,Q){let J=Q?.flushTimeout??300,Y=Q?.minLinesToFlush??5,Z=Q?.minCharsToFlush??400,q=t$(""),X=t$(null),G=t$(""),K=t$(null),U=N$(()=>{if(q.current){let W=q.current,w=$.appendAssistantContent(W);i1(w,W),q.current=""}if(X.current)clearTimeout(X.current),X.current=null}),F=N$(()=>{if(G.current)$.appendThinkingContent(G.current),G.current="";if(K.current)clearTimeout(K.current),K.current=null}),O=N$((W)=>{q.current+=W;let w=q.current;if(g6(w)>=Y||w.length>=Z){U();return}if(!X.current)X.current=setTimeout(U,J)}),N=N$((W)=>{G.current+=W;let w=G.current;if(g6(w)>=Y||w.length>=Z){F();return}if(!K.current)K.current=setTimeout(F,J)}),z=N$(()=>{if(q.current="",X.current)clearTimeout(X.current),X.current=null;if(G.current="",K.current)clearTimeout(K.current),K.current=null}),_=N$(()=>{if(X.current)clearTimeout(X.current),X.current=null;if(K.current)clearTimeout(K.current),K.current=null;let W=q.current,w=G.current;return q.current="",G.current="",{extraContent:W,extraThinking:w}});return J9(()=>{return()=>{z()}},[z]),{batchAppendContent:O,batchAppendThinking:N,flushContentBuffer:U,flushThinkingBuffer:F,resetStreamingBuffers:z,drainPendingBuffers:_}}var u6=j1("UI"),l6=($,Q,J,Y,Z)=>{let q=V1(),X=tQ(),G=_$(),K=n$(),U=f1(),F=D1(),O=F6(),N=Y9(!1),{createAgent:z,cleanupAgent:_}=m6({sessionId:X,systemPrompt:$,appendSystemPrompt:Q,maxTurns:Y}),W=p6(U);c6(()=>{return()=>{_(),W.resetStreamingBuffers()}},[_,W.resetStreamingBuffers]),c6(()=>{if(!K)U.setCurrentThinkingContent(null)},[K,U]);let w=u8(()=>{if(!q)return;Z?.();let{extraContent:R,extraThinking:I}=W.drainPendingBuffers();O.abort("user-cancel"),F.setTasks([]);let v=H1().session.currentStreamingMessageId;if(v){if(R)i1(v,R);T$(v)}if(U.finalizeStreamingMessage(R,I),!N.current)U.addAssistantMessage("任务已停止"),N.current=!0}),L=u8(async(R)=>{let I=!1,v,B=R;try{await x6();let A=O.getAbortController()??O.createAbortController(),b=await k6(R,F,U,A.signal);if(b.type==="handled")return b.commandResult;if(b.type==="continue_as_agent")I=b.result.userMessageAlreadyAdded,v=b.result.onceModelId,B=b.result.agentInput;let k=L1.getInstance(),V,p=await k.executeUserPromptSubmitHooks(B.text,{projectDir:A0(),sessionId:X,permissionMode:G,hasImages:B.images.length>0,imageCount:B.images.length});if(!p.proceed){if(p.warning)U.addAssistantMessage(`${p.warning}`);return{success:!1,error:"blocked by hook"}}if(p.updatedPrompt)B={...B,text:p.updatedPrompt,displayText:p.updatedPrompt,parts:[{type:"text",text:p.updatedPrompt}]};if(p.contextInjection)V=p.contextInjection;try{let{SpecManager:P}=await import("./chunk-563zye36.js"),r=P.getInstance().buildProgressContext();if(r)V=V?`${V}
|
|
25
25
|
|
|
26
26
|
${r}`:r}catch{}if(!I)U.addUserMessage(B.displayText);let d=y6(B),l=await z(v?{modelId:v}:void 0);if(A.signal.aborted)return u6.info("[handleCommandSubmit] Agent 创建期间已被中止"),{success:!1,error:"aborted"};let s=I6(H1().session);if(V)s.push({role:"system",content:`<user-prompt-submit-hook>
|
|
27
27
|
${V}
|