blade-code 0.6.4 → 0.7.1
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/README.md +1 -1
- package/dist/blade.js +2 -2
- package/dist/{chunk-j7nh0j36.js → chunk-0afbeec0.js} +1 -1
- package/dist/chunk-0k8js58t.js +6 -0
- package/dist/chunk-0vd9antx.js +1 -0
- package/dist/{chunk-w96xaeyd.js → chunk-1dt2y16n.js} +1 -1
- package/dist/{chunk-jm9r362m.js → chunk-2dvn9y9f.js} +1 -1
- package/dist/{chunk-hc91pmdk.js → chunk-56frm8dx.js} +1 -1
- package/dist/chunk-6jezjq4h.js +6 -0
- package/dist/chunk-6k4vs71p.js +1 -0
- package/dist/chunk-70ya127f.js +1 -0
- package/dist/{chunk-sfr69fw8.js → chunk-7v7s2aag.js} +2 -2
- package/dist/{chunk-nm2w2ftg.js → chunk-7z6ba6t9.js} +1 -1
- package/dist/{chunk-m41xq6d0.js → chunk-867h27ke.js} +4 -4
- package/dist/chunk-92qcc3gj.js +2138 -0
- package/dist/{chunk-ck43cs45.js → chunk-a2nshjdc.js} +2 -2
- package/dist/chunk-a7dw8fwn.js +1 -0
- package/dist/chunk-a8eedntd.js +6 -0
- package/dist/{chunk-59e6eg4b.js → chunk-aam53te2.js} +6 -6
- package/dist/{chunk-evc1xkeb.js → chunk-b0q2q0ax.js} +1 -1
- package/dist/{chunk-ey640ttd.js → chunk-bmxgshct.js} +1 -1
- package/dist/chunk-d3db8wrw.js +1 -0
- package/dist/chunk-dzmrdtpc.js +612 -0
- package/dist/chunk-e06p3dkw.js +157 -0
- package/dist/{chunk-f24ahjpc.js → chunk-f76d6jxg.js} +1 -1
- package/dist/chunk-f8mjpmdx.js +4 -0
- package/dist/chunk-h7qab07x.js +2 -0
- package/dist/{chunk-h46kk20y.js → chunk-k9h9bw13.js} +2 -2
- package/dist/chunk-m51xzgwt.js +1 -0
- package/dist/{chunk-bpx8x87m.js → chunk-mt1c5da4.js} +2 -2
- package/dist/chunk-qdnx9x5g.js +2 -0
- package/dist/chunk-qds0yxfy.js +41 -0
- package/dist/chunk-qyfdt8h1.js +2 -0
- package/dist/chunk-r6paqm6d.js +1 -0
- package/dist/chunk-v0rjbvky.js +9 -0
- package/dist/{chunk-cfe1fywb.js → chunk-v1d0d4b4.js} +2 -2
- package/dist/chunk-vs915jzz.js +1 -0
- package/dist/chunk-xmdpc0y5.js +2 -0
- package/dist/chunk-zbtb3jxm.js +1 -0
- package/dist/{chunk-sh1pk5j3.js → chunk-zm4jr1k2.js} +1 -1
- package/dist/chunk-zvk6ktj1.js +6 -0
- package/dist/{chunk-m26jr2tg.js → chunk-zxddgwsb.js} +1 -1
- package/dist/web/assets/{FilePreview-R1mRzyRz.js → FilePreview-DLnUh-wQ.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-B46lJYAn.js → MarkdownRenderer-C5KTk9XG.js} +1 -1
- package/dist/web/assets/{McpModal-QRv5Ij61.js → McpModal-B9qJ4ewt.js} +1 -1
- package/dist/web/assets/{SettingsModal-D-mi6mUR.js → SettingsModal-DpeZ6cJb.js} +1 -1
- package/dist/web/assets/{SettingsStore-Dmo3sZ_R.js → SettingsStore-IzKtyAnM.js} +1 -1
- package/dist/web/assets/{SkillsModal-DNXjbjEs.js → SkillsModal-BDfzgJIj.js} +1 -1
- package/dist/web/assets/{TerminalPanel-DG_Q4UKr.js → TerminalPanel-B2iTF_CR.js} +1 -1
- package/dist/web/assets/{dialog-CsiChiYt.js → dialog-sI3ihAze.js} +1 -1
- package/dist/web/assets/{index-BeYCsOvo.js → index-D8mo0jzF.js} +8 -8
- package/dist/web/index.html +1 -1
- package/package.json +4 -2
- package/dist/chunk-07xv0cqp.js +0 -1
- package/dist/chunk-0e9dhemy.js +0 -41
- package/dist/chunk-2zk921d9.js +0 -1
- package/dist/chunk-3mmm8g84.js +0 -1
- package/dist/chunk-5bs94pb1.js +0 -157
- package/dist/chunk-6mfmy7nq.js +0 -8
- package/dist/chunk-7c9k2c9m.js +0 -1
- package/dist/chunk-7t23swne.js +0 -2125
- package/dist/chunk-9p4fe43p.js +0 -1
- package/dist/chunk-9vsbmtqj.js +0 -1
- package/dist/chunk-dmc5gf4f.js +0 -6
- package/dist/chunk-k063tt5h.js +0 -1
- package/dist/chunk-mpn4zfcn.js +0 -6
- package/dist/chunk-njq4w631.js +0 -613
- package/dist/chunk-p8pggabj.js +0 -2
- package/dist/chunk-qnvkxpkw.js +0 -2
- package/dist/chunk-tdarh4fh.js +0 -1
- package/dist/chunk-tz44akn7.js +0 -6
- package/dist/chunk-vxgexcsm.js +0 -1
- package/dist/chunk-zm78rg9t.js +0 -6
- package/dist/chunk-zwwvv85t.js +0 -4
package/dist/chunk-9p4fe43p.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as a,u as b}from"./chunk-w96xaeyd.js";import"./chunk-p8pggabj.js";import"./chunk-j7nh0j36.js";export{a as globalOptions,b as cliConfig};
|
package/dist/chunk-9vsbmtqj.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Aa as g,Ba as h,Ca as i,Da as j,Ea as k,Fa as l,Ga as m,ua as a,va as b,wa as c,xa as d,ya as e,za as f}from"./chunk-h46kk20y.js";import"./chunk-m41xq6d0.js";import"./chunk-7ycmx7c2.js";import"./chunk-bpx8x87m.js";import"./chunk-j7nh0j36.js";export{a as vanillaStore,c as sessionActions,l as getThinkingModeEnabled,b as getState,j as getModelById,e as getMessages,k as getMcpServers,i as getCurrentModel,f as getConfig,h as getAllModels,g as ensureStoreInitialized,m as configActions,d as appActions};
|
package/dist/chunk-dmc5gf4f.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{A as V,G as f,J as N,K as L,M as T,S as h,U as P,V as R}from"./chunk-7t23swne.js";import{Y as M}from"./chunk-59e6eg4b.js";import"./chunk-evc1xkeb.js";import"./chunk-p8pggabj.js";import"./chunk-ck43cs45.js";import{za as y}from"./chunk-h46kk20y.js";import"./chunk-m41xq6d0.js";import{Ta as O}from"./chunk-njq4w631.js";import"./chunk-f24ahjpc.js";import"./chunk-0e9dhemy.js";import"./chunk-6mfmy7nq.js";import{xb as D}from"./chunk-7ycmx7c2.js";import{Hb as W}from"./chunk-bpx8x87m.js";import"./chunk-j7nh0j36.js";import{Readable as K,Writable as k}from"node:stream";import*as _ from"@agentclientprotocol/sdk";import{PROTOCOL_VERSION as I}from"@agentclientprotocol/sdk";import{nanoid as S}from"nanoid";import{nanoid as x}from"nanoid";var X=W("Agent");class B{id;cwd;connection;clientCapabilities;agent=null;runtime=null;pendingPrompt=null;messages=[];mode="default";sessionApprovals=new Set;constructor(z,G,H,Q){this.id=z;this.cwd=G;this.connection=H;this.clientCapabilities=Q}async initialize(){X.debug(`[AcpSession ${this.id}] Initializing...`),V.initializeSession(this.connection,this.id,this.clientCapabilities,this.cwd),X.debug(`[AcpSession ${this.id}] ACP service context initialized`),this.runtime=await f.create({sessionId:this.id}),this.agent=await T.createWithRuntime(this.runtime,{sessionId:this.id}),X.debug(`[AcpSession ${this.id}] Agent created successfully`)}sendAvailableCommandsDelayed(){X.debug(`[AcpSession ${this.id}] Scheduling available commands update (500ms delay)`),setTimeout(()=>{this.sendAvailableCommands()},500)}async handleSlashCommand(z,G){try{X.debug(`[AcpSession ${this.id}] Executing slash command: ${z}`);let H={cwd:this.cwd,signal:G,acp:{sendMessage:(U)=>{this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:U}})},sendToolStart:(U,Y,q)=>{let Z=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,E=this.mapToolKind(q);this.sendUpdate({sessionUpdate:"tool_call",toolCallId:Z,status:"in_progress",title:`${U}`,content:[{type:"content",content:{type:"text",text:JSON.stringify(Y,null,2)}}],kind:E})},sendToolResult:(U,Y)=>{if(Y.summary)this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:Y.summary}})}}},Q=await P(z,H),J=Q.content||Q.message;if(J)this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:J}});if(Q.error)this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`[FAIL] ${Q.error}`}});return{stopReason:Q.success?"end_turn":"cancelled"}}catch(H){return X.error(`[AcpSession ${this.id}] Slash command error:`,H),this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`[FAIL] 命令执行失败: ${H instanceof Error?H.message:"未知错误"}`}}),{stopReason:"cancelled"}}}async sendAvailableCommands(){try{let z=R(),G=["model","permissions","theme","config","exit","ide"],Q=z.filter((J)=>!G.includes(J.name)).map((J)=>{let U;if(J.usage){let Y=J.usage.replace(/^\/\w+\s*/,"").trim();if(Y)U=Y}if(J.aliases?.length){let Y=`Aliases: ${J.aliases.join(", ")}`;U=U?`${U} | ${Y}`:Y}return{name:J.name,description:J.description,input:U?{hint:U}:void 0}});X.info(`[AcpSession ${this.id}] Sending available commands: ${JSON.stringify(Q.map((J)=>J.name))}`),this.sendUpdate({sessionUpdate:"available_commands_update",availableCommands:Q}),X.info(`[AcpSession ${this.id}] Sent ${Q.length} available commands`)}catch(z){X.error(`[AcpSession ${this.id}] Failed to send available commands:`,z)}}async prompt(z){V.setCurrentSession(this.id),this.pendingPrompt?.abort();let G=new AbortController;if(this.pendingPrompt=G,!this.agent)throw Error("Session not initialized");try{let H=this.resolvePrompt(z.prompt);if(X.debug(`[AcpSession ${this.id}] Received prompt: ${H.slice(0,100)}...`),h(H))return await this.handleSlashCommand(H,G.signal);let Q={sessionId:this.id,userId:"acp-user",workspaceRoot:this.cwd,messages:[...this.messages],signal:G.signal,permissionMode:this.mapModeToPermissionMode(),confirmationHandler:{requestConfirmation:async(J)=>{return this.requestPermission(J)}}};if(await O(this.agent.chatStream(H,Q),async(J)=>{switch(J.kind){case"content_delta":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:J.delta}});break;case"thinking_delta":this.sendUpdate({sessionUpdate:"agent_thought_chunk",content:{type:"text",text:J.delta}});break;case"tool_start":{let U=J.toolCall,Y="function"in U?U.function.name:U.type,q=this.mapToolKind(J.toolKind);this.sendUpdate({sessionUpdate:"tool_call",toolCallId:U.id,status:"in_progress",title:`Executing ${Y}`,content:[],kind:q});break}case"tool_result":{let{toolCall:U,result:Y}=J,q=[],Z=Y.metadata;if(Z?.kind==="edit"&&typeof Z.file_path==="string"&&typeof Z.oldContent==="string"&&(typeof Z.newContent==="string"||Z.newContent===void 0))q.push({type:"diff",path:Z.file_path,oldText:Z.oldContent,newText:Z.newContent??null});else{let F="function"in U?U.function.name:U.type,j=L(N(F,Y));q.push({type:"content",content:{type:"text",text:j}})}let E=Y.success?"completed":"failed";this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:U.id,status:E,content:q});break}case"task_update":this.sendPlanUpdate(J.tasks);break;default:break}}),this.messages=[...Q.messages],G.signal.aborted)return{stopReason:"cancelled"};return{stopReason:"end_turn"}}catch(H){if(G.signal.aborted||H instanceof Error&&H.name==="AbortError")return{stopReason:"cancelled"};throw X.error(`[AcpSession ${this.id}] Prompt error:`,H),H}finally{if(this.pendingPrompt===G)this.pendingPrompt=null}}cancel(){if(X.info(`[AcpSession ${this.id}] Cancel requested`),this.pendingPrompt)this.pendingPrompt.abort(),this.pendingPrompt=null,X.info(`[AcpSession ${this.id}] Cancelled successfully`);else X.warn(`[AcpSession ${this.id}] No pending prompt to cancel`)}async setMode(z){let G=["default","auto-edit","yolo","plan"];this.mode=G.includes(z)?z:"default",X.info(`[AcpSession ${this.id}] Mode set to: ${this.mode}`),this.sendUpdate({sessionUpdate:"current_mode_update",currentModeId:this.mode})}mapModeToPermissionMode(){switch(this.mode){case"yolo":return"yolo";case"auto-edit":return"autoEdit";case"plan":return"plan";case"default":default:return"default"}}shouldAutoApprove(z){switch(this.mode){case"yolo":return!0;case"auto-edit":return z==="readonly"||z==="write";case"plan":return z==="readonly";case"default":default:return!1}}async setModel(z){if(X.info(`[AcpSession ${this.id}] Model set to: ${z}`),this.agent)X.warn(`[AcpSession ${this.id}] Runtime model switching not yet implemented`)}async destroy(){if(this.cancel(),this.agent)await this.agent.destroy(),this.agent=null;if(this.runtime)await this.runtime.dispose(),this.runtime=null;V.destroySession(this.id),X.debug(`[AcpSession ${this.id}] Destroyed`)}resolvePrompt(z){let G=[];for(let H of z)if(H.type==="text")G.push(H.text);else if(H.type==="image")G.push(`[Image: ${H.mimeType}]`);else if(H.type==="resource"){let Q=H.resource;if("text"in Q)G.push(`<file path="${Q.uri}">
|
|
2
|
-
${Q.text}
|
|
3
|
-
</file>`)}else if(H.type==="resource_link")G.push(`[Resource: ${H.uri}]`);return G.join(`
|
|
4
|
-
`)}sendUpdate(z){let G={sessionId:this.id,update:z};this.connection.sessionUpdate(G).catch((H)=>{X.warn(`[AcpSession ${this.id}] Failed to send update:`,H)})}sendPlanUpdate(z){let G=z.map((H)=>({content:H.subject,priority:H.priority,status:H.status}));X.debug(`[AcpSession ${this.id}] Sending plan update with ${G.length} entries`),this.sendUpdate({sessionUpdate:"plan",entries:G})}async requestPermission(z){let G=z.kind?.toLowerCase()||"execute";if(this.shouldAutoApprove(G))return X.debug(`[AcpSession ${this.id}] Auto-approving ${G} in mode: ${this.mode}`),{approved:!0};if(this.mode==="plan"&&(G==="write"||G==="execute"))return X.debug(`[AcpSession ${this.id}] Rejecting ${G} in plan mode`),{approved:!1,reason:"Write and execute operations are not allowed in Plan mode"};let H=`${G}:${z.title||"unknown"}`;if(this.sessionApprovals.has(H))return X.debug(`[AcpSession ${this.id}] Using cached approval for: ${H}`),{approved:!0};try{let Q=x(),J=[];if(z.message)J.push({type:"content",content:{type:"text",text:z.message}});if(z.risks&&z.risks.length>0)J.push({type:"content",content:{type:"text",text:`Risks:
|
|
5
|
-
- ${z.risks.join(`
|
|
6
|
-
- `)}`}});let U=this.mapToolKind(G),Y={sessionId:this.id,options:[{optionId:"allow_once",name:"Allow once",kind:"allow_once"},{optionId:"allow_always",name:"Always allow",kind:"allow_always"},{optionId:"reject_once",name:"Deny once",kind:"reject_once"},{optionId:"reject_always",name:"Always deny",kind:"reject_always"}],toolCall:{toolCallId:Q,status:"pending",title:z.title||"Permission Required",content:J,kind:U}},Z=(await this.connection.requestPermission(Y)).outcome;if(Z.outcome==="cancelled")return{approved:!1,reason:"User cancelled the permission request"};let E=Z.optionId,F=E==="allow_once"||E==="allow_always";if(E==="allow_always")this.sessionApprovals.add(H),X.debug(`[AcpSession ${this.id}] Cached approval for: ${H}`);return{approved:F,reason:F?void 0:"User denied the operation"}}catch(Q){return X.warn(`[AcpSession ${this.id}] Permission request failed:`,Q),{approved:!1,reason:"Permission request failed"}}}mapToolKind(z){return{readonly:"read",write:"edit",execute:"execute",read:"read",edit:"edit",delete:"delete",move:"move",search:"search",think:"think",fetch:"fetch"}[z||""]||"other"}}var $=W("Agent");class w{connection;sessions=new Map;clientCapabilities;constructor(z){this.connection=z}async initialize(z){return $.info("[BladeAgent] Initializing ACP connection"),$.debug(`[BladeAgent] Client capabilities: ${JSON.stringify(z.clientCapabilities)}`),this.clientCapabilities=z.clientCapabilities,{protocolVersion:I,agentCapabilities:{loadSession:!1,promptCapabilities:{image:!0,audio:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0}}}}async authenticate(z){return}async newSession(z){let G=S();$.info(`[BladeAgent] Creating new session: ${G}`),$.debug(`[BladeAgent] Session cwd: ${z.cwd||D()}`);let H=new B(G,z.cwd||D(),this.connection,this.clientCapabilities);await H.initialize(),this.sessions.set(G,H),$.info(`[BladeAgent] Session ${G} created, scheduling available commands update`),H.sendAvailableCommandsDelayed();let Q=y(),J=Q?.models||[],U=Q?.currentModelId||J[0]?.id,Y=J.map((Z)=>({modelId:Z.id,name:Z.name||Z.id,description:Z.provider?`Provider: ${Z.provider}`:void 0}));return{sessionId:G,modes:{availableModes:[{id:"default",name:"Default",description:"Ask for confirmation before all file edits and commands"},{id:"auto-edit",name:"Auto Edit",description:"Auto-approve file edits, ask for shell commands"},{id:"yolo",name:"Full Auto",description:"Auto-approve everything without confirmation"},{id:"plan",name:"Plan Only",description:"Read-only mode, no file changes or commands"}],currentModeId:"default"},models:Y.length>0?{availableModels:Y,currentModelId:U}:void 0}}async prompt(z){let G=this.sessions.get(z.sessionId);if(!G)throw Error(`Session not found: ${z.sessionId}`);return G.prompt(z)}async cancel(z){$.info(`[BladeAgent] Cancel notification received for session: ${z.sessionId}`);let G=this.sessions.get(z.sessionId);if(G)$.info("[BladeAgent] Found session, calling session.cancel()"),G.cancel();else $.warn(`[BladeAgent] Session not found for cancel: ${z.sessionId}`)}async setSessionMode(z){$.info(`[BladeAgent] Setting session mode: ${z.modeId}`);let G=this.sessions.get(z.sessionId);if(G)await G.setMode(z.modeId);return{}}async unstable_setSessionModel(z){$.info(`[BladeAgent] Setting session model: ${z.modelId}`);let G=this.sessions.get(z.sessionId);if(G)await G.setModel(z.modelId);return{}}async destroy(){for(let z of this.sessions.values())await z.destroy();this.sessions.clear(),await M.getInstance().disconnectAll()}}async function Jz(){let z=k.toWeb(process.stdout),G=K.toWeb(process.stdin),H=_.ndJsonStream(z,G);await new _.AgentSideConnection((J)=>new w(J),H).closed}export{Jz as runAcpIntegration};
|
package/dist/chunk-k063tt5h.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aa as a,ba as b,ca as c,da as d,ea as e,fa as f}from"./chunk-p8pggabj.js";import"./chunk-j7nh0j36.js";export{b as getVersion,c as getPackageName,a as getPackageInfo,e as getFormattedVersion,d as getDescription,f as getCopyright};
|
package/dist/chunk-mpn4zfcn.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{p as _,q as x,r as E,s as N}from"./chunk-zwwvv85t.js";import{t as A}from"./chunk-w96xaeyd.js";import{v as B,w as D,x as L}from"./chunk-tz44akn7.js";import{G as $,M as b}from"./chunk-7t23swne.js";import"./chunk-59e6eg4b.js";import"./chunk-evc1xkeb.js";import"./chunk-p8pggabj.js";import"./chunk-ck43cs45.js";import"./chunk-h46kk20y.js";import"./chunk-m41xq6d0.js";import{Ta as Z}from"./chunk-njq4w631.js";import"./chunk-f24ahjpc.js";import"./chunk-0e9dhemy.js";import"./chunk-6mfmy7nq.js";import{wb as X,xb as Y}from"./chunk-7ycmx7c2.js";import"./chunk-bpx8x87m.js";import"./chunk-j7nh0j36.js";import f from"yargs";import{hideBin as h}from"yargs/helpers";var R=new Set(Object.values(X));function W(k){if(k&&R.has(k))return k;return}function w(k){return k.command("* [message]","Print response and exit (useful for pipes)",(F)=>F.positional("message",{describe:"Message to process",type:"string"}).option("p",{alias:"print",describe:"Print response and exit (useful for pipes)",type:"boolean"}).option("output-format",{describe:'Output format: "text", "json", "stream-json"',type:"string",default:"text"}).option("include-partial-messages",{describe:"Include partial message chunks as they arrive",type:"boolean"}).option("input-format",{describe:'Input format: "text", "stream-json"',type:"string",default:"text"}).option("model",{describe:"Model for the current session",type:"string"}).option("append-system-prompt",{describe:"Append a system prompt to the default system prompt",type:"string"}).option("system-prompt",{describe:"Replace the default system prompt",type:"string"}).option("max-turns",{alias:["maxTurns"],describe:"Maximum conversation turns (-1: unlimited, N>0: limit to N turns)",type:"number"}),async(F)=>{if(!F.p)return;let q=await M(F);process.exit(q)})}async function M(k,F=process){let q;try{await _();let J=await x({message:k.message,_:k._,defaultMessage:"Hello"}),G=await E(J);if(G.mode==="output"){if(G.content)F.stdout.write(`${G.content}
|
|
2
|
-
`);return G.exitCode??0}let Q=G.content,{sessionId:K,messages:T}=await N({sessionId:k.sessionId,continue:k.continue,resume:k.resume,fallbackSessionPrefix:"print"});q=await $.create({sessionId:K,modelId:k.model,mcpConfig:k.mcpConfig,strictMcpConfig:k.strictMcpConfig});let U=await b.createWithRuntime(q,{sessionId:K,systemPrompt:k.systemPrompt,appendSystemPrompt:k.appendSystemPrompt,maxTurns:k.maxTurns,modelId:k.model,permissionMode:W(k.permissionMode),toolWhitelist:k.allowedTools,toolBlacklist:k.disallowedTools,mcpConfig:k.mcpConfig,strictMcpConfig:k.strictMcpConfig}),H=(await Z(U.chatStream(Q,{messages:[...T],userId:"cli-user",sessionId:K,workspaceRoot:Y(),permissionMode:W(k.permissionMode)}))).finalMessage||"";if(k.outputFormat==="json")F.stdout.write(`${JSON.stringify({response:H,input:Q,model:k.model,timestamp:new Date().toISOString()},null,2)}
|
|
3
|
-
`);else if(k.outputFormat==="stream-json")F.stdout.write(`${JSON.stringify({type:"response",content:H})}
|
|
4
|
-
`);else F.stdout.write(`${H}
|
|
5
|
-
`);return 0}catch(J){return F.stderr.write(`Error: ${J instanceof Error?J.message:"未知错误"}
|
|
6
|
-
`),1}finally{await q?.dispose()}}async function m(){if(process.argv.slice(2).findIndex((q)=>q==="--print"||q==="-p")===-1)return!1;try{let{print:q,"output-format":J,"include-partial-messages":G,"input-format":Q,"system-prompt":K,"append-system-prompt":T,"max-turns":U,...V}=A,H=f(h(process.argv)).scriptName("blade").strict(!1).options(V).middleware([B,D,L]);return w(H),await H.parse(),!0}catch(q){console.error(`Print mode error: ${q instanceof Error?q.message:"未知错误"}`),process.exit(1)}}export{M as runPrint,m as handlePrintMode};
|