import { sanitizeText } from "../../shared/index.js";
import { LAB_REPRESENTATIVE_AGENT } from "../../agents/identity.js";
export function findTeamMemberBySession(runtime, sessionId) {
    if (!runtime || !sessionId)
        return undefined;
    return runtime.members.find((member) => member.session_id === sessionId);
}
export function renderTeamMemberContract(runId, runtime, member) {
    const mission = sanitizeText(member.mission_prompt ?? `${member.role_label ?? member.name}: continue your assigned SEED team role.`);
    return `<system-reminder>
[SEED member contract]
Run: ${runId}
Team: ${runtime.team_name ?? runtime.team_id ?? "(dynamic team)"}
Team ID: ${runtime.team_id ?? "(none)"}
Role ID: ${member.name}
Role label: ${member.role_label ?? member.name}
Capability profile: ${member.capability_profile ?? "unspecified"}
OpenCode agent: ${member.opencode_agent ?? member.resolved_agent ?? LAB_REPRESENTATIVE_AGENT}
Mission: ${mission.slice(0, 900)}
Allowed tools: ${formatList(member.tool_policy?.allowed_tools)}
Denied tools: ${formatList(member.tool_policy?.denied_tools)}
MCP policy: allowed=${formatList(member.mcp_policy?.allowed_mcps)} denied=${formatList(member.mcp_policy?.denied_mcps)}
Skill policy: allowed=${formatList(member.skill_policy?.allowed_skills)} denied=${formatList(member.skill_policy?.denied_skills)} user_skills=${member.skill_policy?.allow_user_skills === true ? "allowed" : "blocked"}
Spawn policy: allowed=${member.spawn_policy?.allowed === true ? "yes" : "no"} max_depth=${member.spawn_policy?.max_depth ?? 0} lab_approval=${member.spawn_policy?.requires_lab_representative_approval === false ? "no" : "yes"}
Write surface: ${member.write_surface ?? "read_only_or_coordination_only"}
Read paths: ${formatList(member.read_paths)}
Write paths: ${formatList(member.write_paths)}
Evidence contract: refs=${formatList(member.evidence_contract?.required_refs)} artifacts=${formatList(member.evidence_contract?.required_artifacts)} oracle=${formatList(member.evidence_contract?.oracle_scope)}
Stop condition: ${sanitizeText(member.stop_condition ?? "Report output with evidence or a blocker.").slice(0, 500)}
Report target: ${member.delivery_policy?.report_to ?? "Lab-Representative"}

You are an agent-thread, not a temporary helper. Your thread id is your role id. Stay inside this role contract. Use OpenCode native tools for permitted file/shell execution, and durable SEED tools for team state, evidence, workspace leases, workspace diff refs, meetings, message-bus coordination, and mailbox coordination. Use seed_agent_thread_status and seed_team_roster to discover current teammates, thread state, tool manifests, and roles. Use seed_team_send for peer-to-peer messages; the runtime infers your durable role from this session and logs explicit from/to entries in messages/envelopes.json, messages/delivery.jsonl, and team/conversation.jsonl. Use seed_agent_thread_trace or seed_team_conversation when you need the audit trail of member launches, prompts, deliveries, helper calls, and peer messages. Use seed_team_meeting_create/post/close for multi-member alignment, but treat meetings as Lab-Representative-governed team state, not private side chat. Use helper child sessions only when your spawn policy permits and the work benefits from parallel evidence gathering, implementation, or verification. Helper outputs must be summarized back into your thread memory and reported to your parent thread. Before writing, confirm your lease and sub-plan assignment; after native writes, report changed paths through seed_workspace_diff_record. If you need another member, task, meeting, or delegation and your spawn policy does not explicitly allow direct spawning, use seed_team_member_request instead of calling delegation tools yourself.
</system-reminder>`;
}
function formatList(values) {
    return values?.length ? values.join(", ") : "none";
}
//# sourceMappingURL=contract.js.map