Skip to Content
DocumentationGetting StartedπŸ”² Blocks and Configs

πŸ”² Blocks and Configs

Loopstack uses a block-based architecture where every component (workflow, pipeline, document, tool, and workspace) is defined as a reusable, configurable block.

Core Concept

Every block in Loopstack consists of two parts:

  1. TypeScript (NestJS) Service: Defines data structure and houses custom code.
  2. YAML Configuration: Defines the runtime behavior, UI representation, and execution flow

Note, using the separate yaml configs is optional. You can also define the behaviour using the config property in the BlockConfig decorator following the same block schema. However, we recommend using the yaml configuration for better modularity, reusability and readability.

Anatomy of a Block

Here’s a minimal example showing the essential components of a workflow block:

import { Expose } from 'class-transformer'; import { Workflow } from '@loopstack/core'; import { BlockConfig, Input } from '@loopstack/shared'; @BlockConfig({ imports: [ // Tools and documents used in this workflow ], config: { title: 'My First Workflow', }, configFile: __dirname + '/my-workflow.yaml', }) export class MyWorkflow extends Workflow { @Input() @Expose() myData: string; }
# my-workflow.yaml transitions: - id: process from: start to: end call: - id: do_something tool: SomeTool args: input: "Hello World" assign: myData: ${ result.data }

Key Components

@BlockConfig Decorator

  • Marks a class as a Loopstack block
  • Links the NestJS service to its YAML configuration via configFile
  • Defines title and metadata in config
  • Specifies dependencies (tools, documents) through imports

YAML Configuration

  • Defines workflow transitions as a state machine
  • Uses declarative syntax for execution flow
  • Supports template expressions for dynamic values
  • Specifies which tools to call and how to handle results

Block Types

Loopstack includes several block types, each serving a specific purpose:

  • Workspaces: Group related workflows and provide organizational structure
  • Workflows: Orchestrate processes using state machine transitions
  • Documents: Define structured data with validation and UI configuration
  • Tools: Encapsulate reusable operations (API calls, transformations, etc.)
  • Pipelines: Enables sequential, parallel and nested automation flows.

Each block type extends a base class and uses the @BlockConfig decorator with type-specific configuration options.

Last updated on