Defining a plugin
The builders that declare a plugin and its command tree, and the shapes they produce.
Exports of @north-light/crouter-plugin, read from the TypeScript compiler at build time. Types re-exported from @north-light/crouter-api are documented with that package.
BranchNode
interface declared in define.ts
A group of commands, as returned by defineBranch. A branch is never invoked itself.
Prop
Type
defineBranch
function declared in define.ts
Groups commands under one name.
(spec: Omit<BranchNode, 'kind'>) => BranchNodedefineLeaf
function declared in define.ts
Declares one command whose handler returns a single object matching output.
params may be omitted when the command takes no input.
<P extends object = {}, O extends object = {}>(spec: { description: string; whenToUse: string; summary: string; tier?: 'normal' | 'common' | 'important'; params?: P; output: O; effects: readonly string[]; handler: (input: Input<P>, ctx: LeafContext) => Output<O> | Promise<Output<O>>; }) => LeafNodedefinePlugin
function declared in define.ts
Validates the whole declaration and returns a frozen plugin. Throws PluginDefinitionError
on any malformed name, text, parameter, output field, or memory document, so a plugin that
constructs successfully is one crtr can install.
(spec: { name: string; description: string; whenToUse: string; summary: string; rootEntry: { concept: string; description: string; whenToUse: string; }; commands: Record<string, LeafNode | BranchNode>; memory?: readonly MemoryDoc[]; timeouts?: { connectMs?: number; requestMs?: number; streamIdleMs?: number; }; }) => PluginDefinitiondefineStreamingLeaf
function declared in define.ts
Declares one command whose handler yields objects instead of returning one. The generated REST mapping is marked streaming; see the errors and streaming guide.
<P extends object = {}, O extends object = {}>(spec: { description: string; whenToUse: string; summary: string; tier?: 'normal' | 'common' | 'important'; params?: P; output: O; effects: readonly string[]; handler: (input: Input<P>, ctx: LeafContext) => AsyncIterable<object>; }) => LeafNodekebab
function declared in define.ts
The lowercase kebab-case name crtr exposes for a camelCase key. Throws
PluginDefinitionError when the key does not convert.
(key: string) => stringLeafContext
interface declared in define.ts
The second argument to every leaf handler.
Prop
Type
LeafNode
interface declared in define.ts
One command an agent can invoke, as returned by defineLeaf or defineStreamingLeaf.
Prop
Type
MemoryDoc
interface declared in define.ts
A memory document the plugin installs alongside its commands.
Prop
Type
PluginDefinition
interface declared in define.ts
A validated, frozen plugin, as returned by definePlugin.
Prop
Type
PluginDefinitionError
class declared in define.ts
Thrown by definePlugin when a declaration is malformed, before anything is served.
Prop
Type