addSection

View as MarkdownOpen in Claude

Add a new top-level Section to the PromptObjectModel and return it.

Only the first section may be titleless. Adding a section with no title after the first one throws Error("Only the first section can have no title").

Parameters

title
string | nullDefaults to null

Section heading. Pass null only for the first section.

opts
object

Optional section content.

opts.body
string

Section body text.

opts.bullets
string[] | string | null

Bullet points for this section. A single string is coerced into a one-item list.

opts.numbered
boolean | null

Whether to number this section in the rendered output.

opts.numberedBullets
boolean

Whether to render bullets as a numbered list instead of using bullet markers.

Returns

Section — The newly created section.

Example

1import { PromptObjectModel } from '@signalwire/sdk';
2
3const pom = new PromptObjectModel();
4const section = pom.addSection('Rules', { bullets: ['Be concise', 'Be accurate'] });
5section.addBody('Follow these guidelines.');