Elsa Core Documentation

repository·main·Indexed 27 days ago

https://github.com/elsa-workflows/elsa-core

A modular .NET workflow engine featuring a JavaScript-inspired DSL (ElsaScript) for Elsa 3. Documentation covers the engine's mental model, initialization via AddElsa, runtime execution, and the integration of features such as the Dashboard API, Console Logs diagnostics, and ASP.NET Core rate limiting. It includes guidance on EF Core migrations, OpenTelemetry configuration for MacOS, and integration testing using ShutdownElsaAsync.

Tokens
142.9K
Snippets
177
Records
851
Agent score
92%

What's inside Elsa Core

  1. Overview of Weaver AI Copilot Platform Tasks

    main

    The Weaver AI Copilot Platform is organized into development phases to implement an AI-driven assistant for Elsa workflows. The implementation follows a structured progression from core abstractions to user-facing features:

    1. Phase 1: Setup: Establishes the project structure, including Elsa.AI.Abstractions, Elsa.AI.Host, Elsa.AI.Copilot, and Elsa.AI.Persistence.EFCore modules, along with their respective unit and integration test projects.
    2. Phase 2: Foundational: Implements shared contracts, models (conversations, sessions, messages, tools, proposals, and audit events), and persistence layers using EF Core. This phase also introduces service registration, permissions, and tool enablement services.
    3. Phase 3: User Story 1 (MVP): Enables authorized users to chat with 'Weaver' using workflow-aware context. Key features include streaming assistant events, tool lifecycle events, context resolution with authorization/redaction, and reconnection grace periods for durable output recovery.

    Tasks are identified by an ID, priority [P], and a User Story label.

  2. Overview of Elsa.Diagnostics.StructuredLogs module

    main

    The Elsa.Diagnostics.StructuredLogs module provides structured logging capabilities for Elsa. It captures logs with semantic improvements, including message templates (via {OriginalFormat}) and active logging scopes.

    Key features include:

    • Structured Capture: Captures logs with metadata, message templates, and active scopes.
    • Redaction: Supports redacting sensitive information before logs are buffered or streamed.
    • Bounded In-Memory Storage: Uses a bounded in-memory ring buffer to store recent log history without unbounded memory growth.
    • Real-time Streaming: Provides a SignalR hub (StructuredLogsHub) for live log streaming.
    • REST API: Exposes endpoints to query recent logs and log sources.
    • Extensibility: Provides interfaces for custom log providers, redactors, and source registries.
  3. Overview of the Elsa.Secrets Module

    main

    The Elsa.Secrets module provides a first-class system for managing immutable named secrets within Elsa. It replaces the legacy elsa-extensions secrets implementation with an Orchard-style system.

    Key features include:

    • Immutable Named Secrets: Secrets are identified by immutable technical names used as serialized references.
    • Latest-Active Resolution: References automatically resolve to the latest active version of a secret.
    • Pluggable Stores: Supports multiple storage backends including in-memory (for development), configuration-backed read-only stores (for deployment-managed values), and EF Core-based encrypted stores (for production).
    • Extensible Secret Types: A registry system allows for different types of secrets.
    • Security by Design: The system disallows user-initiated cleartext reveal after a secret has been created.
    • Studio Integration: Includes management and picker UX for elsa-studio.
  4. Overview of Elsa.Diagnostics.ConsoleLogs module

    main

    The Elsa.Diagnostics.ConsoleLogs module is an opt-in Core diagnostics feature designed to capture raw stdout and stderr line output. It provides a mechanism to redact sensitive information before it reaches providers, maintains a bounded recent history of logs, and exposes these logs via REST and SignalR contracts for real-time monitoring (e.g., in Elsa Studio).

    Key characteristics:

    • Redaction: Content is redacted and ANSI codes are stripped by default before being passed to providers.
    • Buffering: Uses a bounded in-memory buffer for recent history and bounded subscriber queues for live streams.
    • Transport: Uses REST endpoints for retrieving recent log history and source lists, and SignalR for live, mutable log subscriptions.
    • Extensibility: Provides explicit extension points via IConsoleLogProvider, IConsoleLogRedactor, and IConsoleLogSourceRegistry to allow for future shared aggregation or custom redaction logic.
  5. Overview of Elsa.Diagnostics.OpenTelemetry

    main

    The Elsa.Diagnostics.OpenTelemetry module is an opt-in Core diagnostics module designed to act as an OTLP (OpenTelemetry Protocol) collector and API backend.

    Key Functions:

    • Receives OTLP telemetry (traces, metrics, logs, resources).
    • Normalizes telemetry into Elsa diagnostics read models.
    • Redacts sensitive values before data reaches provider boundaries.
    • Stores recent telemetry in a bounded in-memory repository.
    • Exposes authenticated REST APIs and SignalR live updates for real-time monitoring (e.g., for Elsa Studio).
    • Publishes collector configuration metadata for standard OTEL senders.

    Important Distinctions:

    • This is a collector/API backend, not a producer-side workflow tracing middleware.
    • It does not replace or modify the existing Elsa.Workflows.Core ActivitySource and Meter instrumentation, which remain the telemetry producers.
    • It does not include durable database persistence in v1; it uses bounded in-memory storage.
  6. Overview of Live Server Log Streaming

    main

    The Live Server Log Streaming feature provides an opt-in mechanism to capture structured ILogger events from an Elsa server. It includes data redaction for sensitive information, bounded recent history storage, and exposes both REST and SignalR contracts for real-time log streaming.

    Key capabilities include:

    • Source-aware events: Every log event carries source topology, allowing for future integration with clustered providers like Redis, OpenTelemetry, Loki, Seq, or Elasticsearch.
    • Redaction: Sensitive data is redacted before being buffered.
    • Bounded Storage: The MVP uses an in-memory ring buffer to prevent unbounded memory growth.
    • Real-time & Historical Access: Access logs via SignalR for live streaming or REST endpoints for recent log backfill.
  7. Overview of the Secrets Module

    main

    The Secrets Module provides a first-class capability for managing sensitive information within Elsa Workflows and Elsa Studio. It replaces ad hoc secret handling with named secret references that are resolved at runtime.

    Key characteristics include:

    • Named References: Secrets are identified by immutable technical names. References always resolve to the latest active version of that name.
    • Pluggable Stores: Secrets can be backed by different storage providers (e.g., Elsa-managed encrypted stores or configuration-backed read-only stores).
    • Extensible Types: Supports various secret types and metadata.
    • Security Model: To prevent exposure, cleartext secret values cannot be revealed via the API or Studio after creation. Users can only replace, rotate, use, test, or perform encrypted exports.
    • Integration: Designed to be usable by other modules without those modules needing to know the underlying storage mechanism.
  8. Overview of Weaver AI Copilot Platform

    main
    Weaver is Elsa's AI copilot platform, designed as a server-hosted, provider-isolated AI orchestration layer. It provides Studio chat capabilities, governed tool execution, context providers, streaming events, and durable audit records. A key safety feature is its use of 'proposal-only' workflow mutations, where AI-generated changes to workflows are submitted as proposals that must be reviewed and applied, rather than being written directly to the runtime.
  9. Overview of Elsa Expression Language Modules

    main

    Elsa provides a base expression infrastructure (Elsa.Expressions) and several language-specific modules that add concrete evaluators and activities:

    ModuleEvaluatorKey Features
    Elsa.Expressions.JavaScriptIJavaScriptEvaluator (Jint)RunJavaScript activity, TypeScript support, Lodash/Moment libraries
    Elsa.Expressions.CSharpICSharpEvaluator (Roslyn)RunCSharp activity, C# descriptors
    Elsa.Expressions.PythonIPythonEvaluator (pythonnet)RunPython activity, PythonGlobalInterpreterManager
    Elsa.Expressions.LiquidFluid managerLiquid filters and parser services
  10. Overview of ElsaScript DSL

    main
    ElsaScript is a JavaScript-inspired textual Domain Specific Language (DSL) designed for authoring Elsa 3 workflows. It serves as a concise, code-centric alternative to using C# WorkflowBuilder APIs or manual JSON workflow definitions. The implementation consists of a parser (ElsaScriptParser) that generates an Abstract Syntax Tree (AST) and a compiler (ElsaScriptCompiler) that transforms that AST into Elsa workflow activities.
  11. Overview of Elsa Workflows Core

    main

    Elsa Workflows (elsa-core) is an open-source .NET library and engine designed for embedding workflow execution directly into .NET applications. It provides the necessary components for managing data models, execution runtimes, persistence abstractions, expression evaluation, and security. It supports both short-running and long-running business processes that run entirely within the consuming application's host process.

    Workflow Authoring Methods

    You can author workflows using three distinct methods, all of which compile to the same in-memory activity graph:

    1. Typed C# Classes: Classes derived from WorkflowBase.
    2. JSON Definitions: Definitions loaded at runtime from a file system or data store.
    3. ElsaScript: .elsa text files that are parsed and compiled at application startup.