NodeReportingContext
CORE · interface · Type contract
Reporting surface handed to a node or tool for the duration of one visit.
Import
import type { NodeReportingContext } from '@jangts/agent-core/diagnostics';/** @typedef {import('@jangts/agent-core/diagnostics').NodeReportingContext} NodeReportingContext */Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/diagnostics.
Definition
interface NodeReportingContextField structure
| Field | Type | Required | Description |
|---|---|---|---|
report | (update: import("./execution/workflow.js").WorkflowNodeReport) => void | Required | Reports progress for the active node; Core supplies the execution identity. |
createSubFlowLogger | () => SubFlowLogger | Required | Bound to this context and owned by runtime; repeated calls in one visit return the same instance. |
Member index
| Member | Purpose |
|---|---|
report | Reports progress for the active node; Core supplies the execution identity. |
createSubFlowLogger | Bound to this context and owned by runtime; repeated calls in one visit return the same instance. |
Member details
report
Reports progress for the active node; Core supplies the execution identity.
NodeReportingContext.report(update: import("./execution/workflow.js").WorkflowNodeReport): voidReports progress for the active node; Core supplies the execution identity.
| Parameter | Type | Passing | Description |
|---|---|---|---|
update | WorkflowNodeReport | Required | — |
Fields of update
| Field | Type | Required | Description |
|---|---|---|---|
usedModel | boolean | undefined | Optional | Read-only. This visit's own use only; omitted means unknown. |
payload | unknown | Optional | Read-only. App-defined progress detail; collected only when content logging is enabled. |
Returns: void.
createSubFlowLogger
Bound to this context and owned by runtime; repeated calls in one visit return the same instance.
NodeReportingContext.createSubFlowLogger(): SubFlowLoggerBound to this context and owned by runtime; repeated calls in one visit return the same instance.
No call parameters.
Returns: SubFlowLogger.
Examples
- Process observation and node reports: The App subscribes to Core execution facts; nodes report their own usedModel and use an instance sub-logger to record intent first and then results, while the Loop owns identity and logging.
Observe the nodes and model events a task passes through
Beginner · Node.js
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
type State = { name: string; answer?: string };
const workflow = defineWorkflow<State, string>({
id: 'greeting',
nodes: [{
id: 'greet', description: '根据本次姓名生成问候', startsRound: true,
run: state => ({ answer: '你好,' + state.name }),
routes: [route.deliver('answer')],
}],
});
const agent = new AgentCoreEngine({ workflow, execution: {
observe: { event(event) { console.log(event.type, event.eventId); } },
} });
console.log(await agent.run({ name: 'Ivan' }));import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
const workflow = defineWorkflow({
id: 'greeting',
nodes: [{
id: 'greet', description: '根据本次姓名生成问候', startsRound: true,
run: state => ({ answer: '你好,' + state.name }),
routes: [route.deliver('answer')],
}],
});
const agent = new AgentCoreEngine({ workflow, execution: {
observe: { event(event) { console.log(event.type, event.eventId); } },
} });
console.log(await agent.run({ name: 'Ivan' }));Report a business stage while the node executes
Configuration · Node.js
The node only reports facts it knows; Core owns node identity and execution association.
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
type State = { name: string; answer?: string };
const workflow = defineWorkflow<State, string>({ id: 'greeting', nodes: [{
id: 'greet', description: '生成问候', startsRound: true,
run(state, context) {
context.report({ payload: { phase: 'formatting' } });
return { answer: '你好,' + state.name };
}, routes: [route.deliver('answer')],
}] });
const agent = new AgentCoreEngine({ workflow, execution: {
observe: { event(event) { console.log(event.type); } },
} });
console.log(await agent.run({ name: 'Ivan' }));import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
const workflow = defineWorkflow({ id: 'greeting', nodes: [{
id: 'greet', description: '生成问候', startsRound: true,
run(state, context) {
context.report({ payload: { phase: 'formatting' } });
return { answer: '你好,' + state.name };
}, routes: [route.deliver('answer')],
}] });
const agent = new AgentCoreEngine({ workflow, execution: {
observe: { event(event) { console.log(event.type); } },
} });
console.log(await agent.run({ name: 'Ivan' }));