Skip to content

AIDK API Reference / aidk-kernel / ProcedureGraph

Class: ProcedureGraph ​

Defined in: packages/kernel/src/procedure-graph.ts:123

Procedure graph for tracking parent-child relationships

Constructors ​

Constructor ​

ts
new ProcedureGraph(): ProcedureGraph;

Returns ​

ProcedureGraph

Methods ​

clear() ​

ts
clear(): void;

Defined in: packages/kernel/src/procedure-graph.ts:255

Clear all procedures

Returns ​

void


get() ​

ts
get(pid: string): ProcedureNode | undefined;

Defined in: packages/kernel/src/procedure-graph.ts:177

Get procedure node by PID

Parameters ​

ParameterType
pidstring

Returns ​

ProcedureNode | undefined


getAllNodes() ​

ts
getAllNodes(): ProcedureNode[];

Defined in: packages/kernel/src/procedure-graph.ts:278

Get all procedure nodes

Returns ​

ProcedureNode[]


getChildNodes() ​

ts
getChildNodes(parentPid: string): ProcedureNode[];

Defined in: packages/kernel/src/procedure-graph.ts:207

Get child procedure nodes

Parameters ​

ParameterType
parentPidstring

Returns ​

ProcedureNode[]


getChildren() ​

ts
getChildren(parentPid: string): string[];

Defined in: packages/kernel/src/procedure-graph.ts:199

Get child procedure PIDs

Parameters ​

ParameterType
parentPidstring

Returns ​

string[]


getCount() ​

ts
getCount(): number;

Defined in: packages/kernel/src/procedure-graph.ts:285

Get count of procedures

Returns ​

number


getParent() ​

ts
getParent(pid: string): string | undefined;

Defined in: packages/kernel/src/procedure-graph.ts:184

Get parent PID

Parameters ​

ParameterType
pidstring

Returns ​

string | undefined


getParentNode() ​

ts
getParentNode(pid: string): ProcedureNode | undefined;

Defined in: packages/kernel/src/procedure-graph.ts:191

Get parent node

Parameters ​

ParameterType
pidstring

Returns ​

ProcedureNode | undefined


getRoot() ​

ts
getRoot(): ProcedureNode | undefined;

Defined in: packages/kernel/src/procedure-graph.ts:264

Get the root procedure node (O(1) lookup)

Returns ​

ProcedureNode | undefined


getRootPid() ​

ts
getRootPid(): string | undefined;

Defined in: packages/kernel/src/procedure-graph.ts:271

Get the root procedure PID

Returns ​

string | undefined


hasAncestor() ​

ts
hasAncestor(pid: string, predicate: (node: ProcedureNode) => boolean): boolean;

Defined in: packages/kernel/src/procedure-graph.ts:297

Check if any ancestor (parent chain) matches a predicate Traverses up the parent chain starting from the given PID

Parameters ​

ParameterTypeDescription
pidstringStarting procedure PID
predicate(node: ProcedureNode) => booleanFunction to test each ancestor node

Returns ​

boolean

True if any ancestor matches, false otherwise


hasAncestorWithName() ​

ts
hasAncestorWithName(pid: string, name: string): boolean;

Defined in: packages/kernel/src/procedure-graph.ts:334

Check if any ancestor has a specific procedure name Useful for determining if a procedure was called by Engine vs direct application call

Parameters ​

ParameterTypeDescription
pidstringStarting procedure PID
namestringProcedure name to search for (e.g., 'engine:execute', 'engine:stream')

Returns ​

boolean

True if any ancestor has the specified name


propagateMetrics() ​

ts
propagateMetrics(childPid: string): void;

Defined in: packages/kernel/src/procedure-graph.ts:216

Propagate metrics from child to parent

Parameters ​

ParameterType
childPidstring

Returns ​

void


register() ​

ts
register(
   pid: string, 
   parentPid?: string, 
   name?: string, 
   metadata?: Record<string, any>, 
   executionId?: string, 
   isExecutionBoundary?: boolean, 
   executionType?: string): ProcedureNode;

Defined in: packages/kernel/src/procedure-graph.ts:139

Register a new procedure

Parameters ​

ParameterTypeDescription
pidstringProcedure ID
parentPid?stringParent procedure ID (undefined for root)
name?stringProcedure name (e.g., 'model:generate', 'tool:run')
metadata?Record<string, any>Optional metadata
executionId?stringExecution ID this procedure belongs to
isExecutionBoundary?booleanWhether this procedure is an execution entry point
executionType?stringType of execution (derived from procedure name prefix)

Returns ​

ProcedureNode


updateStatus() ​

ts
updateStatus(
   pid: string, 
   status: ProcedureStatus, 
   error?: Error): void;

Defined in: packages/kernel/src/procedure-graph.ts:231

Update procedure status

Parameters ​

ParameterType
pidstring
statusProcedureStatus
error?Error

Returns ​

void

Released under the MIT License.