ModelSessionCall
CORE · interface · 类型合同
One completed tool call in a session response.
导入
ts
import type { ModelSessionCall } from '@jangts/agent-core/types';js
/** @typedef {import('@jangts/agent-core/types').ModelSessionCall} ModelSessionCall */其他公开入口:@jangts/agent-core/types、@jangts/agent-core/structs。
定义
ts
interface ModelSessionCall字段结构
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
index | number | 必需 | 只读。Provider index used to join streamed fragments. |
id | string | 必需 | 只读。Provider call id, echoed by the matching tool result. |
name | string | 必需 | 只读。Declared function name exactly as returned by the model. |
arguments | string | 必需 | 只读。Raw JSON argument text exactly as returned by the model. |
argumentChars | number | 必需 | 只读。Characters counted for the output budget. |
使用示例
- 模型传输与阶段投影:从 Tool 定义生成封存目录与阶段投影,原生函数和 JSON 适配复用同一 Tool 合同。
- Support:推荐用法的聚合入口:Support 聚合推荐的构造、策略与同源配置生成;Core 运行不依赖这个命名空间。
创建具名文本传输
入门 · 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);从同源 Tool 生成两个阶段的传输
配置 · 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);