blade-code 0.7.4 → 0.7.5
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-byxazdwv.js → chunk-0rw4tdqy.js} +1 -1
- package/dist/{chunk-3mhbped9.js → chunk-7pcm8vy5.js} +35 -35
- package/dist/{chunk-n5rg9dbv.js → chunk-8ea9h3mb.js} +1 -1
- package/dist/{chunk-6rszb7xd.js → chunk-8w1hd9ct.js} +255 -255
- package/dist/{chunk-7mnefph6.js → chunk-a8znntss.js} +1 -1
- package/dist/{chunk-pa364yr9.js → chunk-apb1p5q4.js} +1 -1
- package/dist/{chunk-erpgkabk.js → chunk-ay3rhhx8.js} +1 -1
- package/dist/{chunk-egavbybx.js → chunk-c3yn8ds8.js} +1 -1
- package/dist/{chunk-jpry8h07.js → chunk-g1eb7f4q.js} +1 -1
- package/dist/{chunk-501my8nh.js → chunk-jfykets9.js} +1 -1
- package/dist/{chunk-4e2fzyf2.js → chunk-jsn8476q.js} +1 -1
- package/dist/chunk-kssr4fbg.js +1 -0
- package/dist/{chunk-b1d49byc.js → chunk-n969rv4v.js} +1 -1
- package/dist/{chunk-ctbhcw8h.js → chunk-vhc1yr3v.js} +1 -1
- package/dist/{chunk-by93yn92.js → chunk-yaj4nmmp.js} +1 -1
- package/dist/{chunk-z7x21493.js → chunk-yz2jztga.js} +1 -1
- package/dist/chunk-zye2s6f0.js +2 -0
- package/package.json +1 -1
- package/dist/chunk-dftaxwg9.js +0 -1
- package/dist/chunk-gzc9n5d6.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as _4,c as N4,d as F4}from"./chunk-gjf2d2yg.js";import{j as T2,k as f2}from"./chunk-pvxp2gzr.js";import{l as f$,m as t$,o as W1}from"./chunk-bmcc85nj.js";import{y as y4}from"./chunk-k4behavv.js";import{C as o8,D as a6,E as v4,F as q8,G as V1,H as z$,J as M6,K as k6,N as S$,O as k8,P as R4,Q as x1,R as _J,S as NJ,T as T6,U as P4,V as f6,X as YJ,z as JJ}from"./chunk-
|
|
1
|
+
import{b as _4,c as N4,d as F4}from"./chunk-gjf2d2yg.js";import{j as T2,k as f2}from"./chunk-pvxp2gzr.js";import{l as f$,m as t$,o as W1}from"./chunk-bmcc85nj.js";import{y as y4}from"./chunk-k4behavv.js";import{C as o8,D as a6,E as v4,F as q8,G as V1,H as z$,J as M6,K as k6,N as S$,O as k8,P as R4,Q as x1,R as _J,S as NJ,T as T6,U as P4,V as f6,X as YJ,z as JJ}from"./chunk-8w1hd9ct.js";import"./chunk-e21htmg4.js";import{_ as b4}from"./chunk-a8znntss.js";import"./chunk-rtn0rb16.js";import{ca as G$,da as E0,ea as j1,fa as RQ,ga as O$,ha as n$,ia as xJ,ja as cQ,ka as M2,la as dJ,ma as sQ,na as $1,oa as B4,pa as H1,qa as O4,sa as e$,ya as m0}from"./chunk-5smacbk0.js";import{Ba as w4,za as L4}from"./chunk-rkhhzc4r.js";import{Ia as b2}from"./chunk-jsn8476q.js";import{Ma as Q4,Na as A4,Va as m6}from"./chunk-7pcm8vy5.js";import"./chunk-cyxb6fxe.js";import{lb as MQ,nb as O1}from"./chunk-jf48kahn.js";import{qb as WJ,tb as z0}from"./chunk-63dzf6hr.js";import{wb as x2}from"./chunk-98jpdmgc.js";import{Ib as H4,Lb as D1}from"./chunk-w1zb8zac.js";import{Nb as IQ}from"./chunk-kfg3vx5z.js";import{useMemoizedFn as aQ}from"ahooks";import{useEffect as k5,useState as oQ}from"react";import{useMemoizedFn as c0}from"ahooks";import{Box as d1}from"ink";import{useEffect as l1,useRef as S8}from"react";import{useShallow as V4}from"zustand/react/shallow";import{useStore as D4}from"zustand";function Q0($){return D4(sQ,$)}var j4=[],eQ=()=>Q0(($)=>$.session.sessionId),$6=()=>Q0(($)=>$.session.messages),Q6=()=>Q0(($)=>$.session.clearCount),J6=()=>Q0(($)=>$.session.isCompacting),Y6=()=>Q0(($)=>$.session.tokenUsage.estimatedCostUsd),S1=()=>Q0(($)=>$.session.actions),Z6=()=>Q0(($)=>{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)}),X6=()=>Q0(($)=>$.app.initializationStatus),q6=()=>Q0(($)=>$.app.initializationError),d$=()=>Q0(($)=>$.app.activeModal),G6=()=>Q0(($)=>$.app.tasks),U6=()=>Q0(($)=>$.app.modelEditorTarget),K6=()=>Q0(($)=>$.app.sessionSelectorData),O6=()=>Q0(($)=>$.app.awaitingSecondCtrlC),T1=()=>Q0(($)=>$.app.actions),l$=()=>Q0(($)=>$.app.initializationStatus==="ready"),z6=()=>Q0(($)=>$.app.tasks.length>0),K$=()=>Q0(($)=>$.config.config?.permissionMode||"default"),_6=()=>Q0(($)=>$.config.config?.models??j4),r$=()=>Q0(($)=>{let Q=$.config.config;if(!Q)return;let Y=Q.currentModelId;return Q.models.find((Z)=>Z.id===Y)??Q.models[0]}),N6=()=>Q0(($)=>$.config.config?.currentModelId),F0=()=>Q0(($)=>{return E0.getTheme()}),F6=()=>Q0(($)=>$.config.config?.theme??"default"),a0=()=>Q0(($)=>$.focus.currentFocus),W6=()=>Q0(($)=>$.focus.actions),f1=()=>Q0(($)=>$.command.isProcessing),H6=()=>Q0(($)=>$.command.actions),a$=()=>Q0(($)=>$.command.pendingCommands),L6=()=>Q0(($)=>$.command.recoveredSteeringCount),o$=()=>Q0(($)=>$.app.thinkingModeEnabled),w6=()=>Q0(($)=>$.session.currentThinkingContent),B6=()=>Q0(($)=>$.session.thinkingExpanded),b6=()=>Q0(($)=>$.session.currentStreamingMessageId),A6=()=>Q0(V4(($)=>({lines:$.session.currentStreamingLines,tail:$.session.currentStreamingTail,lineCount:$.session.currentStreamingLineCount,version:$.session.currentStreamingVersion}))),v6=()=>Q0(($)=>$.session.finalizingStreamingMessageId),y6=()=>Q0(($)=>$.session.historyExpanded),R6=()=>Q0(($)=>$.session.expandedMessageCount);import{useMemoizedFn as T$}from"ahooks";import{useEffect as x8,useRef as h6}from"react";function E4($){if(!($ instanceof Error))return"未知错误";let J=$.lastError??$;if(J.responseBody)try{let G=JSON.parse(J.responseBody)?.error?.message;if(G){let X=J.statusCode?` (HTTP ${J.statusCode})`:"";return`${G}${X}`}}catch{}let Z=$.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return $.message}function h4($){if(!($ instanceof Error))return!1;return $.name==="AbortError"||$.message.includes("aborted")}function m4($){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 i$($){let Q=h4($),Y=m4($),J;if(Y)J="当前模型不支持图片理解功能。请切换到支持视觉能力的模型(如 Claude 4.5、GPT-5.2、Gemini 3 Pro、Qwen3-VL-Plus 等)后重试。";else J=E4($);return{displayMessage:J,isAbort:Q,isVisionNotSupported:Y}}import{appendFileSync as p4,mkdirSync as g4,writeFileSync as c4}from"node:fs";import u4 from"node:os";import I6 from"node:path";var E8=I6.join(u4.homedir(),".blade","logs","stream-debug.log"),P6=!1;function x4(){if(P6)return;let $=I6.dirname(E8);g4($,{recursive:!0,mode:493}),c4(E8,`=== Stream Debug Log Started: ${new Date().toISOString()} ===
|
|
2
2
|
`),P6=!0}function h8($,Q,Y){x4();let J=new Date().toISOString(),Z=Y?` | ${JSON.stringify(Y)}`:"",q=`[${J}] [${$}] ${Q}${Z}
|
|
3
3
|
`;p4(E8,q)}var C$=D1("UI");function C6($,Q){let Y=!1;return(J)=>{switch(J.kind){case"content_delta":if(Y||$.signal.aborted)break;Q.contentDeltaCount++,Q.contentDeltaTotalLen+=J.delta.length,h8("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(C$.debug("[loopEventHandler] stream_end",{contentDeltaCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),h8("loopEventHandler","onStreamEnd",{contentDeltaCallCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),Y||$.signal.aborted){Y=!0;break}let{extraContent:Z,extraThinking:q}=$.streamingBuffer.drainPendingBuffers(),G=$.getStreamingMessageId();if(G){if(Z)O$(G,Z);n$(G)}$.sessionActions.finalizeStreamingMessage(Z,q),Y=!0;break}case"model_fallback":Y=!0,$.streamingBuffer.resetStreamingBuffers(),$.sessionActions.discardStreamingMessage(),$.sessionActions.setCurrentThinkingContent(null);break;case"tool_start":{let Z=J.toolCall;if(!("function"in Z))break;if(C$.debug("[loopEventHandler] tool_start",{toolName:Z.function.name,toolKind:J.toolKind}),["TaskCreate","TaskUpdate","TaskList"].includes(Z.function.name))break;try{let q=JSON.parse(Z.function.arguments),G=M6(Z.function.name,q);$.sessionActions.addToolMessage(G,{toolName:Z.function.name,phase:"start",summary:G,params:q})}catch(q){C$.error("[loopEventHandler] onToolStart error:",q)}break}case"tool_result":{let Z=J.toolCall;if(!("function"in Z))break;C$.debug("[loopEventHandler] tool_result",{toolName:Z.function.name,success:J.result.success});let q=k6(Z.function.name,J.result);$.sessionActions.addToolMessage(q.summary,{toolName:Z.function.name,phase:"complete",summary:q.summary,detail:q.detail});break}case"token_usage":$.sessionActions.updateTokenUsage(J.usage);break;case"compaction":if($.sessionActions.setCompacting(J.phase==="start"),J.phase==="end")$.sessionActions.resetTokenUsage();break;case"turn_start":C$.debug("[loopEventHandler] turn_start",{turn:J.turn,maxTurns:J.maxTurns}),$.sessionActions.updateTokenUsage({turnCount:J.turn}),Y=!1;break;case"task_update":$.appActions.setTasks(J.tasks);break;case"steering_applied":for(let Z=0;Z<J.count;Z++)$.commandActions.dequeueCommand();if(J.recovered>0)$.commandActions.setRecoveredSteeringCount(J.recovered);break;case"follow_up_started":for(let Z of J.messages){if(!Z.recovered||Z.persisted)continue;let q=typeof Z.content==="string"?Z.content:Z.content.map((G)=>G.type==="text"?G.text:"[Image]").join(`
|
|
4
4
|
`);$.sessionActions.addUserMessage(q)}if(J.recovered>0)$.commandActions.setRecoveredSteeringCount(J.recovered);break;case"subagent_spawned":case"subagent_completed":break;default:{let Z=J}}}}function p8($){let{text:Q,images:Y,parts:J}=$;if(Y.length===0)return Q;let Z=[];for(let q of J)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 S6($){return{role:$.role,content:$.content}}function g8($){if(!$.restoredContextMessages||$.restoredVisibleMessageCount<=0)return $.messages.map(S6);let Q=$.messages.slice($.restoredVisibleMessageCount).map(S6);return[...$.restoredContextMessages,...Q]}function d4($){return typeof $==="object"&&$!==null&&$.action==="invoke_skill"&&typeof $.skillName==="string"}function l4($){return typeof $==="object"&&$!==null&&$.action==="invoke_custom_command"&&typeof $.commandName==="string"&&typeof $.processedContent==="string"}function r4($){return typeof $==="object"&&$!==null&&$.action==="invoke_plugin_command"&&typeof $.commandName==="string"&&typeof $.processedContent==="string"}function a4($){return typeof $==="object"&&$!==null&&$.action==="invoke_once_model"&&typeof $.modelId==="string"&&typeof $.prompt==="string"}function o4($,Q,Y,J){switch($){case"show_theme_selector":return Y.setActiveModal("themeSelector"),!0;case"show_model_selector":return Y.setActiveModal("modelSelector"),!0;case"show_model_add_wizard":return Y.setActiveModal("modelAddWizard"),!0;case"show_permissions_manager":return Y.setActiveModal("permissionsManager"),!0;case"show_agents_manager":return Y.setActiveModal("agentsManager"),!0;case"show_skills_manager":return Y.setActiveModal("skillsManager"),!0;case"show_hooks_manager":return Y.setActiveModal("hooksManager"),!0;case"show_plugins_manager":return Y.setActiveModal("pluginsManager"),!0;case"show_agent_creation_wizard":return Y.setActiveModal("agentCreationWizard"),!0;case"show_session_selector":{let Z=Q?.sessions;return Y.showSessionSelector(Z),!0}case"clear_screen":return J.clearMessages(),J.setError(null),J.resetTokenUsage(),Y.setTasks([]),!0;case"compact_completed":case"compact_fallback":return J.resetTokenUsage(),!0;case"exit_application":return W1(0),!0;default:return!1}}async function D6($,Q,Y,J,Z){let{text:q}=$;if(!T6(q))return{type:"not_slash"};let G={cwd:z0(),sessionId:Z,signal:J},X=await f6(q,G);if(X.message){if(o4(X.message,X.data,Q,Y))return{type:"handled",commandResult:{success:!0}}}if(d4(X.data)){let{skillName:U,skillArgs:F}=X.data,O=F?`Please use the "${U}" skill to help me with: ${F}`:`Please use the "${U}" skill.`;return Y.addUserMessage(O),{type:"continue_as_agent",result:{userDisplayMessage:O,agentInput:{displayText:O,text:O,images:[],parts:[{type:"text",text:O}]},userMessageAlreadyAdded:!0}}}if(l4(X.data)){let{commandName:U,processedContent:F}=X.data;Y.addUserMessage(q);let O=`# Custom Command: /${U}
|