Commit Graph

17 Commits

Author SHA1 Message Date
Lucas Berger 87c7bf75e5 fix(04): correct connection source names for logs nodes
Connection keys referenced hyphenated IDs (code-parse-logs) instead of
actual node names (Parse Logs Command). Fixed 10 connection sources to
use proper node names.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:01:27 -05:00
Lucas Berger 01667b0bdb feat(04-02): integrate Claude API for natural language understanding
Tasks 1-3 complete:

Task 1: Claude API HTTP Request node
- POST to api.anthropic.com/v1/messages
- Uses claude-sonnet-4-5-20250929 with prompt caching
- System prompt defines 6 intent actions
- 30s timeout, 3 retries

Task 2: Intent parsing and validation
- Parse Intent Code node validates Claude response
- Strips markdown, validates actions, normalizes container names
- Error handling for malformed responses
- Preserves original message for fallback

Task 3: Intent-first routing
- Rewired auth -> Claude Intent Parser flow
- Intent Router Switch with 7 outputs
- Routes to existing handlers: logs, actions, status
- New handlers: unknown intent, stats placeholder, error
- Updated Parse and Match to use intent.container
- Updated Parse Action to use intent data
- Updated Parse Logs Command to use intent structure
2026-01-30 21:45:49 -05:00
Lucas Berger 93c40fed66 feat(04-01): add logs command routing to workflow
- Add logs command route in Route Message switch node
- Pattern matches: 'logs <container>' or 'show logs <container>'
- Create Parse Logs Command node to extract container name and line count
- Support optional line count parameter (default 50, max 1000)
- Examples: 'logs plex', 'show logs sonarr', 'logs nginx 100'

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:42:48 -05:00
Lucas Berger 04321c1c9a feat(03-04): implement container update workflow
Add complete update command flow with image pull and container recreation:

- Parse update command and extract container query
- Match container using fuzzy matching (single match only for update)
- Handle no-match and multiple-match cases with appropriate messages
- Inspect container to extract current config
- Pull latest image from registry
- Compare image digests to detect if update is available
- Stay silent if no update needed (per CONTEXT.md)
- Stop container with graceful 10-second timeout
- Remove old container
- Create new container preserving Config, HostConfig, Networks
- Start new container
- Report version change (from image labels or ID substring)

Nodes added:
- Parse Update Command, Docker List for Update, Match Update Container
- Check Update Match Count, Handle Update Multiple, Send Update Error/No Match/Multiple
- Build Inspect Command, Inspect Container, Parse Container Config
- Build Pull Command, Pull Image, Build Image Inspect, Inspect New Image
- Compare Digests, Check If Update Needed
- Build Stop Command, Stop Container, Verify Stop Build Remove
- Remove Container, Build Create Body, Build Create Command
- Create Container, Parse Create Response
- Build Start Command, Start New Container
- Format Update Result, Send Update Result

Closes all 3 tasks of 03-04-PLAN.md
2026-01-30 13:26:32 -05:00
Lucas Berger 6737ef09c8 feat(03-03): clean up UI after batch action
- Add Answer Batch Query to dismiss callback loading state
- Add Delete Batch Confirm Message to remove confirmation message
- Add Send Batch Result to display final success/failure message
- Wire up complete flow: Format Result -> Answer -> Delete -> Send
- UI cleanup keeps chat clean with only result message remaining
2026-01-30 08:48:04 -05:00
Lucas Berger 25a7994fcb feat(03-03): handle batch confirmation callback execution
- Update Parse Callback Data to detect batch (c is array) vs single
- Add isBatch and containerIds fields to callback data
- Add 'batch' route in Route Callback switch (output 2)
- Add Build Batch Commands node to prepare curl commands for each container
- Add Prepare Batch Execution to combine commands with result markers
- Add Execute Batch Action to run all container actions sequentially
- Add Parse Batch Result to parse RESULT_N:statusCode output
- Add Format Batch Result to build success/failure message
2026-01-30 08:47:27 -05:00
Lucas Berger ab8d5282c0 feat(03-03): build batch confirmation keyboard with inline buttons
- Replace placeholder 'Format Multiple Matches' with 'Build Batch Keyboard'
- Create inline_keyboard with 'Yes, <action> N containers' and 'Cancel' buttons
- Encode batch container IDs in callback_data (limit 4 for 64-byte constraint)
- Use HTTP Request for sendMessage (same pattern as suggestion flow)
- Format container list with bullet points in confirmation message
2026-01-30 08:45:56 -05:00
Lucas Berger 768d7584e2 feat(03-02): handle suggestion callback and execute action
- Add Parse Callback Data code node to decode callback_query JSON
- Add Route Callback switch for cancel/expired/execute branches
- Add Handle Cancel with answer query and delete message
- Add Handle Expired with alert message and delete message
- Add Build Callback Action to construct curl command from callback
- Add Execute Callback Action to run Docker API call
- Add Parse Callback Result to check status and build response
- Add Answer Action Query, Delete Suggestion Message, Send Callback Result
- 2-minute timeout enforced via timestamp in callback_data
2026-01-30 08:42:43 -05:00
Lucas Berger 56eea26d44 feat(03-02): implement suggestion flow for no-match cases
- Replace Format No Match with Find Closest Match code node
- Add Check Suggestion IF node to route based on hasSuggestion
- Add Build Suggestion Keyboard code node for inline button payload
- Add Send Suggestion HTTP Request to Telegram API with inline_keyboard
- Update Match Container to include allContainers for suggestion logic
- Suggestion shown when score >= 2 (partial match found)
2026-01-30 08:41:27 -05:00
Lucas Berger 2cbf6e7ec7 feat(03-02): configure Telegram Trigger for callback queries
- Update Telegram Trigger to receive both message and callback_query updates
- Add Route Update Type switch to route messages vs callbacks
- Add IF Callback Authenticated node for callback query auth
- Restructure connections: message flow through auth, callback through separate auth
2026-01-30 08:40:15 -05:00
Lucas Berger 2bd90c8a0c feat(03-01): add error handling for action flow
- Add docker-error route to Check Match Count switch (matchCount < 0)
- Add Send Docker Error node for Docker connection failures
- Route Docker API errors to user-facing error messages
- Ensure all error paths reach a Send Message node (no silent failures)
- Error messages include diagnostic details per CONTEXT.md requirements
2026-01-30 08:36:44 -05:00
Lucas Berger f466a2916e feat(03-01): implement container matching and action execution
- Add Docker List for Action node to get container list
- Add Match Container node with fuzzy matching (substring, prefix stripping)
- Add Check Match Count Switch node to route 0/1/>1 matches
- Add Build Action Command node to construct curl POST command
- Add Execute Action node to call Docker API start/stop/restart
- Add Parse Action Result node handling 204/304 success and error codes
- Add Send Action Result node for Telegram response
- Add placeholder nodes for No Match and Multiple Matches branches
- Use graceful ?t=10 timeout for stop/restart actions
2026-01-30 08:35:38 -05:00
Lucas Berger 4848e7db16 feat(03-01): add action command routing to workflow
- Add new route in Switch node for start/stop/restart commands
- Route matches case-insensitive startsWith for each action
- Add Parse Action Code node to extract action type and container name
- Action branch routes to Parse Action, ready for container matching
2026-01-30 08:33:47 -05:00
Lucas Berger 8e155c55de fix(02-02): fix false positive docker connection error
- Add -s (silent) flag to curl to suppress progress output
- Change error handling to only check stdout for valid JSON
- Ignore stderr which contains curl progress info
2026-01-29 14:39:14 -05:00
Lucas Berger 1252ff42f4 feat(02-02): add Docker query branch to workflow
- Add Switch node to route messages based on content
- Add Execute Command node with curl to Docker API
- Add Parse and Match code node with fuzzy matching
- Add Format Response code node with emoji mapping
- Preserve echo branch for non-docker messages
- Handle summary, single match, multiple matches, and errors
2026-01-29 14:28:01 -05:00
Lucas Berger 23c5705050 fix(01-01): hardcode user ID instead of env var
n8n community edition blocks env var access in expressions.
Hardcoded TELEGRAM_USER_ID for single-user authentication.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:25:33 -05:00
Lucas Berger 9d503bb9a8 feat(01-01): create n8n workflow for telegram echo bot
- Telegram Trigger node listens for messages
- IF node authenticates via $env.TELEGRAM_USER_ID
- Code node formats echo with timestamp
- Telegram Send node replies to authorized users
- False branch has no connections (silent ignore)
2026-01-28 19:47:39 -05:00