How aotol/ai_automation works
Purpose and Entry Points
Node.js CLI framework for controlled AI automation: an LLM may choose approved skills and fill parameters, while code validates and executes every transition. CLI and admin workflow commands enter via src/app.js; programmatic callers construct TaskEngine from src/task-engine.js.
Composition Root and Runtime Services
Configuration is loaded from config.json through src/config.js. The runtime is Node.js 18+, with Ollama as the local LLM endpoint, SQLite for durable state, and optional SMTP/IMAP email infrastructure. src/logger.js provides operational event logging.
Task Orchestration State Machine
src/task-engine.js owns the task lifecycle: normalize input, locate/reuse or create a workflow, build step payloads, execute steps serially, validate outputs, persist progress, and return task/workflow/step results. It is the trust boundary: LLM output informs plans but never directly controls arbitrary execution.
Input, Planning, and Guardrails
src/input-provider.js accepts and bounds raw requests. src/prompt-builder.js creates restricted planning and parameter-filling prompts from registered skills and prior context; src/llm-provider.js invokes Ollama. src/validators.js validates structured LLM responses and state transitions. New plans are limited to known skill names and can produce parameter-retrieval guardrails for retries on later matching inputs.
Dynamic Skill Registry and Execution
src/skills-loader.js discovers skill modules under src/skills/; src/skill-utils.js supports their shared execution/data behavior. Each skill exposes a named atomic operation, payload schema, executor, and result validator. Representative boundary-facing skills include web acquisition (src/skills/fetch_url.js, src/skills/search_web.js), content processing (src/skills/extract_text_from_html.js, src/skills/summarize_text.js, src/skills/translate_text.js), and email I/O (src/skills/receive_email.js, src/skills/send_email.js).
Data Flow Between Steps
A request becomes a normalized reusable template, then an ordered skill plan. For each plan item, payload filling receives the raw request, skill payload definition, and accumulated prior outputs. Step results become execution context for downstream skills, are validated after execution, and are persisted. The final result contains identifiers, workflow provenance, normalized template, plan, and step outputs.
Persistence and Workflow Governance
src/task-repository.js encapsulates SQLite initialization and access for tasks, ordered task steps, events, and workflow templates. Templates are keyed by normalized request patterns and carry active/inactive/rejected status. Active templates bypass planning; inactive matches require administrative approval; execution failures may inactivate reusable workflows. Admin controls are routed through src/app.js.
Main entry points: task-engine.js TaskEngine · skills-loader.js Skills loader · fetch_url.js Web acquisition skills · receive_email.js Email I/O skills
Components 18
Entry & Control
- CLI & admin commands · Starts task runs and workflow governance actions.
src/app.js - Configuration
src/config.js - Operational logger
src/logger.js
Task Orchestration
- TaskEngine · Trust boundary for the serial task lifecycle.
src/task-engine.js - Input provider · Bounds and normalizes raw requests.
src/input-provider.js
AI Planning & Validation
- Prompt builder · Restricts planning and parameter-filling context to registered skills.
src/prompt-builder.js - LLM provider
src/llm-provider.js - Validators · Validates LLM structures, transitions, and skill results.
src/validators.js - Ollama endpoint
Skill Execution
- Skills loader · Discovers approved atomic skill modules.
src/skills-loader.js - Skill utilities
src/skill-utils.js - Web acquisition skills · Fetch URL and web search operations.
src/skills/fetch_url.js - Content processing skills · HTML extraction, summarization, and translation.
src/skills/extract_text_from_html.js - Email I/O skills · Receive and send email operations.
src/skills/receive_email.js - Web services
- SMTP / IMAP
Durable State
- Task repository · Manages tasks, ordered steps, events, and workflow templates.
src/task-repository.js - SQLite
Connections 23
- CLI & admin commands → TaskEngine: runs tasks and admin actions
- Configuration → TaskEngine: runtime settings
- Configuration → LLM provider: endpoint settings
- TaskEngine → Input provider: normalizes request
- TaskEngine → Task repository: loads templates; persists progress
- Task repository → SQLite: stores tasks, steps, events, templates
- TaskEngine → Skills loader: loads approved registry
- TaskEngine → Prompt builder: builds plan and payload prompts
- Prompt builder → LLM provider: restricted prompts
- LLM provider → Ollama endpoint: inference
- TaskEngine → Validators: validates plans, transitions, outputs
- Skills loader → Web acquisition skills: discovers
- Skills loader → Content processing skills: discovers
- Skills loader → Email I/O skills: discovers
- TaskEngine → Web acquisition skills: executes serial plan steps
- TaskEngine → Content processing skills: passes prior step context
- TaskEngine → Email I/O skills: executes validated payloads
- Web acquisition skills → Skill utilities: shared execution support
- Content processing skills → Skill utilities: shared execution support
- Email I/O skills → Skill utilities: shared execution support
- Web acquisition skills → Web services: acquires content
- Email I/O skills → SMTP / IMAP: receives and sends
- TaskEngine → Operational logger: operational events