/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */ import type { Phase, WorkItem, WorkItemCostSource, WorkItemUsage, Workstream } from '../../../orchestration/types.js'; import type { ProcessCostState, ProcessNode, ProcessUsage } from '../types.js'; import { workItemNodeId } from './agent.js'; /** * Live in-flight usage of a work-item's currently-active agent, read from that * agent's fleet node at snapshot time. Overlaid onto the * item's phase-boundary-committed `item.usage` so a RUNNING phase shows real, * growing numbers instead of n/a until it completes. */ export interface LiveItemUsage { readonly usage?: ProcessUsage | undefined; readonly costUsd?: number | null | undefined; readonly costState?: ProcessCostState | undefined; readonly costSource?: WorkItemCostSource | undefined; readonly pricingAsOf?: string | undefined; } /** * The usage the fleet DISPLAYS for a work-item: its committed phase-boundary * total, plus, only while it is actively 'in-phase', the live in-flight * usage of its current agent. The overlay is applied ONLY for an 'in-phase' * item, which is exactly the window in which `item.usage` does NOT yet include * the running phase (the engine folds that in at completion, see * runItemPhase), so committed + live never double-counts and the two hand off * atomically at the phase boundary. Because both operands only ever grow and * merge through {@link mergeWorkItemUsage}, presence is MONOTONE: once usage * has appeared for an item it never blinks back to n/a. */ export declare function displayWorkItemUsage(item: WorkItem, live: LiveItemUsage | undefined): WorkItemUsage; /** * Resolve each item's active-agent in-flight usage ONCE, keyed by item id, so * the workstream rollup and the per-item nodes share one overlay resolution. * displayWorkItemUsage applies the overlay only while an item is 'in-phase', * so this never double-counts committed usage. Cost provenance travels with * the live cost, the dollars and their source are copied together. */ export declare function collectLiveItemUsage(workstream: Workstream, agentNodeById: ReadonlyMap): Map; /** Workstream node ids are namespaced to avoid colliding with agent/process ids. */ export declare function workstreamNodeId(workstreamId: string): string; /** * Phase node ids are namespaced by their owning workstream, phase ids are * only unique WITHIN a workstream, so two workstreams' phases must not * collide in the flat node list. */ export declare function phaseNodeId(workstreamId: string, phaseId: string): string; export { workItemNodeId }; /** The work-item's currently-active agent, i.e. the one driving its live phase run. Undefined once terminal or between phases. */ export declare function activeWorkItemAgentId(item: WorkItem): string | undefined; /** * The best-of-N groups in this workstream that are READY for the winner pick: * every sibling settled (held-merge or failed) and at least one held * candidate. Pure over the items, the same readiness the attempts * coordinator computes, derived here so the snapshot needs no engine access. */ export declare function readyAttemptGroupIds(workstream: Workstream): ReadonlySet; /** * WorkItem -> ProcessNode. Delegates interruptible/killable/steerable to its * currently-active agent, mirroring adaptSubtask. `opts.live` supplies the * currently-active agent's in-flight usage so a running phase shows real, * growing numbers instead of n/a until it completes; omit it * (or pass undefined) for the committed-only view. */ export declare function adaptWorkItem(item: WorkItem, workstreamId: string, parentId: string, opts: { steerable: boolean; live?: LiveItemUsage | undefined; readyGroups?: ReadonlySet | undefined; }): ProcessNode; /** * Phase -> ProcessNode. Deliberately reports NO usage/cost (mirrors * adaptSubtask's "report nothing" choice): a work-item's usage is cumulative * across every phase it has visited, so attributing it to whichever phase it * currently occupies would double-count against both the phase and the * workstream total. Real numbers live on the workstream (sums every item * exactly once) and the work-item (its own direct total), never on phase. */ export declare function adaptPhase(phase: Phase, workstream: Workstream): ProcessNode; /** * Workstream -> ProcessNode. Root node (no parentId). Sums every item's DISPLAY * usage/cost (committed total + any live in-flight overlay, resolved once per * item) exactly once, never through an intermediate phase bucket (see * adaptPhase), so this total can never double-count and never shows n/a while * an item is actively producing usage. `liveByItemId` supplies * the active agents' in-flight usage keyed by item id; omit it for the * committed-only view. */ export declare function adaptWorkstream(workstream: Workstream, now: number, liveByItemId?: ReadonlyMap): ProcessNode; //# sourceMappingURL=orchestration.d.ts.map