WorkflowChainNodeEvent
CORE · interface · Type contract
Node-local lifecycle facts; payload remains subject to the source's content policy.
Import
ts
import type { WorkflowChainNodeEvent } from '@jangts/agent-core/engine';js
/** @typedef {import('@jangts/agent-core/engine').WorkflowChainNodeEvent} WorkflowChainNodeEvent */Other public entry points:@jangts/agent-core, @jangts/agent-core/engine, @jangts/agent-core/types, @jangts/agent-core/structs.
Definition
ts
interface WorkflowChainNodeEventField structure
| Field | Type | Required | Description |
|---|---|---|---|
eventId | string | Required | Read-only. See the type definition and usage context. |
producerSequence | number | Required | Read-only. See the type definition and usage context. |
occurredAtMs | number | Required | Read-only. See the type definition and usage context. |
type | "error" | "transition" | "complete" | "enter" | "progress" | Required | Read-only. See the type definition and usage context. |
phase | "complete" | "boundary" | "requires" | "run" | "provides" | "route" | "result" | undefined | Optional | Read-only. See the type definition and usage context. |
routeId | string | undefined | Optional | Read-only. See the type definition and usage context. |
conditionId | string | undefined | Optional | Read-only. See the type definition and usage context. |
errorCode | string | undefined | Optional | Read-only. See the type definition and usage context. |
errorEventId | string | undefined | Optional | Read-only. See the type definition and usage context. |
payload | SubFlowValue | undefined | Optional | Read-only. See the type definition and usage context. |
Examples
- Workflow: nodes, routes, and partial state updates: Use a single node definition that actually participates in execution to show order, branches, error destinations, and end conditions together.
- Reusing a base Workflow and Agent branches: add preserves the old Workflow and produces a new combined Workflow; fork inherits existing bindings and the branch origin.
A single node completes the greeting
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')],
}],
});
console.log(workflow.entryNodeId);
console.log(workflow.describe());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')],
}],
});
console.log(workflow.entryNodeId);
console.log(workflow.describe());Add a validation stage without changing state or the run call
Configuration · Node.js
ts
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
type State = { name: string; answer?: string; error?: string };
const workflow = defineWorkflow<State, string>({
id: 'greeting',
nodes: [
{ id: 'check', description: '检查姓名', startsRound: true,
run: state => ({ error: state.name.trim() ? undefined : '姓名不能为空' }),
routes: [route.toIfError('failure'), route.to('greet')] },
{ id: 'greet', description: '生成问候', provides: ['answer'],
run: state => ({ answer: '你好,' + state.name }), routes: [route.deliver('answer')] },
{ id: 'failure', description: '返回校验提示', requires: ['error'], routes: [route.deliver('error')] },
],
});
console.log(await new AgentCoreEngine({ workflow }).run({ name: 'Ivan' }));js
import { AgentCoreEngine, defineWorkflow, route } from '@jangts/agent-core/engine';
const workflow = defineWorkflow({
id: 'greeting',
nodes: [
{ id: 'check', description: '检查姓名', startsRound: true,
run: state => ({ error: state.name.trim() ? undefined : '姓名不能为空' }),
routes: [route.toIfError('failure'), route.to('greet')] },
{ id: 'greet', description: '生成问候', provides: ['answer'],
run: state => ({ answer: '你好,' + state.name }), routes: [route.deliver('answer')] },
{ id: 'failure', description: '返回校验提示', requires: ['error'], routes: [route.deliver('error')] },
],
});
console.log(await new AgentCoreEngine({ workflow }).run({ name: 'Ivan' }));Related policy source
- Execution implementation of the bounded loop, commit, and cancellation
- Reference, reachability, and bounded-loop validation