@@ -104,7 +104,7 @@ type Config struct {
104104 ExecutionTimeout int
105105}
106106
107- type sandboxToolBackend struct {
107+ type SandboxTool struct {
108108 secretAccessKey string
109109 accessKeyID string
110110 baseURL string
@@ -117,14 +117,14 @@ type sandboxToolBackend struct {
117117 executionTimeout int
118118}
119119
120- // NewSandboxToolBackend creates a new sandboxToolBackend instance.
121- // sandboxToolBackend refers to the sandbox running instance created by the sandbox tool in Volcengine.
120+ // NewSandboxToolBackend creates a new SandboxTool instance.
121+ // SandboxTool refers to the sandbox running instance created by the sandbox tool in Volcengine.
122122// For creating a sandbox tool environment, please refer to: https://www.volcengine.com/docs/86681/1847934?lang=zh;
123123// For creating a sandbox tool running instance, please refer to: https://www.volcengine.com/docs/86681/1860266?lang=zh.
124124// Note: The execution paths within the sandbox environment may be subject to permission restrictions (read, write, execute, etc.).
125125// Improper path selection can result in operation failures or permission errors.
126126// It is recommended to perform operations within paths where the sandbox environment has explicit permissions to mitigate permission-related risks.
127- func NewSandboxToolBackend (config * Config ) (filesystem. Backend , error ) {
127+ func NewSandboxToolBackend (config * Config ) (* SandboxTool , error ) {
128128 if config .AccessKeyID == "" {
129129 return nil , fmt .Errorf ("AccessKeyID is required" )
130130 }
@@ -159,7 +159,7 @@ func NewSandboxToolBackend(config *Config) (filesystem.Backend, error) {
159159 return nil , fmt .Errorf ("invalid region: %s" , region )
160160 }
161161
162- return & sandboxToolBackend {
162+ return & SandboxTool {
163163 accessKeyID : config .AccessKeyID ,
164164 secretAccessKey : config .SecretAccessKey ,
165165 httpClient : httpClient ,
@@ -174,7 +174,7 @@ func NewSandboxToolBackend(config *Config) (filesystem.Backend, error) {
174174}
175175
176176// LsInfo lists file information under the given path.
177- func (s * sandboxToolBackend ) LsInfo (ctx context.Context , req * filesystem.LsInfoRequest ) ([]filesystem.FileInfo , error ) {
177+ func (s * SandboxTool ) LsInfo (ctx context.Context , req * filesystem.LsInfoRequest ) ([]filesystem.FileInfo , error ) {
178178 path , err := formatPath (req .Path , "/" , true )
179179 if err != nil {
180180 return nil , err
@@ -216,7 +216,7 @@ func (s *sandboxToolBackend) LsInfo(ctx context.Context, req *filesystem.LsInfoR
216216}
217217
218218// Read reads file content with support for line-based offset and limit.
219- func (s * sandboxToolBackend ) Read (ctx context.Context , req * filesystem.ReadRequest ) (string , error ) {
219+ func (s * SandboxTool ) Read (ctx context.Context , req * filesystem.ReadRequest ) (string , error ) {
220220 path , err := formatPath (req .FilePath , "" , true )
221221 if err != nil {
222222 return "" , err
@@ -251,7 +251,7 @@ func (s *sandboxToolBackend) Read(ctx context.Context, req *filesystem.ReadReque
251251}
252252
253253// GrepRaw searches for content matching the specified pattern in files.
254- func (s * sandboxToolBackend ) GrepRaw (ctx context.Context , req * filesystem.GrepRequest ) ([]filesystem.GrepMatch , error ) {
254+ func (s * SandboxTool ) GrepRaw (ctx context.Context , req * filesystem.GrepRequest ) ([]filesystem.GrepMatch , error ) {
255255 path , _ := formatPath (req .Path , "" , false )
256256 params := map [string ]any {
257257 "pattern" : req .Pattern ,
@@ -292,7 +292,7 @@ func (s *sandboxToolBackend) GrepRaw(ctx context.Context, req *filesystem.GrepRe
292292}
293293
294294// GlobInfo returns file information matching the glob pattern.
295- func (s * sandboxToolBackend ) GlobInfo (ctx context.Context , req * filesystem.GlobInfoRequest ) ([]filesystem.FileInfo , error ) {
295+ func (s * SandboxTool ) GlobInfo (ctx context.Context , req * filesystem.GlobInfoRequest ) ([]filesystem.FileInfo , error ) {
296296 path , _ := formatPath (req .Path , "/" , false )
297297 params := map [string ]any {
298298 "path_b64" : base64 .StdEncoding .EncodeToString ([]byte (path )),
@@ -330,7 +330,7 @@ func (s *sandboxToolBackend) GlobInfo(ctx context.Context, req *filesystem.GlobI
330330}
331331
332332// Write creates file content.
333- func (s * sandboxToolBackend ) Write (ctx context.Context , req * filesystem.WriteRequest ) error {
333+ func (s * SandboxTool ) Write (ctx context.Context , req * filesystem.WriteRequest ) error {
334334 path , err := formatPath (req .FilePath , "" , true )
335335 if err != nil {
336336 return err
@@ -358,7 +358,7 @@ func (s *sandboxToolBackend) Write(ctx context.Context, req *filesystem.WriteReq
358358}
359359
360360// Edit replaces string occurrences in a file.
361- func (s * sandboxToolBackend ) Edit (ctx context.Context , req * filesystem.EditRequest ) error {
361+ func (s * SandboxTool ) Edit (ctx context.Context , req * filesystem.EditRequest ) error {
362362 path , err := formatPath (req .FilePath , "" , true )
363363 if err != nil {
364364 return err
@@ -401,7 +401,7 @@ func (s *sandboxToolBackend) Edit(ctx context.Context, req *filesystem.EditReque
401401}
402402
403403// execute executes a command in the sandbox.
404- func (s * sandboxToolBackend ) execute (ctx context.Context , command string ) (text string , exitCode * int , err error ) {
404+ func (s * SandboxTool ) execute (ctx context.Context , command string ) (text string , exitCode * int , err error ) {
405405 var operationPayload string
406406 if s .executionTimeout <= 0 {
407407 operationPayload , err = sonic .MarshalString (map [string ]any {
@@ -473,7 +473,7 @@ func (s *sandboxToolBackend) execute(ctx context.Context, command string) (text
473473 return text , exitCode , nil
474474}
475475
476- func (s * sandboxToolBackend ) invokeTool (ctx context.Context , method string , body []byte ) ([]byte , error ) {
476+ func (s * SandboxTool ) invokeTool (ctx context.Context , method string , body []byte ) ([]byte , error ) {
477477 queries := make (url.Values )
478478 queries .Set ("Action" , "InvokeTool" )
479479 queries .Set ("Version" , "2025-10-30" )
@@ -506,7 +506,7 @@ func (s *sandboxToolBackend) invokeTool(ctx context.Context, method string, body
506506 return responseBody , nil
507507}
508508
509- func (s * sandboxToolBackend ) signRequest (request * http.Request , queries url.Values , body []byte ) {
509+ func (s * SandboxTool ) signRequest (request * http.Request , queries url.Values , body []byte ) {
510510 now := time .Now ()
511511 date := now .UTC ().Format ("20060102T150405Z" )
512512 authDate := date [:8 ]
@@ -558,7 +558,7 @@ func (s *sandboxToolBackend) signRequest(request *http.Request, queries url.Valu
558558 request .Header .Set ("Authorization" , authorization )
559559}
560560
561- func (s * sandboxToolBackend ) Execute (ctx context.Context , input * filesystem.ExecuteRequest ) (result * filesystem.ExecuteResponse , err error ) {
561+ func (s * SandboxTool ) Execute (ctx context.Context , input * filesystem.ExecuteRequest ) (result * filesystem.ExecuteResponse , err error ) {
562562 if input .Command == "" {
563563 return nil , fmt .Errorf ("command is required" )
564564 }
0 commit comments