SubStepProgress
CORE · interface · Type contract
Compact progress notification emitted for each accepted sub-step write or fix.
Import
ts
import type { SubStepProgress } from '@jangts/agent-core/diagnostics';js
/** @typedef {import('@jangts/agent-core/diagnostics').SubStepProgress} SubStepProgress */Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/diagnostics.
Definition
ts
interface SubStepProgressField structure
| Field | Type | Required | Description |
|---|---|---|---|
relatedInvocationId | string | undefined | Optional | Read-only. See the type definition and usage context. |
operation | "write" | "fix" | Required | Read-only. See the type definition and usage context. |
type | string | undefined | Optional | Read-only. See the type definition and usage context. |
subnodeId | string | undefined | Optional | Read-only. See the type definition and usage context. |
targetStepId | string | undefined | Optional | Read-only. Original write record when this operation is a fix. |
stepId | string | Required | Read-only. Unique id of this append-only record. |
sequence | number | Required | Read-only. Append sequence of this record within the node visit, including every fix. |
revision | number | Required | Read-only. Revision after the operation; write starts at 1. |
createdAtMs | number | Required | Read-only. Instant the progress fact was recorded, in epoch milliseconds. |
status | "error" | "success" | "unknown" | "planned" | "running" | "cancelled" | "skipped" | Required | Read-only. Status after the operation. |
usedModel | boolean | undefined | Optional | Read-only. Reported model use after the operation, when the node stated it. |
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
ts
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' }));js
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.
ts
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' }));js
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' }));