/** * PomBuilder - Prompt Object Model for structured prompt sections. * * Built-in replacement for the external signalwire-pom package. * Sections have a title, body, bullets (optionally numbered), * and nested subsections. */ import { PromptObjectModel } from './POM/PromptObjectModel.js'; /** Serializable representation of a POM section, used for JSON export. */ export interface PomSectionData { /** Section heading text. */ title?: string; /** Section body paragraph text. */ body?: string; /** List of bullet point strings. */ bullets?: string[]; /** Whether subsections are numbered. */ numbered?: boolean; /** Whether bullet points are rendered as a numbered list. */ numberedBullets?: boolean; /** Nested child sections. */ subsections?: PomSectionData[]; } /** A single section in a Prompt Object Model, with optional title, body, bullets, and nested subsections. */ export declare class PomSection { /** Section heading text, or null if untitled. */ title: string | null; /** Section body paragraph text. */ body: string; /** List of bullet point strings. */ bullets: string[]; /** Nested child sections. */ subsections: PomSection[]; /** Whether this section is numbered when rendered; null means inherit from parent context. */ numbered: boolean | null; /** Whether bullet points are rendered as a numbered list. */ numberedBullets: boolean; /** * Creates a new PomSection. * @param opts - Optional section configuration. */ constructor(opts?: { title?: string | null; body?: string; bullets?: string[]; numbered?: boolean | null; numberedBullets?: boolean; }); /** * Adds a nested subsection to this section. * @param opts - Subsection configuration including title and optional body/bullets. * @returns The newly created child PomSection. */ addSubsection(opts: { title: string; body?: string; bullets?: string[]; numbered?: boolean; numberedBullets?: boolean; }): PomSection; /** * Serializes this section to a plain data object. * @returns A PomSectionData representation of this section and its subsections. */ toDict(): PomSectionData; /** * Renders this section and its subsections as a Markdown string. * @param level - The heading level to start at (default 2 for ##). * @param sectionNumber - Hierarchical numbering prefix for numbered sections. * @returns The rendered Markdown string. */ renderMarkdown(level?: number, sectionNumber?: number[]): string; /** * Renders this section and its subsections as an XML string. * @param indent - The indentation depth (default 0). * @param sectionNumber - Hierarchical numbering prefix for numbered sections. * @returns The rendered XML string. */ renderXml(indent?: number, sectionNumber?: number[]): string; } /** * Builds a structured prompt by composing named POM sections, with Markdown and dict export. * * The Prompt Object Model lets you assemble a large system prompt from reusable, * named sections (Role, Objective, Constraints, etc.) instead of a single string. * This plays well with {@link AgentBase} methods like `promptAddSection()` and * `promptAddToSection()` that let user code and skills add prompt content * incrementally. * * @example Build a structured prompt * ```ts * import { PomBuilder } from '@signalwire/sdk'; * * const pom = new PomBuilder() * .addSection('Role', { body: 'You are a friendly customer service agent.' }) * .addSection('Objectives', { bullets: [ * 'Identify the customer politely', * 'Resolve their issue in under 3 turns if possible', * ]}) * .addSection('Constraints', { bullets: [ * 'Never reveal internal tool names', * ]}); * * const systemPrompt = pom.renderMarkdown(); * ``` * * @see {@link PomSection} * @see {@link AgentBase.promptAddSection} */ export declare class PomBuilder { private sections; private sectionMap; /** * Clears all sections, returning the builder to its initial empty state. * @returns This builder for chaining. */ reset(): this; /** * Adds a new top-level section to the prompt. * @param title - The section heading. * @param opts - Optional body, bullets, numbering, and subsection configuration. * @returns This builder for chaining. */ addSection(title: string, opts?: { body?: string; bullets?: string[]; numbered?: boolean; numberedBullets?: boolean; subsections?: { title: string; body?: string; bullets?: string[]; }[]; }): this; /** * Appends body text or bullets to an existing section, creating it if absent. * @param title - The section heading to append to. * @param opts - Body text and/or bullets to add. * @returns This builder for chaining. */ addToSection(title: string, opts?: { body?: string; bullet?: string; bullets?: string[]; }): this; /** * Adds a subsection under an existing parent section, creating the parent if absent. * @param parentTitle - The heading of the parent section. * @param title - The subsection heading. * @param opts - Optional body text and bullets for the subsection. * @returns This builder for chaining. */ addSubsection(parentTitle: string, title: string, opts?: { body?: string; bullets?: string[]; }): this; /** * Checks whether a top-level section with the given title exists. * @param title - The section heading to look for. * @returns True if the section exists. */ hasSection(title: string): boolean; /** * Returns a top-level section by title. * @param title - The section heading to retrieve. * @returns The matching PomSection, or undefined if not found. */ getSection(title: string): PomSection | undefined; /** * Recursively searches all sections and subsections for one matching the given title. * @param title - The section heading to search for. * @returns The matching PomSection, or undefined if not found. */ findSection(title: string): PomSection | undefined; /** * Appends every top-level section of another PomBuilder as subsections of a target section. * @param target - The heading of the target section, or the PomSection to append into. * @param pomToAdd - The PomBuilder whose sections should be appended as subsections. * @returns This builder for chaining. * @throws {Error} If target is a string and no section with that title is found. */ addPomAsSubsection(target: string | PomSection, pomToAdd: PomBuilder): this; /** * Serializes all sections to an array of plain data objects. * @returns An array of PomSectionData representing all top-level sections. */ toDict(): PomSectionData[]; /** * Serializes all sections to a JSON string. * @returns A JSON string representation of all top-level sections. */ toJson(): string; /** * Creates a PomBuilder from an array of section data objects. * @param sections - Array of section data to reconstruct. * @returns A new PomBuilder populated with the given sections. */ static fromSections(sections: PomSectionData[]): PomBuilder; /** * Returns the underlying {@link PromptObjectModel} for the builder. * * Mirrors Python's `PomBuilder.pom` attribute (the wrapped low-level model). * Returns a fresh `PromptObjectModel` populated from the builder's current * sections; mutations on the returned instance do not propagate back to * this builder. */ get pom(): PromptObjectModel; /** * Renders all sections as a combined Markdown string. * @returns The complete rendered Markdown prompt text. */ renderMarkdown(): string; /** * Renders all sections as a combined XML string with a `` root element. * @returns The complete rendered XML prompt text. */ renderXml(): string; }