33800 Docs

← Retour

Backlog: Actions & Routines pour Connectors Hub

Date: 28/01/2026 Priorite: HAUTE Status: IDEE / CONCEPTION

Vision

Transformer Connectors Hub en plateforme d'automatisation legere type n8n, avec :

Concept

┌─────────────────────────────────────────────────────────────────────────┐
│                         CONNECTORS HUB v2                                │
│                                                                          │
│  ┌──────────────┐     ┌──────────────┐     ┌──────────────┐            │
│  │   ACTION 1   │────►│   ACTION 2   │────►│   ACTION 3   │            │
│  │  SSH: top    │     │ API: parse   │     │ Notif: send  │            │
│  └──────────────┘     └──────────────┘     └──────────────┘            │
│        │                    │                    │                      │
│        ▼                    ▼                    ▼                      │
│     output              input/output          input                     │
│   (stdout)              (json)               (message)                  │
│                                                                          │
│  ROUTINE: "Server Health Check"                                         │
│  Trigger: cron 0 8 * * * | manual | webhook                            │
└─────────────────────────────────────────────────────────────────────────┘

1. Actions

Definition

Une action est une unite atomique associee a un connecteur et reutilisable.

interface Action {
  id: string;
  name: string;
  description: string;
  connector_type: string;      // ssh, jellyfin, proxmox...
  instance_id?: string;        // instance specifique ou any

  // Configuration selon type
  config: SSHActionConfig | APIActionConfig;

  // Schema I/O
  input_schema?: JSONSchema;   // params attendus
  output_schema?: JSONSchema;  // structure output

  // Metadata
  user_id: string;
  is_public: boolean;          // partage entre users
  created_at: Date;
}

Actions SSH

Plus complexe car output = stdout/stderr brut.

interface SSHActionConfig {
  type: 'command' | 'script' | 'sftp';

  // Pour command/script
  command?: string;            // "apt update && apt upgrade -y"
  script?: string;             // contenu script bash
  sudo?: boolean;
  timeout?: number;

  // Pour sftp
  sftp_operation?: 'upload' | 'download' | 'list';
  remote_path?: string;
  local_path?: string;

  // Parsing output
  output_parser?: 'raw' | 'json' | 'lines' | 'table' | 'regex';
  parser_config?: {
    regex?: string;
    columns?: string[];        // pour table (top, ps, df...)
    json_path?: string;        // jq-like extraction
  };
}

Exemples actions SSH predefinies :

Action Commande Output Parser
system-update apt update && apt upgrade -y raw
disk-usage df -h table (columns: filesystem, size, used, avail, use%, mount)
top-snapshot top -bn1 | head -20 table
docker-ps docker ps --format json json
service-status systemctl status {service} regex
tail-logs tail -n {lines} {path} lines

Actions API

Plus simple car input/output = JSON structure.

interface APIActionConfig {
  method: 'GET' | 'POST' | 'PUT' | 'DELETE';
  path: string;                // "/api/nodes/{node}/status"

  // Params avec placeholders
  path_params?: Record<string, string>;   // {node} -> "pve"
  query_params?: Record<string, any>;
  body?: any;
  headers?: Record<string, string>;

  // Extraction output
  output_path?: string;        // "data.status" -> extrait ce champ
}

Exemples actions API predefinies :

Connecteur Action Path Output
Proxmox get-node-status /api2/json/nodes/{node}/status {cpu, memory, uptime}
Proxmox list-vms /api2/json/nodes/{node}/qemu [{vmid, name, status}]
Jellyfin get-sessions /Sessions [{user, device, playing}]
Jellyfin scan-library POST /Library/Refresh {success}
Portainer list-containers /endpoints/{id}/docker/containers/json [{name, status}]

2. Routines

Definition

Une routine est un enchainement d'actions avec gestion du flux de donnees.

interface Routine {
  id: string;
  name: string;
  description: string;
  user_id: string;

  // Steps
  steps: RoutineStep[];

  // Triggers
  triggers: RoutineTrigger[];

  // Config globale
  timeout?: number;
  on_error: 'stop' | 'continue' | 'retry';
  retry_count?: number;

  // Metadata
  is_enabled: boolean;
  last_run?: Date;
  last_status?: 'success' | 'error' | 'running';
}

interface RoutineStep {
  id: string;
  action_id: string;           // reference action

  // Mapping input depuis steps precedents
  input_mapping?: {
    [param: string]: string;   // "node" -> "{{steps.0.output.node}}"
  };

  // Conditions
  condition?: string;          // "{{steps.0.output.status}} == 'running'"

  // Flow control
  on_success?: string;         // step_id ou 'next' ou 'end'
  on_error?: string;
}

interface RoutineTrigger {
  type: 'manual' | 'cron' | 'webhook' | 'event';

  // Pour cron
  cron_expression?: string;    // "0 8 * * *"

  // Pour webhook
  webhook_secret?: string;

  // Pour event (futur)
  event_type?: string;         // "container.stopped"
  event_filter?: any;
}

Exemples de routines

1. Daily Server Health Check

name: Daily Health Check
triggers:
  - type: cron
    cron_expression: "0 8 * * *"
steps:
  - action: ssh/disk-usage
    instance: prod-portainer
  - action: ssh/docker-ps
    instance: prod-portainer
  - action: api/proxmox/get-node-status
    input: { node: "pve" }
  - action: notification/send
    input:
      title: "Health Report"
      body: "{{summary}}"

2. Auto-update servers

name: Weekly Updates
triggers:
  - type: cron
    cron_expression: "0 3 * * 0"  # Dimanche 3h
steps:
  - action: ssh/system-update
    instance: prod-portainer
    on_error: continue
  - action: ssh/system-update
    instance: nginx
    on_error: continue
  - action: notification/send
    input:
      title: "Updates terminés"

3. Backup avant maintenance

name: Pre-maintenance Backup
triggers:
  - type: manual
  - type: webhook
steps:
  - action: api/proxmox/snapshot-vm
    input: { node: "pve", vmid: "{{input.vmid}}" }
  - action: ssh/docker-compose-down
    instance: prod-portainer
    condition: "{{input.stop_docker}}"

3. Interface UI

Page Actions

/connectors/actions
├── Liste actions (filtre par connecteur, user/public)
├── Bouton "Nouvelle action"
└── Pour chaque action:
    ├── Run manuel avec params
    ├── Voir historique executions
    └── Edit/Delete

Page Routines

/connectors/routines
├── Liste routines (actives/inactives)
├── Bouton "Nouvelle routine"
└── Pour chaque routine:
    ├── Visual workflow builder (drag & drop steps)
    ├── Run manuel
    ├── Historique runs avec logs
    ├── Enable/Disable
    └── Edit triggers

Workflow Builder

Interface visuelle type n8n simplifiee :

4. Schema DB (Supabase)

-- Actions
CREATE TABLE actions (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES auth.users,
  name VARCHAR(100) NOT NULL,
  description TEXT,
  connector_type VARCHAR(50) NOT NULL,
  instance_id UUID REFERENCES connector_instances,
  config JSONB NOT NULL,
  input_schema JSONB,
  output_schema JSONB,
  is_public BOOLEAN DEFAULT false,
  created_at TIMESTAMPTZ DEFAULT now(),
  updated_at TIMESTAMPTZ DEFAULT now()
);

-- Routines
CREATE TABLE routines (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES auth.users,
  name VARCHAR(100) NOT NULL,
  description TEXT,
  steps JSONB NOT NULL,
  triggers JSONB NOT NULL,
  timeout INTEGER DEFAULT 300,
  on_error VARCHAR(20) DEFAULT 'stop',
  is_enabled BOOLEAN DEFAULT true,
  created_at TIMESTAMPTZ DEFAULT now(),
  updated_at TIMESTAMPTZ DEFAULT now()
);

-- Executions (historique)
CREATE TABLE routine_executions (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  routine_id UUID REFERENCES routines,
  trigger_type VARCHAR(20),
  status VARCHAR(20),
  started_at TIMESTAMPTZ DEFAULT now(),
  completed_at TIMESTAMPTZ,
  steps_results JSONB,  -- output de chaque step
  error_message TEXT
);

-- Actions executions (pour actions standalone)
CREATE TABLE action_executions (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  action_id UUID REFERENCES actions,
  user_id UUID REFERENCES auth.users,
  input JSONB,
  output JSONB,
  status VARCHAR(20),
  duration_ms INTEGER,
  executed_at TIMESTAMPTZ DEFAULT now()
);

5. Implementation phases

Phase 1 : Actions simples - FAIT (28/01/2026)

Phase 1.5 : Input parametrable - A FAIRE

Phase 2 : Routines basiques

Phase 3 : Triggers & scheduling

Phase 4 : Avance

Notes techniques

Parsing SSH output

Le plus complexe. Solutions :

  1. Table parser : regex pour colonnes (df, ps, top)
  2. JSON mode : forcer --format json quand dispo (docker)
  3. Custom regex : user definit son pattern
  4. AI parsing : envoyer a LLM pour extraction (couteux)

Securite

Performance

Liens