





















@@ -10,7 +10,6 @@ import { getRegisteredDetachedTaskLifecycleRuntime } from "./detached-task-runti
1010import {
1111cancelTaskById,
1212createTaskRecord,
13-findLatestTaskForFlowId,
1413getTaskById,
1514isParentFlowLinkError,
1615linkTaskToFlowById,
@@ -216,141 +215,6 @@ export function setDetachedTaskDeliveryStatusByRunId(params: {
216215return setTaskRunDeliveryStatusByRunId(params);
217216}
218217219-type RetryBlockedFlowResult = {
220-found: boolean;
221-retried: boolean;
222-reason?: string;
223-previousTask?: TaskRecord;
224-task?: TaskRecord;
225-};
226-227-type RetryBlockedFlowParams = {
228-flowId: string;
229-sourceId?: string;
230-requesterOrigin?: TaskDeliveryState["requesterOrigin"];
231-childSessionKey?: string;
232-agentId?: string;
233-runId?: string;
234-label?: string;
235-task?: string;
236-preferMetadata?: boolean;
237-notifyPolicy?: TaskNotifyPolicy;
238-deliveryStatus?: TaskDeliveryStatus;
239-status: "queued" | "running";
240-startedAt?: number;
241-lastEventAt?: number;
242-progressSummary?: string | null;
243-};
244-245-function resolveRetryableBlockedFlowTask(flowId: string): {
246-flowFound: boolean;
247-retryable: boolean;
248-latestTask?: TaskRecord;
249-reason?: string;
250-} {
251-const flow = getTaskFlowById(flowId);
252-if (!flow) {
253-return {
254-flowFound: false,
255-retryable: false,
256-reason: "Flow not found.",
257-};
258-}
259-const latestTask = findLatestTaskForFlowId(flowId);
260-if (!latestTask) {
261-return {
262-flowFound: true,
263-retryable: false,
264-reason: "Flow has no retryable task.",
265-};
266-}
267-if (flow.status !== "blocked") {
268-return {
269-flowFound: true,
270-retryable: false,
271- latestTask,
272-reason: "Flow is not blocked.",
273-};
274-}
275-if (latestTask.status !== "succeeded" || latestTask.terminalOutcome !== "blocked") {
276-return {
277-flowFound: true,
278-retryable: false,
279- latestTask,
280-reason: "Latest TaskFlow task is not blocked.",
281-};
282-}
283-return {
284-flowFound: true,
285-retryable: true,
286- latestTask,
287-};
288-}
289-290-function retryBlockedFlowTask(params: RetryBlockedFlowParams): RetryBlockedFlowResult {
291-const resolved = resolveRetryableBlockedFlowTask(params.flowId);
292-if (!resolved.retryable || !resolved.latestTask) {
293-return {
294-found: resolved.flowFound,
295-retried: false,
296-reason: resolved.reason,
297-};
298-}
299-const flow = getTaskFlowById(params.flowId);
300-if (!flow) {
301-return {
302-found: false,
303-retried: false,
304-reason: "Flow not found.",
305-previousTask: resolved.latestTask,
306-};
307-}
308-const task = createTaskRecord({
309-runtime: resolved.latestTask.runtime,
310-sourceId: params.sourceId ?? resolved.latestTask.sourceId,
311-ownerKey: flow.ownerKey,
312-scopeKind: "session",
313-requesterOrigin: params.requesterOrigin ?? flow.requesterOrigin,
314-parentFlowId: flow.flowId,
315-childSessionKey: params.childSessionKey,
316-parentTaskId: resolved.latestTask.taskId,
317-agentId: params.agentId ?? resolved.latestTask.agentId,
318-runId: params.runId,
319-label: params.label ?? resolved.latestTask.label,
320-task: params.task ?? resolved.latestTask.task,
321-preferMetadata: params.preferMetadata,
322-notifyPolicy: params.notifyPolicy ?? resolved.latestTask.notifyPolicy,
323-deliveryStatus: params.deliveryStatus ?? "pending",
324-status: params.status,
325-startedAt: params.startedAt,
326-lastEventAt: params.lastEventAt,
327-progressSummary: params.progressSummary,
328-});
329-if (!task) {
330-return {
331-found: true,
332-retried: false,
333-reason: "Task persistence failed.",
334-previousTask: resolved.latestTask,
335-};
336-}
337-return {
338-found: true,
339-retried: true,
340-previousTask: resolved.latestTask,
341- task,
342-};
343-}
344-345-export function retryBlockedFlowAsQueuedTaskRun(
346-params: Omit<RetryBlockedFlowParams, "status" | "startedAt" | "lastEventAt" | "progressSummary">,
347-): RetryBlockedFlowResult {
348-return retryBlockedFlowTask({
349- ...params,
350-status: "queued",
351-});
352-}
353-354218type CancelFlowResult = {
355219found: boolean;
356220cancelled: boolean;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。