/**
 * ReasoningAgent Template — Tier 2 (LLM + Reflexion + Inner Monologue).
 *
 * Promoted from forge/src/agents/shared/templates/reasoning-agent.ts (Vague 1.B.7).
 *
 * For agents that need reasoning but not multi-agent debate or supervisor-worker:
 *   - CFO IA, Chief of Staff IA, Prospector, Lead Qualifier, Outreach Writer,
 *     Churn Predictor, Contract Generator.
 *
 * Pattern: observe → orient (LLM + Reflexion) → decide (LLM) →
 *          act → reflect (self-critique, optional) → feedback.
 *
 * Extended thinking (Anthropic): pass `thinkingBudget` to enable budget_tokens
 * in orient/decide phases via `deps.llm` with extended thinking support.
 *
 * Differences from Forge template:
 * - AgentDependencies removed — uses AgentFactoryDeps (SDK-native)
 * - buildSkills / createForgeAgent replaced by createAgentFromConfig (SDK)
 * - `thinkingBudget` is an SDK-native concept (Anthropic extended thinking)
 *   exposed via `ctx.deps.llm` metadata — no hardcoded model names here
 * - Forge-specific couplings (slackWebhookUrl, litellmUrl) removed
 *
 * @public @since 0.20.0
 */
import { createAgentFromConfig } from "../factory/agent-factory.js";
// ─── Factory ──────────────────────────────────────────────────────────────────
/**
 * Create a Tier 2 (reasoning, LLM-powered, Reflexion-capable) OODA agent.
 *
 * Boilerplate reduction vs. raw `createAgentFromConfig`:
 * - `agentRole` and `thinkingBudget` surfaced as first-class options
 * - Optional `reflect` phase wired correctly between act and feedback
 * - Phase `type` codes and `readOnly` flags set automatically
 * - HITL wiring handled when `hitlEscalationLevel` is set
 *
 * The `agentRole` and `thinkingBudget` values are accessible in every phase
 * via closure — pass them to `buildOrientPrompt` or `deps.llm.complete()` as
 * needed in your phase implementations.
 *
 * @example
 * ```ts
 * const agent = await createReasoningAgent<Obs, Orient, Decision, Action, Feedback>(deps, {
 *   agentId: "cfo-agent",
 *   intervalMs: 3_600_000,
 *   agentRole: "You are the CFO agent. Analyze financial data and provide recommendations.",
 *   thinkingBudget: 4096,
 *   observe: async () => ({ revenue: 10000, expenses: 8000 }),
 *   orient: async (obs, ctx) => {
 *     const { system, user } = buildOrientPrompt({
 *       systemPrompt: ctx.config.agentRole ?? "",
 *       userContext: JSON.stringify(obs),
 *     });
 *     const response = await ctx.deps.llm?.complete({ messages: [
 *       { role: "system", content: system },
 *       { role: "user", content: user },
 *     ]});
 *     return parseStructuredOutput(response?.content ?? "{}");
 *   },
 *   decide: async (orient) => ({ recommendation: orient.recommendation }),
 *   act: async (decision) => ({ executed: true, decision }),
 *   feedback: async (result) => ({ success: result.executed }),
 * });
 * await agent.start();
 * ```
 *
 * @public
 */
export async function createReasoningAgent(deps, opts) {
    return createAgentFromConfig(deps, {
        agentId: opts.agentId,
        agentVersion: opts.agentVersion ?? "0.1.0",
        intervalMs: opts.intervalMs,
        hitlEscalationLevel: opts.hitlEscalationLevel,
        sessionGuards: opts.sessionGuards,
        riskGuards: opts.riskGuards,
        outcomeMapping: opts.outcomeMapping,
        // Expose agentRole + thinkingBudget via config so phases can access them
        // via ctx.config (cast to ReasoningAgentConfig by the phase implementation)
        defaults: {
            agentRole: opts.agentRole,
            thinkingBudget: opts.thinkingBudget,
        },
        phases: {
            observe: {
                type: "observation",
                readOnly: true,
                fn: opts.observe,
            },
            orient: {
                type: "retrieval",
                readOnly: true,
                fn: opts.orient,
            },
            decide: {
                type: "decision",
                fn: opts.decide,
            },
            act: {
                type: "execution",
                hitlGate: opts.hitlEscalationLevel !== undefined,
                fn: opts.act,
            },
            ...(opts.reflect !== undefined
                ? {
                    reflect: {
                        type: "feedback",
                        readOnly: true,
                        fn: opts.reflect,
                    },
                }
                : {}),
            feedback: {
                type: "feedback",
                fn: opts.feedback,
            },
        },
    });
}
//# sourceMappingURL=reasoning-agent.js.map