@@ -51,6 +51,7 @@ import { LoadAPIKeyError } from "ai"
5151import type { AssistantMessage , Event , OpencodeClient , SessionMessageResponse , ToolPart } from "@opencode-ai/sdk/v2"
5252import { applyPatch } from "diff"
5353import { InstallationVersion } from "@opencode-ai/core/installation/version"
54+ import { ShellToolID } from "@/tool/shell/id"
5455
5556type ModeOption = { id : string ; name : string ; description ?: string }
5657type ModelOption = { modelId : string ; name : string }
@@ -144,7 +145,7 @@ export class Agent implements ACPAgent {
144145 private sessionManager : ACPSessionManager
145146 private eventAbort = new AbortController ( )
146147 private eventStarted = false
147- private bashSnapshots = new Map < string , string > ( )
148+ private shellSnapshots = new Map < string , string > ( )
148149 private toolStarts = new Set < string > ( )
149150 private permissionQueues = new Map < string , Promise < void > > ( )
150151 private permissionOptions : PermissionOption [ ] = [
@@ -283,16 +284,16 @@ export class Agent implements ACPAgent {
283284
284285 switch ( part . state . status ) {
285286 case "pending" :
286- this . bashSnapshots . delete ( part . callID )
287+ this . shellSnapshots . delete ( part . callID )
287288 return
288289
289290 case "running" :
290- const output = this . bashOutput ( part )
291+ const output = this . shellOutput ( part )
291292 const content : ToolCallContent [ ] = [ ]
292293 if ( output ) {
293294 const hash = Hash . fast ( output )
294- if ( part . tool === "bash" ) {
295- if ( this . bashSnapshots . get ( part . callID ) === hash ) {
295+ if ( part . tool === ShellToolID . id ) {
296+ if ( this . shellSnapshots . get ( part . callID ) === hash ) {
296297 await this . connection
297298 . sessionUpdate ( {
298299 sessionId,
@@ -311,7 +312,7 @@ export class Agent implements ACPAgent {
311312 } )
312313 return
313314 }
314- this . bashSnapshots . set ( part . callID , hash )
315+ this . shellSnapshots . set ( part . callID , hash )
315316 }
316317 content . push ( {
317318 type : "content" ,
@@ -342,7 +343,7 @@ export class Agent implements ACPAgent {
342343
343344 case "completed" : {
344345 this . toolStarts . delete ( part . callID )
345- this . bashSnapshots . delete ( part . callID )
346+ this . shellSnapshots . delete ( part . callID )
346347 const kind = toToolKind ( part . tool )
347348 const content : ToolCallContent [ ] = [
348349 {
@@ -423,7 +424,7 @@ export class Agent implements ACPAgent {
423424 }
424425 case "error" :
425426 this . toolStarts . delete ( part . callID )
426- this . bashSnapshots . delete ( part . callID )
427+ this . shellSnapshots . delete ( part . callID )
427428 await this . connection
428429 . sessionUpdate ( {
429430 sessionId,
@@ -837,10 +838,10 @@ export class Agent implements ACPAgent {
837838 await this . toolStart ( sessionId , part )
838839 switch ( part . state . status ) {
839840 case "pending" :
840- this . bashSnapshots . delete ( part . callID )
841+ this . shellSnapshots . delete ( part . callID )
841842 break
842843 case "running" :
843- const output = this . bashOutput ( part )
844+ const output = this . shellOutput ( part )
844845 const runningContent : ToolCallContent [ ] = [ ]
845846 if ( output ) {
846847 runningContent . push ( {
@@ -871,7 +872,7 @@ export class Agent implements ACPAgent {
871872 break
872873 case "completed" :
873874 this . toolStarts . delete ( part . callID )
874- this . bashSnapshots . delete ( part . callID )
875+ this . shellSnapshots . delete ( part . callID )
875876 const kind = toToolKind ( part . tool )
876877 const content : ToolCallContent [ ] = [
877878 {
@@ -951,7 +952,7 @@ export class Agent implements ACPAgent {
951952 break
952953 case "error" :
953954 this . toolStarts . delete ( part . callID )
954- this . bashSnapshots . delete ( part . callID )
955+ this . shellSnapshots . delete ( part . callID )
955956 await this . connection
956957 . sessionUpdate ( {
957958 sessionId,
@@ -1105,8 +1106,8 @@ export class Agent implements ACPAgent {
11051106 }
11061107 }
11071108
1108- private bashOutput ( part : ToolPart ) {
1109- if ( part . tool !== "bash" ) return
1109+ private shellOutput ( part : ToolPart ) {
1110+ if ( part . tool !== ShellToolID . id ) return
11101111 if ( ! ( "metadata" in part . state ) || ! part . state . metadata || typeof part . state . metadata !== "object" ) return
11111112 const output = part . state . metadata [ "output" ]
11121113 if ( typeof output !== "string" ) return
@@ -1549,9 +1550,9 @@ export class Agent implements ACPAgent {
15491550
15501551function toToolKind ( toolName : string ) : ToolKind {
15511552 const tool = toolName . toLocaleLowerCase ( )
1553+ if ( tool === ShellToolID . id ) return "execute"
1554+
15521555 switch ( tool ) {
1553- case "bash" :
1554- return "execute"
15551556 case "webfetch" :
15561557 return "fetch"
15571558
@@ -1576,6 +1577,8 @@ function toToolKind(toolName: string): ToolKind {
15761577
15771578function toLocations ( toolName : string , input : Record < string , any > ) : { path : string } [ ] {
15781579 const tool = toolName . toLocaleLowerCase ( )
1580+ if ( tool === ShellToolID . id ) return [ ]
1581+
15791582 switch ( tool ) {
15801583 case "read" :
15811584 case "edit" :
@@ -1584,8 +1587,6 @@ function toLocations(toolName: string, input: Record<string, any>): { path: stri
15841587 case "glob" :
15851588 case "grep" :
15861589 return input [ "path" ] ? [ { path : input [ "path" ] } ] : [ ]
1587- case "bash" :
1588- return [ ]
15891590 default :
15901591 return [ ]
15911592 }
0 commit comments