Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

V2LifecycleRow.logic.ts

21 lines771 Bytes

1import type { OrchestrationV2Subagent } from "@t3tools/contracts";
2import * as DateTime from "effect/DateTime";
3​
4const ACTIVE_SUBAGENT_STATUSES = new Set<OrchestrationV2Subagent["status"]>([
5 "pending",
6 "running",
7 "waiting",
8]);
9​
10/** Claude can reuse resumed agent ids. Active agents supersede outcomes; settled agents must start after notification. */
11export function subagentResumedSince(
12 agent: Pick<OrchestrationV2Subagent, "status" | "startedAt">,
13 notifiedAt: string,
14): boolean {
15 if (ACTIVE_SUBAGENT_STATUSES.has(agent.status)) return true;
16 if (agent.startedAt === null) return false;
17 const notifiedAtMillis = Date.parse(notifiedAt);
18 return (
19 !Number.isNaN(notifiedAtMillis) && DateTime.toEpochMillis(agent.startedAt) > notifiedAtMillis
20 );