Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.medera.info/llms.txt

Use this file to discover all available pages before exploring further.

┌──────────────────────────────────────────────────────────────────┐
│        Canvas (Frontend) — AgentBuilderContext, AgentCanvas      │
└──────────────────────────────────┬───────────────────────────────┘
                                   │ REST + Socket.IO

┌──────────────────────────────────────────────────────────────────┐
│    Backend /api/agent-workflows + /api/deployments + /api/care-* │
│           Auth · Tenant Context · PHI Audit · Subscription       │
└─┬────────────────────────────────────────────────────────────────┘

  ├─ workflow-engine (Node.js)
  │   ├─ WorkflowExecutor (471L) — _executeNode, _updateExecution, RLS
  │   ├─ ExecutionContext (354L) — resolveVariable, executionTrace[]
  │   └─ WorkflowQueue (285L) — Bull on Redis DB 2, 5 concurrent workers

  └─ Care Orchestrator (AI Services, port 8000)
      ├─ /api/care-orchestrator/workflows · /agents · /tasks · /voice
      ├─ AgentType enum (INTAKE, CARE_COORDINATOR, REFERRAL_SPECIALIST, …)
      ├─ Workflow State Machine (30+ states across Referral / Rx / Lab / Care Plan)
      └─ Event Bus (INTAKE_*, PA_*, REFERRAL_*, PRESCRIPTION_*, LAB_*)

Workflow execution

client → POST /api/agent-workflows/:id/execute
backend → insert into agent_workflow_executions (status=pending)
backend → WorkflowQueue.queueWorkflowExecution(executionId, ...)
       │ (graceful sync fallback if Redis unavailable)

worker → load execution + version snapshot
       → WorkflowExecutor.execute(executionId, organizationId)
            ├─ executeInOrgScope() — SET LOCAL app.current_organization_id
            ├─ find start node
            └─ loop _executeNode(node, context)
                  ├─ dispatch to NodeRunner.execute()
                  ├─ on success → route to next nodes
                  ├─ on { paused: true } → halt + persist state
                  └─ on error → route to error port (or re-throw)
worker → update agent_workflow_executions (status=completed|failed|paused)
worker → emit workflow:execution:* on Socket.IO

Real-time events (Socket.IO)

Emitted to the org room and per-execution room:
EventWhen
workflow:execution:startedExecution claimed by a worker
workflow:node:executing_executeNode invoked
workflow:node:completedNode returned success()
workflow:ehr-syncehr-sync node touched a connected EHR
workflow:execution:pauseduser-approval returned { paused: true }
workflow:execution:completedReached end node
workflow:execution:failedUnhandled node error

Tenant isolation

Background workers obtain a Postgres connection and immediately run SET LOCAL app.current_organization_id = '<org_id>' inside a transaction. RLS policies enforce that every read / write is filtered by organization_id.

Versioned execution

For published executions, the executor loads the immutable snapshot from agent_workflow_versions — draft edits made to the same workflow after the publish do not affect running executions.