ToolJournalStart
CORE · interface · Type contract
Opening record for one tool call, written before the handler runs.
Import
ts
import type { ToolJournalStart } from '@jangts/agent-core/types';js
/** @typedef {import('@jangts/agent-core/types').ToolJournalStart} ToolJournalStart */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/structs.
Definition
ts
interface ToolJournalStartField structure
| Field | Type | Required | Description |
|---|---|---|---|
toolId | string | Required | Tool being invoked. |
input | unknown | Required | Parsed input; stored as-is so the host can build its own domain record. |
invocation | Partial<InvocationMetadata> | undefined | Optional | What the caller already knows. The journal fills gaps and generates an id when absent. |
Examples
- ContextJournal: the in-request projection of receipts: Turn real call receipts into in-request records usable in later context, without starting another persistent logging system.
- Synchronous execution adapter for host-selected invocations: Record start, completion, and failure uniformly for synchronous invocations the host has already selected, without replacing tool selection or authorization.
Read the model receipt already recorded by the Runner
Beginner · Node.js
ts
import { ModelRunner } from '@jangts/agent-core';
const runner = new ModelRunner({ provider: { async *stream() { yield '服务运行正常'; } } });
const result = await runner.invoke('查询服务状态');
console.log(result.invocation.invocationId);
console.log(runner.journal.snapshot());js
import { ModelRunner } from '@jangts/agent-core';
const runner = new ModelRunner({ provider: { async *stream() { yield '服务运行正常'; } } });
const result = await runner.invoke('查询服务状态');
console.log(result.invocation.invocationId);
console.log(runner.journal.snapshot());An App adapter records the local tool it actually executes
Configuration · Node.js
ts
import { ContextJournal } from '@jangts/agent-core/journal';
const journal = new ContextJournal();
const invocationId = journal.beginTool({ toolId: 'get_status', input: {} });
// 此处由 App 实际执行本地读取;不是模型提供的回执。
const status = '服务运行正常';
journal.finishTool({ invocationId, status: 'success', value: status });
console.log(journal.snapshot());js
import { ContextJournal } from '@jangts/agent-core/journal';
const journal = new ContextJournal();
const invocationId = journal.beginTool({ toolId: 'get_status', input: {} });
// 此处由 App 实际执行本地读取;不是模型提供的回执。
const status = '服务运行正常';
journal.finishTool({ invocationId, status: 'success', value: status });
console.log(journal.snapshot());