import path from "node:path";
import { appendJsonl, createId, nowIso, readJsonl } from "../../shared/index.js";
import { teamRoot } from "./store.js";
export function teamLaunchLedgerPath(store, runId) {
    return path.join(teamRoot(store, runId), "launch-ledger.jsonl");
}
export function createTeamLaunchId() {
    return createId("team_launch");
}
export async function appendTeamLaunchLedgerEntry(store, runId, input) {
    const entry = {
        schema_version: 1,
        launch_id: input.launch_id ?? createTeamLaunchId(),
        timestamp: input.timestamp ?? nowIso(),
        run_id: input.run_id,
        team_id: input.team_id,
        role_id: input.role_id,
        role_label: input.role_label,
        capability_profile: input.capability_profile,
        status: input.status,
        target_agent: input.target_agent,
        opencode_agent: input.opencode_agent,
        parent_session_id: input.parent_session_id,
        child_session_id: input.child_session_id,
        background_id: input.background_id,
        agent_call_id: input.agent_call_id,
        prompt_ref: input.prompt_ref,
        prompt_preview: input.prompt_preview,
        stable_context_ref: input.stable_context_ref,
        stable_context_hash: input.stable_context_hash,
        context_refs: input.context_refs,
        allowed_tools: input.allowed_tools,
        denied_tools: input.denied_tools,
        read_paths: input.read_paths,
        write_paths: input.write_paths,
        lease_requirements: input.lease_requirements,
        write_surface: input.write_surface,
        native_tools: input.native_tools,
        model_route: input.model_route,
        model_attempts: input.model_attempts,
        error: input.error,
    };
    await appendJsonl(teamLaunchLedgerPath(store, runId), entry);
    return entry;
}
export async function readTeamLaunchLedger(store, runId) {
    return readJsonl(teamLaunchLedgerPath(store, runId));
}
//# sourceMappingURL=launch-ledger.js.map