sensorium-mcp 2.17.28 → 3.0.0
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.
- package/Install-Sensorium.ps1 +327 -0
- package/README.md +14 -0
- package/dist/config.d.ts +16 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +39 -2
- package/dist/config.js.map +1 -1
- package/dist/daily-session.d.ts +2 -1
- package/dist/daily-session.d.ts.map +1 -1
- package/dist/daily-session.js +23 -26
- package/dist/daily-session.js.map +1 -1
- package/dist/dashboard/routes/settings.d.ts +4 -0
- package/dist/dashboard/routes/settings.d.ts.map +1 -1
- package/dist/dashboard/routes/settings.js +57 -1
- package/dist/dashboard/routes/settings.js.map +1 -1
- package/dist/dashboard/routes/threads.d.ts +1 -0
- package/dist/dashboard/routes/threads.d.ts.map +1 -1
- package/dist/dashboard/routes/threads.js +23 -25
- package/dist/dashboard/routes/threads.js.map +1 -1
- package/dist/dashboard/routes.d.ts.map +1 -1
- package/dist/dashboard/routes.js +7 -2
- package/dist/dashboard/routes.js.map +1 -1
- package/dist/dashboard/spa.html +11 -11
- package/dist/data/interfaces.d.ts +36 -0
- package/dist/data/interfaces.d.ts.map +1 -0
- package/dist/data/interfaces.js +2 -0
- package/dist/data/interfaces.js.map +1 -0
- package/dist/data/memory/bootstrap.d.ts +36 -16
- package/dist/data/memory/bootstrap.d.ts.map +1 -1
- package/dist/data/memory/bootstrap.js +71 -217
- package/dist/data/memory/bootstrap.js.map +1 -1
- package/dist/data/memory/consolidation.d.ts +35 -34
- package/dist/data/memory/consolidation.d.ts.map +1 -1
- package/dist/data/memory/consolidation.js +43 -554
- package/dist/data/memory/consolidation.js.map +1 -1
- package/dist/data/memory/migration-runner.d.ts +5 -0
- package/dist/data/memory/migration-runner.d.ts.map +1 -0
- package/dist/data/memory/migration-runner.js +403 -0
- package/dist/data/memory/migration-runner.js.map +1 -0
- package/dist/data/memory/reflection.js +1 -1
- package/dist/data/memory/schema-ddl.d.ts +4 -0
- package/dist/data/memory/schema-ddl.d.ts.map +1 -0
- package/dist/data/memory/schema-ddl.js +194 -0
- package/dist/data/memory/schema-ddl.js.map +1 -0
- package/dist/data/memory/schema-guard.d.ts +3 -0
- package/dist/data/memory/schema-guard.d.ts.map +1 -0
- package/dist/data/memory/schema-guard.js +184 -0
- package/dist/data/memory/schema-guard.js.map +1 -0
- package/dist/data/memory/schema.d.ts +2 -5
- package/dist/data/memory/schema.d.ts.map +1 -1
- package/dist/data/memory/schema.js +6 -834
- package/dist/data/memory/schema.js.map +1 -1
- package/dist/data/memory/synthesis.js +2 -2
- package/dist/data/memory/synthesis.js.map +1 -1
- package/dist/data/memory/thread-registry.d.ts +18 -4
- package/dist/data/memory/thread-registry.d.ts.map +1 -1
- package/dist/data/memory/thread-registry.js +25 -0
- package/dist/data/memory/thread-registry.js.map +1 -1
- package/dist/data/sent-message.repository.d.ts +12 -0
- package/dist/data/sent-message.repository.d.ts.map +1 -0
- package/dist/data/sent-message.repository.js +31 -0
- package/dist/data/sent-message.repository.js.map +1 -0
- package/dist/http-server.d.ts.map +1 -1
- package/dist/http-server.js +23 -2
- package/dist/http-server.js.map +1 -1
- package/dist/index.js +27 -48
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +7 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +89 -12
- package/dist/logger.js.map +1 -1
- package/dist/scheduler.d.ts +8 -0
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +15 -0
- package/dist/scheduler.js.map +1 -1
- package/dist/server/factory.d.ts +2 -1
- package/dist/server/factory.d.ts.map +1 -1
- package/dist/server/factory.js +11 -4
- package/dist/server/factory.js.map +1 -1
- package/dist/services/agent-spawn.service.d.ts +39 -0
- package/dist/services/agent-spawn.service.d.ts.map +1 -0
- package/dist/services/agent-spawn.service.js +348 -0
- package/dist/services/agent-spawn.service.js.map +1 -0
- package/dist/services/background-runner.d.ts +26 -0
- package/dist/services/background-runner.d.ts.map +1 -0
- package/dist/services/background-runner.js +71 -0
- package/dist/services/background-runner.js.map +1 -0
- package/dist/services/consolidation.service.d.ts +16 -0
- package/dist/services/consolidation.service.d.ts.map +1 -0
- package/dist/services/consolidation.service.js +508 -0
- package/dist/services/consolidation.service.js.map +1 -0
- package/dist/services/dispatcher/broker.d.ts +2 -0
- package/dist/services/dispatcher/broker.d.ts.map +1 -1
- package/dist/services/dispatcher/broker.js +5 -10
- package/dist/services/dispatcher/broker.js.map +1 -1
- package/dist/services/dispatcher/index.d.ts +1 -1
- package/dist/services/dispatcher/index.d.ts.map +1 -1
- package/dist/services/dispatcher/index.js +1 -1
- package/dist/services/dispatcher/index.js.map +1 -1
- package/dist/services/dispatcher/lock.d.ts.map +1 -1
- package/dist/services/dispatcher/lock.js +7 -11
- package/dist/services/dispatcher/lock.js.map +1 -1
- package/dist/services/maintenance-signal.d.ts +18 -0
- package/dist/services/maintenance-signal.d.ts.map +1 -0
- package/dist/services/maintenance-signal.js +48 -0
- package/dist/services/maintenance-signal.js.map +1 -0
- package/dist/services/memory-briefing.service.d.ts +4 -0
- package/dist/services/memory-briefing.service.d.ts.map +1 -0
- package/dist/services/memory-briefing.service.js +143 -0
- package/dist/services/memory-briefing.service.js.map +1 -0
- package/dist/services/process.service.d.ts +31 -0
- package/dist/services/process.service.d.ts.map +1 -0
- package/dist/services/process.service.js +100 -0
- package/dist/services/process.service.js.map +1 -0
- package/dist/services/thread-health.service.d.ts +18 -0
- package/dist/services/thread-health.service.d.ts.map +1 -0
- package/dist/services/thread-health.service.js +118 -0
- package/dist/services/thread-health.service.js.map +1 -0
- package/dist/services/thread-lifecycle.service.d.ts +52 -0
- package/dist/services/thread-lifecycle.service.d.ts.map +1 -0
- package/dist/services/thread-lifecycle.service.js +174 -0
- package/dist/services/thread-lifecycle.service.js.map +1 -0
- package/dist/services/topic.service.d.ts +25 -0
- package/dist/services/topic.service.d.ts.map +1 -0
- package/dist/services/topic.service.js +65 -0
- package/dist/services/topic.service.js.map +1 -0
- package/dist/services/worker-cleanup.service.d.ts +8 -0
- package/dist/services/worker-cleanup.service.d.ts.map +1 -0
- package/dist/services/worker-cleanup.service.js +82 -0
- package/dist/services/worker-cleanup.service.js.map +1 -0
- package/dist/sessions.d.ts +14 -0
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js +55 -0
- package/dist/sessions.js.map +1 -1
- package/dist/telegram.d.ts +13 -6
- package/dist/telegram.d.ts.map +1 -1
- package/dist/telegram.js +43 -14
- package/dist/telegram.js.map +1 -1
- package/dist/tools/delegate-tool.d.ts +4 -0
- package/dist/tools/delegate-tool.d.ts.map +1 -1
- package/dist/tools/delegate-tool.js +48 -109
- package/dist/tools/delegate-tool.js.map +1 -1
- package/dist/tools/memory-tools.d.ts.map +1 -1
- package/dist/tools/memory-tools.js +1 -1
- package/dist/tools/memory-tools.js.map +1 -1
- package/dist/tools/shared-agent-utils.d.ts +9 -1
- package/dist/tools/shared-agent-utils.d.ts.map +1 -1
- package/dist/tools/shared-agent-utils.js +21 -38
- package/dist/tools/shared-agent-utils.js.map +1 -1
- package/dist/tools/start-session-tool.d.ts +2 -0
- package/dist/tools/start-session-tool.d.ts.map +1 -1
- package/dist/tools/start-session-tool.js +66 -106
- package/dist/tools/start-session-tool.js.map +1 -1
- package/dist/tools/thread-lifecycle.d.ts +5 -127
- package/dist/tools/thread-lifecycle.d.ts.map +1 -1
- package/dist/tools/thread-lifecycle.js +5 -1167
- package/dist/tools/thread-lifecycle.js.map +1 -1
- package/dist/tools/utility-tools.js +5 -2
- package/dist/tools/utility-tools.js.map +1 -1
- package/dist/tools/wait/drive-handler.d.ts +0 -1
- package/dist/tools/wait/drive-handler.d.ts.map +1 -1
- package/dist/tools/wait/drive-handler.js +5 -22
- package/dist/tools/wait/drive-handler.js.map +1 -1
- package/dist/tools/wait/message-delivery.js +1 -1
- package/dist/tools/wait/message-delivery.js.map +1 -1
- package/dist/tools/wait/message-processing.d.ts.map +1 -1
- package/dist/tools/wait/message-processing.js +9 -8
- package/dist/tools/wait/message-processing.js.map +1 -1
- package/dist/tools/wait/poll-loop.d.ts +2 -0
- package/dist/tools/wait/poll-loop.d.ts.map +1 -1
- package/dist/tools/wait/poll-loop.js +27 -29
- package/dist/tools/wait/poll-loop.js.map +1 -1
- package/dist/tools/wait/task-handler.d.ts +0 -3
- package/dist/tools/wait/task-handler.d.ts.map +1 -1
- package/dist/tools/wait/task-handler.js +3 -2
- package/dist/tools/wait/task-handler.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -8
- package/supervisor/config.go +182 -69
- package/supervisor/config_test.go +78 -0
- package/supervisor/go.mod +12 -0
- package/supervisor/go.sum +20 -0
- package/supervisor/health.go +56 -6
- package/supervisor/health_test.go +29 -0
- package/supervisor/keeper.go +15 -10
- package/supervisor/log.go +109 -28
- package/supervisor/log_test.go +86 -6
- package/supervisor/main.go +150 -19
- package/supervisor/main_test.go +130 -0
- package/supervisor/process.go +47 -4
- package/supervisor/process_test.go +14 -0
- package/supervisor/secrets.go +95 -0
- package/supervisor/secrets_securevault_test.go +98 -0
- package/supervisor/secrets_test.go +119 -0
- package/supervisor/self_update.go +282 -0
- package/supervisor/self_update_test.go +177 -0
- package/supervisor/service_restart_stub.go +9 -0
- package/supervisor/service_restart_windows.go +63 -0
- package/supervisor/service_stub.go +15 -0
- package/supervisor/service_windows.go +216 -0
- package/supervisor/update_state.go +264 -0
- package/supervisor/update_state_test.go +306 -0
- package/supervisor/updater.go +311 -10
- package/supervisor/updater_test.go +64 -0
- package/scripts/install-supervisor.ps1 +0 -67
- package/scripts/install-supervisor.sh +0 -43
- package/scripts/start-supervisor.ps1 +0 -46
- package/scripts/start-supervisor.sh +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-loop.js","sourceRoot":"","sources":["../../../src/tools/wait/poll-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UA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AI,EAAE,CAAC;gBACT,CAAC;YACH,CAAC,CAAC,CAAC;YACH,sBAAsB,EAAE,CAAC;YACzB,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;gBACpC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;gBACxC,sEAAsE;gBACtE,4DAA4D;gBAC5D,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,MAAM,EAAE,CAAC;oBAC7C,kBAAkB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;oBAChC,IAAI,CAAC;wBACH,GAAG,CAAC,eAAe,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,iBAAiB,EAAE,EAAE,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;oBAChH,CAAC;oBAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACD,CAAC;QAAC,OAAO,OAAO,EAAE,CAAC;YACjB,GAAG,CAAC,KAAK,CAAC,oBAAoB,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC9F,SAAS;QACX,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-handler.d.ts","sourceRoot":"","sources":["../../../src/tools/wait/task-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"task-handler.d.ts","sourceRoot":"","sources":["../../../src/tools/wait/task-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,UAAU,WAAW;IACnB,KAAK,EAAE;QACL,qBAAqB,EAAE,MAAM,CAAC;QAC9B,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,qBAAqB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACrD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,EAChB,iBAAiB,EAAE,MAAM,GACxB,UAAU,GAAG,IAAI,CAqBnB"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { checkDueTasks } from "../../scheduler.js";
|
|
8
8
|
import { getReminders } from "../../response-builders.js";
|
|
9
|
+
import { getEffectiveAutonomousMode } from "../../config.js";
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
11
|
// Handler
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
@@ -19,7 +20,7 @@ import { getReminders } from "../../response-builders.js";
|
|
|
19
20
|
* check (after the loop exits).
|
|
20
21
|
*/
|
|
21
22
|
export function checkForDueTasks(ctx, effectiveThreadId) {
|
|
22
|
-
const { state
|
|
23
|
+
const { state } = ctx;
|
|
23
24
|
const dueTask = checkDueTasks(effectiveThreadId, state.lastOperatorMessageAt, false);
|
|
24
25
|
if (!dueTask)
|
|
25
26
|
return null;
|
|
@@ -33,7 +34,7 @@ export function checkForDueTasks(ctx, effectiveThreadId) {
|
|
|
33
34
|
content: [
|
|
34
35
|
{
|
|
35
36
|
type: "text",
|
|
36
|
-
text: taskPrompt + getReminders(effectiveThreadId, state.sessionStartedAt,
|
|
37
|
+
text: taskPrompt + getReminders(effectiveThreadId, state.sessionStartedAt, getEffectiveAutonomousMode(effectiveThreadId)),
|
|
37
38
|
},
|
|
38
39
|
],
|
|
39
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-handler.js","sourceRoot":"","sources":["../../../src/tools/wait/task-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"task-handler.js","sourceRoot":"","sources":["../../../src/tools/wait/task-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAe7D,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAgB,EAChB,iBAAyB;IAEzB,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAEtB,MAAM,OAAO,GAAG,aAAa,CAAC,iBAAiB,EAAE,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IACrF,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,yDAAyD;IACzD,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,KAAK,SAAS;QAC7C,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,iBAAiB,CAAC;QAC9C,CAAC,CAAC,8BAA8B,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS;YACzD,oKAAoK;YACpK,gBAAgB,OAAO,CAAC,MAAM,EAAE,CAAC;IAErC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,UAAU,GAAG,YAAY,CAAC,iBAAiB,EAAE,KAAK,CAAC,gBAAgB,EAAE,0BAA0B,CAAC,iBAAiB,CAAC,CAAC;aAC1H;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export interface AppConfig {
|
|
|
15
15
|
DMN_ACTIVATION_HOURS: number;
|
|
16
16
|
FILES_DIR: string;
|
|
17
17
|
PKG_VERSION: string;
|
|
18
|
-
AUTONOMOUS_MODE: boolean;
|
|
19
18
|
}
|
|
20
19
|
export type CreateMcpServerFn = (getMcpSessionId?: () => string | undefined, closeTransport?: () => void) => Server;
|
|
21
20
|
export type TextBlock = {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAIxE,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAIxE,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAID,MAAM,MAAM,iBAAiB,GAAG,CAC9B,eAAe,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,EAC1C,cAAc,CAAC,EAAE,MAAM,IAAI,KACxB,MAAM,CAAC;AAIZ,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sensorium-mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "MCP server for remote control of AI assistants via Telegram",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,18 +10,14 @@
|
|
|
10
10
|
"dist",
|
|
11
11
|
"templates",
|
|
12
12
|
"supervisor",
|
|
13
|
-
"
|
|
14
|
-
"scripts/install-supervisor.sh",
|
|
15
|
-
"scripts/start-supervisor.ps1",
|
|
16
|
-
"scripts/start-supervisor.sh"
|
|
13
|
+
"Install-Sensorium.ps1"
|
|
17
14
|
],
|
|
18
15
|
"scripts": {
|
|
19
16
|
"build": "cd src/dashboard/vue && npx vite build && cd ../../.. && node -e \"const fs=require('fs');if(fs.existsSync('dist/dashboard/index.html'))fs.renameSync('dist/dashboard/index.html','dist/dashboard/spa.html')\" && tsc",
|
|
20
17
|
"start": "node dist/index.js",
|
|
21
18
|
"dev": "tsx src/index.ts",
|
|
22
|
-
"supervisor:install": "pwsh
|
|
23
|
-
"supervisor:start": "
|
|
24
|
-
"supervisor:dev": "pwsh scripts/start-supervisor.ps1 -Mode development",
|
|
19
|
+
"supervisor:install": "pwsh Install-Sensorium.ps1",
|
|
20
|
+
"supervisor:start": "node dist/index.js --supervisor",
|
|
25
21
|
"prepublishOnly": "npm run build",
|
|
26
22
|
"test": "echo \"No tests defined\" && exit 0"
|
|
27
23
|
},
|
package/supervisor/config.go
CHANGED
|
@@ -1,43 +1,53 @@
|
|
|
1
1
|
package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"errors"
|
|
4
5
|
"fmt"
|
|
5
6
|
"os"
|
|
6
7
|
"path/filepath"
|
|
8
|
+
"regexp"
|
|
7
9
|
"strconv"
|
|
10
|
+
"strings"
|
|
8
11
|
"time"
|
|
12
|
+
|
|
13
|
+
sv "github.com/andriyshevchenko/SecureVault/securevault-go"
|
|
9
14
|
)
|
|
10
15
|
|
|
11
16
|
// Config holds all supervisor configuration, sourced from environment variables
|
|
12
17
|
// with sensible defaults matching the TypeScript watcher-service.ts CONFIG object.
|
|
13
18
|
type Config struct {
|
|
14
19
|
// Watcher
|
|
15
|
-
Mode
|
|
16
|
-
PollAtHour
|
|
17
|
-
PollInterval
|
|
18
|
-
GracePeriod
|
|
19
|
-
MinUptime
|
|
20
|
-
MCPStartCommand
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
Mode string
|
|
21
|
+
PollAtHour int
|
|
22
|
+
PollInterval time.Duration
|
|
23
|
+
GracePeriod time.Duration
|
|
24
|
+
MinUptime time.Duration
|
|
25
|
+
MCPStartCommand string
|
|
26
|
+
HostMode string
|
|
27
|
+
DataDir string
|
|
28
|
+
KeyringService string
|
|
29
|
+
SecureVaultProfile string
|
|
30
|
+
SecureVaultBaseDir string
|
|
31
|
+
MCPHttpPort int
|
|
32
|
+
MCPHttpSecret string
|
|
33
|
+
TelegramToken string
|
|
34
|
+
TelegramChatID string
|
|
35
|
+
HealthFailThresh int
|
|
36
|
+
ResolvedProfileEnv map[string]string
|
|
27
37
|
|
|
28
38
|
// Keeper defaults
|
|
29
|
-
KeeperBaseBackoff
|
|
30
|
-
KeeperMaxBackoff
|
|
39
|
+
KeeperBaseBackoff time.Duration
|
|
40
|
+
KeeperMaxBackoff time.Duration
|
|
31
41
|
KeeperHealthCheckInterval time.Duration
|
|
32
|
-
KeeperMaxRetries
|
|
33
|
-
KeeperCooldown
|
|
34
|
-
KeeperReadyPollInterval
|
|
35
|
-
KeeperReadyTimeout
|
|
36
|
-
FastExitThreshold
|
|
37
|
-
FastExitMaxCount
|
|
38
|
-
FastExitBaseCooldown
|
|
39
|
-
FastExitMaxCooldown
|
|
40
|
-
StuckThreshold
|
|
42
|
+
KeeperMaxRetries int
|
|
43
|
+
KeeperCooldown time.Duration
|
|
44
|
+
KeeperReadyPollInterval time.Duration
|
|
45
|
+
KeeperReadyTimeout time.Duration
|
|
46
|
+
FastExitThreshold time.Duration
|
|
47
|
+
FastExitMaxCount int
|
|
48
|
+
FastExitBaseCooldown time.Duration
|
|
49
|
+
FastExitMaxCooldown time.Duration
|
|
50
|
+
StuckThreshold time.Duration
|
|
41
51
|
|
|
42
52
|
// Derived paths
|
|
43
53
|
Paths Paths
|
|
@@ -45,64 +55,94 @@ type Config struct {
|
|
|
45
55
|
|
|
46
56
|
// Paths holds all filesystem paths derived from DataDir.
|
|
47
57
|
type Paths struct {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
BinaryDir string
|
|
59
|
+
MaintenanceFlag string
|
|
60
|
+
VersionFile string
|
|
61
|
+
SupervisorVersion string
|
|
62
|
+
UpdateState string
|
|
63
|
+
UpdateApplyLock string
|
|
64
|
+
PendingBinary string
|
|
65
|
+
PendingVersion string
|
|
66
|
+
LastActivity string
|
|
67
|
+
MCPStderrLog string
|
|
68
|
+
ServerPID string
|
|
69
|
+
WatcherLock string
|
|
70
|
+
WatcherLog string
|
|
71
|
+
PIDsDir string
|
|
72
|
+
HeartbeatsDir string
|
|
56
73
|
}
|
|
57
74
|
|
|
58
|
-
func LoadConfig() Config {
|
|
75
|
+
func LoadConfig(runningAsService bool) Config {
|
|
59
76
|
dataDir := filepath.Join(homeDir(), ".remote-copilot-mcp")
|
|
60
77
|
|
|
61
78
|
mode := envOr("WATCHER_MODE", "development")
|
|
62
|
-
graceDef :=
|
|
79
|
+
graceDef := 300
|
|
63
80
|
if mode == "development" {
|
|
64
|
-
graceDef =
|
|
81
|
+
graceDef = 10
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
c := Config{
|
|
68
|
-
Mode:
|
|
69
|
-
PollAtHour:
|
|
70
|
-
PollInterval:
|
|
71
|
-
GracePeriod:
|
|
72
|
-
MinUptime:
|
|
73
|
-
MCPStartCommand:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
HealthFailThresh:
|
|
80
|
-
|
|
81
|
-
KeeperBaseBackoff:
|
|
82
|
-
KeeperMaxBackoff:
|
|
85
|
+
Mode: mode,
|
|
86
|
+
PollAtHour: envInt("WATCHER_POLL_HOUR", 4),
|
|
87
|
+
PollInterval: time.Duration(envInt("WATCHER_POLL_INTERVAL", 60)) * time.Second,
|
|
88
|
+
GracePeriod: time.Duration(envInt("WATCHER_GRACE_PERIOD", graceDef)) * time.Second,
|
|
89
|
+
MinUptime: 600 * time.Second,
|
|
90
|
+
MCPStartCommand: envOr("MCP_START_COMMAND", "npx -y sensorium-mcp@latest"),
|
|
91
|
+
HostMode: parseHostMode(os.Getenv("HOST_MODE"), runningAsService),
|
|
92
|
+
DataDir: dataDir,
|
|
93
|
+
KeyringService: envOr("SUPERVISOR_KEYRING_SERVICE", defaultKeyringService),
|
|
94
|
+
SecureVaultProfile: os.Getenv("SUPERVISOR_SECUREVAULT_PROFILE"),
|
|
95
|
+
SecureVaultBaseDir: os.Getenv("SUPERVISOR_SECUREVAULT_BASEDIR"),
|
|
96
|
+
HealthFailThresh: 3,
|
|
97
|
+
|
|
98
|
+
KeeperBaseBackoff: 5 * time.Second,
|
|
99
|
+
KeeperMaxBackoff: 5 * time.Minute,
|
|
83
100
|
KeeperHealthCheckInterval: 2 * time.Minute,
|
|
84
|
-
KeeperMaxRetries:
|
|
85
|
-
KeeperCooldown:
|
|
86
|
-
KeeperReadyPollInterval:
|
|
87
|
-
KeeperReadyTimeout:
|
|
88
|
-
FastExitThreshold:
|
|
89
|
-
FastExitMaxCount:
|
|
90
|
-
FastExitBaseCooldown:
|
|
91
|
-
FastExitMaxCooldown:
|
|
92
|
-
StuckThreshold:
|
|
101
|
+
KeeperMaxRetries: 5,
|
|
102
|
+
KeeperCooldown: 5 * time.Minute,
|
|
103
|
+
KeeperReadyPollInterval: 3 * time.Second,
|
|
104
|
+
KeeperReadyTimeout: 2 * time.Minute,
|
|
105
|
+
FastExitThreshold: 60 * time.Second,
|
|
106
|
+
FastExitMaxCount: 3,
|
|
107
|
+
FastExitBaseCooldown: 10 * time.Minute,
|
|
108
|
+
FastExitMaxCooldown: 4 * time.Hour,
|
|
109
|
+
StuckThreshold: 10 * time.Minute,
|
|
93
110
|
|
|
94
111
|
Paths: Paths{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
BinaryDir: filepath.Join(dataDir, "bin"),
|
|
113
|
+
MaintenanceFlag: filepath.Join(dataDir, "maintenance.flag"),
|
|
114
|
+
VersionFile: filepath.Join(dataDir, "current-version.txt"),
|
|
115
|
+
SupervisorVersion: filepath.Join(dataDir, "supervisor-version.txt"),
|
|
116
|
+
UpdateState: filepath.Join(dataDir, "update-state.json"),
|
|
117
|
+
UpdateApplyLock: filepath.Join(dataDir, "update-apply.lock"),
|
|
118
|
+
PendingBinary: filepath.Join(dataDir, "bin", "sensorium-supervisor.new.exe"),
|
|
119
|
+
PendingVersion: filepath.Join(dataDir, "bin", "sensorium-supervisor.new.exe.version"),
|
|
120
|
+
LastActivity: filepath.Join(dataDir, "last-activity.txt"),
|
|
121
|
+
MCPStderrLog: filepath.Join(dataDir, "mcp-stderr.log"),
|
|
122
|
+
ServerPID: filepath.Join(dataDir, "server.pid"),
|
|
123
|
+
WatcherLock: filepath.Join(dataDir, "watcher.lock"),
|
|
124
|
+
WatcherLog: filepath.Join(dataDir, "watcher.log"),
|
|
125
|
+
PIDsDir: filepath.Join(dataDir, "pids"),
|
|
126
|
+
HeartbeatsDir: filepath.Join(dataDir, "heartbeats"),
|
|
103
127
|
},
|
|
104
128
|
}
|
|
105
129
|
|
|
130
|
+
// Use the full chain (env → SecureVault → keyring) when a profile is configured;
|
|
131
|
+
// otherwise fall back to the plain env → keyring path.
|
|
132
|
+
if c.SecureVaultProfile != "" {
|
|
133
|
+
c.ResolvedProfileEnv = resolveProfileEnv(c.SecureVaultProfile, c.SecureVaultBaseDir)
|
|
134
|
+
c.MCPHttpPort = resolveIntChain("MCP_HTTP_PORT", c.SecureVaultProfile, c.SecureVaultBaseDir, c.KeyringService, 0)
|
|
135
|
+
c.MCPHttpSecret = resolveStringChain("MCP_HTTP_SECRET", c.SecureVaultProfile, c.SecureVaultBaseDir, c.KeyringService)
|
|
136
|
+
c.TelegramToken = resolveStringChain("TELEGRAM_TOKEN", c.SecureVaultProfile, c.SecureVaultBaseDir, c.KeyringService)
|
|
137
|
+
c.TelegramChatID = resolveStringChain("TELEGRAM_CHAT_ID", c.SecureVaultProfile, c.SecureVaultBaseDir, c.KeyringService)
|
|
138
|
+
} else {
|
|
139
|
+
c.ResolvedProfileEnv = map[string]string{}
|
|
140
|
+
c.MCPHttpPort = resolveIntWithKeyring("MCP_HTTP_PORT", c.KeyringService, 0)
|
|
141
|
+
c.MCPHttpSecret = resolveSecretWithKeyring("MCP_HTTP_SECRET", c.KeyringService)
|
|
142
|
+
c.TelegramToken = resolveSecretWithKeyring("TELEGRAM_TOKEN", c.KeyringService)
|
|
143
|
+
c.TelegramChatID = resolveSecretWithKeyring("TELEGRAM_CHAT_ID", c.KeyringService)
|
|
144
|
+
}
|
|
145
|
+
|
|
106
146
|
return c
|
|
107
147
|
}
|
|
108
148
|
|
|
@@ -134,7 +174,80 @@ func envInt(key string, fallback int) int {
|
|
|
134
174
|
return v
|
|
135
175
|
}
|
|
136
176
|
|
|
137
|
-
func
|
|
138
|
-
|
|
139
|
-
|
|
177
|
+
func parseHostMode(value string, runningAsService bool) string {
|
|
178
|
+
normalized := strings.ToLower(strings.TrimSpace(value))
|
|
179
|
+
if runningAsService {
|
|
180
|
+
if normalized == "" || normalized == "service" {
|
|
181
|
+
return "service"
|
|
182
|
+
}
|
|
183
|
+
if normalized == "task" {
|
|
184
|
+
fmt.Fprintf(os.Stderr, "WARN: HOST_MODE=%q ignored because process is running as a Windows service; forcing \"service\"\n", value)
|
|
185
|
+
} else {
|
|
186
|
+
fmt.Fprintf(os.Stderr, "WARN: invalid HOST_MODE=%q ignored because process is running as a Windows service; forcing \"service\" (allowed: task|service)\n", value)
|
|
187
|
+
}
|
|
188
|
+
return "service"
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if normalized == "" {
|
|
192
|
+
return "task"
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
switch normalized {
|
|
196
|
+
case "task", "service":
|
|
197
|
+
return normalized
|
|
198
|
+
default:
|
|
199
|
+
fmt.Fprintf(os.Stderr, "WARN: invalid HOST_MODE=%q (allowed: task|service); using default \"task\"\n", value)
|
|
200
|
+
return "task"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
func resolveProfileEnv(profileName, baseDir string) map[string]string {
|
|
205
|
+
resolved := map[string]string{}
|
|
206
|
+
if strings.TrimSpace(profileName) == "" {
|
|
207
|
+
return resolved
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
store := sv.NewStore(baseDir)
|
|
211
|
+
vals, err := store.ResolveProfile(profileName)
|
|
212
|
+
if err != nil {
|
|
213
|
+
if errors.Is(err, sv.ErrNotFound) || errors.Is(err, sv.ErrUnsupportedPlatform) {
|
|
214
|
+
return resolved
|
|
215
|
+
}
|
|
216
|
+
fmt.Fprintf(os.Stderr, "WARN: failed to resolve SecureVault profile %q: %v\n", profileName, err)
|
|
217
|
+
return resolved
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
for k, v := range vals {
|
|
221
|
+
if !isAllowedProfileEnvKey(k) {
|
|
222
|
+
fmt.Fprintf(os.Stderr, "WARN: skipping unsafe profile env key %q\n", k)
|
|
223
|
+
continue
|
|
224
|
+
}
|
|
225
|
+
if envVal := os.Getenv(k); envVal != "" {
|
|
226
|
+
resolved[k] = envVal
|
|
227
|
+
continue
|
|
228
|
+
}
|
|
229
|
+
resolved[k] = v
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return resolved
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
var profileEnvKeyPattern = regexp.MustCompile(`^[A-Z_][A-Z0-9_]*$`)
|
|
236
|
+
|
|
237
|
+
var deniedProfileEnvKeys = map[string]struct{}{
|
|
238
|
+
"PATH": {},
|
|
239
|
+
"PATHEXT": {},
|
|
240
|
+
"COMSPEC": {},
|
|
241
|
+
"SYSTEMROOT": {},
|
|
242
|
+
"WINDIR": {},
|
|
243
|
+
"NODE_OPTIONS": {},
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
func isAllowedProfileEnvKey(key string) bool {
|
|
247
|
+
trimmed := strings.TrimSpace(key)
|
|
248
|
+
if !profileEnvKeyPattern.MatchString(trimmed) {
|
|
249
|
+
return false
|
|
250
|
+
}
|
|
251
|
+
_, denied := deniedProfileEnvKeys[trimmed]
|
|
252
|
+
return !denied
|
|
140
253
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import "testing"
|
|
4
|
+
|
|
5
|
+
func TestParseHostMode_DefaultsAndValidation(t *testing.T) {
|
|
6
|
+
tests := []struct {
|
|
7
|
+
name string
|
|
8
|
+
value string
|
|
9
|
+
runningAsService bool
|
|
10
|
+
want string
|
|
11
|
+
}{
|
|
12
|
+
{
|
|
13
|
+
name: "empty defaults to service when running as service",
|
|
14
|
+
value: "",
|
|
15
|
+
runningAsService: true,
|
|
16
|
+
want: "service",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "empty defaults to task when not running as service",
|
|
20
|
+
value: "",
|
|
21
|
+
runningAsService: false,
|
|
22
|
+
want: "task",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "invalid falls back to service default for service mode",
|
|
26
|
+
value: "invalid",
|
|
27
|
+
runningAsService: true,
|
|
28
|
+
want: "service",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "invalid falls back to task default for task mode",
|
|
32
|
+
value: "invalid",
|
|
33
|
+
runningAsService: false,
|
|
34
|
+
want: "task",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "valid task accepted",
|
|
38
|
+
value: "task",
|
|
39
|
+
runningAsService: true,
|
|
40
|
+
want: "service",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "valid service accepted",
|
|
44
|
+
value: "service",
|
|
45
|
+
runningAsService: false,
|
|
46
|
+
want: "service",
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for _, tc := range tests {
|
|
51
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
52
|
+
got := parseHostMode(tc.value, tc.runningAsService)
|
|
53
|
+
if got != tc.want {
|
|
54
|
+
t.Fatalf("parseHostMode(%q, runningAsService=%v) = %q, want %q", tc.value, tc.runningAsService, got, tc.want)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func TestIsAllowedProfileEnvKey(t *testing.T) {
|
|
61
|
+
tests := []struct {
|
|
62
|
+
key string
|
|
63
|
+
want bool
|
|
64
|
+
}{
|
|
65
|
+
{key: "TELEGRAM_TOKEN", want: true},
|
|
66
|
+
{key: "MCP_HTTP_PORT", want: true},
|
|
67
|
+
{key: "PATH", want: false},
|
|
68
|
+
{key: "NODE_OPTIONS", want: false},
|
|
69
|
+
{key: "bad-key", want: false},
|
|
70
|
+
{key: "1BAD", want: false},
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for _, tc := range tests {
|
|
74
|
+
if got := isAllowedProfileEnvKey(tc.key); got != tc.want {
|
|
75
|
+
t.Fatalf("isAllowedProfileEnvKey(%q) = %v, want %v", tc.key, got, tc.want)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
package/supervisor/go.mod
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
module github.com/andriyshevchenko/sensorium-supervisor
|
|
2
2
|
|
|
3
3
|
go 1.22
|
|
4
|
+
|
|
5
|
+
require (
|
|
6
|
+
github.com/zalando/go-keyring v0.2.8
|
|
7
|
+
golang.org/x/sys v0.30.0
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
require github.com/andriyshevchenko/SecureVault/securevault-go v0.1.2
|
|
11
|
+
|
|
12
|
+
require (
|
|
13
|
+
github.com/danieljoos/wincred v1.2.3 // indirect
|
|
14
|
+
github.com/godbus/dbus/v5 v5.2.2 // indirect
|
|
15
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
github.com/andriyshevchenko/SecureVault/securevault-go v0.1.2 h1:4PyakSOgHmBnN0Oqapoh3/Ik92fvmR8R2ksE5qCXXOE=
|
|
2
|
+
github.com/andriyshevchenko/SecureVault/securevault-go v0.1.2/go.mod h1:oEb5uTPCvex+efofFySxxbe55z13LbAO3JSaxcjVq2Q=
|
|
3
|
+
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
|
|
4
|
+
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
|
|
5
|
+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
6
|
+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
7
|
+
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
|
|
8
|
+
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
|
|
9
|
+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
10
|
+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
11
|
+
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
|
12
|
+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
|
13
|
+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
|
14
|
+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
|
15
|
+
github.com/zalando/go-keyring v0.2.8 h1:6sD/Ucpl7jNq10rM2pgqTs0sZ9V3qMrqfIIy5YPccHs=
|
|
16
|
+
github.com/zalando/go-keyring v0.2.8/go.mod h1:tsMo+VpRq5NGyKfxoBVjCuMrG47yj8cmakZDO5QGii0=
|
|
17
|
+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
|
18
|
+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
19
|
+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
20
|
+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
package/supervisor/health.go
CHANGED
|
@@ -98,15 +98,57 @@ func (m *MCPClient) WaitForReady(ctx context.Context, pollInterval, timeout time
|
|
|
98
98
|
|
|
99
99
|
// GetRootThreads fetches the list of root threads from the server.
|
|
100
100
|
func (m *MCPClient) GetRootThreads(ctx context.Context) ([]map[string]any, error) {
|
|
101
|
+
return m.fetchThreadList(ctx, "/api/threads/roots")
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// GetKeepAliveThreads fetches all threads with keepAlive=true (excluding worker threads).
|
|
105
|
+
func (m *MCPClient) GetKeepAliveThreads(ctx context.Context) ([]map[string]any, error) {
|
|
106
|
+
threads, err := m.fetchThreadList(ctx, "/api/threads/keepalive")
|
|
107
|
+
if err == nil {
|
|
108
|
+
return threads, nil
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Backward compatibility: older MCP builds may not expose /api/threads/keepalive.
|
|
112
|
+
if strings.Contains(err.Error(), "GET /api/threads/keepalive: 404") {
|
|
113
|
+
if m.Log != nil {
|
|
114
|
+
m.Log.Warn("/api/threads/keepalive unavailable (404); falling back to /api/threads with client-side filtering")
|
|
115
|
+
}
|
|
116
|
+
allThreads, err2 := m.fetchThreadList(ctx, "/api/threads")
|
|
117
|
+
if err2 != nil {
|
|
118
|
+
return nil, err2
|
|
119
|
+
}
|
|
120
|
+
return filterKeepAliveThreads(allThreads), nil
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return nil, err
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
func filterKeepAliveThreads(threads []map[string]any) []map[string]any {
|
|
127
|
+
result := make([]map[string]any, 0, len(threads))
|
|
128
|
+
for _, t := range threads {
|
|
129
|
+
keepAlive, _ := t["keepAlive"].(bool)
|
|
130
|
+
if !keepAlive {
|
|
131
|
+
continue
|
|
132
|
+
}
|
|
133
|
+
if typ, _ := t["type"].(string); typ == "worker" {
|
|
134
|
+
continue
|
|
135
|
+
}
|
|
136
|
+
result = append(result, t)
|
|
137
|
+
}
|
|
138
|
+
return result
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// fetchThreadList is a shared helper for thread-list endpoints.
|
|
142
|
+
func (m *MCPClient) fetchThreadList(ctx context.Context, path string) ([]map[string]any, error) {
|
|
101
143
|
ctx2, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
102
144
|
defer cancel()
|
|
103
|
-
resp, err := m.doReq(ctx2, "GET",
|
|
145
|
+
resp, err := m.doReq(ctx2, "GET", path, nil)
|
|
104
146
|
if err != nil {
|
|
105
147
|
return nil, err
|
|
106
148
|
}
|
|
107
149
|
defer resp.Body.Close()
|
|
108
150
|
if resp.StatusCode != 200 {
|
|
109
|
-
return nil, fmt.Errorf("GET
|
|
151
|
+
return nil, fmt.Errorf("GET %s: %d", path, resp.StatusCode)
|
|
110
152
|
}
|
|
111
153
|
body, err := io.ReadAll(resp.Body)
|
|
112
154
|
if err != nil {
|
|
@@ -122,7 +164,7 @@ func (m *MCPClient) GetRootThreads(ctx context.Context) ([]map[string]any, error
|
|
|
122
164
|
Threads []map[string]any `json:"threads"`
|
|
123
165
|
}
|
|
124
166
|
if err := json.Unmarshal(body, &wrapped); err != nil {
|
|
125
|
-
return nil, fmt.Errorf("cannot parse
|
|
167
|
+
return nil, fmt.Errorf("cannot parse %s response: %w", path, err)
|
|
126
168
|
}
|
|
127
169
|
return wrapped.Threads, nil
|
|
128
170
|
}
|
|
@@ -145,7 +187,9 @@ func (m *MCPClient) IsThreadRunning(ctx context.Context, threadID int) bool {
|
|
|
145
187
|
}
|
|
146
188
|
return false
|
|
147
189
|
}
|
|
148
|
-
var result struct{
|
|
190
|
+
var result struct {
|
|
191
|
+
Running bool `json:"running"`
|
|
192
|
+
}
|
|
149
193
|
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
|
150
194
|
if m.Log != nil {
|
|
151
195
|
m.Log.Debug("IsThreadRunning(%d): decode error: %v", threadID, err)
|
|
@@ -272,7 +316,10 @@ func (m *MCPClient) OpenMCPSession(ctx context.Context) (string, error) {
|
|
|
272
316
|
"jsonrpc": "2.0",
|
|
273
317
|
"method": "notifications/initialized",
|
|
274
318
|
}
|
|
275
|
-
notifReq,
|
|
319
|
+
notifReq, err := http.NewRequestWithContext(ctx2, "POST", m.BaseURL+"/mcp", nil)
|
|
320
|
+
if err != nil {
|
|
321
|
+
return sessionID, nil // session created, notification failed — non-fatal
|
|
322
|
+
}
|
|
276
323
|
data, err := json.Marshal(notifPayload)
|
|
277
324
|
if err != nil {
|
|
278
325
|
return sessionID, nil // session created, notification failed — non-fatal
|
|
@@ -297,7 +344,10 @@ func (m *MCPClient) CloseMCPSession(ctx context.Context, sessionID string) {
|
|
|
297
344
|
}
|
|
298
345
|
ctx2, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
299
346
|
defer cancel()
|
|
300
|
-
req,
|
|
347
|
+
req, err := http.NewRequestWithContext(ctx2, "DELETE", m.BaseURL+"/mcp", nil)
|
|
348
|
+
if err != nil {
|
|
349
|
+
return
|
|
350
|
+
}
|
|
301
351
|
for k, v := range m.authHeaders() {
|
|
302
352
|
req.Header.Set(k, v)
|
|
303
353
|
}
|