@hivemagnus/magnus-server 0.0.0-stage → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/.env.example +171 -0
  2. package/LICENSE +202 -0
  3. package/README.md +169 -2
  4. package/agent-version.json +1 -0
  5. package/dist/ai/HEARTBEAT.md +56 -0
  6. package/dist/ai/IDENTITY.md +54 -0
  7. package/dist/ai/MEMORY.md +40 -0
  8. package/dist/ai/TOOLS.md +538 -0
  9. package/dist/ai/USER.md +32 -0
  10. package/dist/cli/args.js +62 -0
  11. package/dist/cli/env-catalog.js +131 -0
  12. package/dist/cli/preflight.js +89 -0
  13. package/dist/cli.js +175 -0
  14. package/dist/config/cors.js +16 -0
  15. package/dist/config/env.js +392 -0
  16. package/dist/config/features.js +16 -0
  17. package/dist/config/index.js +3 -0
  18. package/dist/config/listener-security.js +38 -0
  19. package/dist/config/version.js +31 -0
  20. package/dist/db/client.js +44 -0
  21. package/dist/db/generated/prisma/browser.js +18 -0
  22. package/dist/db/generated/prisma/client.js +35 -0
  23. package/dist/db/generated/prisma/commonInputTypes.js +11 -0
  24. package/dist/db/generated/prisma/enums.js +42 -0
  25. package/dist/db/generated/prisma/internal/class.js +50 -0
  26. package/dist/db/generated/prisma/internal/prismaNamespace.js +1598 -0
  27. package/dist/db/generated/prisma/internal/prismaNamespaceBrowser.js +1569 -0
  28. package/dist/db/generated/prisma/models/A2ATask.js +2 -0
  29. package/dist/db/generated/prisma/models/AdmissionFence.js +2 -0
  30. package/dist/db/generated/prisma/models/Agent.js +2 -0
  31. package/dist/db/generated/prisma/models/AiConversation.js +2 -0
  32. package/dist/db/generated/prisma/models/AiDashboard.js +2 -0
  33. package/dist/db/generated/prisma/models/AiMemory.js +2 -0
  34. package/dist/db/generated/prisma/models/AiMessage.js +2 -0
  35. package/dist/db/generated/prisma/models/AiScheduledOp.js +2 -0
  36. package/dist/db/generated/prisma/models/AlertConditionState.js +2 -0
  37. package/dist/db/generated/prisma/models/AlertRule.js +2 -0
  38. package/dist/db/generated/prisma/models/AlertViolation.js +2 -0
  39. package/dist/db/generated/prisma/models/AnomalyEvent.js +2 -0
  40. package/dist/db/generated/prisma/models/ApplicationObservation.js +2 -0
  41. package/dist/db/generated/prisma/models/ArdentInstallation.js +2 -0
  42. package/dist/db/generated/prisma/models/ArdentProfile.js +2 -0
  43. package/dist/db/generated/prisma/models/ArdentScopeEnrollment.js +2 -0
  44. package/dist/db/generated/prisma/models/CommandResourceFence.js +2 -0
  45. package/dist/db/generated/prisma/models/CommandResourceLease.js +2 -0
  46. package/dist/db/generated/prisma/models/CommandResult.js +2 -0
  47. package/dist/db/generated/prisma/models/CronJob.js +2 -0
  48. package/dist/db/generated/prisma/models/CronJobExecution.js +2 -0
  49. package/dist/db/generated/prisma/models/DeployJob.js +2 -0
  50. package/dist/db/generated/prisma/models/DriftScan.js +2 -0
  51. package/dist/db/generated/prisma/models/EngineeringMetricSample.js +2 -0
  52. package/dist/db/generated/prisma/models/EngineeringRecoveryExercise.js +2 -0
  53. package/dist/db/generated/prisma/models/ExecutionRun.js +2 -0
  54. package/dist/db/generated/prisma/models/FilePatchTask.js +2 -0
  55. package/dist/db/generated/prisma/models/GpuSnapshot.js +2 -0
  56. package/dist/db/generated/prisma/models/HealthSnapshot.js +2 -0
  57. package/dist/db/generated/prisma/models/HermesCoreRollout.js +2 -0
  58. package/dist/db/generated/prisma/models/HermesCoreRolloutHost.js +2 -0
  59. package/dist/db/generated/prisma/models/HermesCredentialPool.js +2 -0
  60. package/dist/db/generated/prisma/models/HermesCredentialPoolAttachment.js +2 -0
  61. package/dist/db/generated/prisma/models/HermesCronJob.js +2 -0
  62. package/dist/db/generated/prisma/models/HermesHook.js +2 -0
  63. package/dist/db/generated/prisma/models/HermesInstallation.js +2 -0
  64. package/dist/db/generated/prisma/models/HermesMcpServer.js +2 -0
  65. package/dist/db/generated/prisma/models/HermesMcpServerAttachment.js +2 -0
  66. package/dist/db/generated/prisma/models/HermesMessagingBinding.js +2 -0
  67. package/dist/db/generated/prisma/models/HermesOperationJob.js +2 -0
  68. package/dist/db/generated/prisma/models/HermesPluginInstall.js +2 -0
  69. package/dist/db/generated/prisma/models/HermesProfile.js +2 -0
  70. package/dist/db/generated/prisma/models/HermesProviderConfig.js +2 -0
  71. package/dist/db/generated/prisma/models/HermesRegistryClient.js +2 -0
  72. package/dist/db/generated/prisma/models/HermesRegistryInventory.js +2 -0
  73. package/dist/db/generated/prisma/models/HermesRegistryReceipt.js +2 -0
  74. package/dist/db/generated/prisma/models/HermesRegistryRevision.js +2 -0
  75. package/dist/db/generated/prisma/models/HermesRegistryTarget.js +2 -0
  76. package/dist/db/generated/prisma/models/HermesRole.js +2 -0
  77. package/dist/db/generated/prisma/models/HermesRoleApplication.js +2 -0
  78. package/dist/db/generated/prisma/models/HermesSkillAssignment.js +2 -0
  79. package/dist/db/generated/prisma/models/HermesToolsetPolicy.js +2 -0
  80. package/dist/db/generated/prisma/models/IncidentLesson.js +2 -0
  81. package/dist/db/generated/prisma/models/LibraryCategory.js +2 -0
  82. package/dist/db/generated/prisma/models/LibraryFile.js +2 -0
  83. package/dist/db/generated/prisma/models/LogEntry.js +2 -0
  84. package/dist/db/generated/prisma/models/MagnusReleaseCanary.js +2 -0
  85. package/dist/db/generated/prisma/models/MaintenanceWindow.js +2 -0
  86. package/dist/db/generated/prisma/models/ManagedCronDefinition.js +2 -0
  87. package/dist/db/generated/prisma/models/ManagedCronOccurrence.js +2 -0
  88. package/dist/db/generated/prisma/models/Node.js +2 -0
  89. package/dist/db/generated/prisma/models/Notification.js +2 -0
  90. package/dist/db/generated/prisma/models/NotificationPreference.js +2 -0
  91. package/dist/db/generated/prisma/models/RemediationExecution.js +2 -0
  92. package/dist/db/generated/prisma/models/RemediationRule.js +2 -0
  93. package/dist/db/generated/prisma/models/RemoteCommand.js +2 -0
  94. package/dist/db/generated/prisma/models/ResourceDrainParticipant.js +2 -0
  95. package/dist/db/generated/prisma/models/ResourceEnrollment.js +2 -0
  96. package/dist/db/generated/prisma/models/ResourceParticipantWork.js +2 -0
  97. package/dist/db/generated/prisma/models/Role.js +2 -0
  98. package/dist/db/generated/prisma/models/RoleApplication.js +2 -0
  99. package/dist/db/generated/prisma/models/RolloutTarget.js +2 -0
  100. package/dist/db/generated/prisma/models/SecurityExportOutbox.js +2 -0
  101. package/dist/db/generated/prisma/models/SecurityFusionAction.js +2 -0
  102. package/dist/db/generated/prisma/models/SecurityFusionActionApproval.js +2 -0
  103. package/dist/db/generated/prisma/models/SecurityFusionCase.js +2 -0
  104. package/dist/db/generated/prisma/models/SecurityFusionCaseActivity.js +2 -0
  105. package/dist/db/generated/prisma/models/SecurityFusionCaseEntity.js +2 -0
  106. package/dist/db/generated/prisma/models/SecurityFusionCaseEvent.js +2 -0
  107. package/dist/db/generated/prisma/models/SecurityFusionCaseRelationship.js +2 -0
  108. package/dist/db/generated/prisma/models/SecurityFusionCollector.js +2 -0
  109. package/dist/db/generated/prisma/models/SecurityFusionCommandOutbox.js +2 -0
  110. package/dist/db/generated/prisma/models/SecurityFusionDeletionReceipt.js +2 -0
  111. package/dist/db/generated/prisma/models/SecurityFusionDelivery.js +2 -0
  112. package/dist/db/generated/prisma/models/SecurityFusionEntity.js +2 -0
  113. package/dist/db/generated/prisma/models/SecurityFusionEntityAlias.js +2 -0
  114. package/dist/db/generated/prisma/models/SecurityFusionEvent.js +2 -0
  115. package/dist/db/generated/prisma/models/SecurityFusionEventEntity.js +2 -0
  116. package/dist/db/generated/prisma/models/SecurityFusionEvidence.js +2 -0
  117. package/dist/db/generated/prisma/models/SecurityFusionInvestigation.js +2 -0
  118. package/dist/db/generated/prisma/models/SecurityFusionNonce.js +2 -0
  119. package/dist/db/generated/prisma/models/SecurityFusionReceiptChainHead.js +2 -0
  120. package/dist/db/generated/prisma/models/SecurityFusionRuleVersion.js +2 -0
  121. package/dist/db/generated/prisma/models/SecurityFusionSourceState.js +2 -0
  122. package/dist/db/generated/prisma/models/SecurityServiceState.js +2 -0
  123. package/dist/db/generated/prisma/models/SharedResourceFence.js +2 -0
  124. package/dist/db/generated/prisma/models/SharedResourceLease.js +2 -0
  125. package/dist/db/generated/prisma/models/SharedResourceLeaseResource.js +2 -0
  126. package/dist/db/generated/prisma/models/SkillInstallation.js +2 -0
  127. package/dist/db/generated/prisma/models/SkillRegistryEntry.js +2 -0
  128. package/dist/db/generated/prisma/models/SkillTag.js +2 -0
  129. package/dist/db/generated/prisma/models/SkillVersion.js +2 -0
  130. package/dist/db/generated/prisma/models/TeamApprovalDecision.js +2 -0
  131. package/dist/db/generated/prisma/models/User.js +2 -0
  132. package/dist/db/generated/prisma/models/WebhookDelivery.js +2 -0
  133. package/dist/db/generated/prisma/models/WebhookEndpoint.js +2 -0
  134. package/dist/db/generated/prisma/models.js +2 -0
  135. package/dist/db/index.js +3 -0
  136. package/dist/db/read-retry.js +35 -0
  137. package/dist/db/seed.js +348 -0
  138. package/dist/index.js +162 -0
  139. package/dist/middleware/auth.js +361 -0
  140. package/dist/middleware/body-limit.js +14 -0
  141. package/dist/middleware/correlation-id.js +13 -0
  142. package/dist/middleware/error-handler.js +28 -0
  143. package/dist/middleware/iam-token.js +21 -0
  144. package/dist/middleware/rate-limit.js +78 -0
  145. package/dist/middleware/request-logger.js +85 -0
  146. package/dist/middleware/security-headers.js +23 -0
  147. package/dist/middleware/tracing.js +120 -0
  148. package/dist/middleware/user-status.js +33 -0
  149. package/dist/openapi/spec.js +2656 -0
  150. package/dist/queue/redis.js +20 -0
  151. package/dist/queue/requeue.js +27 -0
  152. package/dist/queue/workers.js +342 -0
  153. package/dist/routes/ai-schedule.js +73 -0
  154. package/dist/routes/alerts.js +79 -0
  155. package/dist/routes/anomalies.js +101 -0
  156. package/dist/routes/ardent.js +82 -0
  157. package/dist/routes/assistant.js +417 -0
  158. package/dist/routes/audit.js +138 -0
  159. package/dist/routes/codex.js +65 -0
  160. package/dist/routes/commands.js +226 -0
  161. package/dist/routes/credentials.js +58 -0
  162. package/dist/routes/cron.js +292 -0
  163. package/dist/routes/dependencies.js +49 -0
  164. package/dist/routes/deploy.js +18 -0
  165. package/dist/routes/discovery.js +168 -0
  166. package/dist/routes/docs.js +24 -0
  167. package/dist/routes/drift.js +126 -0
  168. package/dist/routes/events-stream.js +87 -0
  169. package/dist/routes/files.js +214 -0
  170. package/dist/routes/fleet-checks.js +21 -0
  171. package/dist/routes/health.js +133 -0
  172. package/dist/routes/heartbeat.js +545 -0
  173. package/dist/routes/hermes-registry.js +278 -0
  174. package/dist/routes/hermes.js +61 -0
  175. package/dist/routes/library.js +402 -0
  176. package/dist/routes/logs.js +172 -0
  177. package/dist/routes/managed-cron.js +23 -0
  178. package/dist/routes/mcp.js +39 -0
  179. package/dist/routes/metrics.js +187 -0
  180. package/dist/routes/nodes.js +951 -0
  181. package/dist/routes/notifications.js +130 -0
  182. package/dist/routes/ops.js +258 -0
  183. package/dist/routes/orchestra.js +430 -0
  184. package/dist/routes/predictions.js +23 -0
  185. package/dist/routes/profiling.js +68 -0
  186. package/dist/routes/quick-command.js +72 -0
  187. package/dist/routes/remediation.js +111 -0
  188. package/dist/routes/resource-leases.js +297 -0
  189. package/dist/routes/roles.js +370 -0
  190. package/dist/routes/rollout.js +124 -0
  191. package/dist/routes/scan.js +116 -0
  192. package/dist/routes/security-backup.js +58 -0
  193. package/dist/routes/security-fusion.js +605 -0
  194. package/dist/routes/security-integration.js +71 -0
  195. package/dist/routes/self-update.js +129 -0
  196. package/dist/routes/shared-resource-leases.js +78 -0
  197. package/dist/routes/skills.js +485 -0
  198. package/dist/routes/stats.js +96 -0
  199. package/dist/routes/team-approvals.js +23 -0
  200. package/dist/routes/terminal-ticket.js +15 -0
  201. package/dist/routes/terminal.js +17 -0
  202. package/dist/routes/topology.js +37 -0
  203. package/dist/routes/users.js +219 -0
  204. package/dist/routes/webhooks.js +137 -0
  205. package/dist/schemas/command-reconciliation.js +14 -0
  206. package/dist/schemas/commands.js +51 -0
  207. package/dist/schemas/cron.js +33 -0
  208. package/dist/schemas/deploy.js +20 -0
  209. package/dist/schemas/files.js +14 -0
  210. package/dist/schemas/hermes.js +69 -0
  211. package/dist/schemas/index.js +11 -0
  212. package/dist/schemas/library.js +48 -0
  213. package/dist/schemas/logs.js +35 -0
  214. package/dist/schemas/managed-cron.js +127 -0
  215. package/dist/schemas/node-responses.js +87 -0
  216. package/dist/schemas/node-session-receipt.js +84 -0
  217. package/dist/schemas/nodes.js +36 -0
  218. package/dist/schemas/orchestra.js +118 -0
  219. package/dist/schemas/resource-participant-reconciliation.js +99 -0
  220. package/dist/schemas/roles.js +54 -0
  221. package/dist/schemas/shared-resource-lease.js +132 -0
  222. package/dist/schemas/skills.js +44 -0
  223. package/dist/schemas/users.js +28 -0
  224. package/dist/scripts/run-disposable-recovery-exercise.js +39 -0
  225. package/dist/sdk/index.js +2 -0
  226. package/dist/sdk/node-api-client.js +474 -0
  227. package/dist/security/approval-assertion.js +66 -0
  228. package/dist/security/command-completion-registry.js +35 -0
  229. package/dist/security/command-request.js +12 -0
  230. package/dist/security/command-result-signature.js +34 -0
  231. package/dist/security/managed-http.js +45 -0
  232. package/dist/security/native-completion-registry.js +44 -0
  233. package/dist/server.js +178 -0
  234. package/dist/services/admission-fence.js +71 -0
  235. package/dist/services/ai-assistant-service.js +2523 -0
  236. package/dist/services/ai-correlation-service.js +225 -0
  237. package/dist/services/ai-export-service.js +141 -0
  238. package/dist/services/ai-insights-service.js +219 -0
  239. package/dist/services/ai-schedule-service.js +145 -0
  240. package/dist/services/ai-scratchpad-service.js +222 -0
  241. package/dist/services/ai-tools.js +1343 -0
  242. package/dist/services/alert-service.js +313 -0
  243. package/dist/services/anomaly-detector.js +419 -0
  244. package/dist/services/api-local-work.js +79 -0
  245. package/dist/services/application-probes.js +309 -0
  246. package/dist/services/ardent-scope-enrollment.js +123 -0
  247. package/dist/services/ardent-service.js +86 -0
  248. package/dist/services/audit-service.js +308 -0
  249. package/dist/services/codex-service.js +209 -0
  250. package/dist/services/command-lifecycle.js +60 -0
  251. package/dist/services/command-resource-leases.js +305 -0
  252. package/dist/services/control-host-node.js +242 -0
  253. package/dist/services/credential-rotation-service.js +294 -0
  254. package/dist/services/dependency-service.js +145 -0
  255. package/dist/services/disposable-recovery-runner.js +595 -0
  256. package/dist/services/docker-group-health.js +121 -0
  257. package/dist/services/engineering-assurance.js +492 -0
  258. package/dist/services/engineering-evidence-ledger.js +94 -0
  259. package/dist/services/engineering-metric-evidence.js +26 -0
  260. package/dist/services/event-bus.js +227 -0
  261. package/dist/services/fleet-check-log.js +102 -0
  262. package/dist/services/forecast-service.js +154 -0
  263. package/dist/services/health-retention.js +175 -0
  264. package/dist/services/heartbeat-stream.js +63 -0
  265. package/dist/services/hermes-catalog-import.js +62 -0
  266. package/dist/services/hermes-cli-parser.js +671 -0
  267. package/dist/services/hermes-core-rollout.js +90 -0
  268. package/dist/services/hermes-dashboard-endpoint.js +13 -0
  269. package/dist/services/hermes-plugin-source.js +149 -0
  270. package/dist/services/hermes-registry-service.js +258 -0
  271. package/dist/services/hermes-service.js +566 -0
  272. package/dist/services/hivemem-client.js +85 -0
  273. package/dist/services/host-local-writer.js +82 -0
  274. package/dist/services/incident-evidence.js +110 -0
  275. package/dist/services/incident-lessons.js +186 -0
  276. package/dist/services/llm-providers/anthropic.js +143 -0
  277. package/dist/services/llm-providers/index.js +7 -0
  278. package/dist/services/llm-providers/llama-cpp.js +237 -0
  279. package/dist/services/llm-providers/ollama.js +292 -0
  280. package/dist/services/llm-providers/openai-compatible.js +200 -0
  281. package/dist/services/llm-providers/provider-error.js +36 -0
  282. package/dist/services/llm-providers/registry.js +45 -0
  283. package/dist/services/llm-providers/types.js +2 -0
  284. package/dist/services/log-emitter.js +19 -0
  285. package/dist/services/log-retention.js +66 -0
  286. package/dist/services/maintenance-service.js +29 -0
  287. package/dist/services/managed-cron.js +493 -0
  288. package/dist/services/managed-ssh-admission.js +68 -0
  289. package/dist/services/monitor-pulse.js +10 -0
  290. package/dist/services/node-issue-monitor.js +71 -0
  291. package/dist/services/node-service.js +35 -0
  292. package/dist/services/notification-retention.js +51 -0
  293. package/dist/services/notification-service.js +94 -0
  294. package/dist/services/operational-observations.js +112 -0
  295. package/dist/services/operations-config.js +67 -0
  296. package/dist/services/ops-service.js +491 -0
  297. package/dist/services/orchestra-extras-service.js +370 -0
  298. package/dist/services/orchestra-resources-service.js +530 -0
  299. package/dist/services/os-scheduler-writer.js +73 -0
  300. package/dist/services/password-service.js +22 -0
  301. package/dist/services/prediction-service.js +284 -0
  302. package/dist/services/recovery-exercises.js +682 -0
  303. package/dist/services/remediation-service.js +325 -0
  304. package/dist/services/resource-enrollment.js +433 -0
  305. package/dist/services/resource-node-lock.js +18 -0
  306. package/dist/services/resource-participant-work.js +302 -0
  307. package/dist/services/role-service.js +388 -0
  308. package/dist/services/rollout-service.js +440 -0
  309. package/dist/services/security-export.js +185 -0
  310. package/dist/services/security-fusion-actions.js +22 -0
  311. package/dist/services/security-fusion-approvals.js +83 -0
  312. package/dist/services/security-fusion-evidence-integrity.js +144 -0
  313. package/dist/services/security-fusion-ingest.js +101 -0
  314. package/dist/services/security-fusion-outbox.js +185 -0
  315. package/dist/services/security-fusion-receipt-chain.js +134 -0
  316. package/dist/services/security-fusion-service.js +751 -0
  317. package/dist/services/security-fusion-verification.js +50 -0
  318. package/dist/services/self-update-service.js +200 -0
  319. package/dist/services/shared-resource-leases.js +413 -0
  320. package/dist/services/skill-publication-bundle.js +90 -0
  321. package/dist/services/skill-publication-settlement.js +36 -0
  322. package/dist/services/skill-publication-state.js +40 -0
  323. package/dist/services/skill-registry-service.js +327 -0
  324. package/dist/services/skill-service.js +148 -0
  325. package/dist/services/ssh-exec-service.js +139 -0
  326. package/dist/services/ssh-host-verification.js +27 -0
  327. package/dist/services/tailscale-node-key-service.js +75 -0
  328. package/dist/services/team-approvals.js +118 -0
  329. package/dist/services/topology-service.js +138 -0
  330. package/dist/services/transfer-authority-snapshot.js +151 -0
  331. package/dist/services/webhook-credential-migration.js +97 -0
  332. package/dist/services/webhook-security.js +242 -0
  333. package/dist/services/webhook-service.js +494 -0
  334. package/dist/types/auth.js +3 -0
  335. package/dist/types/index.js +3 -0
  336. package/dist/types/library.js +3 -0
  337. package/dist/types/notifications.js +3 -0
  338. package/dist/types/roles.js +3 -0
  339. package/dist/types/shared-contracts.js +3 -0
  340. package/dist/utils/env.js +141 -0
  341. package/dist/utils/heartbeat-peer.js +19 -0
  342. package/dist/utils/idempotency.js +45 -0
  343. package/dist/utils/ip.js +25 -0
  344. package/dist/utils/json-fields.js +94 -0
  345. package/dist/utils/local-tls.js +39 -0
  346. package/dist/utils/magnus-home.js +15 -0
  347. package/dist/utils/node-url.js +59 -0
  348. package/dist/utils/redact.js +26 -0
  349. package/dist/utils/safe-equal.js +13 -0
  350. package/dist/utils/sentinel-nodes.js +16 -0
  351. package/dist/utils/validate.js +41 -0
  352. package/package.json +119 -4
  353. package/prisma/migrations/20261031000000_baseline/migration.sql +2935 -0
  354. package/prisma/migrations/migration_lock.toml +3 -0
  355. package/prisma/schema.prisma +2185 -0
  356. package/prisma.config.ts +14 -0
package/.env.example ADDED
@@ -0,0 +1,171 @@
1
+ # magnus-server configuration example.
2
+ #
3
+ # Copy to a private file (for example ~/.magnus/server.env, mode 0600) and
4
+ # pass it with `magnus-server --env-file <path>`, or use it as the Compose env
5
+ # file (docker/compose.yml). Variables already set in the environment win.
6
+ # An empty value means "unset". `magnus-server env-schema --format table`
7
+ # lists every documented variable; `magnus-server check` validates this file.
8
+ #
9
+ # Generate each secret with: openssl rand -hex 32
10
+ # Every secret must be distinct; there are no fallback values.
11
+
12
+ # ═══════════════════════════════════════════════════════════════════════════
13
+ # Required
14
+ # ═══════════════════════════════════════════════════════════════════════════
15
+
16
+ NODE_ENV=production
17
+
18
+ # PostgreSQL. Required in production. (Development falls back to
19
+ # postgresql://magnus@127.0.0.1:5432/magnus with no password.)
20
+ DATABASE_URL=postgresql://magnus:change-me@127.0.0.1:5432/magnus
21
+ # Used only by docker/compose.yml to initialise its PostgreSQL container.
22
+ POSTGRES_PASSWORD=
23
+ # Redis (queues, rate limits, event bus).
24
+ REDIS_URL=redis://127.0.0.1:6379
25
+ # Used only by docker/compose.yml.
26
+ REDIS_PASSWORD=
27
+
28
+ # Purpose-specific secrets, 32+ characters each.
29
+ API_SECRET=
30
+ JWT_SECRET=
31
+ NODE_MANAGER_SECRET=
32
+ AUDIT_HMAC_SECRET=
33
+ RESULT_SIGNING_SECRET=
34
+ LOG_INGEST_SIGNING_SECRET=
35
+ CREDENTIAL_ROTATION_KEY=
36
+ METRICS_TOKEN=
37
+ WEBHOOK_ENCRYPTION_KEY=
38
+
39
+ # HTTPS listener. TLS is required in production. Relative paths resolve
40
+ # against the working directory; absolute paths are recommended.
41
+ TLS_CERT_PATH=/etc/magnus-server/tls/server.crt
42
+ TLS_KEY_PATH=/etc/magnus-server/tls/server.key
43
+ CONTROL_API_PORT=4000
44
+ # CONTROL_API_BIND_HOST=0.0.0.0
45
+ # Public URL of this server; agents use it to report back.
46
+ CONTROL_API_URL=https://magnus.example.com:4000
47
+ # Browser origins allowed to call the API (the Magnus dashboard).
48
+ CORS_ORIGIN=https://magnus.example.com:3000
49
+ # DASHBOARD_PUBLIC_ORIGIN=https://magnus.example.com:3000
50
+
51
+ # Local development only: serve cleartext HTTP on loopback without a certificate.
52
+ # ALLOW_INSECURE_HTTP=true
53
+
54
+ # ═══════════════════════════════════════════════════════════════════════════
55
+ # Paths (optional)
56
+ # ═══════════════════════════════════════════════════════════════════════════
57
+
58
+ # Base directory for audit logs, credential rotation state and backups.
59
+ # MAGNUS_HOME=~/.magnus
60
+ # AUDIT_LOG_DIR=$MAGNUS_HOME/audit-logs
61
+ # CREDENTIAL_ROTATION_STATE_PATH=$MAGNUS_HOME/state/credential-rotations.json
62
+ # SKILLS_DIR= # defaults to the bundled @hivemagnus/magnus-skills catalogue
63
+
64
+ # ═══════════════════════════════════════════════════════════════════════════
65
+ # Agents (optional)
66
+ # ═══════════════════════════════════════════════════════════════════════════
67
+
68
+ # Let agents self-register through the discovery endpoint.
69
+ # ENABLE_AGENT_DISCOVERY=true
70
+ # AGENT_DISCOVERY_SECRET=
71
+ # DNS suffix used to derive agent certificate hostnames, and an optional
72
+ # suffix under which agents report their FQDN (for example an overlay network).
73
+ # AGENT_TLS_DOMAIN_SUFFIX=example.com
74
+ # MAGNUS_NODE_DNS_SUFFIX=nodes.example.com
75
+ # SSH credentials for installing and upgrading agents over SSH.
76
+ # SSH_USERNAME=deploy
77
+ # SSH_PRIVATE_KEY_PATH=/etc/magnus-server/ssh/id_ed25519
78
+ # SSH_HOST_KEY_PINS_FILE=/etc/magnus-server/ssh/host-key-pins.json
79
+ # SSH_PASSWORD=
80
+ # Account whose docker group membership is checked on the server host.
81
+ # MAGNUS_DOCKER_USER=deploy
82
+ # Durable node and shared-resource lease coordination.
83
+ # MAGNUS_RESOURCE_LEASES_ENABLED=true
84
+
85
+ # ═══════════════════════════════════════════════════════════════════════════
86
+ # Optional integrations — each is off until configured
87
+ # ═══════════════════════════════════════════════════════════════════════════
88
+
89
+ # ── Hive IAM: verify RS256 access tokens issued by Hive IAM ──
90
+ # When set, JWT_SECRET is no longer required for user tokens.
91
+ # IAM_CORE_URL=https://iam.example.com
92
+ # IAM_TOKEN_ISSUER=https://iam.example.com
93
+ # IAM_TOKEN_AUDIENCE=magnus
94
+
95
+ # ── Hive Router (or any OpenAI-compatible router) for managed Hermes Agents ──
96
+ # HIVE_ROUTER_URL / HIVE_ROUTER_MODEL / HIVE_ROUTER_API_KEY are accepted as aliases.
97
+ # MAGNUS_ROUTER_URL=https://router.example.com/v1
98
+ # MAGNUS_ROUTER_MODEL=
99
+ # MAGNUS_ROUTER_API_KEY=
100
+ # HIVE_ROUTER_HEALTH_URL=https://router.example.com/health
101
+
102
+ # ── HiveMem shared agent memory ──
103
+ # HIVEMEM_URL=https://hivemem.example.com
104
+ # HIVEMEM_TOKEN=
105
+ # MAGNUS_LESSONS_HIVEMEM_URL=
106
+ # MAGNUS_LESSONS_HIVEMEM_TOKEN=
107
+
108
+ # ── Security Fusion / external security console ──
109
+ # off (default): disabled, /api/v1/security-fusion/* answers 404.
110
+ # local: cases, evidence and receipts live in this server's database.
111
+ # remote: observations are exported to an external security console.
112
+ # SECURITY_FUSION_MODE=off
113
+ # local mode:
114
+ # SECURITY_FUSION_RECEIPT_SIGNING_KEY=
115
+ # SECURITY_FUSION_EVIDENCE_DIR=$MAGNUS_HOME/security-fusion/evidence
116
+ # SECURITY_FUSION_CONTAINMENT_COMMAND=/usr/local/sbin/your-containment-helper
117
+ # SECURITY_FUSION_MATTERMOST_URL=https://chat.example.com
118
+ # SECURITY_FUSION_MATTERMOST_BOT_TOKEN=
119
+ # SECURITY_FUSION_MATTERMOST_CHANNEL_ID=
120
+ # remote mode:
121
+ # MAGNUS_SECURITY_CONSOLE_URL=https://security.example.com
122
+ # SECURITY_FUSION_API_URL=https://security.example.com
123
+ # SECURITY_EXPORT_ENABLED=true
124
+ # SECURITY_EXPORT_SECRET=
125
+ # SECURITY_SUMMARY_TOKEN=
126
+ # SECURITY_INVENTORY_TOKEN_SHA256=
127
+ # SECURITY_BACKUP_TOKEN_SHA256=
128
+ # SECURITY_BACKUP_DIRECTORY=$MAGNUS_HOME/security-backups
129
+
130
+ # ── Hermes Agent plugin API ──
131
+ # Plugin credentials are ignored and plugin routes are unreachable unless enabled.
132
+ # Store only SHA-256 digests of the tokens here.
133
+ # MAGNUS_PLUGIN_API_ENABLED=true
134
+ # MAGNUS_PLUGIN_READ_TOKEN_DIGESTS_JSON={"hermes-1":"<sha256 of the read token>"}
135
+ # MAGNUS_PLUGIN_OPERATOR_TOKEN_SHA256=
136
+ # Plugin read consumer allowed to relay signed team-approval decisions, plus the
137
+ # Ed25519 key and actor bindings those decisions are verified against.
138
+ # MAGNUS_APPROVAL_BRIDGE_CONSUMER=hermes-1
139
+ # APPROVAL_SIGNER_PUBLIC_KEY_PATH=/etc/magnus-server/approval-signer.pub
140
+ # APPROVAL_TELEGRAM_ACTOR_SHA256=
141
+ # APPROVAL_IPHONE_ACTOR_SHA256=
142
+ # Read-only digests for an external observability collector and the fleet-check reporter.
143
+ # MAGNUS_COLLECTOR_TOKEN_SHA256=
144
+ # MAGNUS_FLEET_CHECK_TOKEN_SHA256=
145
+
146
+ # ── Hermes registry (skills, plugins, MCP backends) ──
147
+ # Background import of the bundled skill catalogue and plugin source monitoring.
148
+ # MAGNUS_HERMES_REGISTRY_ENABLED=true
149
+ # Short hostnames (optionally host:stage; stage 0 = canary) that may pull deployments.
150
+ # MAGNUS_REGISTRY_DEPLOY_HOSTS=canary-1:0,node-1:1,node-2:2
151
+ # Hosts that may submit changes but never pull.
152
+ # MAGNUS_REGISTRY_SUBMIT_ONLY_HOSTS=
153
+
154
+ # ── Fleet AI assistant (all optional) ──
155
+ # OLLAMA_URL=http://127.0.0.1:11434
156
+ # OLLAMA_MODEL=
157
+ # LLAMACPP_URL=http://127.0.0.1:8080
158
+ # OPENAI_API_KEY=
159
+ # OPENROUTER_API_KEY=
160
+ # ANTHROPIC_API_KEY=
161
+
162
+ # ═══════════════════════════════════════════════════════════════════════════
163
+ # Tuning (optional)
164
+ # ═══════════════════════════════════════════════════════════════════════════
165
+
166
+ # LOG_LEVEL=info
167
+ # DATABASE_POOL_SIZE=20
168
+ # LOG_RETENTION_DAYS=30
169
+ # HEALTH_SNAPSHOT_RETENTION_DAYS=7
170
+ # NOTIFICATION_READ_RETENTION_DAYS=30
171
+ # NOTIFICATION_MAX_RETENTION_DAYS=90
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,170 @@
1
- # Temporary Holding Version
1
+ # @hivemagnus/magnus-server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Magnus server is the control plane of a Magnus fleet. It is a Hono API
4
+ server backed by PostgreSQL and Redis that Linux hosts running
5
+ [`@hivemagnus/magnus-agent`](../../packages/agent) report to, and that the
6
+ [Magnus dashboard](../../apps/dashboard) talks to.
7
+
8
+ It keeps the fleet inventory and desired state, ingests agent heartbeats,
9
+ health snapshots and logs, dispatches signed commands, cron jobs, file syncs
10
+ and skill installs through a durable queue, and records every change in an
11
+ append-only audit log. Optional modules add anomaly detection and remediation
12
+ plans, rollouts, webhooks, an AI fleet assistant, Hermes Agent and Ardent
13
+ management, and Security Fusion.
14
+
15
+ ## Requirements
16
+
17
+ - Node.js `^24.22.1 || ^26.13.0`
18
+ - PostgreSQL 15 or later
19
+ - Redis 7 or later
20
+ - A TLS certificate for production (cleartext HTTP is a loopback-only development opt-in)
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ npm install -g @hivemagnus/magnus-server
26
+ magnus-server --help
27
+ ```
28
+
29
+ The package ships compiled JavaScript, the generated Prisma client, the Prisma
30
+ schema and every migration, so it needs no install-time code generation.
31
+
32
+ ## Configure
33
+
34
+ All configuration comes from environment variables. Start from the documented
35
+ example:
36
+
37
+ ```bash
38
+ mkdir -p ~/.magnus && cp "$(npm root -g)/@hivemagnus/magnus-server/.env.example" ~/.magnus/server.env
39
+ chmod 600 ~/.magnus/server.env
40
+ # fill in DATABASE_URL, REDIS_URL, TLS paths and the required secrets
41
+ # (one `openssl rand -hex 32` each; every secret must be different)
42
+ ```
43
+
44
+ `magnus-server env-schema --format table` lists every documented variable and
45
+ `magnus-server env-schema` prints the same list as JSON.
46
+
47
+ **Required:** `DATABASE_URL` (in production), `REDIS_URL`, `API_SECRET`,
48
+ `JWT_SECRET` (unless Hive IAM is configured), `NODE_MANAGER_SECRET`,
49
+ `AUDIT_HMAC_SECRET`, `RESULT_SIGNING_SECRET`, `LOG_INGEST_SIGNING_SECRET`,
50
+ `CREDENTIAL_ROTATION_KEY`, `METRICS_TOKEN`, `WEBHOOK_ENCRYPTION_KEY`, and in
51
+ production `TLS_CERT_PATH` / `TLS_KEY_PATH`. The server refuses to start while
52
+ any is missing; there are no fallback secret values.
53
+
54
+ Local data (audit logs, credential rotation state, uploaded backups) lives
55
+ under `MAGNUS_HOME`, default `~/.magnus`.
56
+
57
+ ## Run
58
+
59
+ ```bash
60
+ magnus-server check --env-file ~/.magnus/server.env # validate env, reach PostgreSQL and Redis, list integrations
61
+ magnus-server migrate --env-file ~/.magnus/server.env # apply migrations and base data
62
+ magnus-server start --env-file ~/.magnus/server.env # or: start --migrate
63
+ ```
64
+
65
+ | Command | Purpose |
66
+ | --- | --- |
67
+ | `start` (default) | Start the API server. `--migrate` applies pending migrations first. |
68
+ | `check` | Validate configuration, connect to PostgreSQL and Redis, report pending migrations and enabled integrations. Exits non-zero on a problem. |
69
+ | `migrate` | Run `prisma migrate deploy` with the packaged schema and migrations, then create the base rows (system actor, sentinel nodes, starter library). Idempotent. |
70
+ | `env-schema` | Print the documented environment variables (`--format json` or `table`). |
71
+ | `version`, `help` | Print the version or usage. |
72
+
73
+ `--env-file <path>` may be repeated. Variables already set in the process
74
+ environment take precedence, and empty values count as unset.
75
+
76
+ The API is served under `/api/v1`, interactive documentation at `/api/docs`
77
+ (OpenAPI 3.1 JSON at `/api/docs/openapi.json`), and Prometheus metrics at
78
+ `/metrics` (bearer `METRICS_TOKEN`).
79
+
80
+ ### Docker Compose
81
+
82
+ [`docker/compose.yml`](docker/compose.yml) runs magnus-server with PostgreSQL
83
+ and Redis. The image is built from the monorepo root with
84
+ [`Dockerfile`](Dockerfile): it builds and `npm pack`s the server and its
85
+ workspace dependencies, then installs those tarballs exactly as an npm user
86
+ would.
87
+
88
+ ```bash
89
+ cp services/control-api/.env.example services/control-api/docker/.env # set POSTGRES_PASSWORD, REDIS_PASSWORD and the secrets
90
+ docker compose -f services/control-api/docker/compose.yml --env-file services/control-api/docker/.env up -d --build
91
+ ```
92
+
93
+ Compose refuses to start while a required secret is missing. The server
94
+ listens on `https://127.0.0.1:4000`; without a mounted certificate it
95
+ generates a self-signed one for `MAGNUS_TLS_HOSTNAMES` (default `localhost`)
96
+ in its data volume, which is meant for evaluation only. To use a real
97
+ certificate, mount it and set `TLS_CERT_PATH` and `TLS_KEY_PATH`.
98
+ `bash services/control-api/scripts/check-compose.sh` brings the stack up with
99
+ throwaway secrets, checks it end to end and removes it again.
100
+
101
+ ## Optional integrations
102
+
103
+ Every integration is off until it is configured; the server starts and runs
104
+ without any of them. `magnus-server check` prints which are on.
105
+
106
+ | Integration | What it adds | Environment |
107
+ | --- | --- | --- |
108
+ | Hive IAM | RS256 access tokens issued by Hive IAM replace locally issued JWTs | `IAM_CORE_URL`, `IAM_TOKEN_ISSUER`, `IAM_TOKEN_AUDIENCE` |
109
+ | Hive Router | OpenAI-compatible model routing for managed Hermes Agents | `MAGNUS_ROUTER_URL` (alias `HIVE_ROUTER_URL`), `MAGNUS_ROUTER_MODEL`, `MAGNUS_ROUTER_API_KEY`, `HIVE_ROUTER_HEALTH_URL` |
110
+ | HiveMem | Shared agent memory for Hermes Agents and operational lessons | `HIVEMEM_URL`, `HIVEMEM_TOKEN`, `MAGNUS_LESSONS_HIVEMEM_URL`, `MAGNUS_LESSONS_HIVEMEM_TOKEN` |
111
+ | Security Fusion (local) | Security cases, evidence and signed receipts in this server | `SECURITY_FUSION_MODE=local`, `SECURITY_FUSION_RECEIPT_SIGNING_KEY`, optional `SECURITY_FUSION_EVIDENCE_DIR`, `SECURITY_FUSION_CONTAINMENT_COMMAND`, `SECURITY_FUSION_MATTERMOST_*` |
112
+ | External security console | Exports observations to an external console; local Security Fusion routes answer 410 with the console URL | `SECURITY_FUSION_MODE=remote`, `MAGNUS_SECURITY_CONSOLE_URL`, `SECURITY_FUSION_API_URL`, `SECURITY_EXPORT_ENABLED`, `SECURITY_EXPORT_SECRET`, `SECURITY_SUMMARY_TOKEN`, `SECURITY_INVENTORY_TOKEN_SHA256`, `SECURITY_BACKUP_TOKEN_SHA256` |
113
+ | Hermes Agent plugin API | Endpoint-scoped plugin credentials (read, operator) and the signed approval bridge | `MAGNUS_PLUGIN_API_ENABLED=true`, `MAGNUS_PLUGIN_READ_TOKEN_DIGESTS_JSON`, `MAGNUS_PLUGIN_OPERATOR_TOKEN_SHA256`, optional `MAGNUS_APPROVAL_BRIDGE_CONSUMER`, `APPROVAL_SIGNER_PUBLIC_KEY_*`, `APPROVAL_*_ACTOR_SHA256` |
114
+ | Hermes registry sync | Imports the bundled skill catalogue and tracks plugin sources; staged deployments to named hosts | `MAGNUS_HERMES_REGISTRY_ENABLED=true`, `MAGNUS_REGISTRY_DEPLOY_HOSTS`, `MAGNUS_REGISTRY_SUBMIT_ONLY_HOSTS` |
115
+ | Observability collector | Read-only credential for an external collector | `MAGNUS_COLLECTOR_TOKEN_SHA256` |
116
+ | AI fleet assistant | Ollama, llama.cpp, OpenAI, OpenRouter or Anthropic model profiles | `OLLAMA_URL`, `LLAMACPP_URL`, `OPENAI_API_KEY`, `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY` |
117
+ | Agent discovery | Agents self-register | `ENABLE_AGENT_DISCOVERY=true`, `AGENT_DISCOVERY_SECRET` |
118
+ | Resource leases | Durable node and shared-resource lease coordination | `MAGNUS_RESOURCE_LEASES_ENABLED=true` |
119
+
120
+ Credentials for services that call Magnus are stored only as SHA-256 digests.
121
+
122
+ SSH helpers require `SSH_HOST_KEY_PINS_FILE` before they open a connection.
123
+ Set it to an operator-owned JSON file mapping lowercase `hostname:port` keys
124
+ to arrays of OpenSSH SHA-256 fingerprints, for example:
125
+
126
+ ```json
127
+ {"node-1.example.com:22": ["SHA256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"]}
128
+ ```
129
+
130
+ Replace the example with fingerprints verified through a trusted channel.
131
+ Unknown destinations and changed keys fail before authentication. Multiple
132
+ pins permit a reviewed host-key rotation; remove the old pin afterward.
133
+ This setting does not enable the retired browser deployment routes.
134
+
135
+ ## Develop
136
+
137
+ From the repository root:
138
+
139
+ ```bash
140
+ npm ci
141
+ npm --workspace @hivemagnus/magnus-contracts run build
142
+ npm --workspace @hivemagnus/magnus-skills run build
143
+ npm --workspace @hivemagnus/magnus-server run db:generate
144
+ npm --workspace @hivemagnus/magnus-server run typecheck
145
+ npm --workspace @hivemagnus/magnus-server test # unit tests
146
+ npm --workspace @hivemagnus/magnus-server run build
147
+ ```
148
+
149
+ `npm run dev` (in this directory) runs the server with `tsx watch`. Without
150
+ `DATABASE_URL`, development connects to `postgresql://magnus@127.0.0.1:5432/magnus`
151
+ (role `magnus`, no password); production always requires `DATABASE_URL`. Set
152
+ `ALLOW_INSECURE_HTTP=true` to serve cleartext HTTP on loopback while
153
+ developing.
154
+
155
+ Integration tests need a disposable PostgreSQL database whose name starts with
156
+ `magnus_ideas_` and a Redis server:
157
+
158
+ ```bash
159
+ export TEST_DATABASE_URL=postgresql://magnus:<password>@127.0.0.1:5432/magnus_ideas_test
160
+ export DATABASE_URL=$TEST_DATABASE_URL REDIS_URL=redis://127.0.0.1:6379
161
+ npm --workspace @hivemagnus/magnus-server run db:migrate:deploy
162
+ npm --workspace @hivemagnus/magnus-server run test:integration
163
+ ```
164
+
165
+ Schema changes go in a new Prisma migration (`npm run db:migrate`); applied
166
+ migrations are never edited.
167
+
168
+ ## License
169
+
170
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1 @@
1
+ {"version":"1.0.2"}
@@ -0,0 +1,56 @@
1
+ # HEARTBEAT.md — AI Fleet Analysis Prompt
2
+
3
+ ## Invocation
4
+
5
+ This document is added when the assistant is invoked with conversation type
6
+ `heartbeat`. The Control API does not start a fixed built-in heartbeat timer.
7
+ An operator or external scheduler must invoke the flow, and the prompt can be
8
+ overridden through the assistant heartbeat-prompt API.
9
+
10
+ ## Procedure
11
+
12
+ ### 1. Review supplied context
13
+
14
+ Use the fleet and anomaly snapshots supplied with the request. Heartbeat calls
15
+ normally omit the native tool catalogue because the flow receives pre-gathered
16
+ context; analyze that context instead of initiating an unnecessary tool loop.
17
+
18
+ Evaluate:
19
+
20
+ - offline, degraded, or stale nodes;
21
+ - unresolved anomalies and alert violations;
22
+ - correlated symptoms across multiple nodes;
23
+ - recent command or rollout evidence included in the context;
24
+ - missing, delayed, or internally inconsistent telemetry.
25
+ - cached Codex installations with outdated clients, missing ChatGPT OAuth, or
26
+ stale scan timestamps.
27
+
28
+ ### 2. Analyze conservatively
29
+
30
+ Separate observed facts from inference. Treat unknown values and absent samples
31
+ as evidence gaps. Prefer an investigation or reversible action before a
32
+ state-changing recommendation.
33
+
34
+ ### 3. Record a concise result
35
+
36
+ The service stores the response in a `heartbeat` conversation. Heartbeat
37
+ conversations are grouped by UTC day. Include:
38
+
39
+ - a one-line fleet status;
40
+ - anomalies or alerts ordered by severity;
41
+ - trends or likely correlations;
42
+ - recommended next checks or actions;
43
+ - material evidence gaps.
44
+
45
+ ### 4. Memory
46
+
47
+ Only recommend or perform a memory update when the observation is durable and
48
+ actionable. Shared operational memories use HiveMem when configured. The local
49
+ `AiMemory` table remains for assistant settings such as prompt overrides and
50
+ tool policy, not as the primary shared fleet-memory store.
51
+
52
+ ## Failure Handling
53
+
54
+ - Return a partial analysis when some supplied context is unavailable.
55
+ - Name the missing source and avoid turning missing data into a healthy result.
56
+ - Do not retry indefinitely or conceal provider errors.
@@ -0,0 +1,54 @@
1
+ # IDENTITY.md — Magnus AI Fleet Operations Assistant
2
+
3
+ ## Who You Are
4
+
5
+ You are **Magnus AI**, the retained fleet-operations assistant in the Magnus
6
+ Control API. The production Governor is Hermes Agent with the `magnus` plugin;
7
+ this assistant serves compatibility APIs and local operational workflows.
8
+
9
+ ## Your Purpose
10
+
11
+ 1. **Inspect** current fleet health and operational evidence.
12
+ 2. **Detect** anomalies and correlate them with alerts, commands, and history.
13
+ 3. **Advise** operators with specific, evidence-backed next steps.
14
+ 4. **Remember** durable fleet knowledge through HiveMem when it is configured.
15
+ 5. **Act carefully** through approval-controlled tools when the operator asks.
16
+
17
+ ## Your Capabilities
18
+
19
+ - Read fleet health, cached Codex version/OAuth posture, Wazuh posture,
20
+ anomalies, alerts, audit events, and history.
21
+ - Inspect nodes, logs, cron jobs, skills, predictions, and rollout evidence.
22
+ - Read bounded workspace files and use a conversation scratchpad.
23
+ - Store and retrieve shared memories through HiveMem.
24
+ - Preview common commands and execute guarded actions subject to tool policy.
25
+
26
+ ## Operating Style
27
+
28
+ - Lead with the current status or conclusion.
29
+ - Use exact node names, values, timestamps, and evidence paths.
30
+ - Treat missing or unknown data as missing evidence, not a healthy result.
31
+ - Prefer read-only inspection before proposing or requesting an action.
32
+ - State the verification needed after any action.
33
+
34
+ ## Tool Use
35
+
36
+ Use the native function tools supplied with the model request. If a provider
37
+ cannot emit native tool calls, the service also accepts the text fallback format
38
+ documented in `TOOLS.md`. Never invent a tool name or argument.
39
+
40
+ For heartbeat-style analysis, structure the response as:
41
+
42
+ 1. **Status Overview**
43
+ 2. **Anomalies and Alerts**
44
+ 3. **Trends and Correlations**
45
+ 4. **Recommended Actions**
46
+ 5. **Evidence Gaps or Memory Updates**
47
+
48
+ ## Model Routing
49
+
50
+ Model selection is runtime configuration, not identity. Ollama is the default
51
+ provider, using `OLLAMA_URL` and `OLLAMA_MODEL`; task profiles can select
52
+ OpenAI-compatible, Anthropic, or OpenRouter providers and configured fallbacks.
53
+ Do not claim a particular host or model unless the current request context
54
+ confirms it.