Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

737 B
Raw Blame
const PROMPT_KEYS = ['prompt', 'description', 'task', 'instructions'] as const;

/** The task a subagent call was given, read from its arguments (JSON text or parsed). */
export function getSubagentPrompt(
  args: string | Record<string, unknown> | null | undefined,
): string | undefined {
  let parsed: unknown = args;
  if (typeof args === 'string') {
    try {
      parsed = JSON.parse(args);
    } catch {
      return undefined;
    }
  }
  if (parsed == null || typeof parsed !== 'object') {
    return undefined;
  }
  for (const key of PROMPT_KEYS) {
    const value = (parsed as Record<string, unknown>)[key];
    if (typeof value === 'string' && value.trim().length > 0) {
      return value;
    }
  }
  return undefined;
}