@@ -281,6 +281,25 @@ func populateMessageParams(ctx Context, completion *types.CompletionRequest, too
281
281
return nil
282
282
}
283
283
284
+ func (e * Engine ) runCommandTools (ctx Context , tool types.Tool , input string ) (* Return , error ) {
285
+ if tool .IsHTTP () {
286
+ return e .runHTTP (ctx .Ctx , ctx .Program , tool , input )
287
+ } else if tool .IsDaemon () {
288
+ return e .runDaemon (ctx .Ctx , ctx .Program , tool , input )
289
+ } else if tool .IsOpenAPI () {
290
+ return e .runOpenAPI (tool , input )
291
+ } else if tool .IsEcho () {
292
+ return e .runEcho (tool )
293
+ }
294
+ s , err := e .runCommand (ctx , tool , input , ctx .ToolCategory )
295
+ if err != nil {
296
+ return nil , err
297
+ }
298
+ return & Return {
299
+ Result : & s ,
300
+ }, nil
301
+ }
302
+
284
303
func (e * Engine ) Start (ctx Context , input string ) (ret * Return , _ error ) {
285
304
tool := ctx .Tool
286
305
@@ -291,22 +310,7 @@ func (e *Engine) Start(ctx Context, input string) (ret *Return, _ error) {
291
310
}()
292
311
293
312
if tool .IsCommand () {
294
- if tool .IsHTTP () {
295
- return e .runHTTP (ctx .Ctx , ctx .Program , tool , input )
296
- } else if tool .IsDaemon () {
297
- return e .runDaemon (ctx .Ctx , ctx .Program , tool , input )
298
- } else if tool .IsOpenAPI () {
299
- return e .runOpenAPI (tool , input )
300
- } else if tool .IsEcho () {
301
- return e .runEcho (tool )
302
- }
303
- s , err := e .runCommand (ctx , tool , input , ctx .ToolCategory )
304
- if err != nil {
305
- return nil , err
306
- }
307
- return & Return {
308
- Result : & s ,
309
- }, nil
313
+ return e .runCommandTools (ctx , tool , input )
310
314
}
311
315
312
316
if ctx .ToolCategory == CredentialToolCategory {
@@ -431,6 +435,14 @@ func (e *Engine) complete(ctx context.Context, state *State) (*Return, error) {
431
435
}
432
436
433
437
func (e * Engine ) Continue (ctx Context , state * State , results ... CallResult ) (* Return , error ) {
438
+ if ctx .Tool .IsCommand () {
439
+ var input string
440
+ if len (results ) == 1 {
441
+ input = results [0 ].User
442
+ }
443
+ return e .runCommandTools (ctx , ctx .Tool , input )
444
+ }
445
+
434
446
if state == nil {
435
447
return nil , fmt .Errorf ("invalid continue call, missing state" )
436
448
}
0 commit comments