ModelStageTransportRegistration
SUPPORT · interface · Type contract
Stage IDs and capability references are App-owned; this adapter only compiles their relation.
Import
ts
import type { ModelStageTransportRegistration } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').ModelStageTransportRegistration} ModelStageTransportRegistration */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/support, @jangts/agent-core/support/model.
Definition
ts
interface ModelStageTransportRegistration<Result>Extends or implements: ModelTransportRegistration<Result>.
Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Result | — | unknown |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
stages | readonly { readonly id: string; readonly toolIds: readonly string[]; }[] | Required | Read-only. Declared stages; each id is unique and lists non-empty, unique capability ids. |
id | string | Required | Transport id used by call requests and reported in diagnostic events. |
tools | ModelToolSource<Result> | ((stage: string) => ModelToolSource<Result>) | Required | Static capability source, or a factory that selects tools per stage. |
adapter | ModelInteractionAdapter | undefined | Optional | Wire-format adapter; defaults to native function calling. |
options | Pick<ModelOptions, "temperature"> | undefined | Optional | Sampling defaults this transport contributes to every call. |
requireStrictArguments | boolean | undefined | Optional | Reject the registration when the chosen adapter cannot enforce strict arguments. |
Examples
- Model transport and stage projection: Generate a sealed catalog and stage projections from tool definitions; native functions and JSON adapters share the same tool contract.
Create a named text transport
Beginner · Node.js
ts
import { ModelRunner, Support } from '@jangts/agent-core';
const text = Support.createTextTransport({ id: 'brief', options: { temperature: 0.2 } });
const runner = new ModelRunner({ provider: { async *stream() { yield '服务正常'; } }, transports: [text] });
console.log((await runner.invoke({ input: '简答服务状态', transport: text })).value);js
import { ModelRunner, Support } from '@jangts/agent-core';
const text = Support.createTextTransport({ id: 'brief', options: { temperature: 0.2 } });
const runner = new ModelRunner({ provider: { async *stream() { yield '服务正常'; } }, transports: [text] });
console.log((await runner.invoke({ input: '简答服务状态', transport: text })).value);Generate transports for two stages from same-source tools
Configuration · Node.js
ts
import { Support } from '@jangts/agent-core';
const inputSchema = Support.defineSchema({
jsonSchema: { type: 'object', properties: {}, additionalProperties: false },
parse(value: unknown) {
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length) throw new TypeError('需要空对象');
return {};
},
});
const tools = Support.defineModelTools([
{ id: 'greet', description: '问候', inputSchema, resolve: () => 'greet' },
{ id: 'status', description: '状态查询', inputSchema, resolve: () => 'status' },
]);
const transport = Support.createStageModelTransport({ id: 'intent', tools,
stages: [{ id: 'recognize', toolIds: ['greet', 'status'] }, { id: 'status-only', toolIds: ['status'] }],
});
console.log(transport.prepare('status-only').schemaChars);js
import { Support } from '@jangts/agent-core';
const inputSchema = Support.defineSchema({
jsonSchema: { type: 'object', properties: {}, additionalProperties: false },
parse(value) {
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length)
throw new TypeError('需要空对象');
return {};
},
});
const tools = Support.defineModelTools([
{ id: 'greet', description: '问候', inputSchema, resolve: () => 'greet' },
{ id: 'status', description: '状态查询', inputSchema, resolve: () => 'status' },
]);
const transport = Support.createStageModelTransport({ id: 'intent', tools,
stages: [{ id: 'recognize', toolIds: ['greet', 'status'] }, { id: 'status-only', toolIds: ['status'] }],
});
console.log(transport.prepare('status-only').schemaChars);Related policy source
- Stage list validation and dynamic source snapshots
- Explicit model interaction adapter catalog
- Session transport for prose and multiple tool calls