{"version":3,"file":"persona.mjs","names":[],"sources":["../../../../../../../ai/src/system-prompt/persona.ts"],"sourcesContent":["import type { Placeholders } from \"../contracts/placeholders.type\";\nimport type { PersonaContract } from \"../contracts/system-prompt.contract\";\nimport { renderPlaceholders } from \"./render-placeholders\";\n\n/**\n * Concrete `PersonaContract` — a reusable \"who the agent is\" block.\n *\n * **Role.** A single addressable prompt block representing the agent's\n * identity (`\"You are Alex, a senior TypeScript engineer.\"`). Exists as\n * its own type so personas can be defined once and reused across many\n * `SystemPrompt` compositions, agents, and sessions — each render can\n * supply a different placeholder map.\n *\n * **Responsibility.**\n * - Owns: the `type: \"persona\"` discriminator, the raw template text, and\n *   the placeholder-rendering step.\n * - Does NOT own: composition with instructions, ordering, joining, or\n *   any knowledge of the surrounding `SystemPrompt`. Those concerns live\n *   in `SystemPrompt`.\n *\n * Users construct via the `ai.persona()` factory — `new Persona()` is not\n * the public API (see §4.2 of code-style.md).\n *\n * @example\n * const alex = ai.persona(\"You are Alex, a TypeScript expert.\");\n *\n * const prompt = ai.systemPrompt()\n *   .persona(alex)\n *   .instruction(\"Always cite sources.\");\n */\nexport class Persona implements PersonaContract {\n  public readonly type = \"persona\" as const;\n\n  public constructor(public readonly text: string) {\n    //\n  }\n\n  /**\n   * Substitute `{{mustache}}` placeholders in the persona text against the\n   * supplied map. Delegates to the shared `renderPlaceholders` helper so\n   * persona / instruction / system-prompt rendering stays identical.\n   */\n  public resolve(placeholders?: Placeholders): string {\n    return renderPlaceholders(this.text, placeholders);\n  }\n}\n\n/**\n * Create a `Persona` from raw template text.\n *\n * @example\n * const alex = persona(\"You are Alex, a TypeScript expert.\");\n * const greeter = persona(\"You are a greeter in {{language|English}}.\");\n */\nexport function persona(text: string): Persona {\n  return new Persona(text);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,UAAb,MAAgD;CAG9C,AAAO,YAAY,AAAgB,MAAc;EAAd;cAFZ;CAIvB;;;;;;CAOA,AAAO,QAAQ,cAAqC;EAClD,OAAO,mBAAmB,KAAK,MAAM,YAAY;CACnD;AACF;;;;;;;;AASA,SAAgB,QAAQ,MAAuB;CAC7C,OAAO,IAAI,QAAQ,IAAI;AACzB"}