OutputDefinition
KIT · interface · Type contract
One output shape.
Import
ts
import type { OutputDefinition } from '@jangts/agent-core/kits/presentation';js
/** @typedef {import('@jangts/agent-core/kits/presentation').OutputDefinition} OutputDefinition */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits/presentation, @jangts/agent-core/kits.
Definition
ts
interface OutputDefinitionField structure
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Required | Read-only. Output id; duplicate ids are rejected. |
kind | "text" | "master" | "record" | "group" | Required | Read-only. Shape family. text holds one required field; group holds program-assigned items. |
fields | readonly OutputField[] | undefined | Optional | Read-only. Fields of text, master and record outputs; forbidden for groups. |
master | string | undefined | Optional | Read-only. Master template for master outputs; its slots must match the field ids exactly. |
allowedOutputIds | readonly string[] | undefined | Optional | Read-only. Output ids a group may contain; required and unique for groups. |
maxItems | number | undefined | Optional | Read-only. Maximum group members; required for groups and at least 1. |
Examples
- Presentation: field ownership and final output: The model fills only the fields it is assigned; fixed text, bound values, and semantic keys are owned by the program.
First compose one piece of generated text
Beginner · Node.js
ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
{ id: 'reply', kind: 'text', fields: [{ id: 'text', owner: 'generated' }] },
]);
console.log(outputs.toModelSchema('reply'));
const output = outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal });
console.log(output.value);js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
{ id: 'reply', kind: 'text', fields: [{ id: 'text', owner: 'generated' }] },
]);
console.log(outputs.toModelSchema('reply'));
const output = outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal });
console.log(output.value);Let the program own the explanatory prefix in the same compose
Configuration · Node.js
ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
{ id: 'reply', kind: 'master', master: '{{prefix}}{{text}}', fields: [
{ id: 'prefix', owner: 'constant', constantValue: '接口说明:' },
{ id: 'text', owner: 'generated' },
] },
]);
console.log(outputs.toModelSchema('reply')); // 只有 text 由模型填写
console.log(outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal }).value);js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
{ id: 'reply', kind: 'master', master: '{{prefix}}{{text}}', fields: [
{ id: 'prefix', owner: 'constant', constantValue: '接口说明:' },
{ id: 'text', owner: 'generated' },
] },
]);
console.log(outputs.toModelSchema('reply')); // 只有 text 由模型填写
console.log(outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal }).value);Related policy source
- Field ownership, model Schema, and composition
- Reply format declarations, shared checks, and bubble normalization