| 363 | } |
| 364 | |
| 365 | func NewSendMessageTool() coretools.Tool { |
| 366 | return newTaskTool("SendMessage", "Send a new prompt to an existing reusable worker. This only succeeds when the target worker is idle and ready for more work.", SendMessageInput{}, func(_ context.Context, execCtx coretools.ExecutionContext, input any) (string, error) { |
| 367 | rt, scope, err := runtimeAndScope(execCtx) |
| 368 | if err != "" { |
| 369 | return err, nil |
| 370 | } |
| 371 | in := derefSendMessage(input) |
| 372 | result := rt.SendMessage(in.TaskID, scope, in.Prompt) |
| 373 | if text, ok := result.(string); ok { |
| 374 | return text, nil |
| 375 | } |
| 376 | return jsonString(serializeTaskResult(result)), nil |
| 377 | }) |
| 378 | } |
| 379 | |
| 380 | func newTaskTool(name, description string, proto any, exec func(context.Context, coretools.ExecutionContext, any) (string, error)) coretools.Tool { |
| 381 | return &taskTool{ |