PreparedSessionTransport
SUPPORT · interface · Type contract
Prepared session transport handed to the runner.
Import
ts
import type { PreparedSessionTransport } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').PreparedSessionTransport} PreparedSessionTransport */Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/support, @jangts/agent-core/support/model.
Definition
ts
interface PreparedSessionTransportField structure
| Field | Type | Required | Description |
|---|---|---|---|
options | Pick<ModelOptions, "functions" | "json" | "toolChoice" | "parallelToolCalls" | "temperature"> | Required | Read-only. See the type definition and usage context. |
schemaChars | number | Required | Read-only. See the type definition and usage context. |
instruction | string | Required | Read-only. See the type definition and usage context. |
createResponse | () => ModelResponseCollector<ResolvedSessionResult> | Required | See the type definition and usage context. |
Member index
| Member | Purpose |
|---|---|
createResponse | See the overload below for full inputs and outputs. |
Member details
createResponse
ts
PreparedSessionTransport.createResponse(): ModelResponseCollector<ResolvedSessionResult>No call parameters.
Returns: ModelResponseCollector<ResolvedSessionResult>.
Return value structure
| Field | Type | Required | Description |
|---|---|---|---|
call | { id: string; name: string; argumentChars: number; } | undefined | Optional | Read-only. Native function call that carried the selection, when the response used one. |
calls | readonly { id: string; name: string; argumentChars: number; toolId?: string; }[] | undefined | Optional | Read-only. All native calls carried by a session response; omitted by single-selection collectors. |
outputChars | number | Required | Read-only. Output characters accumulated so far, for output-budget accounting. |
push | (part: ModelPart) => void | Required | Appends one streamed part; parts arrive in provider order. |
finish | () => ResolvedSessionResult | Required | Finalizes the response. Throws when the accumulated content is not a valid selection. |
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.
- Support: the aggregate entry for recommended usage: Support aggregates recommended construction, policies, and same-source configuration generation; Core execution does not depend on this namespace.
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