Composition / foldkit-composition
Agents
An agent edits a page through the same path a person does: it sends the
Builder's own Applied Message, so its edit is checked, undoable, autosaved and
revisioned like any other. Composition.operationSchema(Site) is the tool's
input, generated from the Catalog:
ts
Agent.expose(Message, {
GotEditorMessage: Agent.variant({
name: 'edit_page',
description: 'Insert, move, remove or configure blocks on the page',
input: Composition.operationSchema(Site),
toMessage: op => ({ message: PageForm.control('document').send(BuilderMessage.Applied({ op })) }),
}),
})- An insert names one of the Catalog's Blocks, as a literal, with that Block's
props as they are stored, so a Block outside the Catalog is refused by the
tool's own input schema before
applysees it.applychecks the rest. - Each insert carries its Block's description, when it has one
(
Block.words), so the tool's schema says what each Block is for. - The agent mints the ids of what it adds (
composition:id-takenfor one in use), and reads the page asComposition.describe(Site, document), ids and props included. - A pattern (see Patterns) goes in by
UsePattern, whoseidsname exactly the pattern's nodes. examples/cmshas one,pageAgent.ts.