import { invalidV3Input, unavailableV3Read, V3_UINT } from '../../_lib/http';
import { requireV3X402Release } from '../../x402/_lib/release';

export async function GET(
  _request: Request,
  context: { params: Promise<{ taskId: string }> | { taskId: string } },
): Promise<Response> {
  const closed = requireV3X402Release();
  if (closed) return closed;
  const { taskId } = await context.params;
  if (!V3_UINT.test(taskId)) return invalidV3Input('invalid_task_id', 'Task ID must be an unsigned decimal integer');
  return unavailableV3Read({
    route: '/api/v3/tasks/:taskId',
    resource: `/api/v3/tasks/${taskId}`,
    disposition: 'degraded',
    readiness: 'deferred',
    code: 'v3_task_escrow_deferred',
    message: 'TaskEscrowV3 is a canonical SDK read model but is disabled by the current pilot manifest',
  });
}
