@cortex-agent/server 2026.5.19-1
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/defaults/.claude/settings.json +13 -0
- package/defaults/CORTEX.md +15 -0
- package/defaults/config/budget.json +4 -0
- package/defaults/config/session-hooks.json +7 -0
- package/defaults/config/thread-templates.json +528 -0
- package/defaults/context/CORTEX.md +40 -0
- package/defaults/context/decisions/DR-0012.md +54 -0
- package/defaults/context/ideas/CORTEX.md +10 -0
- package/defaults/context/projects/CORTEX.md +25 -0
- package/defaults/context/scans/CORTEX.md +13 -0
- package/defaults/context/user/CORTEX.md +21 -0
- package/defaults/data/schedules.json +52 -0
- package/defaults/gitignore +44 -0
- package/defaults/hooks/ask-user-question-hook.mjs +66 -0
- package/defaults/hooks/cortex-md-injector.mjs +237 -0
- package/defaults/hooks/exit-plan-mode-hook.mjs +84 -0
- package/defaults/hooks/memory-ref-tracker.mjs +154 -0
- package/defaults/hooks/new-session-hook.mjs +83 -0
- package/defaults/hooks/post-task-hook.mjs +63 -0
- package/defaults/hooks/rules-loader.mjs +212 -0
- package/defaults/hooks/sensitive-file-edit.mjs +84 -0
- package/defaults/hooks/session-activity-tracker.mjs +254 -0
- package/defaults/hooks/task-status-check.mjs +218 -0
- package/defaults/hooks/tasks-yaml-guard.mjs +230 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +208 -0
- package/defaults/plugins/cortex-coder/skills/code-standards/SKILL.md +146 -0
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +164 -0
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +349 -0
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +104 -0
- package/defaults/plugins/cortex-common/skills/critique/SKILL.md +88 -0
- package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +508 -0
- package/defaults/plugins/cortex-common/skills/diagnose/SKILL.md +169 -0
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +135 -0
- package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +183 -0
- package/defaults/plugins/cortex-common/skills/synthesize/SKILL.md +120 -0
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +89 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +163 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +425 -0
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-system/skills/approval/SKILL.md +84 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +199 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/SKILL.md +201 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/extract_session.py +165 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/scan_logs.py +402 -0
- package/defaults/plugins/cortex-system/skills/evolve/SKILL.md +115 -0
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +262 -0
- package/defaults/plugins/cortex-system/skills/gravity/SKILL.md +125 -0
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +310 -0
- package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +85 -0
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +167 -0
- package/defaults/plugins/cortex-system/skills/refresh-skills/SKILL.md +153 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +209 -0
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +478 -0
- package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +95 -0
- package/defaults/prompts/directives/coder-reviewer.md +106 -0
- package/defaults/prompts/directives/coder.md +90 -0
- package/defaults/prompts/directives/director.md +97 -0
- package/defaults/prompts/directives/doc-reviewer.md +93 -0
- package/defaults/prompts/directives/doc-writer.md +85 -0
- package/defaults/prompts/directives/executor-reviewer.md +96 -0
- package/defaults/prompts/directives/executor.md +85 -0
- package/defaults/prompts/directives/milestone-executor.md +119 -0
- package/defaults/prompts/directives/milestone-reviewer.md +108 -0
- package/defaults/prompts/directives/plan-executor.md +121 -0
- package/defaults/prompts/directives/plan-reviewer.md +99 -0
- package/defaults/prompts/systemPrompts/coder.md +64 -0
- package/defaults/prompts/systemPrompts/direct.md +92 -0
- package/defaults/prompts/systemPrompts/web-opus-4-6.md +68 -0
- package/defaults/prompts/systemPrompts/web-sonnet-4-6.md +76 -0
- package/defaults/prompts/systemPrompts/web.md +50 -0
- package/defaults/prompts/systemPrompts/worker.md +67 -0
- package/defaults/rules/correction-propagation.md +31 -0
- package/defaults/rules/decision-records.md +49 -0
- package/defaults/rules/experiment-format.md +165 -0
- package/defaults/rules/issues-md.md +37 -0
- package/defaults/rules/meta-conventions.md +45 -0
- package/defaults/rules/mission-md.md +47 -0
- package/defaults/rules/overview-md.md +41 -0
- package/defaults/rules/roadmap-md.md +55 -0
- package/defaults/rules/status-md.md +49 -0
- package/defaults/rules/task-system.md +53 -0
- package/dist/agent-adapter/capabilities.d.ts +12 -0
- package/dist/agent-adapter/capabilities.js +52 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +140 -0
- package/dist/agent-adapter/claude/adapter-tui.js +422 -0
- package/dist/agent-adapter/claude/adapter.d.ts +85 -0
- package/dist/agent-adapter/claude/adapter.js +771 -0
- package/dist/agent-adapter/claude/cost-from-usage.d.ts +62 -0
- package/dist/agent-adapter/claude/cost-from-usage.js +97 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +49 -0
- package/dist/agent-adapter/claude/event-parser.d.ts +28 -0
- package/dist/agent-adapter/claude/event-parser.js +173 -0
- package/dist/agent-adapter/claude/hooks-builder.d.ts +36 -0
- package/dist/agent-adapter/claude/hooks-builder.js +57 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +68 -0
- package/dist/agent-adapter/claude/jsonl-tail.js +344 -0
- package/dist/agent-adapter/claude/spawn-args.d.ts +38 -0
- package/dist/agent-adapter/claude/spawn-args.js +83 -0
- package/dist/agent-adapter/claude/tmux-control.d.ts +69 -0
- package/dist/agent-adapter/claude/tmux-control.js +127 -0
- package/dist/agent-adapter/claude/tool-summarizers.d.ts +2 -0
- package/dist/agent-adapter/claude/tool-summarizers.js +24 -0
- package/dist/agent-adapter/codex/adapter.d.ts +42 -0
- package/dist/agent-adapter/codex/adapter.js +916 -0
- package/dist/agent-adapter/codex/event-parser.d.ts +17 -0
- package/dist/agent-adapter/codex/event-parser.js +41 -0
- package/dist/agent-adapter/codex/spawn-args.d.ts +6 -0
- package/dist/agent-adapter/codex/spawn-args.js +30 -0
- package/dist/agent-adapter/index.d.ts +8 -0
- package/dist/agent-adapter/index.js +33 -0
- package/dist/agent-adapter/normalize/event-stream.d.ts +6 -0
- package/dist/agent-adapter/normalize/event-stream.js +47 -0
- package/dist/agent-adapter/normalize/event-types.d.ts +58 -0
- package/dist/agent-adapter/normalize/event-types.js +5 -0
- package/dist/agent-adapter/normalize/hooks.d.ts +26 -0
- package/dist/agent-adapter/normalize/hooks.js +5 -0
- package/dist/agent-adapter/normalize/prompt-builder.d.ts +6 -0
- package/dist/agent-adapter/normalize/prompt-builder.js +23 -0
- package/dist/agent-adapter/normalize/tool-names.d.ts +6 -0
- package/dist/agent-adapter/normalize/tool-names.js +73 -0
- package/dist/agent-adapter/pi/adapter.d.ts +60 -0
- package/dist/agent-adapter/pi/adapter.js +626 -0
- package/dist/agent-adapter/pi/agent-dir.d.ts +11 -0
- package/dist/agent-adapter/pi/agent-dir.js +34 -0
- package/dist/agent-adapter/pi/event-parser.d.ts +26 -0
- package/dist/agent-adapter/pi/event-parser.js +313 -0
- package/dist/agent-adapter/pi/framing.d.ts +6 -0
- package/dist/agent-adapter/pi/framing.js +35 -0
- package/dist/agent-adapter/pi/hook-bridge.d.ts +59 -0
- package/dist/agent-adapter/pi/hook-bridge.js +233 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +26 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +140 -0
- package/dist/agent-adapter/pi/pi-ext-types.d.ts +90 -0
- package/dist/agent-adapter/pi/pi-ext-types.js +5 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +20 -0
- package/dist/agent-adapter/pi/spawn-args.js +54 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +2 -0
- package/dist/agent-adapter/pi/tool-shims.js +181 -0
- package/dist/agent-adapter/types.d.ts +94 -0
- package/dist/agent-adapter/types.js +5 -0
- package/dist/core/async-mutex.d.ts +6 -0
- package/dist/core/async-mutex.js +36 -0
- package/dist/core/cli-utils.d.ts +37 -0
- package/dist/core/cli-utils.js +69 -0
- package/dist/core/config-generator.d.ts +9 -0
- package/dist/core/config-generator.js +58 -0
- package/dist/core/gateway-generator.d.ts +46 -0
- package/dist/core/gateway-generator.js +336 -0
- package/dist/core/log.d.ts +7 -0
- package/dist/core/log.js +103 -0
- package/dist/core/paths.d.ts +32 -0
- package/dist/core/paths.js +49 -0
- package/dist/core/profile-generator.d.ts +65 -0
- package/dist/core/profile-generator.js +310 -0
- package/dist/core/running-executions.d.ts +88 -0
- package/dist/core/running-executions.js +186 -0
- package/dist/core/status-format.d.ts +18 -0
- package/dist/core/status-format.js +31 -0
- package/dist/core/task-parser.d.ts +69 -0
- package/dist/core/task-parser.js +423 -0
- package/dist/core/types/agent-types.d.ts +31 -0
- package/dist/core/types/agent-types.js +5 -0
- package/dist/core/types/thread-types.d.ts +261 -0
- package/dist/core/types/thread-types.js +5 -0
- package/dist/core/utils.d.ts +29 -0
- package/dist/core/utils.js +98 -0
- package/dist/core/version.d.ts +3 -0
- package/dist/core/version.js +12 -0
- package/dist/domain/agents/config.d.ts +58 -0
- package/dist/domain/agents/config.js +313 -0
- package/dist/domain/agents/facade.d.ts +52 -0
- package/dist/domain/agents/facade.js +264 -0
- package/dist/domain/agents/index.d.ts +2 -0
- package/dist/domain/agents/index.js +4 -0
- package/dist/domain/agents/profile-manager.d.ts +54 -0
- package/dist/domain/agents/profile-manager.js +161 -0
- package/dist/domain/costs/codex-event-format.d.ts +4 -0
- package/dist/domain/costs/codex-event-format.js +66 -0
- package/dist/domain/costs/codex-usage-monitor.d.ts +7 -0
- package/dist/domain/costs/codex-usage-monitor.js +72 -0
- package/dist/domain/costs/cost-tracker.d.ts +115 -0
- package/dist/domain/costs/cost-tracker.js +327 -0
- package/dist/domain/costs/gateway-manager.d.ts +6 -0
- package/dist/domain/costs/gateway-manager.js +228 -0
- package/dist/domain/costs/rate-limit-parser.d.ts +11 -0
- package/dist/domain/costs/rate-limit-parser.js +87 -0
- package/dist/domain/costs/rate-limit-throttle.d.ts +32 -0
- package/dist/domain/costs/rate-limit-throttle.js +129 -0
- package/dist/domain/executions/registry.d.ts +20 -0
- package/dist/domain/executions/registry.js +124 -0
- package/dist/domain/mcp/core-server.d.ts +2 -0
- package/dist/domain/mcp/core-server.js +34 -0
- package/dist/domain/mcp/server.d.ts +3 -0
- package/dist/domain/mcp/server.js +78 -0
- package/dist/domain/mcp/tools/context.d.ts +23 -0
- package/dist/domain/mcp/tools/context.js +51 -0
- package/dist/domain/mcp/tools/cortex-md.d.ts +17 -0
- package/dist/domain/mcp/tools/cortex-md.js +36 -0
- package/dist/domain/mcp/tools/cost.d.ts +2 -0
- package/dist/domain/mcp/tools/cost.js +54 -0
- package/dist/domain/mcp/tools/executions.d.ts +2 -0
- package/dist/domain/mcp/tools/executions.js +94 -0
- package/dist/domain/mcp/tools/schedule.d.ts +23 -0
- package/dist/domain/mcp/tools/schedule.js +245 -0
- package/dist/domain/mcp/tools/slack.d.ts +21 -0
- package/dist/domain/mcp/tools/slack.js +124 -0
- package/dist/domain/mcp/tools/task-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/task-ops.js +509 -0
- package/dist/domain/mcp/tools/tui-ask.d.ts +31 -0
- package/dist/domain/mcp/tools/tui-ask.js +108 -0
- package/dist/domain/mcp/tools/tui-plan.d.ts +28 -0
- package/dist/domain/mcp/tools/tui-plan.js +118 -0
- package/dist/domain/mcp/tui-server.d.ts +2 -0
- package/dist/domain/mcp/tui-server.js +69 -0
- package/dist/domain/memory/consolidate.d.ts +55 -0
- package/dist/domain/memory/consolidate.js +471 -0
- package/dist/domain/memory/cortex-md-injector.d.ts +30 -0
- package/dist/domain/memory/cortex-md-injector.js +123 -0
- package/dist/domain/memory/cortex-md-scanner.d.ts +9 -0
- package/dist/domain/memory/cortex-md-scanner.js +67 -0
- package/dist/domain/memory/index-regen.d.ts +19 -0
- package/dist/domain/memory/index-regen.js +398 -0
- package/dist/domain/memory/rules-loader.d.ts +27 -0
- package/dist/domain/memory/rules-loader.js +97 -0
- package/dist/domain/memory/skill-scanner.d.ts +5 -0
- package/dist/domain/memory/skill-scanner.js +132 -0
- package/dist/domain/memory/user-context.d.ts +5 -0
- package/dist/domain/memory/user-context.js +34 -0
- package/dist/domain/memory/watcher.d.ts +2 -0
- package/dist/domain/memory/watcher.js +81 -0
- package/dist/domain/monitor/disk-monitor.d.ts +20 -0
- package/dist/domain/monitor/disk-monitor.js +97 -0
- package/dist/domain/monitor/gpu-monitor.d.ts +26 -0
- package/dist/domain/monitor/gpu-monitor.js +135 -0
- package/dist/domain/remote/client-bootstrap.d.ts +1 -0
- package/dist/domain/remote/client-bootstrap.js +139 -0
- package/dist/domain/remote/client-hot-reload.d.ts +18 -0
- package/dist/domain/remote/client-hot-reload.js +142 -0
- package/dist/domain/remote/client-manager.d.ts +50 -0
- package/dist/domain/remote/client-manager.js +452 -0
- package/dist/domain/remote/cortex-client.d.ts +1 -0
- package/dist/domain/remote/cortex-client.js +704 -0
- package/dist/domain/scheduling/job-registry.d.ts +31 -0
- package/dist/domain/scheduling/job-registry.js +34 -0
- package/dist/domain/scheduling/jobs/_shared.d.ts +14 -0
- package/dist/domain/scheduling/jobs/_shared.js +45 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.d.ts +1 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.js +16 -0
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +11 -0
- package/dist/domain/scheduling/jobs/scheduled-task.js +186 -0
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +41 -0
- package/dist/domain/scheduling/jobs/target-dispatch.js +48 -0
- package/dist/domain/scheduling/jobs/task-archive.d.ts +1 -0
- package/dist/domain/scheduling/jobs/task-archive.js +19 -0
- package/dist/domain/scheduling/jobs/task-dispatch.d.ts +12 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +214 -0
- package/dist/domain/scheduling/runner.d.ts +13 -0
- package/dist/domain/scheduling/runner.js +24 -0
- package/dist/domain/scheduling/schedule-cli.d.ts +16 -0
- package/dist/domain/scheduling/schedule-cli.js +268 -0
- package/dist/domain/scheduling/schedule-command.d.ts +4 -0
- package/dist/domain/scheduling/schedule-command.js +274 -0
- package/dist/domain/scheduling/scheduler.d.ts +86 -0
- package/dist/domain/scheduling/scheduler.js +544 -0
- package/dist/domain/sessions/session-backup.d.ts +49 -0
- package/dist/domain/sessions/session-backup.js +217 -0
- package/dist/domain/sessions/session-hooks.d.ts +103 -0
- package/dist/domain/sessions/session-hooks.js +311 -0
- package/dist/domain/sessions/session-registry.d.ts +21 -0
- package/dist/domain/sessions/session-registry.js +31 -0
- package/dist/domain/sessions/session.d.ts +3 -0
- package/dist/domain/sessions/session.js +14 -0
- package/dist/domain/tasks/archiver.d.ts +9 -0
- package/dist/domain/tasks/archiver.js +123 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +37 -0
- package/dist/domain/tasks/dispatch-utils.js +143 -0
- package/dist/domain/tasks/dispatcher.d.ts +48 -0
- package/dist/domain/tasks/dispatcher.js +285 -0
- package/dist/domain/tasks/lint.d.ts +12 -0
- package/dist/domain/tasks/lint.js +102 -0
- package/dist/domain/tasks/mutator.d.ts +21 -0
- package/dist/domain/tasks/mutator.js +208 -0
- package/dist/domain/tasks/parser.d.ts +1 -0
- package/dist/domain/tasks/parser.js +6 -0
- package/dist/domain/tasks/pending-tracker.d.ts +67 -0
- package/dist/domain/tasks/pending-tracker.js +163 -0
- package/dist/domain/tasks/recommendation/extractor.d.ts +12 -0
- package/dist/domain/tasks/recommendation/extractor.js +563 -0
- package/dist/domain/tasks/recommendation/patterns.d.ts +11 -0
- package/dist/domain/tasks/recommendation/patterns.js +99 -0
- package/dist/domain/tasks/recommendation/types.d.ts +67 -0
- package/dist/domain/tasks/recommendation/types.js +5 -0
- package/dist/domain/tasks/store.d.ts +1 -0
- package/dist/domain/tasks/store.js +3 -0
- package/dist/domain/tasks/system/cortex-run.d.ts +24 -0
- package/dist/domain/tasks/system/cortex-run.js +342 -0
- package/dist/domain/tasks/system/task-cli.d.ts +49 -0
- package/dist/domain/tasks/system/task-cli.js +664 -0
- package/dist/domain/tasks/system/task-completion.d.ts +22 -0
- package/dist/domain/tasks/system/task-completion.js +89 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +24 -0
- package/dist/domain/tasks/system/task-id-utils.js +84 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +34 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.js +208 -0
- package/dist/domain/tasks/system/task-lock.d.ts +25 -0
- package/dist/domain/tasks/system/task-lock.js +139 -0
- package/dist/domain/tasks/system/task-mutations.d.ts +31 -0
- package/dist/domain/tasks/system/task-mutations.js +110 -0
- package/dist/domain/tasks/system/task-process.d.ts +37 -0
- package/dist/domain/tasks/system/task-process.js +119 -0
- package/dist/domain/tasks/system/task-state.d.ts +70 -0
- package/dist/domain/tasks/system/task-state.js +176 -0
- package/dist/domain/threads/artifact-io.d.ts +18 -0
- package/dist/domain/threads/artifact-io.js +182 -0
- package/dist/domain/threads/auto-thread.d.ts +3 -0
- package/dist/domain/threads/auto-thread.js +19 -0
- package/dist/domain/threads/hook-runner.d.ts +4 -0
- package/dist/domain/threads/hook-runner.js +250 -0
- package/dist/domain/threads/index.d.ts +5 -0
- package/dist/domain/threads/index.js +7 -0
- package/dist/domain/threads/prompt-builder.d.ts +25 -0
- package/dist/domain/threads/prompt-builder.js +176 -0
- package/dist/domain/threads/runner.d.ts +83 -0
- package/dist/domain/threads/runner.js +434 -0
- package/dist/domain/threads/state-machine.d.ts +61 -0
- package/dist/domain/threads/state-machine.js +440 -0
- package/dist/domain/threads/template-loader.d.ts +20 -0
- package/dist/domain/threads/template-loader.js +189 -0
- package/dist/domain/threads/template-resolver.d.ts +1 -0
- package/dist/domain/threads/template-resolver.js +95 -0
- package/dist/domain/threads/utils.d.ts +19 -0
- package/dist/domain/threads/utils.js +49 -0
- package/dist/entry/app.d.ts +1 -0
- package/dist/entry/app.js +234 -0
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +254 -0
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +521 -0
- package/dist/entry/init.d.ts +93 -0
- package/dist/entry/init.js +1299 -0
- package/dist/entry/startup-helpers.d.ts +2 -0
- package/dist/entry/startup-helpers.js +56 -0
- package/dist/entry/startup-notify.d.ts +10 -0
- package/dist/entry/startup-notify.js +20 -0
- package/dist/events/event-bus.d.ts +42 -0
- package/dist/events/event-bus.js +84 -0
- package/dist/events/event-logger.d.ts +12 -0
- package/dist/events/event-logger.js +135 -0
- package/dist/events/event-replay.d.ts +1 -0
- package/dist/events/event-replay.js +51 -0
- package/dist/events/event-types.d.ts +145 -0
- package/dist/events/event-types.js +5 -0
- package/dist/events/index.d.ts +5 -0
- package/dist/events/index.js +6 -0
- package/dist/hooks/ask-user-question-hook.mjs +66 -0
- package/dist/hooks/cortex-md-injector.mjs +237 -0
- package/dist/hooks/exit-plan-mode-hook.mjs +84 -0
- package/dist/hooks/memory-ref-tracker.mjs +154 -0
- package/dist/hooks/new-session-hook.mjs +83 -0
- package/dist/hooks/post-task-hook.mjs +63 -0
- package/dist/hooks/rules-loader.mjs +212 -0
- package/dist/hooks/sensitive-file-edit.mjs +84 -0
- package/dist/hooks/session-activity-tracker.mjs +254 -0
- package/dist/hooks/task-status-check.mjs +218 -0
- package/dist/hooks/tasks-yaml-guard.mjs +230 -0
- package/dist/orchestration/agent-runner.d.ts +72 -0
- package/dist/orchestration/agent-runner.js +289 -0
- package/dist/orchestration/busy-tracker.d.ts +12 -0
- package/dist/orchestration/busy-tracker.js +35 -0
- package/dist/orchestration/channel-queue.d.ts +18 -0
- package/dist/orchestration/channel-queue.js +32 -0
- package/dist/orchestration/dispatch-reconciler.d.ts +1 -0
- package/dist/orchestration/dispatch-reconciler.js +16 -0
- package/dist/orchestration/durable-helpers.d.ts +4 -0
- package/dist/orchestration/durable-helpers.js +42 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +32 -0
- package/dist/orchestration/interactions/ask-user-question.js +182 -0
- package/dist/orchestration/interactions/command-action-router.d.ts +47 -0
- package/dist/orchestration/interactions/command-action-router.js +91 -0
- package/dist/orchestration/interactions/interaction-handlers.d.ts +5 -0
- package/dist/orchestration/interactions/interaction-handlers.js +279 -0
- package/dist/orchestration/interactions/plan-approvals.d.ts +47 -0
- package/dist/orchestration/interactions/plan-approvals.js +77 -0
- package/dist/orchestration/interactions/plan-handler.d.ts +6 -0
- package/dist/orchestration/interactions/plan-handler.js +12 -0
- package/dist/orchestration/lifecycle.d.ts +50 -0
- package/dist/orchestration/lifecycle.js +308 -0
- package/dist/orchestration/orchestrator.d.ts +29 -0
- package/dist/orchestration/orchestrator.js +25 -0
- package/dist/orchestration/routing/commands/cancel.d.ts +10 -0
- package/dist/orchestration/routing/commands/cancel.js +136 -0
- package/dist/orchestration/routing/commands/channel.d.ts +11 -0
- package/dist/orchestration/routing/commands/channel.js +219 -0
- package/dist/orchestration/routing/commands/command-context.d.ts +29 -0
- package/dist/orchestration/routing/commands/command-context.js +4 -0
- package/dist/orchestration/routing/commands/cost.d.ts +3 -0
- package/dist/orchestration/routing/commands/cost.js +22 -0
- package/dist/orchestration/routing/commands/device.d.ts +6 -0
- package/dist/orchestration/routing/commands/device.js +83 -0
- package/dist/orchestration/routing/commands/dispatch.d.ts +2 -0
- package/dist/orchestration/routing/commands/dispatch.js +49 -0
- package/dist/orchestration/routing/commands/index.d.ts +15 -0
- package/dist/orchestration/routing/commands/index.js +130 -0
- package/dist/orchestration/routing/commands/mode.d.ts +13 -0
- package/dist/orchestration/routing/commands/mode.js +290 -0
- package/dist/orchestration/routing/commands/nvtop.d.ts +3 -0
- package/dist/orchestration/routing/commands/nvtop.js +103 -0
- package/dist/orchestration/routing/commands/orient.d.ts +2 -0
- package/dist/orchestration/routing/commands/orient.js +3 -0
- package/dist/orchestration/routing/commands/schedule.d.ts +4 -0
- package/dist/orchestration/routing/commands/schedule.js +132 -0
- package/dist/orchestration/routing/commands/sendfile.d.ts +2 -0
- package/dist/orchestration/routing/commands/sendfile.js +92 -0
- package/dist/orchestration/routing/commands/session.d.ts +9 -0
- package/dist/orchestration/routing/commands/session.js +153 -0
- package/dist/orchestration/routing/commands/status.d.ts +7 -0
- package/dist/orchestration/routing/commands/status.js +180 -0
- package/dist/orchestration/routing/commands/tail.d.ts +2 -0
- package/dist/orchestration/routing/commands/tail.js +73 -0
- package/dist/orchestration/routing/commands/task.d.ts +6 -0
- package/dist/orchestration/routing/commands/task.js +142 -0
- package/dist/orchestration/routing/commands/thread-handlers.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread-handlers.js +138 -0
- package/dist/orchestration/routing/commands/thread.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread.js +2 -0
- package/dist/orchestration/routing/edit-handler.d.ts +24 -0
- package/dist/orchestration/routing/edit-handler.js +161 -0
- package/dist/orchestration/routing/file-handler.d.ts +6 -0
- package/dist/orchestration/routing/file-handler.js +23 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +4 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.js +79 -0
- package/dist/orchestration/routing/hook-bridge.d.ts +30 -0
- package/dist/orchestration/routing/hook-bridge.js +112 -0
- package/dist/orchestration/routing/message-router.d.ts +6 -0
- package/dist/orchestration/routing/message-router.js +70 -0
- package/dist/orchestration/routing/webhook.d.ts +10 -0
- package/dist/orchestration/routing/webhook.js +239 -0
- package/dist/orchestration/status-helpers.d.ts +66 -0
- package/dist/orchestration/status-helpers.js +222 -0
- package/dist/orchestration/superseded-edits.d.ts +22 -0
- package/dist/orchestration/superseded-edits.js +31 -0
- package/dist/orchestration/thread-executor.d.ts +31 -0
- package/dist/orchestration/thread-executor.js +234 -0
- package/dist/platform/adapter.d.ts +28 -0
- package/dist/platform/adapter.js +5 -0
- package/dist/platform/adapters/feishu.d.ts +66 -0
- package/dist/platform/adapters/feishu.js +558 -0
- package/dist/platform/adapters/index.d.ts +16 -0
- package/dist/platform/adapters/index.js +65 -0
- package/dist/platform/adapters/slack.d.ts +90 -0
- package/dist/platform/adapters/slack.js +630 -0
- package/dist/platform/index.d.ts +12 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/interactive-builder.d.ts +27 -0
- package/dist/platform/interactive-builder.js +120 -0
- package/dist/platform/testing.d.ts +100 -0
- package/dist/platform/testing.js +190 -0
- package/dist/platform/tool-trace.d.ts +33 -0
- package/dist/platform/tool-trace.js +165 -0
- package/dist/platform/types.d.ts +176 -0
- package/dist/platform/types.js +5 -0
- package/dist/platform/utils/rate-limiter.d.ts +92 -0
- package/dist/platform/utils/rate-limiter.js +213 -0
- package/dist/platform/virtual-message.d.ts +68 -0
- package/dist/platform/virtual-message.js +464 -0
- package/dist/store/atomic-write.d.ts +6 -0
- package/dist/store/atomic-write.js +18 -0
- package/dist/store/channel-repo.d.ts +21 -0
- package/dist/store/channel-repo.js +55 -0
- package/dist/store/conversation-ledger-repo.d.ts +86 -0
- package/dist/store/conversation-ledger-repo.js +220 -0
- package/dist/store/cost-repo.d.ts +57 -0
- package/dist/store/cost-repo.js +135 -0
- package/dist/store/execution-repo.d.ts +172 -0
- package/dist/store/execution-repo.js +343 -0
- package/dist/store/in-memory-repository.d.ts +14 -0
- package/dist/store/in-memory-repository.js +31 -0
- package/dist/store/json-repository.d.ts +51 -0
- package/dist/store/json-repository.js +118 -0
- package/dist/store/outbound-queue.d.ts +65 -0
- package/dist/store/outbound-queue.js +269 -0
- package/dist/store/profile-repo.d.ts +36 -0
- package/dist/store/profile-repo.js +144 -0
- package/dist/store/project-dir-repo.d.ts +22 -0
- package/dist/store/project-dir-repo.js +60 -0
- package/dist/store/schedule-repo.d.ts +92 -0
- package/dist/store/schedule-repo.js +88 -0
- package/dist/store/session-registry-repo.d.ts +38 -0
- package/dist/store/session-registry-repo.js +96 -0
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +56 -0
- package/dist/store/task-repo.d.ts +41 -0
- package/dist/store/task-repo.js +137 -0
- package/dist/store/thread-repo.d.ts +50 -0
- package/dist/store/thread-repo.js +190 -0
- package/package.json +58 -0
- package/scripts/postinstall-restart-trigger.mjs +39 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// input: DATA_DIR/.claude/skills + DATA_DIR/plugins/*/skills + DATA_DIR/.codex/skills/.system
|
|
2
|
+
// output: getKnown/Display/Groups + normalize prefix
|
|
3
|
+
// pos: skill discovery and command prefix normalization
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { readdirSync, existsSync } from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { DATA_DIR, WORKSPACE_DIR, PLUGINS_DIR } from '../../core/utils.js';
|
|
8
|
+
import { createLogger } from '../../core/log.js';
|
|
9
|
+
const log = createLogger('skill-scanner');
|
|
10
|
+
const SKILL_SCAN_CACHE_MS = 60 * 1000;
|
|
11
|
+
// User-mutable skill roots under DATA_DIR — populated by `cortex init` (copy from defaults/)
|
|
12
|
+
// and editable by the user. INSTALL_ROOT/.claude is immutable package code, not scanned here.
|
|
13
|
+
const CLAUDE_SKILL_ROOT = path.join(DATA_DIR, '.claude', 'skills');
|
|
14
|
+
const PLUGINS_ROOT = PLUGINS_DIR;
|
|
15
|
+
const CODEX_SYSTEM_SKILL_ROOT = path.join(DATA_DIR, '.codex', 'skills', '.system');
|
|
16
|
+
const CODEX_ROUTE_ROOT = path.join(WORKSPACE_DIR, 'codex-routes');
|
|
17
|
+
let cachedDisplayGroups = [];
|
|
18
|
+
let cachedDisplayGroupsAt = 0;
|
|
19
|
+
let cachedKnownNames = new Set();
|
|
20
|
+
let cachedKnownNamesAt = 0;
|
|
21
|
+
function listSubdirectories(dir) {
|
|
22
|
+
if (!existsSync(dir))
|
|
23
|
+
return [];
|
|
24
|
+
try {
|
|
25
|
+
return readdirSync(dir, { withFileTypes: true })
|
|
26
|
+
.filter((entry) => entry.isDirectory())
|
|
27
|
+
.map((entry) => path.join(dir, entry.name));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
log.warn(`Failed to list directories: ${dir} (${error.message})`);
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function collectSkillNamesFromRoot(rootDir) {
|
|
35
|
+
if (!existsSync(rootDir))
|
|
36
|
+
return [];
|
|
37
|
+
const names = [];
|
|
38
|
+
const stack = [rootDir];
|
|
39
|
+
while (stack.length) {
|
|
40
|
+
const dir = stack.pop();
|
|
41
|
+
let entries = [];
|
|
42
|
+
try {
|
|
43
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (entries.some((e) => e.isFile() && e.name === 'SKILL.md')) {
|
|
49
|
+
names.push(path.basename(dir).toLowerCase());
|
|
50
|
+
}
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
if (entry.isDirectory())
|
|
53
|
+
stack.push(path.join(dir, entry.name));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return names;
|
|
57
|
+
}
|
|
58
|
+
function collectPluginSkillGroups() {
|
|
59
|
+
if (!existsSync(PLUGINS_ROOT))
|
|
60
|
+
return [];
|
|
61
|
+
const groups = [];
|
|
62
|
+
for (const pluginDir of listSubdirectories(PLUGINS_ROOT)) {
|
|
63
|
+
const skillsRoot = path.join(pluginDir, 'skills');
|
|
64
|
+
const skills = [...new Set(collectSkillNamesFromRoot(skillsRoot))].sort();
|
|
65
|
+
if (skills.length) {
|
|
66
|
+
groups.push({ plugin: path.basename(pluginDir).toLowerCase(), skills });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
groups.sort((a, b) => a.plugin.localeCompare(b.plugin));
|
|
70
|
+
return groups;
|
|
71
|
+
}
|
|
72
|
+
function getDisplaySkillGroups() {
|
|
73
|
+
const now = Date.now();
|
|
74
|
+
if (now - cachedDisplayGroupsAt < SKILL_SCAN_CACHE_MS)
|
|
75
|
+
return cachedDisplayGroups;
|
|
76
|
+
const groups = [];
|
|
77
|
+
const claudeSkills = [...new Set(collectSkillNamesFromRoot(CLAUDE_SKILL_ROOT))].sort();
|
|
78
|
+
if (claudeSkills.length)
|
|
79
|
+
groups.push({ plugin: null, skills: claudeSkills });
|
|
80
|
+
groups.push(...collectPluginSkillGroups());
|
|
81
|
+
cachedDisplayGroups = groups;
|
|
82
|
+
cachedDisplayGroupsAt = now;
|
|
83
|
+
return groups;
|
|
84
|
+
}
|
|
85
|
+
function getDisplaySkillNames() {
|
|
86
|
+
const names = new Set();
|
|
87
|
+
for (const group of getDisplaySkillGroups()) {
|
|
88
|
+
for (const skill of group.skills)
|
|
89
|
+
names.add(skill);
|
|
90
|
+
}
|
|
91
|
+
return names;
|
|
92
|
+
}
|
|
93
|
+
function getKnownSkillNames() {
|
|
94
|
+
const now = Date.now();
|
|
95
|
+
if (now - cachedKnownNamesAt < SKILL_SCAN_CACHE_MS)
|
|
96
|
+
return cachedKnownNames;
|
|
97
|
+
const names = new Set();
|
|
98
|
+
for (const name of collectSkillNamesFromRoot(CLAUDE_SKILL_ROOT))
|
|
99
|
+
names.add(name);
|
|
100
|
+
for (const { plugin, skills } of collectPluginSkillGroups()) {
|
|
101
|
+
for (const skill of skills) {
|
|
102
|
+
names.add(skill);
|
|
103
|
+
names.add(`${plugin}:${skill}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
for (const name of collectSkillNamesFromRoot(CODEX_SYSTEM_SKILL_ROOT))
|
|
107
|
+
names.add(name);
|
|
108
|
+
for (const routeDir of listSubdirectories(CODEX_ROUTE_ROOT)) {
|
|
109
|
+
for (const name of collectSkillNamesFromRoot(path.join(routeDir, '.codex', 'skills', '.system'))) {
|
|
110
|
+
names.add(name);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
cachedKnownNames = names;
|
|
114
|
+
cachedKnownNamesAt = now;
|
|
115
|
+
return names;
|
|
116
|
+
}
|
|
117
|
+
function normalizeSkillCommandPrefix(messageText) {
|
|
118
|
+
if (typeof messageText !== 'string')
|
|
119
|
+
return '';
|
|
120
|
+
const trimmedStart = messageText.trimStart();
|
|
121
|
+
if (!trimmedStart)
|
|
122
|
+
return messageText;
|
|
123
|
+
if (trimmedStart.startsWith('/') || trimmedStart.startsWith('!'))
|
|
124
|
+
return messageText;
|
|
125
|
+
const firstToken = trimmedStart.match(/^(\S+)/)?.[1];
|
|
126
|
+
if (!firstToken)
|
|
127
|
+
return messageText;
|
|
128
|
+
if (!getKnownSkillNames().has(firstToken.toLowerCase()))
|
|
129
|
+
return messageText;
|
|
130
|
+
return `/${trimmedStart}`;
|
|
131
|
+
}
|
|
132
|
+
export { getKnownSkillNames, getDisplaySkillNames, getDisplaySkillGroups, normalizeSkillCommandPrefix };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// input: REPO_ROOT, fs, thread record
|
|
2
|
+
// output: loadUserContext()
|
|
3
|
+
// pos: user profile injection — reads USER.md and injects in direct conversation threads
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { readFileSync, statSync } from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { CONTEXT_DIR } from '../../core/utils.js';
|
|
8
|
+
const USER_MD_PATH = path.join(CONTEXT_DIR, 'user', 'USER.md');
|
|
9
|
+
const DIRECT_TEMPLATES = new Set(['direct', 'direct-web', 'direct-review']);
|
|
10
|
+
let cachedContent = null;
|
|
11
|
+
let cachedMtimeMs = 0;
|
|
12
|
+
function readUserMd() {
|
|
13
|
+
try {
|
|
14
|
+
const stat = statSync(USER_MD_PATH);
|
|
15
|
+
if (stat.mtimeMs === cachedMtimeMs && cachedContent !== null)
|
|
16
|
+
return cachedContent;
|
|
17
|
+
cachedContent = readFileSync(USER_MD_PATH, 'utf8');
|
|
18
|
+
cachedMtimeMs = stat.mtimeMs;
|
|
19
|
+
return cachedContent;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function loadUserContext(thread) {
|
|
26
|
+
if (process.env.CORTEX_INJECT_USER_CONTEXT !== '1')
|
|
27
|
+
return null;
|
|
28
|
+
if (thread.templateName && !DIRECT_TEMPLATES.has(thread.templateName))
|
|
29
|
+
return null;
|
|
30
|
+
const content = readUserMd();
|
|
31
|
+
if (!content)
|
|
32
|
+
return null;
|
|
33
|
+
return `[User Context]\n${content}\n[/User Context]`;
|
|
34
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// input: projects/*/experiments|knowledge|patterns dirs
|
|
2
|
+
// output: auto-regenerated index.md on change
|
|
3
|
+
// pos: atomic memory index rebuild triggered by fs.watch
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { PROJECTS_DIR } from '../../core/utils.js';
|
|
8
|
+
import { regenProject } from './index-regen.js';
|
|
9
|
+
import { createLogger } from '../../core/log.js';
|
|
10
|
+
const log = createLogger('memory-watcher');
|
|
11
|
+
const MEMORY_SUBDIRS = ['experiments', 'knowledge', 'patterns'];
|
|
12
|
+
const DEBOUNCE_MS = 2000;
|
|
13
|
+
const watchers = [];
|
|
14
|
+
const pendingRegens = new Map();
|
|
15
|
+
function onFileChange(projectName, subdir, filename) {
|
|
16
|
+
// Only care about .md file changes (ignore index.md — we generate it)
|
|
17
|
+
if (!filename || !filename.endsWith('.md') || filename === 'index.md')
|
|
18
|
+
return;
|
|
19
|
+
// Debounce: multiple rapid writes to the same project → single regen
|
|
20
|
+
if (pendingRegens.has(projectName)) {
|
|
21
|
+
clearTimeout(pendingRegens.get(projectName));
|
|
22
|
+
}
|
|
23
|
+
pendingRegens.set(projectName, setTimeout(() => {
|
|
24
|
+
pendingRegens.delete(projectName);
|
|
25
|
+
try {
|
|
26
|
+
regenProject(projectName);
|
|
27
|
+
log.info(`Index regenerated for ${projectName} (triggered by ${subdir}/${filename})`);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
log.error(`Failed to regen ${projectName}:`, err);
|
|
31
|
+
}
|
|
32
|
+
}, DEBOUNCE_MS));
|
|
33
|
+
}
|
|
34
|
+
export function startMemoryWatcher() {
|
|
35
|
+
// Discover all project directories with memory subdirs
|
|
36
|
+
let projectDirs;
|
|
37
|
+
try {
|
|
38
|
+
projectDirs = fs.readdirSync(PROJECTS_DIR).filter(d => fs.statSync(path.join(PROJECTS_DIR, d)).isDirectory());
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
log.error('Cannot read projects directory');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let watchCount = 0;
|
|
45
|
+
for (const project of projectDirs) {
|
|
46
|
+
for (const subdir of MEMORY_SUBDIRS) {
|
|
47
|
+
const dir = path.join(PROJECTS_DIR, project, subdir);
|
|
48
|
+
if (!fs.existsSync(dir))
|
|
49
|
+
continue;
|
|
50
|
+
try {
|
|
51
|
+
const watcher = fs.watch(dir, (eventType, filename) => {
|
|
52
|
+
// On Linux, 'rename' fires for create/delete; 'change' for modify
|
|
53
|
+
onFileChange(project, subdir, filename);
|
|
54
|
+
});
|
|
55
|
+
watcher.on('error', (err) => {
|
|
56
|
+
log.error(`Watcher error for ${project}/${subdir}:`, err.message);
|
|
57
|
+
});
|
|
58
|
+
watchers.push(watcher);
|
|
59
|
+
watchCount++;
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
log.error(`Failed to watch ${project}/${subdir}:`, err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
log.info(`Watching ${watchCount} directories across ${projectDirs.length} projects`);
|
|
67
|
+
}
|
|
68
|
+
export function stopMemoryWatcher() {
|
|
69
|
+
for (const w of watchers) {
|
|
70
|
+
try {
|
|
71
|
+
w.close();
|
|
72
|
+
}
|
|
73
|
+
catch { /* ignore */ }
|
|
74
|
+
}
|
|
75
|
+
watchers.length = 0;
|
|
76
|
+
for (const timer of pendingRegens.values()) {
|
|
77
|
+
clearTimeout(timer);
|
|
78
|
+
}
|
|
79
|
+
pendingRegens.clear();
|
|
80
|
+
log.info('Stopped');
|
|
81
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PlatformAdapter } from '../../platform/index.js';
|
|
2
|
+
declare const WARN_BYTES: number;
|
|
3
|
+
declare const HYSTERESIS_BYTES: number;
|
|
4
|
+
declare const REALERT_COOLDOWN_MS: number;
|
|
5
|
+
interface AlertState {
|
|
6
|
+
hasAlerted: boolean;
|
|
7
|
+
lastAlertAt: number | null;
|
|
8
|
+
}
|
|
9
|
+
interface AlertDecision {
|
|
10
|
+
alert: boolean;
|
|
11
|
+
newState: AlertState;
|
|
12
|
+
}
|
|
13
|
+
declare function formatBytes(bytes: number): string;
|
|
14
|
+
declare function shouldAlert(freeBytes: number, state: AlertState, now: number): AlertDecision;
|
|
15
|
+
declare function checkDiskOnce(): Promise<void>;
|
|
16
|
+
declare function initDiskMonitor(adapter: PlatformAdapter, intervalMs?: number): void;
|
|
17
|
+
declare function stopDiskMonitor(): void;
|
|
18
|
+
declare function _testReset(): void;
|
|
19
|
+
export { initDiskMonitor, stopDiskMonitor, checkDiskOnce, shouldAlert, formatBytes, WARN_BYTES, HYSTERESIS_BYTES, REALERT_COOLDOWN_MS, _testReset, };
|
|
20
|
+
export type { AlertState, AlertDecision };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// input: PlatformAdapter, periodic timer, fs.statfs
|
|
2
|
+
// output: init/stop/checkDiskOnce + alert helpers
|
|
3
|
+
// pos: root filesystem capacity alert monitoring
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { promises as fsp } from 'fs';
|
|
6
|
+
import { createLogger } from '../../core/log.js';
|
|
7
|
+
const log = createLogger('disk-monitor');
|
|
8
|
+
const DEFAULT_CHECK_INTERVAL_MS = 5 * 60 * 1000;
|
|
9
|
+
const WARN_BYTES = 500 * 1024 * 1024;
|
|
10
|
+
const HYSTERESIS_BYTES = 1024 * 1024 * 1024;
|
|
11
|
+
const REALERT_COOLDOWN_MS = 60 * 60 * 1000;
|
|
12
|
+
const WATCH_PATH = '/';
|
|
13
|
+
let _adapter = null;
|
|
14
|
+
let _timer = null;
|
|
15
|
+
let _state = { hasAlerted: false, lastAlertAt: null };
|
|
16
|
+
function formatBytes(bytes) {
|
|
17
|
+
if (bytes >= 1024 * 1024 * 1024)
|
|
18
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
19
|
+
if (bytes >= 1024 * 1024)
|
|
20
|
+
return `${(bytes / (1024 * 1024)).toFixed(0)} MB`;
|
|
21
|
+
if (bytes >= 1024)
|
|
22
|
+
return `${(bytes / 1024).toFixed(0)} KB`;
|
|
23
|
+
return `${bytes} B`;
|
|
24
|
+
}
|
|
25
|
+
function shouldAlert(freeBytes, state, now) {
|
|
26
|
+
if (freeBytes >= HYSTERESIS_BYTES) {
|
|
27
|
+
return { alert: false, newState: { hasAlerted: false, lastAlertAt: null } };
|
|
28
|
+
}
|
|
29
|
+
if (freeBytes < WARN_BYTES) {
|
|
30
|
+
if (!state.hasAlerted) {
|
|
31
|
+
return { alert: true, newState: { hasAlerted: true, lastAlertAt: now } };
|
|
32
|
+
}
|
|
33
|
+
const elapsed = now - (state.lastAlertAt ?? 0);
|
|
34
|
+
if (elapsed >= REALERT_COOLDOWN_MS) {
|
|
35
|
+
return { alert: true, newState: { hasAlerted: true, lastAlertAt: now } };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { alert: false, newState: state };
|
|
39
|
+
}
|
|
40
|
+
async function getFreeBytes(path) {
|
|
41
|
+
const stat = await fsp.statfs(path);
|
|
42
|
+
return Number(stat.bsize) * Number(stat.bavail);
|
|
43
|
+
}
|
|
44
|
+
function sendDM(text) {
|
|
45
|
+
if (!_adapter)
|
|
46
|
+
return;
|
|
47
|
+
const adminChannel = _adapter.getAdminChannel();
|
|
48
|
+
if (!adminChannel) {
|
|
49
|
+
log.info('No admin channel configured, skipping DM');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
_adapter.postMessage(adminChannel, { text }).catch(e => {
|
|
53
|
+
log.error(`DM failed: ${e.message}`);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function checkDiskOnce() {
|
|
57
|
+
let freeBytes;
|
|
58
|
+
try {
|
|
59
|
+
freeBytes = await getFreeBytes(WATCH_PATH);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
log.error(`statfs(${WATCH_PATH}) failed: ${e.message}`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const decision = shouldAlert(freeBytes, _state, Date.now());
|
|
66
|
+
_state = decision.newState;
|
|
67
|
+
if (decision.alert) {
|
|
68
|
+
const msg = `:warning: Disk low on \`${WATCH_PATH}\`: only *${formatBytes(freeBytes)}* free (< ${formatBytes(WARN_BYTES)} threshold). Clean up or Cortex may crash.`;
|
|
69
|
+
log.info(`ALERT: free=${formatBytes(freeBytes)}`);
|
|
70
|
+
sendDM(msg);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function initDiskMonitor(adapter, intervalMs = DEFAULT_CHECK_INTERVAL_MS) {
|
|
74
|
+
if (_timer) {
|
|
75
|
+
log.info('Already initialized, skipping');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
_adapter = adapter;
|
|
79
|
+
_timer = setInterval(() => { checkDiskOnce().catch(e => log.error(`check failed: ${e.message}`)); }, intervalMs);
|
|
80
|
+
checkDiskOnce().catch(e => log.error(`initial check failed: ${e.message}`));
|
|
81
|
+
log.info(`Initialized (interval=${Math.round(intervalMs / 1000)}s, warn<${formatBytes(WARN_BYTES)}, recover>=${formatBytes(HYSTERESIS_BYTES)})`);
|
|
82
|
+
}
|
|
83
|
+
function stopDiskMonitor() {
|
|
84
|
+
if (_timer) {
|
|
85
|
+
clearInterval(_timer);
|
|
86
|
+
_timer = null;
|
|
87
|
+
}
|
|
88
|
+
_adapter = null;
|
|
89
|
+
}
|
|
90
|
+
function _testReset() {
|
|
91
|
+
if (_timer)
|
|
92
|
+
clearInterval(_timer);
|
|
93
|
+
_timer = null;
|
|
94
|
+
_adapter = null;
|
|
95
|
+
_state = { hasAlerted: false, lastAlertAt: null };
|
|
96
|
+
}
|
|
97
|
+
export { initDiskMonitor, stopDiskMonitor, checkDiskOnce, shouldAlert, formatBytes, WARN_BYTES, HYSTERESIS_BYTES, REALERT_COOLDOWN_MS, _testReset, };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type GpuProc = {
|
|
2
|
+
pid: string;
|
|
3
|
+
name: string;
|
|
4
|
+
memoryMB: number;
|
|
5
|
+
gpuUuid: string;
|
|
6
|
+
};
|
|
7
|
+
type GpuInfo = {
|
|
8
|
+
index: number;
|
|
9
|
+
uuid: string;
|
|
10
|
+
name: string;
|
|
11
|
+
utilPercent: number;
|
|
12
|
+
memUsedMB: number;
|
|
13
|
+
memTotalMB: number;
|
|
14
|
+
tempC: number;
|
|
15
|
+
powerW: number;
|
|
16
|
+
processes: GpuProc[];
|
|
17
|
+
};
|
|
18
|
+
type GpuSnapshot = {
|
|
19
|
+
machine: string;
|
|
20
|
+
capturedAt: string;
|
|
21
|
+
gpus: GpuInfo[];
|
|
22
|
+
};
|
|
23
|
+
declare function queryGpuSnapshot(machine: string): Promise<GpuSnapshot>;
|
|
24
|
+
declare function renderGpuSnapshot(snapshot: GpuSnapshot, historyByGpu: Map<string, number[]>, refreshSeconds?: number): string;
|
|
25
|
+
export { queryGpuSnapshot, renderGpuSnapshot };
|
|
26
|
+
export type { GpuSnapshot, GpuInfo, GpuProc };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// input: machine registry + client-manager exec
|
|
2
|
+
// output: queryGpuSnapshot + renderGpuSnapshot
|
|
3
|
+
// pos: GPU query and rendering shared with commands like !nvtop
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { getMachineRegistry } from '../tasks/dispatch-utils.js';
|
|
6
|
+
import { sendCommand, isDeviceOnline } from '../remote/client-manager.js';
|
|
7
|
+
const GPU_QUERY = 'nvidia-smi --query-gpu=index,uuid,name,utilization.gpu,memory.used,memory.total,temperature.gpu,power.draw --format=csv,noheader,nounits 2>/dev/null';
|
|
8
|
+
const PROC_QUERY = 'nvidia-smi --query-compute-apps=pid,process_name,used_memory,gpu_uuid --format=csv,noheader,nounits 2>/dev/null || echo ""';
|
|
9
|
+
const SPARK_CHARS = '▁▂▃▄▅▆▇█';
|
|
10
|
+
let cachedMockRaw = null;
|
|
11
|
+
let cachedMockState = null;
|
|
12
|
+
function parseMock(key) {
|
|
13
|
+
try {
|
|
14
|
+
const raw = process.env.CORTEX_GPU_MONITOR_MOCK;
|
|
15
|
+
if (!raw) {
|
|
16
|
+
cachedMockRaw = null;
|
|
17
|
+
cachedMockState = null;
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (raw !== cachedMockRaw) {
|
|
21
|
+
cachedMockRaw = raw;
|
|
22
|
+
cachedMockState = JSON.parse(raw);
|
|
23
|
+
}
|
|
24
|
+
const value = cachedMockState?.[key];
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return value.shift() ?? '';
|
|
27
|
+
return typeof value === 'string' ? value : null;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function execGpuCommand(machine, command, mockKey) {
|
|
34
|
+
const mocked = parseMock(mockKey);
|
|
35
|
+
if (mocked != null)
|
|
36
|
+
return mocked;
|
|
37
|
+
const reg = getMachineRegistry()[machine];
|
|
38
|
+
if (!reg)
|
|
39
|
+
throw new Error(`Unknown machine: ${machine}`);
|
|
40
|
+
if (!isDeviceOnline(machine))
|
|
41
|
+
throw new Error(`Device ${machine} is not online`);
|
|
42
|
+
const result = await sendCommand(machine, { action: 'bash', params: { command }, timeout: 15000 });
|
|
43
|
+
return result.stdout || '';
|
|
44
|
+
}
|
|
45
|
+
function parseGpuLine(line) {
|
|
46
|
+
const parts = line.split(',').map(part => part.trim());
|
|
47
|
+
if (parts.length < 8)
|
|
48
|
+
return null;
|
|
49
|
+
return {
|
|
50
|
+
index: parseInt(parts[0], 10),
|
|
51
|
+
uuid: parts[1],
|
|
52
|
+
name: parts[2],
|
|
53
|
+
utilPercent: parseInt(parts[3], 10) || 0,
|
|
54
|
+
memUsedMB: parseInt(parts[4], 10) || 0,
|
|
55
|
+
memTotalMB: parseInt(parts[5], 10) || 0,
|
|
56
|
+
tempC: parseInt(parts[6], 10) || 0,
|
|
57
|
+
powerW: Math.round(parseFloat(parts[7]) || 0),
|
|
58
|
+
processes: [],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function parseProcLine(line) {
|
|
62
|
+
const parts = line.split(',').map(part => part.trim());
|
|
63
|
+
if (parts.length < 4)
|
|
64
|
+
return null;
|
|
65
|
+
return {
|
|
66
|
+
pid: parts[0],
|
|
67
|
+
name: parts[1],
|
|
68
|
+
memoryMB: parseInt(parts[2], 10) || 0,
|
|
69
|
+
gpuUuid: parts[3],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async function queryGpuSnapshot(machine) {
|
|
73
|
+
const gpuOutput = await execGpuCommand(machine, GPU_QUERY, 'GPU');
|
|
74
|
+
const procOutput = await execGpuCommand(machine, PROC_QUERY, 'PROC');
|
|
75
|
+
const gpus = gpuOutput
|
|
76
|
+
.split('\n')
|
|
77
|
+
.map(line => line.trim())
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.map(parseGpuLine)
|
|
80
|
+
.filter(Boolean);
|
|
81
|
+
const procMap = new Map();
|
|
82
|
+
for (const proc of procOutput.split('\n').map(line => line.trim()).filter(Boolean).map(parseProcLine).filter(Boolean)) {
|
|
83
|
+
if (!procMap.has(proc.gpuUuid))
|
|
84
|
+
procMap.set(proc.gpuUuid, []);
|
|
85
|
+
procMap.get(proc.gpuUuid).push(proc);
|
|
86
|
+
}
|
|
87
|
+
for (const gpu of gpus) {
|
|
88
|
+
gpu.processes = procMap.get(gpu.uuid) || [];
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
machine,
|
|
92
|
+
capturedAt: new Date().toISOString(),
|
|
93
|
+
gpus,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function buildBar(percent, width = 10) {
|
|
97
|
+
const clamped = Math.max(0, Math.min(100, percent));
|
|
98
|
+
const filled = Math.round((clamped / 100) * width);
|
|
99
|
+
return `[${'█'.repeat(filled)}${'░'.repeat(width - filled)}]`;
|
|
100
|
+
}
|
|
101
|
+
function buildSparkline(history) {
|
|
102
|
+
if (history.length === 0)
|
|
103
|
+
return '▁';
|
|
104
|
+
return history.map(value => {
|
|
105
|
+
const clamped = Math.max(0, Math.min(100, value));
|
|
106
|
+
const idx = Math.min(SPARK_CHARS.length - 1, Math.floor((clamped / 100) * (SPARK_CHARS.length - 1)));
|
|
107
|
+
return SPARK_CHARS[idx];
|
|
108
|
+
}).join('');
|
|
109
|
+
}
|
|
110
|
+
function formatGiB(mb) {
|
|
111
|
+
return `${(mb / 1024).toFixed(1)} GB`;
|
|
112
|
+
}
|
|
113
|
+
function renderGpuSnapshot(snapshot, historyByGpu, refreshSeconds = 5) {
|
|
114
|
+
const lines = [`:desktop_computer: ${snapshot.machine} · refresh ${refreshSeconds}s`, ''];
|
|
115
|
+
for (const gpu of snapshot.gpus) {
|
|
116
|
+
const history = historyByGpu.get(gpu.uuid) || [];
|
|
117
|
+
const memPercent = gpu.memTotalMB > 0 ? (gpu.memUsedMB / gpu.memTotalMB) * 100 : 0;
|
|
118
|
+
lines.push(`GPU${gpu.index} ${gpu.name} ${gpu.utilPercent}% util ${formatGiB(gpu.memUsedMB)}/${formatGiB(gpu.memTotalMB)} ${gpu.tempC}C`);
|
|
119
|
+
lines.push(`Util ${buildBar(gpu.utilPercent)} ${gpu.utilPercent}%`);
|
|
120
|
+
lines.push(`Mem ${buildBar(memPercent)} ${Math.round(memPercent)}%`);
|
|
121
|
+
lines.push(`Pwr ${buildBar(Math.min(100, gpu.powerW / 3.0))} ${gpu.powerW}W`);
|
|
122
|
+
lines.push(`Spark ${buildSparkline(history)}`);
|
|
123
|
+
if (gpu.processes.length === 0) {
|
|
124
|
+
lines.push(' idle');
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
for (const proc of gpu.processes.slice(0, 4)) {
|
|
128
|
+
lines.push(` ${proc.pid} ${proc.name.slice(0, 24).padEnd(24, ' ')} ${formatGiB(proc.memoryMB)}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
lines.push('');
|
|
132
|
+
}
|
|
133
|
+
return lines.join('\n').trim();
|
|
134
|
+
}
|
|
135
|
+
export { queryGpuSnapshot, renderGpuSnapshot };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Cortex client bootstrap — one-time SSH deployment.
|
|
2
|
+
// Installs cortex-client as a global npm package and sets up systemd auto-start.
|
|
3
|
+
import { execFile } from 'child_process';
|
|
4
|
+
import { createLogger } from '../../core/log.js';
|
|
5
|
+
const log = createLogger('client-bootstrap');
|
|
6
|
+
// --- CLI args ---
|
|
7
|
+
function getArg(name) {
|
|
8
|
+
const idx = process.argv.indexOf(name);
|
|
9
|
+
if (idx !== -1 && idx + 1 < process.argv.length)
|
|
10
|
+
return process.argv[idx + 1];
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const sshHost = getArg('--host');
|
|
14
|
+
const deviceName = getArg('--device-name');
|
|
15
|
+
const serverHost = getArg('--server-host');
|
|
16
|
+
if (!serverHost) {
|
|
17
|
+
log.error('--server-host is required');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const serverPort = getArg('--server-port') || '3002';
|
|
21
|
+
if (!sshHost) {
|
|
22
|
+
log.error(`Usage: node --import tsx src/client-bootstrap.ts --host user@host --device-name NAME [options]
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--host <user@host> SSH target (required)
|
|
26
|
+
--device-name <name> Device name for cortex-client (required)
|
|
27
|
+
--server-host <host> Cortex server IP (required)
|
|
28
|
+
--server-port <port> Cortex server WS port (default: 3002)
|
|
29
|
+
`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
if (!deviceName) {
|
|
33
|
+
log.error('--device-name is required');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
// --- SSH helpers ---
|
|
37
|
+
function sshExec(command, timeout = 30000) {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
execFile('ssh', ['-o', 'StrictHostKeyChecking=no', sshHost, command], { timeout }, (err, stdout, stderr) => {
|
|
40
|
+
if (err)
|
|
41
|
+
reject(new Error(`SSH error: ${err.message}\n${stderr}`));
|
|
42
|
+
else
|
|
43
|
+
resolve(stdout.trim());
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// --- Bootstrap steps ---
|
|
48
|
+
async function main() {
|
|
49
|
+
console.log(`\n=== Cortex Client Bootstrap ===`);
|
|
50
|
+
console.log(` Target: ${sshHost}`);
|
|
51
|
+
console.log(` Device: ${deviceName}`);
|
|
52
|
+
console.log(` Server: ${serverHost}:${serverPort}`);
|
|
53
|
+
console.log('');
|
|
54
|
+
// Step 1: Check SSH connectivity
|
|
55
|
+
console.log('[1/5] Checking SSH connectivity...');
|
|
56
|
+
try {
|
|
57
|
+
const hostname = await sshExec('hostname');
|
|
58
|
+
console.log(` Connected to: ${hostname}`);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
log.error(`SSH connectivity check failed: ${e.message}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
// Step 2: Check Node.js >= 20
|
|
65
|
+
console.log('[2/5] Checking Node.js...');
|
|
66
|
+
try {
|
|
67
|
+
const nodeVersion = await sshExec('node --version');
|
|
68
|
+
console.log(` Node.js: ${nodeVersion}`);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
log.error('Node.js not found. Please install Node.js (v20+) on the target machine first.');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
// Step 3: Install cortex-client globally
|
|
75
|
+
console.log('[3/5] Installing cortex-client...');
|
|
76
|
+
try {
|
|
77
|
+
const installOutput = await sshExec('npm install -g cortex-client 2>&1', 120000);
|
|
78
|
+
console.log(` ${installOutput}`);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
log.error(`npm install -g cortex-client failed: ${e.message}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
// Step 4: Write client config
|
|
85
|
+
console.log('[4/5] Writing client config...');
|
|
86
|
+
const config = JSON.stringify({
|
|
87
|
+
serverHost,
|
|
88
|
+
serverPort: parseInt(serverPort, 10),
|
|
89
|
+
deviceName,
|
|
90
|
+
});
|
|
91
|
+
const escaped = config.replace(/'/g, "'\\''");
|
|
92
|
+
try {
|
|
93
|
+
await sshExec(`mkdir -p ~/.cortex/config && echo '${escaped}' > ~/.cortex/config/cortex-client.json`, 15000);
|
|
94
|
+
console.log(` Written ~/.cortex/config/cortex-client.json`);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
log.error(`Failed to write config: ${e.message}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
// Step 5: Create systemd service
|
|
101
|
+
console.log('[5/5] Setting up auto-start...');
|
|
102
|
+
const platform = await sshExec('uname -s').catch(() => 'unknown');
|
|
103
|
+
if (platform === 'Linux') {
|
|
104
|
+
const serviceContent = `[Unit]
|
|
105
|
+
Description=Cortex Client (${deviceName})
|
|
106
|
+
After=network.target
|
|
107
|
+
|
|
108
|
+
[Service]
|
|
109
|
+
Type=simple
|
|
110
|
+
ExecStart=/usr/bin/env cortex-client
|
|
111
|
+
Restart=always
|
|
112
|
+
RestartSec=5
|
|
113
|
+
|
|
114
|
+
[Install]
|
|
115
|
+
WantedBy=default.target
|
|
116
|
+
`;
|
|
117
|
+
await sshExec(`mkdir -p ~/.config/systemd/user`);
|
|
118
|
+
await sshExec(`cat > ~/.config/systemd/user/cortex-client.service << 'SVCEOF'\n${serviceContent}\nSVCEOF`);
|
|
119
|
+
await sshExec('systemctl --user daemon-reload');
|
|
120
|
+
await sshExec('systemctl --user enable cortex-client');
|
|
121
|
+
await sshExec('systemctl --user restart cortex-client');
|
|
122
|
+
console.log(' Created and started systemd user service: cortex-client');
|
|
123
|
+
console.log(' Check status: ssh ' + sshHost + ' "systemctl --user status cortex-client"');
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Non-Linux: just create a wrapper script
|
|
127
|
+
const startScript = '#!/bin/bash\nexec cortex-client\n';
|
|
128
|
+
await sshExec(`mkdir -p ~/.cortex/bin`);
|
|
129
|
+
await sshExec(`cat > ~/.cortex/bin/start-client.sh << 'SHEOF'\n${startScript}\nSHEOF`);
|
|
130
|
+
await sshExec(`chmod +x ~/.cortex/bin/start-client.sh`);
|
|
131
|
+
console.log(` Created start script: ~/.cortex/bin/start-client.sh`);
|
|
132
|
+
console.log(' Start manually: nohup cortex-client &');
|
|
133
|
+
}
|
|
134
|
+
console.log('\n=== Bootstrap complete ===\n');
|
|
135
|
+
}
|
|
136
|
+
main().catch((e) => {
|
|
137
|
+
log.error(`Bootstrap failed: ${e.message}`);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
});
|