sensorium-mcp 3.0.76 → 3.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/daily-session.d.ts.map +1 -1
  2. package/dist/daily-session.js +5 -6
  3. package/dist/daily-session.js.map +1 -1
  4. package/dist/dashboard/routes/copilot.d.ts +7 -4
  5. package/dist/dashboard/routes/copilot.d.ts.map +1 -1
  6. package/dist/dashboard/routes/copilot.js +47 -13
  7. package/dist/dashboard/routes/copilot.js.map +1 -1
  8. package/dist/dashboard/routes.js +2 -2
  9. package/dist/dashboard/routes.js.map +1 -1
  10. package/dist/dashboard/spa.html +7 -7
  11. package/dist/data/daily-marker.d.ts +38 -0
  12. package/dist/data/daily-marker.d.ts.map +1 -0
  13. package/dist/data/daily-marker.js +82 -0
  14. package/dist/data/daily-marker.js.map +1 -0
  15. package/dist/response-builders.d.ts.map +1 -1
  16. package/dist/response-builders.js +12 -5
  17. package/dist/response-builders.js.map +1 -1
  18. package/dist/services/background-runner.d.ts.map +1 -1
  19. package/dist/services/background-runner.js +8 -0
  20. package/dist/services/background-runner.js.map +1 -1
  21. package/dist/services/worker-cleanup.service.d.ts.map +1 -1
  22. package/dist/services/worker-cleanup.service.js +8 -3
  23. package/dist/services/worker-cleanup.service.js.map +1 -1
  24. package/dist/tools/start-session-tool.d.ts.map +1 -1
  25. package/dist/tools/start-session-tool.js +6 -1
  26. package/dist/tools/start-session-tool.js.map +1 -1
  27. package/dist/tools/wait/poll-loop.d.ts.map +1 -1
  28. package/dist/tools/wait/poll-loop.js +5 -4
  29. package/dist/tools/wait/poll-loop.js.map +1 -1
  30. package/package.json +1 -1
  31. package/templates/playwright.default.md +30 -0
  32. package/templates/sensorium-repair.default.md +99 -0
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: Sensorium Self-Repair
3
+ triggers:
4
+ - debug sensorium
5
+ - fix sensorium
6
+ - repair sensorium
7
+ - sensorium crashing
8
+ - sensorium is crashing
9
+ - sensorium down
10
+ - sensorium broken
11
+ - mcp crashing
12
+ - mcp is dead
13
+ - supervisor loop
14
+ - restart loop
15
+ - emergency repair
16
+ - sensorium не працює
17
+ - сенсоріум крешить
18
+ replaces_orchestrator: true
19
+ ---
20
+
21
+ # Sensorium Self-Repair Skill
22
+
23
+ You are repairing **Sensorium itself** (this MCP server + its .NET supervisor) — a live production system the operator depends on. Move deliberately: **establish ground truth from logs and processes before changing anything**, distinguish real crashes from false-death loops, fix the root cause, validate, then ship. Do NOT guess. Do NOT restart blindly.
24
+
25
+ ## Golden rules (read first)
26
+
27
+ - **Root cause over symptoms.** A restart "fixes" nothing if the bug recurs. Find the exact file:line and the commit that introduced it.
28
+ - **Verify file contents via terminal, never trust cached reads.** The `read_file` tool can serve a STALE copy (it served an old `package.json` version during a real incident). For anything you will edit or reason about critically, confirm with `git show HEAD:<path>` or `Get-Content <path>`.
29
+ - **Never trust a subagent's described diff.** Subagents have hallucinated multi-hundred-line diffs for files that were clean. Always confirm with `git diff` / `git status` in a terminal yourself.
30
+ - **Watch for concurrent autonomous agents.** A Sensorium worker may be committing to this repo *while you work*. Re-check `git HEAD`, branch, and `git log` before and after edits; a fix you were about to write may already be committed.
31
+ - **Git safety:** stage explicit paths only. NEVER `git add -A/./-u`, `git commit -a`. NEVER commit `tmp_*`, dumps, screenshots, or binaries.
32
+ - **Deploy ≠ push.** Pushing to git does not update the running system (see "Ship & deploy").
33
+
34
+ ## Key facts & locations
35
+
36
+ - **Repo:** the workspace root (e.g. `c:\src\remote-copilot-mcp`). **Runtime data dir:** `~/.remote-copilot-mcp` (`$HOME`/`%USERPROFILE%`).
37
+ - **Logs** under `~/.remote-copilot-mcp/logs/`:
38
+ - `mcp/server.log` — MCP app log (rotated ~5 MB).
39
+ - `mcp/mcp-stderr-YYYYMMDD.log` — captured MCP stderr (fatal errors, startup banners, `[wait]`/`[telegram]` activity).
40
+ - `supervisor/supervisor-YYYYMMDD.log` — supervisor restart/health decisions (very noisy with Telegram `getUpdates`; filter it out).
41
+ - **Process model:** the .NET supervisor process `sensorium-supervisor` supervises a Node MCP server (**HTTP port 3847**) + watcher (**3848**). MCP start command is either `node dist/index.js` (local build) or `npx -y sensorium-mcp@latest` (published). Workers are `claude`/`codex`/`copilot` processes whose command line references `.remote-copilot-mcp`.
42
+ - **`~/.remote-copilot-mcp/server.pid`** holds `{"pid":N}` — should match the port-3847 owner. A mismatch is the signature of a false-death loop.
43
+ - **Windows: `git` is often NOT on PATH.** Locate it (`%LOCALAPPDATA%\Programs\Git\cmd\git.exe` or `C:\Program Files\Git\cmd\git.exe`) and call it by full path.
44
+ - **Prior root causes are logged in memory:** read `/memories/repo/critical-fixes-log.md`, `/memories/repo/keeper-stuck-detection-bug.md`, `/memories/repo/sensorium-architecture.md` before theorizing — the bug may be known.
45
+
46
+ ## Triage workflow
47
+
48
+ 1. **Ground truth first.** `git rev-parse --abbrev-ref HEAD`, `git log --oneline -20`, `git status --short`. Correlate the symptom's start time with recent commits (a bad push is the usual cause).
49
+ 2. **Real crash vs. false-death loop.** In `supervisor-YYYYMMDD.log`, count `MCP server process is dead — restarting` events and their cadence. Then in `mcp-stderr-YYYYMMDD.log` check whether ONE process kept serving across those times (continuous `[wait]`/`[telegram]` activity, message-ids incrementing, **no startup banner between restarts**). Continuous serving ⇒ the server never actually died ⇒ **false-death loop** (see failure modes), not a code crash.
50
+ 3. **Runtime state.** Enumerate node processes + port owners; compare `server.pid` to the port-3847 owner:
51
+ ```powershell
52
+ Get-Process node,sensorium-supervisor -EA SilentlyContinue | Select Id,ProcessName,StartTime
53
+ Get-NetTCPConnection -LocalPort 3847,3848 -State Listen -EA SilentlyContinue
54
+ Get-Content ~/.remote-copilot-mcp/server.pid
55
+ ```
56
+ `server.pid` ≠ port owner (but port owner alive) confirms a stale-pid false-death loop.
57
+ 4. **Find the real fatal error.** In `mcp-stderr-YYYYMMDD.log` search the crash window for `uncaughtException|unhandledRejection|Error:|EADDRINUSE|ECONNREFUSED|Cannot find module|out of memory`. In `supervisor` log, filter noise: `Get-Content <log> | Where-Object { $_ -notmatch 'getUpdates|api.telegram|processing HTTP|response headers' }`.
58
+
59
+ ## Known failure modes
60
+
61
+ - **False-death restart loop (supervisor).** Health loop declared the MCP dead from a stale `server.pid` without an HTTP cross-check, then spawned a duplicate that couldn't bind 3847 → died → `server.pid` repointed to the dead duplicate → loop every health interval, while the real server kept serving. Fix pattern: probe HTTP (`IsServerReadyAsync`) before killing — restart only when PID dead **and** port silent (`SupervisorWorker.cs`).
62
+ - **Cascade restart after MCP restart.** In-memory `spawnedThreads` empties → `isThreadRunning()` false for all → keeper restarts everything. Fix: rebuild tracking from PID files on startup.
63
+ - **Keeper "stuck" kills keepAlive threads.** `wait_for_instructions` long-poll didn't refresh the per-thread heartbeat → keeper declared stuck → killed. Fix: write `writeThreadHeartbeat()` in the poll loop.
64
+ - **Duplicate thread spawns.** Keeper checks the root threadId but `start_thread` creates a worker with a different id → always "not running" → re-spawns. Fix: track the worker id from the `start_thread` response.
65
+ - **Copilot process dies / no memory.** `copilot.bat` (VS Code wrapper) spawned detached dies silently — prefer `copilot.exe`; and a missing `thread_id` column crashed bootstrap. See critical-fixes-log.
66
+ - **Self-update port-handoff race.** New node self-registers its pid asynchronously, so `server.pid` transiently names a dead pid while HTTP is healthy — the trigger for the false-death loop above.
67
+
68
+ ## Emergency stop & restart
69
+
70
+ Kill in this order so nothing auto-respawns; be **targeted** (never blanket-kill `node`/`claude`/`copilot` — the operator has an interactive coding session):
71
+
72
+ 1. **Supervisor first** (`sensorium-supervisor`) — otherwise it restarts the MCP you kill.
73
+ 2. **MCP server + watcher** — the Node processes owning ports 3847/3848 or whose command line matches `sensorium-mcp` / `remote-copilot-mcp`.
74
+ 3. **Worker agents** — only `claude`/`codex`/`copilot` whose command line contains `.remote-copilot-mcp`.
75
+
76
+ ```powershell
77
+ Get-CimInstance Win32_Process |
78
+ Where-Object { $_.CommandLine -match 'remote-copilot-mcp|sensorium-mcp' -or $_.Name -eq 'sensorium-supervisor.exe' } |
79
+ Select-Object ProcessId,Name,CommandLine # ENUMERATE and confirm BEFORE killing
80
+ ```
81
+
82
+ Then `Stop-Process -Id <pid> -Force` in the order above. Verify ports 3847/3848 are free afterward. Do NOT delete lock/PID/data files unless the operator asked. If a process is unkillable (`Access denied`), report it — the operator must intervene.
83
+
84
+ ## Fix, validate, ship
85
+
86
+ - **Validate before pushing:**
87
+ - TypeScript: `npx tsc --noEmit` (must exit 0).
88
+ - Supervisor: `dotnet test supervisor-dotnet/tests/Sensorium.Supervisor.Tests.csproj`.
89
+ - Node tests: `npm test` — **requires Node ≥ 21** (`node --test` glob). CI matrix runs Node 22/24.
90
+ - **Expert review** the change (dispatch a review subagent; verify security: command injection, path traversal, secrets).
91
+ - **Ship:** `npm version patch --no-git-tag-version` → commit explicit paths (`fix(...)` then `chore(release): x.y.z`) → `git push origin main`.
92
+ - **CI:** confirm green — `gh run watch <run-id> --repo <owner>/<repo> --exit-status`. Fix and re-push until green.
93
+ - **Deploy at runtime (push alone does NOT deploy):**
94
+ - **MCP server** running via `npx sensorium-mcp@latest` picks up a new version only after **`npm publish`** (the watcher auto-updates). A local `node dist/index.js` needs `npm run build`.
95
+ - **Supervisor** (.NET) needs a **rebuild + reinstall via `Install-Sensorium.ps1`** to apply supervisor code changes — a running supervisor keeps its old binary in memory.
96
+
97
+ ## After an incident
98
+
99
+ Record the root cause, the fix, the commit hash, and the version in `/memories/repo/critical-fixes-log.md` (append, don't rewrite) so the next repair starts from knowledge, not zero.