diff --git a/loop/plan.md b/loop/plan.md index 4400de33..2b5ece5d 100644 --- a/loop/plan.md +++ b/loop/plan.md @@ -42,38 +42,44 @@ Currently `wallet` and `files` return placeholders. Wire up real data from store - [ ] **TEST:P2** — Run `cd neode-ui && npm run type-check && npm run build`. Fix all errors. Deploy: `./scripts/deploy-to-target.sh --live`. SSH to server and verify the deployed build loads. -## Phase 3: Action Handlers +## Phase 3: Nginx Proxies & Action Handlers -Expand the ContextBroker's action handling so AIUI can trigger real operations. +Critical: AIUI needs nginx proxies for API calls when deployed on the node. Also expand action handling. -- [ ] **T14** — Add `launch-app` action. When AIUI requests `action:request` with `action: 'launch-app'`, return the app's web UI URL so AIUI can tell the user where to go (or Archy can open it). Validate appId exists and is running. +- [ ] **T14** — Add nginx proxy for AIUI Claude API calls. AIUI's Claude provider hits `/api/claude/v1/messages` which, when served from `/aiui/`, becomes `/aiui/api/claude/v1/messages`. Add an nginx location block in `image-recipe/configs/nginx-archipelago.conf` that proxies `/aiui/api/claude/` to `https://api.anthropic.com/` (pass-through). This lets AIUI make Claude API calls through the node's nginx without CORS issues. The user's API key is sent in the request header by AIUI — nginx just forwards it. Also update the local `nginx-archipelago.conf` on the live server. -- [ ] **T15** — Add `search-web` action. When AIUI requests a web search action, proxy it through SearXNG if available. Accept `{ action: 'search-web', params: { query: '...' } }`, call SearXNG API, return results. This lets AIUI do private web search through the node instead of external services. +- [ ] **T15** — Add nginx proxy for AIUI web search. Proxy `/aiui/api/web-search` to the local SearXNG instance if installed (port from SearXNG manifest). If SearXNG isn't running, return 503. This gives AIUI private web search through the node. -- [ ] **T16** — Add `install-app` action enhancement. The existing install action is basic. Enhance: validate app exists in marketplace, check if already installed, return progress status. Handle errors gracefully. +- [ ] **T16** — Add nginx proxy for AIUI OpenRouter API. Proxy `/aiui/api/openrouter` to `https://openrouter.ai/api/` for users who want to use OpenRouter models. Same pass-through pattern as Claude proxy. -- [ ] **TEST:P3** — Type-check, build, deploy. Verify on live server. +- [ ] **T17** — Add `launch-app` action in ContextBroker. When AIUI requests `action:request` with `action: 'launch-app'`, return the app's web UI URL so AIUI can tell the user where to go (or Archy can navigate to it). Validate appId exists and is running. + +- [ ] **T18** — Add `search-web` action in ContextBroker. When AIUI requests a web search action, proxy it through SearXNG if available. Accept `{ action: 'search-web', params: { query: '...' } }`, call SearXNG API, return results. + +- [ ] **T19** — Add `install-app` action enhancement. The existing install action is basic. Enhance: validate app exists in marketplace, check if already installed, return progress status. Handle errors gracefully. + +- [ ] **TEST:P3** — Type-check, build, deploy. Deploy nginx config to live server: `sshpass -p 'EwPDR8q45l0Upx@' scp -o StrictHostKeyChecking=no image-recipe/configs/nginx-archipelago.conf archipelago@192.168.1.228:/etc/nginx/sites-available/archipelago && sshpass -p 'EwPDR8q45l0Upx@' ssh -o StrictHostKeyChecking=no archipelago@192.168.1.228 'sudo nginx -t && sudo systemctl reload nginx'`. Verify proxies work. ## Phase 4: End-to-End Testing Test the full integration by verifying the postMessage protocol works correctly between Archy and the deployed AIUI iframe. -- [ ] **T17** — Create integration test script. Write a test page or script that: loads the Chat view, verifies iframe loads AIUI, sends test context requests for each category, verifies responses come back with correct structure. Can be a simple HTML page at `/test-aiui.html` or a Vue component at `/dashboard/test-aiui`. Log results to console. +- [ ] **T20** — Create integration test script. Write a test page or script that: loads the Chat view, verifies iframe loads AIUI, sends test context requests for each category, verifies responses come back with correct structure. Can be a simple HTML page at `/test-aiui.html` or a Vue component at `/dashboard/test-aiui`. Log results to console. -- [ ] **T18** — Test each context category end-to-end. For each of the 10 categories: enable permission in Settings, open Chat, verify AIUI receives the permission update, trigger a context request, verify data comes back. Document which categories return real data vs. placeholders (depends on what apps are installed on the server). +- [ ] **T21** — Test each context category end-to-end. For each of the 10 categories: enable permission in Settings, open Chat, verify AIUI receives the permission update, trigger a context request, verify data comes back. Document which categories return real data vs. placeholders (depends on what apps are installed on the server). -- [ ] **T19** — Test action handlers. Test `navigate`, `open-app`, `launch-app`, `search-web` actions from within the AIUI iframe. Verify Archy responds correctly and performs the action. +- [ ] **T22** — Test action handlers. Test `navigate`, `open-app`, `launch-app`, `search-web` actions from within the AIUI iframe. Verify Archy responds correctly and performs the action. -- [ ] **T20** — Test permission denial. Disable all permissions, open Chat, verify AIUI receives empty permissions list. Verify context requests return `{ permitted: false }`. Verify AIUI handles this gracefully (should show "Enable X access in Settings" messages). +- [ ] **T23** — Test permission denial. Disable all permissions, open Chat, verify AIUI receives empty permissions list. Verify context requests return `{ permitted: false }`. Verify AIUI handles this gracefully (should show "Enable X access in Settings" messages). - [ ] **TEST:P4** — Final build, deploy, verify all tests pass on live server. ## Phase 5: UX Polish & Deploy -- [ ] **T21** — Add loading state to Chat.vue iframe. Show a glass-card loading indicator while AIUI iframe is loading. Listen for the `ready` postMessage from AIUI to know when it's loaded, then hide the loader. Use existing glass styling. +- [ ] **T24** — Add loading state to Chat.vue iframe. Show a glass-card loading indicator while AIUI iframe is loading. Listen for the `ready` postMessage from AIUI to know when it's loaded, then hide the loader. Use existing glass styling. -- [ ] **T22** — Add connection status indicator. Small pill/dot in the Chat close button area showing whether the ContextBroker has an active connection to AIUI (received `ready` message). Green dot = connected, no dot = loading. +- [ ] **T25** — Add connection status indicator. Small pill/dot in the Chat close button area showing whether the ContextBroker has an active connection to AIUI (received `ready` message). Green dot = connected, no dot = loading. -- [ ] **T23** — Final deploy and smoke test. Clean build both AIUI and Archy. Deploy both. Hard refresh on 192.168.1.228. Test: login → open chat → 3 panels animate in → close → panels animate out → dashboard returns. Verify all permissions toggles work in Settings. Verify Cmd+3 opens chat, Cmd+1/2 returns to dashboard. +- [ ] **T26** — Final deploy and smoke test. Clean build both AIUI and Archy. Deploy both. Hard refresh on 192.168.1.228. Test: login → open chat → 3 panels animate in → close → panels animate out → dashboard returns. Verify all permissions toggles work in Settings. Verify Cmd+3 opens chat, Cmd+1/2 returns to dashboard. - [ ] **TEST:FINAL** — Run `cd neode-ui && npm run type-check && npm run build`. Deploy with `./scripts/deploy-to-target.sh --live`. Also rebuild and deploy AIUI: `cd /Users/dorian/Projects/AIUI && rm -rf .turbo packages/app/.turbo packages/core/.turbo packages/app/dist packages/core/dist && VITE_BASE_PATH=/aiui/ pnpm build` then `sshpass -p 'EwPDR8q45l0Upx@' scp -o StrictHostKeyChecking=no -r /Users/dorian/Projects/AIUI/packages/app/dist/* archipelago@192.168.1.228:/opt/archipelago/aiui/`. Verify at http://192.168.1.228.