addPomAsSubsection

View as MarkdownOpen in Claude

Append every top-level section of another PromptObjectModel as a subsection of a target section in this model. 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 Section directly.

Parameters

target
string | SectionRequired

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

pomToAdd
PromptObjectModelRequired

The model whose top-level sections should be appended.

Returns

void

Example

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