OutputField
KIT · interface · Type contract
One field of an output definition.
Import
ts
import type { OutputField } from '@jangts/agent-core/kits/presentation';js
/** @typedef {import('@jangts/agent-core/kits/presentation').OutputField} OutputField */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits/presentation, @jangts/agent-core/kits.
Definition
ts
interface OutputFieldField structure
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Required | Read-only. Field id, used as the property name and as a master-template slot name. |
owner | "generated" | "bound" | "constant" | "semantic" | Required | Read-only. Where the value comes from: generated (model writes it), bound (provider resolves it), constant (fixed constantValue) or semantic (model picks one of semanticKeys). |
required | boolean | undefined | Optional | Read-only. Whether the model must provide the field; defaults to true. |
valueSchema | SchemaAdapter<unknown> | undefined | Optional | Read-only. Value parser and schema. Defaults to a string parser when omitted. |
providerId | string | undefined | Optional | Read-only. Provider that resolves bound and semantic fields; required for those owners. |
constantValue | unknown | Optional | Read-only. Fixed value for constant fields; snapshotted at registration. |
semanticKeys | readonly string[] | undefined | Optional | Read-only. Allowlist for semantic fields; must be non-empty and unique. |
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