/** * Self-referencing `toolWorkflow` extraction. * * n8n exposes a workflow as an agent tool via a `toolWorkflow` sub-node whose * `workflowId` is `$workflow.id` (a self-reference). The tool body is a separate * branch of the *same* file, rooted at an `executeWorkflowTrigger` ("When * Executed by Another Workflow"). Pikku has no self-invocation-as-tool concept, * so that branch is lifted out into its own `pikkuWorkflowGraph` and the agent * references it through its `workflows: [ref(...)]` capability (agents invoke * workflows as tools, added in core alongside `tools`/`agents`). * * v1 handles the common single-trigger shape: one `executeWorkflowTrigger` whose * reachable main-branch nodes form one sub-workflow, referenced by every self * `toolWorkflow` in the file. */ import type { ParsedWorkflow } from './types.js'; export interface SubWorkflow { /** Registered graph name — the agent refs this in `workflows: [ref(name)]`. */ name: string; /** File/const slug (`.graph.ts`, `Workflow`). */ slug: string; /** The `executeWorkflowTrigger` nodeId — becomes the sub-graph's input. */ triggerNodeId: string; /** Body nodeIds reachable from the trigger (excluded from the main graph). */ memberNodeIds: Set; } export interface SubWorkflowPlan { subWorkflows: SubWorkflow[]; /** Body nodeIds lifted out of the main graph. */ extractedNodeIds: Set; /** `executeWorkflowTrigger` nodeIds consumed by an extraction. */ triggerNodeIds: Set; /** Self `toolWorkflow` nodeId → the sub-workflow name it invokes. */ toolToWorkflow: Map; } export declare function planSubWorkflows(parsed: ParsedWorkflow): SubWorkflowPlan; /** * Build the sub-`ParsedWorkflow` for a lifted branch: its trigger + body nodes * and the connections between them, as a pure graph. Feeds straight into the * existing `emitGraphFile`. */ export declare function subWorkflowParsed(parsed: ParsedWorkflow, sub: SubWorkflow): ParsedWorkflow;