const WORKSPACE_STATE_BUCKET_PRIORITY = {
    needs_input: 0,
    failed: 1,
    running: 2,
    attention: 3,
    done: 4,
};
export function deriveAgentStateBucket(input) {
    if ((input.pendingPermissionCount ?? 0) > 0 || input.attentionReason === "permission") {
        return "needs_input";
    }
    if (input.status === "error" || input.attentionReason === "error") {
        return "failed";
    }
    if (input.status === "running") {
        return "running";
    }
    if (input.requiresAttention) {
        return "attention";
    }
    return "done";
}
export function getWorkspaceStateBucketPriority(bucket) {
    return WORKSPACE_STATE_BUCKET_PRIORITY[bucket];
}
export function getAgentStatusPriority(input) {
    if ((input.pendingPermissionCount ?? 0) > 0 || input.attentionReason === "permission") {
        return 0;
    }
    if (input.status === "error" || input.attentionReason === "error") {
        return 1;
    }
    if (input.status === "running") {
        return 2;
    }
    if (input.status === "initializing") {
        return 3;
    }
    return 4;
}
//# sourceMappingURL=agent-state-bucket.js.map