Skip to content
中文

SubFlowLog ​

CORE · interface · Type contract

Common read/write surface for both independently implemented logger classes.

Import ​

ts
import type { SubFlowLog } from '@jangts/agent-core/diagnostics';
js
/** @typedef {import('@jangts/agent-core/diagnostics').SubFlowLog} SubFlowLog */

Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/diagnostics.

Definition ​

ts
interface SubFlowLog

Field structure ​

FieldTypeRequiredDescription
write(input: ScopedSubFlowStepInput) => string | -1RequiredSee the type definition and usage context.
fix(stepId: string | -1, patch: SubFlowStepFix) => booleanRequiredSee the type definition and usage context.
readAll() => readonly Readonly<RecordedSubStep>[]RequiredBoth logger classes return the same complete immutable ledger.

Member index ​

MemberPurpose
writeSee the overload below for full inputs and outputs.
fixSee the overload below for full inputs and outputs.
readAllBoth logger classes return the same complete immutable ledger.

Member details ​

write ​

ts
SubFlowLog.write(input: ScopedSubFlowStepInput): string | -1
ParameterTypePassingDescription
inputScopedSubFlowStepInputRequired—
Fields of input
FieldTypeRequiredDescription
kindstring | undefinedOptionalRead-only. Optional family classification; defaults to the custom type when omitted.
typestring | undefinedOptionalRead-only. App-defined business log type; never a write/fix operation enum.
parentStepIdstring | undefinedOptionalRead-only. Reported parent step, forming a tree; absent for a top-level step.
relatedDefinitionIdstring | undefinedOptionalRead-only. Self-reported reference only; never a workflow dispatch identity.
relatedInvocationIdstring | undefinedOptionalRead-only. Real model/tool invocation identity, kept separate from the node-local subnode id.
namestringRequiredRead-only. Short reported label.
status"error" | "success" | "unknown" | "planned" | "running" | "cancelled" | "skipped" | undefinedOptionalRead-only. Reported lifecycle status; omission means the node did not report one.
usedModelboolean | undefinedOptionalRead-only. This step's own reported model use, never a descendant rollup.
startedAtMsnumber | undefinedOptionalRead-only. Reported start instant in epoch milliseconds.
endedAtMsnumber | undefinedOptionalRead-only. Reported end instant in epoch milliseconds; only meaningful for terminal statuses.
nextStepIdsreadonly string[] | undefinedOptionalRead-only. Reported successor step ids, for display only.
caseIdstring | undefinedOptionalRead-only. Reported case or variant id, interpreted by the App.
summarystring | undefinedOptionalRead-only. Reported one-line summary.
payloadReadonly<Record<string, SubFlowValue>> | undefinedOptionalRead-only. See the type definition and usage context.

Returns: string \| -1.

fix ​

ts
SubFlowLog.fix(stepId: string | -1, patch: SubFlowStepFix): boolean
ParameterTypePassingDescription
stepIdstring | -1Required—
patchSubFlowStepFixRequired—
Fields of patch
FieldTypeRequiredDescription
status"error" | "success" | "unknown" | "planned" | "running" | "cancelled" | "skipped" | undefinedOptionalRead-only. See the type definition and usage context.
usedModelboolean | undefinedOptionalRead-only. See the type definition and usage context.
startedAtMsnumber | undefinedOptionalRead-only. See the type definition and usage context.
endedAtMsnumber | undefinedOptionalRead-only. See the type definition and usage context.
summarystring | undefinedOptionalRead-only. See the type definition and usage context.
nextStepIdsreadonly string[] | undefinedOptionalRead-only. See the type definition and usage context.
payloadReadonly<Record<string, SubFlowValue>> | undefinedOptionalRead-only. Fill missing result fields; existing facts cannot be replaced.

Returns: boolean.

readAll ​

Both logger classes return the same complete immutable ledger.

ts
SubFlowLog.readAll(): readonly Readonly<RecordedSubStep>[]

Both logger classes return the same complete immutable ledger.

No call parameters.

Returns: readonly Readonly<RecordedSubStep>[].

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' }));

API reference, usage examples and developer guides.