( ctx context.Context, scope toolspkg.Scope, req toolspkg.CallRequest, )
| 3344 | } |
| 3345 | |
| 3346 | func (n *daemonNativeTools) autonomyClaimNext( |
| 3347 | ctx context.Context, |
| 3348 | scope toolspkg.Scope, |
| 3349 | req toolspkg.CallRequest, |
| 3350 | ) (toolspkg.ToolResult, error) { |
| 3351 | var input autonomyClaimNextInput |
| 3352 | if err := decodeNativeInput(req, &input); err != nil { |
| 3353 | return toolspkg.ToolResult{}, err |
| 3354 | } |
| 3355 | actor, sessionID, err := autonomyActorContext(req.ToolID, scope) |
| 3356 | if err != nil { |
| 3357 | return toolspkg.ToolResult{}, err |
| 3358 | } |
| 3359 | criteria, err := input.criteria(scope, sessionID) |
| 3360 | if err != nil { |
| 3361 | return toolspkg.ToolResult{}, nativeAutonomyToolError(req.ToolID, err) |
| 3362 | } |
| 3363 | result, err := n.deps.Tasks.ClaimNextRun(ctx, criteria, actor) |
| 3364 | if err != nil { |
| 3365 | if errors.Is(err, taskpkg.ErrNoClaimableRun) { |
| 3366 | return structuredResult(map[string]any{nativeToolsClaimedKey: false}, "no claimable task runs") |
| 3367 | } |
| 3368 | return toolspkg.ToolResult{}, nativeAutonomyToolError(req.ToolID, err) |
| 3369 | } |
| 3370 | if result == nil { |
| 3371 | return toolspkg.ToolResult{}, errors.New("daemon: task-run claim returned an empty result") |
| 3372 | } |
| 3373 | payload := core.AgentTaskClaimPayloadFromResult(result) |
| 3374 | return structuredResult( |
| 3375 | map[string]any{nativeToolsClaimedKey: true, "claim": payload}, |
| 3376 | fmt.Sprintf("claimed %s", payload.Lease.RunID), |
| 3377 | ) |
| 3378 | } |
| 3379 | |
| 3380 | func (n *daemonNativeTools) autonomyHeartbeat( |
| 3381 | ctx context.Context, |
nothing calls this directly
no test coverage detected