@jagilber-org/index-server 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/CHANGELOG.md +1218 -0
  2. package/CODE_OF_CONDUCT.md +49 -0
  3. package/CONTRIBUTING.md +75 -0
  4. package/LICENSE +21 -0
  5. package/README.md +523 -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 +45 -0
  10. package/dist/config/dashboardConfig.js +63 -0
  11. package/dist/config/defaultValues.d.ts +61 -0
  12. package/dist/config/defaultValues.js +70 -0
  13. package/dist/config/dirConstants.d.ts +17 -0
  14. package/dist/config/dirConstants.js +28 -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 +145 -0
  18. package/dist/config/runtimeConfig.js +334 -0
  19. package/dist/config/serverConfig.d.ts +90 -0
  20. package/dist/config/serverConfig.js +164 -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 +2150 -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 +1466 -0
  29. package/dist/dashboard/client/js/admin.boot.js +359 -0
  30. package/dist/dashboard/client/js/admin.config.js +196 -0
  31. package/dist/dashboard/client/js/admin.embeddings.js +425 -0
  32. package/dist/dashboard/client/js/admin.graph.js +583 -0
  33. package/dist/dashboard/client/js/admin.instances.js +120 -0
  34. package/dist/dashboard/client/js/admin.instructions.js +552 -0
  35. package/dist/dashboard/client/js/admin.logs.js +113 -0
  36. package/dist/dashboard/client/js/admin.maintenance.js +354 -0
  37. package/dist/dashboard/client/js/admin.messaging.js +635 -0
  38. package/dist/dashboard/client/js/admin.monitor.js +181 -0
  39. package/dist/dashboard/client/js/admin.overview.js +221 -0
  40. package/dist/dashboard/client/js/admin.performance.js +61 -0
  41. package/dist/dashboard/client/js/admin.sessions.js +293 -0
  42. package/dist/dashboard/client/js/admin.sqlite.js +366 -0
  43. package/dist/dashboard/client/js/admin.utils.js +49 -0
  44. package/dist/dashboard/client/js/chart.umd.js +14 -0
  45. package/dist/dashboard/client/js/elk.bundled.js +6696 -0
  46. package/dist/dashboard/client/js/marked.umd.js +74 -0
  47. package/dist/dashboard/client/js/mermaid.min.js +3022 -0
  48. package/dist/dashboard/client/mermaid-layout-elk.esm.min.mjs +1 -0
  49. package/dist/dashboard/export/DataExporter.d.ts +169 -0
  50. package/dist/dashboard/export/DataExporter.js +737 -0
  51. package/dist/dashboard/export/exporters/csvExporter.d.ts +11 -0
  52. package/dist/dashboard/export/exporters/csvExporter.js +46 -0
  53. package/dist/dashboard/export/exporters/exportTypes.d.ts +89 -0
  54. package/dist/dashboard/export/exporters/exportTypes.js +5 -0
  55. package/dist/dashboard/export/exporters/jsonExporter.d.ts +7 -0
  56. package/dist/dashboard/export/exporters/jsonExporter.js +22 -0
  57. package/dist/dashboard/export/exporters/xmlExporter.d.ts +17 -0
  58. package/dist/dashboard/export/exporters/xmlExporter.js +175 -0
  59. package/dist/dashboard/integration/APIIntegration.d.ts +41 -0
  60. package/dist/dashboard/integration/APIIntegration.js +95 -0
  61. package/dist/dashboard/security/SecurityMonitor.d.ts +167 -0
  62. package/dist/dashboard/security/SecurityMonitor.js +559 -0
  63. package/dist/dashboard/server/AdminPanel.d.ts +183 -0
  64. package/dist/dashboard/server/AdminPanel.js +792 -0
  65. package/dist/dashboard/server/AdminPanelConfig.d.ts +42 -0
  66. package/dist/dashboard/server/AdminPanelConfig.js +80 -0
  67. package/dist/dashboard/server/AdminPanelState.d.ts +47 -0
  68. package/dist/dashboard/server/AdminPanelState.js +214 -0
  69. package/dist/dashboard/server/ApiRoutes.d.ts +17 -0
  70. package/dist/dashboard/server/ApiRoutes.js +149 -0
  71. package/dist/dashboard/server/DashboardServer.d.ts +49 -0
  72. package/dist/dashboard/server/DashboardServer.js +159 -0
  73. package/dist/dashboard/server/FileMetricsStorage.d.ts +49 -0
  74. package/dist/dashboard/server/FileMetricsStorage.js +195 -0
  75. package/dist/dashboard/server/HttpTransport.d.ts +23 -0
  76. package/dist/dashboard/server/HttpTransport.js +116 -0
  77. package/dist/dashboard/server/InstanceManager.d.ts +53 -0
  78. package/dist/dashboard/server/InstanceManager.js +284 -0
  79. package/dist/dashboard/server/KnowledgeStore.d.ts +35 -0
  80. package/dist/dashboard/server/KnowledgeStore.js +105 -0
  81. package/dist/dashboard/server/LeaderElection.d.ts +81 -0
  82. package/dist/dashboard/server/LeaderElection.js +268 -0
  83. package/dist/dashboard/server/MetricsCollector.d.ts +200 -0
  84. package/dist/dashboard/server/MetricsCollector.js +803 -0
  85. package/dist/dashboard/server/SessionPersistenceManager.d.ts +88 -0
  86. package/dist/dashboard/server/SessionPersistenceManager.js +457 -0
  87. package/dist/dashboard/server/ThinClient.d.ts +64 -0
  88. package/dist/dashboard/server/ThinClient.js +237 -0
  89. package/dist/dashboard/server/WebSocketManager.d.ts +161 -0
  90. package/dist/dashboard/server/WebSocketManager.js +463 -0
  91. package/dist/dashboard/server/httpLifecycle.d.ts +17 -0
  92. package/dist/dashboard/server/httpLifecycle.js +35 -0
  93. package/dist/dashboard/server/legacyDashboardHtml.d.ts +9 -0
  94. package/dist/dashboard/server/legacyDashboardHtml.js +618 -0
  95. package/dist/dashboard/server/legacyDashboardStyles.d.ts +5 -0
  96. package/dist/dashboard/server/legacyDashboardStyles.js +490 -0
  97. package/dist/dashboard/server/metricsAggregation.d.ts +252 -0
  98. package/dist/dashboard/server/metricsAggregation.js +206 -0
  99. package/dist/dashboard/server/metricsSerializer.d.ts +25 -0
  100. package/dist/dashboard/server/metricsSerializer.js +195 -0
  101. package/dist/dashboard/server/routes/admin.routes.d.ts +16 -0
  102. package/dist/dashboard/server/routes/admin.routes.js +596 -0
  103. package/dist/dashboard/server/routes/alerts.routes.d.ts +7 -0
  104. package/dist/dashboard/server/routes/alerts.routes.js +93 -0
  105. package/dist/dashboard/server/routes/api.feedback.routes.d.ts +73 -0
  106. package/dist/dashboard/server/routes/api.feedback.routes.js +171 -0
  107. package/dist/dashboard/server/routes/api.instructions.routes.d.ts +101 -0
  108. package/dist/dashboard/server/routes/api.instructions.routes.js +213 -0
  109. package/dist/dashboard/server/routes/api.usage.routes.d.ts +57 -0
  110. package/dist/dashboard/server/routes/api.usage.routes.js +374 -0
  111. package/dist/dashboard/server/routes/embeddings.routes.d.ts +6 -0
  112. package/dist/dashboard/server/routes/embeddings.routes.js +246 -0
  113. package/dist/dashboard/server/routes/graph.routes.d.ts +6 -0
  114. package/dist/dashboard/server/routes/graph.routes.js +280 -0
  115. package/dist/dashboard/server/routes/index.d.ts +38 -0
  116. package/dist/dashboard/server/routes/index.js +194 -0
  117. package/dist/dashboard/server/routes/instances.routes.d.ts +6 -0
  118. package/dist/dashboard/server/routes/instances.routes.js +35 -0
  119. package/dist/dashboard/server/routes/instructions.routes.d.ts +8 -0
  120. package/dist/dashboard/server/routes/instructions.routes.js +336 -0
  121. package/dist/dashboard/server/routes/knowledge.routes.d.ts +6 -0
  122. package/dist/dashboard/server/routes/knowledge.routes.js +82 -0
  123. package/dist/dashboard/server/routes/logs.routes.d.ts +6 -0
  124. package/dist/dashboard/server/routes/logs.routes.js +164 -0
  125. package/dist/dashboard/server/routes/messaging.routes.d.ts +16 -0
  126. package/dist/dashboard/server/routes/messaging.routes.js +293 -0
  127. package/dist/dashboard/server/routes/metrics.routes.d.ts +10 -0
  128. package/dist/dashboard/server/routes/metrics.routes.js +346 -0
  129. package/dist/dashboard/server/routes/scripts.routes.d.ts +9 -0
  130. package/dist/dashboard/server/routes/scripts.routes.js +84 -0
  131. package/dist/dashboard/server/routes/sqlite.routes.d.ts +9 -0
  132. package/dist/dashboard/server/routes/sqlite.routes.js +569 -0
  133. package/dist/dashboard/server/routes/status.routes.d.ts +7 -0
  134. package/dist/dashboard/server/routes/status.routes.js +183 -0
  135. package/dist/dashboard/server/routes/synthetic.routes.d.ts +7 -0
  136. package/dist/dashboard/server/routes/synthetic.routes.js +195 -0
  137. package/dist/dashboard/server/routes/tools.routes.d.ts +6 -0
  138. package/dist/dashboard/server/routes/tools.routes.js +46 -0
  139. package/dist/dashboard/server/routes/usage.routes.d.ts +6 -0
  140. package/dist/dashboard/server/routes/usage.routes.js +25 -0
  141. package/dist/dashboard/server/wsInit.d.ts +16 -0
  142. package/dist/dashboard/server/wsInit.js +35 -0
  143. package/dist/externalClientLib.d.ts +1 -0
  144. package/dist/externalClientLib.js +2 -0
  145. package/dist/minimal/index.d.ts +1 -0
  146. package/dist/minimal/index.js +140 -0
  147. package/dist/models/SessionPersistence.d.ts +115 -0
  148. package/dist/models/SessionPersistence.js +66 -0
  149. package/dist/models/instruction.d.ts +45 -0
  150. package/dist/models/instruction.js +2 -0
  151. package/dist/perf/benchmark.d.ts +1 -0
  152. package/dist/perf/benchmark.js +50 -0
  153. package/dist/portableClientWrapper.d.ts +1 -0
  154. package/dist/portableClientWrapper.js +2 -0
  155. package/dist/schemas/index.d.ts +128 -0
  156. package/dist/schemas/index.js +371 -0
  157. package/dist/scripts/runPerformanceBaseline.d.ts +1 -0
  158. package/dist/scripts/runPerformanceBaseline.js +17 -0
  159. package/dist/server/handshakeManager.d.ts +25 -0
  160. package/dist/server/handshakeManager.js +472 -0
  161. package/dist/server/index-server.d.ts +56 -0
  162. package/dist/server/index-server.js +822 -0
  163. package/dist/server/registry.d.ts +44 -0
  164. package/dist/server/registry.js +236 -0
  165. package/dist/server/sdkServer.d.ts +8 -0
  166. package/dist/server/sdkServer.js +299 -0
  167. package/dist/server/shutdownGuard.d.ts +41 -0
  168. package/dist/server/shutdownGuard.js +52 -0
  169. package/dist/server/thin-client.d.ts +22 -0
  170. package/dist/server/thin-client.js +111 -0
  171. package/dist/server/transport.d.ts +41 -0
  172. package/dist/server/transport.js +312 -0
  173. package/dist/server/transportFactory.d.ts +21 -0
  174. package/dist/server/transportFactory.js +429 -0
  175. package/dist/services/atomicFs.d.ts +22 -0
  176. package/dist/services/atomicFs.js +103 -0
  177. package/dist/services/auditLog.d.ts +38 -0
  178. package/dist/services/auditLog.js +142 -0
  179. package/dist/services/autoBackup.d.ts +14 -0
  180. package/dist/services/autoBackup.js +171 -0
  181. package/dist/services/autoSplit.d.ts +32 -0
  182. package/dist/services/autoSplit.js +113 -0
  183. package/dist/services/backupZip.d.ts +25 -0
  184. package/dist/services/backupZip.js +110 -0
  185. package/dist/services/bootstrapGating.d.ts +123 -0
  186. package/dist/services/bootstrapGating.js +221 -0
  187. package/dist/services/canonical.d.ts +23 -0
  188. package/dist/services/canonical.js +65 -0
  189. package/dist/services/categoryRules.d.ts +7 -0
  190. package/dist/services/categoryRules.js +37 -0
  191. package/dist/services/classificationService.d.ts +42 -0
  192. package/dist/services/classificationService.js +168 -0
  193. package/dist/services/embeddingService.d.ts +62 -0
  194. package/dist/services/embeddingService.js +259 -0
  195. package/dist/services/errors.d.ts +22 -0
  196. package/dist/services/errors.js +31 -0
  197. package/dist/services/featureFlags.d.ts +25 -0
  198. package/dist/services/featureFlags.js +89 -0
  199. package/dist/services/features.d.ts +13 -0
  200. package/dist/services/features.js +35 -0
  201. package/dist/services/handlers/instructions.add.d.ts +1 -0
  202. package/dist/services/handlers/instructions.add.js +496 -0
  203. package/dist/services/handlers/instructions.groom.d.ts +1 -0
  204. package/dist/services/handlers/instructions.groom.js +523 -0
  205. package/dist/services/handlers/instructions.import.d.ts +1 -0
  206. package/dist/services/handlers/instructions.import.js +173 -0
  207. package/dist/services/handlers/instructions.patch.d.ts +1 -0
  208. package/dist/services/handlers/instructions.patch.js +167 -0
  209. package/dist/services/handlers/instructions.query.d.ts +163 -0
  210. package/dist/services/handlers/instructions.query.js +522 -0
  211. package/dist/services/handlers/instructions.reload.d.ts +1 -0
  212. package/dist/services/handlers/instructions.reload.js +13 -0
  213. package/dist/services/handlers/instructions.remove.d.ts +1 -0
  214. package/dist/services/handlers/instructions.remove.js +118 -0
  215. package/dist/services/handlers/instructions.shared.d.ts +31 -0
  216. package/dist/services/handlers/instructions.shared.js +124 -0
  217. package/dist/services/handlers.activation.d.ts +1 -0
  218. package/dist/services/handlers.activation.js +203 -0
  219. package/dist/services/handlers.bootstrap.d.ts +1 -0
  220. package/dist/services/handlers.bootstrap.js +38 -0
  221. package/dist/services/handlers.dashboardConfig.d.ts +34 -0
  222. package/dist/services/handlers.dashboardConfig.js +108 -0
  223. package/dist/services/handlers.diagnostics.d.ts +1 -0
  224. package/dist/services/handlers.diagnostics.js +64 -0
  225. package/dist/services/handlers.feedback.d.ts +15 -0
  226. package/dist/services/handlers.feedback.js +378 -0
  227. package/dist/services/handlers.gates.d.ts +1 -0
  228. package/dist/services/handlers.gates.js +46 -0
  229. package/dist/services/handlers.graph.d.ts +53 -0
  230. package/dist/services/handlers.graph.js +231 -0
  231. package/dist/services/handlers.help.d.ts +1 -0
  232. package/dist/services/handlers.help.js +119 -0
  233. package/dist/services/handlers.instructionSchema.d.ts +1 -0
  234. package/dist/services/handlers.instructionSchema.js +227 -0
  235. package/dist/services/handlers.instructions.d.ts +8 -0
  236. package/dist/services/handlers.instructions.js +14 -0
  237. package/dist/services/handlers.instructionsDiagnostics.d.ts +1 -0
  238. package/dist/services/handlers.instructionsDiagnostics.js +14 -0
  239. package/dist/services/handlers.integrity.d.ts +1 -0
  240. package/dist/services/handlers.integrity.js +35 -0
  241. package/dist/services/handlers.manifest.d.ts +1 -0
  242. package/dist/services/handlers.manifest.js +24 -0
  243. package/dist/services/handlers.messaging.d.ts +12 -0
  244. package/dist/services/handlers.messaging.js +203 -0
  245. package/dist/services/handlers.metrics.d.ts +1 -0
  246. package/dist/services/handlers.metrics.js +43 -0
  247. package/dist/services/handlers.promote.d.ts +1 -0
  248. package/dist/services/handlers.promote.js +306 -0
  249. package/dist/services/handlers.prompt.d.ts +1 -0
  250. package/dist/services/handlers.prompt.js +7 -0
  251. package/dist/services/handlers.search.d.ts +69 -0
  252. package/dist/services/handlers.search.js +645 -0
  253. package/dist/services/handlers.testPrimitive.d.ts +1 -0
  254. package/dist/services/handlers.testPrimitive.js +5 -0
  255. package/dist/services/handlers.trace.d.ts +1 -0
  256. package/dist/services/handlers.trace.js +31 -0
  257. package/dist/services/handlers.usage.d.ts +1 -0
  258. package/dist/services/handlers.usage.js +11 -0
  259. package/dist/services/hotScore.d.ts +137 -0
  260. package/dist/services/hotScore.js +244 -0
  261. package/dist/services/indexContext.d.ts +117 -0
  262. package/dist/services/indexContext.js +968 -0
  263. package/dist/services/indexLoader.d.ts +44 -0
  264. package/dist/services/indexLoader.js +921 -0
  265. package/dist/services/indexRepository.d.ts +32 -0
  266. package/dist/services/indexRepository.js +71 -0
  267. package/dist/services/indexingService.d.ts +1 -0
  268. package/dist/services/indexingService.js +2 -0
  269. package/dist/services/instructions.dispatcher.d.ts +1 -0
  270. package/dist/services/instructions.dispatcher.js +231 -0
  271. package/dist/services/logPrefix.d.ts +1 -0
  272. package/dist/services/logPrefix.js +30 -0
  273. package/dist/services/logger.d.ts +52 -0
  274. package/dist/services/logger.js +268 -0
  275. package/dist/services/manifestManager.d.ts +82 -0
  276. package/dist/services/manifestManager.js +200 -0
  277. package/dist/services/messaging/agentMailbox.d.ts +60 -0
  278. package/dist/services/messaging/agentMailbox.js +353 -0
  279. package/dist/services/messaging/messagingPersistence.d.ts +20 -0
  280. package/dist/services/messaging/messagingPersistence.js +111 -0
  281. package/dist/services/messaging/messagingTypes.d.ts +150 -0
  282. package/dist/services/messaging/messagingTypes.js +66 -0
  283. package/dist/services/ownershipService.d.ts +1 -0
  284. package/dist/services/ownershipService.js +38 -0
  285. package/dist/services/performanceBaseline.d.ts +19 -0
  286. package/dist/services/performanceBaseline.js +210 -0
  287. package/dist/services/preflight.d.ts +12 -0
  288. package/dist/services/preflight.js +79 -0
  289. package/dist/services/promptReviewService.d.ts +44 -0
  290. package/dist/services/promptReviewService.js +101 -0
  291. package/dist/services/responseEnvelope.d.ts +6 -0
  292. package/dist/services/responseEnvelope.js +25 -0
  293. package/dist/services/seedBootstrap.d.ts +34 -0
  294. package/dist/services/seedBootstrap.js +427 -0
  295. package/dist/services/storage/factory.d.ts +17 -0
  296. package/dist/services/storage/factory.js +35 -0
  297. package/dist/services/storage/hashUtils.d.ts +11 -0
  298. package/dist/services/storage/hashUtils.js +35 -0
  299. package/dist/services/storage/index.d.ts +12 -0
  300. package/dist/services/storage/index.js +18 -0
  301. package/dist/services/storage/jsonFileStore.d.ts +32 -0
  302. package/dist/services/storage/jsonFileStore.js +241 -0
  303. package/dist/services/storage/migrationEngine.d.ts +35 -0
  304. package/dist/services/storage/migrationEngine.js +93 -0
  305. package/dist/services/storage/sqliteMessageStore.d.ts +53 -0
  306. package/dist/services/storage/sqliteMessageStore.js +146 -0
  307. package/dist/services/storage/sqliteSchema.d.ts +12 -0
  308. package/dist/services/storage/sqliteSchema.js +122 -0
  309. package/dist/services/storage/sqliteStore.d.ts +41 -0
  310. package/dist/services/storage/sqliteStore.js +339 -0
  311. package/dist/services/storage/sqliteUsageStore.d.ts +35 -0
  312. package/dist/services/storage/sqliteUsageStore.js +94 -0
  313. package/dist/services/storage/types.d.ts +171 -0
  314. package/dist/services/storage/types.js +12 -0
  315. package/dist/services/toolHandlers.d.ts +23 -0
  316. package/dist/services/toolHandlers.js +50 -0
  317. package/dist/services/toolRegistry.d.ts +20 -0
  318. package/dist/services/toolRegistry.js +490 -0
  319. package/dist/services/toolRegistry.zod.d.ts +10 -0
  320. package/dist/services/toolRegistry.zod.js +323 -0
  321. package/dist/services/tracing.d.ts +26 -0
  322. package/dist/services/tracing.js +260 -0
  323. package/dist/services/usageBuckets.d.ts +161 -0
  324. package/dist/services/usageBuckets.js +364 -0
  325. package/dist/services/validationService.d.ts +38 -0
  326. package/dist/services/validationService.js +125 -0
  327. package/dist/utils/BufferRing.d.ts +203 -0
  328. package/dist/utils/BufferRing.js +551 -0
  329. package/dist/utils/BufferRingExamples.d.ts +55 -0
  330. package/dist/utils/BufferRingExamples.js +188 -0
  331. package/dist/utils/envUtils.d.ts +42 -0
  332. package/dist/utils/envUtils.js +80 -0
  333. package/dist/utils/memoryMonitor.d.ts +83 -0
  334. package/dist/utils/memoryMonitor.js +275 -0
  335. package/dist/versioning/schemaVersion.d.ts +6 -0
  336. package/dist/versioning/schemaVersion.js +93 -0
  337. package/package.json +134 -0
  338. package/schemas/README.md +13 -0
  339. package/schemas/feedback-entry.schema.json +27 -0
  340. package/schemas/graph-export-v2.schema.json +60 -0
  341. package/schemas/index-server.code-schema.json +38477 -0
  342. package/schemas/instruction.schema.json +262 -0
  343. package/schemas/json-schema/SessionPersistence-persisted-admin-session.schema.json +54 -0
  344. package/schemas/json-schema/SessionPersistence-persisted-session-history-entry.schema.json +51 -0
  345. package/schemas/json-schema/SessionPersistence-persisted-web-socket-connection.schema.json +54 -0
  346. package/schemas/json-schema/SessionPersistence-session-persistence-config.schema.json +110 -0
  347. package/schemas/json-schema/SessionPersistence-session-persistence-data.schema.json +229 -0
  348. package/schemas/json-schema/SessionPersistence-session-persistence-manifest.schema.json +109 -0
  349. package/schemas/json-schema/SessionPersistence-session-persistence-metadata.schema.json +55 -0
  350. package/schemas/json-schema/instruction-audience-scope.schema.json +14 -0
  351. package/schemas/json-schema/instruction-content-type.schema.json +17 -0
  352. package/schemas/json-schema/instruction-instruction-entry.schema.json +206 -0
  353. package/schemas/json-schema/instruction-requirement-level.schema.json +16 -0
  354. package/schemas/manifest.json +78 -0
  355. package/schemas/manifest.schema.json +33 -0
  356. package/schemas/usage-batch.schema.json +16 -0
  357. package/schemas/usage-buckets.schema.json +30 -0
  358. package/schemas/usage-event.schema.json +17 -0
  359. package/scripts/copy-dashboard-assets.mjs +170 -0
  360. package/scripts/setup-hooks.cjs +28 -0
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ // JSON Schemas for tool response contracts. These are used in tests to lock interfaces.
3
+ // Increment version in docs/tools.md when changing any stable schema.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.schemas = exports.instructionEntry = void 0;
6
+ exports.instructionEntry = {
7
+ type: 'object',
8
+ additionalProperties: false,
9
+ required: [
10
+ 'id', 'title', 'body', 'priority', 'audience', 'requirement', 'categories', 'sourceHash', 'schemaVersion', 'createdAt', 'updatedAt',
11
+ 'version', 'status', 'owner', 'priorityTier', 'classification', 'lastReviewedAt', 'nextReviewDue', 'changeLog', 'semanticSummary'
12
+ ],
13
+ properties: {
14
+ id: { type: 'string', minLength: 1 },
15
+ title: { type: 'string' },
16
+ body: { type: 'string' },
17
+ rationale: { type: 'string' },
18
+ priority: { type: 'number' },
19
+ audience: { enum: ['individual', 'group', 'all'] },
20
+ requirement: { enum: ['mandatory', 'critical', 'recommended', 'optional', 'deprecated'] },
21
+ categories: { type: 'array', items: { type: 'string' } },
22
+ sourceHash: { type: 'string' },
23
+ schemaVersion: { type: 'string' },
24
+ deprecatedBy: { type: 'string' },
25
+ createdAt: { type: 'string' },
26
+ updatedAt: { type: 'string' },
27
+ usageCount: { type: 'number' },
28
+ firstSeenTs: { type: 'string' },
29
+ lastUsedAt: { type: 'string' },
30
+ riskScore: { type: 'number' },
31
+ workspaceId: { type: 'string' },
32
+ userId: { type: 'string' },
33
+ teamIds: { type: 'array', items: { type: 'string' } },
34
+ version: { type: 'string' },
35
+ status: { enum: ['draft', 'review', 'approved', 'deprecated'] },
36
+ owner: { type: 'string' },
37
+ priorityTier: { enum: ['P1', 'P2', 'P3', 'P4'] },
38
+ classification: { enum: ['public', 'internal', 'restricted'] },
39
+ lastReviewedAt: { type: 'string' },
40
+ nextReviewDue: { type: 'string' },
41
+ changeLog: { type: 'array', items: { type: 'object', required: ['version', 'changedAt', 'summary'], additionalProperties: false, properties: { version: { type: 'string' }, changedAt: { type: 'string' }, summary: { type: 'string' } } } },
42
+ supersedes: { type: 'string' },
43
+ semanticSummary: { type: 'string' },
44
+ createdByAgent: { type: 'string' },
45
+ sourceWorkspace: { type: 'string' }
46
+ }
47
+ };
48
+ // (listLike schema removed after dispatcher consolidation of read-only instruction methods)
49
+ // Using unknown for schema values to avoid any and preserve flexibility
50
+ exports.schemas = {
51
+ 'health_check': {
52
+ type: 'object', additionalProperties: false,
53
+ required: ['status', 'timestamp', 'version'],
54
+ properties: {
55
+ status: { const: 'ok' },
56
+ timestamp: { type: 'string' },
57
+ version: { type: 'string' }
58
+ }
59
+ },
60
+ 'index_dispatch': {
61
+ // Dispatcher returns varying shapes; keep loose but assert required action echo when capabilities.
62
+ anyOf: [
63
+ { type: 'object', required: ['supportedActions', 'mutationEnabled', 'version'], additionalProperties: true, properties: {
64
+ version: { type: 'string' },
65
+ supportedActions: { type: 'array', items: { type: 'string' } },
66
+ mutationEnabled: { type: 'boolean' }
67
+ } },
68
+ { type: 'object', required: ['results'], additionalProperties: true, properties: { results: { type: 'array' } } },
69
+ { type: 'object', required: ['hash'], additionalProperties: true, properties: { hash: { type: 'string' } } },
70
+ { type: 'object', required: ['error'], additionalProperties: true, properties: { error: { type: 'string' } } }
71
+ ]
72
+ },
73
+ 'index_import': {
74
+ anyOf: [
75
+ { type: 'object', required: ['error'], properties: { error: { type: 'string' } }, additionalProperties: true },
76
+ { type: 'object', required: ['hash', 'imported', 'skipped', 'overwritten', 'errors', 'total'], additionalProperties: false, properties: {
77
+ hash: { type: 'string' }, imported: { type: 'number' }, skipped: { type: 'number' }, overwritten: { type: 'number' }, total: { type: 'number' }, errors: { type: 'array', items: { type: 'object', required: ['id', 'error'], properties: { id: { type: 'string' }, error: { type: 'string' } }, additionalProperties: false } }
78
+ } }
79
+ ]
80
+ },
81
+ 'index_repair': { type: 'object', required: ['repaired', 'updated'], additionalProperties: false, properties: { repaired: { type: 'number' }, updated: { type: 'array', items: { type: 'string' } } } },
82
+ 'prompt_review': {
83
+ anyOf: [
84
+ { type: 'object', required: ['truncated', 'message', 'max'], additionalProperties: false, properties: {
85
+ truncated: { const: true },
86
+ message: { type: 'string' },
87
+ max: { type: 'number' }
88
+ } },
89
+ { type: 'object', required: ['issues', 'summary', 'length'], additionalProperties: false, properties: {
90
+ issues: { type: 'array', items: { type: 'object' } },
91
+ summary: { type: 'object' },
92
+ length: { type: 'number' }
93
+ } }
94
+ ]
95
+ },
96
+ 'integrity_verify': {
97
+ type: 'object', additionalProperties: false,
98
+ required: ['hash', 'count', 'issues', 'issueCount'],
99
+ properties: {
100
+ hash: { type: 'string' },
101
+ count: { type: 'number' },
102
+ issues: { type: 'array', items: { type: 'object', required: ['id', 'expected', 'actual'], properties: { id: { type: 'string' }, expected: { type: 'string' }, actual: { type: 'string' } }, additionalProperties: false } },
103
+ issueCount: { type: 'number' }
104
+ }
105
+ },
106
+ 'usage_track': {
107
+ anyOf: [
108
+ { type: 'object', required: ['error'], properties: { error: { type: 'string' } }, additionalProperties: true },
109
+ { type: 'object', required: ['notFound'], properties: { notFound: { const: true } }, additionalProperties: true },
110
+ { type: 'object', required: ['featureDisabled'], properties: { featureDisabled: { const: true } }, additionalProperties: true },
111
+ { type: 'object', required: ['id', 'usageCount', 'lastUsedAt'], additionalProperties: false, properties: {
112
+ id: { type: 'string' }, usageCount: { type: 'number' }, firstSeenTs: { type: 'string' }, lastUsedAt: { type: 'string' }
113
+ } }
114
+ ]
115
+ },
116
+ 'usage_hotset': {
117
+ type: 'object', additionalProperties: false,
118
+ required: ['hash', 'count', 'limit', 'items'],
119
+ properties: {
120
+ hash: { type: 'string' },
121
+ count: { type: 'number' },
122
+ 'feature_status': {
123
+ type: 'object',
124
+ properties: {},
125
+ additionalProperties: false
126
+ },
127
+ limit: { type: 'number' },
128
+ items: { type: 'array', items: { type: 'object', required: ['id', 'usageCount'], additionalProperties: false, properties: {
129
+ id: { type: 'string' }, usageCount: { type: 'number' }, lastUsedAt: { type: 'string' }
130
+ } } }
131
+ }
132
+ },
133
+ 'metrics_snapshot': {
134
+ type: 'object', additionalProperties: false,
135
+ required: ['generatedAt', 'methods'],
136
+ properties: {
137
+ generatedAt: { type: 'string' },
138
+ methods: { type: 'array', items: { type: 'object', required: ['method', 'count', 'avgMs', 'maxMs'], additionalProperties: false, properties: {
139
+ method: { type: 'string' }, count: { type: 'number' }, avgMs: { type: 'number' }, maxMs: { type: 'number' }
140
+ } } },
141
+ features: { type: 'object', additionalProperties: true }
142
+ }
143
+ },
144
+ 'index_governanceHash': {
145
+ type: 'object', additionalProperties: false,
146
+ required: ['count', 'governanceHash', 'items'],
147
+ properties: {
148
+ count: { type: 'number' },
149
+ governanceHash: { type: 'string' },
150
+ items: { type: 'array', items: { type: 'object', required: ['id', 'title', 'version', 'owner', 'priorityTier', 'nextReviewDue', 'semanticSummarySha256', 'changeLogLength'], additionalProperties: false, properties: {
151
+ id: { type: 'string' }, title: { type: 'string' }, version: { type: 'string' }, owner: { type: 'string' }, priorityTier: { type: 'string' }, nextReviewDue: { type: 'string' }, semanticSummarySha256: { type: 'string' }, changeLogLength: { type: 'number' }
152
+ } } }
153
+ }
154
+ },
155
+ 'index_health': {
156
+ anyOf: [
157
+ { type: 'object', required: ['snapshot', 'hash', 'count'], additionalProperties: true, properties: { snapshot: { const: 'missing' }, hash: { type: 'string' }, count: { type: 'number' } } },
158
+ { type: 'object', required: ['snapshot', 'hash', 'count', 'missing', 'changed', 'extra', 'drift'], additionalProperties: true, properties: {
159
+ snapshot: { const: 'present' }, hash: { type: 'string' }, count: { type: 'number' },
160
+ missing: { type: 'array', items: { type: 'string' } },
161
+ changed: { type: 'array', items: { type: 'string' } },
162
+ extra: { type: 'array', items: { type: 'string' } },
163
+ drift: { type: 'number' }
164
+ } },
165
+ { type: 'object', required: ['snapshot', 'hash', 'error'], additionalProperties: true, properties: { snapshot: { const: 'error' }, hash: { type: 'string' }, error: { type: 'string' } } }
166
+ ]
167
+ },
168
+ 'gates_evaluate': {
169
+ anyOf: [
170
+ { type: 'object', required: ['notConfigured'], properties: { notConfigured: { const: true } }, additionalProperties: true },
171
+ { type: 'object', required: ['error'], properties: { error: { type: 'string' } }, additionalProperties: true },
172
+ { type: 'object', required: ['generatedAt', 'results', 'summary'], additionalProperties: false, properties: {
173
+ generatedAt: { type: 'string' },
174
+ results: { type: 'array', items: { type: 'object', required: ['id', 'passed', 'count', 'op', 'value', 'severity'], additionalProperties: true, properties: {
175
+ id: { type: 'string' }, passed: { type: 'boolean' }, count: { type: 'number' }, op: { type: 'string' }, value: { type: 'number' }, severity: { type: 'string' }, description: { type: 'string' }
176
+ } } },
177
+ summary: { type: 'object', required: ['errors', 'warnings', 'total'], properties: { errors: { type: 'number' }, warnings: { type: 'number' }, total: { type: 'number' } }, additionalProperties: false }
178
+ } }
179
+ ]
180
+ },
181
+ // Graph export (legacy v1 + enriched v2). Optional contract registration enabling future schema locking.
182
+ 'graph_export': {
183
+ anyOf: [
184
+ { type: 'object', required: ['meta', 'nodes', 'edges'], additionalProperties: true, properties: {
185
+ meta: { type: 'object', required: ['graphSchemaVersion', 'nodeCount', 'edgeCount'], additionalProperties: true, properties: { graphSchemaVersion: { const: 1 }, nodeCount: { type: 'number' }, edgeCount: { type: 'number' } } },
186
+ nodes: { type: 'array', items: { type: 'object', required: ['id'], additionalProperties: true, properties: { id: { type: 'string' } } } },
187
+ edges: { type: 'array', items: { type: 'object', required: ['from', 'to', 'type'], additionalProperties: true, properties: { from: { type: 'string' }, to: { type: 'string' }, type: { enum: ['primary', 'category'] } } } }
188
+ } },
189
+ { type: 'object', required: ['meta', 'nodes', 'edges'], additionalProperties: true, properties: {
190
+ meta: { type: 'object', required: ['graphSchemaVersion', 'nodeCount', 'edgeCount'], additionalProperties: true, properties: { graphSchemaVersion: { const: 2 }, nodeCount: { type: 'number' }, edgeCount: { type: 'number' } } },
191
+ nodes: { type: 'array', items: { type: 'object', required: ['id'], additionalProperties: true, properties: { id: { type: 'string' }, nodeType: { enum: ['instruction', 'category'] }, categories: { type: 'array', items: { type: 'string' } }, primaryCategory: { type: 'string' }, usageCount: { type: 'number' } } } },
192
+ edges: { type: 'array', items: { type: 'object', required: ['from', 'to', 'type'], additionalProperties: true, properties: { from: { type: 'string' }, to: { type: 'string' }, type: { enum: ['primary', 'category', 'belongs'] } } } },
193
+ mermaid: { type: 'string' }, dot: { type: 'string' }
194
+ } }
195
+ ]
196
+ },
197
+ 'meta_tools': {
198
+ type: 'object', additionalProperties: true,
199
+ required: ['stable', 'dynamic', 'tools'],
200
+ properties: {
201
+ // Legacy flat list (includes disabled flag)
202
+ tools: { type: 'array', items: { type: 'object', required: ['method'], additionalProperties: true, properties: {
203
+ method: { type: 'string' }, stable: { type: 'boolean' }, mutation: { type: 'boolean' }, disabled: { type: 'boolean' }
204
+ } } },
205
+ stable: {
206
+ type: 'object', additionalProperties: false,
207
+ required: ['tools'],
208
+ properties: {
209
+ tools: { type: 'array', items: { type: 'object', required: ['method', 'stable', 'mutation'], additionalProperties: true, properties: {
210
+ method: { type: 'string' },
211
+ stable: { type: 'boolean' },
212
+ mutation: { type: 'boolean' }
213
+ } } }
214
+ }
215
+ },
216
+ dynamic: {
217
+ type: 'object', additionalProperties: true,
218
+ required: ['generatedAt', 'mutationEnabled', 'disabled'],
219
+ properties: {
220
+ generatedAt: { type: 'string' },
221
+ mutationEnabled: { type: 'boolean' },
222
+ disabled: { type: 'array', items: { type: 'object', required: ['method'], additionalProperties: false, properties: { method: { type: 'string' } } } }
223
+ }
224
+ },
225
+ // New MCP style registry (optional for now)
226
+ mcp: {
227
+ type: 'object', additionalProperties: true,
228
+ required: ['registryVersion', 'tools'],
229
+ properties: {
230
+ registryVersion: { type: 'string' },
231
+ tools: { type: 'array', items: { type: 'object', required: ['name', 'description', 'stable', 'mutation', 'inputSchema'], additionalProperties: false, properties: {
232
+ name: { type: 'string' },
233
+ description: { type: 'string' },
234
+ stable: { type: 'boolean' },
235
+ mutation: { type: 'boolean' },
236
+ inputSchema: { type: 'object' },
237
+ outputSchema: { type: 'object' }
238
+ } } }
239
+ }
240
+ }
241
+ }
242
+ },
243
+ 'help_overview': {
244
+ type: 'object',
245
+ additionalProperties: true,
246
+ required: ['generatedAt', 'version', 'sections'],
247
+ properties: {
248
+ generatedAt: { type: 'string' },
249
+ version: { type: 'string' },
250
+ summary: { type: 'string' },
251
+ sections: { type: 'array', items: { type: 'object', required: ['id', 'title', 'content'], additionalProperties: true, properties: {
252
+ id: { type: 'string' },
253
+ title: { type: 'string' },
254
+ content: { type: 'string' },
255
+ bullets: { type: 'array', items: { type: 'string' } },
256
+ nextActions: { type: 'array', items: { type: 'string' } }
257
+ } } },
258
+ lifecycleModel: { type: 'object', additionalProperties: true, properties: {
259
+ tiers: { type: 'array', items: { type: 'object', required: ['tier', 'purpose'], additionalProperties: true, properties: { tier: { type: 'string' }, purpose: { type: 'string' } } } },
260
+ promotionChecklist: { type: 'array', items: { type: 'string' } }
261
+ } },
262
+ toolDiscovery: { type: 'object', additionalProperties: true, properties: {
263
+ primary: { type: 'array', items: { type: 'string' } },
264
+ diagnostics: { type: 'array', items: { type: 'string' } }
265
+ } }
266
+ }
267
+ },
268
+ 'index_schema': {
269
+ type: 'object',
270
+ additionalProperties: false,
271
+ required: ['generatedAt', 'version', 'summary', 'schema', 'minimalExample', 'requiredFields', 'optionalFieldsCommon', 'promotionWorkflow', 'validationRules', 'nextSteps'],
272
+ properties: {
273
+ generatedAt: { type: 'string' },
274
+ version: { type: 'string' },
275
+ summary: { type: 'string' },
276
+ schema: { type: 'object', additionalProperties: true },
277
+ minimalExample: { type: 'object', additionalProperties: true },
278
+ requiredFields: { type: 'array', items: { type: 'string' } },
279
+ optionalFieldsCommon: { type: 'array', items: { type: 'string' } },
280
+ promotionWorkflow: { type: 'array', items: { type: 'object', required: ['stage', 'description', 'checklistItems'], additionalProperties: false, properties: {
281
+ stage: { type: 'string' },
282
+ description: { type: 'string' },
283
+ checklistItems: { type: 'array', items: { type: 'string' } }
284
+ } } },
285
+ validationRules: { type: 'array', items: { type: 'object', required: ['field', 'rule', 'constraint'], additionalProperties: false, properties: {
286
+ field: { type: 'string' },
287
+ rule: { type: 'string' },
288
+ constraint: { type: 'string' }
289
+ } } },
290
+ nextSteps: { type: 'array', items: { type: 'string' } }
291
+ }
292
+ },
293
+ 'usage_flush': { type: 'object', required: ['flushed'], additionalProperties: false, properties: { flushed: { const: true } } },
294
+ 'index_reload': { type: 'object', required: ['reloaded', 'hash', 'count'], additionalProperties: false, properties: { reloaded: { const: true }, hash: { type: 'string' }, count: { type: 'number' } } },
295
+ 'index_remove': { type: 'object', required: ['removed', 'removedIds', 'missing', 'errorCount', 'errors'], additionalProperties: false, properties: {
296
+ removed: { type: 'number' },
297
+ removedIds: { type: 'array', items: { type: 'string' } },
298
+ missing: { type: 'array', items: { type: 'string' } },
299
+ errorCount: { type: 'number' },
300
+ errors: { type: 'array', items: { type: 'object', required: ['id', 'error'], additionalProperties: false, properties: { id: { type: 'string' }, error: { type: 'string' } } } }
301
+ } },
302
+ 'index_enrich': { type: 'object', required: ['rewritten', 'updated', 'skipped'], additionalProperties: false, properties: {
303
+ rewritten: { type: 'number' },
304
+ updated: { type: 'array', items: { type: 'string' } },
305
+ skipped: { type: 'array', items: { type: 'string' } }
306
+ } },
307
+ 'index_add': {
308
+ anyOf: [
309
+ { type: 'object', required: ['error'], properties: { error: { type: 'string' }, id: { type: 'string' } }, additionalProperties: true },
310
+ { type: 'object', required: ['id', 'hash', 'skipped', 'created', 'overwritten'], additionalProperties: false, properties: {
311
+ id: { type: 'string' }, hash: { type: 'string' }, skipped: { type: 'boolean' }, created: { type: 'boolean' }, overwritten: { type: 'boolean' }
312
+ } }
313
+ ]
314
+ },
315
+ 'index_groom': {
316
+ type: 'object', additionalProperties: false,
317
+ required: ['previousHash', 'hash', 'scanned', 'repairedHashes', 'normalizedCategories', 'deprecatedRemoved', 'duplicatesMerged', 'signalApplied', 'filesRewritten', 'purgedScopes', 'dryRun', 'notes'],
318
+ properties: {
319
+ previousHash: { type: 'string' },
320
+ hash: { type: 'string' },
321
+ scanned: { type: 'number' },
322
+ repairedHashes: { type: 'number' },
323
+ normalizedCategories: { type: 'number' },
324
+ deprecatedRemoved: { type: 'number' },
325
+ duplicatesMerged: { type: 'number' },
326
+ signalApplied: { type: 'number' },
327
+ filesRewritten: { type: 'number' },
328
+ purgedScopes: { type: 'number' },
329
+ migrated: { type: 'number' },
330
+ remappedCategories: { type: 'number' },
331
+ dryRun: { type: 'boolean' },
332
+ notes: { type: 'array', items: { type: 'string' } }
333
+ }
334
+ },
335
+ 'index_search': {
336
+ type: 'object',
337
+ additionalProperties: false,
338
+ required: ['results', 'totalMatches', 'query', 'executionTimeMs'],
339
+ properties: {
340
+ results: {
341
+ type: 'array',
342
+ items: {
343
+ type: 'object',
344
+ additionalProperties: false,
345
+ required: ['instructionId', 'relevanceScore', 'matchedFields'],
346
+ properties: {
347
+ instructionId: { type: 'string' },
348
+ relevanceScore: { type: 'number' },
349
+ matchedFields: {
350
+ type: 'array',
351
+ items: { enum: ['title', 'body', 'categories'] }
352
+ }
353
+ }
354
+ }
355
+ },
356
+ totalMatches: { type: 'number' },
357
+ query: {
358
+ type: 'object',
359
+ additionalProperties: false,
360
+ required: ['keywords', 'limit', 'includeCategories', 'caseSensitive'],
361
+ properties: {
362
+ keywords: { type: 'array', items: { type: 'string' } },
363
+ limit: { type: 'number' },
364
+ includeCategories: { type: 'boolean' },
365
+ caseSensitive: { type: 'boolean' }
366
+ }
367
+ },
368
+ executionTimeMs: { type: 'number' }
369
+ }
370
+ }
371
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // CLI runner for performance baseline measurement
4
+ const performanceBaseline_1 = require("../services/performanceBaseline");
5
+ async function main() {
6
+ try {
7
+ const results = await (0, performanceBaseline_1.runPerformanceBaseline)();
8
+ process.exit(results.summary.meetsTarget ? 0 : 1);
9
+ }
10
+ catch (error) {
11
+ console.error('❌ Performance baseline failed:', error instanceof Error ? error.message : String(error));
12
+ process.exit(1);
13
+ }
14
+ }
15
+ if (require.main === module) {
16
+ main();
17
+ }
@@ -0,0 +1,25 @@
1
+ export declare function isHandshakeTraceEnabled(): boolean;
2
+ export declare function handshakeLog(stage: string, data?: Record<string, unknown>): void;
3
+ export declare function isHandshakeFallbacksEnabled(): boolean;
4
+ export declare const SUPPORTED_PROTOCOL_VERSIONS: string[];
5
+ export interface HandshakeEvent {
6
+ seq: number;
7
+ ts: string;
8
+ stage: string;
9
+ extra?: Record<string, unknown>;
10
+ }
11
+ export declare function record(stage: string, extra?: Record<string, unknown>): void;
12
+ export declare function isInitFrameDiagEnabled(): boolean;
13
+ export declare function initFrameLog(stage: string, extra?: Record<string, unknown>): void;
14
+ export declare function negotiateProtocolVersion(requested?: string): string;
15
+ export declare function emitReadyGlobal(server: any, reason: string): void;
16
+ /**
17
+ * Pre-connect stdin sniffer: if we observe an initialize request but downstream logic fails
18
+ * to emit server/ready, schedule a guarded fallback emission.
19
+ */
20
+ export declare function setupStdinSniffer(server: any): void;
21
+ /**
22
+ * Safety fallback timers for missed ready emissions, unconditional DIAG fallback,
23
+ * and _oninitialize patch for protocol negotiation.
24
+ */
25
+ export declare function setupSafetyFallbacks(server: any): void;