addPomAsSubsection

View as MarkdownOpen in Claude

Append every top-level section of another PomBuilder as a subsection of a target section in this builder. Useful for composing prompts assembled separately into a single document.

Throws Error("No section with title '<target>' found.") when target is a string and no section with that title exists. For deeper lookups, resolve the section yourself via findSection() and pass the PomSection directly.

Parameters

target
string | PomSectionRequired

The target section to append into. Pass a title string for top-level sections, or a PomSection instance (from findSection()) for nested sections.

pomToAdd
PomBuilderRequired

The builder whose sections should be appended.

Returns

this — returns the builder for fluent chaining.

Example

1import { PomBuilder } from '@signalwire/sdk';
2
3const subPom = new PomBuilder();
4subPom.addSection('Policy A', { body: 'Always greet by name.' });
5subPom.addSection('Policy B', { body: 'Escalate billing issues.' });
6
7const main = new PomBuilder();
8main.addSection('Introduction', { body: 'You are a helpful agent.' });
9main.addSection('Policies');
10
11main.addPomAsSubsection('Policies', subPom);
12console.log(main.renderMarkdown());