@jagilber-org/index-server 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/CHANGELOG.md +1354 -0
  2. package/CODE_OF_CONDUCT.md +49 -0
  3. package/CONTRIBUTING.md +99 -0
  4. package/LICENSE +21 -0
  5. package/README.md +228 -0
  6. package/SECURITY.md +50 -0
  7. package/dist/config/configUtils.d.ts +11 -0
  8. package/dist/config/configUtils.js +87 -0
  9. package/dist/config/dashboardConfig.d.ts +46 -0
  10. package/dist/config/dashboardConfig.js +67 -0
  11. package/dist/config/defaultValues.d.ts +63 -0
  12. package/dist/config/defaultValues.js +72 -0
  13. package/dist/config/dirConstants.d.ts +18 -0
  14. package/dist/config/dirConstants.js +29 -0
  15. package/dist/config/featureConfig.d.ts +61 -0
  16. package/dist/config/featureConfig.js +121 -0
  17. package/dist/config/runtimeConfig.d.ts +151 -0
  18. package/dist/config/runtimeConfig.js +380 -0
  19. package/dist/config/serverConfig.d.ts +90 -0
  20. package/dist/config/serverConfig.js +167 -0
  21. package/dist/dashboard/analytics/AnalyticsEngine.d.ts +142 -0
  22. package/dist/dashboard/analytics/AnalyticsEngine.js +373 -0
  23. package/dist/dashboard/analytics/BusinessIntelligence.d.ts +187 -0
  24. package/dist/dashboard/analytics/BusinessIntelligence.js +594 -0
  25. package/dist/dashboard/client/admin.html +2175 -0
  26. package/dist/dashboard/client/chunks/mermaid-layout-elk.esm.min/chunk-SP2CHFBE.mjs +1 -0
  27. package/dist/dashboard/client/chunks/mermaid-layout-elk.esm.min/render-T6MDALS3.mjs +27 -0
  28. package/dist/dashboard/client/css/admin.css +1587 -0
  29. package/dist/dashboard/client/js/admin.auth.js +179 -0
  30. package/dist/dashboard/client/js/admin.boot.js +359 -0
  31. package/dist/dashboard/client/js/admin.config.js +196 -0
  32. package/dist/dashboard/client/js/admin.embeddings.js +426 -0
  33. package/dist/dashboard/client/js/admin.graph.js +615 -0
  34. package/dist/dashboard/client/js/admin.instances.js +120 -0
  35. package/dist/dashboard/client/js/admin.instructions.js +579 -0
  36. package/dist/dashboard/client/js/admin.logs.js +113 -0
  37. package/dist/dashboard/client/js/admin.maintenance.js +393 -0
  38. package/dist/dashboard/client/js/admin.messaging.js +636 -0
  39. package/dist/dashboard/client/js/admin.monitor.js +184 -0
  40. package/dist/dashboard/client/js/admin.overview.js +221 -0
  41. package/dist/dashboard/client/js/admin.performance.js +61 -0
  42. package/dist/dashboard/client/js/admin.sessions.js +292 -0
  43. package/dist/dashboard/client/js/admin.sqlite.js +373 -0
  44. package/dist/dashboard/client/js/admin.utils.js +49 -0
  45. package/dist/dashboard/client/js/chart.umd.js +14 -0
  46. package/dist/dashboard/client/js/elk.bundled.js +6696 -0
  47. package/dist/dashboard/client/js/marked.umd.js +74 -0
  48. package/dist/dashboard/client/js/mermaid.min.js +3022 -0
  49. package/dist/dashboard/client/mermaid-layout-elk.esm.min.mjs +1 -0
  50. package/dist/dashboard/export/DataExporter.d.ts +169 -0
  51. package/dist/dashboard/export/DataExporter.js +737 -0
  52. package/dist/dashboard/export/exporters/csvExporter.d.ts +11 -0
  53. package/dist/dashboard/export/exporters/csvExporter.js +47 -0
  54. package/dist/dashboard/export/exporters/exportTypes.d.ts +89 -0
  55. package/dist/dashboard/export/exporters/exportTypes.js +5 -0
  56. package/dist/dashboard/export/exporters/jsonExporter.d.ts +7 -0
  57. package/dist/dashboard/export/exporters/jsonExporter.js +23 -0
  58. package/dist/dashboard/export/exporters/xmlExporter.d.ts +17 -0
  59. package/dist/dashboard/export/exporters/xmlExporter.js +176 -0
  60. package/dist/dashboard/integration/APIIntegration.d.ts +41 -0
  61. package/dist/dashboard/integration/APIIntegration.js +95 -0
  62. package/dist/dashboard/security/SecurityMonitor.d.ts +167 -0
  63. package/dist/dashboard/security/SecurityMonitor.js +560 -0
  64. package/dist/dashboard/server/AdminPanel.d.ts +195 -0
  65. package/dist/dashboard/server/AdminPanel.js +861 -0
  66. package/dist/dashboard/server/AdminPanelConfig.d.ts +42 -0
  67. package/dist/dashboard/server/AdminPanelConfig.js +80 -0
  68. package/dist/dashboard/server/AdminPanelState.d.ts +47 -0
  69. package/dist/dashboard/server/AdminPanelState.js +215 -0
  70. package/dist/dashboard/server/ApiRoutes.d.ts +17 -0
  71. package/dist/dashboard/server/ApiRoutes.js +184 -0
  72. package/dist/dashboard/server/DashboardServer.d.ts +49 -0
  73. package/dist/dashboard/server/DashboardServer.js +160 -0
  74. package/dist/dashboard/server/FileMetricsStorage.d.ts +49 -0
  75. package/dist/dashboard/server/FileMetricsStorage.js +196 -0
  76. package/dist/dashboard/server/HttpTransport.d.ts +23 -0
  77. package/dist/dashboard/server/HttpTransport.js +116 -0
  78. package/dist/dashboard/server/InstanceManager.d.ts +53 -0
  79. package/dist/dashboard/server/InstanceManager.js +295 -0
  80. package/dist/dashboard/server/KnowledgeStore.d.ts +35 -0
  81. package/dist/dashboard/server/KnowledgeStore.js +105 -0
  82. package/dist/dashboard/server/LeaderElection.d.ts +81 -0
  83. package/dist/dashboard/server/LeaderElection.js +268 -0
  84. package/dist/dashboard/server/MetricsCollector.d.ts +200 -0
  85. package/dist/dashboard/server/MetricsCollector.js +810 -0
  86. package/dist/dashboard/server/SessionPersistenceManager.d.ts +88 -0
  87. package/dist/dashboard/server/SessionPersistenceManager.js +458 -0
  88. package/dist/dashboard/server/ThinClient.d.ts +64 -0
  89. package/dist/dashboard/server/ThinClient.js +237 -0
  90. package/dist/dashboard/server/WebSocketManager.d.ts +161 -0
  91. package/dist/dashboard/server/WebSocketManager.js +448 -0
  92. package/dist/dashboard/server/httpLifecycle.d.ts +17 -0
  93. package/dist/dashboard/server/httpLifecycle.js +35 -0
  94. package/dist/dashboard/server/legacyDashboardHtml.d.ts +9 -0
  95. package/dist/dashboard/server/legacyDashboardHtml.js +618 -0
  96. package/dist/dashboard/server/legacyDashboardStyles.d.ts +5 -0
  97. package/dist/dashboard/server/legacyDashboardStyles.js +490 -0
  98. package/dist/dashboard/server/metricsAggregation.d.ts +252 -0
  99. package/dist/dashboard/server/metricsAggregation.js +210 -0
  100. package/dist/dashboard/server/metricsSerializer.d.ts +25 -0
  101. package/dist/dashboard/server/metricsSerializer.js +195 -0
  102. package/dist/dashboard/server/middleware/ensureLoadedMiddleware.d.ts +25 -0
  103. package/dist/dashboard/server/middleware/ensureLoadedMiddleware.js +24 -0
  104. package/dist/dashboard/server/routes/admin.routes.d.ts +16 -0
  105. package/dist/dashboard/server/routes/admin.routes.js +574 -0
  106. package/dist/dashboard/server/routes/adminAuth.d.ts +4 -0
  107. package/dist/dashboard/server/routes/adminAuth.js +46 -0
  108. package/dist/dashboard/server/routes/alerts.routes.d.ts +7 -0
  109. package/dist/dashboard/server/routes/alerts.routes.js +91 -0
  110. package/dist/dashboard/server/routes/api.feedback.routes.d.ts +73 -0
  111. package/dist/dashboard/server/routes/api.feedback.routes.js +171 -0
  112. package/dist/dashboard/server/routes/api.instructions.routes.d.ts +101 -0
  113. package/dist/dashboard/server/routes/api.instructions.routes.js +213 -0
  114. package/dist/dashboard/server/routes/api.usage.routes.d.ts +57 -0
  115. package/dist/dashboard/server/routes/api.usage.routes.js +374 -0
  116. package/dist/dashboard/server/routes/embeddings.routes.d.ts +6 -0
  117. package/dist/dashboard/server/routes/embeddings.routes.js +246 -0
  118. package/dist/dashboard/server/routes/graph.routes.d.ts +6 -0
  119. package/dist/dashboard/server/routes/graph.routes.js +279 -0
  120. package/dist/dashboard/server/routes/index.d.ts +39 -0
  121. package/dist/dashboard/server/routes/index.js +229 -0
  122. package/dist/dashboard/server/routes/instances.routes.d.ts +6 -0
  123. package/dist/dashboard/server/routes/instances.routes.js +35 -0
  124. package/dist/dashboard/server/routes/instructions.routes.d.ts +8 -0
  125. package/dist/dashboard/server/routes/instructions.routes.js +268 -0
  126. package/dist/dashboard/server/routes/knowledge.routes.d.ts +6 -0
  127. package/dist/dashboard/server/routes/knowledge.routes.js +80 -0
  128. package/dist/dashboard/server/routes/logs.routes.d.ts +6 -0
  129. package/dist/dashboard/server/routes/logs.routes.js +166 -0
  130. package/dist/dashboard/server/routes/messaging.routes.d.ts +16 -0
  131. package/dist/dashboard/server/routes/messaging.routes.js +307 -0
  132. package/dist/dashboard/server/routes/metrics.routes.d.ts +10 -0
  133. package/dist/dashboard/server/routes/metrics.routes.js +335 -0
  134. package/dist/dashboard/server/routes/scripts.routes.d.ts +9 -0
  135. package/dist/dashboard/server/routes/scripts.routes.js +84 -0
  136. package/dist/dashboard/server/routes/sqlite.routes.d.ts +9 -0
  137. package/dist/dashboard/server/routes/sqlite.routes.js +570 -0
  138. package/dist/dashboard/server/routes/status.routes.d.ts +7 -0
  139. package/dist/dashboard/server/routes/status.routes.js +179 -0
  140. package/dist/dashboard/server/routes/synthetic.routes.d.ts +7 -0
  141. package/dist/dashboard/server/routes/synthetic.routes.js +197 -0
  142. package/dist/dashboard/server/routes/tools.routes.d.ts +6 -0
  143. package/dist/dashboard/server/routes/tools.routes.js +47 -0
  144. package/dist/dashboard/server/routes/usage.routes.d.ts +6 -0
  145. package/dist/dashboard/server/routes/usage.routes.js +26 -0
  146. package/dist/dashboard/server/wsInit.d.ts +16 -0
  147. package/dist/dashboard/server/wsInit.js +35 -0
  148. package/dist/externalClientLib.d.ts +1 -0
  149. package/dist/externalClientLib.js +2 -0
  150. package/dist/minimal/index.d.ts +1 -0
  151. package/dist/minimal/index.js +140 -0
  152. package/dist/models/SessionPersistence.d.ts +115 -0
  153. package/dist/models/SessionPersistence.js +66 -0
  154. package/dist/models/instruction.d.ts +46 -0
  155. package/dist/models/instruction.js +2 -0
  156. package/dist/perf/benchmark.d.ts +1 -0
  157. package/dist/perf/benchmark.js +50 -0
  158. package/dist/portableClientWrapper.d.ts +1 -0
  159. package/dist/portableClientWrapper.js +2 -0
  160. package/dist/schemas/index.d.ts +132 -0
  161. package/dist/schemas/index.js +372 -0
  162. package/dist/scripts/runPerformanceBaseline.d.ts +1 -0
  163. package/dist/scripts/runPerformanceBaseline.js +17 -0
  164. package/dist/server/backgroundServicesStartup.d.ts +3 -0
  165. package/dist/server/backgroundServicesStartup.js +51 -0
  166. package/dist/server/handshakeManager.d.ts +25 -0
  167. package/dist/server/handshakeManager.js +470 -0
  168. package/dist/server/index-server.d.ts +38 -0
  169. package/dist/server/index-server.js +620 -0
  170. package/dist/server/multiInstanceStartup.d.ts +6 -0
  171. package/dist/server/multiInstanceStartup.js +132 -0
  172. package/dist/server/registry.d.ts +44 -0
  173. package/dist/server/registry.js +236 -0
  174. package/dist/server/sdkServer.d.ts +8 -0
  175. package/dist/server/sdkServer.js +299 -0
  176. package/dist/server/shutdownGuard.d.ts +41 -0
  177. package/dist/server/shutdownGuard.js +52 -0
  178. package/dist/server/startupDiagnostics.d.ts +2 -0
  179. package/dist/server/startupDiagnostics.js +33 -0
  180. package/dist/server/thin-client.d.ts +22 -0
  181. package/dist/server/thin-client.js +111 -0
  182. package/dist/server/transport.d.ts +41 -0
  183. package/dist/server/transport.js +312 -0
  184. package/dist/server/transportFactory.d.ts +21 -0
  185. package/dist/server/transportFactory.js +429 -0
  186. package/dist/services/atomicFs.d.ts +22 -0
  187. package/dist/services/atomicFs.js +103 -0
  188. package/dist/services/auditLog.d.ts +38 -0
  189. package/dist/services/auditLog.js +142 -0
  190. package/dist/services/autoBackup.d.ts +14 -0
  191. package/dist/services/autoBackup.js +171 -0
  192. package/dist/services/autoSplit.d.ts +32 -0
  193. package/dist/services/autoSplit.js +113 -0
  194. package/dist/services/backupZip.d.ts +25 -0
  195. package/dist/services/backupZip.js +112 -0
  196. package/dist/services/bootstrapGating.d.ts +123 -0
  197. package/dist/services/bootstrapGating.js +221 -0
  198. package/dist/services/canonical.d.ts +23 -0
  199. package/dist/services/canonical.js +65 -0
  200. package/dist/services/categoryRules.d.ts +7 -0
  201. package/dist/services/categoryRules.js +37 -0
  202. package/dist/services/classificationService.d.ts +42 -0
  203. package/dist/services/classificationService.js +168 -0
  204. package/dist/services/embeddingService.d.ts +62 -0
  205. package/dist/services/embeddingService.js +264 -0
  206. package/dist/services/errors.d.ts +22 -0
  207. package/dist/services/errors.js +31 -0
  208. package/dist/services/featureFlags.d.ts +25 -0
  209. package/dist/services/featureFlags.js +89 -0
  210. package/dist/services/features.d.ts +13 -0
  211. package/dist/services/features.js +35 -0
  212. package/dist/services/handlers/instructions.add.d.ts +1 -0
  213. package/dist/services/handlers/instructions.add.js +510 -0
  214. package/dist/services/handlers/instructions.groom.d.ts +1 -0
  215. package/dist/services/handlers/instructions.groom.js +575 -0
  216. package/dist/services/handlers/instructions.import.d.ts +1 -0
  217. package/dist/services/handlers/instructions.import.js +205 -0
  218. package/dist/services/handlers/instructions.patch.d.ts +1 -0
  219. package/dist/services/handlers/instructions.patch.js +121 -0
  220. package/dist/services/handlers/instructions.query.d.ts +159 -0
  221. package/dist/services/handlers/instructions.query.js +469 -0
  222. package/dist/services/handlers/instructions.reload.d.ts +1 -0
  223. package/dist/services/handlers/instructions.reload.js +13 -0
  224. package/dist/services/handlers/instructions.remove.d.ts +1 -0
  225. package/dist/services/handlers/instructions.remove.js +122 -0
  226. package/dist/services/handlers/instructions.shared.d.ts +32 -0
  227. package/dist/services/handlers/instructions.shared.js +91 -0
  228. package/dist/services/handlers.activation.d.ts +1 -0
  229. package/dist/services/handlers.activation.js +203 -0
  230. package/dist/services/handlers.bootstrap.d.ts +1 -0
  231. package/dist/services/handlers.bootstrap.js +38 -0
  232. package/dist/services/handlers.dashboardConfig.d.ts +34 -0
  233. package/dist/services/handlers.dashboardConfig.js +110 -0
  234. package/dist/services/handlers.diagnostics.d.ts +1 -0
  235. package/dist/services/handlers.diagnostics.js +64 -0
  236. package/dist/services/handlers.feedback.d.ts +15 -0
  237. package/dist/services/handlers.feedback.js +389 -0
  238. package/dist/services/handlers.gates.d.ts +1 -0
  239. package/dist/services/handlers.gates.js +47 -0
  240. package/dist/services/handlers.graph.d.ts +53 -0
  241. package/dist/services/handlers.graph.js +231 -0
  242. package/dist/services/handlers.help.d.ts +1 -0
  243. package/dist/services/handlers.help.js +119 -0
  244. package/dist/services/handlers.instructionSchema.d.ts +1 -0
  245. package/dist/services/handlers.instructionSchema.js +227 -0
  246. package/dist/services/handlers.instructions.d.ts +8 -0
  247. package/dist/services/handlers.instructions.js +14 -0
  248. package/dist/services/handlers.instructionsDiagnostics.d.ts +1 -0
  249. package/dist/services/handlers.instructionsDiagnostics.js +14 -0
  250. package/dist/services/handlers.integrity.d.ts +1 -0
  251. package/dist/services/handlers.integrity.js +35 -0
  252. package/dist/services/handlers.manifest.d.ts +1 -0
  253. package/dist/services/handlers.manifest.js +24 -0
  254. package/dist/services/handlers.messaging.d.ts +12 -0
  255. package/dist/services/handlers.messaging.js +203 -0
  256. package/dist/services/handlers.metrics.d.ts +1 -0
  257. package/dist/services/handlers.metrics.js +43 -0
  258. package/dist/services/handlers.promote.d.ts +1 -0
  259. package/dist/services/handlers.promote.js +326 -0
  260. package/dist/services/handlers.prompt.d.ts +1 -0
  261. package/dist/services/handlers.prompt.js +7 -0
  262. package/dist/services/handlers.search.d.ts +69 -0
  263. package/dist/services/handlers.search.js +669 -0
  264. package/dist/services/handlers.testPrimitive.d.ts +1 -0
  265. package/dist/services/handlers.testPrimitive.js +5 -0
  266. package/dist/services/handlers.trace.d.ts +1 -0
  267. package/dist/services/handlers.trace.js +35 -0
  268. package/dist/services/handlers.usage.d.ts +1 -0
  269. package/dist/services/handlers.usage.js +11 -0
  270. package/dist/services/hotScore.d.ts +137 -0
  271. package/dist/services/hotScore.js +244 -0
  272. package/dist/services/indexContext.d.ts +117 -0
  273. package/dist/services/indexContext.js +989 -0
  274. package/dist/services/indexLoader.d.ts +44 -0
  275. package/dist/services/indexLoader.js +920 -0
  276. package/dist/services/indexRepository.d.ts +32 -0
  277. package/dist/services/indexRepository.js +71 -0
  278. package/dist/services/indexingService.d.ts +1 -0
  279. package/dist/services/indexingService.js +2 -0
  280. package/dist/services/instructions.dispatcher.d.ts +1 -0
  281. package/dist/services/instructions.dispatcher.js +231 -0
  282. package/dist/services/logPrefix.d.ts +1 -0
  283. package/dist/services/logPrefix.js +30 -0
  284. package/dist/services/logger.d.ts +52 -0
  285. package/dist/services/logger.js +268 -0
  286. package/dist/services/manifestManager.d.ts +82 -0
  287. package/dist/services/manifestManager.js +200 -0
  288. package/dist/services/messaging/agentMailbox.d.ts +60 -0
  289. package/dist/services/messaging/agentMailbox.js +353 -0
  290. package/dist/services/messaging/messagingPersistence.d.ts +20 -0
  291. package/dist/services/messaging/messagingPersistence.js +111 -0
  292. package/dist/services/messaging/messagingTypes.d.ts +150 -0
  293. package/dist/services/messaging/messagingTypes.js +66 -0
  294. package/dist/services/ownershipService.d.ts +1 -0
  295. package/dist/services/ownershipService.js +36 -0
  296. package/dist/services/performanceBaseline.d.ts +19 -0
  297. package/dist/services/performanceBaseline.js +210 -0
  298. package/dist/services/preflight.d.ts +12 -0
  299. package/dist/services/preflight.js +79 -0
  300. package/dist/services/promptReviewService.d.ts +44 -0
  301. package/dist/services/promptReviewService.js +101 -0
  302. package/dist/services/responseEnvelope.d.ts +6 -0
  303. package/dist/services/responseEnvelope.js +25 -0
  304. package/dist/services/seedBootstrap.d.ts +34 -0
  305. package/dist/services/seedBootstrap.js +259 -0
  306. package/dist/services/storage/factory.d.ts +17 -0
  307. package/dist/services/storage/factory.js +35 -0
  308. package/dist/services/storage/hashUtils.d.ts +11 -0
  309. package/dist/services/storage/hashUtils.js +35 -0
  310. package/dist/services/storage/index.d.ts +12 -0
  311. package/dist/services/storage/index.js +18 -0
  312. package/dist/services/storage/jsonFileStore.d.ts +32 -0
  313. package/dist/services/storage/jsonFileStore.js +241 -0
  314. package/dist/services/storage/migrationEngine.d.ts +35 -0
  315. package/dist/services/storage/migrationEngine.js +93 -0
  316. package/dist/services/storage/sqliteMessageStore.d.ts +53 -0
  317. package/dist/services/storage/sqliteMessageStore.js +146 -0
  318. package/dist/services/storage/sqliteSchema.d.ts +12 -0
  319. package/dist/services/storage/sqliteSchema.js +123 -0
  320. package/dist/services/storage/sqliteStore.d.ts +42 -0
  321. package/dist/services/storage/sqliteStore.js +361 -0
  322. package/dist/services/storage/sqliteUsageStore.d.ts +35 -0
  323. package/dist/services/storage/sqliteUsageStore.js +94 -0
  324. package/dist/services/storage/types.d.ts +171 -0
  325. package/dist/services/storage/types.js +12 -0
  326. package/dist/services/toolHandlers.d.ts +23 -0
  327. package/dist/services/toolHandlers.js +50 -0
  328. package/dist/services/toolRegistry.d.ts +20 -0
  329. package/dist/services/toolRegistry.js +490 -0
  330. package/dist/services/toolRegistry.zod.d.ts +10 -0
  331. package/dist/services/toolRegistry.zod.js +325 -0
  332. package/dist/services/tracing.d.ts +26 -0
  333. package/dist/services/tracing.js +260 -0
  334. package/dist/services/usageBuckets.d.ts +161 -0
  335. package/dist/services/usageBuckets.js +364 -0
  336. package/dist/services/validationService.d.ts +38 -0
  337. package/dist/services/validationService.js +125 -0
  338. package/dist/utils/BufferRing.d.ts +203 -0
  339. package/dist/utils/BufferRing.js +551 -0
  340. package/dist/utils/BufferRingExamples.d.ts +55 -0
  341. package/dist/utils/BufferRingExamples.js +188 -0
  342. package/dist/utils/envUtils.d.ts +42 -0
  343. package/dist/utils/envUtils.js +80 -0
  344. package/dist/utils/memoryMonitor.d.ts +83 -0
  345. package/dist/utils/memoryMonitor.js +275 -0
  346. package/dist/versioning/schemaVersion.d.ts +6 -0
  347. package/dist/versioning/schemaVersion.js +94 -0
  348. package/package.json +139 -0
  349. package/schemas/README.md +13 -0
  350. package/schemas/feedback-entry.schema.json +27 -0
  351. package/schemas/graph-export-v2.schema.json +60 -0
  352. package/schemas/index-server.code-schema.json +40670 -0
  353. package/schemas/instruction.schema.json +262 -0
  354. package/schemas/json-schema/SessionPersistence-persisted-admin-session.schema.json +54 -0
  355. package/schemas/json-schema/SessionPersistence-persisted-session-history-entry.schema.json +51 -0
  356. package/schemas/json-schema/SessionPersistence-persisted-web-socket-connection.schema.json +54 -0
  357. package/schemas/json-schema/SessionPersistence-session-persistence-config.schema.json +110 -0
  358. package/schemas/json-schema/SessionPersistence-session-persistence-data.schema.json +229 -0
  359. package/schemas/json-schema/SessionPersistence-session-persistence-manifest.schema.json +109 -0
  360. package/schemas/json-schema/SessionPersistence-session-persistence-metadata.schema.json +55 -0
  361. package/schemas/json-schema/instruction-audience-scope.schema.json +14 -0
  362. package/schemas/json-schema/instruction-content-type.schema.json +17 -0
  363. package/schemas/json-schema/instruction-instruction-entry.schema.json +210 -0
  364. package/schemas/json-schema/instruction-requirement-level.schema.json +16 -0
  365. package/schemas/manifest.json +78 -0
  366. package/schemas/manifest.schema.json +33 -0
  367. package/schemas/usage-batch.schema.json +16 -0
  368. package/schemas/usage-buckets.schema.json +30 -0
  369. package/schemas/usage-event.schema.json +17 -0
  370. package/scripts/copy-dashboard-assets.mjs +170 -0
  371. package/scripts/dist/README.md +15 -0
  372. package/scripts/setup-hooks.cjs +28 -0
@@ -0,0 +1,335 @@
1
+ "use strict";
2
+ /**
3
+ * Metrics & Analytics Routes
4
+ * Routes: GET /metrics, GET /metrics/history, GET /tools, GET /tools/:toolName,
5
+ * GET /performance, GET /performance/detailed, GET /realtime,
6
+ * GET /streaming/data, GET /charts/tool-usage, GET /charts/performance,
7
+ * GET /charts/timerange, GET /charts/export, GET /analytics/advanced
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.createMetricsRoutes = createMetricsRoutes;
11
+ const express_1 = require("express");
12
+ const registry_js_1 = require("../../../server/registry.js");
13
+ function createMetricsRoutes(metricsCollector) {
14
+ const router = (0, express_1.Router)();
15
+ /**
16
+ * GET /api/tools - List all registered tools
17
+ */
18
+ router.get('/tools', (_req, res) => {
19
+ try {
20
+ const tools = (0, registry_js_1.listRegisteredMethods)();
21
+ const toolMetrics = metricsCollector.getToolMetrics();
22
+ const enrichedTools = tools.map(toolName => ({
23
+ name: toolName,
24
+ metrics: toolMetrics[toolName] || {
25
+ callCount: 0,
26
+ successCount: 0,
27
+ errorCount: 0,
28
+ totalResponseTime: 0,
29
+ errorTypes: {},
30
+ },
31
+ }));
32
+ res.json({
33
+ tools: enrichedTools,
34
+ totalTools: tools.length,
35
+ timestamp: Date.now(),
36
+ });
37
+ }
38
+ catch (error) {
39
+ console.error('[API] Tools error:', error);
40
+ res.status(500).json({
41
+ error: 'Failed to get tools list',
42
+ });
43
+ }
44
+ });
45
+ /**
46
+ * GET /api/metrics - Current metrics snapshot
47
+ */
48
+ router.get('/metrics', (_req, res) => {
49
+ try {
50
+ const snapshot = metricsCollector.getCurrentSnapshot();
51
+ res.json(snapshot);
52
+ }
53
+ catch (error) {
54
+ console.error('[API] Metrics error:', error);
55
+ res.status(500).json({
56
+ error: 'Failed to get metrics',
57
+ });
58
+ }
59
+ });
60
+ /**
61
+ * GET /api/metrics/history - Historical metrics snapshots
62
+ */
63
+ router.get('/metrics/history', (req, res) => {
64
+ try {
65
+ const count = req.query.count ? parseInt(req.query.count, 10) : undefined;
66
+ const snapshots = metricsCollector.getSnapshots(count);
67
+ res.json({
68
+ snapshots,
69
+ count: snapshots.length,
70
+ timestamp: Date.now(),
71
+ });
72
+ }
73
+ catch (error) {
74
+ console.error('[API] Metrics history error:', error);
75
+ res.status(500).json({
76
+ error: 'Failed to get metrics history',
77
+ });
78
+ }
79
+ });
80
+ /**
81
+ * GET /api/tools/:toolName - Specific tool metrics
82
+ */
83
+ router.get('/tools/:toolName', (req, res) => {
84
+ try {
85
+ const { toolName } = req.params;
86
+ const metrics = metricsCollector.getToolMetrics(toolName);
87
+ if (!metrics) {
88
+ return res.status(404).json({
89
+ error: 'Tool not found',
90
+ toolName,
91
+ });
92
+ }
93
+ res.json({
94
+ toolName,
95
+ metrics,
96
+ timestamp: Date.now(),
97
+ });
98
+ }
99
+ catch (error) {
100
+ console.error('[API] Tool metrics error:', error);
101
+ res.status(500).json({
102
+ error: 'Failed to get tool metrics',
103
+ });
104
+ }
105
+ });
106
+ /**
107
+ * GET /api/performance - Performance summary
108
+ */
109
+ router.get('/performance', (_req, res) => {
110
+ try {
111
+ const snapshot = metricsCollector.getCurrentSnapshot();
112
+ res.json({
113
+ performance: snapshot.performance,
114
+ server: {
115
+ uptime: snapshot.server.uptime,
116
+ memoryUsage: snapshot.server.memoryUsage,
117
+ cpuUsage: snapshot.server.cpuUsage,
118
+ },
119
+ connections: snapshot.connections,
120
+ timestamp: snapshot.timestamp,
121
+ });
122
+ }
123
+ catch (error) {
124
+ console.error('[API] Performance error:', error);
125
+ res.status(500).json({
126
+ error: 'Failed to get performance metrics',
127
+ });
128
+ }
129
+ });
130
+ /**
131
+ * GET /api/realtime - Real-time metrics for dashboard widgets
132
+ */
133
+ router.get('/realtime', (_req, res) => {
134
+ try {
135
+ const realtimeMetrics = metricsCollector.getRealtimeMetrics();
136
+ res.json({
137
+ success: true,
138
+ data: realtimeMetrics,
139
+ timestamp: Date.now(),
140
+ });
141
+ }
142
+ catch (error) {
143
+ console.error('[API] Realtime metrics error:', error);
144
+ res.status(500).json({
145
+ error: 'Failed to get realtime metrics',
146
+ });
147
+ }
148
+ });
149
+ /**
150
+ * GET /api/streaming/data - Real-time streaming data for Phase 4
151
+ */
152
+ router.get('/streaming/data', (_req, res) => {
153
+ try {
154
+ const streamingData = metricsCollector.getRealtimeStreamingData();
155
+ res.json({
156
+ success: true,
157
+ data: streamingData,
158
+ timestamp: Date.now()
159
+ });
160
+ }
161
+ catch (error) {
162
+ console.error('[API] Streaming data error:', error);
163
+ res.status(500).json({
164
+ error: 'Failed to get streaming data',
165
+ });
166
+ }
167
+ });
168
+ /**
169
+ * GET /api/charts/tool-usage - Tool usage chart data
170
+ * Query params: minutes (default: 60)
171
+ */
172
+ router.get('/charts/tool-usage', (req, res) => {
173
+ try {
174
+ const minutes = parseInt(req.query.minutes) || 60;
175
+ const chartData = metricsCollector.getToolUsageChartData(minutes);
176
+ res.json({
177
+ success: true,
178
+ data: chartData,
179
+ timeRange: `${minutes} minutes`,
180
+ timestamp: Date.now(),
181
+ });
182
+ }
183
+ catch (error) {
184
+ console.error('[API] Tool usage chart error:', error);
185
+ res.status(500).json({
186
+ error: 'Failed to get tool usage chart data',
187
+ });
188
+ }
189
+ });
190
+ /**
191
+ * GET /api/charts/performance - Performance metrics chart data
192
+ * Query params: minutes (default: 60)
193
+ */
194
+ router.get('/charts/performance', (req, res) => {
195
+ try {
196
+ const minutes = parseInt(req.query.minutes) || 60;
197
+ const chartData = metricsCollector.getPerformanceChartData(minutes);
198
+ res.json({
199
+ success: true,
200
+ data: chartData,
201
+ timeRange: `${minutes} minutes`,
202
+ timestamp: Date.now(),
203
+ });
204
+ }
205
+ catch (error) {
206
+ console.error('[API] Performance chart error:', error);
207
+ res.status(500).json({
208
+ error: 'Failed to get performance chart data',
209
+ });
210
+ }
211
+ });
212
+ /**
213
+ * GET /api/charts/timerange - Metrics for specific time ranges
214
+ * Query params: range (1h, 6h, 24h, 7d, 30d)
215
+ */
216
+ router.get('/charts/timerange', (req, res) => {
217
+ try {
218
+ const range = req.query.range || '1h';
219
+ const validRanges = ['1h', '6h', '24h', '7d', '30d'];
220
+ if (!validRanges.includes(range)) {
221
+ return res.status(400).json({
222
+ error: 'Invalid time range',
223
+ message: `Range must be one of: ${validRanges.join(', ')}`,
224
+ validRanges,
225
+ });
226
+ }
227
+ const timeRangeData = metricsCollector.getTimeRangeMetrics(range);
228
+ res.json({
229
+ success: true,
230
+ data: timeRangeData,
231
+ range,
232
+ count: timeRangeData.length,
233
+ timestamp: Date.now(),
234
+ });
235
+ }
236
+ catch (error) {
237
+ console.error('[API] Time range chart error:', error);
238
+ res.status(500).json({
239
+ error: 'Failed to get time range data',
240
+ });
241
+ }
242
+ });
243
+ /**
244
+ * GET /api/charts/export - Export chart data for reports
245
+ * Query params: format (json, csv), range (1h, 6h, 24h, 7d, 30d)
246
+ */
247
+ router.get('/charts/export', (req, res) => {
248
+ try {
249
+ const format = req.query.format || 'json';
250
+ const range = req.query.range || '1h';
251
+ if (!['json', 'csv'].includes(format)) {
252
+ return res.status(400).json({
253
+ error: 'Invalid export format',
254
+ message: 'Format must be either json or csv',
255
+ });
256
+ }
257
+ const data = metricsCollector.getTimeRangeMetrics(range);
258
+ if (format === 'csv') {
259
+ // Convert to CSV format
260
+ const csvHeaders = 'timestamp,activeConnections,requestsPerMinute,successRate,errorRate,avgResponseTime\n';
261
+ const csvRows = data.map(snapshot => `${snapshot.timestamp},${snapshot.connections.activeConnections},${snapshot.performance.requestsPerMinute},${snapshot.performance.successRate},${snapshot.performance.errorRate},${snapshot.performance.avgResponseTime}`).join('\n');
262
+ res.setHeader('Content-Type', 'text/csv');
263
+ res.setHeader('Content-Disposition', `attachment; filename="metrics-${range}-${Date.now()}.csv"`);
264
+ res.send(csvHeaders + csvRows);
265
+ }
266
+ else {
267
+ res.json({
268
+ success: true,
269
+ data,
270
+ range,
271
+ exportedAt: Date.now(),
272
+ format: 'json',
273
+ });
274
+ }
275
+ }
276
+ catch (error) {
277
+ console.error('[API] Chart export error:', error);
278
+ res.status(500).json({
279
+ error: 'Failed to export chart data',
280
+ });
281
+ }
282
+ });
283
+ /**
284
+ * GET /api/performance/detailed - Extended performance metrics (UI convenience endpoint)
285
+ * Supplies the fields the dashboard Monitoring panel expects without the client
286
+ * needing to stitch multiple endpoints. P95/P99 are approximations until full
287
+ * latency histogram support is implemented.
288
+ */
289
+ router.get('/performance/detailed', (_req, res) => {
290
+ try {
291
+ const snap = metricsCollector.getCurrentSnapshot();
292
+ // Approximate p95 by avgResponseTime + (errorRate factor) as a placeholder; real implementation would use distribution.
293
+ const avg = snap.performance.avgResponseTime;
294
+ const p95 = avg ? Math.round(avg * 1.35) : 0;
295
+ res.json({
296
+ success: true,
297
+ data: {
298
+ requestThroughput: snap.performance.requestsPerMinute,
299
+ averageResponseTime: avg,
300
+ p95ResponseTime: p95,
301
+ errorRate: snap.performance.errorRate,
302
+ concurrentConnections: snap.connections.activeConnections,
303
+ successRate: snap.performance.successRate ?? (100 - snap.performance.errorRate),
304
+ activeSyntheticRequests: 0
305
+ },
306
+ timestamp: Date.now()
307
+ });
308
+ }
309
+ catch (err) {
310
+ console.error('[API] Performance detailed error:', err);
311
+ res.status(500).json({ success: false, error: 'Failed to compute performance metrics' });
312
+ }
313
+ });
314
+ /**
315
+ * GET /api/analytics/advanced - Advanced analytics data
316
+ */
317
+ router.get('/analytics/advanced', (req, res) => {
318
+ try {
319
+ const timeRange = req.query.timeRange || '1h';
320
+ const analytics = metricsCollector.getAdvancedAnalytics(timeRange);
321
+ res.json({
322
+ success: true,
323
+ data: analytics,
324
+ timestamp: Date.now()
325
+ });
326
+ }
327
+ catch (error) {
328
+ console.error('[API] Advanced analytics error:', error);
329
+ res.status(500).json({
330
+ error: 'Failed to get advanced analytics',
331
+ });
332
+ }
333
+ });
334
+ return router;
335
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Scripts Routes — Serve client scripts for download
3
+ * Routes: GET /scripts, GET /scripts/:name
4
+ *
5
+ * Provides downloadable REST client scripts for agents and users
6
+ * that lack MCP tool access and need to interact via HTTP.
7
+ */
8
+ import { Router } from 'express';
9
+ export declare function createScriptsRoutes(): Router;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /**
3
+ * Scripts Routes — Serve client scripts for download
4
+ * Routes: GET /scripts, GET /scripts/:name
5
+ *
6
+ * Provides downloadable REST client scripts for agents and users
7
+ * that lack MCP tool access and need to interact via HTTP.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.createScriptsRoutes = createScriptsRoutes;
14
+ const express_1 = require("express");
15
+ const promises_1 = require("fs/promises");
16
+ const path_1 = __importDefault(require("path"));
17
+ /** Allowed script files with metadata */
18
+ const AVAILABLE_SCRIPTS = {
19
+ 'index-server-client.ps1': {
20
+ file: 'index-server-client.ps1',
21
+ contentType: 'application/octet-stream',
22
+ description: 'PowerShell REST client for Index Server (agents without MCP)',
23
+ },
24
+ 'index-server-client.sh': {
25
+ file: 'index-server-client.sh',
26
+ contentType: 'application/octet-stream',
27
+ description: 'Bash REST client for Index Server (agents without MCP)',
28
+ },
29
+ };
30
+ function createScriptsRoutes() {
31
+ const router = (0, express_1.Router)();
32
+ /**
33
+ * GET /api/scripts — List available client scripts with download URLs
34
+ */
35
+ router.get('/scripts', (_req, res) => {
36
+ const scripts = Object.entries(AVAILABLE_SCRIPTS).map(([name, meta]) => ({
37
+ name,
38
+ description: meta.description,
39
+ downloadUrl: `/api/scripts/${name}`,
40
+ }));
41
+ res.setHeader('Cache-Control', 'no-store');
42
+ res.json({ scripts });
43
+ });
44
+ /**
45
+ * GET /api/scripts/:name — Download a specific client script
46
+ */
47
+ router.get('/scripts/:name', async (req, res) => {
48
+ const name = req.params.name;
49
+ // Validate against allowlist (no path traversal)
50
+ const meta = AVAILABLE_SCRIPTS[name];
51
+ if (!meta) {
52
+ res.status(404).json({
53
+ error: `Script not found: ${name}`,
54
+ available: Object.keys(AVAILABLE_SCRIPTS),
55
+ });
56
+ return;
57
+ }
58
+ try {
59
+ const scriptsDir = path_1.default.join(process.cwd(), 'scripts');
60
+ const filePath = path_1.default.join(scriptsDir, meta.file); // nosemgrep: javascript.express.security.audit.express-path-join-resolve-traversal.express-path-join-resolve-traversal -- path validated below via startsWith check
61
+ // Verify resolved path is within scripts directory (defense in depth)
62
+ const resolved = path_1.default.resolve(filePath); // nosemgrep: javascript.express.security.audit.express-path-join-resolve-traversal.express-path-join-resolve-traversal -- resolved path checked against scriptsDir on next line
63
+ if (!resolved.startsWith(path_1.default.resolve(scriptsDir))) {
64
+ res.status(400).json({ error: 'Invalid script path' });
65
+ return;
66
+ }
67
+ const content = await (0, promises_1.readFile)(resolved, 'utf-8');
68
+ res.setHeader('Content-Type', meta.contentType);
69
+ res.setHeader('Content-Disposition', `attachment; filename="${meta.file}"`);
70
+ res.setHeader('X-Content-Type-Options', 'nosniff');
71
+ res.send(content); // nosemgrep: javascript.express.security.audit.xss.direct-response-write.direct-response-write -- content served with Content-Type, Content-Disposition attachment, and X-Content-Type-Options: nosniff headers
72
+ }
73
+ catch (err) {
74
+ const message = err instanceof Error ? err.message : String(err);
75
+ if (message.includes('ENOENT')) {
76
+ res.status(404).json({ error: `Script file not found on disk: ${name}` });
77
+ }
78
+ else {
79
+ res.status(500).json({ error: `Failed to read script: ${message}` });
80
+ }
81
+ }
82
+ });
83
+ return router;
84
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SQLite dashboard routes — DB info, ad-hoc query, maintenance,
3
+ * backup/restore, WAL management, grooming, migration & export.
4
+ *
5
+ * Only active when INDEX_SERVER_STORAGE_BACKEND=sqlite.
6
+ * All routes prefixed with /sqlite/.
7
+ */
8
+ import { Router } from 'express';
9
+ export declare function createSqliteRoutes(): Router;