( ctx context.Context, scope toolspkg.Scope, req toolspkg.CallRequest, )
| 3137 | } |
| 3138 | |
| 3139 | func (n *daemonNativeTools) taskFanOutRuns( |
| 3140 | ctx context.Context, |
| 3141 | scope toolspkg.Scope, |
| 3142 | req toolspkg.CallRequest, |
| 3143 | ) (toolspkg.ToolResult, error) { |
| 3144 | var input taskFanOutRunsInput |
| 3145 | if err := decodeNativeInput(req, &input); err != nil { |
| 3146 | return toolspkg.ToolResult{}, err |
| 3147 | } |
| 3148 | if n.deps.NetworkStore == nil { |
| 3149 | return toolspkg.ToolResult{}, nativeUnavailableError(req.ToolID, "network store is unavailable") |
| 3150 | } |
| 3151 | taskID, err := requiredNativeString(req.ToolID, "task_id", input.TaskID) |
| 3152 | if err != nil { |
| 3153 | return toolspkg.ToolResult{}, err |
| 3154 | } |
| 3155 | maxDesignations := n.deps.Config.Task.Orchestration.DesignatedRunMax |
| 3156 | if maxDesignations <= 0 { |
| 3157 | maxDesignations = aghconfig.DefaultTaskDesignatedRunMax |
| 3158 | } |
| 3159 | if len(input.Designations) == 0 { |
| 3160 | return toolspkg.ToolResult{}, nativeRequiredInputError(req.ToolID, "designations") |
| 3161 | } |
| 3162 | prepared, err := prepareNativeFanOutDesignations(input, maxDesignations) |
| 3163 | if err != nil { |
| 3164 | return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err) |
| 3165 | } |
| 3166 | actor, err := actorContextFromScope(scope) |
| 3167 | if err != nil { |
| 3168 | return toolspkg.ToolResult{}, err |
| 3169 | } |
| 3170 | groupID := store.NewID("tdg") |
| 3171 | runs := make([]taskpkg.Run, 0, len(input.Designations)) |
| 3172 | for index := range input.Designations { |
| 3173 | run, enqueueErr := n.deps.Tasks.EnqueueRun(ctx, taskpkg.EnqueueRun{ |
| 3174 | TaskID: taskID, |
| 3175 | IdempotencyKey: prepared[index].idempotencyKey, |
| 3176 | NetworkChannel: strings.TrimSpace(input.NetworkChannel), |
| 3177 | DesignationGroupID: groupID, |
| 3178 | Metadata: prepared[index].metadata, |
| 3179 | }, actor) |
| 3180 | if enqueueErr != nil { |
| 3181 | return toolspkg.ToolResult{}, enqueueErr |
| 3182 | } |
| 3183 | runs = append(runs, *run) |
| 3184 | } |
| 3185 | if err := n.deps.NetworkStore.PutTaskDesignationRollup(ctx, store.TaskDesignationRollup{ |
| 3186 | DesignationGroupID: groupID, |
| 3187 | TaskID: taskID, |
| 3188 | SummaryJSON: nativeFanOutDesignationRollupJSON(runs), |
| 3189 | CreatedAt: time.Now().UTC(), |
| 3190 | }); err != nil { |
| 3191 | return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err) |
| 3192 | } |
| 3193 | return structuredResult( |
| 3194 | map[string]any{"designation_group_id": groupID, nativeToolsRunsKey: runs}, |
| 3195 | fmt.Sprintf("%d runs", len(runs)), |
| 3196 | ) |
nothing calls this directly
no test coverage detected