import type { WorkerId } from '@platform-modules/chatgpt-orchestrator-protocol';

export const RESUME_PROMPT_VERSION = 1 as const;

export type ResumeReason = 'auto_resume' | 'manual_resume' | 'recovery';

export interface WorkerResumePromptInput {
  workerId: WorkerId;
  reason: ResumeReason;
  sequence?: number;
}

export function workerResumePrompt(input: WorkerResumePromptInput): string {
  const attempt = input.sequence === undefined ? '' : `\nExecution attempt: ${input.sequence} (${input.reason})`;
  return `Continue the current orchestrated worker assignment.

Worker: ${input.workerId}${attempt}

Recover authoritative state using the ChatGPT Orchestrator MCP before acting. Do not redo completed work. Inspect durable repository/worktree/progress state as needed. Continue until the assignment acceptance criteria are satisfied.

Before ending, use the explicit worker lifecycle operation that matches reality: worker.complete when fully finished, worker.fail for irrecoverable failure, worker.await_human only for genuine human input, or worker.await_dependency only for an external dependency. Otherwise leave the worker active. End the response with the required continuation-state output contract.`;
}
