@weavelogic/knowledge-graph-agent 0.2.0 → 0.3.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 (585) hide show
  1. package/README.md +686 -304
  2. package/dist/_virtual/_commonjsHelpers.js +7 -0
  3. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  4. package/dist/_virtual/additionalItems.js +5 -0
  5. package/dist/_virtual/additionalItems.js.map +1 -0
  6. package/dist/_virtual/additionalProperties.js +5 -0
  7. package/dist/_virtual/additionalProperties.js.map +1 -0
  8. package/dist/_virtual/ajv.js +6 -0
  9. package/dist/_virtual/ajv.js.map +1 -0
  10. package/dist/_virtual/ajv2.js +5 -0
  11. package/dist/_virtual/ajv2.js.map +1 -0
  12. package/dist/_virtual/allOf.js +5 -0
  13. package/dist/_virtual/allOf.js.map +1 -0
  14. package/dist/_virtual/anyOf.js +5 -0
  15. package/dist/_virtual/anyOf.js.map +1 -0
  16. package/dist/_virtual/applicability.js +5 -0
  17. package/dist/_virtual/applicability.js.map +1 -0
  18. package/dist/_virtual/boolSchema.js +5 -0
  19. package/dist/_virtual/boolSchema.js.map +1 -0
  20. package/dist/_virtual/code.js +5 -0
  21. package/dist/_virtual/code.js.map +1 -0
  22. package/dist/_virtual/code2.js +5 -0
  23. package/dist/_virtual/code2.js.map +1 -0
  24. package/dist/_virtual/const.js +5 -0
  25. package/dist/_virtual/const.js.map +1 -0
  26. package/dist/_virtual/contains.js +5 -0
  27. package/dist/_virtual/contains.js.map +1 -0
  28. package/dist/_virtual/core.js +5 -0
  29. package/dist/_virtual/core.js.map +1 -0
  30. package/dist/_virtual/dataType.js +5 -0
  31. package/dist/_virtual/dataType.js.map +1 -0
  32. package/dist/_virtual/defaults.js +5 -0
  33. package/dist/_virtual/defaults.js.map +1 -0
  34. package/dist/_virtual/dependencies.js +5 -0
  35. package/dist/_virtual/dependencies.js.map +1 -0
  36. package/dist/_virtual/draft7.js +5 -0
  37. package/dist/_virtual/draft7.js.map +1 -0
  38. package/dist/_virtual/enum.js +5 -0
  39. package/dist/_virtual/enum.js.map +1 -0
  40. package/dist/_virtual/equal.js +5 -0
  41. package/dist/_virtual/equal.js.map +1 -0
  42. package/dist/_virtual/errors.js +5 -0
  43. package/dist/_virtual/errors.js.map +1 -0
  44. package/dist/_virtual/format.js +5 -0
  45. package/dist/_virtual/format.js.map +1 -0
  46. package/dist/_virtual/formats.js +5 -0
  47. package/dist/_virtual/formats.js.map +1 -0
  48. package/dist/_virtual/id.js +5 -0
  49. package/dist/_virtual/id.js.map +1 -0
  50. package/dist/_virtual/if.js +5 -0
  51. package/dist/_virtual/if.js.map +1 -0
  52. package/dist/_virtual/index.js +8 -0
  53. package/dist/_virtual/index.js.map +1 -0
  54. package/dist/_virtual/index10.js +5 -0
  55. package/dist/_virtual/index10.js.map +1 -0
  56. package/dist/_virtual/index11.js +5 -0
  57. package/dist/_virtual/index11.js.map +1 -0
  58. package/dist/_virtual/index12.js +5 -0
  59. package/dist/_virtual/index12.js.map +1 -0
  60. package/dist/_virtual/index2.js +5 -0
  61. package/dist/_virtual/index2.js.map +1 -0
  62. package/dist/_virtual/index3.js +5 -0
  63. package/dist/_virtual/index3.js.map +1 -0
  64. package/dist/_virtual/index4.js +5 -0
  65. package/dist/_virtual/index4.js.map +1 -0
  66. package/dist/_virtual/index5.js +5 -0
  67. package/dist/_virtual/index5.js.map +1 -0
  68. package/dist/_virtual/index6.js +5 -0
  69. package/dist/_virtual/index6.js.map +1 -0
  70. package/dist/_virtual/index7.js +5 -0
  71. package/dist/_virtual/index7.js.map +1 -0
  72. package/dist/_virtual/index8.js +5 -0
  73. package/dist/_virtual/index8.js.map +1 -0
  74. package/dist/_virtual/index9.js +5 -0
  75. package/dist/_virtual/index9.js.map +1 -0
  76. package/dist/_virtual/items.js +5 -0
  77. package/dist/_virtual/items.js.map +1 -0
  78. package/dist/_virtual/items2020.js +5 -0
  79. package/dist/_virtual/items2020.js.map +1 -0
  80. package/dist/_virtual/keyword.js +5 -0
  81. package/dist/_virtual/keyword.js.map +1 -0
  82. package/dist/_virtual/limit.js +5 -0
  83. package/dist/_virtual/limit.js.map +1 -0
  84. package/dist/_virtual/limitItems.js +5 -0
  85. package/dist/_virtual/limitItems.js.map +1 -0
  86. package/dist/_virtual/limitLength.js +5 -0
  87. package/dist/_virtual/limitLength.js.map +1 -0
  88. package/dist/_virtual/limitNumber.js +5 -0
  89. package/dist/_virtual/limitNumber.js.map +1 -0
  90. package/dist/_virtual/limitProperties.js +5 -0
  91. package/dist/_virtual/limitProperties.js.map +1 -0
  92. package/dist/_virtual/metadata.js +5 -0
  93. package/dist/_virtual/metadata.js.map +1 -0
  94. package/dist/_virtual/multipleOf.js +5 -0
  95. package/dist/_virtual/multipleOf.js.map +1 -0
  96. package/dist/_virtual/names.js +5 -0
  97. package/dist/_virtual/names.js.map +1 -0
  98. package/dist/_virtual/not.js +5 -0
  99. package/dist/_virtual/not.js.map +1 -0
  100. package/dist/_virtual/oneOf.js +5 -0
  101. package/dist/_virtual/oneOf.js.map +1 -0
  102. package/dist/_virtual/pattern.js +5 -0
  103. package/dist/_virtual/pattern.js.map +1 -0
  104. package/dist/_virtual/patternProperties.js +5 -0
  105. package/dist/_virtual/patternProperties.js.map +1 -0
  106. package/dist/_virtual/prefixItems.js +5 -0
  107. package/dist/_virtual/prefixItems.js.map +1 -0
  108. package/dist/_virtual/properties.js +5 -0
  109. package/dist/_virtual/properties.js.map +1 -0
  110. package/dist/_virtual/propertyNames.js +5 -0
  111. package/dist/_virtual/propertyNames.js.map +1 -0
  112. package/dist/_virtual/ref.js +5 -0
  113. package/dist/_virtual/ref.js.map +1 -0
  114. package/dist/_virtual/ref_error.js +5 -0
  115. package/dist/_virtual/ref_error.js.map +1 -0
  116. package/dist/_virtual/required.js +5 -0
  117. package/dist/_virtual/required.js.map +1 -0
  118. package/dist/_virtual/resolve.js +5 -0
  119. package/dist/_virtual/resolve.js.map +1 -0
  120. package/dist/_virtual/rules.js +5 -0
  121. package/dist/_virtual/rules.js.map +1 -0
  122. package/dist/_virtual/scope.js +5 -0
  123. package/dist/_virtual/scope.js.map +1 -0
  124. package/dist/_virtual/subschema.js +5 -0
  125. package/dist/_virtual/subschema.js.map +1 -0
  126. package/dist/_virtual/thenElse.js +5 -0
  127. package/dist/_virtual/thenElse.js.map +1 -0
  128. package/dist/_virtual/types.js +5 -0
  129. package/dist/_virtual/types.js.map +1 -0
  130. package/dist/_virtual/ucs2length.js +5 -0
  131. package/dist/_virtual/ucs2length.js.map +1 -0
  132. package/dist/_virtual/uniqueItems.js +5 -0
  133. package/dist/_virtual/uniqueItems.js.map +1 -0
  134. package/dist/_virtual/uri.js +5 -0
  135. package/dist/_virtual/uri.js.map +1 -0
  136. package/dist/_virtual/util.js +5 -0
  137. package/dist/_virtual/util.js.map +1 -0
  138. package/dist/_virtual/validation_error.js +5 -0
  139. package/dist/_virtual/validation_error.js.map +1 -0
  140. package/dist/agents/analyst-agent.d.ts +230 -0
  141. package/dist/agents/analyst-agent.d.ts.map +1 -0
  142. package/dist/agents/analyst-agent.js +793 -0
  143. package/dist/agents/analyst-agent.js.map +1 -0
  144. package/dist/agents/architect-agent.d.ts +248 -0
  145. package/dist/agents/architect-agent.d.ts.map +1 -0
  146. package/dist/agents/architect-agent.js +685 -0
  147. package/dist/agents/architect-agent.js.map +1 -0
  148. package/dist/agents/base-agent.d.ts +169 -0
  149. package/dist/agents/base-agent.d.ts.map +1 -0
  150. package/dist/agents/base-agent.js +441 -0
  151. package/dist/agents/base-agent.js.map +1 -0
  152. package/dist/agents/coder-agent.d.ts +191 -0
  153. package/dist/agents/coder-agent.d.ts.map +1 -0
  154. package/dist/agents/coder-agent.js +1008 -0
  155. package/dist/agents/coder-agent.js.map +1 -0
  156. package/dist/agents/index.d.ts +18 -0
  157. package/dist/agents/index.d.ts.map +1 -0
  158. package/dist/agents/index.js +40 -0
  159. package/dist/agents/index.js.map +1 -0
  160. package/dist/agents/registry.d.ts +213 -0
  161. package/dist/agents/registry.d.ts.map +1 -0
  162. package/dist/agents/registry.js +419 -0
  163. package/dist/agents/registry.js.map +1 -0
  164. package/dist/agents/researcher-agent.d.ts +226 -0
  165. package/dist/agents/researcher-agent.d.ts.map +1 -0
  166. package/dist/agents/researcher-agent.js +572 -0
  167. package/dist/agents/researcher-agent.js.map +1 -0
  168. package/dist/agents/rules-engine.d.ts +320 -0
  169. package/dist/agents/rules-engine.d.ts.map +1 -0
  170. package/dist/agents/rules-engine.js +552 -0
  171. package/dist/agents/rules-engine.js.map +1 -0
  172. package/dist/agents/tester-agent.d.ts +219 -0
  173. package/dist/agents/tester-agent.d.ts.map +1 -0
  174. package/dist/agents/tester-agent.js +683 -0
  175. package/dist/agents/tester-agent.js.map +1 -0
  176. package/dist/agents/types.d.ts +425 -0
  177. package/dist/agents/types.d.ts.map +1 -0
  178. package/dist/agents/types.js +57 -0
  179. package/dist/agents/types.js.map +1 -0
  180. package/dist/caching/index.d.ts +55 -0
  181. package/dist/caching/index.d.ts.map +1 -0
  182. package/dist/caching/index.js +206 -0
  183. package/dist/caching/index.js.map +1 -0
  184. package/dist/caching/lru-cache.d.ts +254 -0
  185. package/dist/caching/lru-cache.d.ts.map +1 -0
  186. package/dist/caching/types.d.ts +95 -0
  187. package/dist/caching/types.d.ts.map +1 -0
  188. package/dist/chunking/chunker.d.ts +94 -0
  189. package/dist/chunking/chunker.d.ts.map +1 -0
  190. package/dist/chunking/index.d.ts +125 -0
  191. package/dist/chunking/index.d.ts.map +1 -0
  192. package/dist/chunking/index.js +283 -0
  193. package/dist/chunking/index.js.map +1 -0
  194. package/dist/chunking/types.d.ts +92 -0
  195. package/dist/chunking/types.d.ts.map +1 -0
  196. package/dist/cli/commands/commit.d.ts +11 -0
  197. package/dist/cli/commands/commit.d.ts.map +1 -0
  198. package/dist/cli/commands/commit.js +379 -0
  199. package/dist/cli/commands/commit.js.map +1 -0
  200. package/dist/cli/commands/config.d.ts +8 -0
  201. package/dist/cli/commands/config.d.ts.map +1 -0
  202. package/dist/cli/commands/config.js +107 -0
  203. package/dist/cli/commands/config.js.map +1 -0
  204. package/dist/cli/commands/cultivate.d.ts +16 -0
  205. package/dist/cli/commands/cultivate.d.ts.map +1 -0
  206. package/dist/cli/commands/cultivate.js +254 -0
  207. package/dist/cli/commands/cultivate.js.map +1 -0
  208. package/dist/cli/commands/diagnostics.d.ts +8 -0
  209. package/dist/cli/commands/diagnostics.d.ts.map +1 -0
  210. package/dist/cli/commands/diagnostics.js +140 -0
  211. package/dist/cli/commands/diagnostics.js.map +1 -0
  212. package/dist/cli/commands/generate.d.ts +13 -0
  213. package/dist/cli/commands/generate.d.ts.map +1 -0
  214. package/dist/cli/commands/init-primitives.d.ts +19 -0
  215. package/dist/cli/commands/init-primitives.d.ts.map +1 -0
  216. package/dist/cli/commands/init-primitives.js +208 -0
  217. package/dist/cli/commands/init-primitives.js.map +1 -0
  218. package/dist/cli/commands/sop.d.ts +14 -0
  219. package/dist/cli/commands/sop.d.ts.map +1 -0
  220. package/dist/cli/commands/sop.js +598 -0
  221. package/dist/cli/commands/sop.js.map +1 -0
  222. package/dist/cli/index.d.ts.map +1 -1
  223. package/dist/cli/index.js +40 -1
  224. package/dist/cli/index.js.map +1 -1
  225. package/dist/config/index.d.ts +153 -0
  226. package/dist/config/index.d.ts.map +1 -0
  227. package/dist/config/index.js +141 -0
  228. package/dist/config/index.js.map +1 -0
  229. package/dist/config/manager.d.ts +136 -0
  230. package/dist/config/manager.d.ts.map +1 -0
  231. package/dist/config/types.d.ts +127 -0
  232. package/dist/config/types.d.ts.map +1 -0
  233. package/dist/core/cache.d.ts +185 -0
  234. package/dist/core/cache.d.ts.map +1 -0
  235. package/dist/core/cache.js +435 -0
  236. package/dist/core/cache.js.map +1 -0
  237. package/dist/cultivation/deep-analyzer.d.ts +129 -0
  238. package/dist/cultivation/deep-analyzer.d.ts.map +1 -0
  239. package/dist/cultivation/deep-analyzer.js +322 -0
  240. package/dist/cultivation/deep-analyzer.js.map +1 -0
  241. package/dist/cultivation/index.d.ts +13 -0
  242. package/dist/cultivation/index.d.ts.map +1 -0
  243. package/dist/cultivation/seed-generator.d.ts +92 -0
  244. package/dist/cultivation/seed-generator.d.ts.map +1 -0
  245. package/dist/cultivation/seed-generator.js +1033 -0
  246. package/dist/cultivation/seed-generator.js.map +1 -0
  247. package/dist/cultivation/types.d.ts +230 -0
  248. package/dist/cultivation/types.d.ts.map +1 -0
  249. package/dist/generators/claude-md.d.ts +7 -0
  250. package/dist/generators/claude-md.d.ts.map +1 -1
  251. package/dist/generators/claude-md.js.map +1 -1
  252. package/dist/generators/docs-init.d.ts +6 -0
  253. package/dist/generators/docs-init.d.ts.map +1 -1
  254. package/dist/generators/docs-init.js.map +1 -1
  255. package/dist/health/checks.d.ts +135 -0
  256. package/dist/health/checks.d.ts.map +1 -0
  257. package/dist/health/index.d.ts +119 -0
  258. package/dist/health/index.d.ts.map +1 -0
  259. package/dist/health/index.js +191 -0
  260. package/dist/health/index.js.map +1 -0
  261. package/dist/health/monitor.d.ts +146 -0
  262. package/dist/health/monitor.d.ts.map +1 -0
  263. package/dist/health/types.d.ts +135 -0
  264. package/dist/health/types.d.ts.map +1 -0
  265. package/dist/index.d.ts +30 -0
  266. package/dist/index.d.ts.map +1 -1
  267. package/dist/index.js +173 -1
  268. package/dist/index.js.map +1 -1
  269. package/dist/integrations/auto-commit.d.ts +175 -0
  270. package/dist/integrations/auto-commit.d.ts.map +1 -0
  271. package/dist/integrations/auto-commit.js +399 -0
  272. package/dist/integrations/auto-commit.js.map +1 -0
  273. package/dist/integrations/git.d.ts +299 -0
  274. package/dist/integrations/git.d.ts.map +1 -0
  275. package/dist/integrations/git.js +465 -0
  276. package/dist/integrations/git.js.map +1 -0
  277. package/dist/mcp-server/bin.d.ts +11 -0
  278. package/dist/mcp-server/bin.d.ts.map +1 -0
  279. package/dist/mcp-server/handlers/index.d.ts +57 -0
  280. package/dist/mcp-server/handlers/index.d.ts.map +1 -0
  281. package/dist/mcp-server/handlers/index.js +235 -0
  282. package/dist/mcp-server/handlers/index.js.map +1 -0
  283. package/dist/mcp-server/index.d.ts +28 -0
  284. package/dist/mcp-server/index.d.ts.map +1 -0
  285. package/dist/mcp-server/server.d.ts +133 -0
  286. package/dist/mcp-server/server.d.ts.map +1 -0
  287. package/dist/mcp-server/server.js +280 -0
  288. package/dist/mcp-server/server.js.map +1 -0
  289. package/dist/mcp-server/tools/agents/index.d.ts +10 -0
  290. package/dist/mcp-server/tools/agents/index.d.ts.map +1 -0
  291. package/dist/mcp-server/tools/agents/list.d.ts +19 -0
  292. package/dist/mcp-server/tools/agents/list.d.ts.map +1 -0
  293. package/dist/mcp-server/tools/agents/spawn.d.ts +19 -0
  294. package/dist/mcp-server/tools/agents/spawn.d.ts.map +1 -0
  295. package/dist/mcp-server/tools/graph/generate.d.ts +21 -0
  296. package/dist/mcp-server/tools/graph/generate.d.ts.map +1 -0
  297. package/dist/mcp-server/tools/graph/index.d.ts +11 -0
  298. package/dist/mcp-server/tools/graph/index.d.ts.map +1 -0
  299. package/dist/mcp-server/tools/graph/query.d.ts +22 -0
  300. package/dist/mcp-server/tools/graph/query.d.ts.map +1 -0
  301. package/dist/mcp-server/tools/graph/stats.d.ts +22 -0
  302. package/dist/mcp-server/tools/graph/stats.d.ts.map +1 -0
  303. package/dist/mcp-server/tools/health.d.ts +21 -0
  304. package/dist/mcp-server/tools/health.d.ts.map +1 -0
  305. package/dist/mcp-server/tools/index.d.ts +13 -0
  306. package/dist/mcp-server/tools/index.d.ts.map +1 -0
  307. package/dist/mcp-server/tools/registry.d.ts +90 -0
  308. package/dist/mcp-server/tools/registry.d.ts.map +1 -0
  309. package/dist/mcp-server/tools/registry.js +663 -0
  310. package/dist/mcp-server/tools/registry.js.map +1 -0
  311. package/dist/mcp-server/tools/search/index.d.ts +10 -0
  312. package/dist/mcp-server/tools/search/index.d.ts.map +1 -0
  313. package/dist/mcp-server/tools/search/nodes.d.ts +22 -0
  314. package/dist/mcp-server/tools/search/nodes.d.ts.map +1 -0
  315. package/dist/mcp-server/tools/search/tags.d.ts +22 -0
  316. package/dist/mcp-server/tools/search/tags.d.ts.map +1 -0
  317. package/dist/mcp-server/types/index.d.ts +286 -0
  318. package/dist/mcp-server/types/index.d.ts.map +1 -0
  319. package/dist/memory/index.d.ts +10 -0
  320. package/dist/memory/index.d.ts.map +1 -0
  321. package/dist/memory/vault-sync.d.ts +212 -0
  322. package/dist/memory/vault-sync.d.ts.map +1 -0
  323. package/dist/memory/vault-sync.js +463 -0
  324. package/dist/memory/vault-sync.js.map +1 -0
  325. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +296 -0
  326. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
  327. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +71 -0
  328. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
  329. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +26 -0
  330. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
  331. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +407 -0
  332. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
  333. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1332 -0
  334. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
  335. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +71 -0
  336. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
  337. package/dist/node_modules/ajv/dist/ajv.js +84 -0
  338. package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
  339. package/dist/node_modules/ajv/dist/compile/codegen/code.js +160 -0
  340. package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
  341. package/dist/node_modules/ajv/dist/compile/codegen/index.js +728 -0
  342. package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
  343. package/dist/node_modules/ajv/dist/compile/codegen/scope.js +152 -0
  344. package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
  345. package/dist/node_modules/ajv/dist/compile/errors.js +131 -0
  346. package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
  347. package/dist/node_modules/ajv/dist/compile/index.js +234 -0
  348. package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
  349. package/dist/node_modules/ajv/dist/compile/names.js +44 -0
  350. package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
  351. package/dist/node_modules/ajv/dist/compile/ref_error.js +22 -0
  352. package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
  353. package/dist/node_modules/ajv/dist/compile/resolve.js +163 -0
  354. package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
  355. package/dist/node_modules/ajv/dist/compile/rules.js +35 -0
  356. package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
  357. package/dist/node_modules/ajv/dist/compile/util.js +173 -0
  358. package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
  359. package/dist/node_modules/ajv/dist/compile/validate/applicability.js +27 -0
  360. package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
  361. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +58 -0
  362. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
  363. package/dist/node_modules/ajv/dist/compile/validate/dataType.js +193 -0
  364. package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
  365. package/dist/node_modules/ajv/dist/compile/validate/defaults.js +43 -0
  366. package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
  367. package/dist/node_modules/ajv/dist/compile/validate/index.js +522 -0
  368. package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
  369. package/dist/node_modules/ajv/dist/compile/validate/keyword.js +126 -0
  370. package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
  371. package/dist/node_modules/ajv/dist/compile/validate/subschema.js +89 -0
  372. package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
  373. package/dist/node_modules/ajv/dist/core.js +628 -0
  374. package/dist/node_modules/ajv/dist/core.js.map +1 -0
  375. package/dist/node_modules/ajv/dist/refs/data.json.js +24 -0
  376. package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
  377. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +25 -0
  378. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
  379. package/dist/node_modules/ajv/dist/runtime/equal.js +16 -0
  380. package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
  381. package/dist/node_modules/ajv/dist/runtime/ucs2length.js +30 -0
  382. package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
  383. package/dist/node_modules/ajv/dist/runtime/uri.js +16 -0
  384. package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
  385. package/dist/node_modules/ajv/dist/runtime/validation_error.js +20 -0
  386. package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
  387. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +59 -0
  388. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
  389. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +114 -0
  390. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
  391. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +32 -0
  392. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
  393. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +22 -0
  394. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
  395. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +100 -0
  396. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
  397. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +103 -0
  398. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
  399. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +75 -0
  400. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
  401. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +68 -0
  402. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
  403. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +64 -0
  404. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
  405. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +43 -0
  406. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
  407. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +36 -0
  408. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
  409. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
  410. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
  411. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +81 -0
  412. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
  413. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +22 -0
  414. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
  415. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +66 -0
  416. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
  417. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +49 -0
  418. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
  419. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +23 -0
  420. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
  421. package/dist/node_modules/ajv/dist/vocabularies/code.js +140 -0
  422. package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
  423. package/dist/node_modules/ajv/dist/vocabularies/core/id.js +19 -0
  424. package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
  425. package/dist/node_modules/ajv/dist/vocabularies/core/index.js +27 -0
  426. package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
  427. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +132 -0
  428. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
  429. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +114 -0
  430. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
  431. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +18 -0
  432. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
  433. package/dist/node_modules/ajv/dist/vocabularies/draft7.js +31 -0
  434. package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
  435. package/dist/node_modules/ajv/dist/vocabularies/format/format.js +95 -0
  436. package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
  437. package/dist/node_modules/ajv/dist/vocabularies/format/index.js +16 -0
  438. package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
  439. package/dist/node_modules/ajv/dist/vocabularies/metadata.js +27 -0
  440. package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
  441. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +36 -0
  442. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
  443. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +56 -0
  444. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
  445. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +52 -0
  446. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
  447. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +34 -0
  448. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
  449. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +39 -0
  450. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
  451. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +37 -0
  452. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
  453. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +34 -0
  454. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
  455. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +33 -0
  456. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
  457. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +34 -0
  458. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
  459. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +89 -0
  460. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
  461. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +75 -0
  462. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
  463. package/dist/node_modules/ajv-formats/dist/formats.js +209 -0
  464. package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
  465. package/dist/node_modules/ajv-formats/dist/index.js +51 -0
  466. package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
  467. package/dist/node_modules/ajv-formats/dist/limit.js +80 -0
  468. package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
  469. package/dist/node_modules/fast-deep-equal/index.js +39 -0
  470. package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
  471. package/dist/node_modules/fast-uri/index.js +261 -0
  472. package/dist/node_modules/fast-uri/index.js.map +1 -0
  473. package/dist/node_modules/fast-uri/lib/schemes.js +215 -0
  474. package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
  475. package/dist/node_modules/fast-uri/lib/utils.js +261 -0
  476. package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
  477. package/dist/node_modules/json-schema-traverse/index.js +92 -0
  478. package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
  479. package/dist/node_modules/zod/v4/classic/errors.js +37 -0
  480. package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
  481. package/dist/node_modules/zod/v4/classic/iso.js +43 -0
  482. package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
  483. package/dist/node_modules/zod/v4/classic/parse.js +13 -0
  484. package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
  485. package/dist/node_modules/zod/v4/classic/schemas.js +688 -0
  486. package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
  487. package/dist/node_modules/zod/v4/core/api.js +492 -0
  488. package/dist/node_modules/zod/v4/core/api.js.map +1 -0
  489. package/dist/node_modules/zod/v4/core/checks.js +405 -0
  490. package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
  491. package/dist/node_modules/zod/v4/core/core.js +58 -0
  492. package/dist/node_modules/zod/v4/core/core.js.map +1 -0
  493. package/dist/node_modules/zod/v4/core/doc.js +38 -0
  494. package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
  495. package/dist/node_modules/zod/v4/core/errors.js +82 -0
  496. package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
  497. package/dist/node_modules/zod/v4/core/parse.js +60 -0
  498. package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
  499. package/dist/node_modules/zod/v4/core/regexes.js +87 -0
  500. package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
  501. package/dist/node_modules/zod/v4/core/registries.js +52 -0
  502. package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
  503. package/dist/node_modules/zod/v4/core/schemas.js +1283 -0
  504. package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
  505. package/dist/node_modules/zod/v4/core/util.js +341 -0
  506. package/dist/node_modules/zod/v4/core/util.js.map +1 -0
  507. package/dist/node_modules/zod/v4/core/versions.js +9 -0
  508. package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
  509. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +2 -0
  510. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
  511. package/dist/reasoning/index.d.ts +74 -0
  512. package/dist/reasoning/index.d.ts.map +1 -0
  513. package/dist/reasoning/index.js +124 -0
  514. package/dist/reasoning/index.js.map +1 -0
  515. package/dist/reasoning/tracker.d.ts +210 -0
  516. package/dist/reasoning/tracker.d.ts.map +1 -0
  517. package/dist/reasoning/types.d.ts +146 -0
  518. package/dist/reasoning/types.d.ts.map +1 -0
  519. package/dist/recovery/backup.d.ts +110 -0
  520. package/dist/recovery/backup.d.ts.map +1 -0
  521. package/dist/recovery/index.d.ts +70 -0
  522. package/dist/recovery/index.d.ts.map +1 -0
  523. package/dist/recovery/index.js +186 -0
  524. package/dist/recovery/index.js.map +1 -0
  525. package/dist/recovery/integrity.d.ts +74 -0
  526. package/dist/recovery/integrity.d.ts.map +1 -0
  527. package/dist/recovery/types.d.ts +94 -0
  528. package/dist/recovery/types.d.ts.map +1 -0
  529. package/dist/services/index.d.ts +130 -0
  530. package/dist/services/index.d.ts.map +1 -0
  531. package/dist/services/index.js +134 -0
  532. package/dist/services/index.js.map +1 -0
  533. package/dist/services/manager.d.ts +140 -0
  534. package/dist/services/manager.d.ts.map +1 -0
  535. package/dist/services/types.d.ts +106 -0
  536. package/dist/services/types.d.ts.map +1 -0
  537. package/dist/services/watchers.d.ts +95 -0
  538. package/dist/services/watchers.d.ts.map +1 -0
  539. package/dist/sops/compliance-checker.d.ts +83 -0
  540. package/dist/sops/compliance-checker.d.ts.map +1 -0
  541. package/dist/sops/compliance-checker.js +399 -0
  542. package/dist/sops/compliance-checker.js.map +1 -0
  543. package/dist/sops/gap-analyzer.d.ts +124 -0
  544. package/dist/sops/gap-analyzer.d.ts.map +1 -0
  545. package/dist/sops/gap-analyzer.js +313 -0
  546. package/dist/sops/gap-analyzer.js.map +1 -0
  547. package/dist/sops/index.d.ts +14 -0
  548. package/dist/sops/index.d.ts.map +1 -0
  549. package/dist/sops/overlay-manager.d.ts +115 -0
  550. package/dist/sops/overlay-manager.d.ts.map +1 -0
  551. package/dist/sops/overlay-manager.js +394 -0
  552. package/dist/sops/overlay-manager.js.map +1 -0
  553. package/dist/sops/registry.d.ts +73 -0
  554. package/dist/sops/registry.d.ts.map +1 -0
  555. package/dist/sops/registry.js +919 -0
  556. package/dist/sops/registry.js.map +1 -0
  557. package/dist/sops/types.d.ts +377 -0
  558. package/dist/sops/types.d.ts.map +1 -0
  559. package/dist/sops/types.js +46 -0
  560. package/dist/sops/types.js.map +1 -0
  561. package/dist/utils/error-recovery.d.ts +230 -0
  562. package/dist/utils/error-recovery.d.ts.map +1 -0
  563. package/dist/utils/error-recovery.js +228 -0
  564. package/dist/utils/error-recovery.js.map +1 -0
  565. package/dist/utils/error-taxonomy.d.ts +149 -0
  566. package/dist/utils/error-taxonomy.d.ts.map +1 -0
  567. package/dist/utils/error-taxonomy.js +260 -0
  568. package/dist/utils/error-taxonomy.js.map +1 -0
  569. package/dist/utils/index.d.ts +11 -0
  570. package/dist/utils/index.d.ts.map +1 -0
  571. package/dist/utils/logger.d.ts +139 -0
  572. package/dist/utils/logger.d.ts.map +1 -0
  573. package/dist/utils/logger.js +311 -0
  574. package/dist/utils/logger.js.map +1 -0
  575. package/dist/workflows/index.d.ts +11 -0
  576. package/dist/workflows/index.d.ts.map +1 -0
  577. package/dist/workflows/registry.d.ts +118 -0
  578. package/dist/workflows/registry.d.ts.map +1 -0
  579. package/dist/workflows/registry.js +575 -0
  580. package/dist/workflows/registry.js.map +1 -0
  581. package/dist/workflows/types.d.ts +322 -0
  582. package/dist/workflows/types.d.ts.map +1 -0
  583. package/dist/workflows/types.js +16 -0
  584. package/dist/workflows/types.js.map +1 -0
  585. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../src/sops/types.ts"],"sourcesContent":["/**\n * AI-SDLC SOP Types and Schemas\n *\n * Type definitions for AI-SDLC Standard Operating Procedures integration.\n * Based on https://github.com/AISDLC/AI-SDLC-SOPs\n *\n * @module sops/types\n */\n\n/**\n * SOP Categories aligned with AI-SDLC framework\n */\nexport enum SOPCategory {\n /** Program and Project Management (1000-1010) */\n PROGRAM_MANAGEMENT = 'program-management',\n\n /** Operational and Maintenance (1011-1060) */\n OPERATIONS = 'operations',\n\n /** Training and Development (1100-1220) */\n DEVELOPMENT = 'development',\n\n /** Governance and Specialized Controls (1300-2000) */\n GOVERNANCE = 'governance',\n\n /** Quality Records (2000+) */\n QUALITY = 'quality',\n}\n\n/**\n * SOP Compliance Status\n */\nexport enum ComplianceStatus {\n /** Fully compliant with SOP requirements */\n COMPLIANT = 'compliant',\n\n /** Partially compliant - some requirements met */\n PARTIAL = 'partial',\n\n /** Not compliant - requirements not met */\n NON_COMPLIANT = 'non-compliant',\n\n /** Not applicable to this project */\n NOT_APPLICABLE = 'not-applicable',\n\n /** Not yet assessed */\n PENDING = 'pending',\n}\n\n/**\n * SOP Priority/Risk Level\n */\nexport enum SOPPriority {\n /** Critical - Must be addressed immediately */\n CRITICAL = 'critical',\n\n /** High - Should be addressed soon */\n HIGH = 'high',\n\n /** Medium - Address in normal course */\n MEDIUM = 'medium',\n\n /** Low - Nice to have */\n LOW = 'low',\n}\n\n/**\n * AI-IRB Review Status\n */\nexport enum IRBStatus {\n /** Requires IRB review */\n REQUIRED = 'required',\n\n /** IRB review in progress */\n IN_REVIEW = 'in-review',\n\n /** IRB approved */\n APPROVED = 'approved',\n\n /** IRB approval not required */\n NOT_REQUIRED = 'not-required',\n\n /** IRB review pending */\n PENDING = 'pending',\n}\n\n/**\n * Knowledge Graph Layer Types\n */\nexport enum GraphLayer {\n /** Foundation layer - AI-SDLC SOPs reference */\n STANDARDS = 'standards',\n\n /** Project implementation layer */\n PROJECT = 'project',\n\n /** Compliance overlay showing gaps */\n COMPLIANCE = 'compliance',\n\n /** Custom overlay */\n CUSTOM = 'custom',\n}\n\n/**\n * SOP Requirement definition\n */\nexport interface SOPRequirement {\n /** Requirement ID */\n id: string;\n\n /** Requirement description */\n description: string;\n\n /** Whether this requirement is mandatory */\n mandatory: boolean;\n\n /** Verification method */\n verification: 'document' | 'test' | 'review' | 'audit' | 'automated';\n\n /** Evidence required for compliance */\n evidence: string[];\n\n /** Related artifacts */\n artifacts?: string[];\n}\n\n/**\n * SOP Checkpoint definition\n */\nexport interface SOPCheckpoint {\n /** Checkpoint ID */\n id: string;\n\n /** Checkpoint name */\n name: string;\n\n /** When this checkpoint should be triggered */\n trigger: 'phase-start' | 'phase-end' | 'milestone' | 'continuous' | 'scheduled';\n\n /** Phase this checkpoint applies to */\n phase?: string;\n\n /** Requirements to verify at this checkpoint */\n requirements: string[];\n\n /** AI-IRB involvement */\n irbRequired: boolean;\n\n /** Approval authorities */\n approvers: string[];\n}\n\n/**\n * SOP Definition\n */\nexport interface SOPDefinition {\n /** SOP ID (e.g., \"SOP-1200-01-AI\") */\n id: string;\n\n /** SOP number (e.g., 1200) */\n number: number;\n\n /** SOP title */\n title: string;\n\n /** SOP description */\n description: string;\n\n /** SOP category */\n category: SOPCategory;\n\n /** Priority/risk level */\n priority: SOPPriority;\n\n /** Version */\n version: string;\n\n /** Source URL */\n sourceUrl: string;\n\n /** Scope description */\n scope: string;\n\n /** Requirements */\n requirements: SOPRequirement[];\n\n /** Checkpoints */\n checkpoints: SOPCheckpoint[];\n\n /** Related SOPs */\n relatedSOPs: string[];\n\n /** Tags for searching */\n tags: string[];\n\n /** Whether AI-IRB review is typically required */\n irbTypicallyRequired: boolean;\n\n /** Applicable project types */\n applicableTo: string[];\n}\n\n/**\n * Project SOP Assessment\n */\nexport interface SOPAssessment {\n /** SOP ID being assessed */\n sopId: string;\n\n /** Current compliance status */\n status: ComplianceStatus;\n\n /** Compliance score (0-100) */\n score: number;\n\n /** Requirements met */\n requirementsMet: string[];\n\n /** Requirements not met (gaps) */\n requirementsGaps: string[];\n\n /** Evidence provided */\n evidence: Record<string, string>;\n\n /** AI-IRB status */\n irbStatus: IRBStatus;\n\n /** Assessment date */\n assessedAt: Date;\n\n /** Assessor */\n assessedBy: string;\n\n /** Notes */\n notes: string;\n\n /** Remediation plan if non-compliant */\n remediationPlan?: string;\n\n /** Target compliance date */\n targetDate?: Date;\n}\n\n/**\n * Compliance Gap\n */\nexport interface ComplianceGap {\n /** Gap ID */\n id: string;\n\n /** SOP ID */\n sopId: string;\n\n /** Requirement ID */\n requirementId: string;\n\n /** Gap description */\n description: string;\n\n /** Priority */\n priority: SOPPriority;\n\n /** Impact description */\n impact: string;\n\n /** Recommended remediation */\n remediation: string;\n\n /** Effort estimate */\n effort: 'low' | 'medium' | 'high';\n\n /** Status */\n status: 'open' | 'in-progress' | 'resolved' | 'accepted-risk';\n\n /** Created date */\n createdAt: Date;\n\n /** Resolved date */\n resolvedAt?: Date;\n}\n\n/**\n * Graph Layer Definition\n */\nexport interface LayerDefinition {\n /** Layer ID */\n id: string;\n\n /** Layer name */\n name: string;\n\n /** Layer type */\n type: GraphLayer;\n\n /** Layer description */\n description: string;\n\n /** Whether layer is visible */\n visible: boolean;\n\n /** Layer order (for rendering) */\n order: number;\n\n /** Node filter for this layer */\n nodeFilter?: (node: LayerNode) => boolean;\n\n /** Edge filter for this layer */\n edgeFilter?: (edge: LayerEdge) => boolean;\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Layer Node - extends base node with layer info\n */\nexport interface LayerNode {\n /** Node ID */\n id: string;\n\n /** Node title */\n title: string;\n\n /** Node type */\n type: string;\n\n /** Layer this node belongs to */\n layer: GraphLayer;\n\n /** SOP reference (for standards layer) */\n sopRef?: string;\n\n /** Compliance status (for compliance layer) */\n complianceStatus?: ComplianceStatus;\n\n /** Tags */\n tags: string[];\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Layer Edge - extends base edge with layer info\n */\nexport interface LayerEdge {\n /** Source node ID */\n source: string;\n\n /** Target node ID */\n target: string;\n\n /** Edge type */\n type: 'implements' | 'references' | 'depends-on' | 'compliance-gap' | 'wikilink';\n\n /** Layer this edge belongs to */\n layer: GraphLayer;\n\n /** Weight */\n weight: number;\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Multi-Layer Graph\n */\nexport interface MultiLayerGraph {\n /** Graph ID */\n id: string;\n\n /** Graph name */\n name: string;\n\n /** Layers */\n layers: LayerDefinition[];\n\n /** All nodes across layers */\n nodes: LayerNode[];\n\n /** All edges across layers */\n edges: LayerEdge[];\n\n /** Cross-layer edges (connecting nodes in different layers) */\n crossLayerEdges: LayerEdge[];\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Compliance Report\n */\nexport interface ComplianceReport {\n /** Report ID */\n id: string;\n\n /** Project name */\n projectName: string;\n\n /** Report generation date */\n generatedAt: Date;\n\n /** Overall compliance score (0-100) */\n overallScore: number;\n\n /** SOP assessments */\n assessments: SOPAssessment[];\n\n /** Open gaps */\n gaps: ComplianceGap[];\n\n /** Summary by category */\n categoryScores: Record<SOPCategory, number>;\n\n /** Summary by priority */\n priorityBreakdown: Record<SOPPriority, { total: number; compliant: number }>;\n\n /** AI-IRB summary */\n irbSummary: {\n required: number;\n approved: number;\n pending: number;\n inReview: number;\n };\n\n /** Recommendations */\n recommendations: string[];\n}\n\n/**\n * SOP Node Frontmatter - extends standard frontmatter with SOP fields\n */\nexport interface SOPFrontmatter {\n /** Standard frontmatter fields */\n title?: string;\n type?: string;\n status?: string;\n created?: string;\n updated?: string;\n tags?: string[];\n\n /** SOP-specific fields */\n sop?: {\n /** SOP ID reference */\n id?: string;\n\n /** Compliance status */\n status?: ComplianceStatus;\n\n /** AI-IRB status */\n irbStatus?: IRBStatus;\n\n /** Requirements addressed */\n requirements?: string[];\n\n /** Evidence links */\n evidence?: string[];\n\n /** Last assessment date */\n assessedAt?: string;\n\n /** Assessor */\n assessedBy?: string;\n\n /** Notes */\n notes?: string;\n };\n\n /** Layer assignment */\n layer?: GraphLayer;\n}\n\n/**\n * SOP Configuration\n */\nexport interface SOPConfig {\n /** Whether SOP compliance is enabled */\n enabled: boolean;\n\n /** Source repository for SOPs */\n sourceRepo: string;\n\n /** SOP version/tag to use */\n version: string;\n\n /** Categories to include */\n categories: SOPCategory[];\n\n /** Custom SOP definitions */\n customSOPs?: SOPDefinition[];\n\n /** Default IRB requirement */\n defaultIRBRequired: boolean;\n\n /** Auto-assessment configuration */\n autoAssess?: {\n /** Enable auto-assessment */\n enabled: boolean;\n\n /** Patterns to match for compliance */\n patterns: Record<string, string[]>;\n };\n}\n"],"names":["SOPCategory","ComplianceStatus","SOPPriority","IRBStatus","GraphLayer"],"mappings":"AAYO,IAAK,gCAAAA,iBAAL;AAELA,eAAA,oBAAA,IAAqB;AAGrBA,eAAA,YAAA,IAAa;AAGbA,eAAA,aAAA,IAAc;AAGdA,eAAA,YAAA,IAAa;AAGbA,eAAA,SAAA,IAAU;AAdA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAoBL,IAAK,qCAAAC,sBAAL;AAELA,oBAAA,WAAA,IAAY;AAGZA,oBAAA,SAAA,IAAU;AAGVA,oBAAA,eAAA,IAAgB;AAGhBA,oBAAA,gBAAA,IAAiB;AAGjBA,oBAAA,SAAA,IAAU;AAdA,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAoBL,IAAK,gCAAAC,iBAAL;AAELA,eAAA,UAAA,IAAW;AAGXA,eAAA,MAAA,IAAO;AAGPA,eAAA,QAAA,IAAS;AAGTA,eAAA,KAAA,IAAM;AAXI,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAiBL,IAAK,8BAAAC,eAAL;AAELA,aAAA,UAAA,IAAW;AAGXA,aAAA,WAAA,IAAY;AAGZA,aAAA,UAAA,IAAW;AAGXA,aAAA,cAAA,IAAe;AAGfA,aAAA,SAAA,IAAU;AAdA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAoBL,IAAK,+BAAAC,gBAAL;AAELA,cAAA,WAAA,IAAY;AAGZA,cAAA,SAAA,IAAU;AAGVA,cAAA,YAAA,IAAa;AAGbA,cAAA,QAAA,IAAS;AAXC,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;"}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Error Recovery System
3
+ *
4
+ * Provides intelligent retry strategies with exponential backoff,
5
+ * jitter, and circuit breaker patterns. Based on weaver recovery patterns.
6
+ *
7
+ * @module utils/error-recovery
8
+ */
9
+ import { type ClassifiedError } from './error-taxonomy.js';
10
+ /**
11
+ * Retry configuration options
12
+ */
13
+ export interface RetryOptions {
14
+ /** Maximum number of retry attempts (default: 3) */
15
+ maxRetries?: number;
16
+ /** Initial delay in milliseconds (default: 1000) */
17
+ initialDelay?: number;
18
+ /** Maximum delay in milliseconds (default: 30000) */
19
+ maxDelay?: number;
20
+ /** Backoff factor for exponential backoff (default: 2) */
21
+ backoffFactor?: number;
22
+ /** Whether to add random jitter (default: true) */
23
+ jitter?: boolean;
24
+ /** Jitter factor (0-1, default: 0.1) */
25
+ jitterFactor?: number;
26
+ /** Custom function to determine if error is retryable */
27
+ isRetryable?: (error: unknown) => boolean;
28
+ /** Called before each retry attempt */
29
+ onRetry?: (error: ClassifiedError, attempt: number, delay: number) => void;
30
+ /** Abort signal for cancellation */
31
+ signal?: AbortSignal;
32
+ }
33
+ /**
34
+ * Result of a retry operation
35
+ */
36
+ export interface RetryResult<T> {
37
+ /** Whether the operation succeeded */
38
+ success: boolean;
39
+ /** The result value (if successful) */
40
+ value?: T;
41
+ /** The final error (if failed) */
42
+ error?: ClassifiedError;
43
+ /** Number of attempts made */
44
+ attempts: number;
45
+ /** Total time spent in milliseconds */
46
+ totalTime: number;
47
+ }
48
+ /**
49
+ * Circuit breaker state
50
+ */
51
+ export declare enum CircuitState {
52
+ CLOSED = "closed",
53
+ OPEN = "open",
54
+ HALF_OPEN = "half_open"
55
+ }
56
+ /**
57
+ * Circuit breaker configuration
58
+ */
59
+ export interface CircuitBreakerOptions {
60
+ /** Number of failures before opening circuit (default: 5) */
61
+ failureThreshold?: number;
62
+ /** Time in ms before testing circuit again (default: 30000) */
63
+ resetTimeout?: number;
64
+ /** Number of successful tests before fully closing (default: 2) */
65
+ successThreshold?: number;
66
+ /** Whether to track errors by type (default: false) */
67
+ trackByErrorType?: boolean;
68
+ }
69
+ /**
70
+ * Circuit breaker for protecting against cascading failures
71
+ */
72
+ export declare class CircuitBreaker {
73
+ private state;
74
+ private failures;
75
+ private successCount;
76
+ private lastFailureTime;
77
+ private readonly options;
78
+ constructor(options?: CircuitBreakerOptions);
79
+ /**
80
+ * Get current circuit state
81
+ */
82
+ getState(): CircuitState;
83
+ /**
84
+ * Check if circuit allows execution
85
+ */
86
+ canExecute(): boolean;
87
+ /**
88
+ * Record a successful execution
89
+ */
90
+ recordSuccess(): void;
91
+ /**
92
+ * Record a failed execution
93
+ */
94
+ recordFailure(): void;
95
+ /**
96
+ * Reset the circuit breaker
97
+ */
98
+ reset(): void;
99
+ }
100
+ /**
101
+ * Calculate delay with exponential backoff
102
+ *
103
+ * @param attempt - The current attempt number (1-based)
104
+ * @param options - Retry options
105
+ * @returns Delay in milliseconds
106
+ */
107
+ export declare function calculateBackoff(attempt: number, options?: Pick<RetryOptions, 'initialDelay' | 'maxDelay' | 'backoffFactor' | 'jitter' | 'jitterFactor'>): number;
108
+ /**
109
+ * Sleep for specified duration
110
+ *
111
+ * @param ms - Duration in milliseconds
112
+ * @param signal - Optional abort signal
113
+ */
114
+ export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
115
+ /**
116
+ * Execute operation with automatic retry
117
+ *
118
+ * @param operation - The async operation to execute
119
+ * @param options - Retry configuration
120
+ * @returns Result containing value or error
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const result = await withRetry(
125
+ * () => fetchData(),
126
+ * { maxRetries: 5, onRetry: (err, attempt) => console.log(`Retry ${attempt}`) }
127
+ * );
128
+ *
129
+ * if (result.success) {
130
+ * console.log('Data:', result.value);
131
+ * } else {
132
+ * console.error('Failed after', result.attempts, 'attempts');
133
+ * }
134
+ * ```
135
+ */
136
+ export declare function withRetry<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<RetryResult<T>>;
137
+ /**
138
+ * Execute operation with automatic retry (throws on failure)
139
+ *
140
+ * @param operation - The async operation to execute
141
+ * @param options - Retry configuration
142
+ * @returns The operation result
143
+ * @throws The last error if all retries fail
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * try {
148
+ * const data = await retry(() => fetchData(), { maxRetries: 3 });
149
+ * console.log('Data:', data);
150
+ * } catch (error) {
151
+ * console.error('All retries failed:', error);
152
+ * }
153
+ * ```
154
+ */
155
+ export declare function retry<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<T>;
156
+ /**
157
+ * Fallback chain options
158
+ */
159
+ export interface FallbackOptions<T> {
160
+ /** Called when primary operation fails */
161
+ onFallback?: (error: ClassifiedError, index: number) => void;
162
+ /** Abort signal */
163
+ signal?: AbortSignal;
164
+ /** Default value if all operations fail */
165
+ defaultValue?: T;
166
+ }
167
+ /**
168
+ * Execute with fallback chain
169
+ *
170
+ * Tries each operation in sequence until one succeeds.
171
+ *
172
+ * @param operations - Array of fallback operations
173
+ * @param options - Fallback configuration
174
+ * @returns The first successful result or default value
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const data = await withFallback(
179
+ * [
180
+ * () => fetchFromPrimary(),
181
+ * () => fetchFromSecondary(),
182
+ * () => fetchFromCache(),
183
+ * ],
184
+ * { defaultValue: { cached: true, data: [] } }
185
+ * );
186
+ * ```
187
+ */
188
+ export declare function withFallback<T>(operations: Array<() => Promise<T>>, options?: FallbackOptions<T>): Promise<T>;
189
+ /**
190
+ * Execute with circuit breaker
191
+ *
192
+ * @param operation - The operation to execute
193
+ * @param breaker - Circuit breaker instance
194
+ * @returns The operation result
195
+ * @throws If circuit is open or operation fails
196
+ */
197
+ export declare function withCircuitBreaker<T>(operation: () => Promise<T>, breaker: CircuitBreaker): Promise<T>;
198
+ /**
199
+ * Create a retryable version of an async function
200
+ *
201
+ * @param fn - The async function to wrap
202
+ * @param options - Default retry options
203
+ * @returns A new function that automatically retries on failure
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const fetchWithRetry = retryable(
208
+ * (url: string) => fetch(url),
209
+ * { maxRetries: 3 }
210
+ * );
211
+ *
212
+ * const response = await fetchWithRetry('https://api.example.com/data');
213
+ * ```
214
+ */
215
+ export declare function retryable<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, options?: RetryOptions): (...args: TArgs) => Promise<TResult>;
216
+ /**
217
+ * Error class for retries exhausted
218
+ */
219
+ export declare class RetriesExhaustedError extends Error {
220
+ readonly lastError: ClassifiedError;
221
+ readonly attempts: number;
222
+ constructor(lastError: ClassifiedError, attempts: number);
223
+ }
224
+ /**
225
+ * Error class for circuit breaker open
226
+ */
227
+ export declare class CircuitOpenError extends Error {
228
+ constructor(message?: string);
229
+ }
230
+ //# sourceMappingURL=error-recovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-recovery.d.ts","sourceRoot":"","sources":["../../src/utils/error-recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGL,KAAK,eAAe,EAGrB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,mDAAmD;IACnD,MAAM,CAAC,EAA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C,CAAC,CAAC,EACnC,OAAO,GAAE,eAAe,CAAC,CAAC,CAAM,GAC/B,OAAO,CAAC,CAAC,CAAC,CA6BZ;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACxD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,EACxC,OAAO,GAAE,YAAiB,GACzB,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAEtC;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAgB,SAAS,EAAE,eAAe,CAAC;IAC3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM;CAMzD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,SAA4B;CAIhD"}
@@ -0,0 +1,228 @@
1
+ import { isRetryableError, classifyError, isRateLimitError } from "./error-taxonomy.js";
2
+ var CircuitState = /* @__PURE__ */ ((CircuitState2) => {
3
+ CircuitState2["CLOSED"] = "closed";
4
+ CircuitState2["OPEN"] = "open";
5
+ CircuitState2["HALF_OPEN"] = "half_open";
6
+ return CircuitState2;
7
+ })(CircuitState || {});
8
+ class CircuitBreaker {
9
+ state = "closed";
10
+ failures = 0;
11
+ successCount = 0;
12
+ lastFailureTime = 0;
13
+ options;
14
+ constructor(options = {}) {
15
+ this.options = {
16
+ failureThreshold: options.failureThreshold ?? 5,
17
+ resetTimeout: options.resetTimeout ?? 3e4,
18
+ successThreshold: options.successThreshold ?? 2,
19
+ trackByErrorType: options.trackByErrorType ?? false
20
+ };
21
+ }
22
+ /**
23
+ * Get current circuit state
24
+ */
25
+ getState() {
26
+ if (this.state === "open" && Date.now() - this.lastFailureTime >= this.options.resetTimeout) {
27
+ this.state = "half_open";
28
+ this.successCount = 0;
29
+ }
30
+ return this.state;
31
+ }
32
+ /**
33
+ * Check if circuit allows execution
34
+ */
35
+ canExecute() {
36
+ const state = this.getState();
37
+ return state === "closed" || state === "half_open";
38
+ }
39
+ /**
40
+ * Record a successful execution
41
+ */
42
+ recordSuccess() {
43
+ if (this.state === "half_open") {
44
+ this.successCount++;
45
+ if (this.successCount >= this.options.successThreshold) {
46
+ this.state = "closed";
47
+ this.failures = 0;
48
+ this.successCount = 0;
49
+ }
50
+ } else if (this.state === "closed") {
51
+ this.failures = 0;
52
+ }
53
+ }
54
+ /**
55
+ * Record a failed execution
56
+ */
57
+ recordFailure() {
58
+ this.failures++;
59
+ this.lastFailureTime = Date.now();
60
+ if (this.state === "half_open") {
61
+ this.state = "open";
62
+ this.successCount = 0;
63
+ } else if (this.failures >= this.options.failureThreshold) {
64
+ this.state = "open";
65
+ }
66
+ }
67
+ /**
68
+ * Reset the circuit breaker
69
+ */
70
+ reset() {
71
+ this.state = "closed";
72
+ this.failures = 0;
73
+ this.successCount = 0;
74
+ this.lastFailureTime = 0;
75
+ }
76
+ }
77
+ function calculateBackoff(attempt, options = {}) {
78
+ const initialDelay = options.initialDelay ?? 1e3;
79
+ const maxDelay = options.maxDelay ?? 3e4;
80
+ const backoffFactor = options.backoffFactor ?? 2;
81
+ const jitter = options.jitter ?? true;
82
+ const jitterFactor = options.jitterFactor ?? 0.1;
83
+ let delay = initialDelay * Math.pow(backoffFactor, attempt - 1);
84
+ delay = Math.min(delay, maxDelay);
85
+ if (jitter) {
86
+ const jitterAmount = delay * jitterFactor;
87
+ delay = delay + (Math.random() * 2 - 1) * jitterAmount;
88
+ }
89
+ return Math.round(delay);
90
+ }
91
+ function sleep(ms, signal) {
92
+ return new Promise((resolve, reject) => {
93
+ if (signal?.aborted) {
94
+ reject(new Error("Aborted"));
95
+ return;
96
+ }
97
+ const timeout = setTimeout(resolve, ms);
98
+ signal?.addEventListener("abort", () => {
99
+ clearTimeout(timeout);
100
+ reject(new Error("Aborted"));
101
+ });
102
+ });
103
+ }
104
+ async function withRetry(operation, options = {}) {
105
+ const maxRetries = options.maxRetries ?? 3;
106
+ const isRetryable = options.isRetryable ?? isRetryableError;
107
+ const startTime = Date.now();
108
+ let attempt = 0;
109
+ let lastError;
110
+ while (attempt <= maxRetries) {
111
+ try {
112
+ if (options.signal?.aborted) {
113
+ throw new Error("Operation aborted");
114
+ }
115
+ const value = await operation();
116
+ return {
117
+ success: true,
118
+ value,
119
+ attempts: attempt + 1,
120
+ totalTime: Date.now() - startTime
121
+ };
122
+ } catch (error) {
123
+ const classified = classifyError(error);
124
+ lastError = classified;
125
+ attempt++;
126
+ if (attempt > maxRetries) {
127
+ break;
128
+ }
129
+ if (!isRetryable(error)) {
130
+ break;
131
+ }
132
+ let delay = calculateBackoff(attempt, options);
133
+ if (isRateLimitError(error) && classified.suggestedDelay > delay) {
134
+ delay = classified.suggestedDelay;
135
+ }
136
+ options.onRetry?.(classified, attempt, delay);
137
+ try {
138
+ await sleep(delay, options.signal);
139
+ } catch {
140
+ break;
141
+ }
142
+ }
143
+ }
144
+ return {
145
+ success: false,
146
+ error: lastError,
147
+ attempts: attempt,
148
+ totalTime: Date.now() - startTime
149
+ };
150
+ }
151
+ async function retry(operation, options = {}) {
152
+ const result = await withRetry(operation, options);
153
+ if (result.success) {
154
+ return result.value;
155
+ }
156
+ throw result.error?.original ?? new Error("Operation failed");
157
+ }
158
+ async function withFallback(operations, options = {}) {
159
+ if (operations.length === 0) {
160
+ if (options.defaultValue !== void 0) {
161
+ return options.defaultValue;
162
+ }
163
+ throw new Error("No fallback operations provided");
164
+ }
165
+ let lastError;
166
+ for (let i = 0; i < operations.length; i++) {
167
+ try {
168
+ if (options.signal?.aborted) {
169
+ throw new Error("Operation aborted");
170
+ }
171
+ return await operations[i]();
172
+ } catch (error) {
173
+ const classified = classifyError(error);
174
+ lastError = classified;
175
+ options.onFallback?.(classified, i);
176
+ }
177
+ }
178
+ if (options.defaultValue !== void 0) {
179
+ return options.defaultValue;
180
+ }
181
+ throw lastError?.original ?? new Error("All fallback operations failed");
182
+ }
183
+ async function withCircuitBreaker(operation, breaker) {
184
+ if (!breaker.canExecute()) {
185
+ throw new Error("Circuit breaker is open");
186
+ }
187
+ try {
188
+ const result = await operation();
189
+ breaker.recordSuccess();
190
+ return result;
191
+ } catch (error) {
192
+ breaker.recordFailure();
193
+ throw error;
194
+ }
195
+ }
196
+ function retryable(fn, options = {}) {
197
+ return (...args) => retry(() => fn(...args), options);
198
+ }
199
+ class RetriesExhaustedError extends Error {
200
+ lastError;
201
+ attempts;
202
+ constructor(lastError, attempts) {
203
+ super(`All ${attempts} retry attempts exhausted: ${lastError.message}`);
204
+ this.name = "RetriesExhaustedError";
205
+ this.lastError = lastError;
206
+ this.attempts = attempts;
207
+ }
208
+ }
209
+ class CircuitOpenError extends Error {
210
+ constructor(message = "Circuit breaker is open") {
211
+ super(message);
212
+ this.name = "CircuitOpenError";
213
+ }
214
+ }
215
+ export {
216
+ CircuitBreaker,
217
+ CircuitOpenError,
218
+ CircuitState,
219
+ RetriesExhaustedError,
220
+ calculateBackoff,
221
+ retry,
222
+ retryable,
223
+ sleep,
224
+ withCircuitBreaker,
225
+ withFallback,
226
+ withRetry
227
+ };
228
+ //# sourceMappingURL=error-recovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-recovery.js","sources":["../../src/utils/error-recovery.ts"],"sourcesContent":["/**\n * Error Recovery System\n *\n * Provides intelligent retry strategies with exponential backoff,\n * jitter, and circuit breaker patterns. Based on weaver recovery patterns.\n *\n * @module utils/error-recovery\n */\n\nimport {\n classifyError,\n ErrorCategory,\n type ClassifiedError,\n isRetryableError,\n isRateLimitError,\n} from './error-taxonomy.js';\n\n/**\n * Retry configuration options\n */\nexport interface RetryOptions {\n /** Maximum number of retry attempts (default: 3) */\n maxRetries?: number;\n\n /** Initial delay in milliseconds (default: 1000) */\n initialDelay?: number;\n\n /** Maximum delay in milliseconds (default: 30000) */\n maxDelay?: number;\n\n /** Backoff factor for exponential backoff (default: 2) */\n backoffFactor?: number;\n\n /** Whether to add random jitter (default: true) */\n jitter?: boolean;\n\n /** Jitter factor (0-1, default: 0.1) */\n jitterFactor?: number;\n\n /** Custom function to determine if error is retryable */\n isRetryable?: (error: unknown) => boolean;\n\n /** Called before each retry attempt */\n onRetry?: (error: ClassifiedError, attempt: number, delay: number) => void;\n\n /** Abort signal for cancellation */\n signal?: AbortSignal;\n}\n\n/**\n * Result of a retry operation\n */\nexport interface RetryResult<T> {\n /** Whether the operation succeeded */\n success: boolean;\n\n /** The result value (if successful) */\n value?: T;\n\n /** The final error (if failed) */\n error?: ClassifiedError;\n\n /** Number of attempts made */\n attempts: number;\n\n /** Total time spent in milliseconds */\n totalTime: number;\n}\n\n/**\n * Circuit breaker state\n */\nexport enum CircuitState {\n CLOSED = 'closed',\n OPEN = 'open',\n HALF_OPEN = 'half_open',\n}\n\n/**\n * Circuit breaker configuration\n */\nexport interface CircuitBreakerOptions {\n /** Number of failures before opening circuit (default: 5) */\n failureThreshold?: number;\n\n /** Time in ms before testing circuit again (default: 30000) */\n resetTimeout?: number;\n\n /** Number of successful tests before fully closing (default: 2) */\n successThreshold?: number;\n\n /** Whether to track errors by type (default: false) */\n trackByErrorType?: boolean;\n}\n\n/**\n * Circuit breaker for protecting against cascading failures\n */\nexport class CircuitBreaker {\n private state = CircuitState.CLOSED;\n private failures = 0;\n private successCount = 0;\n private lastFailureTime = 0;\n private readonly options: Required<CircuitBreakerOptions>;\n\n constructor(options: CircuitBreakerOptions = {}) {\n this.options = {\n failureThreshold: options.failureThreshold ?? 5,\n resetTimeout: options.resetTimeout ?? 30000,\n successThreshold: options.successThreshold ?? 2,\n trackByErrorType: options.trackByErrorType ?? false,\n };\n }\n\n /**\n * Get current circuit state\n */\n getState(): CircuitState {\n // Check if we should transition from OPEN to HALF_OPEN\n if (\n this.state === CircuitState.OPEN &&\n Date.now() - this.lastFailureTime >= this.options.resetTimeout\n ) {\n this.state = CircuitState.HALF_OPEN;\n this.successCount = 0;\n }\n return this.state;\n }\n\n /**\n * Check if circuit allows execution\n */\n canExecute(): boolean {\n const state = this.getState();\n return state === CircuitState.CLOSED || state === CircuitState.HALF_OPEN;\n }\n\n /**\n * Record a successful execution\n */\n recordSuccess(): void {\n if (this.state === CircuitState.HALF_OPEN) {\n this.successCount++;\n if (this.successCount >= this.options.successThreshold) {\n this.state = CircuitState.CLOSED;\n this.failures = 0;\n this.successCount = 0;\n }\n } else if (this.state === CircuitState.CLOSED) {\n // Reset failures on success\n this.failures = 0;\n }\n }\n\n /**\n * Record a failed execution\n */\n recordFailure(): void {\n this.failures++;\n this.lastFailureTime = Date.now();\n\n if (this.state === CircuitState.HALF_OPEN) {\n // Any failure in half-open returns to open\n this.state = CircuitState.OPEN;\n this.successCount = 0;\n } else if (this.failures >= this.options.failureThreshold) {\n this.state = CircuitState.OPEN;\n }\n }\n\n /**\n * Reset the circuit breaker\n */\n reset(): void {\n this.state = CircuitState.CLOSED;\n this.failures = 0;\n this.successCount = 0;\n this.lastFailureTime = 0;\n }\n}\n\n/**\n * Calculate delay with exponential backoff\n *\n * @param attempt - The current attempt number (1-based)\n * @param options - Retry options\n * @returns Delay in milliseconds\n */\nexport function calculateBackoff(\n attempt: number,\n options: Pick<RetryOptions, 'initialDelay' | 'maxDelay' | 'backoffFactor' | 'jitter' | 'jitterFactor'> = {}\n): number {\n const initialDelay = options.initialDelay ?? 1000;\n const maxDelay = options.maxDelay ?? 30000;\n const backoffFactor = options.backoffFactor ?? 2;\n const jitter = options.jitter ?? true;\n const jitterFactor = options.jitterFactor ?? 0.1;\n\n // Calculate exponential delay\n let delay = initialDelay * Math.pow(backoffFactor, attempt - 1);\n\n // Cap at maximum\n delay = Math.min(delay, maxDelay);\n\n // Add jitter if enabled\n if (jitter) {\n const jitterAmount = delay * jitterFactor;\n delay = delay + (Math.random() * 2 - 1) * jitterAmount;\n }\n\n return Math.round(delay);\n}\n\n/**\n * Sleep for specified duration\n *\n * @param ms - Duration in milliseconds\n * @param signal - Optional abort signal\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(new Error('Aborted'));\n return;\n }\n\n const timeout = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', () => {\n clearTimeout(timeout);\n reject(new Error('Aborted'));\n });\n });\n}\n\n/**\n * Execute operation with automatic retry\n *\n * @param operation - The async operation to execute\n * @param options - Retry configuration\n * @returns Result containing value or error\n *\n * @example\n * ```typescript\n * const result = await withRetry(\n * () => fetchData(),\n * { maxRetries: 5, onRetry: (err, attempt) => console.log(`Retry ${attempt}`) }\n * );\n *\n * if (result.success) {\n * console.log('Data:', result.value);\n * } else {\n * console.error('Failed after', result.attempts, 'attempts');\n * }\n * ```\n */\nexport async function withRetry<T>(\n operation: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<RetryResult<T>> {\n const maxRetries = options.maxRetries ?? 3;\n const isRetryable = options.isRetryable ?? isRetryableError;\n\n const startTime = Date.now();\n let attempt = 0;\n let lastError: ClassifiedError | undefined;\n\n while (attempt <= maxRetries) {\n try {\n // Check for abort\n if (options.signal?.aborted) {\n throw new Error('Operation aborted');\n }\n\n const value = await operation();\n return {\n success: true,\n value,\n attempts: attempt + 1,\n totalTime: Date.now() - startTime,\n };\n } catch (error) {\n const classified = classifyError(error);\n lastError = classified;\n attempt++;\n\n // Don't retry if we've exhausted attempts\n if (attempt > maxRetries) {\n break;\n }\n\n // Don't retry non-retryable errors\n if (!isRetryable(error)) {\n break;\n }\n\n // Calculate delay\n let delay = calculateBackoff(attempt, options);\n\n // Use suggested delay for rate limits (often includes Retry-After header)\n if (isRateLimitError(error) && classified.suggestedDelay > delay) {\n delay = classified.suggestedDelay;\n }\n\n // Notify about retry\n options.onRetry?.(classified, attempt, delay);\n\n // Wait before retry\n try {\n await sleep(delay, options.signal);\n } catch {\n // Aborted during sleep\n break;\n }\n }\n }\n\n return {\n success: false,\n error: lastError,\n attempts: attempt,\n totalTime: Date.now() - startTime,\n };\n}\n\n/**\n * Execute operation with automatic retry (throws on failure)\n *\n * @param operation - The async operation to execute\n * @param options - Retry configuration\n * @returns The operation result\n * @throws The last error if all retries fail\n *\n * @example\n * ```typescript\n * try {\n * const data = await retry(() => fetchData(), { maxRetries: 3 });\n * console.log('Data:', data);\n * } catch (error) {\n * console.error('All retries failed:', error);\n * }\n * ```\n */\nexport async function retry<T>(\n operation: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const result = await withRetry(operation, options);\n\n if (result.success) {\n return result.value as T;\n }\n\n // Throw the original error\n throw result.error?.original ?? new Error('Operation failed');\n}\n\n/**\n * Fallback chain options\n */\nexport interface FallbackOptions<T> {\n /** Called when primary operation fails */\n onFallback?: (error: ClassifiedError, index: number) => void;\n\n /** Abort signal */\n signal?: AbortSignal;\n\n /** Default value if all operations fail */\n defaultValue?: T;\n}\n\n/**\n * Execute with fallback chain\n *\n * Tries each operation in sequence until one succeeds.\n *\n * @param operations - Array of fallback operations\n * @param options - Fallback configuration\n * @returns The first successful result or default value\n *\n * @example\n * ```typescript\n * const data = await withFallback(\n * [\n * () => fetchFromPrimary(),\n * () => fetchFromSecondary(),\n * () => fetchFromCache(),\n * ],\n * { defaultValue: { cached: true, data: [] } }\n * );\n * ```\n */\nexport async function withFallback<T>(\n operations: Array<() => Promise<T>>,\n options: FallbackOptions<T> = {}\n): Promise<T> {\n if (operations.length === 0) {\n if (options.defaultValue !== undefined) {\n return options.defaultValue;\n }\n throw new Error('No fallback operations provided');\n }\n\n let lastError: ClassifiedError | undefined;\n\n for (let i = 0; i < operations.length; i++) {\n try {\n if (options.signal?.aborted) {\n throw new Error('Operation aborted');\n }\n\n return await operations[i]();\n } catch (error) {\n const classified = classifyError(error);\n lastError = classified;\n options.onFallback?.(classified, i);\n }\n }\n\n if (options.defaultValue !== undefined) {\n return options.defaultValue;\n }\n\n throw lastError?.original ?? new Error('All fallback operations failed');\n}\n\n/**\n * Execute with circuit breaker\n *\n * @param operation - The operation to execute\n * @param breaker - Circuit breaker instance\n * @returns The operation result\n * @throws If circuit is open or operation fails\n */\nexport async function withCircuitBreaker<T>(\n operation: () => Promise<T>,\n breaker: CircuitBreaker\n): Promise<T> {\n if (!breaker.canExecute()) {\n throw new Error('Circuit breaker is open');\n }\n\n try {\n const result = await operation();\n breaker.recordSuccess();\n return result;\n } catch (error) {\n breaker.recordFailure();\n throw error;\n }\n}\n\n/**\n * Create a retryable version of an async function\n *\n * @param fn - The async function to wrap\n * @param options - Default retry options\n * @returns A new function that automatically retries on failure\n *\n * @example\n * ```typescript\n * const fetchWithRetry = retryable(\n * (url: string) => fetch(url),\n * { maxRetries: 3 }\n * );\n *\n * const response = await fetchWithRetry('https://api.example.com/data');\n * ```\n */\nexport function retryable<TArgs extends unknown[], TResult>(\n fn: (...args: TArgs) => Promise<TResult>,\n options: RetryOptions = {}\n): (...args: TArgs) => Promise<TResult> {\n return (...args: TArgs) => retry(() => fn(...args), options);\n}\n\n/**\n * Error class for retries exhausted\n */\nexport class RetriesExhaustedError extends Error {\n public readonly lastError: ClassifiedError;\n public readonly attempts: number;\n\n constructor(lastError: ClassifiedError, attempts: number) {\n super(`All ${attempts} retry attempts exhausted: ${lastError.message}`);\n this.name = 'RetriesExhaustedError';\n this.lastError = lastError;\n this.attempts = attempts;\n }\n}\n\n/**\n * Error class for circuit breaker open\n */\nexport class CircuitOpenError extends Error {\n constructor(message = 'Circuit breaker is open') {\n super(message);\n this.name = 'CircuitOpenError';\n }\n}\n"],"names":["CircuitState"],"mappings":";AAwEO,IAAK,iCAAAA,kBAAL;AACLA,gBAAA,QAAA,IAAS;AACTA,gBAAA,MAAA,IAAO;AACPA,gBAAA,WAAA,IAAY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C;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,QAAQ,iBAAiB,QAAW;AACtC,WAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,WAAW,YAAY,IAAI,MAAM,gCAAgC;AACzE;AAUA,eAAsB,mBACpB,WACA,SACY;AACZ,MAAI,CAAC,QAAQ,cAAc;AACzB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAEA,MAAI;AACF,UAAM,SAAS,MAAM,UAAA;AACrB,YAAQ,cAAA;AACR,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,cAAA;AACR,UAAM;AAAA,EACR;AACF;AAmBO,SAAS,UACd,IACA,UAAwB,IACc;AACtC,SAAO,IAAI,SAAgB,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG,OAAO;AAC7D;AAKO,MAAM,8BAA8B,MAAM;AAAA,EAC/B;AAAA,EACA;AAAA,EAEhB,YAAY,WAA4B,UAAkB;AACxD,UAAM,OAAO,QAAQ,8BAA8B,UAAU,OAAO,EAAE;AACtE,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AACF;AAKO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,UAAU,2BAA2B;AAC/C,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Error Taxonomy System
3
+ *
4
+ * Provides structured error classification for intelligent retry strategies
5
+ * and graceful degradation. Based on weaver error handling patterns.
6
+ *
7
+ * @module utils/error-taxonomy
8
+ */
9
+ /**
10
+ * Error categories for classification and recovery strategy selection
11
+ */
12
+ export declare enum ErrorCategory {
13
+ /** Transient errors that may succeed on retry (network hiccups, temporary failures) */
14
+ TRANSIENT = "transient",
15
+ /** Permanent errors that won't succeed on retry (invalid input, missing resources) */
16
+ PERMANENT = "permanent",
17
+ /** Rate limit errors requiring backoff (429 responses) */
18
+ RATE_LIMIT = "rate_limit",
19
+ /** Network connectivity errors (DNS, connection refused) */
20
+ NETWORK = "network",
21
+ /** Input validation errors (schema violations, type mismatches) */
22
+ VALIDATION = "validation",
23
+ /** Resource errors (file not found, permissions) */
24
+ RESOURCE = "resource",
25
+ /** Configuration errors (missing config, invalid settings) */
26
+ CONFIGURATION = "configuration",
27
+ /** Timeout errors (operation exceeded time limit) */
28
+ TIMEOUT = "timeout",
29
+ /** Unknown errors that couldn't be classified */
30
+ UNKNOWN = "unknown"
31
+ }
32
+ /**
33
+ * Error severity levels
34
+ */
35
+ export declare enum ErrorSeverity {
36
+ /** Informational - operation can continue */
37
+ INFO = "info",
38
+ /** Warning - operation continues with degraded functionality */
39
+ WARNING = "warning",
40
+ /** Error - operation failed but system stable */
41
+ ERROR = "error",
42
+ /** Critical - operation failed, may affect system stability */
43
+ CRITICAL = "critical",
44
+ /** Fatal - system cannot continue */
45
+ FATAL = "fatal"
46
+ }
47
+ /**
48
+ * Classified error with metadata
49
+ */
50
+ export interface ClassifiedError {
51
+ /** Original error */
52
+ original: Error | unknown;
53
+ /** Classified category */
54
+ category: ErrorCategory;
55
+ /** Error severity */
56
+ severity: ErrorSeverity;
57
+ /** Whether retry is recommended */
58
+ retryable: boolean;
59
+ /** Suggested delay before retry (milliseconds) */
60
+ suggestedDelay: number;
61
+ /** Error message */
62
+ message: string;
63
+ /** Error code if available */
64
+ code?: string;
65
+ /** HTTP status code if applicable */
66
+ statusCode?: number;
67
+ /** Additional context */
68
+ context?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Classify an error into a category with recovery metadata
72
+ *
73
+ * @param error - The error to classify
74
+ * @returns Classified error with recovery recommendations
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * try {
79
+ * await fetchData();
80
+ * } catch (error) {
81
+ * const classified = classifyError(error);
82
+ * if (classified.retryable) {
83
+ * await delay(classified.suggestedDelay);
84
+ * return retry();
85
+ * }
86
+ * throw error;
87
+ * }
88
+ * ```
89
+ */
90
+ export declare function classifyError(error: unknown): ClassifiedError;
91
+ /**
92
+ * Check if an error is retryable
93
+ *
94
+ * @param error - The error to check
95
+ * @returns Whether the error is retryable
96
+ */
97
+ export declare function isRetryableError(error: unknown): boolean;
98
+ /**
99
+ * Check if an error is transient (temporary failure)
100
+ *
101
+ * @param error - The error to check
102
+ * @returns Whether the error is transient
103
+ */
104
+ export declare function isTransientError(error: unknown): boolean;
105
+ /**
106
+ * Check if an error is a rate limit error
107
+ *
108
+ * @param error - The error to check
109
+ * @returns Whether the error is a rate limit error
110
+ */
111
+ export declare function isRateLimitError(error: unknown): boolean;
112
+ /**
113
+ * Check if an error is permanent (won't succeed on retry)
114
+ *
115
+ * @param error - The error to check
116
+ * @returns Whether the error is permanent
117
+ */
118
+ export declare function isPermanentError(error: unknown): boolean;
119
+ /**
120
+ * Custom error class for knowledge graph operations
121
+ */
122
+ export declare class KnowledgeGraphError extends Error {
123
+ readonly category: ErrorCategory;
124
+ readonly severity: ErrorSeverity;
125
+ readonly retryable: boolean;
126
+ readonly code?: string;
127
+ readonly context?: Record<string, unknown>;
128
+ constructor(message: string, options?: {
129
+ category?: ErrorCategory;
130
+ severity?: ErrorSeverity;
131
+ retryable?: boolean;
132
+ code?: string;
133
+ context?: Record<string, unknown>;
134
+ cause?: Error;
135
+ });
136
+ }
137
+ /**
138
+ * Create a validation error
139
+ */
140
+ export declare function createValidationError(message: string, context?: Record<string, unknown>): KnowledgeGraphError;
141
+ /**
142
+ * Create a configuration error
143
+ */
144
+ export declare function createConfigurationError(message: string, context?: Record<string, unknown>): KnowledgeGraphError;
145
+ /**
146
+ * Create a resource error
147
+ */
148
+ export declare function createResourceError(message: string, context?: Record<string, unknown>): KnowledgeGraphError;
149
+ //# sourceMappingURL=error-taxonomy.d.ts.map