RegisteredTransportOutput
CORE · type · Type contract
Result type of a transport selected by id.
core:plain-text yields string, a registered id yields its declared result, and an id the runner does not know yields unknown rather than a guessed type.
Import
ts
import type { RegisteredTransportOutput } from '@jangts/agent-core/types';js
/** @typedef {import('@jangts/agent-core/types').RegisteredTransportOutput} RegisteredTransportOutput */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/structs.
Definition
ts
type RegisteredTransportOutput<Transports extends readonly ModelTransportDefinition[], Id extends string> = string extends Id
? unknown
: Id extends 'core:plain-text'
? string
: [Extract<Transports[number], { readonly id: Id }>] extends [never]
? unknown
: Extract<Transports[number], { readonly id: Id }> extends ModelTransportDefinition<
infer Value
>
? Value
: unknown;Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Transports | readonly ModelTransportDefinition[] | — |
Id | string | — |
Examples
- ModelRunner: input can be shortened while the output contract stays the same: Execute one model interaction through the real Provider port and return a value plus the invocation for this call.
- Actual request measurement and same-call preparation snapshot: Use prepare only when context must be handled ahead of time; multiple measurements and the final send reuse the same transport preparation.
- Child execution: isolated records, shared ancestor quota: A child Runner does not inherit conversation or the output receiver, but cannot bypass parent budget, cancellation, or deadlines.
Two inputs for the same output
Beginner · Node.js
ts
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages: readonly { content: string }[]) {
yield '收到:' + messages.at(-1)!.content;
},
};
const runner = new ModelRunner({ provider });
const first = await runner.invoke('你好');
const second = await runner.invoke({ input: '你好' });
console.log(first.value, second.value);
console.log(first.invocation.invocationId);js
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages) {
yield '收到:' + messages.at(-1).content;
},
};
const runner = new ModelRunner({ provider });
const first = await runner.invoke('你好');
const second = await runner.invoke({ input: '你好' });
console.log(first.value, second.value);
console.log(first.invocation.invocationId);Add budget and request cancellation
Configuration · Node.js
ts
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages: readonly { content: string }[]) {
yield '收到:' + messages.at(-1)!.content;
},
};
const runner = new ModelRunner({ provider, maxCalls: 2, maxInputChars: 4000,
maxOutputChars: 2000, callTimeoutMs: 15000,
execution: { signal: AbortSignal.timeout(20000) },
});
const result = await runner.invoke({ input: '你好', stageId: 'reply', maxOutputTokens: 600 });
console.log(result.value, runner.remainingCalls);js
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages) {
yield '收到:' + messages.at(-1).content;
},
};
const runner = new ModelRunner({ provider, maxCalls: 2, maxInputChars: 4000,
maxOutputChars: 2000, callTimeoutMs: 15000,
execution: { signal: AbortSignal.timeout(20000) },
});
const result = await runner.invoke({ input: '你好', stageId: 'reply', maxOutputTokens: 600 });
console.log(result.value, runner.remainingCalls);