Commit Graph

230 Commits

Author SHA1 Message Date
Lucas Berger e5c02f9a21 docs: complete v1.0 milestone - Phase 5 Plan 3 approved
- Add 05-03-SUMMARY.md documenting testing session and bug fixes
- Update STATE.md to 100% complete
- Update ROADMAP.md marking all Phase 5 plans complete
- Remove .continue-here checkpoint

v1.0 Docker Manager Bot is production-ready:
- All 6 commands working (status, start, stop, restart, update, logs)
- Keyword routing (no Claude API dependency)
- Single-user Telegram auth
- Terse error messages
- Complete deployment README

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 21:48:22 -05:00
Lucas Berger c979a7fe7b feat(update): notify user when container is already up to date
Previously the "no update needed" branch was empty, leaving users
with no feedback after the update check completed.

Added Format No Update and Send No Update nodes to display
"<container> is already up to date" message.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 21:39:08 -05:00
Lucas Berger 808d1afe21 fix(logs): correct property name for line count parameter
Parse Logs Command returned 'lineCount' but Match Logs Container
expected 'lines', causing the line count to always be undefined
and Docker to return its default.

Renamed to 'lines' for consistency throughout the logs flow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 21:33:39 -05:00
Lucas Berger 287c7220cb fix(logs): escape HTML entities in log output
Log content may contain <, >, & characters (like "<computed>") which
Telegram interprets as HTML tags when using parse_mode=HTML.

Added escapeHtml() function to convert:
- & → &amp;
- < → &lt;
- > → &gt;

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 21:31:22 -05:00
Lucas Berger 74dd8f1a94 fix(update): ensure image tag is specified to prevent pulling all tags
When Config.Image has no tag (e.g., "nitnelave/lldap" instead of
"nitnelave/lldap:latest"), Docker's API pulls ALL tags for that image.
This caused massive downloads and rate limit hits.

Now appends ":latest" if no tag or digest is present in the image name.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 21:21:57 -05:00
Lucas Berger 3e3b9ae47f fix(update): pipe pull output through tail to prevent memory exhaustion
Docker's /images/create API streams progress JSON for every layer.
For large images, this can be gigabytes of output that was being
buffered by curl and n8n, causing hangs and disk usage spikes.

Now pipes through `tail -c 10000` to only keep the last 10KB where
error/success messages appear. Discards the streaming progress data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 21:14:25 -05:00
Lucas Berger 88830a8b61 fix(update): correct image removal node data reference
- Reference $('Format Update Result') instead of $json for currentImageId
- The Telegram node doesn't pass through input data, it returns API response
- Also add no-op command fallback when currentImageId is missing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 20:56:00 -05:00
Lucas Berger 4f85e00dc4 fix(update): add timeout to prevent pull command from hanging
- Add --max-time 600 (10 min) to curl pull command
- Add timeout: 660 to n8n executeCommand node

Docker's /images/create API streams progress until complete.
Without timeout, large image pulls could hang indefinitely.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 20:50:22 -05:00
Lucas Berger b0b22c3b39 wip: 05-polish-deploy paused at task 2/2 (testing checkpoint)
Testing session found and fixed multiple issues:
- Show Menu keyboard/HTML issues
- Container exact match priority
- Update acknowledgment and error handling
- Old image removal after update

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 22:08:43 -05:00
Lucas Berger d03e79cc7f feat(05): add update acknowledgment and pull error handling
1. Send "Updating <container>..." message immediately when update starts
   so user knows the command was received during long image pulls

2. Check pull response for rate limiting and other errors before
   continuing with update. Errors like "toomanyrequests" now show
   a proper error message instead of silently failing to update.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 22:07:40 -05:00
Lucas Berger 0839c44b50 feat(05): remove old image after successful container update
Mimics Unraid's update behavior by removing the orphan image after
the new container is started. The old image ID is now passed through
the entire update flow and used to call DELETE /images/{id} at the end.

Removal is fire-and-forget with force=false so it will fail gracefully
if another container still uses the image.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:58:41 -05:00
Lucas Berger 004911ea32 fix(05): improve container matching to prioritize exact matches
Fixed matching in Match Container, Match Update Container, and Match
Logs Container nodes:
1. First check for exact name match (e.g., "jellyplex" matches only jellyplex)
2. Then fall back to substring matching (container name contains query)
3. Removed reverse matching (query contains container name) which caused
   "jellyplex" to incorrectly match "plex"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:41:27 -05:00
Lucas Berger 0b6dfe69d9 fix(05-01): escape angle brackets in Show Menu text
Changed <name> to [name] to avoid HTML parse errors in Telegram.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:36:23 -05:00
Lucas Berger 0b140c4f1e fix(05-01): simplify Show Menu to text-only help message
Native Telegram node replyKeyboard wasn't displaying. Fallback to
simple text message listing available commands. Can revisit persistent
keyboard feature later.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:34:45 -05:00
Lucas Berger 6defb2daaf fix(05-01): switch Show Menu to native Telegram node
HTTP Request node with $credentials reference was causing 404 errors.
Native Telegram node handles credentials more reliably for static menus.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:31:16 -05:00
Lucas Berger 32fd965a2f fix(05-02): revert credential reference to hardcoded user ID
n8n IF nodes don't support credentials - $credentials syntax only works
in nodes that make external calls. Reverted to direct user ID in the
IF conditions and updated README with simpler configuration instructions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:28:20 -05:00
Lucas Berger e92bfc8061 docs(05-03): write deployment README
- Step-by-step installation guide for Unraid
- n8n container configuration with Docker socket access
- Credential creation instructions for Telegram API and Auth
- Usage section with all 6 commands documented
- No troubleshooting section (focused on initial setup)
2026-01-31 21:18:27 -05:00
Lucas Berger 09a4c9ba07 docs(05-02): complete error hardening and credential migration plan
Tasks completed: 2/2
- Standardize error messages to terse format
- Migrate user ID to n8n credentials system

SUMMARY: .planning/phases/05-polish-deploy/05-02-SUMMARY.md
2026-01-31 21:16:36 -05:00
Lucas Berger 1e6c31f790 feat(05-02): migrate user ID to n8n credentials system
- Auth nodes now reference $credentials.telegramAuth.userId
- Added telegramAuth credential reference to both IF nodes
- Removed hardcoded user ID from workflow JSON
- Workflow can now be safely exported/shared
2026-01-31 21:15:20 -05:00
Lucas Berger cab0914788 chore(05-02): standardize error messages to terse format
- Docker socket errors now show 'Cannot connect to Docker'
- Action failures now show 'Failed to {action} {container}'
- Removed HTTP status codes and technical details from error messages
- Simplified callback action error handling
2026-01-31 21:14:36 -05:00
Lucas Berger 9ae500cdf5 docs(05-01): complete NLU cleanup plan
Tasks completed: 2/2
- Task 1: Remove NLU/Claude nodes and add Keyword Router
- Task 2: Add persistent Telegram menu

SUMMARY: .planning/phases/05-polish-deploy/05-01-SUMMARY.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:11:01 -05:00
Lucas Berger a29f444e08 feat(05-01): replace NLU/Claude with keyword routing
- Remove Prepare Claude Request, Claude Intent Parser, Parse Intent,
  Intent Router, Send Unknown Intent, Send Intent Error nodes
- Remove Anthropic API credential reference
- Rename Route Message to Keyword Router with updated rules
- Update IF User Authenticated to connect to Keyword Router
- Update Parse and Match to work without NLU context
- Update Parse Action Command to parse from message text directly
- Update Match Container to reference Parse Action Command
- Update Parse Logs Command to work with keyword routing

Keyword Router handles: /start, status, restart, start, stop,
update, logs with fallback to menu

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:09:33 -05:00
Lucas Berger b7cefd931e docs(05): create phase plan
Phase 05: Polish & Deploy
- 3 plans in 3 waves
- 1 parallel (Wave 1), 2 sequential (Waves 2-3)
- Ready for execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:00:51 -05:00
Lucas Berger 4c09d61943 docs(05): research phase domain
Phase 5: Polish & Deploy
- Standard stack identified (n8n, Telegram Bot API, Docker)
- Architecture patterns documented (Switch routing, persistent keyboards, error workflows)
- Pitfalls catalogued (credential leaks, testing limitations, configuration issues)
- Code examples for keyword routing, persistent menus, error handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 20:55:29 -05:00
Lucas Berger fc1eda2b07 docs(05): capture phase context
Phase 05: Polish & Deploy
- Implementation decisions documented
- Phase boundary established

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 20:49:04 -05:00
Lucas Berger b82ce152bb docs: add NLU workflow cleanup to Phase 5
Workflow currently has Claude API nodes that need removal.
Added to Phase 5 scope along with keyword routing replacement.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:54:25 -05:00
Lucas Berger 21e888c1ce docs: remove NLU from v1.0 scope
- Remove Claude API integration and intent parsing (04-02-PLAN)
- REQ-08 (conversational queries) moved to out of scope
- Phase 4 renamed from "Logs & Intelligence" to "Logs" (complete)
- v1.0 now focuses on keyword-based container control

Simple substring matching works well for container management.
NLU adds complexity without proportional value for v1.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:52:37 -05:00
Lucas Berger 9ae67ccd7b wip: phase 4 paused at checkpoint verification
Multiple workflow bugs fixed during testing. Awaiting user
verification of conversational routing via Telegram.
2026-01-30 22:38:18 -05:00
Lucas Berger 5e7cab54ca fix(batch): convert Send Batch Confirmation to native Telegram node
HTTP Request node with credential access via URL expression was
failing. Native Telegram node handles credentials internally and
is more reliable for this use case.
2026-01-30 22:37:09 -05:00
Lucas Berger 23ce6a88d5 fix(batch): add chatId validation in Build Batch Keyboard
Add defensive error handling to throw clear error if chatId is
missing before attempting to send Telegram message. This helps
debug 'resource not found' errors by identifying data flow issues.
2026-01-30 22:36:44 -05:00
Lucas Berger 5d55bdecac fix(04): fix type validation in all Switch nodes with number comparisons
Fixed Check Match Count and Check Update Match Count nodes:
- Changed typeValidation from 'strict' to 'loose'
- Changed rightValue from strings ('0', '1') to numbers (0, 1)
- Removed empty leftValue from options

This fixes 'Wrong type: string but expecting number' errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:26:08 -05:00
Lucas Berger aa677703c9 fix(04): update Match Container to use Parse Intent
Changed Match Container to get action data from Parse Intent node
instead of the old Parse Action node which isn't executed in the
intent-based routing flow.

Mapping:
- action -> intent.parameters.action
- containerQuery -> intent.container
- chatId -> intent.original_message.chat.id

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:21:37 -05:00
Lucas Berger d842efbf17 fix(04): bypass Format Response for intent-based status queries
Parse and Match now returns formatted text directly, so Format Response
node is redundant. Connect Parse and Match directly to Send Docker Response
to avoid 'Unexpected response format' error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:18:44 -05:00
Lucas Berger ada8800bff fix(04): fix Check Logs Match Count type validation
Changed typeValidation from 'strict' to 'loose' and rightValue from
strings to numbers to fix type mismatch error in Switch node conditions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:13:56 -05:00
Lucas Berger f423f4ae4c fix(04): add Prepare Claude Request node for robust API body
Split Claude API call into two nodes:
- Prepare Claude Request: Code node that builds the request body
- Claude Intent Parser: HTTP Request node that sends the request

This fixes the 'model: Field Required' error caused by complex
expression evaluation issues in the HTTP Request node's jsonBody.

Also updated Parse Intent to get original message from the new node.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:10:50 -05:00
Lucas Berger a08b8dba6b fix(04): fix Route Update Type conversion error
Removed empty leftValue from options and changed condition check from
object notEmpty to string notEmpty using optional chaining on specific
properties (message?.text, callback_query?.id).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:05:34 -05:00
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 f883908a7b docs(04-01): complete container log retrieval plan
Tasks completed: 3/3
- Add logs command routing to workflow
- Implement Docker logs API call with formatting
- Handle Docker log stream binary format

SUMMARY: .planning/phases/04-logs-intelligence/04-01-SUMMARY.md
2026-01-30 21:44:54 -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 0ee37acfec phase 4 planning 2026-01-30 15:29:24 -05:00
Lucas Berger 0f1ceba947 docs(04): research phase domain
Phase 04: Logs & Intelligence
- Standard stack identified
- Architecture patterns documented
- Pitfalls catalogued

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:55:20 -05:00
Lucas Berger fce57d9bd8 docs(03): complete container-actions phase 2026-01-30 13:31:07 -05:00
Lucas Berger e9a76852eb docs(03-04): complete container update plan
Tasks completed: 3/3
- Update command routing and container matching
- Image pull and change detection
- Container recreation workflow

SUMMARY: .planning/phases/03-container-actions/03-04-SUMMARY.md
Phase 3 complete - all container actions implemented
2026-01-30 13:27:43 -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 818b403c95 docs(03): pause work - update action plan interrupted 2026-01-30 13:19:13 -05:00
Lucas Berger f503d3e68b docs(03-03): complete batch confirmation flow plan
Tasks completed: 3/3
- Build batch confirmation message with inline keyboard
- Handle batch confirmation callback
- Clean up UI after batch action

SUMMARY: .planning/phases/03-container-actions/03-03-SUMMARY.md
2026-01-30 08:49:02 -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